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 #include <linux/config.h>
23 #include <linux/kernel.h>
24 #include <linux/sched.h>
25 #include <linux/fs.h>
26 #include <linux/tty.h>
27 #include <linux/types.h>
28 #include <linux/ptrace.h>
29 #include <asm/system.h>
30 #include <asm/segment.h>
31 #include <asm/io.h>
32 #include <asm/memory.h>
33 #include <errno.h>
34 #include <linux/fcntl.h>
35 #include <netinet/in.h>
36
37 #include "dev.h"
38 #include "eth.h"
39 #include "timer.h"
40 #include "ip.h"
41 #include "tcp.h"
42 #include "sock.h"
43 #include "arp.h"
44
45 #include "../kern_sock.h"
46
47
48
49 static int
50 loopback_xmit(struct sk_buff *skb, struct device *dev)
51 {
52 static int inuse=0;
53 struct enet_header *eth;
54 int i;
55 int done;
56 static unsigned char buff[2048];
57 unsigned char *tmp;
58
59 PRINTK ("loopback_xmit (dev = %X)\n", dev);
60 cli();
61 if (inuse)
62 {
63 sti();
64 return (1);
65 }
66 inuse = 1;
67 sti();
68 tmp = NULL;
69 done = dev_rint ((unsigned char *)(skb+1), skb->len, 0, dev);
70
71 if (skb->free)
72 free_skb (skb, FREE_WRITE);
73
74 while (done != 1)
75 {
76 if (done != -1 && (i = dev_tint (buff,dev)) != 0)
77 {
78
79 PRINTK ("ethernet xmit: \n");
80 eth = (struct enet_header *)buff;
81 print_eth (eth);
82 tmp = buff;
83 done = dev_rint (buff, i, 0, dev);
84 if (done != -1) tmp = NULL;
85 }
86 else
87 {
88 done = dev_rint (tmp, 0, 0, dev);
89 }
90
91 }
92 inuse = 0;
93 return (0);
94 }
95
96 void
97 loopback_init(struct device *dev)
98 {
99 printk ("Loopback device init\n");
100
101 dev->mtu = 2000;
102 dev->hard_start_xmit = loopback_xmit;
103 dev->open = NULL;
104 dev->hard_header = eth_hard_header;
105 dev->add_arp = NULL;
106 dev->hard_header_len = sizeof (struct enet_header);
107 dev->addr_len = ETHER_ADDR_LEN;
108 dev->type = ETHER_TYPE;
109 dev->queue_xmit = dev_queue_xmit;
110 dev->rebuild_header = eth_rebuild_header;
111 dev->type_trans = eth_type_trans;
112 dev->loopback = 1;
113 }