OSDN Git Service

2013.10.24
[uclinux-h8/uClinux-dist.git] / lib / Libnet / support / bpf-lkm / FreeBSD / diff.if_ethersubr.c
1 #
2 #   $Id: diff.if_ethersubr.c,v 1.1.1.1 2000/05/25 00:28:49 route Exp $
3 #
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>
8 #
9 # Specify Source Hardware Address Patch (FreeBSD 3.x)
10 #
11 # This patch enables you to specify a source ethernet address other than your
12 # own when creating custom ethernet packets.  
13 #
14 # To use, copy the patch into /sys/net. Create a backup of if_ethersubr.c,
15 # then: patch < diff.if_ethersubr.c
16 #
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:
19 #
20 # root@kungfu:~# sysctl -w net.link.ether.inet.specify_src_hwaddr=1
21 # net.link.ether.inet.specify_src_hwaddr: 0 -> 1
22 # root@kungfu:~# 
23
24 # -Nicholas Brawn 
25
26 *** if_ethersubr.c.orig Mon May 24 20:57:44 1999
27 --- if_ethersubr.c      Sun May 30 15:40:15 1999
28 ***************
29 *** 111,116 ****
30 --- 111,120 ----
31   #include <net/if_vlan_var.h>
32   #endif /* NVLAN > 0 */
33   
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, ""); 
37
38   static        int ether_resolvemulti __P((struct ifnet *, struct sockaddr **, 
39                                     struct sockaddr *));
40   u_char        etherbroadcastaddr[6] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
41 ***************
42 *** 133,138 ****
43 --- 137,143 ----
44         short type;
45         int s, error = 0;
46         u_char edst[6];
47 +       u_char esrc[6];
48         register struct mbuf *m = m0;
49         register struct rtentry *rt;
50         register struct ether_header *eh;
51 ***************
52 *** 333,338 ****
53 --- 338,345 ----
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;
60                 break;
61   
62 ***************
63 *** 353,359 ****
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));
69   
70         /*
71 --- 360,369 ----
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));
77 !       else
78 !               (void)memcpy(eh->ether_shost, ac->ac_enaddr,
79             sizeof(eh->ether_shost));
80   
81         /*