# This is the patch from . # I just made it aply cleanly against xnu 517.7.7 # -fkr (fkr@opendarwin.org) # Original README: # A patch to add complete support for the BIOCSHDRCMPLT ioctl to Mac OS X # Panther (Darwin). This is also known as ETHERSPOOF. # # This patch improves the functionality provided in the ETHERSPOOF patch # by Peter Bartoli. NOTE: This patch is incompatible with the ETHERSPOOF patch. # # Instead of (potentially) altering the source Ethernet address of all # AF_UNSPEC packets, this patch only affects packets when the BIOCSHDRCMPLT # ioctl is used. In other words, this won't break dhcp. # # apply in the top level xnu-xxx source directory: # patch -p0 -b --verbose --suffix=.orig < BIOCSHDRCMPLT-panther.patch # # Then, build the kernel and install it as you normally would. --- bsd/net/ether_if_module.c.orig Tue Jul 13 22:08:32 2004 +++ bsd/net/ether_if_module.c Tue Jul 13 18:51:54 2004 @@ -438,6 +438,8 @@ char *ether_type; { register struct ether_header *eh; + int hdrcmplt = 0; + u_char esrc[6]; int hlen; /* link layer header length */ struct arpcom *ac = IFP2AC(ifp); @@ -485,12 +487,22 @@ } + if (ndest->sa_family == pseudo_AF_HDRCMPLT) + { + hdrcmplt = 1; + eh = (struct ether_header *)ndest->sa_data; + memcpy((u_char *)esrc, (u_char *)eh->ether_shost, sizeof(esrc)); + } + eh = mtod(*m, struct ether_header *); (void)memcpy(&eh->ether_type, ether_type, sizeof(eh->ether_type)); (void)memcpy(eh->ether_dhost, edst, 6); - (void)memcpy(eh->ether_shost, ac->ac_enaddr, - sizeof(eh->ether_shost)); + if (hdrcmplt) + (void)memcpy(eh->ether_shost, esrc, sizeof(eh->ether_shost)); + else + (void)memcpy(eh->ether_shost, ac->ac_enaddr, + sizeof(eh->ether_shost)); return 0; } --- bsd/net/ether_inet_pr_module.c.orig Tue Jul 13 22:09:14 2004 +++ bsd/net/ether_inet_pr_module.c Tue Jul 13 18:48:26 2004 @@ -278,6 +278,7 @@ *(u_short *)type = htons(ETHERTYPE_IP); break; + case pseudo_AF_HDRCMPLT: case AF_UNSPEC: m->m_flags &= ~M_LOOP; eh = (struct ether_header *)dst_netaddr->sa_data;