# A patch to add complete support for the BIOCSHDRCMPLT ioctl to Mac OS X # Jaguar (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-jaguar.patch # # Then, build the kernel and install it as you normally would. --- bsd/net/ether_if_module.c.orig Fri Oct 24 18:25:55 2003 +++ bsd/net/ether_if_module.c Tue Nov 18 00:14:46 2003 @@ -438,6 +438,8 @@ char *ether_type; { register struct ether_header *eh; + int hdrcmplt = 0; + u_char esrc[6]; int hlen; /* link layer header lenght */ 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; }