2 # Libnet FreeBSD source etheraddr patch
3 # (c) 2000 Matt Bing <matt@csis.gvsu.edu>
4 # (c) 1999 Nicholas Brawn <nick@feralmonkey.org>
5 # (c) 1998 - 2001 Mike D. Schiffman <mike@infonexus.com>
7 # Specify Source Hardware Address Patch (FreeBSD 4.0)
9 # This patch enables you to specify a source ethernet address other than your
10 # own when creating custom ethernet packets.
12 # To use, copy the patch into /sys/net. Create a backup of if_ethersubr.c,
13 # then: patch < diff.if_ethersubr.c
15 # Recompile your kernel and reboot. You will now have a new sysctl MIB,
16 # net.link.ether.inet.specify_src_hwaddr. To use, you must set it to > 0:
19 ===================================================================
20 RCS file: /home/ncvs/src/sys/net/if_ethersubr.c,v
21 retrieving revision 1.70.2.1
22 diff -c -r1.70.2.1 if_ethersubr.c
23 *** if_ethersubr.c 2000/05/01 01:04:41 1.70.2.1
24 --- if_ethersubr.c 2000/05/18 21:17:45
28 extern u_char aarp_org_code[3];
31 + static int specify_src_hwaddr; /* arbitrary ether src address */
32 + SYSCTL_DECL(_net_link_ether_inet);
33 + SYSCTL_INT(_net_link_ether_inet, OID_AUTO, specify_src_hwaddr, CTLFLAG_RW,
34 + &specify_src_hwaddr, 0, "");
37 #include <net/bridge.h>
42 loop_copy = -1; /* if this is for us, don't do it */
43 eh = (struct ether_header *)dst->sa_data;
44 (void)memcpy(edst, eh->ether_dhost, sizeof (edst));
45 + if(specify_src_hwaddr)
46 + (void)memcpy(esrc, eh->ether_shost, sizeof (esrc));
47 type = eh->ether_type;
52 (void)memcpy(&eh->ether_type, &type,
53 sizeof(eh->ether_type));
54 (void)memcpy(eh->ether_dhost, edst, sizeof (edst));
56 (void)memcpy(eh->ether_shost, esrc,
57 sizeof(eh->ether_shost));
60 (void)memcpy(&eh->ether_type, &type,
61 sizeof(eh->ether_type));
62 (void)memcpy(eh->ether_dhost, edst, sizeof (edst));
63 ! if (hdrcmplt || specify_src_hwaddr)
64 (void)memcpy(eh->ether_shost, esrc,
65 sizeof(eh->ether_shost));