本文整理汇总了C++中prop_dictionary_get函数的典型用法代码示例。如果您正苦于以下问题:C++ prop_dictionary_get函数的具体用法?C++ prop_dictionary_get怎么用?C++ prop_dictionary_get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了prop_dictionary_get函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: settunnel
static int
settunnel(prop_dictionary_t env, prop_dictionary_t oenv)
{
const struct paddr_prefix *srcpfx, *dstpfx;
struct if_laddrreq req;
prop_data_t srcdata, dstdata;
srcdata = (prop_data_t)prop_dictionary_get(env, "tunsrc");
dstdata = (prop_data_t)prop_dictionary_get(env, "tundst");
if (srcdata == NULL || dstdata == NULL) {
warnx("%s.%d", __func__, __LINE__);
errno = ENOENT;
return -1;
}
srcpfx = prop_data_data_nocopy(srcdata);
dstpfx = prop_data_data_nocopy(dstdata);
if (srcpfx->pfx_addr.sa_family != dstpfx->pfx_addr.sa_family)
errx(EXIT_FAILURE,
"source and destination address families do not match");
memset(&req, 0, sizeof(req));
memcpy(&req.addr, &srcpfx->pfx_addr,
MIN(sizeof(req.addr), srcpfx->pfx_addr.sa_len));
memcpy(&req.dstaddr, &dstpfx->pfx_addr,
MIN(sizeof(req.dstaddr), dstpfx->pfx_addr.sa_len));
#ifdef INET6
if (req.addr.ss_family == AF_INET6) {
struct sockaddr_in6 *s6, *d;
s6 = (struct sockaddr_in6 *)&req.addr;
d = (struct sockaddr_in6 *)&req.dstaddr;
if (s6->sin6_scope_id != d->sin6_scope_id) {
errx(EXIT_FAILURE, "scope mismatch");
/* NOTREACHED */
}
if (IN6_IS_ADDR_MULTICAST(&d->sin6_addr) ||
IN6_IS_ADDR_MULTICAST(&s6->sin6_addr))
errx(EXIT_FAILURE, "tunnel src/dst is multicast");
/* embed scopeid */
if (s6->sin6_scope_id &&
IN6_IS_ADDR_LINKLOCAL(&s6->sin6_addr)) {
*(u_int16_t *)&s6->sin6_addr.s6_addr[2] =
htons(s6->sin6_scope_id);
}
if (d->sin6_scope_id && IN6_IS_ADDR_LINKLOCAL(&d->sin6_addr)) {
*(u_int16_t *)&d->sin6_addr.s6_addr[2] =
htons(d->sin6_scope_id);
}
}
#endif /* INET6 */
if (direct_ioctl(env, SIOCSLIFPHYADDR, &req) == -1)
warn("SIOCSLIFPHYADDR");
return 0;
}
示例2: npf_mk_natlist
static int __noinline
npf_mk_natlist(npf_ruleset_t *nset, prop_array_t natlist,
prop_dictionary_t errdict)
{
prop_object_iterator_t it;
prop_dictionary_t natdict;
int error;
/* NAT policies - array. */
if (prop_object_type(natlist) != PROP_TYPE_ARRAY) {
NPF_ERR_DEBUG(errdict);
return EINVAL;
}
error = 0;
it = prop_array_iterator(natlist);
while ((natdict = prop_object_iterator_next(it)) != NULL) {
npf_rule_t *rl = NULL;
npf_natpolicy_t *np;
/* NAT policy - dictionary. */
if (prop_object_type(natdict) != PROP_TYPE_DICTIONARY) {
NPF_ERR_DEBUG(errdict);
error = EINVAL;
break;
}
/*
* NAT policies are standard rules, plus additional
* information for translation. Make a rule.
*/
error = npf_mk_singlerule(natdict, NULL, &rl, errdict);
if (error) {
break;
}
npf_ruleset_insert(nset, rl);
/* If rule is named, it is a group with NAT policies. */
if (prop_dictionary_get(natdict, "name") &&
prop_dictionary_get(natdict, "subrules")) {
continue;
}
/* Allocate a new NAT policy and assign to the rule. */
np = npf_nat_newpolicy(natdict, nset);
if (np == NULL) {
NPF_ERR_DEBUG(errdict);
error = ENOMEM;
break;
}
npf_rule_setnat(rl, np);
}
prop_object_iterator_release(it);
/*
* Note: in a case of error, caller will free entire NAT ruleset
* with assigned NAT policies.
*/
return error;
}
示例3: npf_mk_rules
static int __noinline
npf_mk_rules(npf_ruleset_t *rlset, prop_array_t rules, prop_array_t rprocs,
prop_dictionary_t errdict)
{
prop_object_iterator_t it;
prop_dictionary_t rldict, rpdict;
int error;
/* Rule procedures and the ruleset - arrays. */
if (prop_object_type(rprocs) != PROP_TYPE_ARRAY ||
prop_object_type(rules) != PROP_TYPE_ARRAY) {
NPF_ERR_DEBUG(errdict);
return EINVAL;
}
it = prop_array_iterator(rprocs);
while ((rpdict = prop_object_iterator_next(it)) != NULL) {
if (prop_dictionary_get(rpdict, "rproc-ptr")) {
prop_object_iterator_release(it);
NPF_ERR_DEBUG(errdict);
return EINVAL;
}
}
prop_object_iterator_release(it);
error = 0;
it = prop_array_iterator(rules);
while ((rldict = prop_object_iterator_next(it)) != NULL) {
prop_array_t subrules;
npf_ruleset_t *rlsetsub;
npf_rule_t *rl;
/* Generate a single rule. */
error = npf_mk_singlerule(rldict, rprocs, &rl, errdict);
if (error) {
break;
}
npf_ruleset_insert(rlset, rl);
/* Check for sub-rules and generate, if any. */
subrules = prop_dictionary_get(rldict, "subrules");
if (subrules == NULL) {
/* No subrules, next.. */
continue;
}
rlsetsub = npf_rule_subset(rl);
error = npf_mk_subrules(rlsetsub, subrules, rprocs, errdict);
if (error)
break;
}
prop_object_iterator_release(it);
/*
* Note: in a case of error, caller will free the ruleset.
*/
return error;
}
示例4: xbps_pkg_find_conflicts
void HIDDEN
xbps_pkg_find_conflicts(struct xbps_handle *xhp, prop_dictionary_t pkg_repod)
{
prop_array_t pkg_cflicts, trans_cflicts;
prop_dictionary_t pkgd;
const char *cfpkg, *repopkgver, *pkgver;
char *buf;
size_t i;
pkg_cflicts = prop_dictionary_get(pkg_repod, "conflicts");
if (pkg_cflicts == NULL || prop_array_count(pkg_cflicts) == 0)
return;
trans_cflicts = prop_dictionary_get(xhp->transd, "conflicts");
prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &repopkgver);
for (i = 0; i < prop_array_count(pkg_cflicts); i++) {
prop_array_get_cstring_nocopy(pkg_cflicts, i, &cfpkg);
/*
* Check if current pkg conflicts with an installed package.
*/
if ((pkgd = xbps_pkgdb_get_pkgd(xhp, cfpkg, true))) {
prop_dictionary_get_cstring_nocopy(pkgd,
"pkgver", &pkgver);
buf = xbps_xasprintf("%s conflicts with "
"installed pkg %s", repopkgver, pkgver);
assert(buf != NULL);
prop_array_add_cstring(trans_cflicts, buf);
free(buf);
continue;
}
/*
* Check if current pkg conflicts with any pkg in transaction.
*/
pkgd = xbps_find_pkg_in_dict_by_pattern(xhp, xhp->transd,
"unsorted_deps", cfpkg);
if (pkgd != NULL) {
prop_dictionary_get_cstring_nocopy(pkgd,
"pkgver", &pkgver);
buf = xbps_xasprintf("%s conflicts with "
"%s in transaction", repopkgver, pkgver);
assert(buf != NULL);
prop_array_add_cstring(trans_cflicts, buf);
free(buf);
continue;
}
}
}
示例5: acpi_debug_sysctl_level
static int
acpi_debug_sysctl_level(SYSCTLFN_ARGS)
{
char buf[ACPI_DEBUG_MAX];
struct sysctlnode node;
prop_object_t obj;
int error;
node = *rnode;
node.sysctl_data = buf;
(void)memcpy(node.sysctl_data, rnode->sysctl_data, ACPI_DEBUG_MAX);
error = sysctl_lookup(SYSCTLFN_CALL(&node));
if (error || newp == NULL)
return error;
obj = prop_dictionary_get(acpi_debug_level_d, node.sysctl_data);
if (obj == NULL)
return EINVAL;
AcpiDbgLevel = prop_number_unsigned_integer_value(obj);
(void)memcpy(rnode->sysctl_data, node.sysctl_data, ACPI_DEBUG_MAX);
return 0;
}
示例6: dm_cmd_to_fun
/*
* Translate command sent from libdevmapper to func.
*/
static int
dm_cmd_to_fun(prop_dictionary_t dm_dict) {
int i, r;
prop_string_t command;
r = 0;
if ((command = prop_dictionary_get(dm_dict, DM_IOCTL_COMMAND)) == NULL)
return EINVAL;
for(i = 0; cmd_fn[i].cmd != NULL; i++)
if (prop_string_equals_cstring(command, cmd_fn[i].cmd))
break;
if (!cmd_fn[i].allowed &&
(r = kauth_authorize_system(kauth_cred_get(),
KAUTH_SYSTEM_DEVMAPPER, 0, NULL, NULL, NULL)) != 0)
return r;
if (cmd_fn[i].cmd == NULL)
return EINVAL;
aprint_debug("ioctl %s called\n", cmd_fn[i].cmd);
r = cmd_fn[i].fn(dm_dict);
return r;
}
示例7: npfctl_sessions_load
/*
* npfctl_sessions_load: import a list of sessions, reconstruct them and load.
*/
int
npfctl_sessions_load(u_long cmd, void *data)
{
const struct plistref *pref = data;
npf_sehash_t *sehasht = NULL;
prop_dictionary_t sesdict, sedict;
prop_object_iterator_t it;
prop_array_t selist;
int error;
/* Retrieve the dictionary containing session and NAT policy lists. */
error = prop_dictionary_copyin_ioctl(pref, cmd, &sesdict);
if (error)
return error;
/*
* Note: session objects contain the references to the NAT policy
* entries. Therefore, no need to directly access it.
*/
selist = prop_dictionary_get(sesdict, "session-list");
if (prop_object_type(selist) != PROP_TYPE_ARRAY) {
error = EINVAL;
goto fail;
}
/* Create a session hash table. */
sehasht = sess_htable_create();
if (sehasht == NULL) {
error = ENOMEM;
goto fail;
}
/*
* Iterate through and construct each session.
*/
error = 0;
it = prop_array_iterator(selist);
npf_core_enter();
while ((sedict = prop_object_iterator_next(it)) != NULL) {
/* Session - dictionary. */
if (prop_object_type(sedict) != PROP_TYPE_DICTIONARY) {
error = EINVAL;
goto fail;
}
/* Construct and insert real session structure. */
error = npf_session_restore(sehasht, sedict);
if (error) {
goto fail;
}
}
npf_core_exit();
sess_htable_reload(sehasht);
fail:
prop_object_release(selist);
if (error && sehasht) {
/* Destroy session table. */
sess_htable_destroy(sehasht);
}
return error;
}
示例8: npfctl_remove_rule
int
npfctl_remove_rule(u_long cmd, void *data)
{
struct plistref *pref = data;
prop_dictionary_t dict, errdict;
prop_object_t obj;
const char *name;
int error, numrules;
/* Retrieve and construct the rule. */
error = prop_dictionary_copyin_ioctl(pref, cmd, &dict);
if (error) {
return error;
}
/* Dictionary for error reporting. */
errdict = prop_dictionary_create();
obj = prop_dictionary_get(dict, "name");
name = prop_string_cstring_nocopy(obj);
npf_rule_t *rl;
error = npf_mk_singlerule(dict, prop_array_create(), &rl, errdict);
npf_core_enter();
numrules = npf_named_ruleset_remove(name, npf_core_ruleset(), rl);
npf_core_exit();
prop_object_release(dict);
/* Error report. */
prop_dictionary_set_int32(errdict, "errno", error);
prop_dictionary_set_int32(errdict, "numrules", numrules);
prop_dictionary_copyout_ioctl(pref, cmd, errdict);
prop_object_release(errdict);
return error;
}
示例9: npf_mk_table_entries
static int __noinline
npf_mk_table_entries(npf_table_t *t, prop_array_t entries)
{
prop_object_iterator_t eit;
prop_dictionary_t ent;
int error = 0;
if (prop_object_type(entries) != PROP_TYPE_ARRAY) {
return EINVAL;
}
eit = prop_array_iterator(entries);
while ((ent = prop_object_iterator_next(eit)) != NULL) {
const npf_addr_t *addr;
npf_netmask_t mask;
int alen;
/* Get address and mask. Add a table entry. */
prop_object_t obj = prop_dictionary_get(ent, "addr");
addr = (const npf_addr_t *)prop_data_data_nocopy(obj);
prop_dictionary_get_uint8(ent, "mask", &mask);
alen = prop_data_size(obj);
error = npf_table_insert(t, alen, addr, mask);
if (error)
break;
}
prop_object_iterator_release(eit);
return error;
}
示例10: npf_mk_singlerproc
static npf_rproc_t *
npf_mk_singlerproc(prop_dictionary_t rpdict)
{
prop_object_iterator_t it;
prop_dictionary_t extdict;
prop_array_t extlist;
npf_rproc_t *rp;
extlist = prop_dictionary_get(rpdict, "extcalls");
if (prop_object_type(extlist) != PROP_TYPE_ARRAY) {
return NULL;
}
rp = npf_rproc_create(rpdict);
if (rp == NULL) {
return NULL;
}
it = prop_array_iterator(extlist);
while ((extdict = prop_object_iterator_next(it)) != NULL) {
const char *name;
if (!prop_dictionary_get_cstring_nocopy(extdict,
"name", &name) || npf_ext_construct(name, rp, extdict)) {
npf_rproc_release(rp);
rp = NULL;
break;
}
}
prop_object_iterator_release(it);
return rp;
}
示例11: via_mapchan
static void
via_mapchan(const struct pci_attach_args *pa, struct pciide_channel *cp,
pcireg_t interface, int (*pci_intr)(void *))
{
struct ata_channel *wdc_cp;
struct pciide_softc *sc;
prop_bool_t compat_nat_enable;
wdc_cp = &cp->ata_channel;
sc = CHAN_TO_PCIIDE(&cp->ata_channel);
compat_nat_enable = prop_dictionary_get(
device_properties(sc->sc_wdcdev.sc_atac.atac_dev),
"use-compat-native-irq");
if (interface & PCIIDE_INTERFACE_PCI(wdc_cp->ch_channel)) {
/* native mode with irq 14/15 requested? */
if (compat_nat_enable != NULL &&
prop_bool_true(compat_nat_enable))
via_mapregs_compat_native(pa, cp);
else
pciide_mapregs_native(pa, cp, pci_intr);
} else {
pciide_mapregs_compat(pa, cp, wdc_cp->ch_channel);
if ((cp->ata_channel.ch_flags & ATACH_DISABLED) == 0)
pciide_map_compat_intr(pa, cp, wdc_cp->ch_channel);
}
wdcattach(wdc_cp);
}
示例12: ibm4xx_device_register
void
ibm4xx_device_register(struct device *dev, void *aux)
{
struct device *parent = device_parent(dev);
if (device_is_a(dev, "emac") && device_is_a(parent, "opb")) {
/* Set the mac-addr of the on-chip Ethernet. */
struct opb_attach_args *oaa = aux;
if (oaa->opb_instance < 10) {
prop_data_t pd;
unsigned char prop_name[15];
snprintf(prop_name, sizeof(prop_name),
"emac%d-mac-addr", oaa->opb_instance);
pd = prop_dictionary_get(board_properties, prop_name);
if (pd == NULL) {
printf("WARNING: unable to get mac-addr "
"property from board properties\n");
return;
}
if (prop_dictionary_set(device_properties(dev),
"mac-addr", pd) == false) {
printf("WARNING: unable to set mac-addr "
"property for %s\n", dev->dv_xname);
}
}
return;
}
}
示例13: npfctl_update_rule
/*
* npfctl_update_rule: reload a specific rule identified by the name.
*/
int
npfctl_update_rule(u_long cmd, void *data)
{
struct plistref *pref = data;
prop_dictionary_t dict, errdict;
prop_array_t subrules;
prop_object_t obj;
npf_ruleset_t *rlset;
const char *name;
int error;
/* Retrieve and construct the rule. */
error = prop_dictionary_copyin_ioctl(pref, cmd, &dict);
if (error) {
return error;
}
/* Dictionary for error reporting. */
errdict = prop_dictionary_create();
/* Create the ruleset and construct sub-rules. */
rlset = npf_ruleset_create();
subrules = prop_dictionary_get(dict, "subrules");
error = npf_mk_subrules(rlset, subrules, NULL, errdict);
if (error) {
goto out;
}
/* Lookup the rule by name, and replace its subset (sub-rules). */
obj = prop_dictionary_get(dict, "name");
name = prop_string_cstring_nocopy(obj);
if (npf_ruleset_replace(name, rlset) == NULL) {
/* Not found. */
error = ENOENT;
out: /* Error path. */
npf_ruleset_destroy(rlset);
}
prop_object_release(dict);
/* Error report. */
prop_dictionary_set_int32(errdict, "errno", error);
prop_dictionary_copyout_ioctl(pref, cmd, errdict);
prop_object_release(errdict);
return error;
}
示例14: npf_mk_singlerule
static int __noinline
npf_mk_singlerule(prop_dictionary_t rldict, npf_rprocset_t *rpset,
npf_rule_t **rlret, prop_dictionary_t errdict)
{
npf_rule_t *rl;
const char *rname;
prop_object_t obj;
int p, error = 0;
/* Rule - dictionary. */
if (prop_object_type(rldict) != PROP_TYPE_DICTIONARY) {
NPF_ERR_DEBUG(errdict);
return EINVAL;
}
if ((rl = npf_rule_alloc(rldict)) == NULL) {
NPF_ERR_DEBUG(errdict);
return EINVAL;
}
/* Assign rule procedure, if any. */
if (prop_dictionary_get_cstring_nocopy(rldict, "rproc", &rname)) {
npf_rproc_t *rp;
if (rpset == NULL) {
error = EINVAL;
goto err;
}
if ((rp = npf_rprocset_lookup(rpset, rname)) == NULL) {
NPF_ERR_DEBUG(errdict);
error = EINVAL;
goto err;
}
npf_rule_setrproc(rl, rp);
}
/* Filter code (binary data). */
if ((obj = prop_dictionary_get(rldict, "code")) != NULL) {
int type;
size_t len;
void *code;
prop_dictionary_get_int32(rldict, "code-type", &type);
error = npf_mk_code(obj, type, &code, &len, errdict);
if (error) {
goto err;
}
npf_rule_setcode(rl, type, code, len);
}
*rlret = rl;
return 0;
err:
npf_rule_free(rl);
prop_dictionary_get_int32(rldict, "prio", &p); /* XXX */
prop_dictionary_set_int32(errdict, "id", p);
return error;
}
示例15: dm_dev_rename_ioctl
/*
* Rename selected devices old name is in struct dm_ioctl.
* newname is taken from dictionary
*
* <key>cmd_data</key>
* <array>
* <string>...</string>
* </array>
*/
int
dm_dev_rename_ioctl(prop_dictionary_t dm_dict)
{
#if 0
prop_array_t cmd_array;
dm_dev_t *dmv;
const char *name, *uuid, *n_name;
uint32_t flags, minor;
name = NULL;
uuid = NULL;
minor = 0;
/* Get needed values from dictionary. */
prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_NAME, &name);
prop_dictionary_get_cstring_nocopy(dm_dict, DM_IOCTL_UUID, &uuid);
prop_dictionary_get_uint32(dm_dict, DM_IOCTL_FLAGS, &flags);
prop_dictionary_get_uint32(dm_dict, DM_IOCTL_MINOR, &minor);
dm_dbg_print_flags(flags);
cmd_array = prop_dictionary_get(dm_dict, DM_IOCTL_CMD_DATA);
prop_array_get_cstring_nocopy(cmd_array, 0, &n_name);
if (strlen(n_name) + 1 > DM_NAME_LEN)
return EINVAL;
if ((dmv = dm_dev_rem(NULL, name, uuid, minor)) == NULL) {
DM_REMOVE_FLAG(flags, DM_EXISTS_FLAG);
return ENOENT;
}
/* change device name */
/*
* XXX How to deal with this change, name only used in
* dm_dev_routines, should I add dm_dev_change_name which will run
* under the dm_dev_list mutex ?
*/
strlcpy(dmv->name, n_name, DM_NAME_LEN);
prop_dictionary_set_uint32(dm_dict, DM_IOCTL_OPEN, dmv->table_head.io_cnt);
prop_dictionary_set_uint32(dm_dict, DM_IOCTL_MINOR, dmv->minor);
prop_dictionary_set_cstring(dm_dict, DM_IOCTL_UUID, dmv->uuid);
dm_dev_insert(dmv);
#endif
/*
* XXX: the rename is not yet implemented. The main complication
* here is devfs. We'd probably need a new function, rename_dev()
* that would trigger a node rename in devfs.
*/
kprintf("dm_dev_rename_ioctl called, but not implemented!\n");
return 0;
}