summaryrefslogtreecommitdiff
path: root/sbin/ifconfig
diff options
context:
space:
mode:
authorAlexander Bluhm <bluhm@cvs.openbsd.org>2019-10-17 18:37:39 +0000
committerAlexander Bluhm <bluhm@cvs.openbsd.org>2019-10-17 18:37:39 +0000
commitcbce929af1571076ce58f7d4aca61c0b3b6ae5d9 (patch)
tree85d89a700c8a91d96aca3e1ff034d5fe62e659e7 /sbin/ifconfig
parent563b5af0ce3f5c97bb00224498ab90fea947259d (diff)
Fix some compiler warings in ifconfig(8). Move all prototypes and
variables used in multiple .c files into common ifconfig.h. Basically this renames brconfig.h to ifconfig.h and also uses it for sff.c. Fix missing prototypes. Global variable name s is bad as it shadows local variables. Call it sock and use it everywhere. OK deraadt@
Diffstat (limited to 'sbin/ifconfig')
-rw-r--r--sbin/ifconfig/brconfig.c94
-rw-r--r--sbin/ifconfig/ifconfig.c463
-rw-r--r--sbin/ifconfig/ifconfig.h (renamed from sbin/ifconfig/brconfig.h)16
-rw-r--r--sbin/ifconfig/sff.c42
4 files changed, 309 insertions, 306 deletions
diff --git a/sbin/ifconfig/brconfig.c b/sbin/ifconfig/brconfig.c
index 9cf97841f65..115fe0df22a 100644
--- a/sbin/ifconfig/brconfig.c
+++ b/sbin/ifconfig/brconfig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: brconfig.c,v 1.22 2019/06/28 13:32:44 deraadt Exp $ */
+/* $OpenBSD: brconfig.c,v 1.23 2019/10/17 18:37:38 bluhm Exp $ */
/*
* Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net)
@@ -47,7 +47,7 @@
#include <limits.h>
#include <arpa/inet.h>
-#include "brconfig.h"
+#include "ifconfig.h"
void bridge_ifsetflag(const char *, u_int32_t);
void bridge_ifclrflag(const char *, u_int32_t);
@@ -202,7 +202,7 @@ addlocal(const char *ifsname, int d)
/* Add local */
strlcpy(breq.ifbr_name, name, sizeof(breq.ifbr_name));
strlcpy(breq.ifbr_ifsname, ifsname, sizeof(breq.ifbr_ifsname));
- if (ioctl(s, SIOCBRDGADDL, (caddr_t)&breq) == -1) {
+ if (ioctl(sock, SIOCBRDGADDL, (caddr_t)&breq) == -1) {
if (errno == EEXIST)
return;
else
@@ -217,12 +217,12 @@ bridge_ifsetflag(const char *ifsname, u_int32_t flag)
strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
strlcpy(req.ifbr_ifsname, ifsname, sizeof(req.ifbr_ifsname));
- if (ioctl(s, SIOCBRDGGIFFLGS, (caddr_t)&req) == -1)
+ if (ioctl(sock, SIOCBRDGGIFFLGS, (caddr_t)&req) == -1)
err(1, "%s: ioctl SIOCBRDGGIFFLGS %s", name, ifsname);
req.ifbr_ifsflags |= flag & ~IFBIF_RO_MASK;
- if (ioctl(s, SIOCBRDGSIFFLGS, (caddr_t)&req) == -1)
+ if (ioctl(sock, SIOCBRDGSIFFLGS, (caddr_t)&req) == -1)
err(1, "%s: ioctl SIOCBRDGSIFFLGS %s", name, ifsname);
}
@@ -234,12 +234,12 @@ bridge_ifclrflag(const char *ifsname, u_int32_t flag)
strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
strlcpy(req.ifbr_ifsname, ifsname, sizeof(req.ifbr_ifsname));
- if (ioctl(s, SIOCBRDGGIFFLGS, (caddr_t)&req) == -1)
+ if (ioctl(sock, SIOCBRDGGIFFLGS, (caddr_t)&req) == -1)
err(1, "%s: ioctl SIOCBRDGGIFFLGS %s", name, ifsname);
req.ifbr_ifsflags &= ~(flag | IFBIF_RO_MASK);
- if (ioctl(s, SIOCBRDGSIFFLGS, (caddr_t)&req) == -1)
+ if (ioctl(sock, SIOCBRDGSIFFLGS, (caddr_t)&req) == -1)
err(1, "%s: ioctl SIOCBRDGSIFFLGS %s", name, ifsname);
}
@@ -250,7 +250,7 @@ bridge_flushall(const char *val, int p)
strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
req.ifbr_ifsflags = IFBF_FLUSHALL;
- if (ioctl(s, SIOCBRDGFLUSH, &req) == -1)
+ if (ioctl(sock, SIOCBRDGFLUSH, &req) == -1)
err(1, "%s", name);
}
@@ -261,7 +261,7 @@ bridge_flush(const char *val, int p)
strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
req.ifbr_ifsflags = IFBF_FLUSHDYN;
- if (ioctl(s, SIOCBRDGFLUSH, &req) == -1)
+ if (ioctl(sock, SIOCBRDGFLUSH, &req) == -1)
err(1, "%s", name);
}
@@ -275,7 +275,7 @@ bridge_cfg(const char *delim)
u_int16_t bprio;
strlcpy(ifbp.ifbop_name, name, sizeof(ifbp.ifbop_name));
- if (ioctl(s, SIOCBRDGGPARAM, (caddr_t)&ifbp) == -1) {
+ if (ioctl(sock, SIOCBRDGGPARAM, (caddr_t)&ifbp) == -1) {
if (errno == ENOTTY)
return;
err(1, "%s SIOCBRDGGPARAM", name);
@@ -323,7 +323,7 @@ bridge_list(char *delim)
err(1, "malloc");
bifc.ifbic_buf = inbuf = inb;
strlcpy(bifc.ifbic_name, name, sizeof(bifc.ifbic_name));
- if (ioctl(s, SIOCBRDGIFS, &bifc) == -1) {
+ if (ioctl(sock, SIOCBRDGIFS, &bifc) == -1) {
if (errno == ENOTTY)
return;
err(1, "%s SIOCBRDGIFS", name);
@@ -371,7 +371,7 @@ bridge_add(const char *ifn, int d)
strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
strlcpy(req.ifbr_ifsname, ifn, sizeof(req.ifbr_ifsname));
- if (ioctl(s, SIOCBRDGADD, &req) == -1) {
+ if (ioctl(sock, SIOCBRDGADD, &req) == -1) {
if (errno == EEXIST)
return;
err(1, "%s: %s", name, ifn);
@@ -385,7 +385,7 @@ bridge_delete(const char *ifn, int d)
strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
strlcpy(req.ifbr_ifsname, ifn, sizeof(req.ifbr_ifsname));
- if (ioctl(s, SIOCBRDGDEL, &req) == -1)
+ if (ioctl(sock, SIOCBRDGDEL, &req) == -1)
err(1, "%s: %s", name, ifn);
}
@@ -396,7 +396,7 @@ bridge_addspan(const char *ifn, int d)
strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
strlcpy(req.ifbr_ifsname, ifn, sizeof(req.ifbr_ifsname));
- if (ioctl(s, SIOCBRDGADDS, &req) == -1) {
+ if (ioctl(sock, SIOCBRDGADDS, &req) == -1) {
if (errno == EEXIST)
return;
err(1, "%s: %s", name, ifn);
@@ -410,7 +410,7 @@ bridge_delspan(const char *ifn, int d)
strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
strlcpy(req.ifbr_ifsname, ifn, sizeof(req.ifbr_ifsname));
- if (ioctl(s, SIOCBRDGDELS, &req) == -1)
+ if (ioctl(sock, SIOCBRDGDELS, &req) == -1)
err(1, "%s: %s", name, ifn);
}
@@ -430,7 +430,7 @@ bridge_timeout(const char *arg, int d)
strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name));
bp.ifbrp_ctime = newtime;
- if (ioctl(s, SIOCBRDGSTO, (caddr_t)&bp) == -1)
+ if (ioctl(sock, SIOCBRDGSTO, (caddr_t)&bp) == -1)
err(1, "%s", name);
}
@@ -449,7 +449,7 @@ bridge_maxage(const char *arg, int d)
strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name));
bp.ifbrp_maxage = v;
- if (ioctl(s, SIOCBRDGSMA, (caddr_t)&bp) == -1)
+ if (ioctl(sock, SIOCBRDGSMA, (caddr_t)&bp) == -1)
err(1, "%s", name);
}
@@ -468,7 +468,7 @@ bridge_priority(const char *arg, int d)
strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name));
bp.ifbrp_prio = v;
- if (ioctl(s, SIOCBRDGSPRI, (caddr_t)&bp) == -1)
+ if (ioctl(sock, SIOCBRDGSPRI, (caddr_t)&bp) == -1)
err(1, "%s", name);
}
@@ -500,7 +500,7 @@ bridge_protect(const char *ifname, const char *val)
str = strtok(NULL, ",");
}
- if (ioctl(s, SIOCBRDGSIFPROT, (caddr_t)&breq) == -1)
+ if (ioctl(sock, SIOCBRDGSIFPROT, (caddr_t)&breq) == -1)
err(1, "%s: %s", name, val);
free(optlist);
@@ -516,7 +516,7 @@ bridge_unprotect(const char *ifname, int d)
breq.ifbr_protected = 0;
- if (ioctl(s, SIOCBRDGSIFPROT, (caddr_t)&breq) == -1)
+ if (ioctl(sock, SIOCBRDGSIFPROT, (caddr_t)&breq) == -1)
err(1, "%s: %d", name, 0);
}
@@ -536,7 +536,7 @@ bridge_proto(const char *arg, int d)
strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name));
bp.ifbrp_prio = proto;
- if (ioctl(s, SIOCBRDGSPROTO, (caddr_t)&bp) == -1)
+ if (ioctl(sock, SIOCBRDGSPROTO, (caddr_t)&bp) == -1)
err(1, "%s", name);
}
@@ -555,7 +555,7 @@ bridge_fwddelay(const char *arg, int d)
strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name));
bp.ifbrp_fwddelay = v;
- if (ioctl(s, SIOCBRDGSFD, (caddr_t)&bp) == -1)
+ if (ioctl(sock, SIOCBRDGSFD, (caddr_t)&bp) == -1)
err(1, "%s", name);
}
@@ -574,7 +574,7 @@ bridge_hellotime(const char *arg, int d)
strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name));
bp.ifbrp_hellotime = v;
- if (ioctl(s, SIOCBRDGSHT, (caddr_t)&bp) == -1)
+ if (ioctl(sock, SIOCBRDGSHT, (caddr_t)&bp) == -1)
err(1, "%s", name);
}
@@ -593,7 +593,7 @@ bridge_maxaddr(const char *arg, int d)
strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name));
bp.ifbrp_csize = newsize;
- if (ioctl(s, SIOCBRDGSCACHE, (caddr_t)&bp) == -1)
+ if (ioctl(sock, SIOCBRDGSCACHE, (caddr_t)&bp) == -1)
err(1, "%s", name);
}
@@ -610,7 +610,7 @@ bridge_deladdr(const char *addr, int d)
bcopy(ea, &ifba.ifba_dst, sizeof(struct ether_addr));
- if (ioctl(s, SIOCBRDGDADDR, &ifba) == -1)
+ if (ioctl(sock, SIOCBRDGDADDR, &ifba) == -1)
err(1, "%s: %s", name, addr);
}
@@ -631,7 +631,7 @@ bridge_ifprio(const char *ifname, const char *val)
err(1, "invalid arg for ifpriority: %s", val);
breq.ifbr_priority = v;
- if (ioctl(s, SIOCBRDGSIFPRIO, (caddr_t)&breq) == -1)
+ if (ioctl(sock, SIOCBRDGSIFPRIO, (caddr_t)&breq) == -1)
err(1, "%s: %s", name, val);
}
@@ -653,7 +653,7 @@ bridge_ifcost(const char *ifname, const char *val)
breq.ifbr_path_cost = v;
- if (ioctl(s, SIOCBRDGSIFCOST, (caddr_t)&breq) == -1)
+ if (ioctl(sock, SIOCBRDGSIFCOST, (caddr_t)&breq) == -1)
err(1, "%s: %s", name, val);
}
@@ -667,7 +667,7 @@ bridge_noifcost(const char *ifname, int d)
breq.ifbr_path_cost = 0;
- if (ioctl(s, SIOCBRDGSIFCOST, (caddr_t)&breq) == -1)
+ if (ioctl(sock, SIOCBRDGSIFCOST, (caddr_t)&breq) == -1)
err(1, "%s", name);
}
@@ -687,7 +687,7 @@ bridge_addaddr(const char *ifname, const char *addr)
bcopy(ea, &ifba.ifba_dst, sizeof(struct ether_addr));
ifba.ifba_flags = IFBAF_STATIC;
- if (ioctl(s, SIOCBRDGSADDR, &ifba) == -1)
+ if (ioctl(sock, SIOCBRDGSADDR, &ifba) == -1)
err(1, "%s: %s", name, addr);
}
@@ -714,7 +714,7 @@ bridge_addrs(const char *delim, int d)
err(1, "malloc");
ifbac.ifbac_buf = inbuf = inb;
strlcpy(ifbac.ifbac_name, name, sizeof(ifbac.ifbac_name));
- if (ioctl(s, SIOCBRDGRTS, &ifbac) == -1) {
+ if (ioctl(sock, SIOCBRDGRTS, &ifbac) == -1) {
if (errno == ENETDOWN)
return;
err(1, "%s", name);
@@ -752,7 +752,7 @@ bridge_holdcnt(const char *value, int d)
err(1, "holdcnt %s %s", value, errstr);
strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name));
- if (ioctl(s, SIOCBRDGSTXHC, (caddr_t)&bp) == -1)
+ if (ioctl(sock, SIOCBRDGSTXHC, (caddr_t)&bp) == -1)
err(1, "%s", name);
}
@@ -767,12 +767,12 @@ is_bridge(char *brdg)
strlcpy(ifr.ifr_name, brdg, sizeof(ifr.ifr_name));
- if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGIFFLAGS, (caddr_t)&ifr) == -1)
return (0);
ifbac.ifbac_len = 0;
strlcpy(ifbac.ifbac_name, brdg, sizeof(ifbac.ifbac_name));
- if (ioctl(s, SIOCBRDGRTS, (caddr_t)&ifbac) == -1) {
+ if (ioctl(sock, SIOCBRDGRTS, (caddr_t)&ifbac) == -1) {
if (errno == ENETDOWN)
return (1);
return (0);
@@ -790,7 +790,7 @@ bridge_status(void)
return;
strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
- if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGIFFLAGS, (caddr_t)&ifr) == -1)
return;
bridge_cfg("\t");
@@ -801,11 +801,11 @@ bridge_status(void)
return;
strlcpy(bp1.ifbrp_name, name, sizeof(bp1.ifbrp_name));
- if (ioctl(s, SIOCBRDGGCACHE, (caddr_t)&bp1) == -1)
+ if (ioctl(sock, SIOCBRDGGCACHE, (caddr_t)&bp1) == -1)
return;
strlcpy(bp2.ifbrp_name, name, sizeof(bp2.ifbrp_name));
- if (ioctl(s, SIOCBRDGGTO, (caddr_t)&bp2) == -1)
+ if (ioctl(sock, SIOCBRDGGTO, (caddr_t)&bp2) == -1)
return;
printf("\tAddresses (max cache: %u, timeout: %u):\n",
@@ -821,7 +821,7 @@ bridge_flushrule(const char *ifname, int d)
strlcpy(req.ifbr_name, name, sizeof(req.ifbr_name));
strlcpy(req.ifbr_ifsname, ifname, sizeof(req.ifbr_ifsname));
- if (ioctl(s, SIOCBRDGFRL, &req) == -1)
+ if (ioctl(sock, SIOCBRDGFRL, &req) == -1)
err(1, "%s: %s", name, ifname);
}
@@ -841,7 +841,7 @@ bridge_rules(const char *ifname, int usetab)
ifc.ifbrl_buf = inbuf = inb;
strlcpy(ifc.ifbrl_name, name, sizeof(ifc.ifbrl_name));
strlcpy(ifc.ifbrl_ifsname, ifname, sizeof(ifc.ifbrl_ifsname));
- if (ioctl(s, SIOCBRDGGRL, &ifc) == -1)
+ if (ioctl(sock, SIOCBRDGGRL, &ifc) == -1)
err(1, "ioctl(SIOCBRDGGRL)");
if (ifc.ifbrl_len + sizeof(*ifrp) < len)
break;
@@ -1020,7 +1020,7 @@ bridge_rule(int targc, char **targv, int ln)
}
}
- if (ioctl(s, SIOCBRDGARL, &rule) == -1) {
+ if (ioctl(sock, SIOCBRDGARL, &rule) == -1) {
warn("%s", name);
return (1);
}
@@ -1151,31 +1151,31 @@ is_switch(char *swname)
struct ifbrparam bp;
strlcpy(bp.ifbrp_name, swname, sizeof(bp.ifbrp_name));
- if (ioctl(s, SIOCSWGDPID, (caddr_t)&bp) == -1)
+ if (ioctl(sock, SIOCSWGDPID, (caddr_t)&bp) == -1)
return (0);
return (1);
}
-void
+static void
switch_cfg(char *delim)
{
struct ifbrparam bp;
strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name));
- if (ioctl(s, SIOCSWGDPID, (caddr_t)&bp) == -1)
+ if (ioctl(sock, SIOCSWGDPID, (caddr_t)&bp) == -1)
err(1, "%s", name);
printf("%sdatapath %#016llx", delim, bp.ifbrp_datapath);
strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name));
- if (ioctl(s, SIOCSWGMAXFLOW, (caddr_t)&bp) == -1)
+ if (ioctl(sock, SIOCSWGMAXFLOW, (caddr_t)&bp) == -1)
err(1, "%s", name);
printf(" maxflow %d", bp.ifbrp_maxflow);
strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name));
- if (ioctl(s, SIOCSWGMAXGROUP, (caddr_t)&bp) == -1)
+ if (ioctl(sock, SIOCSWGMAXGROUP, (caddr_t)&bp) == -1)
err(1, "%s", name);
printf(" maxgroup %d\n", bp.ifbrp_maxgroup);
@@ -1190,7 +1190,7 @@ switch_status(void)
return;
strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
- if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGIFFLAGS, (caddr_t)&ifr) == -1)
return;
switch_cfg("\t");
@@ -1215,7 +1215,7 @@ switch_datapathid(const char *arg, int d)
strlcpy(bp.ifbrp_name, name, sizeof(bp.ifbrp_name));
bp.ifbrp_datapath = newdpid;
- if (ioctl(s, SIOCSWSDPID, (caddr_t)&bp) == -1)
+ if (ioctl(sock, SIOCSWSDPID, (caddr_t)&bp) == -1)
err(1, "%s", name);
}
@@ -1235,7 +1235,7 @@ switch_portno(const char *ifname, const char *val)
errx(1, "invalid arg for portidx: %s", val);
breq.ifbr_portno = newportidx;
- if (ioctl(s, SIOCSWSPORTNO, (caddr_t)&breq) == -1) {
+ if (ioctl(sock, SIOCSWSPORTNO, (caddr_t)&breq) == -1) {
if (errno == EEXIST)
return;
else
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 961a54ab4db..8a8a62ad693 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ifconfig.c,v 1.412 2019/09/02 12:54:21 stsp Exp $ */
+/* $OpenBSD: ifconfig.c,v 1.413 2019/10/17 18:37:38 bluhm Exp $ */
/* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */
/*
@@ -106,12 +106,13 @@
#include <util.h>
#include <ifaddrs.h>
-#include "brconfig.h"
#ifndef SMALL
#include <dev/usb/mbim.h>
#include <dev/usb/if_umb.h>
#endif /* SMALL */
+#include "ifconfig.h"
+
#define MINIMUM(a, b) (((a) < (b)) ? (a) : (b))
#define MAXIMUM(a, b) (((a) > (b)) ? (a) : (b))
@@ -161,7 +162,7 @@ int flags, xflags, setaddr, setipdst, doalias;
u_long metric, mtu;
int rdomainid;
int llprio;
-int clearaddr, s;
+int clearaddr, sock;
int newaddr = 0;
int af = AF_INET;
int explicit_prefix = 0;
@@ -343,7 +344,6 @@ void utf16_to_char(uint16_t *, int, char *, size_t);
int char_to_utf16(const char *, uint16_t *, size_t);
void transceiver(const char *, int);
void transceiverdump(const char *, int);
-int if_sff_info(int, const char *, int);
#else
void setignore(const char *, int);
#endif
@@ -637,6 +637,13 @@ const struct cmd {
{ NULL, /*illegal*/0, 0, NULL },
};
+#define IFFBITS \
+ "\024\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6STATICARP" \
+ "\7RUNNING\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX" \
+ "\15LINK0\16LINK1\17LINK2\20MULTICAST" \
+ "\23INET6_NOPRIVACY\24MPLS\25WOL\26AUTOCONF6\27INET6_NOSOII" \
+ "\30AUTOCONF4"
+
int getinfo(struct ifreq *, int);
void getsock(int);
void printgroupattribs(char *);
@@ -924,7 +931,7 @@ nextarg:
if (clearaddr) {
(void) strlcpy(rafp->af_ridreq, name, sizeof(ifr.ifr_name));
- if (ioctl(s, rafp->af_difaddr, rafp->af_ridreq) == -1) {
+ if (ioctl(sock, rafp->af_difaddr, rafp->af_ridreq) == -1) {
if (errno == EADDRNOTAVAIL && (doalias >= 0)) {
/* means no previous address for interface */
} else
@@ -933,7 +940,7 @@ nextarg:
}
if (newaddr) {
(void) strlcpy(rafp->af_addreq, name, sizeof(ifr.ifr_name));
- if (ioctl(s, rafp->af_aifaddr, rafp->af_addreq) == -1)
+ if (ioctl(sock, rafp->af_aifaddr, rafp->af_addreq) == -1)
err(1, "SIOCAIFADDR");
}
return (0);
@@ -947,9 +954,9 @@ getsock(int naf)
if (oaf == naf)
return;
if (oaf != -1)
- close(s);
- s = socket(naf, SOCK_DGRAM, 0);
- if (s == -1)
+ close(sock);
+ sock = socket(naf, SOCK_DGRAM, 0);
+ if (sock == -1)
oaf = -1;
else
oaf = naf;
@@ -960,45 +967,45 @@ getinfo(struct ifreq *ifr, int create)
{
getsock(af);
- if (s == -1)
+ if (sock == -1)
err(1, "socket");
if (!isdigit((unsigned char)name[strlen(name) - 1]))
return (-1); /* ignore groups here */
- if (ioctl(s, SIOCGIFFLAGS, (caddr_t)ifr) == -1) {
+ if (ioctl(sock, SIOCGIFFLAGS, (caddr_t)ifr) == -1) {
int oerrno = errno;
if (!create)
return (-1);
- if (ioctl(s, SIOCIFCREATE, (caddr_t)ifr) == -1) {
+ if (ioctl(sock, SIOCIFCREATE, (caddr_t)ifr) == -1) {
errno = oerrno;
return (-1);
}
- if (ioctl(s, SIOCGIFFLAGS, (caddr_t)ifr) == -1)
+ if (ioctl(sock, SIOCGIFFLAGS, (caddr_t)ifr) == -1)
return (-1);
}
flags = ifr->ifr_flags & 0xffff;
- if (ioctl(s, SIOCGIFXFLAGS, (caddr_t)ifr) == -1)
+ if (ioctl(sock, SIOCGIFXFLAGS, (caddr_t)ifr) == -1)
ifr->ifr_flags = 0;
xflags = ifr->ifr_flags;
- if (ioctl(s, SIOCGIFMETRIC, (caddr_t)ifr) == -1)
+ if (ioctl(sock, SIOCGIFMETRIC, (caddr_t)ifr) == -1)
metric = 0;
else
metric = ifr->ifr_metric;
#ifdef SMALL
- if (ioctl(s, SIOCGIFMTU, (caddr_t)ifr) == -1)
+ if (ioctl(sock, SIOCGIFMTU, (caddr_t)ifr) == -1)
#else
- if (is_bridge(name) || ioctl(s, SIOCGIFMTU, (caddr_t)ifr) == -1)
+ if (is_bridge(name) || ioctl(sock, SIOCGIFMTU, (caddr_t)ifr) == -1)
#endif
mtu = 0;
else
mtu = ifr->ifr_mtu;
#ifndef SMALL
- if (ioctl(s, SIOCGIFRDOMAIN, (caddr_t)ifr) == -1)
+ if (ioctl(sock, SIOCGIFRDOMAIN, (caddr_t)ifr) == -1)
rdomainid = 0;
else
rdomainid = ifr->ifr_rdomainid;
#endif
- if (ioctl(s, SIOCGIFLLPRIO, (caddr_t)ifr) == -1)
+ if (ioctl(sock, SIOCGIFLLPRIO, (caddr_t)ifr) == -1)
llprio = 0;
else
llprio = ifr->ifr_llprio;
@@ -1016,7 +1023,7 @@ printgroup(char *groupname, int ifaliases)
getsock(AF_INET);
bzero(&ifgr, sizeof(ifgr));
strlcpy(ifgr.ifgr_name, groupname, sizeof(ifgr.ifgr_name));
- if (ioctl(s, SIOCGIFGMEMB, (caddr_t)&ifgr) == -1) {
+ if (ioctl(sock, SIOCGIFGMEMB, (caddr_t)&ifgr) == -1) {
if (errno == EINVAL || errno == ENOTTY ||
errno == ENOENT)
return (-1);
@@ -1027,7 +1034,7 @@ printgroup(char *groupname, int ifaliases)
len = ifgr.ifgr_len;
if ((ifgr.ifgr_groups = calloc(1, len)) == NULL)
err(1, "printgroup");
- if (ioctl(s, SIOCGIFGMEMB, (caddr_t)&ifgr) == -1)
+ if (ioctl(sock, SIOCGIFGMEMB, (caddr_t)&ifgr) == -1)
err(1, "SIOCGIFGMEMB");
for (ifg = ifgr.ifgr_groups; ifg && len >= sizeof(struct ifg_req);
@@ -1049,7 +1056,7 @@ printgroupattribs(char *groupname)
getsock(AF_INET);
bzero(&ifgr, sizeof(ifgr));
strlcpy(ifgr.ifgr_name, groupname, sizeof(ifgr.ifgr_name));
- if (ioctl(s, SIOCGIFGATTR, (caddr_t)&ifgr) == -1)
+ if (ioctl(sock, SIOCGIFGATTR, (caddr_t)&ifgr) == -1)
err(1, "SIOCGIFGATTR");
printf("%s:", groupname);
@@ -1085,7 +1092,7 @@ setgroupattribs(char *groupname, int argc, char *argv[])
else
usage();
- if (ioctl(s, SIOCSIFGATTR, (caddr_t)&ifgr) == -1)
+ if (ioctl(sock, SIOCSIFGATTR, (caddr_t)&ifgr) == -1)
err(1, "SIOCSIFGATTR");
}
@@ -1197,7 +1204,7 @@ clone_create(const char *addr, int param)
getsock(AF_INET);
(void) strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
- if (ioctl(s, SIOCIFCREATE, &ifr) == -1)
+ if (ioctl(sock, SIOCIFCREATE, &ifr) == -1)
err(1, "SIOCIFCREATE");
}
@@ -1207,7 +1214,7 @@ clone_destroy(const char *addr, int param)
{
(void) strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
- if (ioctl(s, SIOCIFDESTROY, &ifr) == -1)
+ if (ioctl(sock, SIOCIFDESTROY, &ifr) == -1)
err(1, "SIOCIFDESTROY");
}
@@ -1222,7 +1229,7 @@ list_cloners(void)
getsock(AF_INET);
- if (ioctl(s, SIOCIFGCLONERS, &ifcr) == -1)
+ if (ioctl(sock, SIOCIFGCLONERS, &ifcr) == -1)
err(1, "SIOCIFGCLONERS for count");
buf = calloc(ifcr.ifcr_total, IFNAMSIZ);
@@ -1232,7 +1239,7 @@ list_cloners(void)
ifcr.ifcr_count = ifcr.ifcr_total;
ifcr.ifcr_buffer = buf;
- if (ioctl(s, SIOCIFGCLONERS, &ifcr) == -1)
+ if (ioctl(sock, SIOCIFGCLONERS, &ifcr) == -1)
err(1, "SIOCIFGCLONERS for names");
/*
@@ -1284,7 +1291,7 @@ setifrtlabel(const char *label, int d)
ifr.ifr_data = (caddr_t)(const char *)"";
else
ifr.ifr_data = (caddr_t)label;
- if (ioctl(s, SIOCSIFRTLABEL, &ifr) == -1)
+ if (ioctl(sock, SIOCSIFRTLABEL, &ifr) == -1)
warn("SIOCSIFRTLABEL");
}
#endif
@@ -1309,7 +1316,7 @@ void
setifdesc(const char *val, int ignored)
{
ifr.ifr_data = (caddr_t)val;
- if (ioctl(s, SIOCSIFDESCR, &ifr) == -1)
+ if (ioctl(sock, SIOCSIFDESCR, &ifr) == -1)
warn("SIOCSIFDESCR");
}
@@ -1318,7 +1325,7 @@ void
unsetifdesc(const char *noval, int ignored)
{
ifr.ifr_data = (caddr_t)(const char *)"";
- if (ioctl(s, SIOCSIFDESCR, &ifr) == -1)
+ if (ioctl(sock, SIOCSIFDESCR, &ifr) == -1)
warn("SIOCSIFDESCR");
}
@@ -1371,7 +1378,7 @@ setifflags(const char *vname, int value)
bcopy((char *)&ifr, (char *)&my_ifr, sizeof(struct ifreq));
- if (ioctl(s, SIOCGIFFLAGS, (caddr_t)&my_ifr) == -1)
+ if (ioctl(sock, SIOCGIFFLAGS, (caddr_t)&my_ifr) == -1)
err(1, "SIOCGIFFLAGS");
(void) strlcpy(my_ifr.ifr_name, name, sizeof(my_ifr.ifr_name));
flags = my_ifr.ifr_flags;
@@ -1382,7 +1389,7 @@ setifflags(const char *vname, int value)
} else
flags |= value;
my_ifr.ifr_flags = flags;
- if (ioctl(s, SIOCSIFFLAGS, (caddr_t)&my_ifr) == -1)
+ if (ioctl(sock, SIOCSIFFLAGS, (caddr_t)&my_ifr) == -1)
err(1, "SIOCSIFFLAGS");
}
@@ -1394,7 +1401,7 @@ setifxflags(const char *vname, int value)
bcopy((char *)&ifr, (char *)&my_ifr, sizeof(struct ifreq));
- if (ioctl(s, SIOCGIFXFLAGS, (caddr_t)&my_ifr) == -1)
+ if (ioctl(sock, SIOCGIFXFLAGS, (caddr_t)&my_ifr) == -1)
warn("SIOCGIFXFLAGS");
(void) strlcpy(my_ifr.ifr_name, name, sizeof(my_ifr.ifr_name));
xflags = my_ifr.ifr_flags;
@@ -1405,7 +1412,7 @@ setifxflags(const char *vname, int value)
} else
xflags |= value;
my_ifr.ifr_flags = xflags;
- if (ioctl(s, SIOCSIFXFLAGS, (caddr_t)&my_ifr) == -1)
+ if (ioctl(sock, SIOCSIFXFLAGS, (caddr_t)&my_ifr) == -1)
warn("SIOCSIFXFLAGS");
}
@@ -1416,7 +1423,7 @@ addaf(const char *vname, int value)
strlcpy(ifar.ifar_name, name, sizeof(ifar.ifar_name));
ifar.ifar_af = value;
- if (ioctl(s, SIOCIFAFATTACH, (caddr_t)&ifar) == -1)
+ if (ioctl(sock, SIOCIFAFATTACH, (caddr_t)&ifar) == -1)
warn("SIOCIFAFATTACH");
}
@@ -1427,7 +1434,7 @@ removeaf(const char *vname, int value)
strlcpy(ifar.ifar_name, name, sizeof(ifar.ifar_name));
ifar.ifar_af = value;
- if (ioctl(s, SIOCIFAFDETACH, (caddr_t)&ifar) == -1)
+ if (ioctl(sock, SIOCIFAFDETACH, (caddr_t)&ifar) == -1)
warn("SIOCIFAFDETACH");
}
@@ -1542,7 +1549,7 @@ setifmetric(const char *val, int ignored)
ifr.ifr_metric = strtonum(val, 0, INT_MAX, &errmsg);
if (errmsg)
errx(1, "metric %s: %s", val, errmsg);
- if (ioctl(s, SIOCSIFMETRIC, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSIFMETRIC, (caddr_t)&ifr) == -1)
warn("SIOCSIFMETRIC");
}
#endif
@@ -1558,7 +1565,7 @@ setifmtu(const char *val, int d)
ifr.ifr_mtu = strtonum(val, 0, INT_MAX, &errmsg);
if (errmsg)
errx(1, "mtu %s: %s", val, errmsg);
- if (ioctl(s, SIOCSIFMTU, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSIFMTU, (caddr_t)&ifr) == -1)
warn("SIOCSIFMTU");
}
@@ -1573,7 +1580,7 @@ setifllprio(const char *val, int d)
ifr.ifr_llprio = strtonum(val, 0, UCHAR_MAX, &errmsg);
if (errmsg)
errx(1, "llprio %s: %s", val, errmsg);
- if (ioctl(s, SIOCSIFLLPRIO, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSIFLLPRIO, (caddr_t)&ifr) == -1)
warn("SIOCSIFLLPRIO");
}
@@ -1592,7 +1599,7 @@ setifgroup(const char *group_name, int dummy)
if (strlcpy(ifgr.ifgr_group, group_name, IFNAMSIZ) >= IFNAMSIZ)
errx(1, "setifgroup: group name too long");
- if (ioctl(s, SIOCAIFGROUP, (caddr_t)&ifgr) == -1) {
+ if (ioctl(sock, SIOCAIFGROUP, (caddr_t)&ifgr) == -1) {
if (errno != EEXIST)
err(1," SIOCAIFGROUP");
}
@@ -1613,7 +1620,7 @@ unsetifgroup(const char *group_name, int dummy)
if (strlcpy(ifgr.ifgr_group, group_name, IFNAMSIZ) >= IFNAMSIZ)
errx(1, "unsetifgroup: group name too long");
- if (ioctl(s, SIOCDIFGROUP, (caddr_t)&ifgr) == -1)
+ if (ioctl(sock, SIOCDIFGROUP, (caddr_t)&ifgr) == -1)
err(1, "SIOCDIFGROUP");
}
@@ -1747,7 +1754,7 @@ setifnwid(const char *val, int d)
(void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
(void)strlcpy(nwidname, nwid.i_nwid, sizeof(nwidname));
ifr.ifr_data = (caddr_t)&nwid;
- if (ioctl(s, SIOCS80211NWID, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCS80211NWID, (caddr_t)&ifr) == -1)
warn("SIOCS80211NWID");
}
@@ -1759,7 +1766,7 @@ process_join_commands(void)
return;
ifr.ifr_data = (caddr_t)&join;
- if (ioctl(s, SIOCS80211JOIN, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCS80211JOIN, (caddr_t)&ifr) == -1)
err(1, "SIOCS80211JOIN");
}
@@ -1806,7 +1813,7 @@ delifjoin(const char *val, int d)
if (d == -1) {
ifr.ifr_data = (caddr_t)&join;
- if (ioctl(s, SIOCS80211JOIN, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCS80211JOIN, (caddr_t)&ifr) == -1)
err(1, "SIOCS80211JOIN");
}
@@ -1818,7 +1825,7 @@ delifjoin(const char *val, int d)
join.i_flags |= IEEE80211_JOIN_ANY;
(void)strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
ifr.ifr_data = (caddr_t)&join;
- if (ioctl(s, SIOCS80211JOIN, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCS80211JOIN, (caddr_t)&ifr) == -1)
err(1, "SIOCS80211JOIN");
}
@@ -1834,13 +1841,13 @@ delifjoinlist(const char *val, int d)
if (d == -1) {
ifr.ifr_data = (caddr_t)&join;
- if (ioctl(s, SIOCS80211JOIN, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCS80211JOIN, (caddr_t)&ifr) == -1)
err(1, "SIOCS80211JOIN");
return;
}
ifr.ifr_data = (caddr_t)&join;
- if (ioctl(s, SIOCS80211JOIN, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCS80211JOIN, (caddr_t)&ifr) == -1)
err(1, "SIOCS80211JOIN");
}
@@ -1864,7 +1871,7 @@ setifbssid(const char *val, int d)
sizeof(bssid.i_bssid));
}
strlcpy(bssid.i_name, name, sizeof(bssid.i_name));
- if (ioctl(s, SIOCS80211BSSID, &bssid) == -1)
+ if (ioctl(sock, SIOCS80211BSSID, &bssid) == -1)
warn("SIOCS80211BSSID");
}
@@ -1963,7 +1970,7 @@ setifnwkey(const char *val, int d)
return;
}
- if (ioctl(s, SIOCS80211NWKEY, (caddr_t)&nwkey) == -1)
+ if (ioctl(sock, SIOCS80211NWKEY, (caddr_t)&nwkey) == -1)
warn("SIOCS80211NWKEY");
}
@@ -1984,7 +1991,7 @@ setifwpa(const char *val, int d)
return;
}
- if (ioctl(s, SIOCS80211WPAPARMS, (caddr_t)&wpa) == -1)
+ if (ioctl(sock, SIOCS80211WPAPARMS, (caddr_t)&wpa) == -1)
err(1, "SIOCS80211WPAPARMS");
}
@@ -2018,14 +2025,14 @@ setifwpaprotos(const char *val, int d)
memset(&wpa, 0, sizeof(wpa));
(void)strlcpy(wpa.i_name, name, sizeof(wpa.i_name));
- if (ioctl(s, SIOCG80211WPAPARMS, (caddr_t)&wpa) == -1)
+ if (ioctl(sock, SIOCG80211WPAPARMS, (caddr_t)&wpa) == -1)
err(1, "SIOCG80211WPAPARMS");
wpa.i_protos = rval;
/* Let the kernel set up the appropriate default ciphers. */
wpa.i_ciphers = 0;
wpa.i_groupcipher = 0;
- if (ioctl(s, SIOCS80211WPAPARMS, (caddr_t)&wpa) == -1)
+ if (ioctl(sock, SIOCS80211WPAPARMS, (caddr_t)&wpa) == -1)
err(1, "SIOCS80211WPAPARMS");
}
@@ -2061,13 +2068,13 @@ setifwpaakms(const char *val, int d)
memset(&wpa, 0, sizeof(wpa));
(void)strlcpy(wpa.i_name, name, sizeof(wpa.i_name));
- if (ioctl(s, SIOCG80211WPAPARMS, (caddr_t)&wpa) == -1)
+ if (ioctl(sock, SIOCG80211WPAPARMS, (caddr_t)&wpa) == -1)
err(1, "SIOCG80211WPAPARMS");
wpa.i_akms = rval;
/* Enable WPA for 802.1x here. PSK case is handled in setifwpakey(). */
wpa.i_enabled = ((rval & IEEE80211_WPA_AKM_8021X) != 0);
- if (ioctl(s, SIOCS80211WPAPARMS, (caddr_t)&wpa) == -1)
+ if (ioctl(sock, SIOCS80211WPAPARMS, (caddr_t)&wpa) == -1)
err(1, "SIOCS80211WPAPARMS");
}
@@ -2122,11 +2129,11 @@ setifwpaciphers(const char *val, int d)
memset(&wpa, 0, sizeof(wpa));
(void)strlcpy(wpa.i_name, name, sizeof(wpa.i_name));
- if (ioctl(s, SIOCG80211WPAPARMS, (caddr_t)&wpa) == -1)
+ if (ioctl(sock, SIOCG80211WPAPARMS, (caddr_t)&wpa) == -1)
err(1, "SIOCG80211WPAPARMS");
wpa.i_ciphers = rval;
- if (ioctl(s, SIOCS80211WPAPARMS, (caddr_t)&wpa) == -1)
+ if (ioctl(sock, SIOCS80211WPAPARMS, (caddr_t)&wpa) == -1)
err(1, "SIOCS80211WPAPARMS");
}
@@ -2143,7 +2150,7 @@ setifwpagroupcipher(const char *val, int d)
memset(&wpa, 0, sizeof(wpa));
(void)strlcpy(wpa.i_name, name, sizeof(wpa.i_name));
- if (ioctl(s, SIOCG80211WPAPARMS, (caddr_t)&wpa) == -1)
+ if (ioctl(sock, SIOCG80211WPAPARMS, (caddr_t)&wpa) == -1)
err(1, "SIOCG80211WPAPARMS");
wpa.i_groupcipher = cipher;
@@ -2153,7 +2160,7 @@ setifwpagroupcipher(const char *val, int d)
return;
}
- if (ioctl(s, SIOCS80211WPAPARMS, (caddr_t)&wpa) == -1)
+ if (ioctl(sock, SIOCS80211WPAPARMS, (caddr_t)&wpa) == -1)
err(1, "SIOCS80211WPAPARMS");
}
@@ -2181,7 +2188,7 @@ setifwpakey(const char *val, int d)
} else {
warnx("no nwid or join command, guessing nwid to use");
- if (ioctl(s, SIOCG80211NWID, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCG80211NWID, (caddr_t)&ifr) == -1)
err(1, "SIOCG80211NWID");
}
@@ -2218,16 +2225,16 @@ setifwpakey(const char *val, int d)
return;
}
- if (ioctl(s, SIOCS80211WPAPSK, (caddr_t)&psk) == -1)
+ if (ioctl(sock, SIOCS80211WPAPSK, (caddr_t)&psk) == -1)
err(1, "SIOCS80211WPAPSK");
/* And ... automatically enable or disable WPA */
memset(&wpa, 0, sizeof(wpa));
(void)strlcpy(wpa.i_name, name, sizeof(wpa.i_name));
- if (ioctl(s, SIOCG80211WPAPARMS, (caddr_t)&wpa) == -1)
+ if (ioctl(sock, SIOCG80211WPAPARMS, (caddr_t)&wpa) == -1)
err(1, "SIOCG80211WPAPARMS");
wpa.i_enabled = psk.i_enabled;
- if (ioctl(s, SIOCS80211WPAPARMS, (caddr_t)&wpa) == -1)
+ if (ioctl(sock, SIOCS80211WPAPARMS, (caddr_t)&wpa) == -1)
err(1, "SIOCS80211WPAPARMS");
}
@@ -2256,7 +2263,7 @@ setifchan(const char *val, int d)
strlcpy(channel.i_name, name, sizeof(channel.i_name));
channel.i_channel = (u_int16_t)chan;
- if (ioctl(s, SIOCS80211CHANNEL, (caddr_t)&channel) == -1)
+ if (ioctl(sock, SIOCS80211CHANNEL, (caddr_t)&channel) == -1)
warn("SIOCS80211CHANNEL");
}
@@ -2286,7 +2293,7 @@ setifnwflag(const char *val, int d)
if (flag == 0)
errx(1, "Invalid nwflag: %s", val);
- if (ioctl(s, SIOCG80211FLAGS, (caddr_t)&ifr) != 0)
+ if (ioctl(sock, SIOCG80211FLAGS, (caddr_t)&ifr) != 0)
err(1, "SIOCG80211FLAGS");
if (d)
@@ -2294,7 +2301,7 @@ setifnwflag(const char *val, int d)
else
ifr.ifr_flags |= flag;
- if (ioctl(s, SIOCS80211FLAGS, (caddr_t)&ifr) != 0)
+ if (ioctl(sock, SIOCS80211FLAGS, (caddr_t)&ifr) != 0)
err(1, "SIOCS80211FLAGS");
}
@@ -2312,7 +2319,7 @@ setifpowersave(const char *val, int d)
const char *errmsg = NULL;
(void)strlcpy(power.i_name, name, sizeof(power.i_name));
- if (ioctl(s, SIOCG80211POWER, (caddr_t)&power) == -1) {
+ if (ioctl(sock, SIOCG80211POWER, (caddr_t)&power) == -1) {
warn("SIOCG80211POWER");
return;
}
@@ -2324,7 +2331,7 @@ setifpowersave(const char *val, int d)
}
power.i_enabled = d == -1 ? 0 : 1;
- if (ioctl(s, SIOCS80211POWER, (caddr_t)&power) == -1)
+ if (ioctl(sock, SIOCS80211POWER, (caddr_t)&power) == -1)
warn("SIOCS80211POWER");
}
#endif
@@ -2347,7 +2354,7 @@ print_cipherset(u_int32_t cipherset)
}
}
-void
+static void
print_assoc_failures(uint32_t assoc_fail)
{
/* Filter out the most obvious failure cases. */
@@ -2383,35 +2390,35 @@ ieee80211_status(void)
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_data = (caddr_t)&nwid;
strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
- inwid = ioctl(s, SIOCG80211NWID, (caddr_t)&ifr);
+ inwid = ioctl(sock, SIOCG80211NWID, (caddr_t)&ifr);
ifr.ifr_data = (caddr_t)&join;
strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
- ijoin = ioctl(s, SIOCG80211JOIN, (caddr_t)&ifr);
+ ijoin = ioctl(sock, SIOCG80211JOIN, (caddr_t)&ifr);
memset(&nwkey, 0, sizeof(nwkey));
strlcpy(nwkey.i_name, name, sizeof(nwkey.i_name));
- inwkey = ioctl(s, SIOCG80211NWKEY, (caddr_t)&nwkey);
+ inwkey = ioctl(sock, SIOCG80211NWKEY, (caddr_t)&nwkey);
memset(&psk, 0, sizeof(psk));
strlcpy(psk.i_name, name, sizeof(psk.i_name));
- ipsk = ioctl(s, SIOCG80211WPAPSK, (caddr_t)&psk);
+ ipsk = ioctl(sock, SIOCG80211WPAPSK, (caddr_t)&psk);
memset(&power, 0, sizeof(power));
strlcpy(power.i_name, name, sizeof(power.i_name));
- ipwr = ioctl(s, SIOCG80211POWER, &power);
+ ipwr = ioctl(sock, SIOCG80211POWER, &power);
memset(&channel, 0, sizeof(channel));
strlcpy(channel.i_name, name, sizeof(channel.i_name));
- ichan = ioctl(s, SIOCG80211CHANNEL, (caddr_t)&channel);
+ ichan = ioctl(sock, SIOCG80211CHANNEL, (caddr_t)&channel);
memset(&bssid, 0, sizeof(bssid));
strlcpy(bssid.i_name, name, sizeof(bssid.i_name));
- ibssid = ioctl(s, SIOCG80211BSSID, &bssid);
+ ibssid = ioctl(sock, SIOCG80211BSSID, &bssid);
memset(&wpa, 0, sizeof(wpa));
strlcpy(wpa.i_name, name, sizeof(wpa.i_name));
- iwpa = ioctl(s, SIOCG80211WPAPARMS, &wpa);
+ iwpa = ioctl(sock, SIOCG80211WPAPARMS, &wpa);
/* check if any ieee80211 option is active */
if (inwid == 0 || ijoin == 0 || inwkey == 0 || ipsk == 0 ||
@@ -2446,7 +2453,7 @@ ieee80211_status(void)
bzero(&nr, sizeof(nr));
bcopy(bssid.i_bssid, &nr.nr_macaddr, sizeof(nr.nr_macaddr));
strlcpy(nr.nr_ifname, name, sizeof(nr.nr_ifname));
- if (ioctl(s, SIOCG80211NODE, &nr) == 0) {
+ if (ioctl(sock, SIOCG80211NODE, &nr) == 0) {
if (nr.nr_rssi) {
if (nr.nr_max_rssi)
printf(" %u%%",
@@ -2492,7 +2499,7 @@ ieee80211_status(void)
if (ipwr == 0 && power.i_enabled)
printf(" powersave on (%dms sleep)", power.i_maxsleep);
- if (ioctl(s, SIOCG80211FLAGS, (caddr_t)&ifr) == 0 &&
+ if (ioctl(sock, SIOCG80211FLAGS, (caddr_t)&ifr) == 0 &&
ifr.ifr_flags) {
putchar(' ');
printb_status(ifr.ifr_flags, IEEE80211_F_USERBITS);
@@ -2540,7 +2547,7 @@ join_status(void)
ja.ja_size = jsz * sizeof(*jn);
strlcpy(ja.ja_ifname, name, sizeof(ja.ja_ifname));
- if ((r = ioctl(s, SIOCG80211JOINALL, &ja)) != 0) {
+ if ((r = ioctl(sock, SIOCG80211JOINALL, &ja)) != 0) {
if (errno == E2BIG) {
jsz += 100;
jn = recallocarray(jn, ojsz, jsz, sizeof(*jn));
@@ -2622,7 +2629,7 @@ ieee80211_listchans(void)
ca.i_chans = chans;
strlcpy(ca.i_name, name, sizeof(ca.i_name));
- if (ioctl(s, SIOCG80211ALLCHANS, &ca) != 0) {
+ if (ioctl(sock, SIOCG80211ALLCHANS, &ca) != 0) {
warn("SIOCG80211ALLCHANS");
return;
}
@@ -2666,7 +2673,7 @@ ieee80211_listnodes(void)
bzero(&ifr, sizeof(ifr));
strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
- if (ioctl(s, SIOCS80211SCAN, (caddr_t)&ifr) != 0) {
+ if (ioctl(sock, SIOCS80211SCAN, (caddr_t)&ifr) != 0) {
if (errno == EPERM)
printf("\t\tno permission to scan\n");
return;
@@ -2678,7 +2685,7 @@ ieee80211_listnodes(void)
na.na_size = sizeof(nr);
strlcpy(na.na_ifname, name, sizeof(na.na_ifname));
- if (ioctl(s, SIOCG80211ALLNODES, &na) != 0) {
+ if (ioctl(sock, SIOCG80211ALLNODES, &na) != 0) {
warn("SIOCG80211ALLNODES");
return;
}
@@ -2726,7 +2733,7 @@ ieee80211_printnode(struct ieee80211_nodereq *nr)
if (nr->nr_pwrsave)
printf("powersave ");
- /*
+ /*
* Print our current Tx rate for associated nodes.
* Print the fastest supported rate for APs.
*/
@@ -2792,7 +2799,7 @@ init_current_media(void)
(void) memset(&ifmr, 0, sizeof(ifmr));
(void) strlcpy(ifmr.ifm_name, name, sizeof(ifmr.ifm_name));
- if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) == -1) {
+ if (ioctl(sock, SIOCGIFMEDIA, (caddr_t)&ifmr) == -1) {
/*
* If we get E2BIG, the kernel is telling us
* that there are more, so we can ignore it.
@@ -2828,7 +2835,7 @@ process_media_commands(void)
(void) strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
ifr.ifr_media = media_current;
- if (ioctl(s, SIOCSIFMEDIA, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSIFMEDIA, (caddr_t)&ifr) == -1)
err(1, "SIOCSIFMEDIA");
}
@@ -3199,7 +3206,7 @@ phys_status(int force)
memset(&req, 0, sizeof(req));
(void) strlcpy(req.iflr_name, name, sizeof(req.iflr_name));
- if (ioctl(s, SIOCGLIFPHYADDR, (caddr_t)&req) == -1) {
+ if (ioctl(sock, SIOCGLIFPHYADDR, (caddr_t)&req) == -1) {
if (errno != EADDRNOTAVAIL)
return;
@@ -3209,21 +3216,21 @@ phys_status(int force)
printf("\ttunnel: ");
print_tunnel(r);
- if (ioctl(s, SIOCGLIFPHYTTL, (caddr_t)&ifr) == 0) {
+ if (ioctl(sock, SIOCGLIFPHYTTL, (caddr_t)&ifr) == 0) {
if (ifr.ifr_ttl == -1)
printf(" ttl copy");
else if (ifr.ifr_ttl > 0)
printf(" ttl %d", ifr.ifr_ttl);
}
- if (ioctl(s, SIOCGLIFPHYDF, (caddr_t)&ifr) == 0)
+ if (ioctl(sock, SIOCGLIFPHYDF, (caddr_t)&ifr) == 0)
printf(" %s", ifr.ifr_df ? "df" : "nodf");
#ifndef SMALL
- if (ioctl(s, SIOCGLIFPHYECN, (caddr_t)&ifr) == 0)
+ if (ioctl(sock, SIOCGLIFPHYECN, (caddr_t)&ifr) == 0)
printf(" %s", ifr.ifr_metric ? "ecn" : "noecn");
- if (ioctl(s, SIOCGLIFPHYRTABLE, (caddr_t)&ifr) == 0 &&
+ if (ioctl(sock, SIOCGLIFPHYRTABLE, (caddr_t)&ifr) == 0 &&
(rdomainid != 0 || ifr.ifr_rdomainid != 0))
printf(" rdomain %d", ifr.ifr_rdomainid);
#endif
@@ -3297,7 +3304,7 @@ status(int link, struct sockaddr_dl *sdl, int ls)
(void) memset(&ifrdesc, 0, sizeof(ifrdesc));
(void) strlcpy(ifrdesc.ifr_name, name, sizeof(ifrdesc.ifr_name));
ifrdesc.ifr_data = (caddr_t)&ifdescr;
- if (ioctl(s, SIOCGIFDESCR, &ifrdesc) == 0 &&
+ if (ioctl(sock, SIOCGIFDESCR, &ifrdesc) == 0 &&
strlen(ifrdesc.ifr_data))
printf("\tdescription: %s\n", ifrdesc.ifr_data);
@@ -3305,7 +3312,7 @@ status(int link, struct sockaddr_dl *sdl, int ls)
printf("%cindex %u", sep, sdl->sdl_index);
sep = ' ';
}
- if (!is_bridge(name) && ioctl(s, SIOCGIFPRIORITY, &ifrdesc) == 0) {
+ if (!is_bridge(name) && ioctl(sock, SIOCGIFPRIORITY, &ifrdesc) == 0) {
printf("%cpriority %d", sep, ifrdesc.ifr_metric);
sep = ' ';
}
@@ -3315,11 +3322,11 @@ status(int link, struct sockaddr_dl *sdl, int ls)
#ifndef SMALL
(void) memset(&ikardesc, 0, sizeof(ikardesc));
(void) strlcpy(ikardesc.ikar_name, name, sizeof(ikardesc.ikar_name));
- if (ioctl(s, SIOCGETKALIVE, &ikardesc) == 0 &&
+ if (ioctl(sock, SIOCGETKALIVE, &ikardesc) == 0 &&
(ikardesc.ikar_timeo != 0 || ikardesc.ikar_cnt != 0))
printf("\tkeepalive: timeout %d count %d\n",
ikardesc.ikar_timeo, ikardesc.ikar_cnt);
- if (ioctl(s, SIOCGIFPAIR, &ifrdesc) == 0 && ifrdesc.ifr_index != 0 &&
+ if (ioctl(sock, SIOCGIFPAIR, &ifrdesc) == 0 && ifrdesc.ifr_index != 0 &&
if_indextoname(ifrdesc.ifr_index, ifname) != NULL)
printf("\tpatch: %s\n", ifname);
#endif
@@ -3339,7 +3346,7 @@ status(int link, struct sockaddr_dl *sdl, int ls)
(void) memset(&ifmr, 0, sizeof(ifmr));
(void) strlcpy(ifmr.ifm_name, name, sizeof(ifmr.ifm_name));
- if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) == -1) {
+ if (ioctl(sock, SIOCGIFMEDIA, (caddr_t)&ifmr) == -1) {
/*
* Interface doesn't support SIOC{G,S}IFMEDIA.
*/
@@ -3359,7 +3366,7 @@ status(int link, struct sockaddr_dl *sdl, int ls)
err(1, "calloc");
ifmr.ifm_ulist = media_list;
- if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) == -1)
+ if (ioctl(sock, SIOCGIFMEDIA, (caddr_t)&ifmr) == -1)
err(1, "SIOCGIFMEDIA");
printf("\tmedia: ");
@@ -3407,7 +3414,7 @@ status(int link, struct sockaddr_dl *sdl, int ls)
}
if (showtransceiver) {
- if (if_sff_info(s, name, 0) == -1)
+ if (if_sff_info(name, 0) == -1)
if (!aflag && errno != EPERM && errno != ENOTTY)
warn("%s transceiver", name);
}
@@ -3470,7 +3477,7 @@ in_status(int force)
struct sockaddr_in *sin, sin2;
getsock(AF_INET);
- if (s == -1) {
+ if (sock == -1) {
if (errno == EPROTONOSUPPORT)
return;
err(1, "socket");
@@ -3488,7 +3495,7 @@ in_status(int force)
printf("\tinet %s", inet_ntoa(sin->sin_addr));
(void) strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
- if (ioctl(s, SIOCGIFNETMASK, (caddr_t)&ifr) == -1) {
+ if (ioctl(sock, SIOCGIFNETMASK, (caddr_t)&ifr) == -1) {
if (errno != EADDRNOTAVAIL)
warn("SIOCGIFNETMASK");
memset(&ifr.ifr_addr, 0, sizeof(ifr.ifr_addr));
@@ -3497,7 +3504,7 @@ in_status(int force)
((struct sockaddr_in *)&ifr.ifr_addr)->sin_addr;
if (flags & IFF_POINTOPOINT) {
memcpy(&ifr.ifr_addr, &sin2, sizeof(sin2));
- if (ioctl(s, SIOCGIFDSTADDR, (caddr_t)&ifr) == -1) {
+ if (ioctl(sock, SIOCGIFDSTADDR, (caddr_t)&ifr) == -1) {
if (errno == EADDRNOTAVAIL)
memset(&ifr.ifr_addr, 0, sizeof(ifr.ifr_addr));
else
@@ -3510,7 +3517,7 @@ in_status(int force)
printf(" netmask 0x%x", ntohl(netmask.sin_addr.s_addr));
if (flags & IFF_BROADCAST) {
memcpy(&ifr.ifr_addr, &sin2, sizeof(sin2));
- if (ioctl(s, SIOCGIFBRDADDR, (caddr_t)&ifr) == -1) {
+ if (ioctl(sock, SIOCGIFBRDADDR, (caddr_t)&ifr) == -1) {
if (errno == EADDRNOTAVAIL)
memset(&ifr.ifr_addr, 0, sizeof(ifr.ifr_addr));
else
@@ -3557,7 +3564,7 @@ in6_alias(struct in6_ifreq *creq)
/* Get the non-alias address for this interface. */
getsock(AF_INET6);
- if (s == -1) {
+ if (sock == -1) {
if (errno == EPROTONOSUPPORT)
return;
err(1, "socket");
@@ -3576,7 +3583,7 @@ in6_alias(struct in6_ifreq *creq)
(void) memset(&ifr6, 0, sizeof(ifr6));
(void) strlcpy(ifr6.ifr_name, name, sizeof(ifr6.ifr_name));
ifr6.ifr_addr = creq->ifr_addr;
- if (ioctl(s, SIOCGIFDSTADDR_IN6, (caddr_t)&ifr6) == -1) {
+ if (ioctl(sock, SIOCGIFDSTADDR_IN6, (caddr_t)&ifr6) == -1) {
if (errno != EADDRNOTAVAIL)
warn("SIOCGIFDSTADDR_IN6");
(void) memset(&ifr6.ifr_addr, 0, sizeof(ifr6.ifr_addr));
@@ -3594,7 +3601,7 @@ in6_alias(struct in6_ifreq *creq)
(void) memset(&ifr6, 0, sizeof(ifr6));
(void) strlcpy(ifr6.ifr_name, name, sizeof(ifr6.ifr_name));
ifr6.ifr_addr = creq->ifr_addr;
- if (ioctl(s, SIOCGIFNETMASK_IN6, (caddr_t)&ifr6) == -1) {
+ if (ioctl(sock, SIOCGIFNETMASK_IN6, (caddr_t)&ifr6) == -1) {
if (errno != EADDRNOTAVAIL)
warn("SIOCGIFNETMASK_IN6");
} else {
@@ -3606,7 +3613,7 @@ in6_alias(struct in6_ifreq *creq)
(void) memset(&ifr6, 0, sizeof(ifr6));
(void) strlcpy(ifr6.ifr_name, name, sizeof(ifr6.ifr_name));
ifr6.ifr_addr = creq->ifr_addr;
- if (ioctl(s, SIOCGIFAFLAG_IN6, (caddr_t)&ifr6) == -1) {
+ if (ioctl(sock, SIOCGIFAFLAG_IN6, (caddr_t)&ifr6) == -1) {
if (errno != EADDRNOTAVAIL)
warn("SIOCGIFAFLAG_IN6");
} else {
@@ -3636,7 +3643,7 @@ in6_alias(struct in6_ifreq *creq)
(void) strlcpy(ifr6.ifr_name, name, sizeof(ifr6.ifr_name));
ifr6.ifr_addr = creq->ifr_addr;
lifetime = &ifr6.ifr_ifru.ifru_lifetime;
- if (ioctl(s, SIOCGIFALIFETIME_IN6, (caddr_t)&ifr6) == -1) {
+ if (ioctl(sock, SIOCGIFALIFETIME_IN6, (caddr_t)&ifr6) == -1) {
if (errno != EADDRNOTAVAIL)
warn("SIOCGIFALIFETIME_IN6");
} else if (lifetime->ia6t_preferred || lifetime->ia6t_expire) {
@@ -3707,7 +3714,7 @@ settunnel(const char *src, const char *dst)
(void) strlcpy(req.iflr_name, name, sizeof(req.iflr_name));
memcpy(&req.addr, srcres->ai_addr, srcres->ai_addrlen);
memcpy(&req.dstaddr, dstres->ai_addr, dstres->ai_addrlen);
- if (ioctl(s, SIOCSLIFPHYADDR, &req) == -1)
+ if (ioctl(sock, SIOCSLIFPHYADDR, &req) == -1)
warn("SIOCSLIFPHYADDR");
freeaddrinfo(srcres);
@@ -3742,7 +3749,7 @@ settunneladdr(const char *addr, int ignored)
req.dstaddr.ss_len = 2;
req.dstaddr.ss_family = AF_UNSPEC;
- if (ioctl(s, SIOCSLIFPHYADDR, &req) == -1)
+ if (ioctl(sock, SIOCSLIFPHYADDR, &req) == -1)
warn("tunneladdr %s", addr);
freeaddrinfo(res);
@@ -3752,7 +3759,7 @@ settunneladdr(const char *addr, int ignored)
void
deletetunnel(const char *ignored, int alsoignored)
{
- if (ioctl(s, SIOCDIFPHYADDR, &ifr) == -1)
+ if (ioctl(sock, SIOCDIFPHYADDR, &ifr) == -1)
warn("SIOCDIFPHYADDR");
}
@@ -3768,7 +3775,7 @@ settunnelinst(const char *id, int param)
strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
ifr.ifr_rdomainid = rdomainid;
- if (ioctl(s, SIOCSLIFPHYRTABLE, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSLIFPHYRTABLE, (caddr_t)&ifr) == -1)
warn("SIOCSLIFPHYRTABLE");
}
@@ -3777,7 +3784,7 @@ unsettunnelinst(const char *ignored, int alsoignored)
{
strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
ifr.ifr_rdomainid = 0;
- if (ioctl(s, SIOCSLIFPHYRTABLE, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSLIFPHYRTABLE, (caddr_t)&ifr) == -1)
warn("SIOCSLIFPHYRTABLE");
}
@@ -3797,7 +3804,7 @@ settunnelttl(const char *id, int param)
strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
ifr.ifr_ttl = ttl;
- if (ioctl(s, SIOCSLIFPHYTTL, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSLIFPHYTTL, (caddr_t)&ifr) == -1)
warn("SIOCSLIFPHYTTL");
}
@@ -3806,7 +3813,7 @@ settunneldf(const char *ignored, int alsoignored)
{
strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
ifr.ifr_df = 1;
- if (ioctl(s, SIOCSLIFPHYDF, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSLIFPHYDF, (caddr_t)&ifr) == -1)
warn("SIOCSLIFPHYDF");
}
@@ -3815,7 +3822,7 @@ settunnelnodf(const char *ignored, int alsoignored)
{
strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
ifr.ifr_df = 0;
- if (ioctl(s, SIOCSLIFPHYDF, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSLIFPHYDF, (caddr_t)&ifr) == -1)
warn("SIOCSLIFPHYDF");
}
@@ -3824,7 +3831,7 @@ settunnelecn(const char *ignored, int alsoignored)
{
strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
ifr.ifr_metric = 1;
- if (ioctl(s, SIOCSLIFPHYECN, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSLIFPHYECN, (caddr_t)&ifr) == -1)
warn("SIOCSLIFPHYECN");
}
@@ -3833,7 +3840,7 @@ settunnelnoecn(const char *ignored, int alsoignored)
{
strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
ifr.ifr_metric = 0;
- if (ioctl(s, SIOCSLIFPHYECN, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSLIFPHYECN, (caddr_t)&ifr) == -1)
warn("SIOCSLIFPHYECN");
}
@@ -3845,7 +3852,7 @@ setvnetflowid(const char *ignored, int alsoignored)
errx(1, "vnetflowid: name is too long");
ifr.ifr_vnetid = 1;
- if (ioctl(s, SIOCSVNETFLOWID, &ifr) == -1)
+ if (ioctl(sock, SIOCSVNETFLOWID, &ifr) == -1)
warn("SIOCSVNETFLOWID");
}
@@ -3857,11 +3864,11 @@ delvnetflowid(const char *ignored, int alsoignored)
errx(1, "vnetflowid: name is too long");
ifr.ifr_vnetid = 0;
- if (ioctl(s, SIOCSVNETFLOWID, &ifr) == -1)
+ if (ioctl(sock, SIOCSVNETFLOWID, &ifr) == -1)
warn("SIOCSVNETFLOWID");
}
-void
+static void
pwe3_neighbor(void)
{
const char *prefix = "pwe3 remote label";
@@ -3875,7 +3882,7 @@ pwe3_neighbor(void)
sizeof(req.iflr_name))
errx(1, "pwe3 neighbor: name is too long");
- if (ioctl(s, SIOCGPWE3NEIGHBOR, &req) == -1) {
+ if (ioctl(sock, SIOCGPWE3NEIGHBOR, &req) == -1) {
if (errno != EADDRNOTAVAIL)
return;
@@ -3899,7 +3906,7 @@ pwe3_neighbor(void)
printf(" %s %u on %s", prefix, smpls->smpls_label, hbuf);
}
-void
+static void
pwe3_cword(void)
{
struct ifreq req;
@@ -3909,14 +3916,14 @@ pwe3_cword(void)
sizeof(req.ifr_name))
errx(1, "pwe3 control word: name is too long");
- if (ioctl(s, SIOCGPWE3CTRLWORD, &req) == -1) {
+ if (ioctl(sock, SIOCGPWE3CTRLWORD, &req) == -1) {
return;
}
printf(" %s", req.ifr_pwe3 ? "cw" : "nocw");
}
-void
+static void
pwe3_fword(void)
{
struct ifreq req;
@@ -3926,7 +3933,7 @@ pwe3_fword(void)
sizeof(req.ifr_name))
errx(1, "pwe3 control word: name is too long");
- if (ioctl(s, SIOCGPWE3FAT, &req) == -1)
+ if (ioctl(sock, SIOCGPWE3FAT, &req) == -1)
return;
printf(" %s", req.ifr_pwe3 ? "fat" : "nofat");
@@ -3940,7 +3947,7 @@ mpls_status(void)
bzero(&shim, sizeof(shim));
ifr.ifr_data = (caddr_t)&shim;
- if (ioctl(s, SIOCGETLABEL, (caddr_t)&ifr) == -1) {
+ if (ioctl(sock, SIOCGETLABEL, (caddr_t)&ifr) == -1) {
if (errno != EADDRNOTAVAIL)
return;
@@ -3968,7 +3975,7 @@ setmplslabel(const char *val, int d)
if (estr)
errx(1, "mpls label %s is %s", val, estr);
- if (ioctl(s, SIOCSETLABEL, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSETLABEL, (caddr_t)&ifr) == -1)
warn("SIOCSETLABEL");
}
@@ -3982,11 +3989,11 @@ unsetmplslabel(const char *val, int d)
sizeof(req.ifr_name))
errx(1, "interface name is too long");
- if (ioctl(s, SIOCDELLABEL, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCDELLABEL, (caddr_t)&ifr) == -1)
warn("-mplslabel");
}
-void
+static void
setpwe3(unsigned long cmd, const char *cmdname, int value)
{
struct ifreq req;
@@ -3998,7 +4005,7 @@ setpwe3(unsigned long cmd, const char *cmdname, int value)
req.ifr_pwe3 = value;
- if (ioctl(s, cmd, &req) == -1)
+ if (ioctl(sock, cmd, &req) == -1)
warn("%s", cmdname);
}
@@ -4062,7 +4069,7 @@ setpwe3neighbor(const char *label, const char *neighbor)
freeaddrinfo(res);
- if (ioctl(s, SIOCSPWE3NEIGHBOR, &req) == -1)
+ if (ioctl(sock, SIOCSPWE3NEIGHBOR, &req) == -1)
warn("pweneighbor");
}
@@ -4076,7 +4083,7 @@ unsetpwe3neighbor(const char *val, int d)
sizeof(req.ifr_name))
errx(1, "interface name is too long");
- if (ioctl(s, SIOCDPWE3NEIGHBOR, &req) == -1)
+ if (ioctl(sock, SIOCDPWE3NEIGHBOR, &req) == -1)
warn("-pweneighbor");
}
@@ -4089,7 +4096,7 @@ transceiver(const char *value, int d)
void
transceiverdump(const char *value, int d)
{
- if (if_sff_info(s, name, 1) == -1)
+ if (if_sff_info(name, 1) == -1)
err(1, "%s transceiver", name);
}
#endif /* SMALL */
@@ -4101,7 +4108,7 @@ getvnetflowid(struct ifencap *ife)
sizeof(ifr.ifr_name))
errx(1, "vnetflowid: name is too long");
- if (ioctl(s, SIOCGVNETFLOWID, &ifr) == -1)
+ if (ioctl(sock, SIOCGVNETFLOWID, &ifr) == -1)
return;
if (ifr.ifr_vnetid)
@@ -4125,7 +4132,7 @@ setvnetid(const char *id, int param)
}
ifr.ifr_vnetid = vnetid;
- if (ioctl(s, SIOCSVNETID, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSVNETID, (caddr_t)&ifr) == -1)
warn("SIOCSVNETID");
}
@@ -4133,7 +4140,7 @@ setvnetid(const char *id, int param)
void
delvnetid(const char *ignored, int alsoignored)
{
- if (ioctl(s, SIOCDVNETID, &ifr) == -1)
+ if (ioctl(sock, SIOCDVNETID, &ifr) == -1)
warn("SIOCDVNETID");
}
@@ -4144,7 +4151,7 @@ getvnetid(struct ifencap *ife)
sizeof(ifr.ifr_name))
errx(1, "vnetid: name is too long");
- if (ioctl(s, SIOCGVNETID, &ifr) == -1) {
+ if (ioctl(sock, SIOCGVNETID, &ifr) == -1) {
if (errno != EADDRNOTAVAIL)
return;
@@ -4174,7 +4181,7 @@ setifparent(const char *id, int param)
sizeof(ifp.ifp_parent))
errx(1, "parent: parent too long");
- if (ioctl(s, SIOCSIFPARENT, (caddr_t)&ifp) == -1)
+ if (ioctl(sock, SIOCSIFPARENT, (caddr_t)&ifp) == -1)
warn("SIOCSIFPARENT");
}
@@ -4182,7 +4189,7 @@ setifparent(const char *id, int param)
void
delifparent(const char *ignored, int alsoignored)
{
- if (ioctl(s, SIOCDIFPARENT, &ifr) == -1)
+ if (ioctl(sock, SIOCDIFPARENT, &ifr) == -1)
warn("SIOCDIFPARENT");
}
@@ -4196,7 +4203,7 @@ getifparent(struct ifencap *ife)
sizeof(ifp.ifp_name))
errx(1, "parent: name too long");
- if (ioctl(s, SIOCGIFPARENT, (caddr_t)&ifp) == -1) {
+ if (ioctl(sock, SIOCGIFPARENT, (caddr_t)&ifp) == -1) {
if (errno != EADDRNOTAVAIL)
return;
@@ -4216,7 +4223,7 @@ gettxprio(struct ifencap *ife)
sizeof(ifr.ifr_name))
errx(1, "hdr prio: name is too long");
- if (ioctl(s, SIOCGTXHPRIO, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGTXHPRIO, (caddr_t)&ifr) == -1)
return;
ife->ife_flags |= IFE_TXHPRIO_SET;
@@ -4243,7 +4250,7 @@ settxprio(const char *val, int d)
errx(1, "tx prio %s: %s", val, errmsg);
}
- if (ioctl(s, SIOCSTXHPRIO, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSTXHPRIO, (caddr_t)&ifr) == -1)
warn("SIOCSTXHPRIO");
}
@@ -4254,7 +4261,7 @@ getrxprio(struct ifencap *ife)
sizeof(ifr.ifr_name))
errx(1, "hdr prio: name is too long");
- if (ioctl(s, SIOCGRXHPRIO, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGRXHPRIO, (caddr_t)&ifr) == -1)
return;
ife->ife_flags |= IFE_RXHPRIO_SET;
@@ -4283,7 +4290,7 @@ setrxprio(const char *val, int d)
errx(1, "rx prio %s: %s", val, errmsg);
}
- if (ioctl(s, SIOCSRXHPRIO, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSRXHPRIO, (caddr_t)&ifr) == -1)
warn("SIOCSRXHPRIO");
}
#endif
@@ -4376,7 +4383,7 @@ settrunkport(const char *val, int d)
strlcpy(rp.rp_ifname, name, sizeof(rp.rp_ifname));
strlcpy(rp.rp_portname, val, sizeof(rp.rp_portname));
- if (ioctl(s, SIOCSTRUNKPORT, &rp) == -1)
+ if (ioctl(sock, SIOCSTRUNKPORT, &rp) == -1)
err(1, "SIOCSTRUNKPORT");
}
@@ -4389,7 +4396,7 @@ unsettrunkport(const char *val, int d)
strlcpy(rp.rp_ifname, name, sizeof(rp.rp_ifname));
strlcpy(rp.rp_portname, val, sizeof(rp.rp_portname));
- if (ioctl(s, SIOCSTRUNKDELPORT, &rp) == -1)
+ if (ioctl(sock, SIOCSTRUNKDELPORT, &rp) == -1)
err(1, "SIOCSTRUNKDELPORT");
}
@@ -4413,7 +4420,7 @@ settrunkproto(const char *val, int d)
errx(1, "Invalid trunk protocol: %s", val);
strlcpy(ra.ra_ifname, name, sizeof(ra.ra_ifname));
- if (ioctl(s, SIOCSTRUNK, &ra) != 0)
+ if (ioctl(sock, SIOCSTRUNK, &ra) != 0)
err(1, "SIOCSTRUNK");
}
@@ -4426,7 +4433,7 @@ settrunklacpmode(const char *val, int d)
bzero(&ra, sizeof(ra));
strlcpy(ra.ra_ifname, name, sizeof(ra.ra_ifname));
- if (ioctl(s, SIOCGTRUNK, &ra) != 0)
+ if (ioctl(sock, SIOCGTRUNK, &ra) != 0)
err(1, "SIOCGTRUNK");
if (ra.ra_proto != TRUNK_PROTO_LACP)
@@ -4446,7 +4453,7 @@ settrunklacpmode(const char *val, int d)
else
tops.to_lacpopts.lacp_mode = 0;
- if (ioctl(s, SIOCSTRUNKOPTS, &tops) != 0)
+ if (ioctl(sock, SIOCSTRUNKOPTS, &tops) != 0)
err(1, "SIOCSTRUNKOPTS");
}
@@ -4459,7 +4466,7 @@ settrunklacptimeout(const char *val, int d)
bzero(&ra, sizeof(ra));
strlcpy(ra.ra_ifname, name, sizeof(ra.ra_ifname));
- if (ioctl(s, SIOCGTRUNK, &ra) != 0)
+ if (ioctl(sock, SIOCGTRUNK, &ra) != 0)
err(1, "SIOCGTRUNK");
if (ra.ra_proto != TRUNK_PROTO_LACP)
@@ -4479,7 +4486,7 @@ settrunklacptimeout(const char *val, int d)
else
tops.to_lacpopts.lacp_timeout = 0;
- if (ioctl(s, SIOCSTRUNKOPTS, &tops) != 0)
+ if (ioctl(sock, SIOCSTRUNKOPTS, &tops) != 0)
err(1, "SIOCSTRUNKOPTS");
}
@@ -4499,14 +4506,14 @@ trunk_status(void)
strlcpy(rp.rp_ifname, name, sizeof(rp.rp_ifname));
strlcpy(rp.rp_portname, name, sizeof(rp.rp_portname));
- if (ioctl(s, SIOCGTRUNKPORT, &rp) == 0)
+ if (ioctl(sock, SIOCGTRUNKPORT, &rp) == 0)
isport = 1;
strlcpy(ra.ra_ifname, name, sizeof(ra.ra_ifname));
ra.ra_size = sizeof(rpbuf);
ra.ra_port = rpbuf;
- if (ioctl(s, SIOCGTRUNK, &ra) == 0) {
+ if (ioctl(sock, SIOCGTRUNK, &ra) == 0) {
lp = (struct lacp_opreq *)&ra.ra_lacpreq;
for (i = 0; i < (sizeof(tpr) / sizeof(tpr[0])); i++) {
@@ -4599,7 +4606,7 @@ carp_status(void)
memset((char *)&carpr, 0, sizeof(struct carpreq));
ifr.ifr_data = (caddr_t)&carpr;
- if (ioctl(s, SIOCGVH, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGVH, (caddr_t)&ifr) == -1)
return;
if (carpr.carpr_vhids[0] == 0)
@@ -4651,13 +4658,13 @@ setcarp_passwd(const char *val, int d)
bzero(&carpr, sizeof(struct carpreq));
ifr.ifr_data = (caddr_t)&carpr;
- if (ioctl(s, SIOCGVH, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGVH, (caddr_t)&ifr) == -1)
err(1, "SIOCGVH");
bzero(carpr.carpr_key, CARP_KEY_LEN);
strlcpy((char *)carpr.carpr_key, val, CARP_KEY_LEN);
- if (ioctl(s, SIOCSVH, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSVH, (caddr_t)&ifr) == -1)
err(1, "SIOCSVH");
}
@@ -4676,13 +4683,13 @@ setcarp_vhid(const char *val, int d)
bzero(&carpr, sizeof(struct carpreq));
ifr.ifr_data = (caddr_t)&carpr;
- if (ioctl(s, SIOCGVH, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGVH, (caddr_t)&ifr) == -1)
err(1, "SIOCGVH");
carpr.carpr_vhids[0] = vhid;
carpr.carpr_vhids[1] = 0;
- if (ioctl(s, SIOCSVH, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSVH, (caddr_t)&ifr) == -1)
err(1, "SIOCSVH");
}
@@ -4701,12 +4708,12 @@ setcarp_advskew(const char *val, int d)
bzero(&carpr, sizeof(struct carpreq));
ifr.ifr_data = (caddr_t)&carpr;
- if (ioctl(s, SIOCGVH, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGVH, (caddr_t)&ifr) == -1)
err(1, "SIOCGVH");
carpr.carpr_advskews[0] = advskew;
- if (ioctl(s, SIOCSVH, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSVH, (caddr_t)&ifr) == -1)
err(1, "SIOCSVH");
}
@@ -4725,12 +4732,12 @@ setcarp_advbase(const char *val, int d)
bzero(&carpr, sizeof(struct carpreq));
ifr.ifr_data = (caddr_t)&carpr;
- if (ioctl(s, SIOCGVH, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGVH, (caddr_t)&ifr) == -1)
err(1, "SIOCGVH");
carpr.carpr_advbase = advbase;
- if (ioctl(s, SIOCSVH, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSVH, (caddr_t)&ifr) == -1)
err(1, "SIOCSVH");
}
@@ -4745,7 +4752,7 @@ setcarppeer(const char *val, int d)
bzero(&carpr, sizeof(struct carpreq));
ifr.ifr_data = (caddr_t)&carpr;
- if (ioctl(s, SIOCGVH, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGVH, (caddr_t)&ifr) == -1)
err(1, "SIOCGVH");
bzero(&hints, sizeof(hints));
@@ -4762,7 +4769,7 @@ setcarppeer(const char *val, int d)
carpr.carpr_peer.s_addr = ((struct sockaddr_in *)
peerres->ai_addr)->sin_addr.s_addr;
- if (ioctl(s, SIOCSVH, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSVH, (caddr_t)&ifr) == -1)
err(1, "SIOCSVH");
freeaddrinfo(peerres);
@@ -4776,12 +4783,12 @@ unsetcarppeer(const char *val, int d)
bzero(&carpr, sizeof(struct carpreq));
ifr.ifr_data = (caddr_t)&carpr;
- if (ioctl(s, SIOCGVH, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGVH, (caddr_t)&ifr) == -1)
err(1, "SIOCGVH");
bzero(&carpr.carpr_peer, sizeof(carpr.carpr_peer));
- if (ioctl(s, SIOCSVH, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSVH, (caddr_t)&ifr) == -1)
err(1, "SIOCSVH");
}
@@ -4795,7 +4802,7 @@ setcarp_state(const char *val, int d)
bzero(&carpr, sizeof(struct carpreq));
ifr.ifr_data = (caddr_t)&carpr;
- if (ioctl(s, SIOCGVH, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGVH, (caddr_t)&ifr) == -1)
err(1, "SIOCGVH");
for (i = 0; i <= CARP_MAXSTATE; i++) {
@@ -4805,7 +4812,7 @@ setcarp_state(const char *val, int d)
}
}
- if (ioctl(s, SIOCSVH, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSVH, (caddr_t)&ifr) == -1)
err(1, "SIOCSVH");
}
@@ -4818,12 +4825,12 @@ setcarpdev(const char *val, int d)
bzero(&carpr, sizeof(struct carpreq));
ifr.ifr_data = (caddr_t)&carpr;
- if (ioctl(s, SIOCGVH, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGVH, (caddr_t)&ifr) == -1)
err(1, "SIOCGVH");
strlcpy(carpr.carpr_carpdev, val, sizeof(carpr.carpr_carpdev));
- if (ioctl(s, SIOCSVH, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSVH, (caddr_t)&ifr) == -1)
err(1, "SIOCSVH");
}
@@ -4837,7 +4844,7 @@ setcarp_nodes(const char *val, int d)
bzero(&carpr, sizeof(struct carpreq));
ifr.ifr_data = (caddr_t)&carpr;
- if (ioctl(s, SIOCGVH, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGVH, (caddr_t)&ifr) == -1)
err(1, "SIOCGVH");
bzero(carpr.carpr_vhids, sizeof(carpr.carpr_vhids));
@@ -4867,7 +4874,7 @@ setcarp_nodes(const char *val, int d)
}
free(optlist);
- if (ioctl(s, SIOCSVH, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSVH, (caddr_t)&ifr) == -1)
err(1, "SIOCSVH");
}
@@ -4880,7 +4887,7 @@ setcarp_balancing(const char *val, int d)
bzero(&carpr, sizeof(struct carpreq));
ifr.ifr_data = (caddr_t)&carpr;
- if (ioctl(s, SIOCGVH, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGVH, (caddr_t)&ifr) == -1)
err(1, "SIOCGVH");
for (i = 0; i <= CARP_BAL_MAXID; i++)
@@ -4892,7 +4899,7 @@ setcarp_balancing(const char *val, int d)
carpr.carpr_balancing = i;
- if (ioctl(s, SIOCSVH, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSVH, (caddr_t)&ifr) == -1)
err(1, "SIOCSVH");
}
@@ -4904,12 +4911,12 @@ setpfsync_syncdev(const char *val, int d)
bzero(&preq, sizeof(struct pfsyncreq));
ifr.ifr_data = (caddr_t)&preq;
- if (ioctl(s, SIOCGETPFSYNC, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGETPFSYNC, (caddr_t)&ifr) == -1)
err(1, "SIOCGETPFSYNC");
strlcpy(preq.pfsyncr_syncdev, val, sizeof(preq.pfsyncr_syncdev));
- if (ioctl(s, SIOCSETPFSYNC, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSETPFSYNC, (caddr_t)&ifr) == -1)
err(1, "SIOCSETPFSYNC");
}
@@ -4922,12 +4929,12 @@ unsetpfsync_syncdev(const char *val, int d)
bzero(&preq, sizeof(struct pfsyncreq));
ifr.ifr_data = (caddr_t)&preq;
- if (ioctl(s, SIOCGETPFSYNC, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGETPFSYNC, (caddr_t)&ifr) == -1)
err(1, "SIOCGETPFSYNC");
bzero(&preq.pfsyncr_syncdev, sizeof(preq.pfsyncr_syncdev));
- if (ioctl(s, SIOCSETPFSYNC, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSETPFSYNC, (caddr_t)&ifr) == -1)
err(1, "SIOCSETPFSYNC");
}
@@ -4942,7 +4949,7 @@ setpfsync_syncpeer(const char *val, int d)
bzero(&preq, sizeof(struct pfsyncreq));
ifr.ifr_data = (caddr_t)&preq;
- if (ioctl(s, SIOCGETPFSYNC, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGETPFSYNC, (caddr_t)&ifr) == -1)
err(1, "SIOCGETPFSYNC");
memset(&hints, 0, sizeof(hints));
@@ -4959,7 +4966,7 @@ setpfsync_syncpeer(const char *val, int d)
preq.pfsyncr_syncpeer.s_addr = ((struct sockaddr_in *)
peerres->ai_addr)->sin_addr.s_addr;
- if (ioctl(s, SIOCSETPFSYNC, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSETPFSYNC, (caddr_t)&ifr) == -1)
err(1, "SIOCSETPFSYNC");
freeaddrinfo(peerres);
@@ -4974,12 +4981,12 @@ unsetpfsync_syncpeer(const char *val, int d)
bzero(&preq, sizeof(struct pfsyncreq));
ifr.ifr_data = (caddr_t)&preq;
- if (ioctl(s, SIOCGETPFSYNC, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGETPFSYNC, (caddr_t)&ifr) == -1)
err(1, "SIOCGETPFSYNC");
preq.pfsyncr_syncpeer.s_addr = 0;
- if (ioctl(s, SIOCSETPFSYNC, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSETPFSYNC, (caddr_t)&ifr) == -1)
err(1, "SIOCSETPFSYNC");
}
@@ -4998,12 +5005,12 @@ setpfsync_maxupd(const char *val, int d)
bzero(&preq, sizeof(struct pfsyncreq));
ifr.ifr_data = (caddr_t)&preq;
- if (ioctl(s, SIOCGETPFSYNC, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGETPFSYNC, (caddr_t)&ifr) == -1)
err(1, "SIOCGETPFSYNC");
preq.pfsyncr_maxupdates = maxupdates;
- if (ioctl(s, SIOCSETPFSYNC, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSETPFSYNC, (caddr_t)&ifr) == -1)
err(1, "SIOCSETPFSYNC");
}
@@ -5015,11 +5022,11 @@ setpfsync_defer(const char *val, int d)
bzero(&preq, sizeof(struct pfsyncreq));
ifr.ifr_data = (caddr_t)&preq;
- if (ioctl(s, SIOCGETPFSYNC, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGETPFSYNC, (caddr_t)&ifr) == -1)
err(1, "SIOCGETPFSYNC");
preq.pfsyncr_defer = d;
- if (ioctl(s, SIOCSETPFSYNC, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSETPFSYNC, (caddr_t)&ifr) == -1)
err(1, "SIOCSETPFSYNC");
}
@@ -5031,7 +5038,7 @@ pfsync_status(void)
bzero(&preq, sizeof(struct pfsyncreq));
ifr.ifr_data = (caddr_t)&preq;
- if (ioctl(s, SIOCGETPFSYNC, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGETPFSYNC, (caddr_t)&ifr) == -1)
return;
if (preq.pfsyncr_syncdev[0] != '\0') {
@@ -5056,7 +5063,7 @@ pflow_status(void)
bzero(&preq, sizeof(struct pflowreq));
ifr.ifr_data = (caddr_t)&preq;
- if (ioctl(s, SIOCGETPFLOW, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGETPFLOW, (caddr_t)&ifr) == -1)
return;
if (preq.flowsrc.ss_family == AF_INET || preq.flowsrc.ss_family ==
@@ -5187,7 +5194,7 @@ setpflow_sender(const char *val, int d)
preq.addrmask |= PFLOW_MASK_SRCIP;
pflow_addr(val, &preq.flowsrc);
- if (ioctl(s, SIOCSETPFLOW, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSETPFLOW, (caddr_t)&ifr) == -1)
err(1, "SIOCSETPFLOW");
}
@@ -5199,7 +5206,7 @@ unsetpflow_sender(const char *val, int d)
bzero(&preq, sizeof(struct pflowreq));
preq.addrmask |= PFLOW_MASK_SRCIP;
ifr.ifr_data = (caddr_t)&preq;
- if (ioctl(s, SIOCSETPFLOW, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSETPFLOW, (caddr_t)&ifr) == -1)
err(1, "SIOCSETPFLOW");
}
@@ -5213,7 +5220,7 @@ setpflow_receiver(const char *val, int d)
preq.addrmask |= PFLOW_MASK_DSTIP;
pflow_addr(val, &preq.flowdst);
- if (ioctl(s, SIOCSETPFLOW, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSETPFLOW, (caddr_t)&ifr) == -1)
err(1, "SIOCSETPFLOW");
}
@@ -5225,7 +5232,7 @@ unsetpflow_receiver(const char *val, int d)
bzero(&preq, sizeof(struct pflowreq));
ifr.ifr_data = (caddr_t)&preq;
preq.addrmask |= PFLOW_MASK_DSTIP;
- if (ioctl(s, SIOCSETPFLOW, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSETPFLOW, (caddr_t)&ifr) == -1)
err(1, "SIOCSETPFLOW");
}
@@ -5253,7 +5260,7 @@ setpflowproto(const char *val, int d)
ifr.ifr_data = (caddr_t)&preq;
- if (ioctl(s, SIOCSETPFLOW, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSETPFLOW, (caddr_t)&ifr) == -1)
err(1, "SIOCSETPFLOW");
}
@@ -5266,7 +5273,7 @@ pppoe_status(void)
memset(&state, 0, sizeof(state));
strlcpy(parms.ifname, name, sizeof(parms.ifname));
- if (ioctl(s, PPPOEGETPARMS, &parms) == -1)
+ if (ioctl(sock, PPPOEGETPARMS, &parms) == -1)
return;
printf("\tdev: %s ", parms.eth_ifname);
@@ -5277,7 +5284,7 @@ pppoe_status(void)
printf("svc: %s ", parms.service_name);
strlcpy(state.ifname, name, sizeof(state.ifname));
- if (ioctl(s, PPPOEGETSESSION, &state) == -1)
+ if (ioctl(sock, PPPOEGETSESSION, &state) == -1)
err(1, "PPPOEGETSESSION");
printf("state: ");
@@ -5333,12 +5340,12 @@ setpppoe_dev(const char *val, int d)
struct pppoediscparms parms;
strlcpy(parms.ifname, name, sizeof(parms.ifname));
- if (ioctl(s, PPPOEGETPARMS, &parms) == -1)
+ if (ioctl(sock, PPPOEGETPARMS, &parms) == -1)
return;
strlcpy(parms.eth_ifname, val, sizeof(parms.eth_ifname));
- if (ioctl(s, PPPOESETPARMS, &parms) == -1)
+ if (ioctl(sock, PPPOESETPARMS, &parms) == -1)
err(1, "PPPOESETPARMS");
}
@@ -5349,7 +5356,7 @@ setpppoe_svc(const char *val, int d)
struct pppoediscparms parms;
strlcpy(parms.ifname, name, sizeof(parms.ifname));
- if (ioctl(s, PPPOEGETPARMS, &parms) == -1)
+ if (ioctl(sock, PPPOEGETPARMS, &parms) == -1)
return;
if (d == 0)
@@ -5357,7 +5364,7 @@ setpppoe_svc(const char *val, int d)
else
memset(parms.service_name, 0, sizeof(parms.service_name));
- if (ioctl(s, PPPOESETPARMS, &parms) == -1)
+ if (ioctl(sock, PPPOESETPARMS, &parms) == -1)
err(1, "PPPOESETPARMS");
}
@@ -5368,7 +5375,7 @@ setpppoe_ac(const char *val, int d)
struct pppoediscparms parms;
strlcpy(parms.ifname, name, sizeof(parms.ifname));
- if (ioctl(s, PPPOEGETPARMS, &parms) == -1)
+ if (ioctl(sock, PPPOEGETPARMS, &parms) == -1)
return;
if (d == 0)
@@ -5376,7 +5383,7 @@ setpppoe_ac(const char *val, int d)
else
memset(parms.ac_name, 0, sizeof(parms.ac_name));
- if (ioctl(s, PPPOESETPARMS, &parms) == -1)
+ if (ioctl(sock, PPPOESETPARMS, &parms) == -1)
err(1, "PPPOESETPARMS");
}
@@ -5387,7 +5394,7 @@ spppauthinfo(struct sauthreq *spa, int d)
ifr.ifr_data = (caddr_t)spa;
spa->cmd = d == 0 ? SPPPIOGMAUTH : SPPPIOGHAUTH;
- if (ioctl(s, SIOCGSPPPPARAMS, &ifr) == -1)
+ if (ioctl(sock, SIOCGSPPPPARAMS, &ifr) == -1)
err(1, "SIOCGSPPPPARAMS(SPPPIOGXAUTH)");
}
@@ -5408,7 +5415,7 @@ setspppproto(const char *val, int d)
errx(1, "setpppproto");
spa.cmd = d == 0 ? SPPPIOSMAUTH : SPPPIOSHAUTH;
- if (ioctl(s, SIOCSSPPPPARAMS, &ifr) == -1)
+ if (ioctl(sock, SIOCSSPPPPARAMS, &ifr) == -1)
err(1, "SIOCSSPPPPARAMS(SPPPIOSXAUTH)");
}
@@ -5431,7 +5438,7 @@ setspppname(const char *val, int d)
errx(1, "setspppname");
spa.cmd = d == 0 ? SPPPIOSMAUTH : SPPPIOSHAUTH;
- if (ioctl(s, SIOCSSPPPPARAMS, &ifr) == -1)
+ if (ioctl(sock, SIOCSSPPPPARAMS, &ifr) == -1)
err(1, "SIOCSSPPPPARAMS(SPPPIOSXAUTH)");
}
@@ -5454,7 +5461,7 @@ setspppkey(const char *val, int d)
errx(1, "setspppkey");
spa.cmd = d == 0 ? SPPPIOSMAUTH : SPPPIOSHAUTH;
- if (ioctl(s, SIOCSSPPPPARAMS, &ifr) == -1)
+ if (ioctl(sock, SIOCSSPPPPARAMS, &ifr) == -1)
err(1, "SIOCSSPPPPARAMS(SPPPIOSXAUTH)");
}
@@ -5487,7 +5494,7 @@ setsppppeerflag(const char *val, int d)
spa.flags |= flag;
spa.cmd = SPPPIOSHAUTH;
- if (ioctl(s, SIOCSSPPPPARAMS, &ifr) == -1)
+ if (ioctl(sock, SIOCSSPPPPARAMS, &ifr) == -1)
err(1, "SIOCSSPPPPARAMS(SPPPIOSXAUTH)");
}
@@ -5530,7 +5537,7 @@ sppp_status(void)
ifr.ifr_data = (caddr_t)&spr;
spr.cmd = SPPPIOGDEFS;
- if (ioctl(s, SIOCGSPPPPARAMS, &ifr) == -1) {
+ if (ioctl(sock, SIOCGSPPPPARAMS, &ifr) == -1) {
return;
}
@@ -5583,7 +5590,7 @@ setkeepalive(const char *timeout, const char *count)
strlcpy(ikar.ikar_name, name, sizeof(ikar.ikar_name));
ikar.ikar_timeo = t;
ikar.ikar_cnt = c;
- if (ioctl(s, SIOCSETKALIVE, (caddr_t)&ikar) == -1)
+ if (ioctl(sock, SIOCSETKALIVE, (caddr_t)&ikar) == -1)
warn("SIOCSETKALIVE");
}
@@ -5594,7 +5601,7 @@ unsetkeepalive(const char *val, int d)
bzero(&ikar, sizeof(ikar));
strlcpy(ikar.ikar_name, name, sizeof(ikar.ikar_name));
- if (ioctl(s, SIOCSETKALIVE, (caddr_t)&ikar) == -1)
+ if (ioctl(sock, SIOCSETKALIVE, (caddr_t)&ikar) == -1)
warn("SIOCSETKALIVE");
}
@@ -5610,7 +5617,7 @@ setifpriority(const char *id, int param)
strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
ifr.ifr_metric = prio;
- if (ioctl(s, SIOCSIFPRIORITY, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSIFPRIORITY, (caddr_t)&ifr) == -1)
warn("SIOCSIFPRIORITY");
}
@@ -5630,7 +5637,7 @@ const struct umb_valdescr umb_classalias[] = {
{ 0, NULL }
};
-int
+static int
umb_descr2val(const struct umb_valdescr *vdp, char *str)
{
while (vdp->descr != NULL) {
@@ -5658,7 +5665,7 @@ umb_status(void)
memset((char *)&mi, 0, sizeof(mi));
ifr.ifr_data = (caddr_t)&mi;
- if (ioctl(s, SIOCGUMBINFO, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGUMBINFO, (caddr_t)&ifr) == -1)
return;
if (mi.nwerror) {
@@ -5887,7 +5894,7 @@ umb_pinop(int op, int is_puk, const char *pin, const char *newpin)
memset(&mp, 0, sizeof (mp));
ifr.ifr_data = (caddr_t)&mp;
- if (ioctl(s, SIOCGUMBPARAM, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGUMBPARAM, (caddr_t)&ifr) == -1)
err(1, "SIOCGUMBPARAM");
mp.op = op;
@@ -5902,7 +5909,7 @@ umb_pinop(int op, int is_puk, const char *pin, const char *newpin)
errx(1, "new PIN too long");
}
- if (ioctl(s, SIOCSUMBPARAM, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSUMBPARAM, (caddr_t)&ifr) == -1)
err(1, "SIOCSUMBPARAM");
}
@@ -5913,7 +5920,7 @@ umb_apn(const char *apn, int d)
memset(&mp, 0, sizeof (mp));
ifr.ifr_data = (caddr_t)&mp;
- if (ioctl(s, SIOCGUMBPARAM, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGUMBPARAM, (caddr_t)&ifr) == -1)
err(1, "SIOCGUMBPARAM");
if (d != 0)
@@ -5922,7 +5929,7 @@ umb_apn(const char *apn, int d)
sizeof (mp.apn))) == -1)
errx(1, "APN too long");
- if (ioctl(s, SIOCSUMBPARAM, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSUMBPARAM, (caddr_t)&ifr) == -1)
err(1, "SIOCSUMBPARAM");
}
@@ -5940,13 +5947,13 @@ umb_setclass(const char *val, int d)
memset(&mp, 0, sizeof (mp));
ifr.ifr_data = (caddr_t)&mp;
- if (ioctl(s, SIOCGUMBPARAM, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGUMBPARAM, (caddr_t)&ifr) == -1)
err(1, "SIOCGUMBPARAM");
if (d != -1)
mp.preferredclasses = umb_parse_classes(val);
else
mp.preferredclasses = MBIM_DATACLASS_NONE;
- if (ioctl(s, SIOCSUMBPARAM, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSUMBPARAM, (caddr_t)&ifr) == -1)
err(1, "SIOCSUMBPARAM");
}
@@ -5957,10 +5964,10 @@ umb_roaming(const char *val, int d)
memset(&mp, 0, sizeof (mp));
ifr.ifr_data = (caddr_t)&mp;
- if (ioctl(s, SIOCGUMBPARAM, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGUMBPARAM, (caddr_t)&ifr) == -1)
err(1, "SIOCGUMBPARAM");
mp.roaming = d;
- if (ioctl(s, SIOCSUMBPARAM, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSUMBPARAM, (caddr_t)&ifr) == -1)
err(1, "SIOCSUMBPARAM");
}
@@ -6245,7 +6252,7 @@ getifgroups(void)
memset(&ifgr, 0, sizeof(ifgr));
strlcpy(ifgr.ifgr_name, name, IFNAMSIZ);
- if (ioctl(s, SIOCGIFGROUP, (caddr_t)&ifgr) == -1) {
+ if (ioctl(sock, SIOCGIFGROUP, (caddr_t)&ifgr) == -1) {
if (errno == EINVAL || errno == ENOTTY)
return;
else
@@ -6257,7 +6264,7 @@ getifgroups(void)
sizeof(struct ifg_req));
if (ifgr.ifgr_groups == NULL)
err(1, "getifgroups");
- if (ioctl(s, SIOCGIFGROUP, (caddr_t)&ifgr) == -1)
+ if (ioctl(sock, SIOCGIFGROUP, (caddr_t)&ifgr) == -1)
err(1, "SIOCGIFGROUP");
cnt = 0;
@@ -6291,11 +6298,11 @@ printifhwfeatures(const char *unused, int show)
}
bzero(&ifrdat, sizeof(ifrdat));
ifr.ifr_data = (caddr_t)&ifrdat;
- if (ioctl(s, SIOCGIFDATA, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCGIFDATA, (caddr_t)&ifr) == -1)
err(1, "SIOCGIFDATA");
printb("\thwfeatures", (u_int)ifrdat.ifi_capabilities, HWFEATURESBITS);
- if (ioctl(s, SIOCGIFHARDMTU, (caddr_t)&ifr) != -1) {
+ if (ioctl(sock, SIOCGIFHARDMTU, (caddr_t)&ifr) != -1) {
if (ifr.ifr_hardmtu)
printf(" hardmtu %u", ifr.ifr_hardmtu);
}
@@ -6336,7 +6343,7 @@ setiflladdr(const char *addr, int param)
ifr.ifr_addr.sa_len = ETHER_ADDR_LEN;
ifr.ifr_addr.sa_family = AF_LINK;
bcopy(eap, ifr.ifr_addr.sa_data, ETHER_ADDR_LEN);
- if (ioctl(s, SIOCSIFLLADDR, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSIFLLADDR, (caddr_t)&ifr) == -1)
warn("SIOCSIFLLADDR");
}
@@ -6353,7 +6360,7 @@ setrdomain(const char *id, int param)
strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
ifr.ifr_rdomainid = rdomainid;
- if (ioctl(s, SIOCSIFRDOMAIN, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSIFRDOMAIN, (caddr_t)&ifr) == -1)
warn("SIOCSIFRDOMAIN");
}
@@ -6362,7 +6369,7 @@ unsetrdomain(const char *ignored, int alsoignored)
{
strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
ifr.ifr_rdomainid = 0;
- if (ioctl(s, SIOCSIFRDOMAIN, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSIFRDOMAIN, (caddr_t)&ifr) == -1)
warn("SIOCSIFRDOMAIN");
}
#endif
@@ -6376,7 +6383,7 @@ setpair(const char *val, int d)
errno = ENOENT;
err(1, "patch %s", val);
}
- if (ioctl(s, SIOCSIFPAIR, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSIFPAIR, (caddr_t)&ifr) == -1)
warn("SIOCSIFPAIR");
}
@@ -6385,7 +6392,7 @@ unsetpair(const char *val, int d)
{
ifr.ifr_index = 0;
strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name));
- if (ioctl(s, SIOCSIFPAIR, (caddr_t)&ifr) == -1)
+ if (ioctl(sock, SIOCSIFPAIR, (caddr_t)&ifr) == -1)
warn("SIOCSIFPAIR");
}
#endif
diff --git a/sbin/ifconfig/brconfig.h b/sbin/ifconfig/ifconfig.h
index 6cf643a7d84..33b147f4515 100644
--- a/sbin/ifconfig/brconfig.h
+++ b/sbin/ifconfig/ifconfig.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: brconfig.h,v 1.15 2019/07/25 13:56:23 krw Exp $ */
+/* $OpenBSD: ifconfig.h,v 1.1 2019/10/17 18:37:38 bluhm Exp $ */
/*
* Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
@@ -18,9 +18,11 @@
extern int aflag;
extern int ifaliases;
-extern int s;
+extern int sock;
extern char name[IFNAMSIZ];
+void printb(char *, unsigned int, unsigned char *);
+
void setdiscover(const char *, int);
void unsetdiscover(const char *, int);
void setblocknonip(const char *, int);
@@ -71,12 +73,4 @@ void switch_status(void);
void switch_datapathid(const char *, int);
void switch_portno(const char *, const char *);
-#define IFFBITS \
- "\024\1UP\2BROADCAST\3DEBUG\4LOOPBACK\5POINTOPOINT\6STATICARP" \
- "\7RUNNING\10NOARP\11PROMISC\12ALLMULTI\13OACTIVE\14SIMPLEX" \
- "\15LINK0\16LINK1\17LINK2\20MULTICAST" \
- "\23INET6_NOPRIVACY\24MPLS\25WOL\26AUTOCONF6\27INET6_NOSOII" \
- "\30AUTOCONF4"
-
-void printb(char *, unsigned int, unsigned char *);
-
+int if_sff_info(const char *, int);
diff --git a/sbin/ifconfig/sff.c b/sbin/ifconfig/sff.c
index 7a4ff4e4e54..35859d15280 100644
--- a/sbin/ifconfig/sff.c
+++ b/sbin/ifconfig/sff.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sff.c,v 1.21 2019/08/30 03:52:21 deraadt Exp $ */
+/* $OpenBSD: sff.c,v 1.22 2019/10/17 18:37:38 bluhm Exp $ */
/*
* Copyright (c) 2019 David Gwynne <dlg@openbsd.org>
@@ -34,6 +34,8 @@
#include <limits.h>
#include <vis.h>
+#include "ifconfig.h"
+
#ifndef nitems
#define nitems(_a) (sizeof((_a)) / sizeof((_a)[0]))
#endif
@@ -344,9 +346,9 @@ static const struct sff_media_map upper_media_map = {
};
static void hexdump(const void *, size_t);
-static int if_sff8472(int, const char *, int, const struct if_sffpage *);
-static int if_sff8636(int, const char *, int, const struct if_sffpage *);
-static int if_inf8077(int, const char *, int, const struct if_sffpage *);
+static int if_sff8472(const char *, int, const struct if_sffpage *);
+static int if_sff8636(const char *, int, const struct if_sffpage *);
+static int if_inf8077(const char *, int, const struct if_sffpage *);
static const char *
sff_id_name(uint8_t id)
@@ -407,18 +409,18 @@ if_sffpage_dump(const char *ifname, const struct if_sffpage *sff)
}
int
-if_sff_info(int s, const char *ifname, int dump)
+if_sff_info(const char *ifname, int dump)
{
struct if_sffpage pg0;
int error = 0;
uint8_t id, ext_id;
if_sffpage_init(&pg0, ifname, IFSFF_ADDR_EEPROM, 0);
- if (ioctl(s, SIOCGIFSFFPAGE, (caddr_t)&pg0) == -1) {
+ if (ioctl(sock, SIOCGIFSFFPAGE, (caddr_t)&pg0) == -1) {
if (errno == ENXIO) {
/* try 1 for XFP cos myx which can't switch pages... */
if_sffpage_init(&pg0, ifname, IFSFF_ADDR_EEPROM, 1);
- if (ioctl(s, SIOCGIFSFFPAGE, (caddr_t)&pg0) == -1)
+ if (ioctl(sock, SIOCGIFSFFPAGE, (caddr_t)&pg0) == -1)
return (-1);
} else
return (-1);
@@ -439,22 +441,22 @@ if_sff_info(int s, const char *ifname, int dump)
}
/* FALLTHROUGH */
case SFF8024_ID_GBIC:
- error = if_sff8472(s, ifname, dump, &pg0);
+ error = if_sff8472(ifname, dump, &pg0);
break;
case SFF8024_ID_XFP:
if (pg0.sff_page != 1) {
if_sffpage_init(&pg0, ifname, IFSFF_ADDR_EEPROM, 1);
- if (ioctl(s, SIOCGIFSFFPAGE, (caddr_t)&pg0) == -1)
+ if (ioctl(sock, SIOCGIFSFFPAGE, (caddr_t)&pg0) == -1)
return (-1);
if (dump)
if_sffpage_dump(ifname, &pg0);
}
- error = if_inf8077(s, ifname, dump, &pg0);
+ error = if_inf8077(ifname, dump, &pg0);
break;
case SFF8024_ID_QSFP:
case SFF8024_ID_QSFP_PLUS:
case SFF8024_ID_QSFP28:
- error = if_sff8636(s, ifname, dump, &pg0);
+ error = if_sff8636(ifname, dump, &pg0);
break;
default:
printf("\n");
@@ -484,7 +486,7 @@ if_sff_ascii_print(const struct if_sffpage *sff, const char *name,
printf("%s", name);
for (;;) {
- int ch = d[end];
+ ch = d[end];
if (!isspace(ch) && ch != '\0')
break;
@@ -578,7 +580,7 @@ if_sff_printdist(const char *type, int value, int scale)
static void
if_sff_printmedia(const struct if_sffpage *pg, const struct sff_media_map *m)
{
- uint8_t con, dist;
+ uint8_t con;
unsigned int wavelength;
con = pg->sff_data[m->connector_type];
@@ -611,7 +613,7 @@ if_sff_printmedia(const struct if_sffpage *pg, const struct sff_media_map *m)
}
static int
-if_sff8472(int s, const char *ifname, int dump, const struct if_sffpage *pg0)
+if_sff8472(const char *ifname, int dump, const struct if_sffpage *pg0)
{
struct if_sffpage ddm;
uint8_t ddm_types;
@@ -636,7 +638,7 @@ if_sff8472(int s, const char *ifname, int dump, const struct if_sffpage *pg0)
return (0);
if_sffpage_init(&ddm, ifname, IFSFF_ADDR_DDM, 0);
- if (ioctl(s, SIOCGIFSFFPAGE, (caddr_t)&ddm) == -1)
+ if (ioctl(sock, SIOCGIFSFFPAGE, (caddr_t)&ddm) == -1)
return (-1);
if (dump)
@@ -714,7 +716,7 @@ if_upper_strings(const struct if_sffpage *pg)
}
static int
-if_inf8077(int s, const char *ifname, int dump, const struct if_sffpage *pg1)
+if_inf8077(const char *ifname, int dump, const struct if_sffpage *pg1)
{
if_upper_strings(pg1);
@@ -722,7 +724,7 @@ if_inf8077(int s, const char *ifname, int dump, const struct if_sffpage *pg1)
}
static int
-if_sff8636_thresh(int s, const char *ifname, int dump,
+if_sff8636_thresh(const char *ifname, int dump,
const struct if_sffpage *pg0)
{
struct if_sffpage pg3;
@@ -730,7 +732,7 @@ if_sff8636_thresh(int s, const char *ifname, int dump,
struct sff_thresholds temp, vcc, tx, rx, bias;
if_sffpage_init(&pg3, ifname, IFSFF_ADDR_EEPROM, 3);
- if (ioctl(s, SIOCGIFSFFPAGE, (caddr_t)&pg3) == -1) {
+ if (ioctl(sock, SIOCGIFSFFPAGE, (caddr_t)&pg3) == -1) {
if (dump)
warn("%s SIOCGIFSFFPAGE page 3", ifname);
return (-1);
@@ -817,7 +819,7 @@ if_sff8636_thresh(int s, const char *ifname, int dump,
}
static int
-if_sff8636(int s, const char *ifname, int dump, const struct if_sffpage *pg0)
+if_sff8636(const char *ifname, int dump, const struct if_sffpage *pg0)
{
int16_t temp;
uint8_t maxcasetemp;
@@ -844,7 +846,7 @@ if_sff8636(int s, const char *ifname, int dump, const struct if_sffpage *pg0)
}
flat = pg0->sff_data[SFF8436_STATUS2] & SFF8436_STATUS2_FLAT_MEM;
- if (!flat && if_sff8636_thresh(s, ifname, dump, pg0) == 0) {
+ if (!flat && if_sff8636_thresh(ifname, dump, pg0) == 0) {
if (!dump)
return (0);
}