More meth updates.
[linux-2.6/linux-mips.git] / drivers / net / dummy.c
blob7739a846cc19537e05170b1dedddbc0620c3a08f
1 /* dummy.c: a dummy net driver
3 The purpose of this driver is to provide a device to point a
4 route through, but not to actually transmit packets.
6 Why? If you have a machine whose only connection is an occasional
7 PPP/SLIP/PLIP link, you can only connect to your own hostname
8 when the link is up. Otherwise you have to use localhost.
9 This isn't very consistent.
11 One solution is to set up a dummy link using PPP/SLIP/PLIP,
12 but this seems (to me) too much overhead for too little gain.
13 This driver provides a small alternative. Thus you can do
15 [when not running slip]
16 ifconfig dummy slip.addr.ess.here up
17 [to go to slip]
18 ifconfig dummy down
19 dip whatever
21 This was written by looking at Donald Becker's skeleton driver
22 and the loopback driver. I then threw away anything that didn't
23 apply! Thanks to Alan Cox for the key clue on what to do with
24 misguided packets.
26 Nick Holloway, 27th May 1994
27 [I tweaked this explanation a little but that's all]
28 Alan Cox, 30th May 1994
31 /* To have statistics (just packets sent) define this */
33 #include <linux/config.h>
34 #include <linux/module.h>
35 #include <linux/kernel.h>
36 #include <linux/netdevice.h>
37 #include <linux/init.h>
39 static int dummy_xmit(struct sk_buff *skb, struct net_device *dev);
40 static struct net_device_stats *dummy_get_stats(struct net_device *dev);
42 /* fake multicast ability */
43 static void set_multicast_list(struct net_device *dev)
47 #ifdef CONFIG_NET_FASTROUTE
48 static int dummy_accept_fastpath(struct net_device *dev, struct dst_entry *dst)
50 return -1;
52 #endif
54 static void __init dummy_setup(struct net_device *dev)
56 /* Initialize the device structure. */
57 dev->get_stats = dummy_get_stats;
58 dev->hard_start_xmit = dummy_xmit;
59 dev->set_multicast_list = set_multicast_list;
60 #ifdef CONFIG_NET_FASTROUTE
61 dev->accept_fastpath = dummy_accept_fastpath;
62 #endif
64 /* Fill in device structure with ethernet-generic values. */
65 ether_setup(dev);
66 dev->tx_queue_len = 0;
67 dev->flags |= IFF_NOARP;
68 dev->flags &= ~IFF_MULTICAST;
69 SET_MODULE_OWNER(dev);
72 static int dummy_xmit(struct sk_buff *skb, struct net_device *dev)
74 struct net_device_stats *stats = dev->priv;
76 stats->tx_packets++;
77 stats->tx_bytes+=skb->len;
79 dev_kfree_skb(skb);
80 return 0;
83 static struct net_device_stats *dummy_get_stats(struct net_device *dev)
85 return dev->priv;
88 static struct net_device *dev_dummy;
90 static int __init dummy_init_module(void)
92 int err;
94 dev_dummy = alloc_netdev(sizeof(struct net_device_stats),
95 "dummy%d", dummy_setup);
97 if (!dev_dummy)
98 return -ENOMEM;
100 if ((err = register_netdev(dev_dummy))) {
101 kfree(dev_dummy);
102 dev_dummy = NULL;
104 return err;
107 static void __exit dummy_cleanup_module(void)
109 unregister_netdev(dev_dummy);
110 kfree(dev_dummy);
111 dev_dummy = NULL;
114 module_init(dummy_init_module);
115 module_exit(dummy_cleanup_module);
116 MODULE_LICENSE("GPL");