This source file includes following definitions.
- print_eth
- eth_hard_header
- eth_rebuild_header
- eth_add_arp
- eth_type_trans
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 #include <asm/segment.h>
43 #include <asm/system.h>
44 #include <linux/types.h>
45 #include <linux/kernel.h>
46 #include <linux/sched.h>
47 #include <linux/string.h>
48 #include <linux/mm.h>
49 #include <linux/socket.h>
50 #include <netinet/in.h>
51 #include "dev.h"
52 #include "eth.h"
53 #include "timer.h"
54 #include "ip.h"
55 #include "tcp.h"
56 #include "sock.h"
57 #include <linux/errno.h>
58 #include "arp.h"
59
60 #undef ETH_DEBUG
61 #ifdef ETH_DEBUG
62 #define PRINTK(x) printk x
63 #else
64 #define PRINTK(x)
65 #endif
66
67 void
68 print_eth (struct enet_header *eth)
69 {
70 int i;
71 PRINTK (("ether source addr: "));
72 for (i =0 ; i < ETHER_ADDR_LEN; i++)
73 {
74 PRINTK (("0x%2X ",eth->saddr[i]));
75 }
76 PRINTK (("\n"));
77
78 PRINTK (("ether dest addr: "));
79 for (i =0 ; i < ETHER_ADDR_LEN; i++)
80 {
81 PRINTK (("0x%2X ",eth->daddr[i]));
82 }
83 PRINTK (("\n"));
84 PRINTK (("ethertype = %X\n",net16(eth->type)));
85 }
86
87 int
88 eth_hard_header (unsigned char *buff, struct device *dev,
89 unsigned short type, unsigned long daddr,
90 unsigned long saddr, unsigned len)
91 {
92 struct enet_header *eth;
93 eth = (struct enet_header *)buff;
94 eth->type = net16(type);
95 memcpy (eth->saddr, dev->dev_addr, dev->addr_len);
96 if (daddr == 0)
97 {
98 memset (eth->daddr, 0xff, dev->addr_len);
99 return (14);
100 }
101 if (!arp_find (eth->daddr, daddr, dev, saddr))
102 {
103 return (14);
104 }
105 else
106 {
107 *(unsigned long *)eth->saddr = saddr;
108 return (-14);
109 }
110 }
111
112 int
113 eth_rebuild_header (void *buff, struct device *dev)
114 {
115 struct enet_header *eth;
116 eth = buff;
117 if (arp_find(eth->daddr, *(unsigned long*)eth->daddr, dev,
118 *(unsigned long *)eth->saddr))
119 return (1);
120 memcpy (eth->saddr, dev->dev_addr, dev->addr_len);
121 return (0);
122 }
123
124 void
125 eth_add_arp (unsigned long addr, struct sk_buff *skb, struct device *dev)
126 {
127 struct enet_header *eh;
128 eh = (struct enet_header *)(skb + 1);
129 arp_add (addr, eh->saddr, dev);
130 }
131
132 unsigned short
133 eth_type_trans (struct sk_buff *skb, struct device *dev)
134 {
135 struct enet_header *eh;
136 eh = (struct enet_header *)(skb + 1);
137 return (eh->type);
138 }