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