snull.c
上传用户:wudi5211
上传日期:2010-01-21
资源大小:607k
文件大小:16k
- /*
- * snull.c -- the Simple Network Utility
- *
- * $Id: snull.c,v 1.15 2001/07/11 08:51:51 rubini Exp $
- */
- #ifndef __KERNEL__
- # define __KERNEL__
- #endif
- #ifndef MODULE
- # define MODULE
- #endif
- #include <linux/config.h>
- #include <linux/module.h>
- #include <linux/sched.h>
- #include <linux/kernel.h> /* printk() */
- #include <linux/malloc.h> /* kmalloc() */
- #include <linux/errno.h> /* error codes */
- #include <linux/types.h> /* size_t */
- #include <linux/interrupt.h> /* mark_bh */
- #include <linux/in.h>
- #include <linux/netdevice.h> /* struct device, and other headers */
- #include <linux/etherdevice.h> /* eth_type_trans */
- #include <linux/ip.h> /* struct iphdr */
- #include <linux/tcp.h> /* struct tcphdr */
- #include <linux/skbuff.h>
- #include "snull.h"
- #ifdef LINUX_20
- # include <linux/if_ether.h>
- # define net_device_stats enet_statistics
- #else
- # include <linux/in6.h>
- #endif
- #include <asm/checksum.h>
- MODULE_AUTHOR("Alessandro Rubini");
- /* This is a load-time options */
- static int eth = 0; /* Call yourself "ethX". Default is "sn0"/"sn1" */
- MODULE_PARM(eth, "i");
- /*
- * Transmitter lockup simulation, normally disabled.
- */
- static int lockup = 0;
- MODULE_PARM(lockup, "i");
- #ifdef HAVE_TX_TIMEOUT
- static int timeout = SNULL_TIMEOUT;
- MODULE_PARM(timeout, "i");
- #endif
- int snull_eth;
- /*
- * This structure is private to each device. It is used to pass
- * packets in and out, so there is place for a packet
- */
- struct snull_priv {
- struct net_device_stats stats;
- int status;
- int rx_packetlen;
- u8 *rx_packetdata;
- int tx_packetlen;
- u8 *tx_packetdata;
- struct sk_buff *skb;
- spinlock_t lock;
- };
- extern struct net_device snull_devs[];
- void snull_tx_timeout (struct net_device *dev);
-
- /*
- * Open and close
- */
- int snull_open(struct net_device *dev)
- {
- MOD_INC_USE_COUNT;
-
- /* request_region(), request_irq(), .... (like fops->open) */
- #if 0 && defined(LINUX_20)
- /*
- * We have no irq line, otherwise this assignment can be used to
- * grab a non-shared interrupt. To share interrupt lines use
- * the dev_id argument of request_irq. See snull_interrupt below.
- */
- irq2dev_map[dev->irq] = dev;
- #endif
- /*
- * Assign the hardware address of the board: use "