diff options
author | hrs <hrs@FreeBSD.org> | 2013-01-08 17:24:43 +0000 |
---|---|---|
committer | hrs <hrs@FreeBSD.org> | 2013-01-08 17:24:43 +0000 |
commit | 9b2193d68972f5c42e08f1f03b60ee546de59f89 (patch) | |
tree | 327987babecb4c864fd858191aa6c9083a175fad /sbin/route | |
parent | afe1d4e213e502872a2b8ec74459a88132ba221d (diff) | |
download | FreeBSD-src-9b2193d68972f5c42e08f1f03b60ee546de59f89.zip FreeBSD-src-9b2193d68972f5c42e08f1f03b60ee546de59f89.tar.gz |
Fix -iface and -interface modifiers.
Spotted by: Ian FREISLICH
Diffstat (limited to 'sbin/route')
-rw-r--r-- | sbin/route/route.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/sbin/route/route.c b/sbin/route/route.c index 847f3ee..4637ba4 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -94,7 +94,7 @@ typedef union sockunion *sup; int pid, rtm_addrs; int s; int forcehost, forcenet, doflush, nflag, af, qflag, tflag; -int iflag, verbose, aflen = sizeof (struct sockaddr_in); +int verbose, aflen = sizeof (struct sockaddr_in); int locking, lockrest, debugonly; struct rt_metrics rt_metrics; u_long rtm_inits; @@ -107,7 +107,7 @@ static char *atalk_ntoa(struct at_addr); static void bprintf(FILE *, int, u_char *); static void flushroutes(int argc, char *argv[]); static int flushroutes_fib(int); -static int getaddr(int, char *, struct hostent **); +static int getaddr(int, char *, struct hostent **, int); static int keyword(const char *); static void inet_makenetandmask(u_long, struct sockaddr_in *, u_long); #ifdef INET6 @@ -833,34 +833,34 @@ newroute(int argc, char **argv) case K_IFA: if (!--argc) usage(NULL); - (void) getaddr(RTA_IFA, *++argv, 0); + getaddr(RTA_IFA, *++argv, 0, nrflags); break; case K_IFP: if (!--argc) usage(NULL); - (void) getaddr(RTA_IFP, *++argv, 0); + getaddr(RTA_IFP, *++argv, 0, nrflags); break; case K_GENMASK: if (!--argc) usage(NULL); - (void) getaddr(RTA_GENMASK, *++argv, 0); + getaddr(RTA_GENMASK, *++argv, 0, nrflags); break; case K_GATEWAY: if (!--argc) usage(NULL); - (void) getaddr(RTA_GATEWAY, *++argv, 0); + getaddr(RTA_GATEWAY, *++argv, 0, nrflags); break; case K_DST: if (!--argc) usage(NULL); - if (getaddr(RTA_DST, *++argv, &hp)) + if (getaddr(RTA_DST, *++argv, &hp, nrflags)) nrflags |= F_ISHOST; dest = *argv; break; case K_NETMASK: if (!--argc) usage(NULL); - (void) getaddr(RTA_NETMASK, *++argv, 0); + getaddr(RTA_NETMASK, *++argv, 0, nrflags); /* FALLTHROUGH */ case K_NET: nrflags |= F_FORCENET; @@ -895,13 +895,13 @@ newroute(int argc, char **argv) } else { if ((rtm_addrs & RTA_DST) == 0) { dest = *argv; - if (getaddr(RTA_DST, *argv, &hp)) + if (getaddr(RTA_DST, *argv, &hp, nrflags)) nrflags |= F_ISHOST; } else if ((rtm_addrs & RTA_GATEWAY) == 0) { gateway = *argv; - (void) getaddr(RTA_GATEWAY, *argv, &hp); + getaddr(RTA_GATEWAY, *argv, &hp, nrflags); } else { - (void) getaddr(RTA_NETMASK, *argv, 0); + getaddr(RTA_NETMASK, *argv, 0, nrflags); nrflags |= F_FORCENET; } } @@ -1116,7 +1116,7 @@ inet6_makenetandmask(struct sockaddr_in6 *sin6, const char *plen) * returning 1 if a host address, 0 if a network address. */ static int -getaddr(int which, char *str, struct hostent **hpp) +getaddr(int which, char *str, struct hostent **hpp, int nrflags) { sup su; struct hostent *hp; @@ -1137,7 +1137,7 @@ getaddr(int which, char *str, struct hostent **hpp) break; case RTA_GATEWAY: su = &so_gate; - if (iflag) { + if (nrflags & F_INTERFACE) { struct ifaddrs *ifap, *ifa; struct sockaddr_dl *sdl = NULL; @@ -1197,7 +1197,7 @@ getaddr(int which, char *str, struct hostent **hpp) #if 0 bzero(su, sizeof(*su)); /* for readability */ #endif - getaddr(RTA_NETMASK, str, 0); + getaddr(RTA_NETMASK, str, 0, nrflags); break; #if 0 case RTA_NETMASK: |