Use prop_dictionary_util(3).
This commit is contained in:
parent
cde723377a
commit
fac0aeb0a0
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: af_atalk.c,v 1.9 2008/05/06 16:15:17 dyoung Exp $ */
|
||||
/* $NetBSD: af_atalk.c,v 1.10 2008/05/06 21:16:52 dyoung Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@ -33,7 +33,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: af_atalk.c,v 1.9 2008/05/06 16:15:17 dyoung Exp $");
|
||||
__RCSID("$NetBSD: af_atalk.c,v 1.10 2008/05/06 21:16:52 dyoung Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -96,14 +96,10 @@ setatrange(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
int
|
||||
setatphase(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
{
|
||||
prop_number_t num;
|
||||
|
||||
num = (prop_number_t)prop_dictionary_get(env, "phase");
|
||||
if (num == NULL) {
|
||||
if (!prop_dictionary_get_uint8(env, "phase", &at_nr.nr_phase)) {
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
at_nr.nr_phase = (uint8_t)prop_number_integer_value(num);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: af_inet6.c,v 1.9 2008/05/06 16:15:17 dyoung Exp $ */
|
||||
/* $NetBSD: af_inet6.c,v 1.10 2008/05/06 21:16:52 dyoung Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: af_inet6.c,v 1.9 2008/05/06 16:15:17 dyoung Exp $");
|
||||
__RCSID("$NetBSD: af_inet6.c,v 1.10 2008/05/06 21:16:52 dyoung Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -153,17 +153,13 @@ prefix(void *val, int size)
|
||||
int
|
||||
setia6flags_impl(prop_dictionary_t env, struct in6_aliasreq *ifra)
|
||||
{
|
||||
int ia6flag;
|
||||
prop_number_t num;
|
||||
int64_t ia6flag;
|
||||
|
||||
num = (prop_number_t)prop_dictionary_get(env, "ia6flag");
|
||||
if (num == NULL) {
|
||||
if (!prop_dictionary_get_int64(env, "ia6flag", &ia6flag)) {
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ia6flag = (int)prop_number_integer_value(num);
|
||||
|
||||
if (ia6flag < 0) {
|
||||
ia6flag = -ia6flag;
|
||||
ifra->ifra_flags &= ~ia6flag;
|
||||
@ -181,15 +177,14 @@ setia6flags(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
int
|
||||
setia6pltime_impl(prop_dictionary_t env, struct in6_aliasreq *ifra)
|
||||
{
|
||||
prop_number_t num;
|
||||
int64_t pltime;
|
||||
|
||||
num = (prop_number_t)prop_dictionary_get(env, "pltime");
|
||||
if (num == NULL) {
|
||||
if (!prop_dictionary_get_int64(env, "pltime", &pltime)) {
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return setia6lifetime(env, prop_number_integer_value(num),
|
||||
return setia6lifetime(env, pltime,
|
||||
&ifra->ifra_lifetime.ia6t_preferred,
|
||||
&ifra->ifra_lifetime.ia6t_pltime);
|
||||
}
|
||||
@ -203,15 +198,14 @@ setia6pltime(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
int
|
||||
setia6vltime_impl(prop_dictionary_t env, struct in6_aliasreq *ifra)
|
||||
{
|
||||
prop_number_t num;
|
||||
int64_t vltime;
|
||||
|
||||
num = (prop_number_t)prop_dictionary_get(env, "vltime");
|
||||
if (num == NULL) {
|
||||
if (!prop_dictionary_get_int64(env, "vltime", &vltime)) {
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return setia6lifetime(env, prop_number_integer_value(num),
|
||||
return setia6lifetime(env, vltime,
|
||||
&ifra->ifra_lifetime.ia6t_expire,
|
||||
&ifra->ifra_lifetime.ia6t_vltime);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: af_inetany.c,v 1.3 2008/05/06 17:29:04 dyoung Exp $ */
|
||||
/* $NetBSD: af_inetany.c,v 1.4 2008/05/06 21:16:52 dyoung Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1983, 1993
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#ifndef lint
|
||||
__RCSID("$NetBSD: af_inetany.c,v 1.3 2008/05/06 17:29:04 dyoung Exp $");
|
||||
__RCSID("$NetBSD: af_inetany.c,v 1.4 2008/05/06 21:16:52 dyoung Exp $");
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -143,8 +143,7 @@ commit_address(prop_dictionary_t env, prop_dictionary_t oenv)
|
||||
};
|
||||
#endif
|
||||
int af, rc, s;
|
||||
bool delete, replace;
|
||||
prop_bool_t b;
|
||||
bool alias, delete, replace;
|
||||
prop_data_t d;
|
||||
const struct paddr_prefix *addr, *brd, *dst, *mask;
|
||||
unsigned short flags;
|
||||
@ -229,12 +228,12 @@ commit_address(prop_dictionary_t env, prop_dictionary_t oenv)
|
||||
else
|
||||
brd = NULL;
|
||||
|
||||
if ((b = (prop_bool_t)prop_dictionary_get(env, "alias")) == NULL) {
|
||||
if (!prop_dictionary_get_bool(env, "alias", &alias)) {
|
||||
delete = false;
|
||||
replace = (param->gifaddr.cmd != 0);
|
||||
} else {
|
||||
replace = false;
|
||||
delete = !prop_bool_true(b);
|
||||
delete = !alias;
|
||||
}
|
||||
|
||||
memset(param->req.buf, 0, param->req.buflen);
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: agr.c,v 1.6 2008/05/06 17:29:04 dyoung Exp $ */
|
||||
/* $NetBSD: agr.c,v 1.7 2008/05/06 21:16:52 dyoung Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c)2005 YAMAMOTO Takashi,
|
||||
@ -28,7 +28,7 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#if !defined(lint)
|
||||
__RCSID("$NetBSD: agr.c,v 1.6 2008/05/06 17:29:04 dyoung Exp $");
|
||||
__RCSID("$NetBSD: agr.c,v 1.7 2008/05/06 21:16:52 dyoung Exp $");
|
||||
#endif /* !defined(lint) */
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -76,30 +76,28 @@ agrsetport(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
char buf[IFNAMSIZ];
|
||||
struct agrreq ar;
|
||||
int s;
|
||||
prop_string_t str;
|
||||
prop_number_t num;
|
||||
const char *port;
|
||||
const char *ifname;
|
||||
struct ifreq ifr;
|
||||
int64_t cmd;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
assertifname(ifr.ifr_name);
|
||||
|
||||
num = (prop_number_t)prop_dictionary_get(env, "agrcmd");
|
||||
if (num == NULL) {
|
||||
if (!prop_dictionary_get_int64(env, "agrcmd", &cmd)) {
|
||||
warnx("%s.%d", __func__, __LINE__);
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
str = (prop_string_t)prop_dictionary_get(env, "agrport");
|
||||
if (str == NULL) {
|
||||
if (!prop_dictionary_get_cstring_nocopy(env, "agrport", &port)) {
|
||||
warnx("%s.%d", __func__, __LINE__);
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
strlcpy(buf, prop_string_cstring_nocopy(str), sizeof(buf));
|
||||
strlcpy(buf, port, sizeof(buf));
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
if ((ifname = getifname(env)) == NULL)
|
||||
@ -107,7 +105,7 @@ agrsetport(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
estrlcpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name));
|
||||
memset(&ar, 0, sizeof(ar));
|
||||
ar.ar_version = AGRREQ_VERSION;
|
||||
ar.ar_cmd = (int)prop_number_integer_value(num);
|
||||
ar.ar_cmd = cmd;
|
||||
ar.ar_buf = buf;
|
||||
ar.ar_buflen = strlen(buf);
|
||||
ifr.ifr_data = &ar;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: carp.c,v 1.6 2008/05/06 17:29:04 dyoung Exp $ */
|
||||
/* $NetBSD: carp.c,v 1.7 2008/05/06 21:16:52 dyoung Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2002 Michael Shalayeff. All rights reserved.
|
||||
@ -158,21 +158,17 @@ setcarp_vhid(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
struct carpreq carpr;
|
||||
int vhid;
|
||||
int64_t vhid;
|
||||
int s;
|
||||
prop_number_t num;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
num = (prop_number_t)prop_dictionary_get(env, "vhid");
|
||||
if (num == NULL) {
|
||||
if (!prop_dictionary_get_int64(env, "vhid", &vhid)) {
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
vhid = (int)prop_number_integer_value(num);
|
||||
|
||||
memset(&carpr, 0, sizeof(struct carpreq));
|
||||
ifr.ifr_data = &carpr;
|
||||
|
||||
@ -191,22 +187,18 @@ setcarp_advskew(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
{
|
||||
struct ifreq ifr;
|
||||
struct carpreq carpr;
|
||||
int advskew;
|
||||
int64_t advskew;
|
||||
int s;
|
||||
prop_number_t num;
|
||||
const char *ifname;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
num = (prop_number_t)prop_dictionary_get(env, "advskew");
|
||||
if (num == NULL) {
|
||||
if (!prop_dictionary_get_int64(env, "advskew", &advskew)) {
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
advskew = (int)prop_number_integer_value(num);
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
memset(&carpr, 0, sizeof(carpr));
|
||||
ifr.ifr_data = &carpr;
|
||||
@ -230,23 +222,19 @@ int
|
||||
setcarp_advbase(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
{
|
||||
struct carpreq carpr;
|
||||
int advbase;
|
||||
int64_t advbase;
|
||||
int s;
|
||||
prop_number_t num;
|
||||
struct ifreq ifr;
|
||||
const char *ifname;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
num = (prop_number_t)prop_dictionary_get(env, "advbase");
|
||||
if (num == NULL) {
|
||||
if (!prop_dictionary_get_int64(env, "advbase", &advbase)) {
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
advbase = (int)prop_number_integer_value(num);
|
||||
|
||||
memset(&ifr, 0, sizeof(ifr));
|
||||
memset(&carpr, 0, sizeof(carpr));
|
||||
ifr.ifr_data = &carpr;
|
||||
@ -271,15 +259,14 @@ setcarp_state(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
{
|
||||
struct carpreq carpr;
|
||||
int s;
|
||||
prop_number_t num;
|
||||
struct ifreq ifr;
|
||||
int64_t carp_state;
|
||||
const char *ifname;
|
||||
|
||||
if ((s = getsock(AF_UNSPEC)) == -1)
|
||||
err(EXIT_FAILURE, "%s: getsock", __func__);
|
||||
|
||||
num = (prop_number_t)prop_dictionary_get(env, "carp_state");
|
||||
if (num == NULL) {
|
||||
if (!prop_dictionary_get_int64(env, "carp_state", &carp_state)) {
|
||||
errno = ENOENT;
|
||||
return -1;
|
||||
}
|
||||
@ -295,7 +282,7 @@ setcarp_state(prop_dictionary_t env, prop_dictionary_t xenv)
|
||||
if (ioctl(s, SIOCGVH, &ifr) == -1)
|
||||
err(EXIT_FAILURE, "SIOCGVH");
|
||||
|
||||
carpr.carpr_state = (int)prop_number_integer_value(num);
|
||||
carpr.carpr_state = carp_state;
|
||||
|
||||
if (ioctl(s, SIOCSVH, &ifr) == -1)
|
||||
err(EXIT_FAILURE, "SIOCSVH");
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: parse.c,v 1.2 2008/05/06 16:09:18 dyoung Exp $ */
|
||||
/* $NetBSD: parse.c,v 1.3 2008/05/06 21:13:20 dyoung Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c)2008 David Young. All rights reserved.
|
||||
@ -221,7 +221,7 @@ paddr_match(const struct parser *p, const struct match *im, struct match *om,
|
||||
const struct paddr *pa = (const struct paddr *)p;
|
||||
prop_data_t d;
|
||||
prop_object_t o;
|
||||
prop_number_t num;
|
||||
int64_t af0;
|
||||
int af, rc;
|
||||
struct paddr_prefix *pfx, *mask;
|
||||
const struct sockaddr *sa = NULL;
|
||||
@ -242,9 +242,10 @@ paddr_match(const struct parser *p, const struct match *im, struct match *om,
|
||||
prop_dictionary_get(im->m_env, pa->pa_deactivator) != NULL)
|
||||
return -1;
|
||||
|
||||
num = (prop_number_t)prop_dictionary_get(im->m_env, "af");
|
||||
|
||||
af = (num != NULL) ? (int)prop_number_integer_value(num) : AF_UNSPEC;
|
||||
if (!prop_dictionary_get_int64(im->m_env, "af", &af0))
|
||||
af = AF_UNSPEC;
|
||||
else
|
||||
af = af0;
|
||||
|
||||
switch (af) {
|
||||
case AF_UNSPEC:
|
||||
|
Loading…
x
Reference in New Issue
Block a user