亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? snull.c

?? LINUX設備驅動2源代碼
?? C
字號:
/* * snull.c --  the Simple Network Utility * */#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 "sysdep-2.1.h"#if LINUX_VERSION_CODE > VERSION_CODE(2,1,7)#  include <linux/in6.h>    /* needed by checksum.h */#endif#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 "\0SNULx", where     * x is 0 or 1. The first byte is '\0': a safe choice with regard     * to multicast     */    for (i=0; i < ETH_ALEN; i++)        dev->dev_addr[i] = "\0SNUL0"[i];    dev->dev_addr[ETH_ALEN-1] += (dev - snull_devs); /* the number */    dev->start = 1;    dev->tbusy = 0;    MOD_INC_USE_COUNT;    return 0;}int snull_release(struct device *dev){    /* release ports, irq and such -- like fops->close */    dev->start = 0;    dev->tbusy = 1; /* can't transmit any more */    MOD_DEC_USE_COUNT;    /* if irq2dev_map was used, zero the entry here */    return 0;}/* * Configuration changes (passed on by ifconfig) */int snull_config(struct device *dev, struct ifmap *map){    if (dev->flags & IFF_UP) /* can't act on a running interface */        return -EBUSY;    /* Don't allow changing the I/O address */    if (map->base_addr != dev->base_addr) {        printk(KERN_WARNING "snull: Can't change I/O address\n");        return -EOPNOTSUPP;    }    /* Allow changing the IRQ */    if (map->irq != dev->irq) {        dev->irq = map->irq;        /* request_irq() is delayed to open-time */    }    /* ignore other fields */    return 0;}/* * Receive a packet: retrieve, encapsulate and pass over to upper levels */void snull_rx(struct device *dev, int len, unsigned char *buf){    struct sk_buff *skb;    struct snull_priv *privp = (struct snull_priv *)dev->priv;    /*     * The packet has been retrieved from the transmission     * medium. Build an skb around it, so upper layers can handle it     */    skb = dev_alloc_skb(len+2);    if (!skb) {        printk("snull rx: low on mem\n");        return;    }    skb_reserve(skb, 2); /* align IP on 16B boundary */      memcpy(skb_put(skb, len), buf, len);    /* Write metadata, and then pass to the receive level */    skb->dev = dev;    skb->protocol = eth_type_trans(skb, dev);    skb->ip_summed = CHECKSUM_UNNECESSARY; /* don't check it */    privp->stats.rx_packets++;    netif_rx(skb);    return;}            /* * The typical interrupt entry point (1.3.70 and later) */void snull_interrupt(int irq, void *dev_id, struct pt_regs *regs){    int statusword;    struct snull_priv *privptr;    /*     * As usual, check the "device" pointer for shared handlers.     * Then assign "struct device *dev"     */#if 0    /* This is the way to do things for non-shared handlers */    struct device *dev = (struct device *)(irq2dev_map[irq]);#else    /* Otherwise use this SA_SHIRQ-safe approach */    struct device *dev = (struct device *)dev_id;    /* ... and check with hw if it's really ours */#endif    if (!dev /*paranoid*/ ) return;    dev->interrupt = 1; /* lock */    /* retrieve statusword: real netdevices use inb() or inw() */    privptr = (struct snull_priv *)(dev->priv);    statusword = privptr->status;    if (statusword & SNULL_RX_INTR) {        /* send it to snull_rx for handling */        snull_rx(dev, privptr->packetlen, privptr->packetdata);    }    if (statusword & SNULL_TX_INTR) {        /* a transmission is over: tell we are no more busy */        privptr->stats.tx_packets++;        dev->tbusy = 0;        mark_bh(NET_BH);    }    dev->interrupt = 0; /* release lock */    return;}/* * Transmit a packet (low level interface) */void snull_hw_tx(char *buf, int len, struct device *dev){    /*     * This function deals with hw details. This interface loops     * back the packet to the other snull interface (if any).     * In other words, this function implements the snull behaviour,     * while all other procedures are rather device-independent     */    struct iphdr *ih;    struct device *dest;    struct snull_priv *privp;    u32 *saddr, *daddr;    /* I am paranoid. Ain't I? */    if (len < sizeof(struct ethhdr) + sizeof(struct iphdr)) {        printk("snull: Hmm... packet too short (%i octets)\n",               len);        return;    }    if (0) { /* enable this conditional to look at all the data */        int i;        PDEBUG("snull: len is %i\n" KERN_DEBUG "data:",len);        for (i=14 ; i<len; i++)            printk(" %02x",buf[i]&0xff);        printk("\n");    }    /*     * Ethhdr is 14 bytes, but the kernel arranges for iphdr     * to be aligned (i.e., ethhdr is unaligned)     */    ih = (struct iphdr *)(buf+sizeof(struct ethhdr));    saddr = &ih->saddr;    daddr = &ih->daddr;    ((u8 *)saddr)[2] ^= 1; /* change the third octet (class C) */    ((u8 *)daddr)[2] ^= 1;    ih->check = 0;         /* and rebuild the checksum (ip needs it) */    ih->check = ip_fast_csum((unsigned char *)ih,ih->ihl);    if (dev == snull_devs)        PDEBUGG("%08lx:%05i --> %08lx:%05i\n",               ntohl(ih->saddr),ntohs(((struct tcphdr *)(ih+1))->source),               ntohl(ih->daddr),ntohs(((struct tcphdr *)(ih+1))->dest));    else        PDEBUGG("%08lx:%05i <-- %08lx:%05i\n",               ntohl(ih->daddr),ntohs(((struct tcphdr *)(ih+1))->dest),               ntohl(ih->saddr),ntohs(((struct tcphdr *)(ih+1))->source));    /*     * Ok, now the packet is ready for transmission: first send a     * receive interrupt on the twin device, then send a     * transmission-done to the transmitting device     */    dest = snull_devs + (dev==snull_devs ? 1 : 0);    privp = (struct snull_priv *)dest->priv;    privp->status = SNULL_RX_INTR;    privp->packetlen = len;    privp->packetdata = buf;    snull_interrupt(0, dest, NULL);    privp = (struct snull_priv *)dev->priv;    privp->status = SNULL_TX_INTR;    snull_interrupt(0, dev, NULL);}/* * Transmit a packet (called by the kernel) */int snull_tx(struct sk_buff *skb, struct device *dev){    int len, retval=0;    char *data;    if (dev->tbusy) {/* shouldn't happen */        retval = -EBUSY;        goto tx_done;    }    if (skb == NULL) {        PDEBUG("tint for %p\n",dev);        dev_tint(dev); /* we are ready to transmit */        return 0;    }    dev->tbusy = 1; /* transmission is busy */    len = ETH_ZLEN < skb->len ? skb->len : ETH_ZLEN; /* minimum len */    data = skb->data;    dev->trans_start = jiffies; /* save the timestamp */    /* actual deliver of data is device-specific, and not shown here */    snull_hw_tx(data, len, dev);  tx_done:    dev_kfree_skb(skb, FREE_WRITE); /* release it */    return retval; /* zero == done; nonzero == fail */}/* * Ioctl commands  */int snull_ioctl(struct device *dev, struct ifreq *rq, int cmd){     PDEBUG("ioctl\n");    return 0;}/* * Return statistics to the caller */struct enet_statistics *snull_stats(struct device *dev){    struct snull_priv *priv = (struct snull_priv *)dev->priv;    return &priv->stats;}/* * This function is called to fill up an eth header, since arp is not * available on the interface */#ifdef __USE_OLD_REBUILD_HEADER__int snull_rebuild_header(void *buff, struct device *dev, unsigned long dst,		    struct sk_buff *skb){    struct ethhdr *eth = (struct ethhdr *)buff;#elseint snull_rebuild_header(struct sk_buff *skb){    struct device *dev = skb->dev;    struct ethhdr *eth = (struct ethhdr *)skb->data;#endif    memcpy(eth->h_source, dev->dev_addr, dev->addr_len);    memcpy(eth->h_dest, dev->dev_addr, dev->addr_len);    eth->h_dest[ETH_ALEN-1]   ^= 0x01;   /* dest is us xor 1 */    return 0;}/* * The "change_mtu" method is usually not needed. * If you need it, it must be like this. */int snull_change_mtu(struct device *dev, int new_mtu){    /* chack ranges */    if ((new_mtu < 68) || (new_mtu > 1500))        return -EINVAL;    /*     * Do anything you need, and the accept the value     */    dev->mtu = new_mtu;    return 0; /* success */}/* * The init function (sometimes called probe). * It is invoked by register_netdev() */int snull_init(struct device *dev){#if 0    /*     * Make the usual checks: check_region(), probe irq, ...  -ENODEV     * should be returned if no device found.  No resource should be     * grabbed: this is done on open().      */#endif    /*      * Then, assign other fields in dev, using ether_setup() and some     * hand assignments     */    ether_setup(dev); /* assign some of the fields */    dev->open            = snull_open;    dev->stop            = snull_release;    dev->set_config      = snull_config;    dev->hard_start_xmit = snull_tx;    dev->do_ioctl        = snull_ioctl;    dev->get_stats       = snull_stats;    dev->change_mtu      = snull_change_mtu;      dev->rebuild_header = snull_rebuild_header;    /* keep the default flags, just add NOARP */    dev->flags           |= IFF_NOARP;    /*     * Then, allocate the priv field. This encloses the statistics     * and a few private fields.     */    dev->priv = kmalloc(sizeof(struct snull_priv), GFP_KERNEL);    if (dev->priv == NULL)        return -ENOMEM;    memset(dev->priv, 0, sizeof(struct snull_priv));    return 0;}/* * The devices */char snull_names[16]; /* two eight-byte buffers */struct device snull_devs[2] = {    {        snull_names, /* name -- set at load time */        0, 0, 0, 0,  /* shmem addresses */        0x000,       /* ioport */        0,           /* irq line */        0, 0, 0,     /* various flags: init to 0 */        NULL,        /* next ptr */        snull_init,  /* init function, fill other fields with NULL's */    },    {        snull_names+8,/* name -- set at load time */        0, 0, 0, 0,  /* shmem addresses */        0x000,       /* ioport */        0,           /* irq line */        0, 0, 0,     /* various flags: init to 0 */        NULL,        /* next ptr */        snull_init,  /* init function, fill other fields with NULL's */    }};/* * Finally, the module stuff */int init_module(void){    int result, i, device_present = 0;    snull_eth = eth; /* copy the cfg datum in the non-static place */    if (!snull_eth) { /* call them "sn0" and "sn1" */        memcpy(snull_devs[0].name, "sn0", 4);        memcpy(snull_devs[1].name, "sn1", 4);    } else { /* use automatic assignment */        snull_devs[0].name[0] = snull_devs[1].name[0] = ' ';    }    for (i=0; i<2;  i++)        if ( (result = register_netdev(snull_devs + i)) )            printk("snull: error %i registering device \"%s\"\n",                   result, snull_devs[i].name);        else device_present++;#ifndef SNULL_DEBUG    REGISTER_SYMTAB(NULL); /* hide symbols */#endif    return device_present ? 0 : -ENODEV;}void cleanup_module(void){    int i;       for (i=0; i<2;  i++) {        kfree(snull_devs[i].priv);        unregister_netdev(snull_devs + i);    }    return;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
av一区二区三区黑人| 欧美日韩视频在线第一区 | 国产一区二区三区在线观看精品| 成人免费在线播放视频| 欧美精品一区二区精品网| 国产91精品入口| 国产精品一区免费在线观看| 国产精品一区在线观看你懂的| 色综合久久综合网欧美综合网| 91美女蜜桃在线| 色综合久久久久久久久久久| 亚洲精品一区二区在线观看| 日韩电影在线免费| 午夜久久电影网| 丝袜美腿亚洲综合| 精品一区二区三区免费观看| 另类中文字幕网| 国产盗摄视频一区二区三区| 成人av资源在线| 欧美日韩激情在线| 精品久久一区二区| 久久这里只有精品视频网| 亚洲成a天堂v人片| 精品一区二区三区视频| 这里是久久伊人| 久久久五月婷婷| 亚洲免费视频成人| 亚洲gay无套男同| 91理论电影在线观看| 国产精品久久久久婷婷二区次| 一区二区三区欧美亚洲| 久久精品国产在热久久| 日韩欧美一级精品久久| 国产欧美一区二区精品性色超碰| ...中文天堂在线一区| 成人永久aaa| 91麻豆精品国产91久久久| 香蕉影视欧美成人| 91精品国产综合久久精品图片 | 日韩欧美一区二区在线视频| 久久免费精品国产久精品久久久久| 蜜桃精品在线观看| 色婷婷av一区二区三区软件| 一区二区三区免费网站| 欧美精三区欧美精三区| 国产精品美女久久久久av爽李琼| 午夜精品久久一牛影视| 91精品欧美久久久久久动漫| 日韩福利电影在线| 精品国产一区二区在线观看| 国产精品一品二品| 亚洲欧美日韩国产成人精品影院| 欧美视频你懂的| 国产日韩精品一区二区三区在线| 国产成人超碰人人澡人人澡| 亚洲女女做受ⅹxx高潮| 欧美丰满一区二区免费视频| 狠狠色综合色综合网络| 制服丝袜亚洲色图| 国产精品 欧美精品| 亚洲精品成人精品456| 成人av电影在线网| 亚洲无人区一区| 欧美午夜寂寞影院| 另类专区欧美蜜桃臀第一页| 国产精品少妇自拍| 欧美午夜一区二区| 国产suv一区二区三区88区| 一区二区三区四区蜜桃| 精品久久国产字幕高潮| 97久久久精品综合88久久| 91福利资源站| 亚洲一区二区高清| 91福利社在线观看| 精品一区二区三区在线播放| 中文字幕一区二区三区精华液 | 蜜桃传媒麻豆第一区在线观看| 欧美国产日韩精品免费观看| 国产大陆亚洲精品国产| 亚洲一区二区三区四区的| 久久天天做天天爱综合色| 欧美性猛交一区二区三区精品| 国内一区二区视频| 天堂成人免费av电影一区| 国产精品久久久久影院亚瑟| 欧美大片在线观看一区| 欧美日韩久久久一区| www.色综合.com| 国产一区二区三区电影在线观看 | 欧美日韩久久不卡| 91麻豆自制传媒国产之光| 国内精品免费**视频| 午夜欧美视频在线观看| 日韩理论片网站| 欧美日韩精品是欧美日韩精品| 成人免费视频免费观看| 久久99国产精品麻豆| 日韩影视精彩在线| 亚洲影院理伦片| 亚洲免费三区一区二区| 中文字幕日韩av资源站| 中文字幕不卡在线播放| 久久久精品天堂| 久久免费国产精品| 久久久五月婷婷| 久久久久久久久久久99999| 精品久久一二三区| 精品久久99ma| 久久亚洲综合色一区二区三区| 9191成人精品久久| 91精品欧美一区二区三区综合在| 欧美日韩一区三区四区| 欧美日本视频在线| 日韩一级黄色大片| 日韩精品中文字幕在线一区| 精品国产乱码久久久久久久| 日韩精品一区二区三区在线播放| 在线观看91av| 日韩免费电影一区| 久久综合av免费| 国产欧美精品国产国产专区| 国产精品无圣光一区二区| 亚洲欧洲色图综合| 亚洲国产综合91精品麻豆| 日韩影院精彩在线| 国产一区高清在线| 成人黄色小视频| 在线日韩一区二区| 成人综合激情网| 91丝袜呻吟高潮美腿白嫩在线观看| 99riav久久精品riav| 欧美中文字幕一区二区三区| 91精品国产综合久久久蜜臀粉嫩| 精品处破学生在线二十三| 国产精品免费久久| 亚洲综合视频网| 久久国产精品露脸对白| 99久久久无码国产精品| 欧美日韩在线精品一区二区三区激情| 5月丁香婷婷综合| 国产日韩综合av| 亚洲成人黄色小说| 国产老女人精品毛片久久| 99re热视频精品| 欧美mv日韩mv国产网站app| 中文字幕欧美日韩一区| 午夜精品福利一区二区三区蜜桃| 国产精品资源网| 欧美日韩一区在线| 国产欧美一区二区三区网站| 亚洲成av人片一区二区梦乃| 国产伦精品一区二区三区免费 | 欧美午夜一区二区三区| 久久久美女毛片| 亚洲国产欧美日韩另类综合 | 亚洲二区视频在线| 国产综合久久久久久鬼色| 99久久伊人网影院| 91精品国产黑色紧身裤美女| 欧美在线免费观看亚洲| 久久久久国产免费免费 | 国产乱妇无码大片在线观看| 在线观看日韩国产| 久久久蜜桃精品| 五月天欧美精品| 国产91富婆露脸刺激对白 | 91电影在线观看| 国产午夜精品一区二区三区视频 | 欧美激情在线观看视频免费| 天天综合日日夜夜精品| 99久久国产综合色|国产精品| 日韩欧美国产精品一区| 亚洲超丰满肉感bbw| 91伊人久久大香线蕉| ww亚洲ww在线观看国产| 日韩国产一区二| 91国产丝袜在线播放| 亚洲欧洲精品天堂一级| 国产在线国偷精品免费看| 717成人午夜免费福利电影| 亚洲线精品一区二区三区| 99精品视频在线观看| 国产女同性恋一区二区| 国模大尺度一区二区三区| 欧美一区二区三区视频| 五月婷婷久久丁香| 欧美在线综合视频| 亚洲天堂a在线| 91亚洲精品一区二区乱码| 中文av一区特黄| 不卡视频在线观看| 综合av第一页| av午夜一区麻豆| 国产精品久久久久久久久图文区 | 99在线精品一区二区三区| 久久精品夜夜夜夜久久| 九九精品视频在线看| 精品盗摄一区二区三区| 国产乱码一区二区三区| 亚洲国产精品成人综合|