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

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

?? plip.c

?? linux 1.0 源代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
plip_receive_packet(struct device *dev){    int plip_type;    unsigned length;    int checksum = 0;    struct sk_buff *skb;    struct netstats *localstats;    struct ethhdr eth;    localstats = (struct netstats*) dev->priv;        outb(1, dev->base_addr + PAR_DATA);		/* Ack: 'Ready' */    {	/* get header octet and length of packet */	plip_type = get_byte(dev);	if (plip_type < 0) return 1; /* probably wrong interrupt */	length = get_byte(dev) << 8;	length |= get_byte(dev);	switch ( plip_type ) {	  case PLIP_HEADER_TYPE1:	    {		int i;		unsigned char *eth_p = (unsigned char*)&eth;		for ( i = 0; i < sizeof(eth); i++, eth_p++) {		    *eth_p = get_byte(dev);		}	    }	    break;	  case PLIP_HEADER_TYPE2:	    {		unsigned char h_dest, h_source;		unsigned short type;		h_dest = get_byte(dev);		h_source = get_byte(dev);		type = get_byte(dev) << 8;		type |= get_byte(dev);		plip_rebuild_enethdr(dev, &eth, h_dest, h_source, type);	    }	    break;	  default:	    PRINTK(("%s: wrong header octet\n", dev->name));	}	PRINTK2(("length = %d\n", length));	if (length > dev->mtu || length < 8) {	    PRINTK2(("%s: bogus packet size %d.\n", dev->name, length));	    return 1;	}    }    {	/* get skb area from kernel and 	 * set appropriate values to skb	 */	int sksize;	sksize = sizeof(struct sk_buff) + length;	skb = alloc_skb(sksize, GFP_ATOMIC);	if (skb == NULL) {	    PRINTK(("%s: Couldn't allocate a sk_buff of size %d.\n",		    dev->name, sksize));	    return 1;	}	skb->lock = 0;	skb->mem_len = sksize;	skb->mem_addr = skb;    }    {	/* phase of receiving the data */	/* 'skb->data' points to the start of sk_buff data area. */	unsigned char *buf = skb->data;	unsigned char *eth_p = (unsigned char *)&eth;	int i;	for ( i = 0; i < sizeof(eth); i++) {	    checksum += *eth_p;	    *buf++ = *eth_p++;	}	for ( i = 0; i < length - sizeof(eth); i++) {	    unsigned char new_byte = get_byte(dev);	    checksum += new_byte;	    *buf++ = new_byte;	}	checksum &= 0xff;	if (checksum != get_byte(dev)) {	    localstats->rx_crc_errors++;	    PRINTK(("checksum error\n"));	    return 1;	} else if(dev_rint((unsigned char *)skb, length, IN_SKBUFF, dev)) {	    printk("%s: rcv buff full.\n", dev->name);	    localstats->rx_dropped++;	    return 1;	}    }    {	/* phase of terminating this connection */	int timeout;	timeout = jiffies + length * timeoutfactor / 16;	outb(0x00, dev->base_addr + PAR_DATA);	/* Wait for the remote end to reset. */	while ( (inb(dev->base_addr + PAR_STATUS) & 0xf8) != 0x80 ) {	    if (timeout < jiffies ) {		double_timeoutfactor();		PRINTK(("Remote has not reset.\n"));		break;	    }	}    }    localstats->rx_packets++;    return 0;}static int send_byte(struct device *dev, unsigned char val){    int timeout;    int error = 0;    if (!(inb(dev->base_addr+PAR_STATUS) & 0x08)) {	PRINTK(("remote end become unready while sending\n"));	return -1;    }    PRINTK2((" S%02x", val));    outb(val, dev->base_addr); /* this makes data bits more stable */    outb(0x10 | val, dev->base_addr);    timeout = jiffies + timeoutfactor;    while( inb(dev->base_addr+PAR_STATUS) & 0x80 )	if ( timeout < jiffies ) {	    error++;	    break;	}    outb(0x10 | (val >> 4), dev->base_addr);    outb(val >> 4, dev->base_addr);    timeout = jiffies + timeoutfactor;    while( (inb(dev->base_addr+PAR_STATUS) & 0x80) == 0 )	if ( timeout < jiffies ) {	    error++;	    break;	}    if (error) {	/* timeout error */	double_timeoutfactor();	PRINTK2(("t"));	return -1;    }    return 0;}/* * plip_send_start * trigger remoto rx interrupt and establish a connection. *  * return value * 0 : establish the connection * -1 : connection failed. */static intplip_send_start(struct device *dev, struct ethhdr *eth){	    int timeout;    int status;    int lasttrigger;    struct netstats *localstats = (struct netstats*) dev->priv;    /* This starts the packet protocol by triggering a remote IRQ. */    timeout = jiffies + timeoutfactor * 16;    lasttrigger = jiffies;    while ( ((status = inb(dev->base_addr+PAR_STATUS)) & 0x08) == 0 ) {	dev->tbusy = 1;	outb(0x00, dev->base_addr + PAR_CONTROL); /* Disable my rx intr. */	outb(0x08, dev->base_addr + PAR_DATA); 	/* Trigger remote rx intr. */	if (status & 0x40) {	    /* The remote end is also trying to send a packet.	     * Only one end may go to the receiving phase,	     * so we use the "ethernet" address (set from the IP address)	     * to determine which end dominates.	     */	    if ( plip_addrcmp(eth) > 0 ) {		localstats->collisions++;		PRINTK2(("both ends are trying to send a packet.\n"));		if (plip_receive_packet(dev)) {		    /* get some error while receiving data */		    localstats->rx_errors++;		    outb(0x02, dev->base_addr + PAR_DATA);		} else {		    outb(0x00, dev->base_addr + PAR_DATA);		}		cold_sleep(2); /* make sure that remote end is ready */	    }	    continue; /* restart send sequence */	}	if (lasttrigger != jiffies) {	    /* trigger again */	    outb(0x00, dev->base_addr + PAR_DATA);	    cold_sleep(1);	    lasttrigger = jiffies;	}	if (timeout < jiffies) {	    double_timeoutfactor();	    plip_device_clear(dev);	    localstats->tx_errors++;	    PRINTK(("%s: Connect failed in send_packet().\n",		    dev->name));	    /* We failed to send the packet.  To emulate the ethernet we	       should pretent the send worked fine */	    return -1;	}    }    return 0;}static intplip_send_packet(struct device *dev, unsigned char *buf, int length){    int error = 0;    int plip_type;    struct netstats *localstats;    PRINTK2(("%s: plip_send_packet(%d) %02x %02x %02x %02x %02x...",	   dev->name, length, buf[0], buf[1], buf[2], buf[3], buf[4]));    if (length > dev->mtu) {	printk("%s: packet too big, %d.\n", dev->name, length);	return 0;    }    localstats = (struct netstats*) dev->priv;    {	/* phase of checking remote status */	int i;	int timeout = jiffies + timeoutfactor * 8;	while ( (i = (inb(dev->base_addr+PAR_STATUS) & 0xe8)) != 0x80 ) {	    if (i == 0x78) {		/* probably cable is not connected */		/* Implementation Note:		 * This status should result in 'Network unreachable'.		 * but I don't know the way.		 */		return 0;	    }	    if (timeout < jiffies) {		/* remote end is not ready */		double_timeoutfactor();		localstats->tx_errors++;		PRINTK(("remote end is not ready.\n"));		return 1; /* Failed to send the packet */	    }	}    }    /* phase of making a connection */    if (plip_send_start(dev, (struct ethhdr *)buf) < 0)	return 1;    /* select plip type */    {	/* Use stripped ethernet header if each first 5 octet of eth	 * address is same.	 */	int i;	struct ethhdr *eth = (struct ethhdr *)buf;	plip_type = PLIP_HEADER_TYPE2;		for ( i = 0; i < ETH_ALEN - 1; i++)	    if (eth->h_dest[i] != eth->h_source[i])		plip_type = PLIP_HEADER_TYPE1;    }    send_byte(dev, plip_type); /* send header octet */    {	/* send packet's length */	/*	 * in original plip (before v0.1), it was sent with little endian.	 * but in internet, network byteorder is big endian,	 * so changed to use big endian.	 * maybe using 'ntos()' is better.	 */	send_byte(dev, length >> 8); send_byte(dev, length);    }    {	/* phase of sending data */	int i;	int checksum = 0;	if (plip_type == PLIP_HEADER_TYPE2) {	    plip_send_enethdr(dev, (struct ethhdr*)buf);	}	for ( i = 0; i < sizeof(struct ethhdr); i++ ) {	    if (plip_type == PLIP_HEADER_TYPE1) {		send_byte(dev, *buf);	    }	    checksum += *buf++;	}	for (i = 0; i < length - sizeof(struct ethhdr); i++) {	    checksum += buf[i];	    if (send_byte(dev, buf[i]) < 0) {		error++;		break;	    }	}	send_byte(dev, checksum & 0xff);    }    {	/* phase of terminating this connection */	int timeout;		outb(0x00, dev->base_addr + PAR_DATA);	/* Wait for the remote end to reset. */	timeout = jiffies + ((length * timeoutfactor) >> 4);	while ((inb(dev->base_addr + PAR_STATUS) & 0xe8) != 0x80) {	    if (timeout < jiffies ) {			double_timeoutfactor();		PRINTK(("Remote end has not reset.\n"));		error++;		break;	    }	}	if (inb(dev->base_addr + PAR_STATUS) & 0x10) {	    /* receiver reports error */	    error++;	}    }    plip_device_clear(dev);    localstats->tx_packets++;    PRINTK2(("plip_send_packet(%d) done.\n", length));    return error?1:0;}/* * some trivial functions */static voidplip_set_physicaladdr(struct device *dev, unsigned long ipaddr){    /*     * set physical address to     *  0xfd.0xfd.ipaddr     */    unsigned char *addr = dev->dev_addr;    int i;    if ((ipaddr >> 24) == 0 || (ipaddr >> 24) == 0xff) return;    PRINTK2(("%s: set physical address to %08x\n", dev->name, ipaddr));    for (i=0; i < ETH_ALEN - sizeof(unsigned long); i++) {	addr[i] = 0xfd;    }    memcpy(&(addr[i]), &ipaddr, sizeof(unsigned long));}static intplip_addrcmp(struct ethhdr *eth){    int i;    for ( i = ETH_ALEN - 1; i >= 0; i-- ) {	if (eth->h_dest[i] > eth->h_source[i]) return -1;	if (eth->h_dest[i] < eth->h_source[i]) return 1;    }    PRINTK2(("h_dest = %08x%04x h_source = %08x%04x\n",	    *(long*)&eth->h_dest[2],*(short*)&eth->h_dest[0],	    *(long*)&eth->h_source[2],*(short*)&eth->h_source[0]));    return 0;}static intplip_send_enethdr(struct device *dev, struct ethhdr *eth){    send_byte(dev, eth->h_dest[ETH_ALEN-1]);    send_byte(dev, eth->h_source[ETH_ALEN-1]);    send_byte(dev, eth->h_proto >> 8);    send_byte(dev, eth->h_proto);    return 0;}static intplip_rebuild_enethdr(struct device *dev, struct ethhdr *eth,		     unsigned char dest, unsigned char source,		     unsigned short type){    eth->h_proto = type;    memcpy(eth->h_dest, dev->dev_addr, ETH_ALEN-1);    eth->h_dest[ETH_ALEN-1] = dest;    memcpy(eth->h_source, dev->dev_addr, ETH_ALEN-1);    eth->h_source[ETH_ALEN-1] = source;    return 0;}/* This function is evil, evil, evil.  This should be a   _kernel_, rescheduling sleep!. */static voidcold_sleep(int tics){    int start = jiffies;    while(jiffies < start + tics)	; /* do nothing */    return;}static void  double_timeoutfactor(){    timeoutfactor *= 2;    if (timeoutfactor >= MAXTIMEOUTFACTOR) {	timeoutfactor = MAXTIMEOUTFACTOR;    }    return;}static struct enet_statistics *plip_get_stats(struct device *dev){    struct netstats *localstats = (struct netstats*) dev->priv;    return localstats;}/* * Local variables: *  compile-command: "gcc -D__KERNEL__ -Wall -O6 -fomit-frame-pointer -x c++ -c plip.c" *  version-control: t *  kept-new-versions: 5 * End: */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美国产日产图区| 美女网站在线免费欧美精品| 天天av天天翘天天综合网| 奇米色777欧美一区二区| 成人黄动漫网站免费app| 在线免费精品视频| 国产欧美一区在线| 天堂影院一区二区| 91美女在线视频| 久久久久97国产精华液好用吗| 亚洲一二三四在线观看| 北岛玲一区二区三区四区| 26uuu亚洲| 蜜臀av在线播放一区二区三区| 色网站国产精品| 国产精品美女视频| 国产精品一区三区| 精品国产乱码久久久久久1区2区 | 亚洲高清中文字幕| 波多野结衣亚洲一区| 久久综合九色综合久久久精品综合| 午夜激情综合网| 欧美在线观看18| 亚洲欧美日韩在线| 91美女片黄在线观看91美女| 亚洲欧洲无码一区二区三区| 国产精品综合av一区二区国产馆| 日韩三级免费观看| 免费成人在线观看视频| 日韩一区二区在线观看| 麻豆freexxxx性91精品| 欧美变态凌虐bdsm| 精品一区二区av| 精品欧美黑人一区二区三区| 国产做a爰片久久毛片| 精品剧情在线观看| 九九国产精品视频| 久久久久九九视频| 国产成人精品一区二区三区四区 | 国产精品国产三级国产三级人妇| 国产老妇另类xxxxx| 久久久精品黄色| 国产精品1区2区3区| 欧美国产国产综合| a美女胸又www黄视频久久| 最新热久久免费视频| 日本久久精品电影| 五月综合激情日本mⅴ| 欧美一级高清片| 韩国三级中文字幕hd久久精品| 国产日韩v精品一区二区| 成人av在线网| 亚洲bt欧美bt精品777| 欧美一区二区视频网站| 国产一区二区三区日韩| 最近日韩中文字幕| 欧美精品久久一区| 国产一区二区视频在线播放| 中文欧美字幕免费| 欧美日韩国产片| 狠狠色综合日日| 亚洲欧美在线视频观看| 91精品麻豆日日躁夜夜躁| 国产精品99久久不卡二区| 中文字幕日韩av资源站| 欧美另类高清zo欧美| 国产91精品一区二区麻豆网站| 17c精品麻豆一区二区免费| 制服丝袜中文字幕亚洲| 成人精品高清在线| 视频一区在线播放| 国产精品毛片久久久久久久| 欧美日韩电影一区| 成人中文字幕电影| 青青草成人在线观看| 国产精品二区一区二区aⅴ污介绍| 9191久久久久久久久久久| 一级精品视频在线观看宜春院| 日韩女优电影在线观看| 国产福利一区二区| 亚洲va欧美va天堂v国产综合| 亚洲精品一线二线三线| 色婷婷综合久久久久中文 | 综合激情网...| 日韩美女一区二区三区| 欧美性感一类影片在线播放| 国产成人综合在线播放| 日本中文字幕不卡| 一区二区在线免费| 国产精品久久久久久久裸模| 精品国精品自拍自在线| 在线成人av影院| 91国在线观看| a级精品国产片在线观看| 国产在线观看一区二区| 日韩制服丝袜av| 夜夜夜精品看看| 中文字幕在线一区二区三区| 久久人人97超碰com| 日韩精品一区二区三区老鸭窝| 欧美日本免费一区二区三区| 色综合久久中文字幕综合网| 99久久99久久精品国产片果冻| 国产精品亚洲人在线观看| 久久精品999| 久久99精品久久久久婷婷| 午夜激情一区二区三区| 伊人开心综合网| 一区二区三区在线视频观看 | 精品久久久久久亚洲综合网 | 日韩有码一区二区三区| 亚洲影院在线观看| 一区二区三区久久| 洋洋成人永久网站入口| 亚洲综合视频在线观看| 亚洲欧美一区二区久久| 亚洲免费色视频| 亚洲人成在线播放网站岛国| 亚洲欧美日韩国产成人精品影院| 中文字幕一区二区三区四区不卡| 国产精品人成在线观看免费| 国产亚洲精品精华液| 国产精品免费视频观看| 欧美福利视频一区| 欧美性猛交一区二区三区精品 | 国产成人精品亚洲日本在线桃色| 国产精品一级黄| 大尺度一区二区| av电影一区二区| 欧美男人的天堂一二区| 欧美体内she精高潮| 欧美二区乱c少妇| 欧美一级理论片| 久久精品亚洲国产奇米99| 国产精品久久久久天堂| 亚洲综合免费观看高清完整版在线| 亚洲一区二区三区国产| 日韩精品欧美成人高清一区二区| 视频在线观看国产精品| 激情文学综合网| 不卡一区二区在线| 欧美日韩国产一区二区三区地区| 欧美大片在线观看一区二区| 亚洲国产精品成人久久综合一区| 亚洲精品视频在线看| 视频一区二区中文字幕| 国产精品一区在线| 91福利在线免费观看| 正在播放亚洲一区| 国产欧美一区二区精品性| 亚洲蜜臀av乱码久久精品| 奇米777欧美一区二区| 成人毛片视频在线观看| 欧美撒尿777hd撒尿| 久久一区二区三区国产精品| 综合婷婷亚洲小说| 久久精品国产一区二区三| 91原创在线视频| 精品精品国产高清a毛片牛牛 | 成人美女视频在线看| 欧美性色综合网| 久久久一区二区| 五月激情六月综合| 99久久er热在这里只有精品15 | 91女神在线视频| 欧美不卡一区二区| 亚洲精品高清视频在线观看| 韩国v欧美v日本v亚洲v| 欧美系列亚洲系列| 国产精品丝袜黑色高跟| 免费高清成人在线| 在线观看一区二区精品视频| 久久久精品免费免费| 日韩精彩视频在线观看| 99re热这里只有精品视频| 精品久久一区二区三区| 视频在线观看一区| 欧美va天堂va视频va在线| 亚洲色图在线播放| 丁香婷婷综合激情五月色| 欧美一区二区三区免费观看视频| 亚洲欧洲精品一区二区三区| 国产一区二区在线视频| 日韩欧美亚洲国产另类| 午夜伊人狠狠久久| 91福利视频在线| 亚洲乱码国产乱码精品精的特点 | 欧美国产欧美亚州国产日韩mv天天看完整 | 亚洲图片欧美激情| 国产91精品精华液一区二区三区| 在线不卡免费欧美| 洋洋av久久久久久久一区| 99久久99久久精品国产片果冻| 欧美国产一区在线| 国产成人精品在线看| 欧美极品xxx| 国产成人亚洲精品狼色在线 | 狠狠色丁香久久婷婷综合_中| 7777女厕盗摄久久久| 日本午夜精品视频在线观看|