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