2 # $Id: diff.if_ethersubr.c,v 1.1.1.1 2000/05/25 00:28:49 route Exp $
4 # Libnet FreeBSD source etheraddr patch
5 # (c) 1999 Nicholas Brawn <nick@feralmonkey.org>
6 # (c) 1998, 1999 Mike D. Schiffman <mike@infonexus.com>
7 # route|daemon9 <route@infonexus.com>
9 # Specify Source Hardware Address Patch (FreeBSD 3.x)
11 # This patch enables you to specify a source ethernet address other than your
12 # own when creating custom ethernet packets.
14 # To use, copy the patch into /sys/net. Create a backup of if_ethersubr.c,
15 # then: patch < diff.if_ethersubr.c
17 # Recompile your kernel and reboot. You will now have a new sysctl MIB,
18 # net.link.ether.inet.specify_src_hwaddr. To use, you must set it to > 0:
20 # root@kungfu:~# sysctl -w net.link.ether.inet.specify_src_hwaddr=1
21 # net.link.ether.inet.specify_src_hwaddr: 0 -> 1
26 *** if_ethersubr.c.orig Mon May 24 20:57:44 1999
27 --- if_ethersubr.c Sun May 30 15:40:15 1999
31 #include <net/if_vlan_var.h>
32 #endif /* NVLAN > 0 */
34 + static int specify_src_hwaddr = 0;
35 + SYSCTL_INT(_net_link_ether_inet, OID_AUTO, specify_src_hwaddr, CTLFLAG_RW,
36 + &specify_src_hwaddr, 0, "");
38 static int ether_resolvemulti __P((struct ifnet *, struct sockaddr **,
40 u_char etherbroadcastaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
48 register struct mbuf *m = m0;
49 register struct rtentry *rt;
50 register struct ether_header *eh;
54 loop_copy = -1; /* if this is for us, don't do it */
55 eh = (struct ether_header *)dst->sa_data;
56 (void)memcpy(edst, eh->ether_dhost, sizeof (edst));
57 + if (specify_src_hwaddr)
58 + (void)memcpy(esrc, eh->ether_shost, sizeof (esrc));
59 type = eh->ether_type;
64 (void)memcpy(&eh->ether_type, &type,
65 sizeof(eh->ether_type));
66 (void)memcpy(eh->ether_dhost, edst, sizeof (edst));
67 ! (void)memcpy(eh->ether_shost, ac->ac_enaddr,
68 sizeof(eh->ether_shost));
72 (void)memcpy(&eh->ether_type, &type,
73 sizeof(eh->ether_type));
74 (void)memcpy(eh->ether_dhost, edst, sizeof (edst));
75 ! if (specify_src_hwaddr)
76 ! (void)memcpy(eh->ether_shost, esrc, sizeof(esrc));
78 ! (void)memcpy(eh->ether_shost, ac->ac_enaddr,
79 sizeof(eh->ether_shost));