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