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