This source file includes following definitions.
- dummy_init
- dummy_xmit
- dummy_get_stats
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 #undef DUMMY_STATS
33
34 #include <linux/config.h>
35 #include <linux/kernel.h>
36 #include <linux/sched.h>
37 #include <linux/types.h>
38 #include <linux/fcntl.h>
39 #include <linux/interrupt.h>
40 #include <linux/ptrace.h>
41 #include <linux/ioport.h>
42 #include <linux/in.h>
43 #include <linux/malloc.h>
44 #include <linux/string.h>
45 #include <asm/system.h>
46 #include <asm/bitops.h>
47 #include <asm/io.h>
48 #include <asm/dma.h>
49 #include <linux/errno.h>
50
51 #include <linux/netdevice.h>
52 #include <linux/etherdevice.h>
53 #include <linux/skbuff.h>
54
55 static int dummy_xmit(struct sk_buff *skb, struct device *dev);
56 #ifdef DUMMY_STATS
57 static struct enet_statistics *dummy_get_stats(struct device *dev);
58 #endif
59
60 int
61 dummy_init(struct device *dev)
62 {
63
64
65
66
67
68 dev->hard_start_xmit = dummy_xmit;
69
70 #if DUMMY_STATS
71 dev->priv = kmalloc(sizeof(struct enet_statistics), GFP_KERNEL);
72 memset(dev->priv, 0, sizeof(struct enet_statistics));
73 dev->get_stats = dummy_get_stats;
74 #endif
75
76
77 ether_setup(dev);
78 dev->flags |= IFF_NOARP;
79
80 return 0;
81 }
82
83 static int
84 dummy_xmit(struct sk_buff *skb, struct device *dev)
85 {
86 #if DUMMY_STATS
87 struct enet_statistics *stats;
88 #endif
89
90 if (skb == NULL || dev == NULL)
91 return 0;
92
93 dev_kfree_skb(skb, FREE_WRITE);
94
95 #if DUMMY_STATS
96 stats = (struct enet_statistics *)dev->priv;
97 stats->tx_packets++;
98 #endif
99
100 return 0;
101 }
102
103 #if DUMMY_STATS
104 static struct enet_statistics *
105 dummy_get_stats(struct device *dev)
106 {
107 struct enet_statistics *stats = (struct enet_statistics*) dev->priv;
108 return stats;
109 }
110 #endif