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