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
79 return 0;
80 }
81
82 static int
83 dummy_xmit(struct sk_buff *skb, struct device *dev)
84 {
85 #if DUMMY_STATS
86 struct enet_statistics *stats;
87 #endif
88
89 if (skb == NULL || dev == NULL)
90 return 0;
91
92 dev_kfree_skb(skb, FREE_WRITE);
93
94 #if DUMMY_STATS
95 stats = (struct enet_statistics *)dev->priv;
96 stats->tx_packets++;
97 #endif
98
99 return 0;
100 }
101
102 #if DUMMY_STATS
103 static struct enet_statistics *
104 dummy_get_stats(struct device *dev)
105 {
106 struct enet_statistics *stats = (struct enet_statistics*) dev->priv;
107 return stats;
108 }
109 #endif