root/drivers/net/dummy.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. dummy_init
  2. dummy_xmit
  3. dummy_get_stats

   1 /* dummy.c: a dummy net driver
   2 
   3         The purpose of this driver is to provide a device to point a
   4         route through, but not to actually transmit packets.
   5 
   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.
  10 
  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
  14         
  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
  20 
  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.
  25 
  26                         Nick Holloway, 27th May 1994
  27         [I tweaked this explanation a little but thats all]
  28                         Alan Cox, 30th May 1994
  29 */
  30 
  31 /* To have statistics (just packets sent) define this */
  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)
     /* [previous][next][first][last][top][bottom][index][help] */
  62 {
  63 /* I commented this out as bootup is noisy enough anyway and this driver
  64    seems pretty reliable 8) 8) 8) */
  65 /*      printk ( KERN_INFO "Dummy net driver (94/05/27 v1.0)\n" ); */
  66 
  67         /* Initialize the device structure. */
  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         /* Fill in the fields of the device structure with ethernet-generic values. */
  77         ether_setup(dev);
  78 
  79         return 0;
  80 }
  81 
  82 static int
  83 dummy_xmit(struct sk_buff *skb, struct device *dev)
     /* [previous][next][first][last][top][bottom][index][help] */
  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)
     /* [previous][next][first][last][top][bottom][index][help] */
 105 {
 106         struct enet_statistics *stats = (struct enet_statistics*) dev->priv;
 107         return stats;
 108 }
 109 #endif

/* [previous][next][first][last][top][bottom][index][help] */