uint8_t *p;
const struct iarp_state *state;
- ar.ar_hrd = htons(ifp->family);
+ ar.ar_hrd = htons(ifp->hwtype);
ar.ar_pro = htons(ETHERTYPE_IP);
ar.ar_hln = ifp->hwlen;
ar.ar_pln = sizeof(tip->s_addr);
arp_validate(const struct interface *ifp, struct arphdr *arp)
{
- /* Families must match */
- if (arp->ar_hrd != htons(ifp->family))
+ /* Address type must match */
+ if (arp->ar_hrd != htons(ifp->hwtype))
return false;
/* Protocol must be IP. */
bpf_frame_header_len(const struct interface *ifp)
{
- switch (ifp->family) {
+ switch (ifp->hwtype) {
case ARPHRD_ETHER:
return sizeof(struct ether_header);
default:
{
uint8_t *f = fh;
- switch (ifp->family) {
+ switch (ifp->hwtype) {
case ARPHRD_ETHER:
*len = sizeof(((struct ether_header *)0)->ether_shost);
return f + offsetof(struct ether_header, ether_shost);
{
uint8_t *f = fh;
- switch (ifp->family) {
+ switch (ifp->hwtype) {
case ARPHRD_ETHER:
*len = sizeof(((struct ether_header *)0)->ether_dhost);
return f + offsetof(struct ether_header, ether_dhost);
bpf_frame_bcast(const struct interface *ifp, const char *frame)
{
- switch (ifp->family) {
+ switch (ifp->hwtype) {
case ARPHRD_ETHER:
return memcmp(frame +
offsetof(struct ether_header, ether_dhost),
struct iovec iov[2];
struct ether_header eh;
- switch(ifp->family) {
+ switch(ifp->hwtype) {
case ARPHRD_ETHER:
memset(&eh.ether_dhost, 0xff, sizeof(eh.ether_dhost));
memcpy(&eh.ether_shost, ifp->hwaddr, sizeof(eh.ether_shost));
/* Load frame header length into X */
BPF_STMT(BPF_LDX + BPF_W + BPF_IMM, sizeof(struct ether_header)),
- /* Make sure the hardware family matches. */
+ /* Make sure the hardware type matches. */
BPF_STMT(BPF_LD + BPF_H + BPF_IND, offsetof(struct arphdr, ar_hrd)),
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ARPHRD_ETHER, 1, 0),
BPF_STMT(BPF_RET + BPF_K, 0),
bp = bpf;
/* Check frame header. */
- switch(ifp->family) {
+ switch(ifp->hwtype) {
case ARPHRD_ETHER:
memcpy(bp, bpf_arp_ether, sizeof(bpf_arp_ether));
bp += BPF_ARP_ETHER_LEN;
bp = bpf;
/* Check frame header. */
- switch(ifp->family) {
+ switch(ifp->hwtype) {
#ifdef ARPHRD_NONE
case ARPHRD_NONE:
memcpy(bp, bpf_bootp_none, sizeof(bpf_bootp_none));
bootp->ciaddr = state->addr->addr.s_addr;
bootp->op = BOOTREQUEST;
- bootp->htype = (uint8_t)ifp->family;
+ bootp->htype = (uint8_t)ifp->hwtype;
if (ifp->hwlen != 0 && ifp->hwlen < sizeof(bootp->chaddr)) {
bootp->hlen = (uint8_t)ifp->hwlen;
memcpy(&bootp->chaddr, &ifp->hwaddr, ifp->hwlen);
if (state->clientid == NULL)
goto eexit;
state->clientid[0] = len;
- state->clientid[1] = (uint8_t)ifp->family;
+ state->clientid[1] = (uint8_t)ifp->hwtype;
memcpy(state->clientid + 2, ifp->hwaddr,
ifp->hwlen);
}
/* If we haven't specified a ClientID and our hardware address
* length is greater than BOOTP CHADDR then we enforce a ClientID
- * of the hardware address family and the hardware address.
+ * of the hardware address type and the hardware address.
* If there is no hardware address and no ClientID set,
* force a DUID based ClientID. */
if (ifp->hwlen > 16)
/* Firewire and InfiniBand interfaces require ClientID and
* the broadcast option being set. */
- switch (ifp->family) {
+ switch (ifp->hwtype) {
case ARPHRD_IEEE1394: /* FALLTHROUGH */
case ARPHRD_INFINIBAND:
ifp->options->options |= DHCPCD_CLIENTID | DHCPCD_BROADCAST;
unsigned int index;
unsigned int active;
unsigned int flags;
- sa_family_t family;
+ uint16_t hwtype; /* ARPHRD_ETHER for example */
unsigned char hwaddr[HWADDR_LEN];
uint8_t hwlen;
unsigned short vlanid;
u16 = htons(type);
memcpy(p, &u16, sizeof(u16));
p += sizeof(u16);
- u16 = htons(ifp->family);
+ u16 = htons(ifp->hwtype);
memcpy(p, &u16, sizeof(u16));
p += sizeof(u16);
if (type == DUID_LLT) {
if_setmac(struct interface *ifp, void *mac, uint8_t maclen)
{
struct ifreq ifr = {
- .ifr_hwaddr.sa_family = ifp->family,
+ .ifr_hwaddr.sa_family = ifp->hwtype,
};
if (ifp->hwlen != maclen || maclen > sizeof(ifr.ifr_hwaddr.sa_data)) {
if_noconf = ((argc == 0 || argc == -1) && ctx->ifac == 0 &&
!if_hasconf(ctx, spec.devname));
- /* Don't allow loopback or pointopoint unless explicit.
- * Don't allow some reserved interface names unless explicit. */
- if (if_noconf) {
- if (ifa->ifa_flags & (IFF_LOOPBACK | IFF_POINTOPOINT) ||
- if_ignore(ctx, spec.devname))
- active = IF_INACTIVE;
- }
+ /* Don't allow some reserved interface names unless explicit. */
+ if (if_noconf && if_ignore(ctx, spec.devname))
+ active = IF_INACTIVE;
ifp = calloc(1, sizeof(*ifp));
if (ifp == NULL) {
#ifdef IFT_TUNNEL
case IFT_TUNNEL: /* FALLTHROUGH */
#endif
+ case IFT_LOOP: /* FALLTHROUGH */
case IFT_PPP:
/* Don't allow unless explicit */
if (if_noconf) {
case IFT_L3IPVLAN: /* FALLTHROUGH */
#endif
case IFT_ETHER:
- ifp->family = ARPHRD_ETHER;
+ ifp->hwtype = ARPHRD_ETHER;
break;
#ifdef IFT_IEEE1394
case IFT_IEEE1394:
- ifp->family = ARPHRD_IEEE1394;
+ ifp->hwtype = ARPHRD_IEEE1394;
break;
#endif
#ifdef IFT_INFINIBAND
case IFT_INFINIBAND:
- ifp->family = ARPHRD_INFINIBAND;
+ ifp->hwtype = ARPHRD_INFINIBAND;
break;
#endif
default:
" interface type 0x%.2x",
ifp->name, sdl->sdl_type);
/* Pretend it's ethernet */
- ifp->family = ARPHRD_ETHER;
+ ifp->hwtype = ARPHRD_ETHER;
break;
}
ifp->hwlen = sdl->sdl_alen;
#elif AF_PACKET
sll = (const void *)ifa->ifa_addr;
ifp->index = (unsigned int)sll->sll_ifindex;
- ifp->family = sll->sll_hatype;
+ ifp->hwtype = sll->sll_hatype;
ifp->hwlen = sll->sll_halen;
if (ifp->hwlen != 0)
memcpy(ifp->hwaddr, sll->sll_addr, ifp->hwlen);
-#endif
- }
-#ifdef SIOCGIFHWADDR
- else {
- /* This is a huge bug in getifaddrs(3) as there
- * is no reason why this can't be returned in
- * ifa_addr. */
- memset(&ifr, 0, sizeof(ifr));
- strlcpy(ifr.ifr_name, ifa->ifa_name,
- sizeof(ifr.ifr_name));
- if (ioctl(ctx->pf_inet_fd, SIOCGIFHWADDR, &ifr) == -1)
- logerr("%s: SIOCGIFHWADDR", ifa->ifa_name);
- ifp->family = ifr.ifr_hwaddr.sa_family;
- if (ioctl(ctx->pf_inet_fd, SIOCGIFINDEX, &ifr) == -1)
- logerr("%s: SIOCGIFINDEX", ifa->ifa_name);
- ifp->index = (unsigned int)ifr.ifr_ifindex;
- }
-#endif
- /* Ensure hardware address is valid. */
- if (!if_valid_hwaddr(ifp->hwaddr, ifp->hwlen))
- ifp->hwlen = 0;
-
- /* We only work on ethernet by default */
- if (ifp->family != ARPHRD_ETHER) {
- if ((argc == 0 || argc == -1) &&
- ctx->ifac == 0 && !if_hasconf(ctx, ifp->name))
- active = IF_INACTIVE;
- switch (ifp->family) {
- case ARPHRD_IEEE1394:
- case ARPHRD_INFINIBAND:
-#ifdef ARPHRD_LOOPBACK
+ switch(ifp->hwtype) {
+ case ARPHRD_ETHER: /* FALLTHROUGH */
+ case ARPHRD_IEEE1394: /* FALLTHROUGH */
+ case ARPHRD_INFINIBAND: /* FALLTHROUGH */
+ case ARPHRD_NONE: /* FALLTHROUGH */
+ break;
case ARPHRD_LOOPBACK:
-#endif
-#ifdef ARPHRD_PPP
case ARPHRD_PPP:
-#endif
-#ifdef ARPHRD_NONE
- case ARPHRD_NONE:
-#endif
- /* We don't warn for supported families */
+ if (if_noconf) {
+ logdebugx("%s: ignoring due to"
+ " interface type and"
+ " no config",
+ ifp->name);
+ active = IF_INACTIVE;
+ }
break;
-
-/* IFT already checked */
-#ifndef AF_LINK
default:
if (active)
logwarnx("%s: unsupported"
- " interface family 0x%.2x",
- ifp->name, ifp->family);
+ " interface type 0x%.2x",
+ ifp->name, ifp->hwtype);
break;
-#endif
}
+#endif
}
if (!(ctx->options & (DHCPCD_DUMPLEASE | DHCPCD_TEST))) {
/* Check sanity before malloc */
if (!(ifp->options->options & DHCPCD_SLAACPRIVATE)) {
- switch (ifp->family) {
+ switch (ifp->hwtype) {
case ARPHRD_ETHER:
/* Check for a valid hardware address */
if (ifp->hwlen != 6 && ifp->hwlen != 8) {
ap->dadcounter = dadcounter;
} else {
memcpy(ap->addr.s6_addr, ap->prefix.s6_addr, 8);
- switch (ifp->family) {
+ switch (ifp->hwtype) {
case ARPHRD_ETHER:
if (ifp->hwlen == 6) {
ap->addr.s6_addr[ 8] = ifp->hwaddr[0];