summaryrefslogtreecommitdiffstats
path: root/net.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2012-03-20 09:19:01 +0000
committerRoy Marples <roy@marples.name>2012-03-20 09:19:01 +0000
commit8cf1f9a8ca06c73a8192cadbe740ef7e26a9448e (patch)
treeb4f7fc7e25db17b668dedb0b8e5abc6a84915911 /net.c
parent5e084fac909d60e7b965d0d5c23aa26cee305232 (diff)
downloaddhcpcd-8cf1f9a8ca06c73a8192cadbe740ef7e26a9448e.tar.xz
Support bridge and VLAN interfaces on BSD.
Fall back to ethernet if unknown and specified.
Diffstat (limited to 'net.c')
-rw-r--r--net.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/net.c b/net.c
index 8e35adca..c69d0097 100644
--- a/net.c
+++ b/net.c
@@ -317,7 +317,7 @@ discover_interfaces(int argc, char * const *argv)
{
struct ifaddrs *ifaddrs, *ifa;
char *p;
- int i;
+ int i, sdl_type;
struct interface *ifp, *ifs, *ifl;
#ifdef __linux__
char ifn[IF_NAMESIZE];
@@ -411,6 +411,7 @@ discover_interfaces(int argc, char * const *argv)
syslog(LOG_ERR, "%s: up_interface: %m", ifp->name);
}
+ sdl_type = 0;
/* Don't allow loopback unless explicit */
if (ifp->flags & IFF_LOOPBACK) {
if (argc == 0 && ifac == 0) {
@@ -437,13 +438,20 @@ discover_interfaces(int argc, char * const *argv)
}
#endif
+ sdl_type = sdl->sdl_type;
switch(sdl->sdl_type) {
+ case IFT_BRIDGE: /* FALLTHROUGH */
+ case IFT_L2VLAN: /* FALLTHOUGH */
+ case IFT_L3IPVLAN: /* FALLTHROUGH */
case IFT_ETHER:
ifp->family = ARPHRD_ETHER;
break;
case IFT_IEEE1394:
ifp->family = ARPHRD_IEEE1394;
break;
+ case IFT_INFINIBAND:
+ ifp->family = ARPHRD_INFINIBAND;
+ break;
}
ifp->hwlen = sdl->sdl_alen;
#ifndef CLLADDR
@@ -452,7 +460,7 @@ discover_interfaces(int argc, char * const *argv)
memcpy(ifp->hwaddr, CLLADDR(sdl), ifp->hwlen);
#elif AF_PACKET
sll = (const struct sockaddr_ll *)(void *)ifa->ifa_addr;
- ifp->family = sll->sll_hatype;
+ ifp->family = sdl_type = sll->sll_hatype;
ifp->hwlen = sll->sll_halen;
if (ifp->hwlen != 0)
memcpy(ifp->hwaddr, sll->sll_addr, ifp->hwlen);
@@ -474,7 +482,11 @@ discover_interfaces(int argc, char * const *argv)
break;
default:
syslog(LOG_WARNING,
- "%s: unknown hardware family", p);
+ "%s: unsupported interface type %.2x"
+ ", falling back to ethernet",
+ ifp->name, sdl_type);
+ ifp->family = ARPHRD_ETHER;
+ break;
}
}