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 @@ -142,12 +142,6 @@ return (a); } -static struct sockaddr_in * -satosin(struct sockaddr *sa) -{ - return ((struct sockaddr_in *)(void *)sa); -} - static void in_status_nl(struct ifconfig_args *args __unused, struct io_handler *h, if_link_t *link, if_addr_t *ifa) @@ -204,7 +198,7 @@ if((p = strrchr(s, '/')) != NULL) { const char *errstr; /* address is `name/masklen' */ - int masklen; + int masklen = 0; struct sockaddr_in *min = sintab[MASK]; *p = '\0'; if (!isdigit(*(p + 1))) 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 @@ -65,7 +65,9 @@ .ifra_lifetime = { 0, 0, ND6_INFINITE_LIFETIME, ND6_INFINITE_LIFETIME } }; static int ip6lifetime; +#ifdef WITHOUT_NETLINK static int prefix(void *, int); +#endif static char *sec2str(time_t); static int explicit_prefix = 0; extern char *f_inet6, *f_addr; @@ -154,7 +156,7 @@ for (ifa = ifap; ifa; ifa = ifa->ifa_next) { if (ifa->ifa_addr->sa_family == AF_INET6 && strcmp(ifa->ifa_name, name) == 0) { - sin6 = (const struct sockaddr_in6 *)ifa->ifa_addr; + sin6 = (const struct sockaddr_in6 *)satosin6(ifa->ifa_addr); if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { lladdr = &sin6->sin6_addr; break; @@ -338,12 +340,6 @@ print_lifetime("vltime", vl + now.tv_sec, &now); } -static struct sockaddr_in6 * -satosin6(struct sockaddr *sa) -{ - return ((struct sockaddr_in6 *)(void *)sa); -} - static void in6_status_nl(struct ifconfig_args *args __unused, struct io_handler *h, if_link_t *link, if_addr_t *ifa) @@ -376,10 +372,9 @@ } #endif -#define SIN6(x) ((struct sockaddr_in6 *) &(x)) static struct sockaddr_in6 *sin6tab[] = { - SIN6(in6_ridreq.ifr_addr), SIN6(in6_addreq.ifra_addr), - SIN6(in6_addreq.ifra_prefixmask), SIN6(in6_addreq.ifra_dstaddr) + &in6_ridreq.ifr_addr, &in6_addreq.ifra_addr, + &in6_addreq.ifra_prefixmask, &in6_addreq.ifra_dstaddr }; static void @@ -440,6 +435,7 @@ } } +#ifdef WITHOUT_NETLINK static int prefix(void *val, int size) { @@ -463,6 +459,7 @@ return(0); return (plen); } +#endif static char * sec2str(time_t total) diff --git a/sbin/ifconfig/carp.c b/sbin/ifconfig/carp.c --- a/sbin/ifconfig/carp.c +++ b/sbin/ifconfig/carp.c @@ -252,13 +252,11 @@ static __constructor void carp_ctor(void) { - int i; - /* Default to multicast. */ setcarp_mcast(NULL, 0, 0, NULL); setcarp_mcast6(NULL, 0, 0, NULL); - for (i = 0; i < nitems(carp_cmds); i++) + for (size_t i = 0; i < nitems(carp_cmds); i++) cmd_register(&carp_cmds[i]); af_register(&af_carp); } diff --git a/sbin/ifconfig/ifbridge.c b/sbin/ifconfig/ifbridge.c --- a/sbin/ifconfig/ifbridge.c +++ b/sbin/ifconfig/ifbridge.c @@ -124,7 +124,7 @@ struct ifbaconf ifbac; struct ifbareq *ifba; char *inbuf = NULL, *ninbuf; - int i, len = 8192; + size_t len = 8192; struct ether_addr ea; for (;;) { @@ -140,7 +140,7 @@ len *= 2; } - for (i = 0; i < ifbac.ifbac_len / sizeof(*ifba); i++) { + for (unsigned long i = 0; i < ifbac.ifbac_len / sizeof(*ifba); i++) { ifba = ifbac.ifbac_req + i; memcpy(ea.octet, ifba->ifba_dst, sizeof(ea.octet)); @@ -683,9 +683,7 @@ static __constructor void bridge_ctor(void) { - int i; - - for (i = 0; i < nitems(bridge_cmds); i++) + for (size_t i = 0; i < nitems(bridge_cmds); i++) cmd_register(&bridge_cmds[i]); af_register(&af_bridge); } diff --git a/sbin/ifconfig/ifconfig.h b/sbin/ifconfig/ifconfig.h --- a/sbin/ifconfig/ifconfig.h +++ b/sbin/ifconfig/ifconfig.h @@ -240,6 +240,7 @@ extern int printifname; extern int exit_code; extern struct ifconfig_args 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, @@ -281,3 +282,20 @@ void print_vhid(const struct ifaddrs *, const char *); void ioctl_ifcreate(int s, struct ifreq *); + +/* Helpers */ +struct sockaddr_in; +struct sockaddr_in6; +struct sockaddr; + +static inline struct sockaddr_in6 * +satosin6(struct sockaddr *sa) +{ + return ((struct sockaddr_in6 *)(void *)sa); +} + +static inline struct sockaddr_in * +satosin(struct sockaddr *sa) +{ + return ((struct sockaddr_in *)(void *)sa); +} diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -93,8 +93,10 @@ struct ifreq ifr; char name[IFNAMSIZ]; -char *descr = NULL; -size_t descrlen = 64; +#ifdef WITHOUT_NETLINK +static char *descr = NULL; +static size_t descrlen = 64; +#endif static int setaddr; static int setmask; static int doalias; @@ -111,17 +113,17 @@ /* Formatter Strings */ char *f_inet, *f_inet6, *f_ether, *f_addr; +#ifdef WITHOUT_NETLINK static void list_interfaces_ioctl(struct ifconfig_args *args); static void status(struct ifconfig_args *args, const struct sockaddr_dl *sdl, struct ifaddrs *ifa); +#endif static _Noreturn void usage(void); static int getifflags(const char *ifname, int us, bool err_ok); static struct afswtch *af_getbyname(const char *name); -void printifnamemaybe(void); - static struct option *opts = NULL; struct ifa_order_elt { @@ -210,6 +212,7 @@ } } +#ifdef WITHOUT_NETLINK static int calcorders(struct ifaddrs *ifa, struct ifa_queue *q) { @@ -296,6 +299,7 @@ return (0); } +#endif static void freeformat(void) { @@ -339,6 +343,7 @@ free(formatstr); } +#ifdef WITHOUT_NETLINK static struct ifaddrs * sortifaddrs(struct ifaddrs *list, int (*compare)(struct ifaddrs *, struct ifaddrs *, struct ifa_queue *), @@ -393,8 +398,10 @@ return (result); } +#endif -void printifnamemaybe() +static void +printifnamemaybe(void) { if (printifname) printf("%s\n", name); @@ -694,6 +701,19 @@ } } +bool +match_if_flags(struct ifconfig_args *args, int if_flags) +{ + if ((if_flags & IFF_CANTCONFIG) != 0) + return (false); + if (args->downonly && (if_flags & IFF_UP) != 0) + return (false); + if (args->uponly && (if_flags & IFF_UP) == 0) + return (false); + return (true); +} + +#ifdef WITHOUT_NETLINK static bool match_afp(const struct afswtch *afp, int sa_family, const struct sockaddr_dl *sdl) { @@ -708,19 +728,6 @@ return (afp->af_af == sa_family); } -bool -match_if_flags(struct ifconfig_args *args, int if_flags) -{ - if ((if_flags & IFF_CANTCONFIG) != 0) - return (false); - if (args->downonly && (if_flags & IFF_UP) != 0) - return (false); - if (args->uponly && (if_flags & IFF_UP) == 0) - return (false); - return (true); -} - -#ifdef WITHOUT_NETLINK static void list_interfaces_ioctl(struct ifconfig_args *args) { @@ -815,7 +822,7 @@ struct ifgroupreq ifgr; struct ifg_req *ifg; - int len; + unsigned int len; bool matched, nomatched; /* Sanity checks. */ @@ -1806,7 +1813,7 @@ { #define MOD_PREFIX_LEN 3 /* "if_" */ struct module_stat mstat; - int i, fileid, modid; + int fileid, modid; char ifkind[IFNAMSIZ + MOD_PREFIX_LEN], ifname[IFNAMSIZ], *dp; const char *cp; struct module_map_entry *mme; @@ -1829,7 +1836,7 @@ /* Either derive it from the map or guess otherwise */ *ifkind = '\0'; found = false; - for (i = 0; i < nitems(module_map); ++i) { + for (unsigned i = 0; i < nitems(module_map); ++i) { mme = &module_map[i]; if (strcmp(mme->ifname, ifname) == 0) { strlcpy(ifkind, mme->kldname, sizeof(ifkind)); 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 @@ -288,7 +288,7 @@ struct ifa **sorted_ifaddrs = snl_allocz(ss, iface->ifa_count * sizeof(void *)); struct ifa *ifa = iface->ifa; - for (int i = 0; i < iface->ifa_count; i++) { + for (uint32_t i = 0; i < iface->ifa_count; i++) { struct ifa *ifa_next = ifa->next; sorted_ifaddrs[i] = ifa; @@ -298,7 +298,7 @@ qsort(sorted_ifaddrs, iface->ifa_count, sizeof(void *), cmp_ifaddr); ifa = sorted_ifaddrs[0]; iface->ifa = ifa; - for (int i = 1; i < iface->ifa_count; i++) { + for (uint32_t i = 1; i < iface->ifa_count; i++) { ifa->next = sorted_ifaddrs[i]; ifa = sorted_ifaddrs[i]; } @@ -371,7 +371,8 @@ static void set_global_ifname(if_link_t *link) { - int iflen = strlcpy(name, link->ifla_ifname, sizeof(name)); + size_t iflen = strlcpy(name, link->ifla_ifname, sizeof(name)); + if (iflen >= sizeof(name)) errx(1, "%s: cloning name too long", link->ifla_ifname); strlcpy(ifr.ifr_name, link->ifla_ifname, sizeof(ifr.ifr_name)); @@ -386,7 +387,7 @@ struct ifmap *ifmap = prepare_ifmap(&ss); struct iface **sorted_ifaces = snl_allocz(&ss, ifmap->count * sizeof(void *)); - for (int i = 0, num = 0; i < ifmap->size; i++) { + for (uint32_t i = 0, num = 0; i < ifmap->size; i++) { if (ifmap->ifaces[i] != NULL) { sorted_ifaces[num++] = ifmap->ifaces[i]; if (num == ifmap->count) @@ -401,7 +402,7 @@ .ss = &ss, }; - for (int i = 0, num = 0; i < ifmap->count; i++) { + for (uint32_t i = 0, num = 0; i < ifmap->count; i++) { struct iface *iface = sorted_ifaces[i]; if (!match_iface(args, iface)) diff --git a/sbin/ifconfig/ifgroup.c b/sbin/ifconfig/ifgroup.c --- a/sbin/ifconfig/ifgroup.c +++ b/sbin/ifconfig/ifgroup.c @@ -114,7 +114,7 @@ { struct ifgroupreq ifgr; struct ifg_req *ifg; - int len; + unsigned int len; int s; s = socket(AF_LOCAL, SOCK_DGRAM, 0); @@ -150,19 +150,23 @@ DEF_CMD_ARG("group", setifgroup), DEF_CMD_ARG("-group", unsetifgroup), }; + static struct afswtch af_group = { .af_name = "af_group", .af_af = AF_UNSPEC, .af_other_status = getifgroups, }; -static struct option group_gopt = { "g:", "[-g groupname]", printgroup }; + +static struct option group_gopt = { + .opt = "g:", + .opt_usage = "[-g groupname]", + .cb = printgroup, +}; static __constructor void group_ctor(void) { - int i; - - for (i = 0; i < nitems(group_cmds); i++) + for (size_t i = 0; i < nitems(group_cmds); i++) cmd_register(&group_cmds[i]); af_register(&af_group); opt_register(&group_gopt); diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c --- a/sbin/ifconfig/ifieee80211.c +++ b/sbin/ifconfig/ifieee80211.c @@ -264,7 +264,7 @@ * 11b > 11g. */ static int -canpromote(int i, int from, int to) +canpromote(unsigned int i, uint32_t from, uint32_t to) { const struct ieee80211_channel *fc = &chaninfo->ic_chans[i]; u_int j; @@ -301,7 +301,7 @@ * XXX VHT */ static int -promote(int i) +promote(unsigned int i) { /* * Query the current mode of the interface in case it's @@ -347,7 +347,7 @@ } static void -mapfreq(struct ieee80211_channel *chan, int freq, int flags) +mapfreq(struct ieee80211_channel *chan, uint16_t freq, unsigned int flags) { u_int i; @@ -367,7 +367,7 @@ } static void -mapchan(struct ieee80211_channel *chan, int ieee, int flags) +mapchan(struct ieee80211_channel *chan, uint8_t ieee, unsigned int flags) { u_int i; @@ -662,7 +662,7 @@ * The result is not validated here; it's assumed to be * checked against the channel table fetched from the kernel. */ -static int +static unsigned int getchannelflags(const char *val, int freq) { #define _CHAN_HT 0x80000000 @@ -808,7 +808,7 @@ static void getchannel(int s, struct ieee80211_channel *chan, const char *val) { - int v, flags; + unsigned int v, flags; char *eptr; memset(chan, 0, sizeof(*chan)); @@ -2084,11 +2084,9 @@ } static int -chanfind(const struct ieee80211_channel chans[], int nchans, int flags) +chanfind(const struct ieee80211_channel chans[], int nchans, unsigned int flags) { - int i; - - for (i = 0; i < nchans; i++) { + for (int i = 0; i < nchans; i++) { const struct ieee80211_channel *c = &chans[i]; if ((c->ic_flags & flags) == flags) return 1; @@ -2699,7 +2697,7 @@ } static void -printie(const char* tag, const uint8_t *ie, size_t ielen, int maxlen) +printie(const char* tag, const uint8_t *ie, size_t ielen, unsigned int maxlen) { printf("%s", tag); if (verbose) { @@ -2829,14 +2827,14 @@ if (verbose) { const struct ieee80211_ie_vht_txpwrenv *vhtpwr = (const struct ieee80211_ie_vht_txpwrenv *) ie; - int i, n; + size_t i, n; const char *sep = ""; /* Get count; trim at ielen */ n = (vhtpwr->tx_info & IEEE80211_VHT_TXPWRENV_INFO_COUNT_MASK) + 1; /* Trim at ielen */ - if (n > ielen - 3) + if (n + 3 > ielen) n = ielen - 3; printf("tx_info); for (i = 0; i < n; i++) { @@ -3006,11 +3004,10 @@ const struct ieee80211_ap_chan_report_ie *ap = (const struct ieee80211_ap_chan_report_ie *) ie; const char *sep = ""; - int i; printf("i_class); - for (i = 3; i < ielen; i++) { + for (size_t i = 3; i < ielen; i++) { printf("%s%u", sep, ie[i]); sep = ","; } @@ -3331,7 +3328,7 @@ break; case IEEE80211_WPS_ATTR_DEV_PASSWORD_ID: n = LE_READ_2(ie); - if (n < nitems(dev_pass_id)) + if (n < (int)nitems(dev_pass_id)) printf(" dpi:%s", dev_pass_id[n]); break; case IEEE80211_WPS_ATTR_MANUFACTURER: @@ -3492,11 +3489,10 @@ printrates(const char *tag, const u_int8_t *ie, size_t ielen, int maxlen) { const char *sep; - int i; printf("%s", tag); sep = "<"; - for (i = 2; i < ielen; i++) { + for (size_t i = 2; i < ielen; i++) { printf("%s%s%d", sep, ie[i] & IEEE80211_RATE_BASIC ? "B" : "", ie[i] & IEEE80211_RATE_VAL); @@ -3603,7 +3599,7 @@ } static void -printies(const u_int8_t *vp, int ielen, int maxcols) +printies(const u_int8_t *vp, int ielen, unsigned int maxcols) { while (ielen > 0) { switch (vp[0]) { @@ -3737,7 +3733,7 @@ if (get80211len(s, IEEE80211_IOC_SCAN_RESULTS, buf, sizeof(buf), &len) < 0) errx(1, "unable to get scan results"); - if (len < sizeof(struct ieee80211req_scan_result)) + if (len < (int)sizeof(struct ieee80211req_scan_result)) return; getchaninfo(s); @@ -3756,7 +3752,7 @@ const struct ieee80211req_scan_result *sr; const uint8_t *vp, *idp; - sr = (const struct ieee80211req_scan_result *) cp; + sr = (const struct ieee80211req_scan_result *)(const void *) cp; vp = cp + sr->isr_ie_off; if (sr->isr_meshid_len) { idp = vp + sr->isr_ssid_len; @@ -3781,7 +3777,7 @@ printbssidname((const struct ether_addr *)sr->isr_bssid); printf("\n"); cp += sr->isr_len, len -= sr->isr_len; - } while (len >= sizeof(struct ieee80211req_scan_result)); + } while (len >= (int)sizeof(struct ieee80211req_scan_result)); } static void @@ -3862,13 +3858,13 @@ static int getrxseq(const struct ieee80211req_sta_info *si) { - int i, rxseq; + int rxseq; if ((si->isi_state & IEEE80211_NODE_QOS) == 0) return si->isi_rxseqs[0]; /* XXX not right but usually what folks want */ rxseq = 0; - for (i = 0; i < IEEE80211_TID_SIZE; i++) + for (unsigned int i = 0; i < IEEE80211_TID_SIZE; i++) if (si->isi_rxseqs[i] > rxseq) rxseq = si->isi_rxseqs[i]; return rxseq; @@ -3896,7 +3892,7 @@ } if (get80211len(s, IEEE80211_IOC_STA_INFO, &u, sizeof(u), &len) < 0) errx(1, "unable to get station information"); - if (len < sizeof(struct ieee80211req_sta_info)) + if (len < (int)sizeof(struct ieee80211req_sta_info)) return; getchaninfo(s); @@ -3968,7 +3964,7 @@ printmimo(&si->isi_mimo); printf("\n"); cp += si->isi_len, len -= si->isi_len; - } while (len >= sizeof(struct ieee80211req_sta_info)); + } while (len >= (int)sizeof(struct ieee80211req_sta_info)); } static const char * @@ -4108,7 +4104,7 @@ struct ieee80211req_chaninfo *achans; uint8_t reported[IEEE80211_CHAN_BYTES]; const struct ieee80211_channel *c; - int i, half; + unsigned int i, half; achans = malloc(IEEE80211_CHANINFO_SPACE(chans)); if (achans == NULL) @@ -4202,7 +4198,7 @@ struct ieee80211req_chaninfo *achans; uint8_t reported[IEEE80211_CHAN_BYTES]; struct ieee80211_channel *c, *prev; - int i, half; + unsigned int i, half; getchaninfo(s); achans = malloc(IEEE80211_CHANINFO_SPACE(chaninfo)); @@ -4623,7 +4619,8 @@ , "MSEQ" , "FLAGS"); - for (rt = &routes[0]; rt - &routes[0] < ireq.i_len / sizeof(*rt); rt++){ + for (unsigned int i = 0; i < ireq.i_len / sizeof(*rt); i++) { + rt = &routes[i]; printf("%s ", ether_ntoa((const struct ether_addr *)rt->imr_dest)); printf("%s %4u %4u %6u %6u %c%c\n", @@ -6079,9 +6076,7 @@ static __constructor void ieee80211_ctor(void) { - int i; - - for (i = 0; i < nitems(ieee80211_cmds); i++) + for (size_t i = 0; i < nitems(ieee80211_cmds); i++) cmd_register(&ieee80211_cmds[i]); af_register(&af_ieee80211); clone_setdefcallback_prefix("wlan", wlan_create); diff --git a/sbin/ifconfig/iflagg.c b/sbin/ifconfig/iflagg.c --- a/sbin/ifconfig/iflagg.c +++ b/sbin/ifconfig/iflagg.c @@ -78,12 +78,11 @@ { struct lagg_protos lpr[] = LAGG_PROTOS; struct lagg_reqall ra; - int i; bzero(&ra, sizeof(ra)); ra.ra_proto = LAGG_PROTO_MAX; - for (i = 0; i < nitems(lpr); i++) { + for (size_t i = 0; i < nitems(lpr); i++) { if (strcmp(val, lpr[i].lpr_name) == 0) { ra.ra_proto = lpr[i].lpr_proto; break; @@ -279,7 +278,7 @@ } } - for (size_t i = 0; i < ra->ra_ports; ++i) { + for (size_t i = 0; i < (size_t)ra->ra_ports; ++i) { lp = &ports[i].rp_lacpreq; printf("\tlaggport: %s ", ports[i].rp_portname); printb("flags", ports[i].rp_flags, LAGG_PORT_BITS); @@ -298,9 +297,8 @@ DECL_CMD_FUNC(setlaggtype, arg, d) { static const struct lagg_types lt[] = LAGG_TYPES; - int i; - for (i = 0; i < nitems(lt); i++) { + for (size_t i = 0; i < nitems(lt); i++) { if (strcmp(arg, lt[i].lt_name) == 0) { params.lagg_type = lt[i].lt_value; return; @@ -346,9 +344,7 @@ static __constructor void lagg_ctor(void) { - int i; - - for (i = 0; i < nitems(lagg_cmds); i++) + for (size_t i = 0; i < nitems(lagg_cmds); i++) cmd_register(&lagg_cmds[i]); af_register(&af_lagg); clone_setdefcallback_prefix("lagg", lagg_create); diff --git a/sbin/ifconfig/ifmedia.c b/sbin/ifconfig/ifmedia.c --- a/sbin/ifconfig/ifmedia.c +++ b/sbin/ifconfig/ifmedia.c @@ -146,7 +146,7 @@ if (args.supmedia) { printf("\tsupported media:\n"); - for (size_t i = 0; i < ifmr->ifm_count; ++i) { + for (int i = 0; i < ifmr->ifm_count; ++i) { printf("\t\t"); print_media_ifconfig(ifmr->ifm_ulist[i]); putchar('\n'); @@ -486,9 +486,7 @@ static __constructor void ifmedia_ctor(void) { - size_t i; - - for (i = 0; i < nitems(media_cmds); i++) + for (size_t i = 0; i < nitems(media_cmds); i++) cmd_register(&media_cmds[i]); af_register(&af_media); } diff --git a/sbin/ifconfig/ifpfsync.c b/sbin/ifconfig/ifpfsync.c --- a/sbin/ifconfig/ifpfsync.c +++ b/sbin/ifconfig/ifpfsync.c @@ -330,8 +330,8 @@ char syncdev[IFNAMSIZ]; char syncpeer_str[NI_MAXHOST]; struct sockaddr_storage syncpeer; - int maxupdates; - int flags; + int maxupdates = 0; + int flags = 0; int error; nvl = nvlist_create(0); @@ -401,9 +401,7 @@ static __constructor void pfsync_ctor(void) { - int i; - - for (i = 0; i < nitems(pfsync_cmds); i++) + for (size_t i = 0; i < nitems(pfsync_cmds); i++) cmd_register(&pfsync_cmds[i]); af_register(&af_pfsync); } diff --git a/sbin/ifconfig/ifstf.c b/sbin/ifconfig/ifstf.c --- a/sbin/ifconfig/ifstf.c +++ b/sbin/ifconfig/ifstf.c @@ -144,9 +144,7 @@ static __constructor void stf_ctor(void) { - int i; - - for (i = 0; i < nitems(stf_cmds); i++) + for (size_t i = 0; i < nitems(stf_cmds); i++) cmd_register(&stf_cmds[i]); af_register(&af_stf); } diff --git a/sbin/ifconfig/ifvxlan.c b/sbin/ifconfig/ifvxlan.c --- a/sbin/ifconfig/ifvxlan.c +++ b/sbin/ifconfig/ifvxlan.c @@ -128,10 +128,10 @@ dst[0] = dstport[0] = '\0'; if (!ipv6) { - struct sockaddr_in *sin = (struct sockaddr_in *)rsa; + struct sockaddr_in *sin = satosin(rsa); mc = IN_MULTICAST(ntohl(sin->sin_addr.s_addr)); } else { - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)rsa; + struct sockaddr_in6 *sin6 = satosin6(rsa); mc = IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr); } @@ -235,7 +235,7 @@ switch (ai->ai_family) { #ifdef INET case AF_INET: { - struct sockaddr_in *sin = (struct sockaddr_in *)sa; + struct sockaddr_in *sin = satosin(sa); if (IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) errx(1, "local address cannot be multicast"); @@ -246,7 +246,7 @@ #endif #ifdef INET6 case AF_INET6: { - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa; + struct sockaddr_in6 *sin6 = satosin6(sa); if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) errx(1, "local address cannot be multicast"); @@ -295,7 +295,7 @@ switch (ai->ai_family) { #ifdef INET case AF_INET: { - struct sockaddr_in *sin = (struct sockaddr_in *)sa; + struct sockaddr_in *sin = satosin(sa); if (IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) errx(1, "remote address cannot be multicast"); @@ -306,7 +306,7 @@ #endif #ifdef INET6 case AF_INET6: { - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa; + struct sockaddr_in6 *sin6 = satosin6(sa); if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) errx(1, "remote address cannot be multicast"); @@ -355,7 +355,7 @@ switch (ai->ai_family) { #ifdef INET case AF_INET: { - struct sockaddr_in *sin = (struct sockaddr_in *)sa; + struct sockaddr_in *sin = satosin(sa); if (!IN_MULTICAST(ntohl(sin->sin_addr.s_addr))) errx(1, "group address must be multicast"); @@ -366,7 +366,7 @@ #endif #ifdef INET6 case AF_INET6: { - struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)sa; + struct sockaddr_in6 *sin6 = satosin6(sa); if (!IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) errx(1, "group address must be multicast");