snull.c
上传用户:wudi5211
上传日期:2010-01-21
资源大小:607k
文件大小:12k
- /*
- * snull.c -- the Simple Network Utility
- *
- * Tested with 2.0 on the x86, Sparc
- */
- #ifndef __KERNEL__
- # define __KERNEL__
- #endif
- #ifndef MODULE
- # define MODULE
- #endif
- #define __NO_VERSION__ /* don't define kernel_verion in module.h */
- #include <linux/module.h>
- #include <linux/version.h>
- char kernel_version [] = UTS_RELEASE;
- #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/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 <asm/checksum.h>
- #include "snull.h"
- /* This is a load-time options */
- static int eth = 0; /* Call yourself "ethX". Default is "sn0"/"sn1" */
- 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 enet_statistics stats;
- int packetlen;
- int status;
- u8 *packetdata;
- };
- extern struct device snull_devs[];
-
- /*
- * Open and close
- */
- int snull_open(struct device *dev)
- {
- int i;
- /* request_region(), request_irq(), .... (like fops->open) */
- #if 0
- /*
- * 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. Seel snull_interrupt below.
- */
- irq2dev_map[dev->irq] = dev;
- #endif
- /*
- * Assign the hardware address of the board: use "