OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / lib / Libnet / support / bpf-lkm / FreeBSD / 4.0-ether.diff
1 #
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>
6 #
7 # Specify Source Hardware Address Patch (FreeBSD 4.0)
8 #
9 # This patch enables you to specify a source ethernet address other than your
10 # own when creating custom ethernet packets.
11 #
12 # To use, copy the patch into /sys/net. Create a backup of if_ethersubr.c,
13 # then: patch < diff.if_ethersubr.c
14 #
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:
17
18 Index: if_ethersubr.c
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
25 ***************
26 *** 95,100 ****
27 --- 95,105 ----
28   extern u_char aarp_org_code[3];
29   #endif /* NETATALK */
30   
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, "");
35
36   #ifdef BRIDGE
37   #include <net/bridge.h>
38   #endif
39 ***************
40 *** 318,323 ****
41 --- 323,330 ----
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;
48                 break;
49   
50 ***************
51 *** 338,344 ****
52         (void)memcpy(&eh->ether_type, &type,
53                 sizeof(eh->ether_type));
54         (void)memcpy(eh->ether_dhost, edst, sizeof (edst));
55 !       if (hdrcmplt)
56                 (void)memcpy(eh->ether_shost, esrc,
57                         sizeof(eh->ether_shost));
58         else
59 --- 345,351 ----
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));
66         else