Page MenuHomeFreeBSD

D40239.id122319.diff
No OneTemporary

D40239.id122319.diff

diff --git a/sbin/ifconfig/af_inet.c b/sbin/ifconfig/af_inet.c
--- a/sbin/ifconfig/af_inet.c
+++ b/sbin/ifconfig/af_inet.c
@@ -83,7 +83,7 @@
#ifdef WITHOUT_NETLINK
static void
-in_status(int s __unused, const struct ifaddrs *ifa)
+in_status(if_ctx *ctx __unused, const struct ifaddrs *ifa)
{
struct sockaddr_in *sin, null_sin = {};
@@ -143,8 +143,7 @@
}
static void
-in_status_nl(struct ifconfig_args *args __unused, struct io_handler *h,
- if_link_t *link, if_addr_t *ifa)
+in_status_nl(if_ctx *ctx __unused, if_link_t *link, if_addr_t *ifa)
{
struct sockaddr_in *sin = satosin(ifa->ifa_local);
int plen = ifa->ifa_prefixlen;
@@ -228,7 +227,7 @@
}
static void
-in_postproc(int s, const struct afswtch *afp, int newaddr, int ifflags)
+in_postproc(if_ctx *ctx __unused, int newaddr, int ifflags)
{
if (sintab[ADDR]->sin_len != 0 && sintab[MASK]->sin_len == 0 &&
newaddr && (ifflags & (IFF_POINTOPOINT | IFF_LOOPBACK)) == 0) {
@@ -292,7 +291,7 @@
#ifdef WITHOUT_NETLINK
.af_status = in_status,
#else
- .af_status_nl = in_status_nl,
+ .af_status = in_status_nl,
#endif
.af_getaddr = in_getaddr,
.af_postproc = in_postproc,
diff --git a/sbin/ifconfig/af_inet6.c b/sbin/ifconfig/af_inet6.c
--- a/sbin/ifconfig/af_inet6.c
+++ b/sbin/ifconfig/af_inet6.c
@@ -72,25 +72,27 @@
static int explicit_prefix = 0;
extern char *f_inet6, *f_addr;
-extern void setnd6flags(const char *, int, int, const struct afswtch *);
-extern void setnd6defif(const char *, int, int, const struct afswtch *);
-extern void nd6_status(int);
+extern void setnd6flags(if_ctx *, const char *, int);
+extern void setnd6defif(if_ctx *,const char *, int);
+extern void nd6_status(if_ctx *);
static char addr_buf[NI_MAXHOST]; /*for getnameinfo()*/
static void
-setifprefixlen(const char *addr, int dummy __unused, int s,
- const struct afswtch *afp)
+setifprefixlen(if_ctx *ctx, const char *addr, int dummy __unused)
{
+ const struct afswtch *afp = ctx->afp;
+
if (afp->af_getprefix != NULL)
afp->af_getprefix(addr, MASK);
explicit_prefix = 1;
}
static void
-setip6flags(const char *dummyaddr __unused, int flag, int dummysoc __unused,
- const struct afswtch *afp)
+setip6flags(if_ctx *ctx, const char *dummyaddr __unused, int flag)
{
+ const struct afswtch *afp = ctx->afp;
+
if (afp->af_af != AF_INET6)
err(1, "address flags can be set only for inet6 addresses");
@@ -101,9 +103,9 @@
}
static void
-setip6lifetime(const char *cmd, const char *val, int s,
- const struct afswtch *afp)
+setip6lifetime(if_ctx *ctx, const char *cmd, const char *val)
{
+ const struct afswtch *afp = ctx->afp;
struct timespec now;
time_t newval;
char *ep;
@@ -124,23 +126,21 @@
}
static void
-setip6pltime(const char *seconds, int dummy __unused, int s,
- const struct afswtch *afp)
+setip6pltime(if_ctx *ctx, const char *seconds, int dummy __unused)
{
- setip6lifetime("pltime", seconds, s, afp);
+ setip6lifetime(ctx, "pltime", seconds);
}
static void
-setip6vltime(const char *seconds, int dummy __unused, int s,
- const struct afswtch *afp)
+setip6vltime(if_ctx *ctx, const char *seconds, int dummy __unused)
{
- setip6lifetime("vltime", seconds, s, afp);
+ setip6lifetime(ctx, "vltime", seconds);
}
static void
-setip6eui64(const char *cmd, int dummy __unused, int s,
- const struct afswtch *afp)
+setip6eui64(if_ctx *ctx, const char *cmd, int dummy __unused)
{
+ const struct afswtch *afp = ctx->afp;
struct ifaddrs *ifap, *ifa;
const struct sockaddr_in6 *sin6 = NULL;
const struct in6_addr *lladdr = NULL;
@@ -247,7 +247,7 @@
#ifdef WITHOUT_NETLINK
static void
-in6_status(int s __unused, const struct ifaddrs *ifa)
+in6_status(if_ctx *ctx __unused, const struct ifaddrs *ifa)
{
struct sockaddr_in6 *sin, null_sin = {};
struct in6_ifreq ifr6;
@@ -341,8 +341,7 @@
}
static void
-in6_status_nl(struct ifconfig_args *args __unused, struct io_handler *h,
- if_link_t *link, if_addr_t *ifa)
+in6_status_nl(if_ctx *ctx __unused, if_link_t *link, if_addr_t *ifa)
{
int plen = ifa->ifa_prefixlen;
uint32_t scopeid;
@@ -495,14 +494,14 @@
}
static void
-in6_postproc(int s, const struct afswtch *afp, int newaddr __unused,
+in6_postproc(if_ctx *ctx, int newaddr __unused,
int ifflags __unused)
{
if (explicit_prefix == 0) {
/* Aggregatable address architecture defines all prefixes
are 64. So, it is convenient to set prefixlen to 64 if
it is not specified. */
- setifprefixlen("64", 0, s, afp);
+ setifprefixlen(ctx, "64", 0);
/* in6_getprefix("64", MASK) if MASK is available here... */
}
}
@@ -600,7 +599,7 @@
#ifdef WITHOUT_NETLINK
.af_status = in6_status,
#else
- .af_status_nl = in6_status_nl,
+ .af_status = in6_status_nl,
#endif
.af_getaddr = in6_getaddr,
.af_getprefix = in6_getprefix,
diff --git a/sbin/ifconfig/af_link.c b/sbin/ifconfig/af_link.c
--- a/sbin/ifconfig/af_link.c
+++ b/sbin/ifconfig/af_link.c
@@ -93,7 +93,7 @@
#ifdef WITHOUT_NETLINK
static void
-link_status(int s __unused, const struct ifaddrs *ifa)
+link_status(if_ctx *ctx, const struct ifaddrs *ifa)
{
/* XXX no const 'cuz LLADDR is defined wrong */
struct sockaddr_dl *sdl;
@@ -142,7 +142,7 @@
print_ether((const struct ether_addr *)&ifr.ifr_addr.sa_data, "hwaddr");
pcp:
- print_pcp(s);
+ print_pcp(ctx->io->s);
}
#else
@@ -159,8 +159,7 @@
}
static void
-link_status_nl(struct ifconfig_args *args __unused, struct io_handler *h,
- if_link_t *link, if_addr_t *ifa __unused)
+link_status_nl(if_ctx *ctx, if_link_t *link, if_addr_t *ifa __unused)
{
if (link->ifla_address != NULL) {
struct sockaddr_dl sdl = {
@@ -180,7 +179,7 @@
}
}
if (convert_iftype(link->ifi_type) == IFT_ETHER)
- print_pcp(h->s);
+ print_pcp(ctx->io->s);
}
#endif
@@ -224,7 +223,7 @@
#ifdef WITHOUT_NETLINK
.af_status = link_status,
#else
- .af_status_nl = link_status_nl,
+ .af_status = link_status_nl,
#endif
.af_getaddr = link_getaddr,
.af_aifaddr = SIOCSIFLLADDR,
@@ -236,7 +235,7 @@
#ifdef WITHOUT_NETLINK
.af_status = link_status,
#else
- .af_status_nl = link_status_nl,
+ .af_status = link_status_nl,
#endif
.af_getaddr = link_getaddr,
.af_aifaddr = SIOCSIFLLADDR,
@@ -248,7 +247,7 @@
#ifdef WITHOUT_NETLINK
.af_status = link_status,
#else
- .af_status_nl = link_status_nl,
+ .af_status = link_status_nl,
#endif
.af_getaddr = link_getaddr,
.af_aifaddr = SIOCSIFLLADDR,
diff --git a/sbin/ifconfig/af_nd6.c b/sbin/ifconfig/af_nd6.c
--- a/sbin/ifconfig/af_nd6.c
+++ b/sbin/ifconfig/af_nd6.c
@@ -70,21 +70,19 @@
#endif
static int isnd6defif(int);
-void setnd6flags(const char *, int, int, const struct afswtch *);
-void setnd6defif(const char *, int, int, const struct afswtch *);
-void nd6_status(int);
+void setnd6flags(if_ctx *, const char *, int);
+void setnd6defif(if_ctx *,const char *, int);
+void nd6_status(if_ctx *);
void
-setnd6flags(const char *dummyaddr __unused,
- int d, int s,
- const struct afswtch *afp)
+setnd6flags(if_ctx *ctx, const char *dummyaddr __unused, int d)
{
struct in6_ndireq nd;
int error;
memset(&nd, 0, sizeof(nd));
strlcpy(nd.ifname, ifr.ifr_name, sizeof(nd.ifname));
- error = ioctl(s, SIOCGIFINFO_IN6, &nd);
+ error = ioctl(ctx->io->s, SIOCGIFINFO_IN6, &nd);
if (error) {
warn("ioctl(SIOCGIFINFO_IN6)");
return;
@@ -93,15 +91,13 @@
nd.ndi.flags &= ~(-d);
else
nd.ndi.flags |= d;
- error = ioctl(s, SIOCSIFINFO_IN6, (caddr_t)&nd);
+ error = ioctl(ctx->io->s, SIOCSIFINFO_IN6, (caddr_t)&nd);
if (error)
warn("ioctl(SIOCSIFINFO_IN6)");
}
void
-setnd6defif(const char *dummyaddr __unused,
- int d, int s,
- const struct afswtch *afp)
+setnd6defif(if_ctx *ctx, const char *dummyaddr __unused, int d)
{
struct in6_ndifreq ndifreq;
int ifindex;
@@ -111,7 +107,7 @@
strlcpy(ndifreq.ifname, ifr.ifr_name, sizeof(ndifreq.ifname));
if (d < 0) {
- if (isnd6defif(s)) {
+ if (isnd6defif(ctx->io->s)) {
/* ifindex = 0 means to remove default if */
ifindex = 0;
} else
@@ -122,7 +118,7 @@
}
ndifreq.ifindex = ifindex;
- error = ioctl(s, SIOCSDEFIFACE_IN6, (caddr_t)&ndifreq);
+ error = ioctl(ctx->io->s, SIOCSDEFIFACE_IN6, (caddr_t)&ndifreq);
if (error)
warn("ioctl(SIOCSDEFIFACE_IN6)");
}
@@ -147,7 +143,7 @@
}
void
-nd6_status(int s)
+nd6_status(if_ctx *ctx __unused)
{
struct in6_ndireq nd;
int s6;
diff --git a/sbin/ifconfig/carp.c b/sbin/ifconfig/carp.c
--- a/sbin/ifconfig/carp.c
+++ b/sbin/ifconfig/carp.c
@@ -60,12 +60,7 @@
static const char *carp_states[] = { CARP_STATES };
-static void carp_status(int s);
-static void setcarp_vhid(const char *, int, int, const struct afswtch *rafp);
static void setcarp_callback(int, void *);
-static void setcarp_advbase(const char *,int, int, const struct afswtch *rafp);
-static void setcarp_advskew(const char *, int, int, const struct afswtch *rafp);
-static void setcarp_passwd(const char *, int, int, const struct afswtch *rafp);
static int carpr_vhid = -1;
static int carpr_advskew = -1;
@@ -76,7 +71,7 @@
static unsigned char const *carpr_key;
static void
-carp_status(int s)
+carp_status(if_ctx *ctx __unused)
{
struct ifconfig_carp carpr[CARP_MAXVHID];
char addr_buf[NI_MAXHOST];
@@ -102,8 +97,9 @@
}
static void
-setcarp_vhid(const char *val, int d, int s, const struct afswtch *afp)
+setcarp_vhid(if_ctx *ctx, const char *val, int dummy __unused)
{
+ const struct afswtch *afp = ctx->afp;
carpr_vhid = atoi(val);
@@ -148,7 +144,7 @@
}
static void
-setcarp_passwd(const char *val, int d, int s, const struct afswtch *afp)
+setcarp_passwd(if_ctx *ctx __unused, const char *val, int dummy __unused)
{
if (carpr_vhid == -1)
@@ -158,7 +154,7 @@
}
static void
-setcarp_advskew(const char *val, int d, int s, const struct afswtch *afp)
+setcarp_advskew(if_ctx *ctx __unused, const char *val, int dummy __unused)
{
if (carpr_vhid == -1)
@@ -168,7 +164,7 @@
}
static void
-setcarp_advbase(const char *val, int d, int s, const struct afswtch *afp)
+setcarp_advbase(if_ctx *ctx __unused, const char *val, int dummy __unused)
{
if (carpr_vhid == -1)
@@ -178,7 +174,7 @@
}
static void
-setcarp_state(const char *val, int d, int s, const struct afswtch *afp)
+setcarp_state(if_ctx *ctx __unused, const char *val, int dummy __unused)
{
int i;
@@ -195,19 +191,19 @@
}
static void
-setcarp_peer(const char *val, int d, int s, const struct afswtch *afp)
+setcarp_peer(if_ctx *ctx __unused, const char *val, int dummy __unused)
{
carp_addr.s_addr = inet_addr(val);
}
static void
-setcarp_mcast(const char *val, int d, int s, const struct afswtch *afp)
+setcarp_mcast(if_ctx *ctx __unused, const char *val __unused, int dummy __unused)
{
carp_addr.s_addr = htonl(INADDR_CARP_GROUP);
}
static void
-setcarp_peer6(const char *val, int d, int s, const struct afswtch *afp)
+setcarp_peer6(if_ctx *ctx __unused, const char *val, int dummy __unused)
{
struct addrinfo hints, *res;
@@ -224,7 +220,7 @@
}
static void
-setcarp_mcast6(const char *val, int d, int s, const struct afswtch *afp)
+setcarp_mcast6(if_ctx *ctx __unused, const char *val __unused, int dummy __unused)
{
bzero(&carp_addr6, sizeof(carp_addr6));
carp_addr6.s6_addr[0] = 0xff;
@@ -253,8 +249,8 @@
carp_ctor(void)
{
/* Default to multicast. */
- setcarp_mcast(NULL, 0, 0, NULL);
- setcarp_mcast6(NULL, 0, 0, NULL);
+ setcarp_mcast(NULL, NULL, 0);
+ setcarp_mcast6(NULL, NULL, 0);
for (size_t i = 0; i < nitems(carp_cmds); i++)
cmd_register(&carp_cmds[i]);
diff --git a/sbin/ifconfig/ifbridge.c b/sbin/ifconfig/ifbridge.c
--- a/sbin/ifconfig/ifbridge.c
+++ b/sbin/ifconfig/ifbridge.c
@@ -154,7 +154,7 @@
}
static void
-bridge_status(int s)
+bridge_status(if_ctx *ctx __unused)
{
struct ifconfig_bridge_status *bridge;
struct ifbropreq *params;
@@ -225,178 +225,177 @@
}
static void
-setbridge_add(const char *val, int d, int s, const struct afswtch *afp)
+setbridge_add(if_ctx *ctx, const char *val, int dummy __unused)
{
struct ifbreq req;
memset(&req, 0, sizeof(req));
strlcpy(req.ifbr_ifsname, val, sizeof(req.ifbr_ifsname));
- if (do_cmd(s, BRDGADD, &req, sizeof(req), 1) < 0)
+ if (do_cmd(ctx->io->s, BRDGADD, &req, sizeof(req), 1) < 0)
err(1, "BRDGADD %s", val);
}
static void
-setbridge_delete(const char *val, int d, int s, const struct afswtch *afp)
+setbridge_delete(if_ctx *ctx, const char *val, int dummy __unused)
{
struct ifbreq req;
memset(&req, 0, sizeof(req));
strlcpy(req.ifbr_ifsname, val, sizeof(req.ifbr_ifsname));
- if (do_cmd(s, BRDGDEL, &req, sizeof(req), 1) < 0)
+ if (do_cmd(ctx->io->s, BRDGDEL, &req, sizeof(req), 1) < 0)
err(1, "BRDGDEL %s", val);
}
static void
-setbridge_discover(const char *val, int d, int s, const struct afswtch *afp)
+setbridge_discover(if_ctx *ctx, const char *val, int dummy __unused)
{
- do_bridgeflag(s, val, IFBIF_DISCOVER, 1);
+ do_bridgeflag(ctx->io->s, val, IFBIF_DISCOVER, 1);
}
static void
-unsetbridge_discover(const char *val, int d, int s, const struct afswtch *afp)
+unsetbridge_discover(if_ctx *ctx, const char *val, int dummy __unused)
{
- do_bridgeflag(s, val, IFBIF_DISCOVER, 0);
+ do_bridgeflag(ctx->io->s, val, IFBIF_DISCOVER, 0);
}
static void
-setbridge_learn(const char *val, int d, int s, const struct afswtch *afp)
+setbridge_learn(if_ctx *ctx, const char *val, int dummy __unused)
{
- do_bridgeflag(s, val, IFBIF_LEARNING, 1);
+ do_bridgeflag(ctx->io->s, val, IFBIF_LEARNING, 1);
}
static void
-unsetbridge_learn(const char *val, int d, int s, const struct afswtch *afp)
+unsetbridge_learn(if_ctx *ctx, const char *val, int dummy __unused)
{
- do_bridgeflag(s, val, IFBIF_LEARNING, 0);
+ do_bridgeflag(ctx->io->s, val, IFBIF_LEARNING, 0);
}
static void
-setbridge_sticky(const char *val, int d, int s, const struct afswtch *afp)
+setbridge_sticky(if_ctx *ctx, const char *val, int dummy __unused)
{
- do_bridgeflag(s, val, IFBIF_STICKY, 1);
+ do_bridgeflag(ctx->io->s, val, IFBIF_STICKY, 1);
}
static void
-unsetbridge_sticky(const char *val, int d, int s, const struct afswtch *afp)
+unsetbridge_sticky(if_ctx *ctx, const char *val, int dummy __unused)
{
- do_bridgeflag(s, val, IFBIF_STICKY, 0);
+ do_bridgeflag(ctx->io->s, val, IFBIF_STICKY, 0);
}
static void
-setbridge_span(const char *val, int d, int s, const struct afswtch *afp)
+setbridge_span(if_ctx *ctx, const char *val, int dummy __unused)
{
struct ifbreq req;
memset(&req, 0, sizeof(req));
strlcpy(req.ifbr_ifsname, val, sizeof(req.ifbr_ifsname));
- if (do_cmd(s, BRDGADDS, &req, sizeof(req), 1) < 0)
+ if (do_cmd(ctx->io->s, BRDGADDS, &req, sizeof(req), 1) < 0)
err(1, "BRDGADDS %s", val);
}
static void
-unsetbridge_span(const char *val, int d, int s, const struct afswtch *afp)
+unsetbridge_span(if_ctx *ctx, const char *val, int dummy __unused)
{
struct ifbreq req;
memset(&req, 0, sizeof(req));
strlcpy(req.ifbr_ifsname, val, sizeof(req.ifbr_ifsname));
- if (do_cmd(s, BRDGDELS, &req, sizeof(req), 1) < 0)
+ if (do_cmd(ctx->io->s, BRDGDELS, &req, sizeof(req), 1) < 0)
err(1, "BRDGDELS %s", val);
}
static void
-setbridge_stp(const char *val, int d, int s, const struct afswtch *afp)
+setbridge_stp(if_ctx *ctx, const char *val, int dummy __unused)
{
- do_bridgeflag(s, val, IFBIF_STP, 1);
+ do_bridgeflag(ctx->io->s, val, IFBIF_STP, 1);
}
static void
-unsetbridge_stp(const char *val, int d, int s, const struct afswtch *afp)
+unsetbridge_stp(if_ctx *ctx, const char *val, int dummy __unused)
{
- do_bridgeflag(s, val, IFBIF_STP, 0);
+ do_bridgeflag(ctx->io->s, val, IFBIF_STP, 0);
}
static void
-setbridge_edge(const char *val, int d, int s, const struct afswtch *afp)
+setbridge_edge(if_ctx *ctx, const char *val, int dummy __unused)
{
- do_bridgeflag(s, val, IFBIF_BSTP_EDGE, 1);
+ do_bridgeflag(ctx->io->s, val, IFBIF_BSTP_EDGE, 1);
}
static void
-unsetbridge_edge(const char *val, int d, int s, const struct afswtch *afp)
+unsetbridge_edge(if_ctx *ctx, const char *val, int dummy __unused)
{
- do_bridgeflag(s, val, IFBIF_BSTP_EDGE, 0);
+ do_bridgeflag(ctx->io->s, val, IFBIF_BSTP_EDGE, 0);
}
static void
-setbridge_autoedge(const char *val, int d, int s, const struct afswtch *afp)
+setbridge_autoedge(if_ctx *ctx, const char *val, int dummy __unused)
{
- do_bridgeflag(s, val, IFBIF_BSTP_AUTOEDGE, 1);
+ do_bridgeflag(ctx->io->s, val, IFBIF_BSTP_AUTOEDGE, 1);
}
static void
-unsetbridge_autoedge(const char *val, int d, int s, const struct afswtch *afp)
+unsetbridge_autoedge(if_ctx *ctx, const char *val, int dummy __unused)
{
- do_bridgeflag(s, val, IFBIF_BSTP_AUTOEDGE, 0);
+ do_bridgeflag(ctx->io->s, val, IFBIF_BSTP_AUTOEDGE, 0);
}
static void
-setbridge_ptp(const char *val, int d, int s, const struct afswtch *afp)
+setbridge_ptp(if_ctx *ctx, const char *val, int dummy __unused)
{
- do_bridgeflag(s, val, IFBIF_BSTP_PTP, 1);
+ do_bridgeflag(ctx->io->s, val, IFBIF_BSTP_PTP, 1);
}
static void
-unsetbridge_ptp(const char *val, int d, int s, const struct afswtch *afp)
+unsetbridge_ptp(if_ctx *ctx, const char *val, int dummy __unused)
{
- do_bridgeflag(s, val, IFBIF_BSTP_PTP, 0);
+ do_bridgeflag(ctx->io->s, val, IFBIF_BSTP_PTP, 0);
}
static void
-setbridge_autoptp(const char *val, int d, int s, const struct afswtch *afp)
+setbridge_autoptp(if_ctx *ctx, const char *val, int dummy __unused)
{
- do_bridgeflag(s, val, IFBIF_BSTP_AUTOPTP, 1);
+ do_bridgeflag(ctx->io->s, val, IFBIF_BSTP_AUTOPTP, 1);
}
static void
-unsetbridge_autoptp(const char *val, int d, int s, const struct afswtch *afp)
+unsetbridge_autoptp(if_ctx *ctx, const char *val, int dummy __unused)
{
- do_bridgeflag(s, val, IFBIF_BSTP_AUTOPTP, 0);
+ do_bridgeflag(ctx->io->s, val, IFBIF_BSTP_AUTOPTP, 0);
}
static void
-setbridge_flush(const char *val, int d, int s, const struct afswtch *afp)
+setbridge_flush(if_ctx *ctx, const char *val, int dummy __unused)
{
struct ifbreq req;
memset(&req, 0, sizeof(req));
req.ifbr_ifsflags = IFBF_FLUSHDYN;
- if (do_cmd(s, BRDGFLUSH, &req, sizeof(req), 1) < 0)
+ if (do_cmd(ctx->io->s, BRDGFLUSH, &req, sizeof(req), 1) < 0)
err(1, "BRDGFLUSH");
}
static void
-setbridge_flushall(const char *val, int d, int s, const struct afswtch *afp)
+setbridge_flushall(if_ctx *ctx, const char *val, int dummy __unused)
{
struct ifbreq req;
memset(&req, 0, sizeof(req));
req.ifbr_ifsflags = IFBF_FLUSHALL;
- if (do_cmd(s, BRDGFLUSH, &req, sizeof(req), 1) < 0)
+ if (do_cmd(ctx->io->s, BRDGFLUSH, &req, sizeof(req), 1) < 0)
err(1, "BRDGFLUSH");
}
static void
-setbridge_static(const char *val, const char *mac, int s,
- const struct afswtch *afp)
+setbridge_static(if_ctx *ctx, const char *val, const char *mac)
{
struct ifbareq req;
struct ether_addr *ea;
@@ -412,12 +411,12 @@
req.ifba_flags = IFBAF_STATIC;
req.ifba_vlan = 1; /* XXX allow user to specify */
- if (do_cmd(s, BRDGSADDR, &req, sizeof(req), 1) < 0)
+ if (do_cmd(ctx->io->s, BRDGSADDR, &req, sizeof(req), 1) < 0)
err(1, "BRDGSADDR %s", val);
}
static void
-setbridge_deladdr(const char *val, int d, int s, const struct afswtch *afp)
+setbridge_deladdr(if_ctx *ctx, const char *val, int dummy __unused)
{
struct ifbareq req;
struct ether_addr *ea;
@@ -430,19 +429,19 @@
memcpy(req.ifba_dst, ea->octet, sizeof(req.ifba_dst));
- if (do_cmd(s, BRDGDADDR, &req, sizeof(req), 1) < 0)
+ if (do_cmd(ctx->io->s, BRDGDADDR, &req, sizeof(req), 1) < 0)
err(1, "BRDGDADDR %s", val);
}
static void
-setbridge_addr(const char *val, int d, int s, const struct afswtch *afp)
+setbridge_addr(if_ctx *ctx, const char *val, int dummy __unused)
{
- bridge_addresses(s, "");
+ bridge_addresses(ctx->io->s, "");
}
static void
-setbridge_maxaddr(const char *arg, int d, int s, const struct afswtch *afp)
+setbridge_maxaddr(if_ctx *ctx, const char *arg, int dummy __unused)
{
struct ifbrparam param;
u_long val;
@@ -452,12 +451,12 @@
param.ifbrp_csize = val & 0xffffffff;
- if (do_cmd(s, BRDGSCACHE, &param, sizeof(param), 1) < 0)
+ if (do_cmd(ctx->io->s, BRDGSCACHE, &param, sizeof(param), 1) < 0)
err(1, "BRDGSCACHE %s", arg);
}
static void
-setbridge_hellotime(const char *arg, int d, int s, const struct afswtch *afp)
+setbridge_hellotime(if_ctx *ctx, const char *arg, int dummy __unused)
{
struct ifbrparam param;
u_long val;
@@ -467,12 +466,12 @@
param.ifbrp_hellotime = val & 0xff;
- if (do_cmd(s, BRDGSHT, &param, sizeof(param), 1) < 0)
+ if (do_cmd(ctx->io->s, BRDGSHT, &param, sizeof(param), 1) < 0)
err(1, "BRDGSHT %s", arg);
}
static void
-setbridge_fwddelay(const char *arg, int d, int s, const struct afswtch *afp)
+setbridge_fwddelay(if_ctx *ctx, const char *arg, int dummy __unused)
{
struct ifbrparam param;
u_long val;
@@ -482,12 +481,12 @@
param.ifbrp_fwddelay = val & 0xff;
- if (do_cmd(s, BRDGSFD, &param, sizeof(param), 1) < 0)
+ if (do_cmd(ctx->io->s, BRDGSFD, &param, sizeof(param), 1) < 0)
err(1, "BRDGSFD %s", arg);
}
static void
-setbridge_maxage(const char *arg, int d, int s, const struct afswtch *afp)
+setbridge_maxage(if_ctx *ctx, const char *arg, int dummy __unused)
{
struct ifbrparam param;
u_long val;
@@ -497,12 +496,12 @@
param.ifbrp_maxage = val & 0xff;
- if (do_cmd(s, BRDGSMA, &param, sizeof(param), 1) < 0)
+ if (do_cmd(ctx->io->s, BRDGSMA, &param, sizeof(param), 1) < 0)
err(1, "BRDGSMA %s", arg);
}
static void
-setbridge_priority(const char *arg, int d, int s, const struct afswtch *afp)
+setbridge_priority(if_ctx *ctx, const char *arg, int dummy __unused)
{
struct ifbrparam param;
u_long val;
@@ -512,12 +511,12 @@
param.ifbrp_prio = val & 0xffff;
- if (do_cmd(s, BRDGSPRI, &param, sizeof(param), 1) < 0)
+ if (do_cmd(ctx->io->s, BRDGSPRI, &param, sizeof(param), 1) < 0)
err(1, "BRDGSPRI %s", arg);
}
static void
-setbridge_protocol(const char *arg, int d, int s, const struct afswtch *afp)
+setbridge_protocol(if_ctx *ctx, const char *arg, int dummy __unused)
{
struct ifbrparam param;
@@ -529,12 +528,12 @@
errx(1, "unknown stp protocol");
}
- if (do_cmd(s, BRDGSPROTO, &param, sizeof(param), 1) < 0)
+ if (do_cmd(ctx->io->s, BRDGSPROTO, &param, sizeof(param), 1) < 0)
err(1, "BRDGSPROTO %s", arg);
}
static void
-setbridge_holdcount(const char *arg, int d, int s, const struct afswtch *afp)
+setbridge_holdcount(if_ctx *ctx, const char *arg, int dummy __unused)
{
struct ifbrparam param;
u_long val;
@@ -544,13 +543,12 @@
param.ifbrp_txhc = val & 0xff;
- if (do_cmd(s, BRDGSTXHC, &param, sizeof(param), 1) < 0)
+ if (do_cmd(ctx->io->s, BRDGSTXHC, &param, sizeof(param), 1) < 0)
err(1, "BRDGSTXHC %s", arg);
}
static void
-setbridge_ifpriority(const char *ifn, const char *pri, int s,
- const struct afswtch *afp)
+setbridge_ifpriority(if_ctx *ctx, const char *ifn, const char *pri)
{
struct ifbreq req;
u_long val;
@@ -563,13 +561,12 @@
strlcpy(req.ifbr_ifsname, ifn, sizeof(req.ifbr_ifsname));
req.ifbr_priority = val & 0xff;
- if (do_cmd(s, BRDGSIFPRIO, &req, sizeof(req), 1) < 0)
+ if (do_cmd(ctx->io->s, BRDGSIFPRIO, &req, sizeof(req), 1) < 0)
err(1, "BRDGSIFPRIO %s", pri);
}
static void
-setbridge_ifpathcost(const char *ifn, const char *cost, int s,
- const struct afswtch *afp)
+setbridge_ifpathcost(if_ctx *ctx, const char *ifn, const char *cost)
{
struct ifbreq req;
u_long val;
@@ -582,13 +579,12 @@
strlcpy(req.ifbr_ifsname, ifn, sizeof(req.ifbr_ifsname));
req.ifbr_path_cost = val;
- if (do_cmd(s, BRDGSIFCOST, &req, sizeof(req), 1) < 0)
+ if (do_cmd(ctx->io->s, BRDGSIFCOST, &req, sizeof(req), 1) < 0)
err(1, "BRDGSIFCOST %s", cost);
}
static void
-setbridge_ifmaxaddr(const char *ifn, const char *arg, int s,
- const struct afswtch *afp)
+setbridge_ifmaxaddr(if_ctx *ctx, const char *ifn, const char *arg)
{
struct ifbreq req;
u_long val;
@@ -601,12 +597,12 @@
strlcpy(req.ifbr_ifsname, ifn, sizeof(req.ifbr_ifsname));
req.ifbr_addrmax = val & 0xffffffff;
- if (do_cmd(s, BRDGSIFAMAX, &req, sizeof(req), 1) < 0)
+ if (do_cmd(ctx->io->s, BRDGSIFAMAX, &req, sizeof(req), 1) < 0)
err(1, "BRDGSIFAMAX %s", arg);
}
static void
-setbridge_timeout(const char *arg, int d, int s, const struct afswtch *afp)
+setbridge_timeout(if_ctx *ctx, const char *arg, int dummy __unused)
{
struct ifbrparam param;
u_long val;
@@ -616,22 +612,22 @@
param.ifbrp_ctime = val & 0xffffffff;
- if (do_cmd(s, BRDGSTO, &param, sizeof(param), 1) < 0)
+ if (do_cmd(ctx->io->s, BRDGSTO, &param, sizeof(param), 1) < 0)
err(1, "BRDGSTO %s", arg);
}
static void
-setbridge_private(const char *val, int d, int s, const struct afswtch *afp)
+setbridge_private(if_ctx *ctx, const char *val, int dummy __unused)
{
- do_bridgeflag(s, val, IFBIF_PRIVATE, 1);
+ do_bridgeflag(ctx->io->s, val, IFBIF_PRIVATE, 1);
}
static void
-unsetbridge_private(const char *val, int d, int s, const struct afswtch *afp)
+unsetbridge_private(if_ctx *ctx, const char *val, int dummy __unused)
{
- do_bridgeflag(s, val, IFBIF_PRIVATE, 0);
+ do_bridgeflag(ctx->io->s, val, IFBIF_PRIVATE, 0);
}
static struct cmd bridge_cmds[] = {
diff --git a/sbin/ifconfig/ifclone.c b/sbin/ifconfig/ifclone.c
--- a/sbin/ifconfig/ifclone.c
+++ b/sbin/ifconfig/ifclone.c
@@ -160,17 +160,17 @@
}
}
-static
-DECL_CMD_FUNC(clone_create, arg, d)
+static void
+clone_create(if_ctx *ctx __unused, const char *cmd __unused, int d __unused)
{
callback_register(ifclonecreate, NULL);
}
-static
-DECL_CMD_FUNC(clone_destroy, arg, d)
+static void
+clone_destroy(if_ctx *ctx, const char *cmd __unused, int d __unused)
{
- (void) strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
- if (ioctl(s, SIOCIFDESTROY, &ifr) < 0)
+ strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
+ if (ioctl(ctx->io->s, SIOCIFDESTROY, &ifr) < 0)
err(1, "SIOCIFDESTROY");
}
diff --git a/sbin/ifconfig/ifconfig.h b/sbin/ifconfig/ifconfig.h
--- a/sbin/ifconfig/ifconfig.h
+++ b/sbin/ifconfig/ifconfig.h
@@ -45,12 +45,13 @@
struct afswtch;
struct cmd;
+struct ifconfig_context;
-typedef void c_func(const char *cmd, int arg, int s, const struct afswtch *afp);
-typedef void c_func2(const char *arg1, const char *arg2, int s,
- const struct afswtch *afp);
-typedef void c_func3(const char *cmd, const char *arg, int s,
- const struct afswtch *afp);
+typedef void c_func(const struct ifconfig_context *ctx, const char *cmd, int arg);
+typedef void c_func2(const struct ifconfig_context *ctx, const char *arg1,
+ const char *arg2);
+typedef void c_func3(const struct ifconfig_context *ctx, const char *cmd,
+ const char *arg);
struct cmd {
const char *c_name;
@@ -77,10 +78,9 @@
* Macros for declaring command functions and initializing entries.
*/
#define DECL_CMD_FUNC(name, cmd, arg) \
- void name(const char *cmd, int arg, int s, const struct afswtch *afp)
+ void name(const struct ifconfig_context *ctx, const char *cmd, int arg)
#define DECL_CMD_FUNC2(name, arg1, arg2) \
- void name(const char *arg1, const char *arg2, int s, \
- const struct afswtch *afp)
+ void name(const struct ifconfig_context *ctx, const char *arg1, const char *arg2)
#define DEF_CMD(name, param, func) { \
.c_name = (name), \
@@ -140,6 +140,17 @@
.c_next = NULL, \
}
+struct ifconfig_args;
+struct io_handler;
+struct ifconfig_context {
+ struct ifconfig_args *args;
+ const struct afswtch *afp;
+ struct io_handler *io;
+};
+typedef const struct ifconfig_context if_ctx;
+
+#define ioctl_ctx(ctx, _req, ...) ioctl((ctx)->io->s, _req, ## __VA_ARGS__)
+
struct ifaddrs;
struct addrinfo;
@@ -155,15 +166,16 @@
struct snl_parsed_link;
typedef struct snl_parsed_link if_link_t;
typedef struct snl_parsed_addr if_addr_t;
-struct ifconfig_args;
struct io_handler {
int s; /* socket to use for ioctls */
struct snl_state *ss; /* NETLINK_ROUTE snl(3) socket */
};
typedef void af_setvhid_f(int vhid);
-typedef void af_status_nl_f(struct ifconfig_args *args, struct io_handler *h,
- if_link_t *link, if_addr_t *ifa);
+typedef void af_status_nl_f(if_ctx *ctx, if_link_t *link, if_addr_t *ifa);
+typedef void af_status_f(if_ctx *ctx, const struct ifaddrs *);
+typedef void af_other_status_f(if_ctx *ctx);
+typedef void af_postproc_f(if_ctx *ctx, int newaddr, int ifflags);
struct afswtch {
const char *af_name; /* as given on cmd line, e.g. "inet" */
@@ -178,17 +190,15 @@
* is presented.
*/
#ifndef WITHOUT_NETLINK
- af_status_nl_f *af_status_nl;
+ af_status_nl_f *af_status;
#else
- void (*af_status)(int, const struct ifaddrs *);
+ af_status_f *af_status;
#endif
- void (*af_other_status)(int);
- /* parse address method */
+ af_other_status_f *af_other_status;
void (*af_getaddr)(const char *, int);
/* parse prefix method (IPv6) */
void (*af_getprefix)(const char *, int);
- void (*af_postproc)(int s, const struct afswtch *,
- int newaddr, int ifflags);
+ af_postproc_f *af_postproc;
af_setvhid_f *af_setvhid; /* Set CARP vhid for an address */
u_long af_difaddr; /* set dst if address ioctl */
u_long af_aifaddr; /* set if address ioctl */
@@ -238,12 +248,11 @@
extern int verbose;
extern int printifname;
extern int exit_code;
-extern struct ifconfig_args args;
+extern struct ifconfig_args global_args;
extern char *f_inet, *f_inet6, *f_ether, *f_addr;
-void setifcap(const char *, int value, int s, const struct afswtch *);
-void setifcapnv(const char *vname, const char *arg, int s,
- const struct afswtch *afp);
+void setifcap(if_ctx *ctx, const char *, int value);
+void setifcapnv(if_ctx *ctx, const char *vname, const char *arg);
void Perror(const char *cmd);
void printb(const char *s, unsigned value, const char *bits);
@@ -265,7 +274,7 @@
void print_ifcap(struct ifconfig_args *args, int s);
void tunnel_status(int s);
struct afswtch *af_getbyfamily(int af);
-void af_other_status(int s);
+void af_other_status(if_ctx *ctx);
void print_ifstatus(int s);
void print_metric(int s);
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -102,7 +102,7 @@
int verbose;
int printifname = 0;
-struct ifconfig_args args;
+struct ifconfig_args global_args;
int printkeys = 0; /* Print keying material for interfaces. */
int exit_code = 0;
@@ -554,6 +554,7 @@
char *envformat;
size_t iflen;
int flags;
+ struct ifconfig_args *args = &global_args;
f_inet = f_inet6 = f_ether = f_addr = NULL;
@@ -571,17 +572,17 @@
*/
atexit(printifnamemaybe);
- args_parse(&args, ac, av);
+ args_parse(args, ac, av);
- if (!args.all && !args.namesonly) {
+ if (!args->all && !args->namesonly) {
/* not listing, need an argument */
- args.ifname = args_pop(&args);
+ args->ifname = args_pop(args);
/* check and maybe load support for this interface */
- ifmaybeload(&args, args.ifname);
+ ifmaybeload(args, args->ifname);
- char *arg = args_peek(&args);
- if (if_nametoindex(args.ifname) == 0) {
+ char *arg = args_peek(args);
+ if (if_nametoindex(args->ifname) == 0) {
/*
* NOTE: We must special-case the `create' command
* right here as we would otherwise fail when trying
@@ -589,11 +590,11 @@
*/
if (arg != NULL && (strcmp(arg, "create") == 0 ||
strcmp(arg, "plumb") == 0)) {
- iflen = strlcpy(name, args.ifname, sizeof(name));
+ iflen = strlcpy(name, args->ifname, sizeof(name));
if (iflen >= sizeof(name))
errx(1, "%s: cloning name too long",
- args.ifname);
- ifconfig(args.argc, args.argv, 1, NULL);
+ args->ifname);
+ ifconfig(args->argc, args->argv, 1, NULL);
exit(exit_code);
}
#ifdef JAIL
@@ -603,15 +604,15 @@
* to find the interface as it lives in another vnet.
*/
if (arg != NULL && (strcmp(arg, "-vnet") == 0)) {
- iflen = strlcpy(name, args.ifname, sizeof(name));
+ iflen = strlcpy(name, args->ifname, sizeof(name));
if (iflen >= sizeof(name))
errx(1, "%s: interface name too long",
- args.ifname);
- ifconfig(args.argc, args.argv, 0, NULL);
+ args->ifname);
+ ifconfig(args->argc, args->argv, 0, NULL);
exit(exit_code);
}
#endif
- errx(1, "interface %s does not exist", args.ifname);
+ errx(1, "interface %s does not exist", args->ifname);
} else {
/*
* Do not allow use `create` command as hostname if
@@ -619,19 +620,19 @@
*/
if (arg != NULL && (strcmp(arg, "create") == 0 ||
strcmp(arg, "plumb") == 0)) {
- if (args.argc == 1)
+ if (args->argc == 1)
errx(1, "interface %s already exists",
- args.ifname);
- args_pop(&args);
+ args->ifname);
+ args_pop(args);
}
}
}
/* Check for address family */
- if (args.argc > 0) {
- args.afp = af_getbyname(args_peek(&args));
- if (args.afp != NULL)
- args_pop(&args);
+ if (args->argc > 0) {
+ args->afp = af_getbyname(args_peek(args));
+ if (args->afp != NULL)
+ args_pop(args);
}
/*
@@ -639,23 +640,23 @@
* which doesn't require building, sorting, and searching the entire
* system address list
*/
- if ((args.argc > 0) && (args.ifname != NULL)) {
- iflen = strlcpy(name, args.ifname, sizeof(name));
+ if ((args->argc > 0) && (args->ifname != NULL)) {
+ iflen = strlcpy(name, args->ifname, sizeof(name));
if (iflen >= sizeof(name)) {
- warnx("%s: interface name too long, skipping", args.ifname);
+ warnx("%s: interface name too long, skipping", args->ifname);
} else {
flags = getifflags(name, -1, false);
if (!(((flags & IFF_CANTCONFIG) != 0) ||
- (args.downonly && (flags & IFF_UP) != 0) ||
- (args.uponly && (flags & IFF_UP) == 0)))
- ifconfig(args.argc, args.argv, 0, args.afp);
+ (args->downonly && (flags & IFF_UP) != 0) ||
+ (args->uponly && (flags & IFF_UP) == 0)))
+ ifconfig(args->argc, args->argv, 0, args->afp);
}
goto done;
}
- args.allfamilies = args.afp == NULL;
+ args->allfamilies = args->afp == NULL;
- list_interfaces(&args);
+ list_interfaces(args);
done:
freeformat();
@@ -886,7 +887,7 @@
}
void
-af_other_status(int s)
+af_other_status(if_ctx *ctx)
{
struct afswtch *afp;
uint8_t afmask[howmany(AF_MAX, NBBY)];
@@ -897,7 +898,7 @@
continue;
if (afp->af_af != AF_UNSPEC && isset(afmask, afp->af_af))
continue;
- afp->af_other_status(s);
+ afp->af_other_status(ctx);
setbit(afmask, afp->af_af);
}
}
@@ -968,10 +969,10 @@
}
/* specially-handled commands */
-static void setifaddr(const char *, int, int, const struct afswtch *);
+static void setifaddr(if_ctx *ctx, const char *addr, int param);
static const struct cmd setifaddr_cmd = DEF_CMD("ifaddr", 0, setifaddr);
-static void setifdstaddr(const char *, int, int, const struct afswtch *);
+static void setifdstaddr(if_ctx *ctx, const char *addr, int param __unused);
static const struct cmd setifdstaddr_cmd =
DEF_CMD("ifdstaddr", 0, setifdstaddr);
@@ -1047,6 +1048,9 @@
warnx("Please specify an address_family.");
usage();
}
+
+ struct io_handler h = {};
+ struct ifconfig_context ctx = { .io = &h };
top:
ifr.ifr_addr.sa_family =
afp->af_af == AF_LINK || afp->af_af == AF_UNSPEC ?
@@ -1057,6 +1061,9 @@
(s = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0))
err(1, "socket(family %u,SOCK_DGRAM)", ifr.ifr_addr.sa_family);
+ h.s = s;
+ ctx.afp = afp;
+
while (argc > 0) {
p = cmd_lookup(*argv, iscreate);
if (iscreate && p == NULL) {
@@ -1101,22 +1108,22 @@
if (argv[1] == NULL)
errx(1, "'%s' requires argument",
p->c_name);
- p->c_u.c_func(argv[1], 0, s, afp);
+ p->c_u.c_func(&ctx, argv[1], 0);
argc--, argv++;
} else if (p->c_parameter == OPTARG && p->c_u.c_func) {
- p->c_u.c_func(argv[1], 0, s, afp);
+ p->c_u.c_func(&ctx, argv[1], 0);
if (argv[1] != NULL)
argc--, argv++;
} else if (p->c_parameter == NEXTARG2 && p->c_u.c_func2) {
if (argc < 3)
errx(1, "'%s' requires 2 arguments",
p->c_name);
- p->c_u.c_func2(argv[1], argv[2], s, afp);
+ p->c_u.c_func2(&ctx, argv[1], argv[2]);
argc -= 2, argv += 2;
} else if (p->c_parameter == SPARAM && p->c_u.c_func3) {
- p->c_u.c_func3(*argv, p->c_sparameter, s, afp);
+ p->c_u.c_func3(&ctx, *argv, p->c_sparameter);
} else if (p->c_u.c_func)
- p->c_u.c_func(*argv, p->c_parameter, s, afp);
+ p->c_u.c_func(&ctx, *argv, p->c_parameter);
argc--, argv++;
}
@@ -1124,7 +1131,7 @@
* Do any post argument processing required by the address family.
*/
if (afp->af_postproc != NULL)
- afp->af_postproc(s, afp, newaddr, getifflags(name, s, true));
+ afp->af_postproc(&ctx, newaddr, getifflags(name, s, true));
/*
* Do deferred callbacks registered while processing
* command-line arguments.
@@ -1143,10 +1150,11 @@
return(0);
}
-/*ARGSUSED*/
static void
-setifaddr(const char *addr, int param, int s, const struct afswtch *afp)
+setifaddr(if_ctx *ctx, const char *addr, int param)
{
+ const struct afswtch *afp = ctx->afp;
+
if (afp->af_getaddr == NULL)
return;
/*
@@ -1161,8 +1169,9 @@
}
static void
-settunnel(const char *src, const char *dst, int s, const struct afswtch *afp)
+settunnel(if_ctx *ctx, const char *src, const char *dst)
{
+ const struct afswtch *afp = ctx->afp;
struct addrinfo *srcres, *dstres;
int ecode;
@@ -1184,25 +1193,23 @@
errx(1,
"source and destination address families do not match");
- afp->af_settunnel(s, srcres, dstres);
+ afp->af_settunnel(ctx->io->s, srcres, dstres);
freeaddrinfo(srcres);
freeaddrinfo(dstres);
}
-/* ARGSUSED */
static void
-deletetunnel(const char *vname, int param, int s, const struct afswtch *afp)
+deletetunnel(if_ctx *ctx, const char *vname, int param)
{
- if (ioctl(s, SIOCDIFPHYADDR, &ifr) < 0)
+ if (ioctl(ctx->io->s, SIOCDIFPHYADDR, &ifr) < 0)
err(1, "SIOCDIFPHYADDR");
}
#ifdef JAIL
static void
-setifvnet(const char *jname, int dummy __unused, int s,
- const struct afswtch *afp)
+setifvnet(if_ctx *ctx, const char *jname, int dummy __unused)
{
struct ifreq my_ifr;
@@ -1210,13 +1217,12 @@
my_ifr.ifr_jid = jail_getid(jname);
if (my_ifr.ifr_jid < 0)
errx(1, "%s", jail_errmsg);
- if (ioctl(s, SIOCSIFVNET, &my_ifr) < 0)
+ if (ioctl(ctx->io->s, SIOCSIFVNET, &my_ifr) < 0)
err(1, "SIOCSIFVNET");
}
static void
-setifrvnet(const char *jname, int dummy __unused, int s,
- const struct afswtch *afp)
+setifrvnet(if_ctx *ctx, const char *jname, int dummy __unused)
{
struct ifreq my_ifr;
@@ -1224,15 +1230,16 @@
my_ifr.ifr_jid = jail_getid(jname);
if (my_ifr.ifr_jid < 0)
errx(1, "%s", jail_errmsg);
- if (ioctl(s, SIOCSIFRVNET, &my_ifr) < 0)
+ if (ioctl(ctx->io->s, SIOCSIFRVNET, &my_ifr) < 0)
err(1, "SIOCSIFRVNET(%d, %s)", my_ifr.ifr_jid, my_ifr.ifr_name);
}
#endif
static void
-setifnetmask(const char *addr, int dummy __unused, int s,
- const struct afswtch *afp)
+setifnetmask(if_ctx *ctx, const char *addr, int dummy __unused)
{
+ const struct afswtch *afp = ctx->afp;
+
if (afp->af_getaddr != NULL) {
setmask++;
afp->af_getaddr(addr, MASK);
@@ -1240,16 +1247,19 @@
}
static void
-setifbroadaddr(const char *addr, int dummy __unused, int s,
- const struct afswtch *afp)
+setifbroadaddr(if_ctx *ctx, const char *addr, int dummy __unused)
{
+ const struct afswtch *afp = ctx->afp;
+
if (afp->af_getaddr != NULL)
afp->af_getaddr(addr, DSTADDR);
}
static void
-notealias(const char *addr, int param, int s, const struct afswtch *afp)
+notealias(if_ctx *ctx, const char *addr, int param)
{
+ const struct afswtch *afp = ctx->afp;
+
#define rqtosa(x) (&(((struct ifreq *)(afp->x))->ifr_addr))
if (setaddr && doalias == 0 && param < 0)
if (afp->af_addreq != NULL && afp->af_ridreq != NULL)
@@ -1265,11 +1275,11 @@
#undef rqtosa
}
-/*ARGSUSED*/
static void
-setifdstaddr(const char *addr, int param __unused, int s,
- const struct afswtch *afp)
+setifdstaddr(if_ctx *ctx, const char *addr, int param __unused)
{
+ const struct afswtch *afp = ctx->afp;
+
if (afp->af_getaddr != NULL)
afp->af_getaddr(addr, DSTADDR);
}
@@ -1304,12 +1314,12 @@
* Make a private copy so we can avoid that.
*/
static void
-setifflags(const char *vname, int value, int s, const struct afswtch *afp)
+setifflags(if_ctx *ctx, const char *vname, int value)
{
struct ifreq my_ifr;
int flags;
- flags = getifflags(name, s, false);
+ flags = getifflags(name, ctx->io->s, false);
if (value < 0) {
value = -value;
flags &= ~value;
@@ -1319,16 +1329,16 @@
(void) strlcpy(my_ifr.ifr_name, name, sizeof(my_ifr.ifr_name));
my_ifr.ifr_flags = flags & 0xffff;
my_ifr.ifr_flagshigh = flags >> 16;
- if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&my_ifr) < 0)
+ if (ioctl(ctx->io->s, SIOCSIFFLAGS, (caddr_t)&my_ifr) < 0)
Perror(vname);
}
void
-setifcap(const char *vname, int value, int s, const struct afswtch *afp)
+setifcap(if_ctx *ctx, const char *vname, int value)
{
int flags;
- if (ioctl(s, SIOCGIFCAP, (caddr_t)&ifr) < 0) {
+ if (ioctl(ctx->io->s, SIOCGIFCAP, (caddr_t)&ifr) < 0) {
Perror("ioctl (SIOCGIFCAP)");
exit(1);
}
@@ -1343,12 +1353,12 @@
if (ifr.ifr_curcap == flags)
return;
ifr.ifr_reqcap = flags;
- if (ioctl(s, SIOCSIFCAP, (caddr_t)&ifr) < 0)
+ if (ioctl(ctx->io->s, SIOCSIFCAP, (caddr_t)&ifr) < 0)
Perror(vname);
}
void
-setifcapnv(const char *vname, const char *arg, int s, const struct afswtch *afp)
+setifcapnv(if_ctx *ctx, const char *vname, const char *arg)
{
nvlist_t *nvcap;
void *buf;
@@ -1356,7 +1366,7 @@
size_t nvbuflen;
bool neg;
- if (ioctl(s, SIOCGIFCAP, (caddr_t)&ifr) < 0)
+ if (ioctl(ctx->io->s, SIOCGIFCAP, (caddr_t)&ifr) < 0)
Perror("ioctl (SIOCGIFCAP)");
if ((ifr.ifr_curcap & IFCAP_NV) == 0) {
warnx("IFCAP_NV not supported");
@@ -1387,7 +1397,7 @@
}
ifr.ifr_cap_nv.buf_length = ifr.ifr_cap_nv.length = nvbuflen;
ifr.ifr_cap_nv.buffer = buf;
- if (ioctl(s, SIOCSIFCAPNV, (caddr_t)&ifr) < 0)
+ if (ioctl(ctx->io->s, SIOCSIFCAPNV, (caddr_t)&ifr) < 0)
Perror(vname);
free(buf);
nvlist_destroy(nvcap);
@@ -1395,27 +1405,25 @@
}
static void
-setifmetric(const char *val, int dummy __unused, int s,
- const struct afswtch *afp)
+setifmetric(if_ctx *ctx, const char *val, int dummy __unused)
{
strlcpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
ifr.ifr_metric = atoi(val);
- if (ioctl(s, SIOCSIFMETRIC, (caddr_t)&ifr) < 0)
+ if (ioctl(ctx->io->s, SIOCSIFMETRIC, (caddr_t)&ifr) < 0)
err(1, "ioctl SIOCSIFMETRIC (set metric)");
}
static void
-setifmtu(const char *val, int dummy __unused, int s,
- const struct afswtch *afp)
+setifmtu(if_ctx *ctx, const char *val, int dummy __unused)
{
strlcpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
ifr.ifr_mtu = atoi(val);
- if (ioctl(s, SIOCSIFMTU, (caddr_t)&ifr) < 0)
+ if (ioctl(ctx->io->s, SIOCSIFMTU, (caddr_t)&ifr) < 0)
err(1, "ioctl SIOCSIFMTU (set mtu)");
}
static void
-setifpcp(const char *val, int arg __unused, int s, const struct afswtch *afp)
+setifpcp(if_ctx *ctx, const char *val, int arg __unused)
{
u_long ul;
char *endp;
@@ -1426,23 +1434,21 @@
if (ul > 7)
errx(1, "value for pcp out of range");
ifr.ifr_lan_pcp = ul;
- if (ioctl(s, SIOCSLANPCP, (caddr_t)&ifr) == -1)
+ if (ioctl(ctx->io->s, SIOCSLANPCP, (caddr_t)&ifr) == -1)
err(1, "SIOCSLANPCP");
}
static void
-disableifpcp(const char *val, int arg __unused, int s,
- const struct afswtch *afp)
+disableifpcp(if_ctx *ctx, const char *val, int arg __unused)
{
ifr.ifr_lan_pcp = IFNET_PCP_NONE;
- if (ioctl(s, SIOCSLANPCP, (caddr_t)&ifr) == -1)
+ if (ioctl(ctx->io->s, SIOCSLANPCP, (caddr_t)&ifr) == -1)
err(1, "SIOCSLANPCP");
}
static void
-setifname(const char *val, int dummy __unused, int s,
- const struct afswtch *afp)
+setifname(if_ctx *ctx, const char *val, int dummy __unused)
{
char *newname;
@@ -1452,7 +1458,7 @@
if (newname == NULL)
err(1, "no memory to set ifname");
ifr.ifr_data = newname;
- if (ioctl(s, SIOCSIFNAME, (caddr_t)&ifr) < 0) {
+ if (ioctl(ctx->io->s, SIOCSIFNAME, (caddr_t)&ifr) < 0) {
free(newname);
err(1, "ioctl SIOCSIFNAME (set name)");
}
@@ -1461,10 +1467,8 @@
free(newname);
}
-/* ARGSUSED */
static void
-setifdescr(const char *val, int dummy __unused, int s,
- const struct afswtch *afp)
+setifdescr(if_ctx *ctx, const char *val, int dummy __unused)
{
char *newdescr;
@@ -1483,18 +1487,16 @@
}
}
- if (ioctl(s, SIOCSIFDESCR, (caddr_t)&ifr) < 0)
+ if (ioctl(ctx->io->s, SIOCSIFDESCR, (caddr_t)&ifr) < 0)
err(1, "ioctl SIOCSIFDESCR (set descr)");
free(newdescr);
}
-/* ARGSUSED */
static void
-unsetifdescr(const char *val, int value, int s, const struct afswtch *afp)
+unsetifdescr(if_ctx *ctx, const char *val, int value)
{
-
- setifdescr("", 0, s, 0);
+ setifdescr(ctx, "", 0);
}
#define IFFBITS \
@@ -1658,6 +1660,10 @@
if (s < 0)
err(1, "socket(family %u,SOCK_DGRAM)", ifr.ifr_addr.sa_family);
+ struct io_handler h = { .s = s };
+ struct ifconfig_context _ctx = { .io = &h }, *ctx;
+ ctx = &_ctx;
+
printf("%s: ", name);
printb("flags", ifa->ifa_flags, IFFBITS);
print_metric(s);
@@ -1701,9 +1707,9 @@
}
#endif
if (allfamilies)
- af_other_status(s);
+ af_other_status(ctx);
else if (args->afp->af_other_status != NULL)
- args->afp->af_other_status(s);
+ args->afp->af_other_status(ctx);
print_ifstatus(s);
if (args->verbose > 0)
diff --git a/sbin/ifconfig/ifconfig_netlink.c b/sbin/ifconfig/ifconfig_netlink.c
--- a/sbin/ifconfig/ifconfig_netlink.c
+++ b/sbin/ifconfig/ifconfig_netlink.c
@@ -305,16 +305,17 @@
}
static void
-status_nl(struct ifconfig_args *args, struct io_handler *h, struct iface *iface)
+status_nl(if_ctx *ctx, struct iface *iface)
{
if_link_t *link = &iface->link;
+ struct ifconfig_args *args = ctx->args;
printf("%s: ", link->ifla_ifname);
printf("flags=%x", link->ifi_flags);
print_bits("IFF", &link->ifi_flags, 1, IFFBITS, nitems(IFFBITS));
- print_metric(h->s);
+ print_metric(ctx->io->s);
printf(" mtu %d\n", link->ifla_mtu);
if (link->ifla_ifalias != NULL)
@@ -322,40 +323,40 @@
/* TODO: convert to netlink */
strlcpy(ifr.ifr_name, link->ifla_ifname, sizeof(ifr.ifr_name));
- print_ifcap(args, h->s);
- tunnel_status(h->s);
+ print_ifcap(args, ctx->io->s);
+ tunnel_status(ctx->io->s);
if (args->allfamilies | (args->afp != NULL && args->afp->af_af == AF_LINK)) {
/* Start with link-level */
const struct afswtch *p = af_getbyfamily(AF_LINK);
if (p != NULL && link->ifla_address != NULL)
- p->af_status_nl(args, h, link, NULL);
+ p->af_status(ctx, link, NULL);
}
- sort_iface_ifaddrs(h->ss, iface);
+ sort_iface_ifaddrs(ctx->io->ss, iface);
for (struct ifa *ifa = iface->ifa; ifa != NULL; ifa = ifa->next) {
if (args->allfamilies) {
const struct afswtch *p = af_getbyfamily(ifa->addr.ifa_family);
if (p != NULL)
- p->af_status_nl(args, h, link, &ifa->addr);
+ p->af_status(ctx, link, &ifa->addr);
} else if (args->afp->af_af == ifa->addr.ifa_family) {
const struct afswtch *p = args->afp;
- p->af_status_nl(args, h, link, &ifa->addr);
+ p->af_status(ctx, link, &ifa->addr);
}
}
/* TODO: convert to netlink */
if (args->allfamilies)
- af_other_status(h->s);
+ af_other_status(ctx);
else if (args->afp->af_other_status != NULL)
- args->afp->af_other_status(h->s);
+ args->afp->af_other_status(ctx);
- print_ifstatus(h->s);
+ print_ifstatus(ctx->io->s);
if (args->verbose > 0)
- sfp_status(h->s, &ifr, args->verbose);
+ sfp_status(ctx->io->s, &ifr, args->verbose);
}
static int
@@ -401,6 +402,8 @@
.s = get_local_socket(),
.ss = &ss,
};
+ struct ifconfig_context _ctx = { .args = args, .io = &h }, *ctx;
+ ctx = &_ctx;
for (uint32_t i = 0, num = 0; i < ifmap->count; i++) {
struct iface *iface = sorted_ifaces[i];
@@ -415,7 +418,7 @@
printf(" ");
fputs(iface->link.ifla_ifname, stdout);
} else if (args->argc == 0)
- status_nl(args, &h, iface);
+ status_nl(ctx, iface);
else
ifconfig(args->argc, args->argv, 0, args->afp);
}
diff --git a/sbin/ifconfig/iffib.c b/sbin/ifconfig/iffib.c
--- a/sbin/ifconfig/iffib.c
+++ b/sbin/ifconfig/iffib.c
@@ -46,26 +46,25 @@
#include "ifconfig.h"
static void
-fib_status(int s)
+fib_status(if_ctx *ctx)
{
struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));
strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
- if (ioctl(s, SIOCGIFFIB, (caddr_t)&ifr) == 0 &&
+ if (ioctl_ctx(ctx, SIOCGIFFIB, (caddr_t)&ifr) == 0 &&
ifr.ifr_fib != RT_DEFAULT_FIB)
printf("\tfib: %u\n", ifr.ifr_fib);
memset(&ifr, 0, sizeof(ifr));
strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
- if (ioctl(s, SIOCGTUNFIB, (caddr_t)&ifr) == 0 &&
+ if (ioctl_ctx(ctx, SIOCGTUNFIB, (caddr_t)&ifr) == 0 &&
ifr.ifr_fib != RT_DEFAULT_FIB)
printf("\ttunnelfib: %u\n", ifr.ifr_fib);
}
static void
-setiffib(const char *val, int dummy __unused, int s,
- const struct afswtch *afp)
+setiffib(if_ctx *ctx, const char *val, int dummy __unused)
{
unsigned long fib;
char *ep;
@@ -78,13 +77,12 @@
strlcpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
ifr.ifr_fib = fib;
- if (ioctl(s, SIOCSIFFIB, (caddr_t)&ifr) < 0)
+ if (ioctl(ctx->io->s, SIOCSIFFIB, (caddr_t)&ifr) < 0)
warn("ioctl (SIOCSIFFIB)");
}
static void
-settunfib(const char *val, int dummy __unused, int s,
- const struct afswtch *afp)
+settunfib(if_ctx *ctx, const char *val, int dummy __unused)
{
unsigned long fib;
char *ep;
@@ -97,7 +95,7 @@
strlcpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
ifr.ifr_fib = fib;
- if (ioctl(s, SIOCSTUNFIB, (caddr_t)&ifr) < 0)
+ if (ioctl(ctx->io->s, SIOCSTUNFIB, (caddr_t)&ifr) < 0)
warn("ioctl (SIOCSTUNFIB)");
}
diff --git a/sbin/ifconfig/ifgif.c b/sbin/ifconfig/ifgif.c
--- a/sbin/ifconfig/ifgif.c
+++ b/sbin/ifconfig/ifgif.c
@@ -55,15 +55,13 @@
#define GIFBITS "\020\2IGNORE_SOURCE"
-static void gif_status(int);
-
static void
-gif_status(int s)
+gif_status(if_ctx *ctx)
{
int opts;
ifr.ifr_data = (caddr_t)&opts;
- if (ioctl(s, GIFGOPTS, &ifr) == -1)
+ if (ioctl_ctx(ctx, GIFGOPTS, &ifr) == -1)
return;
if (opts == 0)
return;
@@ -72,12 +70,12 @@
}
static void
-setgifopts(const char *val, int d, int s, const struct afswtch *afp)
+setgifopts(if_ctx *ctx, const char *val, int d)
{
int opts;
ifr.ifr_data = (caddr_t)&opts;
- if (ioctl(s, GIFGOPTS, &ifr) == -1) {
+ if (ioctl_ctx(ctx, GIFGOPTS, &ifr) == -1) {
warn("ioctl(GIFGOPTS)");
return;
}
@@ -87,7 +85,7 @@
else
opts |= d;
- if (ioctl(s, GIFSOPTS, &ifr) == -1) {
+ if (ioctl_ctx(ctx, GIFSOPTS, &ifr) == -1) {
warn("ioctl(GIFSOPTS)");
return;
}
diff --git a/sbin/ifconfig/ifgre.c b/sbin/ifconfig/ifgre.c
--- a/sbin/ifconfig/ifgre.c
+++ b/sbin/ifconfig/ifgre.c
@@ -46,61 +46,57 @@
#define GREBITS "\020\01ENABLE_CSUM\02ENABLE_SEQ\03UDPENCAP"
-static void gre_status(int s);
-
static void
-gre_status(int s)
+gre_status(if_ctx *ctx)
{
uint32_t opts, port;
opts = 0;
ifr.ifr_data = (caddr_t)&opts;
- if (ioctl(s, GREGKEY, &ifr) == 0)
+ if (ioctl_ctx(ctx, GREGKEY, &ifr) == 0)
if (opts != 0)
printf("\tgrekey: 0x%x (%u)\n", opts, opts);
opts = 0;
- if (ioctl(s, GREGOPTS, &ifr) != 0 || opts == 0)
+ if (ioctl_ctx(ctx, GREGOPTS, &ifr) != 0 || opts == 0)
return;
port = 0;
ifr.ifr_data = (caddr_t)&port;
- if (ioctl(s, GREGPORT, &ifr) == 0 && port != 0)
+ if (ioctl_ctx(ctx, GREGPORT, &ifr) == 0 && port != 0)
printf("\tudpport: %u\n", port);
printb("\toptions", opts, GREBITS);
putchar('\n');
}
static void
-setifgrekey(const char *val, int dummy __unused, int s,
- const struct afswtch *afp)
+setifgrekey(if_ctx *ctx, const char *val, int dummy __unused)
{
uint32_t grekey = strtol(val, NULL, 0);
strlcpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
ifr.ifr_data = (caddr_t)&grekey;
- if (ioctl(s, GRESKEY, (caddr_t)&ifr) < 0)
+ if (ioctl(ctx->io->s, GRESKEY, (caddr_t)&ifr) < 0)
warn("ioctl (set grekey)");
}
static void
-setifgreport(const char *val, int dummy __unused, int s,
- const struct afswtch *afp)
+setifgreport(if_ctx *ctx, const char *val, int dummy __unused)
{
uint32_t udpport = strtol(val, NULL, 0);
strlcpy(ifr.ifr_name, name, sizeof (ifr.ifr_name));
ifr.ifr_data = (caddr_t)&udpport;
- if (ioctl(s, GRESPORT, (caddr_t)&ifr) < 0)
+ if (ioctl(ctx->io->s, GRESPORT, (caddr_t)&ifr) < 0)
warn("ioctl (set udpport)");
}
static void
-setifgreopts(const char *val, int d, int s, const struct afswtch *afp)
+setifgreopts(if_ctx *ctx, const char *val, int d)
{
uint32_t opts;
ifr.ifr_data = (caddr_t)&opts;
- if (ioctl(s, GREGOPTS, &ifr) == -1) {
+ if (ioctl(ctx->io->s, GREGOPTS, &ifr) == -1) {
warn("ioctl(GREGOPTS)");
return;
}
@@ -110,7 +106,7 @@
else
opts |= d;
- if (ioctl(s, GRESOPTS, &ifr) == -1) {
+ if (ioctl(ctx->io->s, GRESOPTS, &ifr) == -1) {
warn("ioctl(GIFSOPTS)");
return;
}
diff --git a/sbin/ifconfig/ifgroup.c b/sbin/ifconfig/ifgroup.c
--- a/sbin/ifconfig/ifgroup.c
+++ b/sbin/ifconfig/ifgroup.c
@@ -47,9 +47,8 @@
#include "ifconfig.h"
-/* ARGSUSED */
static void
-setifgroup(const char *group_name, int d, int s, const struct afswtch *rafp)
+setifgroup(if_ctx *ctx, const char *group_name, int dummy __unused)
{
struct ifgroupreq ifgr;
@@ -61,13 +60,12 @@
if (strlcpy(ifgr.ifgr_group, group_name, IFNAMSIZ) >= IFNAMSIZ)
errx(1, "setifgroup: group name too long");
- if (ioctl(s, SIOCAIFGROUP, (caddr_t)&ifgr) == -1 && errno != EEXIST)
+ if (ioctl_ctx(ctx, SIOCAIFGROUP, (caddr_t)&ifgr) == -1 && errno != EEXIST)
err(1," SIOCAIFGROUP");
}
-/* ARGSUSED */
static void
-unsetifgroup(const char *group_name, int d, int s, const struct afswtch *rafp)
+unsetifgroup(if_ctx *ctx, const char *group_name, int dummy __unused)
{
struct ifgroupreq ifgr;
@@ -79,12 +77,12 @@
if (strlcpy(ifgr.ifgr_group, group_name, IFNAMSIZ) >= IFNAMSIZ)
errx(1, "unsetifgroup: group name too long");
- if (ioctl(s, SIOCDIFGROUP, (caddr_t)&ifgr) == -1 && errno != ENOENT)
+ if (ioctl_ctx(ctx, SIOCDIFGROUP, (caddr_t)&ifgr) == -1 && errno != ENOENT)
err(1, "SIOCDIFGROUP");
}
static void
-getifgroups(int s)
+getifgroups(if_ctx *ctx __unused)
{
struct ifgroupreq ifgr;
size_t cnt;
diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c
--- a/sbin/ifconfig/ifieee80211.c
+++ b/sbin/ifconfig/ifieee80211.c
@@ -602,7 +602,7 @@
}
static void
-set80211ssid(const char *val, int d, int s, const struct afswtch *rafp)
+set80211ssid(if_ctx *ctx, const char *val, int dummy __unused)
{
int ssid;
int len;
@@ -620,11 +620,11 @@
if (get_string(val, NULL, data, &len) == NULL)
exit(1);
- set80211(s, IEEE80211_IOC_SSID, ssid, len, data);
+ set80211(ctx->io->s, IEEE80211_IOC_SSID, ssid, len, data);
}
static void
-set80211meshid(const char *val, int d, int s, const struct afswtch *rafp)
+set80211meshid(if_ctx *ctx, const char *val, int dummy __unused)
{
int len;
u_int8_t data[IEEE80211_NWID_LEN];
@@ -634,11 +634,11 @@
if (get_string(val, NULL, data, &len) == NULL)
exit(1);
- set80211(s, IEEE80211_IOC_MESH_ID, 0, len, data);
+ set80211(ctx->io->s, IEEE80211_IOC_MESH_ID, 0, len, data);
}
static void
-set80211stationname(const char *val, int d, int s, const struct afswtch *rafp)
+set80211stationname(if_ctx *ctx, const char *val, int dummy __unused)
{
int len;
u_int8_t data[33];
@@ -647,7 +647,7 @@
len = sizeof(data);
get_string(val, NULL, data, &len);
- set80211(s, IEEE80211_IOC_STATIONNAME, 0, len, data);
+ set80211(ctx->io->s, IEEE80211_IOC_STATIONNAME, 0, len, data);
}
/*
@@ -833,18 +833,20 @@
}
static void
-set80211channel(const char *val, int d, int s, const struct afswtch *rafp)
+set80211channel(if_ctx *ctx, const char *val, int dummy __unused)
{
struct ieee80211_channel chan;
+ int s = ctx->io->s;
getchannel(s, &chan, val);
set80211(s, IEEE80211_IOC_CURCHAN, 0, sizeof(chan), &chan);
}
static void
-set80211chanswitch(const char *val, int d, int s, const struct afswtch *rafp)
+set80211chanswitch(if_ctx *ctx, const char *val, int dummy __unused)
{
struct ieee80211_chanswitch_req csr;
+ int s = ctx->io->s;
getchannel(s, &csr.csa_chan, val);
csr.csa_mode = 1;
@@ -853,7 +855,7 @@
}
static void
-set80211authmode(const char *val, int d, int s, const struct afswtch *rafp)
+set80211authmode(if_ctx *ctx, const char *val, int dummy __unused)
{
int mode;
@@ -871,11 +873,11 @@
errx(1, "unknown authmode");
}
- set80211(s, IEEE80211_IOC_AUTHMODE, mode, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_AUTHMODE, mode, 0, NULL);
}
static void
-set80211powersavemode(const char *val, int d, int s, const struct afswtch *rafp)
+set80211powersavemode(if_ctx *ctx, const char *val, int dummy __unused)
{
int mode;
@@ -893,12 +895,14 @@
errx(1, "unknown powersavemode");
}
- set80211(s, IEEE80211_IOC_POWERSAVE, mode, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_POWERSAVE, mode, 0, NULL);
}
static void
-set80211powersave(const char *val, int d, int s, const struct afswtch *rafp)
+set80211powersave(if_ctx *ctx, const char *val, int d)
{
+ int s = ctx->io->s;
+
if (d == 0)
set80211(s, IEEE80211_IOC_POWERSAVE, IEEE80211_POWERSAVE_OFF,
0, NULL);
@@ -908,13 +912,13 @@
}
static void
-set80211powersavesleep(const char *val, int d, int s, const struct afswtch *rafp)
+set80211powersavesleep(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_POWERSAVESLEEP, atoi(val), 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_POWERSAVESLEEP, atoi(val), 0, NULL);
}
static void
-set80211wepmode(const char *val, int d, int s, const struct afswtch *rafp)
+set80211wepmode(if_ctx *ctx, const char *val, int dummy __unused)
{
int mode;
@@ -928,13 +932,13 @@
errx(1, "unknown wep mode");
}
- set80211(s, IEEE80211_IOC_WEP, mode, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_WEP, mode, 0, NULL);
}
static void
-set80211wep(const char *val, int d, int s, const struct afswtch *rafp)
+set80211wep(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_WEP, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_WEP, d, 0, NULL);
}
static int
@@ -944,8 +948,10 @@
}
static void
-set80211weptxkey(const char *val, int d, int s, const struct afswtch *rafp)
+set80211weptxkey(if_ctx *ctx, const char *val, int dummy __unused)
{
+ int s = ctx->io->s;
+
if (isundefarg(val))
set80211(s, IEEE80211_IOC_WEPTXKEY, IEEE80211_KEYIX_NONE, 0, NULL);
else
@@ -953,11 +959,12 @@
}
static void
-set80211wepkey(const char *val, int d, int s, const struct afswtch *rafp)
+set80211wepkey(if_ctx *ctx, const char *val, int dummy __unused)
{
int key = 0;
int len;
u_int8_t data[IEEE80211_KEYBUF_SIZE];
+ int s = ctx->io->s;
if (isdigit((int)val[0]) && val[1] == ':') {
key = atoi(val)-1;
@@ -977,11 +984,12 @@
* it's not all that hard.
*/
static void
-set80211nwkey(const char *val, int d, int s, const struct afswtch *rafp)
+set80211nwkey(if_ctx *ctx, const char *val, int dummy __unused)
{
int txkey;
int i, len;
u_int8_t data[IEEE80211_KEYBUF_SIZE];
+ int s = ctx->io->s;
set80211(s, IEEE80211_IOC_WEP, IEEE80211_WEP_ON, 0, NULL);
@@ -1015,14 +1023,14 @@
}
static void
-set80211rtsthreshold(const char *val, int d, int s, const struct afswtch *rafp)
+set80211rtsthreshold(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_RTSTHRESHOLD,
+ set80211(ctx->io->s, IEEE80211_IOC_RTSTHRESHOLD,
isundefarg(val) ? IEEE80211_RTS_MAX : atoi(val), 0, NULL);
}
static void
-set80211protmode(const char *val, int d, int s, const struct afswtch *rafp)
+set80211protmode(if_ctx *ctx, const char *val, int dummy __unused)
{
int mode;
@@ -1036,11 +1044,11 @@
errx(1, "unknown protection mode");
}
- set80211(s, IEEE80211_IOC_PROTMODE, mode, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_PROTMODE, mode, 0, NULL);
}
static void
-set80211htprotmode(const char *val, int d, int s, const struct afswtch *rafp)
+set80211htprotmode(if_ctx *ctx, const char *val, int dummy __unused)
{
int mode;
@@ -1052,11 +1060,11 @@
errx(1, "unknown protection mode");
}
- set80211(s, IEEE80211_IOC_HTPROTMODE, mode, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_HTPROTMODE, mode, 0, NULL);
}
static void
-set80211txpower(const char *val, int d, int s, const struct afswtch *rafp)
+set80211txpower(if_ctx *ctx, const char *val, int dummy __unused)
{
double v = atof(val);
int txpow;
@@ -1064,7 +1072,7 @@
txpow = (int) (2*v);
if (txpow != 2*v)
errx(-1, "invalid tx power (must be .5 dBm units)");
- set80211(s, IEEE80211_IOC_TXPOWER, txpow, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_TXPOWER, txpow, 0, NULL);
}
#define IEEE80211_ROAMING_DEVICE 0
@@ -1072,7 +1080,7 @@
#define IEEE80211_ROAMING_MANUAL 2
static void
-set80211roaming(const char *val, int d, int s, const struct afswtch *rafp)
+set80211roaming(if_ctx *ctx, const char *val, int dummy __unused)
{
int mode;
@@ -1085,44 +1093,45 @@
} else {
errx(1, "unknown roaming mode");
}
- set80211(s, IEEE80211_IOC_ROAMING, mode, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_ROAMING, mode, 0, NULL);
}
static void
-set80211wme(const char *val, int d, int s, const struct afswtch *rafp)
+set80211wme(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_WME, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_WME, d, 0, NULL);
}
static void
-set80211hidessid(const char *val, int d, int s, const struct afswtch *rafp)
+set80211hidessid(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_HIDESSID, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_HIDESSID, d, 0, NULL);
}
static void
-set80211apbridge(const char *val, int d, int s, const struct afswtch *rafp)
+set80211apbridge(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_APBRIDGE, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_APBRIDGE, d, 0, NULL);
}
static void
-set80211fastframes(const char *val, int d, int s, const struct afswtch *rafp)
+set80211fastframes(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_FF, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_FF, d, 0, NULL);
}
static void
-set80211dturbo(const char *val, int d, int s, const struct afswtch *rafp)
+set80211dturbo(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_TURBOP, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_TURBOP, d, 0, NULL);
}
static void
-set80211chanlist(const char *val, int d, int s, const struct afswtch *rafp)
+set80211chanlist(if_ctx *ctx, const char *val, int dummy __unused)
{
struct ieee80211req_chanlist chanlist;
char *temp, *cp, *tp;
+ int s = ctx->io->s;
temp = malloc(strlen(val) + 1);
if (temp == NULL)
@@ -1171,8 +1180,10 @@
}
static void
-set80211bssid(const char *val, int d, int s, const struct afswtch *rafp)
+set80211bssid(if_ctx *ctx, const char *val, int dummy __unused)
{
+ int s = ctx->io->s;
+
if (!isanyarg(val)) {
char *temp;
@@ -1212,90 +1223,91 @@
errx(1, "unknown wme access class %s", ac);
}
-static
-DECL_CMD_FUNC2(set80211cwmin, ac, val)
+static void
+set80211cwmin(if_ctx *ctx, const char *ac, const char *val)
{
- set80211(s, IEEE80211_IOC_WME_CWMIN, atoi(val), getac(ac), NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_WME_CWMIN, atoi(val), getac(ac), NULL);
}
-static
-DECL_CMD_FUNC2(set80211cwmax, ac, val)
+static void
+set80211cwmax(if_ctx *ctx, const char *ac, const char *val)
{
- set80211(s, IEEE80211_IOC_WME_CWMAX, atoi(val), getac(ac), NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_WME_CWMAX, atoi(val), getac(ac), NULL);
}
-static
-DECL_CMD_FUNC2(set80211aifs, ac, val)
+static void
+set80211aifs(if_ctx *ctx, const char *ac, const char *val)
{
- set80211(s, IEEE80211_IOC_WME_AIFS, atoi(val), getac(ac), NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_WME_AIFS, atoi(val), getac(ac), NULL);
}
-static
-DECL_CMD_FUNC2(set80211txoplimit, ac, val)
+static void
+set80211txoplimit(if_ctx *ctx, const char *ac, const char *val)
{
- set80211(s, IEEE80211_IOC_WME_TXOPLIMIT, atoi(val), getac(ac), NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_WME_TXOPLIMIT, atoi(val), getac(ac), NULL);
}
-static
-DECL_CMD_FUNC(set80211acm, ac, d)
+static void
+set80211acm(if_ctx *ctx, const char *ac, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_WME_ACM, 1, getac(ac), NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_WME_ACM, 1, getac(ac), NULL);
}
-static
-DECL_CMD_FUNC(set80211noacm, ac, d)
+
+static void
+set80211noacm(if_ctx *ctx, const char *ac, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_WME_ACM, 0, getac(ac), NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_WME_ACM, 0, getac(ac), NULL);
}
-static
-DECL_CMD_FUNC(set80211ackpolicy, ac, d)
+static void
+set80211ackpolicy(if_ctx *ctx, const char *ac, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_WME_ACKPOLICY, 1, getac(ac), NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_WME_ACKPOLICY, 1, getac(ac), NULL);
}
-static
-DECL_CMD_FUNC(set80211noackpolicy, ac, d)
+static void
+set80211noackpolicy(if_ctx *ctx, const char *ac, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_WME_ACKPOLICY, 0, getac(ac), NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_WME_ACKPOLICY, 0, getac(ac), NULL);
}
-static
-DECL_CMD_FUNC2(set80211bsscwmin, ac, val)
+static void
+set80211bsscwmin(if_ctx *ctx, const char *ac, const char *val)
{
- set80211(s, IEEE80211_IOC_WME_CWMIN, atoi(val),
+ set80211(ctx->io->s, IEEE80211_IOC_WME_CWMIN, atoi(val),
getac(ac)|IEEE80211_WMEPARAM_BSS, NULL);
}
-static
-DECL_CMD_FUNC2(set80211bsscwmax, ac, val)
+static void
+set80211bsscwmax(if_ctx *ctx, const char *ac, const char *val)
{
- set80211(s, IEEE80211_IOC_WME_CWMAX, atoi(val),
+ set80211(ctx->io->s, IEEE80211_IOC_WME_CWMAX, atoi(val),
getac(ac)|IEEE80211_WMEPARAM_BSS, NULL);
}
-static
-DECL_CMD_FUNC2(set80211bssaifs, ac, val)
+static void
+set80211bssaifs(if_ctx *ctx, const char *ac, const char *val)
{
- set80211(s, IEEE80211_IOC_WME_AIFS, atoi(val),
+ set80211(ctx->io->s, IEEE80211_IOC_WME_AIFS, atoi(val),
getac(ac)|IEEE80211_WMEPARAM_BSS, NULL);
}
-static
-DECL_CMD_FUNC2(set80211bsstxoplimit, ac, val)
+static void
+set80211bsstxoplimit(if_ctx *ctx, const char *ac, const char *val)
{
- set80211(s, IEEE80211_IOC_WME_TXOPLIMIT, atoi(val),
+ set80211(ctx->io->s, IEEE80211_IOC_WME_TXOPLIMIT, atoi(val),
getac(ac)|IEEE80211_WMEPARAM_BSS, NULL);
}
-static
-DECL_CMD_FUNC(set80211dtimperiod, val, d)
+static void
+set80211dtimperiod(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_DTIM_PERIOD, atoi(val), 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_DTIM_PERIOD, atoi(val), 0, NULL);
}
-static
-DECL_CMD_FUNC(set80211bintval, val, d)
+static void
+set80211bintval(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_BEACON_INTERVAL, atoi(val), 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_BEACON_INTERVAL, atoi(val), 0, NULL);
}
static void
@@ -1317,20 +1329,20 @@
set80211(s, op, 0, IEEE80211_ADDR_LEN, LLADDR(&sdl));
}
-static
-DECL_CMD_FUNC(set80211addmac, val, d)
+static void
+set80211addmac(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211macmac(s, IEEE80211_IOC_ADDMAC, val);
+ set80211macmac(ctx->io->s, IEEE80211_IOC_ADDMAC, val);
}
-static
-DECL_CMD_FUNC(set80211delmac, val, d)
+static void
+set80211delmac(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211macmac(s, IEEE80211_IOC_DELMAC, val);
+ set80211macmac(ctx->io->s, IEEE80211_IOC_DELMAC, val);
}
-static
-DECL_CMD_FUNC(set80211kickmac, val, d)
+static void
+set80211kickmac(if_ctx *ctx, const char *val, int dummy __unused)
{
char *temp;
struct sockaddr_dl sdl;
@@ -1350,13 +1362,13 @@
mlme.im_op = IEEE80211_MLME_DEAUTH;
mlme.im_reason = IEEE80211_REASON_AUTH_EXPIRE;
memcpy(mlme.im_macaddr, LLADDR(&sdl), IEEE80211_ADDR_LEN);
- set80211(s, IEEE80211_IOC_MLME, 0, sizeof(mlme), &mlme);
+ set80211(ctx->io->s, IEEE80211_IOC_MLME, 0, sizeof(mlme), &mlme);
}
-static
-DECL_CMD_FUNC(set80211maccmd, val, d)
+static void
+set80211maccmd(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_MACCMD, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_MACCMD, d, 0, NULL);
}
static void
@@ -1379,26 +1391,26 @@
IEEE80211_ADDR_LEN, LLADDR(&sdl));
}
-static
-DECL_CMD_FUNC(set80211addmeshrt, val, d)
+static void
+set80211addmeshrt(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211meshrtmac(s, IEEE80211_MESH_RTCMD_ADD, val);
+ set80211meshrtmac(ctx->io->s, IEEE80211_MESH_RTCMD_ADD, val);
}
-static
-DECL_CMD_FUNC(set80211delmeshrt, val, d)
+static void
+set80211delmeshrt(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211meshrtmac(s, IEEE80211_MESH_RTCMD_DELETE, val);
+ set80211meshrtmac(ctx->io->s, IEEE80211_MESH_RTCMD_DELETE, val);
}
-static
-DECL_CMD_FUNC(set80211meshrtcmd, val, d)
+static void
+set80211meshrtcmd(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_MESH_RTCMD, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_MESH_RTCMD, d, 0, NULL);
}
-static
-DECL_CMD_FUNC(set80211hwmprootmode, val, d)
+static void
+set80211hwmprootmode(if_ctx *ctx, const char *val, int dummy __unused)
{
int mode;
@@ -1410,73 +1422,73 @@
mode = IEEE80211_HWMP_ROOTMODE_RANN;
else
mode = IEEE80211_HWMP_ROOTMODE_DISABLED;
- set80211(s, IEEE80211_IOC_HWMP_ROOTMODE, mode, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_HWMP_ROOTMODE, mode, 0, NULL);
}
-static
-DECL_CMD_FUNC(set80211hwmpmaxhops, val, d)
+static void
+set80211hwmpmaxhops(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_HWMP_MAXHOPS, atoi(val), 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_HWMP_MAXHOPS, atoi(val), 0, NULL);
}
static void
-set80211pureg(const char *val, int d, int s, const struct afswtch *rafp)
+set80211pureg(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_PUREG, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_PUREG, d, 0, NULL);
}
static void
-set80211quiet(const char *val, int d, int s, const struct afswtch *rafp)
+set80211quiet(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_QUIET, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_QUIET, d, 0, NULL);
}
-static
-DECL_CMD_FUNC(set80211quietperiod, val, d)
+static void
+set80211quietperiod(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_QUIET_PERIOD, atoi(val), 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_QUIET_PERIOD, atoi(val), 0, NULL);
}
-static
-DECL_CMD_FUNC(set80211quietcount, val, d)
+static void
+set80211quietcount(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_QUIET_COUNT, atoi(val), 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_QUIET_COUNT, atoi(val), 0, NULL);
}
-static
-DECL_CMD_FUNC(set80211quietduration, val, d)
+static void
+set80211quietduration(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_QUIET_DUR, atoi(val), 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_QUIET_DUR, atoi(val), 0, NULL);
}
-static
-DECL_CMD_FUNC(set80211quietoffset, val, d)
+static void
+set80211quietoffset(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_QUIET_OFFSET, atoi(val), 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_QUIET_OFFSET, atoi(val), 0, NULL);
}
static void
-set80211bgscan(const char *val, int d, int s, const struct afswtch *rafp)
+set80211bgscan(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_BGSCAN, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_BGSCAN, d, 0, NULL);
}
-static
-DECL_CMD_FUNC(set80211bgscanidle, val, d)
+static void
+set80211bgscanidle(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_BGSCAN_IDLE, atoi(val), 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_BGSCAN_IDLE, atoi(val), 0, NULL);
}
-static
-DECL_CMD_FUNC(set80211bgscanintvl, val, d)
+static void
+set80211bgscanintvl(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_BGSCAN_INTERVAL, atoi(val), 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_BGSCAN_INTERVAL, atoi(val), 0, NULL);
}
-static
-DECL_CMD_FUNC(set80211scanvalid, val, d)
+static void
+set80211scanvalid(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_SCANVALID, atoi(val), 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_SCANVALID, atoi(val), 0, NULL);
}
/*
@@ -1615,11 +1627,12 @@
_APPLY1(_flags, _base, _param, _v); \
} while (0)
-static
-DECL_CMD_FUNC(set80211roamrssi, val, d)
+static void
+set80211roamrssi(if_ctx *ctx, const char *val, int dummy __unused)
{
double v = atof(val);
int rssi, flags;
+ int s = ctx->io->s;
rssi = (int) (2*v);
if (rssi != 2*v)
@@ -1646,10 +1659,11 @@
return rate; /* NB: returns 2x the specified value */
}
-static
-DECL_CMD_FUNC(set80211roamrate, val, d)
+static void
+set80211roamrate(if_ctx *ctx, const char *val, int dummy __unused)
{
int rate, flags;
+ int s = ctx->io->s;
rate = getrate(val, "roam");
flags = getmodeflags(val);
@@ -1662,10 +1676,11 @@
callback_register(setroam_cb, &roamparams);
}
-static
-DECL_CMD_FUNC(set80211mcastrate, val, d)
+static void
+set80211mcastrate(if_ctx *ctx, const char *val, int dummy __unused)
{
int rate, flags;
+ int s = ctx->io->s;
rate = getrate(val, "mcast");
flags = getmodeflags(val);
@@ -1678,10 +1693,11 @@
callback_register(settxparams_cb, &txparams);
}
-static
-DECL_CMD_FUNC(set80211mgtrate, val, d)
+static void
+set80211mgtrate(if_ctx *ctx, const char *val, int dummy __unused)
{
int rate, flags;
+ int s = ctx->io->s;
rate = getrate(val, "mgmt");
flags = getmodeflags(val);
@@ -1694,10 +1710,11 @@
callback_register(settxparams_cb, &txparams);
}
-static
-DECL_CMD_FUNC(set80211ucastrate, val, d)
+static void
+set80211ucastrate(if_ctx *ctx, const char *val, int dummy __unused)
{
int flags;
+ int s = ctx->io->s;
gettxparams(s);
flags = getmodeflags(val);
@@ -1720,10 +1737,11 @@
callback_register(settxparams_cb, &txparams);
}
-static
-DECL_CMD_FUNC(set80211maxretry, val, d)
+static void
+set80211maxretry(if_ctx *ctx, const char *val, int dummy __unused)
{
int v = atoi(val), flags;
+ int s = ctx->io->s;
flags = getmodeflags(val);
gettxparams(s);
@@ -1737,51 +1755,52 @@
#undef _APPLY_RATE
#undef _APPLY
-static
-DECL_CMD_FUNC(set80211fragthreshold, val, d)
+static void
+set80211fragthreshold(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_FRAGTHRESHOLD,
+ set80211(ctx->io->s, IEEE80211_IOC_FRAGTHRESHOLD,
isundefarg(val) ? IEEE80211_FRAG_MAX : atoi(val), 0, NULL);
}
-static
-DECL_CMD_FUNC(set80211bmissthreshold, val, d)
+static void
+set80211bmissthreshold(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_BMISSTHRESHOLD,
+ set80211(ctx->io->s, IEEE80211_IOC_BMISSTHRESHOLD,
isundefarg(val) ? IEEE80211_HWBMISS_MAX : atoi(val), 0, NULL);
}
static void
-set80211burst(const char *val, int d, int s, const struct afswtch *rafp)
+set80211burst(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_BURST, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_BURST, d, 0, NULL);
}
static void
-set80211doth(const char *val, int d, int s, const struct afswtch *rafp)
+set80211doth(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_DOTH, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_DOTH, d, 0, NULL);
}
static void
-set80211dfs(const char *val, int d, int s, const struct afswtch *rafp)
+set80211dfs(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_DFS, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_DFS, d, 0, NULL);
}
static void
-set80211shortgi(const char *val, int d, int s, const struct afswtch *rafp)
+set80211shortgi(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_SHORTGI,
+ set80211(ctx->io->s, IEEE80211_IOC_SHORTGI,
d ? (IEEE80211_HTCAP_SHORTGI20 | IEEE80211_HTCAP_SHORTGI40) : 0,
0, NULL);
}
/* XXX 11ac density/size is different */
static void
-set80211ampdu(const char *val, int d, int s, const struct afswtch *rafp)
+set80211ampdu(if_ctx *ctx, const char *val, int d)
{
int ampdu;
+ int s = ctx->io->s;
if (get80211val(s, IEEE80211_IOC_AMPDU, &ampdu) < 0)
errx(-1, "cannot set AMPDU setting");
@@ -1794,9 +1813,10 @@
}
static void
-set80211stbc(const char *val, int d, int s, const struct afswtch *rafp)
+set80211stbc(if_ctx *ctx, const char *val, int d)
{
int stbc;
+ int s = ctx->io->s;
if (get80211val(s, IEEE80211_IOC_STBC, &stbc) < 0)
errx(-1, "cannot set STBC setting");
@@ -1809,8 +1829,9 @@
}
static void
-set80211ldpc(const char *val, int d, int s, const struct afswtch *rafp)
+set80211ldpc(if_ctx *ctx, const char *val, int d)
{
+ int s = ctx->io->s;
int ldpc;
if (get80211val(s, IEEE80211_IOC_LDPC, &ldpc) < 0)
@@ -1824,13 +1845,13 @@
}
static void
-set80211uapsd(const char *val, int d, int s, const struct afswtch *rafp)
+set80211uapsd(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_UAPSD, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_UAPSD, d, 0, NULL);
}
-static
-DECL_CMD_FUNC(set80211ampdulimit, val, d)
+static void
+set80211ampdulimit(if_ctx *ctx, const char *val, int dummy __unused)
{
int v;
@@ -1854,12 +1875,12 @@
default:
errx(-1, "invalid A-MPDU limit %s", val);
}
- set80211(s, IEEE80211_IOC_AMPDU_LIMIT, v, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_AMPDU_LIMIT, v, 0, NULL);
}
/* XXX 11ac density/size is different */
-static
-DECL_CMD_FUNC(set80211ampdudensity, val, d)
+static void
+set80211ampdudensity(if_ctx *ctx, const char *val, int dummy __unused)
{
int v;
@@ -1893,88 +1914,90 @@
default:
errx(-1, "invalid A-MPDU density %s", val);
}
- set80211(s, IEEE80211_IOC_AMPDU_DENSITY, v, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_AMPDU_DENSITY, v, 0, NULL);
}
static void
-set80211amsdu(const char *val, int d, int s, const struct afswtch *rafp)
+set80211amsdu(if_ctx *ctx, const char *val, int d)
{
int amsdu;
- if (get80211val(s, IEEE80211_IOC_AMSDU, &amsdu) < 0)
+ if (get80211val(ctx->io->s, IEEE80211_IOC_AMSDU, &amsdu) < 0)
err(-1, "cannot get AMSDU setting");
if (d < 0) {
d = -d;
amsdu &= ~d;
} else
amsdu |= d;
- set80211(s, IEEE80211_IOC_AMSDU, amsdu, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_AMSDU, amsdu, 0, NULL);
}
-static
-DECL_CMD_FUNC(set80211amsdulimit, val, d)
+static void
+set80211amsdulimit(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_AMSDU_LIMIT, atoi(val), 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_AMSDU_LIMIT, atoi(val), 0, NULL);
}
static void
-set80211puren(const char *val, int d, int s, const struct afswtch *rafp)
+set80211puren(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_PUREN, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_PUREN, d, 0, NULL);
}
static void
-set80211htcompat(const char *val, int d, int s, const struct afswtch *rafp)
+set80211htcompat(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_HTCOMPAT, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_HTCOMPAT, d, 0, NULL);
}
static void
-set80211htconf(const char *val, int d, int s, const struct afswtch *rafp)
+set80211htconf(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_HTCONF, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_HTCONF, d, 0, NULL);
htconf = d;
}
static void
-set80211dwds(const char *val, int d, int s, const struct afswtch *rafp)
+set80211dwds(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_DWDS, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_DWDS, d, 0, NULL);
}
static void
-set80211inact(const char *val, int d, int s, const struct afswtch *rafp)
+set80211inact(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_INACTIVITY, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_INACTIVITY, d, 0, NULL);
}
static void
-set80211tsn(const char *val, int d, int s, const struct afswtch *rafp)
+set80211tsn(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_TSN, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_TSN, d, 0, NULL);
}
static void
-set80211dotd(const char *val, int d, int s, const struct afswtch *rafp)
+set80211dotd(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_DOTD, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_DOTD, d, 0, NULL);
}
static void
-set80211smps(const char *val, int d, int s, const struct afswtch *rafp)
+set80211smps(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_SMPS, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_SMPS, d, 0, NULL);
}
static void
-set80211rifs(const char *val, int d, int s, const struct afswtch *rafp)
+set80211rifs(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_RIFS, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_RIFS, d, 0, NULL);
}
static void
-set80211vhtconf(const char *val, int d, int s, const struct afswtch *rafp)
+set80211vhtconf(if_ctx *ctx, const char *val, int d)
{
+ int s = ctx->io->s;
+
if (get80211val(s, IEEE80211_IOC_VHTCONF, &vhtconf) < 0)
errx(-1, "cannot set VHT setting");
printf("%s: vhtconf=0x%08x, d=%d\n", __func__, vhtconf, d);
@@ -1984,73 +2007,73 @@
} else
vhtconf |= d;
printf("%s: vhtconf is now 0x%08x\n", __func__, vhtconf);
- set80211(s, IEEE80211_IOC_VHTCONF, vhtconf, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_VHTCONF, vhtconf, 0, NULL);
}
-static
-DECL_CMD_FUNC(set80211tdmaslot, val, d)
+static void
+set80211tdmaslot(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_TDMA_SLOT, atoi(val), 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_TDMA_SLOT, atoi(val), 0, NULL);
}
-static
-DECL_CMD_FUNC(set80211tdmaslotcnt, val, d)
+static void
+set80211tdmaslotcnt(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_TDMA_SLOTCNT, atoi(val), 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_TDMA_SLOTCNT, atoi(val), 0, NULL);
}
-static
-DECL_CMD_FUNC(set80211tdmaslotlen, val, d)
+static void
+set80211tdmaslotlen(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_TDMA_SLOTLEN, atoi(val), 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_TDMA_SLOTLEN, atoi(val), 0, NULL);
}
-static
-DECL_CMD_FUNC(set80211tdmabintval, val, d)
+static void
+set80211tdmabintval(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_TDMA_BINTERVAL, atoi(val), 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_TDMA_BINTERVAL, atoi(val), 0, NULL);
}
-static
-DECL_CMD_FUNC(set80211meshttl, val, d)
+static void
+set80211meshttl(if_ctx *ctx, const char *val, int dummy __unused)
{
- set80211(s, IEEE80211_IOC_MESH_TTL, atoi(val), 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_MESH_TTL, atoi(val), 0, NULL);
}
-static
-DECL_CMD_FUNC(set80211meshforward, val, d)
+static void
+set80211meshforward(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_MESH_FWRD, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_MESH_FWRD, d, 0, NULL);
}
-static
-DECL_CMD_FUNC(set80211meshgate, val, d)
+static void
+set80211meshgate(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_MESH_GATE, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_MESH_GATE, d, 0, NULL);
}
-static
-DECL_CMD_FUNC(set80211meshpeering, val, d)
+static void
+set80211meshpeering(if_ctx *ctx, const char *val, int d)
{
- set80211(s, IEEE80211_IOC_MESH_AP, d, 0, NULL);
+ set80211(ctx->io->s, IEEE80211_IOC_MESH_AP, d, 0, NULL);
}
-static
-DECL_CMD_FUNC(set80211meshmetric, val, d)
+static void
+set80211meshmetric(if_ctx *ctx, const char *val, int dummy __unused)
{
char v[12];
memcpy(v, val, sizeof(v));
- set80211(s, IEEE80211_IOC_MESH_PR_METRIC, 0, 0, v);
+ set80211(ctx->io->s, IEEE80211_IOC_MESH_PR_METRIC, 0, 0, v);
}
-static
-DECL_CMD_FUNC(set80211meshpath, val, d)
+static void
+set80211meshpath(if_ctx *ctx, const char *val, int dummy __unused)
{
char v[12];
memcpy(v, val, sizeof(v));
- set80211(s, IEEE80211_IOC_MESH_PR_PATH, 0, 0, v);
+ set80211(ctx->io->s, IEEE80211_IOC_MESH_PR_PATH, 0, 0, v);
}
static int
@@ -2489,8 +2512,8 @@
regdomain.isocc[1] = cc->isoname[1];
}
-static
-DECL_CMD_FUNC(set80211regdomain, val, d)
+static void
+set80211regdomain(if_ctx *ctx, const char *val, int dummy __unused)
{
struct regdata *rdp = getregdata();
const struct regdomain *rd;
@@ -2505,7 +2528,7 @@
if (eptr == val || rd == NULL)
errx(1, "unknown regdomain %s", val);
}
- getregdomain(s);
+ getregdomain(ctx->io->s);
regdomain.regdomain = rd->sku;
if (regdomain.country == 0 && rd->cc != NULL) {
/*
@@ -2517,8 +2540,8 @@
callback_register(setregdomain_cb, &regdomain);
}
-static
-DECL_CMD_FUNC(set80211country, val, d)
+static void
+set80211country(if_ctx *ctx, const char *val, int dummy __unused)
{
struct regdata *rdp = getregdata();
const struct country *cc;
@@ -2533,7 +2556,7 @@
if (eptr == val || cc == NULL)
errx(1, "unknown ISO country code %s", val);
}
- getregdomain(s);
+ getregdomain(ctx->io->s);
regdomain.regdomain = cc->rd->sku;
regdomain.country = cc->code;
regdomain.isocc[0] = cc->isoname[0];
@@ -2542,17 +2565,17 @@
}
static void
-set80211location(const char *val, int d, int s, const struct afswtch *rafp)
+set80211location(if_ctx *ctx, const char *val, int d)
{
- getregdomain(s);
+ getregdomain(ctx->io->s);
regdomain.location = d;
callback_register(setregdomain_cb, &regdomain);
}
static void
-set80211ecm(const char *val, int d, int s, const struct afswtch *rafp)
+set80211ecm(if_ctx *ctx, const char *val, int d)
{
- getregdomain(s);
+ getregdomain(ctx->io->s);
regdomain.ecm = d;
callback_register(setregdomain_cb, &regdomain);
}
@@ -3831,11 +3854,11 @@
close(sroute);
}
-static
-DECL_CMD_FUNC(set80211scan, val, d)
+static void
+set80211scan(if_ctx *ctx, const char *val, int dummy __unused)
{
- scan_and_wait(s);
- list_scan(s);
+ scan_and_wait(ctx->io->s);
+ list_scan(ctx->io->s);
}
static enum ieee80211_opmode get80211opmode(int s);
@@ -4638,9 +4661,10 @@
}
}
-static
-DECL_CMD_FUNC(set80211list, arg, d)
+static void
+set80211list(if_ctx *ctx, const char *arg, int dummy __unused)
{
+ int s = ctx->io->s;
#define iseq(a,b) (strncasecmp(a,b,sizeof(b)-1) == 0)
LINE_INIT('\t');
@@ -4860,8 +4884,9 @@
}
static void
-ieee80211_status(int s)
+ieee80211_status(if_ctx *ctx)
{
+ int s = ctx->io->s;
static const uint8_t zerobssid[IEEE80211_ADDR_LEN];
enum ieee80211_opmode opmode = get80211opmode(s);
int i, num, wpa, wme, bgscan, bgscaninterval, val, len, wepmode;
@@ -5782,14 +5807,14 @@
strlcpy(name, orig_name, sizeof(name));
}
-static
-DECL_CMD_FUNC(set80211clone_wlandev, arg, d)
+static void
+set80211clone_wlandev(if_ctx *ctx, const char *arg, int dummy __unused)
{
strlcpy(params.icp_parent, arg, IFNAMSIZ);
}
-static
-DECL_CMD_FUNC(set80211clone_wlanbssid, arg, d)
+static void
+set80211clone_wlanbssid(if_ctx *ctx, const char *arg, int dummy __unused)
{
const struct ether_addr *ea;
@@ -5799,8 +5824,8 @@
memcpy(params.icp_bssid, ea->octet, IEEE80211_ADDR_LEN);
}
-static
-DECL_CMD_FUNC(set80211clone_wlanaddr, arg, d)
+static void
+set80211clone_wlanaddr(if_ctx *ctx, const char *arg, int dummy __unused)
{
const struct ether_addr *ea;
@@ -5811,8 +5836,8 @@
params.icp_flags |= IEEE80211_CLONE_MACADDR;
}
-static
-DECL_CMD_FUNC(set80211clone_wlanmode, arg, d)
+static void
+set80211clone_wlanmode(if_ctx *ctx, const char *arg, int dummy __unused)
{
#define iseq(a,b) (strncasecmp(a,b,sizeof(b)-1) == 0)
if (iseq(arg, "sta"))
@@ -5838,7 +5863,7 @@
}
static void
-set80211clone_beacons(const char *val, int d, int s, const struct afswtch *rafp)
+set80211clone_beacons(if_ctx *ctx, const char *val, int d)
{
/* NB: inverted sense */
if (d)
@@ -5848,7 +5873,7 @@
}
static void
-set80211clone_bssid(const char *val, int d, int s, const struct afswtch *rafp)
+set80211clone_bssid(if_ctx *ctx, const char *val, int d)
{
if (d)
params.icp_flags |= IEEE80211_CLONE_BSSID;
@@ -5857,7 +5882,7 @@
}
static void
-set80211clone_wdslegacy(const char *val, int d, int s, const struct afswtch *rafp)
+set80211clone_wdslegacy(if_ctx *ctx, const char *val, int d)
{
if (d)
params.icp_flags |= IEEE80211_CLONE_WDSLEGACY;
diff --git a/sbin/ifconfig/ifipsec.c b/sbin/ifconfig/ifipsec.c
--- a/sbin/ifconfig/ifipsec.c
+++ b/sbin/ifconfig/ifipsec.c
@@ -51,18 +51,18 @@
#include "ifconfig.h"
static void
-ipsec_status(int s)
+ipsec_status(if_ctx *ctx)
{
uint32_t reqid;
ifr.ifr_data = (caddr_t)&reqid;
- if (ioctl(s, IPSECGREQID, &ifr) == -1)
+ if (ioctl_ctx(ctx, IPSECGREQID, &ifr) == -1)
return;
printf("\treqid: %u\n", reqid);
}
-static
-DECL_CMD_FUNC(setreqid, val, arg)
+static void
+setreqid(if_ctx *ctx, const char *val, int dummy __unused)
{
char *ep;
uint32_t v;
@@ -74,7 +74,7 @@
}
strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
ifr.ifr_data = (char *)&v;
- if (ioctl(s, IPSECSREQID, &ifr) == -1) {
+ if (ioctl_ctx(ctx, IPSECSREQID, &ifr) == -1) {
warn("ioctl(IPSECSREQID)");
return;
}
diff --git a/sbin/ifconfig/iflagg.c b/sbin/ifconfig/iflagg.c
--- a/sbin/ifconfig/iflagg.c
+++ b/sbin/ifconfig/iflagg.c
@@ -39,7 +39,7 @@
static char lacpbuf[120]; /* LACP peer '[(a,a,a),(p,p,p)]' */
static void
-setlaggport(const char *val, int d, int s, const struct afswtch *afp)
+setlaggport(if_ctx *ctx, const char *val, int dummy __unused)
{
struct lagg_reqport rp;
@@ -53,7 +53,7 @@
*
* Don't error at all if the port is already in the lagg.
*/
- if (ioctl(s, SIOCSLAGGPORT, &rp) && errno != EEXIST) {
+ if (ioctl_ctx(ctx, SIOCSLAGGPORT, &rp) && errno != EEXIST) {
warnx("%s %s: SIOCSLAGGPORT: %s",
name, val, strerror(errno));
exit_code = 1;
@@ -61,7 +61,7 @@
}
static void
-unsetlaggport(const char *val, int d, int s, const struct afswtch *afp)
+unsetlaggport(if_ctx *ctx, const char *val, int dummy __unused)
{
struct lagg_reqport rp;
@@ -69,12 +69,12 @@
strlcpy(rp.rp_ifname, name, sizeof(rp.rp_ifname));
strlcpy(rp.rp_portname, val, sizeof(rp.rp_portname));
- if (ioctl(s, SIOCSLAGGDELPORT, &rp))
+ if (ioctl_ctx(ctx, SIOCSLAGGDELPORT, &rp))
err(1, "SIOCSLAGGDELPORT");
}
static void
-setlaggproto(const char *val, int d, int s, const struct afswtch *afp)
+setlaggproto(if_ctx *ctx, const char *val, int dummy __unused)
{
struct lagg_protos lpr[] = LAGG_PROTOS;
struct lagg_reqall ra;
@@ -92,12 +92,12 @@
errx(1, "Invalid aggregation protocol: %s", val);
strlcpy(ra.ra_ifname, name, sizeof(ra.ra_ifname));
- if (ioctl(s, SIOCSLAGG, &ra) != 0)
+ if (ioctl_ctx(ctx, SIOCSLAGG, &ra) != 0)
err(1, "SIOCSLAGG");
}
static void
-setlaggflowidshift(const char *val, int d, int s, const struct afswtch *afp)
+setlaggflowidshift(if_ctx *ctx, const char *val, int dummy __unused)
{
struct lagg_reqopts ro;
@@ -108,12 +108,12 @@
if (ro.ro_flowid_shift & ~LAGG_OPT_FLOWIDSHIFT_MASK)
errx(1, "Invalid flowid_shift option: %s", val);
- if (ioctl(s, SIOCSLAGGOPTS, &ro) != 0)
+ if (ioctl_ctx(ctx, SIOCSLAGGOPTS, &ro) != 0)
err(1, "SIOCSLAGGOPTS");
}
static void
-setlaggrr_limit(const char *val, int d, int s, const struct afswtch *afp)
+setlaggrr_limit(if_ctx *ctx, const char *val, int dummy __unused)
{
struct lagg_reqopts ro;
@@ -124,12 +124,12 @@
if (ro.ro_bkt == 0)
errx(1, "Invalid round-robin stride: %s", val);
- if (ioctl(s, SIOCSLAGGOPTS, &ro) != 0)
+ if (ioctl_ctx(ctx, SIOCSLAGGOPTS, &ro) != 0)
err(1, "SIOCSLAGGOPTS");
}
static void
-setlaggsetopt(const char *val, int d, int s, const struct afswtch *afp)
+setlaggsetopt(if_ctx *ctx, const char *val __unused, int d)
{
struct lagg_reqopts ro;
@@ -154,12 +154,12 @@
}
strlcpy(ro.ro_ifname, name, sizeof(ro.ro_ifname));
- if (ioctl(s, SIOCSLAGGOPTS, &ro) != 0)
+ if (ioctl_ctx(ctx, SIOCSLAGGOPTS, &ro) != 0)
err(1, "SIOCSLAGGOPTS");
}
static void
-setlagghash(const char *val, int d, int s, const struct afswtch *afp)
+setlagghash(if_ctx *ctx, const char *val, int dummy __unused)
{
struct lagg_reqflags rf;
char *str, *tmp, *tok;
@@ -182,7 +182,7 @@
errx(1, "No lagghash options supplied");
strlcpy(rf.rf_ifname, name, sizeof(rf.rf_ifname));
- if (ioctl(s, SIOCSLAGGHASH, &rf))
+ if (ioctl_ctx(ctx, SIOCSLAGGHASH, &rf))
err(1, "SIOCSLAGGHASH");
}
@@ -215,7 +215,7 @@
}
static void
-lagg_status(int s)
+lagg_status(if_ctx *ctx __unused)
{
struct lagg_protos protos[] = LAGG_PROTOS;
struct ifconfig_lagg_status *lagg;
diff --git a/sbin/ifconfig/ifmac.c b/sbin/ifconfig/ifmac.c
--- a/sbin/ifconfig/ifmac.c
+++ b/sbin/ifconfig/ifmac.c
@@ -52,7 +52,7 @@
#include "ifconfig.h"
static void
-maclabel_status(int s)
+maclabel_status(if_ctx *ctx)
{
struct ifreq ifr;
mac_t label;
@@ -64,7 +64,7 @@
if (mac_prepare_ifnet_label(&label) == -1)
return;
ifr.ifr_ifru.ifru_data = (void *)label;
- if (ioctl(s, SIOCGIFMAC, &ifr) == -1)
+ if (ioctl_ctx(ctx, SIOCGIFMAC, &ifr) == -1)
goto mac_free;
@@ -80,7 +80,7 @@
}
static void
-setifmaclabel(const char *val, int d, int s, const struct afswtch *rafp)
+setifmaclabel(if_ctx *ctx, const char *val, int d __unused)
{
struct ifreq ifr;
mac_t label;
@@ -95,7 +95,7 @@
strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
ifr.ifr_ifru.ifru_data = (void *)label;
- error = ioctl(s, SIOCSIFMAC, &ifr);
+ error = ioctl(ctx->io->s, SIOCSIFMAC, &ifr);
mac_free(label);
if (error == -1)
perror("setifmac");
diff --git a/sbin/ifconfig/ifmedia.c b/sbin/ifconfig/ifmedia.c
--- a/sbin/ifconfig/ifmedia.c
+++ b/sbin/ifconfig/ifmedia.c
@@ -98,7 +98,7 @@
static void print_media_ifconfig(ifmedia_t);
static void
-media_status(int s)
+media_status(if_ctx *ctx __unused)
{
struct ifmediareq *ifmr;
@@ -144,7 +144,7 @@
putchar('\n');
}
- if (args.supmedia) {
+ if (global_args.supmedia) {
printf("\tsupported media:\n");
for (int i = 0; i < ifmr->ifm_count; ++i) {
printf("\t\t");
@@ -190,7 +190,7 @@
}
static void
-setmedia(const char *val, int d, int s, const struct afswtch *afp)
+setmedia(if_ctx *ctx __unused, const char *val, int d __unused)
{
struct ifmediareq *ifmr;
int subtype;
@@ -217,17 +217,17 @@
}
static void
-setmediaopt(const char *val, int d, int s, const struct afswtch *afp)
+setmediaopt(if_ctx *ctx, const char *val, int d __unused)
{
- domediaopt(val, false, s);
+ domediaopt(val, false, ctx->io->s);
}
static void
-unsetmediaopt(const char *val, int d, int s, const struct afswtch *afp)
+unsetmediaopt(if_ctx *ctx, const char *val, int d __unused)
{
- domediaopt(val, true, s);
+ domediaopt(val, true, ctx->io->s);
}
static void
@@ -256,7 +256,7 @@
}
static void
-setmediainst(const char *val, int d, int s, const struct afswtch *afp)
+setmediainst(if_ctx *ctx __unused, const char *val, int d __unused)
{
struct ifmediareq *ifmr;
int inst;
@@ -275,7 +275,7 @@
}
static void
-setmediamode(const char *val, int d, int s, const struct afswtch *afp)
+setmediamode(if_ctx *ctx __unused, const char *val, int d __unused)
{
struct ifmediareq *ifmr;
int mode;
diff --git a/sbin/ifconfig/ifpfsync.c b/sbin/ifconfig/ifpfsync.c
--- a/sbin/ifconfig/ifpfsync.c
+++ b/sbin/ifconfig/ifpfsync.c
@@ -50,15 +50,6 @@
#include "ifconfig.h"
-void setpfsync_syncdev(const char *, int, int, const struct afswtch *);
-void unsetpfsync_syncdev(const char *, int, int, const struct afswtch *);
-void setpfsync_syncpeer(const char *, int, int, const struct afswtch *);
-void unsetpfsync_syncpeer(const char *, int, int, const struct afswtch *);
-void setpfsync_syncpeer(const char *, int, int, const struct afswtch *);
-void setpfsync_maxupd(const char *, int, int, const struct afswtch *);
-void setpfsync_defer(const char *, int, int, const struct afswtch *);
-void pfsync_status(int);
-
static int
pfsync_do_ioctl(int s, uint cmd, nvlist_t **nvl)
{
@@ -173,15 +164,15 @@
return (0);
}
-void
-setpfsync_syncdev(const char *val, int d, int s, const struct afswtch *rafp)
+static void
+setpfsync_syncdev(if_ctx *ctx, const char *val, int dummy __unused)
{
nvlist_t *nvl = nvlist_create(0);
if (strlen(val) > IFNAMSIZ)
errx(1, "interface name %s is too long", val);
- if (pfsync_do_ioctl(s, SIOCGETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx->io->s, SIOCGETPFSYNCNV, &nvl) == -1)
err(1, "SIOCGETPFSYNCNV");
if (nvlist_exists_string(nvl, "syncdev"))
@@ -189,17 +180,16 @@
nvlist_add_string(nvl, "syncdev", val);
- if (pfsync_do_ioctl(s, SIOCSETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx->io->s, SIOCSETPFSYNCNV, &nvl) == -1)
err(1, "SIOCSETPFSYNCNV");
}
-/* ARGSUSED */
-void
-unsetpfsync_syncdev(const char *val, int d, int s, const struct afswtch *rafp)
+static void
+unsetpfsync_syncdev(if_ctx *ctx, const char *val, int dummy __unused)
{
nvlist_t *nvl = nvlist_create(0);
- if (pfsync_do_ioctl(s, SIOCGETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx->io->s, SIOCGETPFSYNCNV, &nvl) == -1)
err(1, "SIOCGETPFSYNCNV");
if (nvlist_exists_string(nvl, "syncdev"))
@@ -207,13 +197,12 @@
nvlist_add_string(nvl, "syncdev", "");
- if (pfsync_do_ioctl(s, SIOCSETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx->io->s, SIOCSETPFSYNCNV, &nvl) == -1)
err(1, "SIOCSETPFSYNCNV");
}
-/* ARGSUSED */
-void
-setpfsync_syncpeer(const char *val, int d, int s, const struct afswtch *rafp)
+static void
+setpfsync_syncpeer(if_ctx *ctx, const char *val, int dummy __unused)
{
struct addrinfo *peerres;
struct sockaddr_storage addr;
@@ -221,7 +210,7 @@
nvlist_t *nvl = nvlist_create(0);
- if (pfsync_do_ioctl(s, SIOCGETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx->io->s, SIOCGETPFSYNCNV, &nvl) == -1)
err(1, "SIOCGETPFSYNCNV");
if ((ecode = getaddrinfo(val, NULL, NULL, &peerres)) != 0)
@@ -251,23 +240,22 @@
nvlist_add_nvlist(nvl, "syncpeer",
pfsync_sockaddr_to_syncpeer_nvlist(&addr));
- if (pfsync_do_ioctl(s, SIOCSETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx->io->s, SIOCSETPFSYNCNV, &nvl) == -1)
err(1, "SIOCSETPFSYNCNV");
nvlist_destroy(nvl);
freeaddrinfo(peerres);
}
-/* ARGSUSED */
-void
-unsetpfsync_syncpeer(const char *val, int d, int s, const struct afswtch *rafp)
+static void
+unsetpfsync_syncpeer(if_ctx *ctx, const char *val, int dummy __unused)
{
struct sockaddr_storage addr;
memset(&addr, 0, sizeof(addr));
nvlist_t *nvl = nvlist_create(0);
- if (pfsync_do_ioctl(s, SIOCGETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx->io->s, SIOCGETPFSYNCNV, &nvl) == -1)
err(1, "SIOCGETPFSYNCNV");
if (nvlist_exists_nvlist(nvl, "syncpeer"))
@@ -276,15 +264,14 @@
nvlist_add_nvlist(nvl, "syncpeer",
pfsync_sockaddr_to_syncpeer_nvlist(&addr));
- if (pfsync_do_ioctl(s, SIOCSETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx->io->s, SIOCSETPFSYNCNV, &nvl) == -1)
err(1, "SIOCSETPFSYNCNV");
nvlist_destroy(nvl);
}
-/* ARGSUSED */
-void
-setpfsync_maxupd(const char *val, int d, int s, const struct afswtch *rafp)
+static void
+setpfsync_maxupd(if_ctx *ctx, const char *val, int dummy __unused)
{
int maxupdates;
nvlist_t *nvl = nvlist_create(0);
@@ -293,38 +280,37 @@
if ((maxupdates < 0) || (maxupdates > 255))
errx(1, "maxupd %s: out of range", val);
- if (pfsync_do_ioctl(s, SIOCGETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx->io->s, SIOCGETPFSYNCNV, &nvl) == -1)
err(1, "SIOCGETPFSYNCNV");
nvlist_free_number(nvl, "maxupdates");
nvlist_add_number(nvl, "maxupdates", maxupdates);
- if (pfsync_do_ioctl(s, SIOCSETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx->io->s, SIOCSETPFSYNCNV, &nvl) == -1)
err(1, "SIOCSETPFSYNCNV");
nvlist_destroy(nvl);
}
-/* ARGSUSED */
-void
-setpfsync_defer(const char *val, int d, int s, const struct afswtch *rafp)
+static void
+setpfsync_defer(if_ctx *ctx, const char *val, int d)
{
nvlist_t *nvl = nvlist_create(0);
- if (pfsync_do_ioctl(s, SIOCGETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx->io->s, SIOCGETPFSYNCNV, &nvl) == -1)
err(1, "SIOCGETPFSYNCNV");
nvlist_free_number(nvl, "flags");
nvlist_add_number(nvl, "flags", d ? PFSYNCF_DEFER : 0);
- if (pfsync_do_ioctl(s, SIOCSETPFSYNCNV, &nvl) == -1)
+ if (pfsync_do_ioctl(ctx->io->s, SIOCSETPFSYNCNV, &nvl) == -1)
err(1, "SIOCSETPFSYNCNV");
nvlist_destroy(nvl);
}
-void
-pfsync_status(int s)
+static void
+pfsync_status(if_ctx *ctx)
{
nvlist_t *nvl;
char syncdev[IFNAMSIZ];
@@ -336,7 +322,7 @@
nvl = nvlist_create(0);
- if (pfsync_do_ioctl(s, SIOCGETPFSYNCNV, &nvl) == -1) {
+ if (pfsync_do_ioctl(ctx->io->s, SIOCGETPFSYNCNV, &nvl) == -1) {
nvlist_destroy(nvl);
return;
}
diff --git a/sbin/ifconfig/ifstf.c b/sbin/ifconfig/ifstf.c
--- a/sbin/ifconfig/ifstf.c
+++ b/sbin/ifconfig/ifstf.c
@@ -67,11 +67,11 @@
}
static void
-stf_status(int s)
+stf_status(if_ctx *ctx)
{
struct stfv4args param;
- if (do_cmd(s, STF6RD_GV4NET, &param, sizeof(param), 0) < 0)
+ if (do_cmd(ctx->io->s, STF6RD_GV4NET, &param, sizeof(param), 0) < 0)
return;
printf("\tv4net %s/%d -> ", inet_ntoa(param.srcv4_addr),
@@ -80,7 +80,7 @@
}
static void
-setstf_br(const char *val, int d, int s, const struct afswtch *afp)
+setstf_br(if_ctx *ctx, const char *val, int d __unused)
{
struct stfv4args req;
struct sockaddr_in sin;
@@ -94,12 +94,12 @@
errx(1, "%s: bad value", val);
req.braddr = sin.sin_addr;
- if (do_cmd(s, STF6RD_SBR, &req, sizeof(req), 1) < 0)
+ if (do_cmd(ctx->io->s, STF6RD_SBR, &req, sizeof(req), 1) < 0)
err(1, "STF6RD_SBR%s", val);
}
static void
-setstf_set(const char *val, int d, int s, const struct afswtch *afp)
+setstf_set(if_ctx *ctx, const char *val, int d __unused)
{
struct stfv4args req;
struct sockaddr_in sin;
@@ -126,7 +126,7 @@
errx(1, "%s: bad value", val);
memcpy(&req.srcv4_addr, &sin.sin_addr, sizeof(req.srcv4_addr));
- if (do_cmd(s, STF6RD_SV4NET, &req, sizeof(req), 1) < 0)
+ if (do_cmd(ctx->io->s, STF6RD_SV4NET, &req, sizeof(req), 1) < 0)
err(1, "STF6RD_SV4NET %s", val);
}
diff --git a/sbin/ifconfig/ifvlan.c b/sbin/ifconfig/ifvlan.c
--- a/sbin/ifconfig/ifvlan.c
+++ b/sbin/ifconfig/ifvlan.c
@@ -85,11 +85,11 @@
}
static void
-vlan_status(int s)
+vlan_status(if_ctx *ctx)
{
struct vlanreq vreq;
- if (getvlan(s, &ifr, &vreq) == -1)
+ if (getvlan(ctx->io->s, &ifr, &vreq) == -1)
return;
printf("\tvlan: %d", vreq.vlr_tag);
printf(" vlanproto: ");
@@ -103,7 +103,7 @@
default:
printf("0x%04x", vreq.vlr_proto);
}
- if (ioctl(s, SIOCGVLANPCP, (caddr_t)&ifr) != -1)
+ if (ioctl_ctx(ctx, SIOCGVLANPCP, (caddr_t)&ifr) != -1)
printf(" vlanpcp: %u", ifr.ifr_vlan_pcp);
printf(" parent interface: %s", vreq.vlr_parent[0] == '\0' ?
"<none>" : vreq.vlr_parent);
@@ -192,8 +192,8 @@
}
}
-static
-DECL_CMD_FUNC(setvlantag, val, d)
+static void
+setvlantag(if_ctx *ctx, const char *val, int dummy __unused)
{
struct vlanreq vreq;
u_long ul;
@@ -207,26 +207,26 @@
if (params.vlr_tag != ul)
errx(1, "value for vlan out of range");
- if (getvlan(s, &ifr, &vreq) != -1) {
+ if (getvlan(ctx->io->s, &ifr, &vreq) != -1) {
vreq.vlr_tag = params.vlr_tag;
memcpy(&params, &vreq, sizeof(params));
- vlan_set(s, &ifr);
+ vlan_set(ctx->io->s, &ifr);
}
}
-static
-DECL_CMD_FUNC(setvlandev, val, d)
+static void
+setvlandev(if_ctx *ctx, const char *val, int dummy __unused)
{
struct vlanreq vreq;
strlcpy(params.vlr_parent, val, sizeof(params.vlr_parent));
- if (getvlan(s, &ifr, &vreq) != -1)
- vlan_set(s, &ifr);
+ if (getvlan(ctx->io->s, &ifr, &vreq) != -1)
+ vlan_set(ctx->io->s, &ifr);
}
-static
-DECL_CMD_FUNC(setvlanproto, val, d)
+static void
+setvlanproto(if_ctx *ctx, const char *val, int dummy __unused)
{
struct vlanreq vreq;
@@ -239,15 +239,15 @@
} else
errx(1, "invalid value for vlanproto");
- if (getvlan(s, &ifr, &vreq) != -1) {
+ if (getvlan(ctx->io->s, &ifr, &vreq) != -1) {
vreq.vlr_proto = params.vlr_proto;
memcpy(&params, &vreq, sizeof(params));
- vlan_set(s, &ifr);
+ vlan_set(ctx->io->s, &ifr);
}
}
-static
-DECL_CMD_FUNC(setvlanpcp, val, d)
+static void
+setvlanpcp(if_ctx *ctx, const char *val, int dummy __unused)
{
u_long ul;
char *endp;
@@ -258,25 +258,25 @@
if (ul > 7)
errx(1, "value for vlanpcp out of range");
ifr.ifr_vlan_pcp = ul;
- if (ioctl(s, SIOCSVLANPCP, (caddr_t)&ifr) == -1)
+ if (ioctl(ctx->io->s, SIOCSVLANPCP, (caddr_t)&ifr) == -1)
err(1, "SIOCSVLANPCP");
}
-static
-DECL_CMD_FUNC(unsetvlandev, val, d)
+static void
+unsetvlandev(if_ctx *ctx, const char *val, int dummy __unused)
{
struct vlanreq vreq;
bzero((char *)&vreq, sizeof(struct vlanreq));
ifr.ifr_data = (caddr_t)&vreq;
- if (ioctl(s, SIOCGETVLAN, (caddr_t)&ifr) == -1)
+ if (ioctl(ctx->io->s, SIOCGETVLAN, (caddr_t)&ifr) == -1)
err(1, "SIOCGETVLAN");
bzero((char *)&vreq.vlr_parent, sizeof(vreq.vlr_parent));
vreq.vlr_tag = 0;
- if (ioctl(s, SIOCSETVLAN, (caddr_t)&ifr) == -1)
+ if (ioctl(ctx->io->s, SIOCSETVLAN, (caddr_t)&ifr) == -1)
err(1, "SIOCSETVLAN");
}
diff --git a/sbin/ifconfig/ifvxlan.c b/sbin/ifconfig/ifvxlan.c
--- a/sbin/ifconfig/ifvxlan.c
+++ b/sbin/ifconfig/ifvxlan.c
@@ -73,7 +73,7 @@
}
static int
-do_cmd(int sock, u_long op, void *arg, size_t argsize, int set)
+do_cmd(if_ctx *ctx, u_long op, void *arg, size_t argsize, int set)
{
struct ifdrv ifd;
@@ -84,21 +84,21 @@
ifd.ifd_len = argsize;
ifd.ifd_data = arg;
- return (ioctl(sock, set ? SIOCSDRVSPEC : SIOCGDRVSPEC, &ifd));
+ return (ioctl(ctx->io->s, set ? SIOCSDRVSPEC : SIOCGDRVSPEC, &ifd));
}
static int
-vxlan_exists(int sock)
+vxlan_exists(if_ctx *ctx)
{
struct ifvxlancfg cfg;
bzero(&cfg, sizeof(cfg));
- return (do_cmd(sock, VXLAN_CMD_GET_CONFIG, &cfg, sizeof(cfg), 0) != -1);
+ return (do_cmd(ctx, VXLAN_CMD_GET_CONFIG, &cfg, sizeof(cfg), 0) != -1);
}
static void
-vxlan_status(int s)
+vxlan_status(if_ctx *ctx)
{
struct ifvxlancfg cfg;
char src[NI_MAXHOST], dst[NI_MAXHOST];
@@ -108,7 +108,7 @@
bzero(&cfg, sizeof(cfg));
- if (do_cmd(s, VXLAN_CMD_GET_CONFIG, &cfg, sizeof(cfg), 0) < 0)
+ if (do_cmd(ctx, VXLAN_CMD_GET_CONFIG, &cfg, sizeof(cfg), 0) < 0)
return;
vni = cfg.vxlc_vni;
@@ -194,8 +194,8 @@
ioctl_ifcreate(s, ifr);
}
-static
-DECL_CMD_FUNC(setvxlan_vni, arg, d)
+static void
+setvxlan_vni(if_ctx *ctx, const char *arg, int dummy __unused)
{
struct ifvxlancmd cmd;
u_long val;
@@ -203,7 +203,7 @@
if (get_val(arg, &val) < 0 || val >= VXLAN_VNI_MAX)
errx(1, "invalid network identifier: %s", arg);
- if (!vxlan_exists(s)) {
+ if (!vxlan_exists(ctx)) {
params.vxlp_with |= VXLAN_PARAM_WITH_VNI;
params.vxlp_vni = val;
return;
@@ -212,12 +212,12 @@
bzero(&cmd, sizeof(cmd));
cmd.vxlcmd_vni = val;
- if (do_cmd(s, VXLAN_CMD_SET_VNI, &cmd, sizeof(cmd), 1) < 0)
+ if (do_cmd(ctx, VXLAN_CMD_SET_VNI, &cmd, sizeof(cmd), 1) < 0)
err(1, "VXLAN_CMD_SET_VNI");
}
-static
-DECL_CMD_FUNC(setvxlan_local, addr, d)
+static void
+setvxlan_local(if_ctx *ctx, const char *addr, int dummy __unused)
{
struct ifvxlancmd cmd;
struct addrinfo *ai;
@@ -261,7 +261,7 @@
freeaddrinfo(ai);
- if (!vxlan_exists(s)) {
+ if (!vxlan_exists(ctx)) {
if (cmd.vxlcmd_sa.sa.sa_family == AF_INET) {
params.vxlp_with |= VXLAN_PARAM_WITH_LOCAL_ADDR4;
params.vxlp_local_sa.in4 = cmd.vxlcmd_sa.in4;
@@ -272,12 +272,12 @@
return;
}
- if (do_cmd(s, VXLAN_CMD_SET_LOCAL_ADDR, &cmd, sizeof(cmd), 1) < 0)
+ if (do_cmd(ctx, VXLAN_CMD_SET_LOCAL_ADDR, &cmd, sizeof(cmd), 1) < 0)
err(1, "VXLAN_CMD_SET_LOCAL_ADDR");
}
-static
-DECL_CMD_FUNC(setvxlan_remote, addr, d)
+static void
+setvxlan_remote(if_ctx *ctx, const char *addr, int dummy __unused)
{
struct ifvxlancmd cmd;
struct addrinfo *ai;
@@ -321,7 +321,7 @@
freeaddrinfo(ai);
- if (!vxlan_exists(s)) {
+ if (!vxlan_exists(ctx)) {
if (cmd.vxlcmd_sa.sa.sa_family == AF_INET) {
params.vxlp_with |= VXLAN_PARAM_WITH_REMOTE_ADDR4;
params.vxlp_remote_sa.in4 = cmd.vxlcmd_sa.in4;
@@ -332,12 +332,12 @@
return;
}
- if (do_cmd(s, VXLAN_CMD_SET_REMOTE_ADDR, &cmd, sizeof(cmd), 1) < 0)
+ if (do_cmd(ctx, VXLAN_CMD_SET_REMOTE_ADDR, &cmd, sizeof(cmd), 1) < 0)
err(1, "VXLAN_CMD_SET_REMOTE_ADDR");
}
-static
-DECL_CMD_FUNC(setvxlan_group, addr, d)
+static void
+setvxlan_group(if_ctx *ctx, const char *addr, int dummy __unused)
{
struct ifvxlancmd cmd;
struct addrinfo *ai;
@@ -381,7 +381,7 @@
freeaddrinfo(ai);
- if (!vxlan_exists(s)) {
+ if (!vxlan_exists(ctx)) {
if (cmd.vxlcmd_sa.sa.sa_family == AF_INET) {
params.vxlp_with |= VXLAN_PARAM_WITH_REMOTE_ADDR4;
params.vxlp_remote_sa.in4 = cmd.vxlcmd_sa.in4;
@@ -392,12 +392,12 @@
return;
}
- if (do_cmd(s, VXLAN_CMD_SET_REMOTE_ADDR, &cmd, sizeof(cmd), 1) < 0)
+ if (do_cmd(ctx, VXLAN_CMD_SET_REMOTE_ADDR, &cmd, sizeof(cmd), 1) < 0)
err(1, "VXLAN_CMD_SET_REMOTE_ADDR");
}
-static
-DECL_CMD_FUNC(setvxlan_local_port, arg, d)
+static void
+setvxlan_local_port(if_ctx *ctx, const char *arg, int dummy __unused)
{
struct ifvxlancmd cmd;
u_long val;
@@ -405,7 +405,7 @@
if (get_val(arg, &val) < 0 || val >= UINT16_MAX)
errx(1, "invalid local port: %s", arg);
- if (!vxlan_exists(s)) {
+ if (!vxlan_exists(ctx)) {
params.vxlp_with |= VXLAN_PARAM_WITH_LOCAL_PORT;
params.vxlp_local_port = val;
return;
@@ -414,12 +414,12 @@
bzero(&cmd, sizeof(cmd));
cmd.vxlcmd_port = val;
- if (do_cmd(s, VXLAN_CMD_SET_LOCAL_PORT, &cmd, sizeof(cmd), 1) < 0)
+ if (do_cmd(ctx, VXLAN_CMD_SET_LOCAL_PORT, &cmd, sizeof(cmd), 1) < 0)
err(1, "VXLAN_CMD_SET_LOCAL_PORT");
}
-static
-DECL_CMD_FUNC(setvxlan_remote_port, arg, d)
+static void
+setvxlan_remote_port(if_ctx *ctx, const char *arg, int dummy __unused)
{
struct ifvxlancmd cmd;
u_long val;
@@ -427,7 +427,7 @@
if (get_val(arg, &val) < 0 || val >= UINT16_MAX)
errx(1, "invalid remote port: %s", arg);
- if (!vxlan_exists(s)) {
+ if (!vxlan_exists(ctx)) {
params.vxlp_with |= VXLAN_PARAM_WITH_REMOTE_PORT;
params.vxlp_remote_port = val;
return;
@@ -436,12 +436,12 @@
bzero(&cmd, sizeof(cmd));
cmd.vxlcmd_port = val;
- if (do_cmd(s, VXLAN_CMD_SET_REMOTE_PORT, &cmd, sizeof(cmd), 1) < 0)
+ if (do_cmd(ctx, VXLAN_CMD_SET_REMOTE_PORT, &cmd, sizeof(cmd), 1) < 0)
err(1, "VXLAN_CMD_SET_REMOTE_PORT");
}
-static
-DECL_CMD_FUNC2(setvxlan_port_range, arg1, arg2)
+static void
+setvxlan_port_range(if_ctx *ctx, const char *arg1, const char *arg2)
{
struct ifvxlancmd cmd;
u_long min, max;
@@ -453,7 +453,7 @@
if (max < min)
errx(1, "invalid port range");
- if (!vxlan_exists(s)) {
+ if (!vxlan_exists(ctx)) {
params.vxlp_with |= VXLAN_PARAM_WITH_PORT_RANGE;
params.vxlp_min_port = min;
params.vxlp_max_port = max;
@@ -464,12 +464,12 @@
cmd.vxlcmd_port_min = min;
cmd.vxlcmd_port_max = max;
- if (do_cmd(s, VXLAN_CMD_SET_PORT_RANGE, &cmd, sizeof(cmd), 1) < 0)
+ if (do_cmd(ctx, VXLAN_CMD_SET_PORT_RANGE, &cmd, sizeof(cmd), 1) < 0)
err(1, "VXLAN_CMD_SET_PORT_RANGE");
}
-static
-DECL_CMD_FUNC(setvxlan_timeout, arg, d)
+static void
+setvxlan_timeout(if_ctx *ctx, const char *arg, int dummy __unused)
{
struct ifvxlancmd cmd;
u_long val;
@@ -477,7 +477,7 @@
if (get_val(arg, &val) < 0 || (val & ~0xFFFFFFFF) != 0)
errx(1, "invalid timeout value: %s", arg);
- if (!vxlan_exists(s)) {
+ if (!vxlan_exists(ctx)) {
params.vxlp_with |= VXLAN_PARAM_WITH_FTABLE_TIMEOUT;
params.vxlp_ftable_timeout = val & 0xFFFFFFFF;
return;
@@ -486,12 +486,12 @@
bzero(&cmd, sizeof(cmd));
cmd.vxlcmd_ftable_timeout = val & 0xFFFFFFFF;
- if (do_cmd(s, VXLAN_CMD_SET_FTABLE_TIMEOUT, &cmd, sizeof(cmd), 1) < 0)
+ if (do_cmd(ctx, VXLAN_CMD_SET_FTABLE_TIMEOUT, &cmd, sizeof(cmd), 1) < 0)
err(1, "VXLAN_CMD_SET_FTABLE_TIMEOUT");
}
-static
-DECL_CMD_FUNC(setvxlan_maxaddr, arg, d)
+static void
+setvxlan_maxaddr(if_ctx *ctx, const char *arg, int dummy __unused)
{
struct ifvxlancmd cmd;
u_long val;
@@ -499,7 +499,7 @@
if (get_val(arg, &val) < 0 || (val & ~0xFFFFFFFF) != 0)
errx(1, "invalid maxaddr value: %s", arg);
- if (!vxlan_exists(s)) {
+ if (!vxlan_exists(ctx)) {
params.vxlp_with |= VXLAN_PARAM_WITH_FTABLE_MAX;
params.vxlp_ftable_max = val & 0xFFFFFFFF;
return;
@@ -508,16 +508,16 @@
bzero(&cmd, sizeof(cmd));
cmd.vxlcmd_ftable_max = val & 0xFFFFFFFF;
- if (do_cmd(s, VXLAN_CMD_SET_FTABLE_MAX, &cmd, sizeof(cmd), 1) < 0)
+ if (do_cmd(ctx, VXLAN_CMD_SET_FTABLE_MAX, &cmd, sizeof(cmd), 1) < 0)
err(1, "VXLAN_CMD_SET_FTABLE_MAX");
}
-static
-DECL_CMD_FUNC(setvxlan_dev, arg, d)
+static void
+setvxlan_dev(if_ctx *ctx, const char *arg, int dummy __unused)
{
struct ifvxlancmd cmd;
- if (!vxlan_exists(s)) {
+ if (!vxlan_exists(ctx)) {
params.vxlp_with |= VXLAN_PARAM_WITH_MULTICAST_IF;
strlcpy(params.vxlp_mc_ifname, arg,
sizeof(params.vxlp_mc_ifname));
@@ -527,12 +527,12 @@
bzero(&cmd, sizeof(cmd));
strlcpy(cmd.vxlcmd_ifname, arg, sizeof(cmd.vxlcmd_ifname));
- if (do_cmd(s, VXLAN_CMD_SET_MULTICAST_IF, &cmd, sizeof(cmd), 1) < 0)
+ if (do_cmd(ctx, VXLAN_CMD_SET_MULTICAST_IF, &cmd, sizeof(cmd), 1) < 0)
err(1, "VXLAN_CMD_SET_MULTICAST_IF");
}
-static
-DECL_CMD_FUNC(setvxlan_ttl, arg, d)
+static void
+setvxlan_ttl(if_ctx *ctx, const char *arg, int dummy __unused)
{
struct ifvxlancmd cmd;
u_long val;
@@ -540,7 +540,7 @@
if (get_val(arg, &val) < 0 || val > 256)
errx(1, "invalid TTL value: %s", arg);
- if (!vxlan_exists(s)) {
+ if (!vxlan_exists(ctx)) {
params.vxlp_with |= VXLAN_PARAM_WITH_TTL;
params.vxlp_ttl = val;
return;
@@ -549,16 +549,16 @@
bzero(&cmd, sizeof(cmd));
cmd.vxlcmd_ttl = val;
- if (do_cmd(s, VXLAN_CMD_SET_TTL, &cmd, sizeof(cmd), 1) < 0)
+ if (do_cmd(ctx, VXLAN_CMD_SET_TTL, &cmd, sizeof(cmd), 1) < 0)
err(1, "VXLAN_CMD_SET_TTL");
}
-static
-DECL_CMD_FUNC(setvxlan_learn, arg, d)
+static void
+setvxlan_learn(if_ctx *ctx, const char *arg, int d)
{
struct ifvxlancmd cmd;
- if (!vxlan_exists(s)) {
+ if (!vxlan_exists(ctx)) {
params.vxlp_with |= VXLAN_PARAM_WITH_LEARN;
params.vxlp_learn = d;
return;
@@ -568,12 +568,12 @@
if (d != 0)
cmd.vxlcmd_flags |= VXLAN_CMD_FLAG_LEARN;
- if (do_cmd(s, VXLAN_CMD_SET_LEARN, &cmd, sizeof(cmd), 1) < 0)
+ if (do_cmd(ctx, VXLAN_CMD_SET_LEARN, &cmd, sizeof(cmd), 1) < 0)
err(1, "VXLAN_CMD_SET_LEARN");
}
static void
-setvxlan_flush(const char *val, int d, int s, const struct afswtch *afp)
+setvxlan_flush(if_ctx *ctx, const char *val __unused, int d)
{
struct ifvxlancmd cmd;
@@ -581,7 +581,7 @@
if (d != 0)
cmd.vxlcmd_flags |= VXLAN_CMD_FLAG_FLUSH_ALL;
- if (do_cmd(s, VXLAN_CMD_FLUSH, &cmd, sizeof(cmd), 1) < 0)
+ if (do_cmd(ctx, VXLAN_CMD_FLUSH, &cmd, sizeof(cmd), 1) < 0)
err(1, "VXLAN_CMD_FLUSH");
}

File Metadata

Mime Type
text/plain
Expires
Thu, Apr 2, 12:40 PM (13 h, 28 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30722933
Default Alt Text
D40239.id122319.diff (112 KB)

Event Timeline