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