This source file includes following definitions.
- loopback_xmit
- loopback_init
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
43 #include <linux/config.h>
44 #include <linux/kernel.h>
45 #include <linux/sched.h>
46 #include <linux/fs.h>
47 #include <linux/tty.h>
48 #include <linux/types.h>
49 #include <linux/ptrace.h>
50 #include <linux/string.h>
51 #include <asm/system.h>
52 #include <asm/segment.h>
53 #include <asm/io.h>
54 #include <errno.h>
55 #include <linux/fcntl.h>
56 #include <netinet/in.h>
57
58 #include "dev.h"
59 #include "eth.h"
60 #include "timer.h"
61 #include "ip.h"
62 #include "tcp.h"
63 #include "sock.h"
64 #include "arp.h"
65
66 #ifdef PRINTK
67 #undef PRINTK
68 #endif
69
70 #ifdef LOOPBACK_DEBUG
71 #define PRINTK(x) printk x
72 #else
73 #define PRINTK(x)
74 #endif
75
76 static int
77 loopback_xmit(struct sk_buff *skb, struct device *dev)
78 {
79 static int inuse=0;
80 struct enet_header *eth;
81 int i;
82 int done;
83 static unsigned char buff[2048];
84 unsigned char *tmp;
85
86 PRINTK (("loopback_xmit (dev = %X)\n", dev));
87 cli();
88 if (inuse)
89 {
90 sti();
91 return (1);
92 }
93 inuse = 1;
94 sti();
95
96 done = -1;
97 while (done == -1)
98 done = dev_rint ((unsigned char *)(skb+1), skb->len, 0, dev);
99
100 if (skb->free)
101 kfree_skb (skb, FREE_WRITE);
102
103 tmp = NULL;
104 i = 0;
105 while (done != 1)
106 {
107 if (done != -1 && (i = dev_tint (buff,dev)) != 0)
108 {
109
110 PRINTK (("loopback xmit: \n"));
111 eth = (struct enet_header *)buff;
112 print_eth (eth);
113 tmp = buff;
114 done = dev_rint (buff, i, 0, dev);
115 if (done != -1)
116 {
117 tmp = NULL;
118 i = 0;
119 }
120 }
121 else
122 {
123 if (i == 0) tmp = NULL;
124 done = dev_rint (tmp, i, 0, dev);
125 }
126
127 }
128 inuse = 0;
129 return (0);
130 }
131
132 int
133 loopback_init(struct device *dev)
134 {
135 printk ("Loopback device init\n");
136
137 dev->mtu = 2000;
138 dev->hard_start_xmit = loopback_xmit;
139 dev->open = NULL;
140 dev->hard_header = eth_hard_header;
141 dev->add_arp = NULL;
142 dev->hard_header_len = sizeof (struct enet_header);
143 dev->addr_len = ETHER_ADDR_LEN;
144 dev->type = ETHER_TYPE;
145 dev->queue_xmit = dev_queue_xmit;
146 dev->rebuild_header = eth_rebuild_header;
147 dev->type_trans = eth_type_trans;
148 dev->loopback = 1;
149 return (0);
150 }