diff options
author | Matt Smith <mgsmith@netgate.com> | 2015-11-18 10:30:43 -0600 |
---|---|---|
committer | Matt Smith <mgsmith@netgate.com> | 2015-11-18 10:30:43 -0600 |
commit | 6c23910924a53e1b7887a29314f9a095810291f9 (patch) | |
tree | dfc85dc25b2a989e6d78fb95dda40112a96311fe /sbin | |
parent | 493fb0978fb224273636e9346921b18826b0351b (diff) | |
download | FreeBSD-src-6c23910924a53e1b7887a29314f9a095810291f9.zip FreeBSD-src-6c23910924a53e1b7887a29314f9a095810291f9.tar.gz |
Importing pfSense patch set_ifaddr_first.diff
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/ifconfig/ifconfig.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 6d29f20..ad39c57 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -636,6 +636,23 @@ top: return(0); } +static void +setaddrfirst(const char *addr, int dummy __unused, int s, + const struct afswtch *afp) +{ + + if (afp == NULL) + err(2, "No address family"); + if (afp->af_getaddr == NULL) + err(2, "No appropriate functions from address family"); + afp->af_getaddr(addr, ADDR); + + strncpy(afp->af_addreq, name, sizeof ifr.ifr_name); + printf("Interface name: %s, socket %d, addr %s\n", name, s, addr); + if (ioctl(s, SIOCORDERIFADDR, afp->af_addreq) < 0) + err(1, "SIOCORDERIFADDR"); +} + /*ARGSUSED*/ static void setifaddr(const char *addr, int param, int s, const struct afswtch *afp) @@ -1229,6 +1246,7 @@ static struct cmd basic_cmds[] = { DEF_CMD("noicmp", IFF_LINK1, setifflags), DEF_CMD_ARG("mtu", setifmtu), DEF_CMD_ARG("name", setifname), + DEF_CMD_ARG("setfirst", setaddrfirst), }; static __constructor void |