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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? ip.c

?? 一百多個(gè)例子很好的verilog 學(xué)習(xí)資料
?? C
?? 第 1 頁 / 共 2 頁
字號(hào):
#undef SIM
/* Upper half of IP, consisting of send/receive primitives, including
 * fragment reassembly, for higher level protocols.
 * Not needed when running as a standalone gateway.
 * Copyright 1991 Phil Karn, KA9Q
 */
#include "global.h"
#include "mbuf.h"
#include "timer.h"
#include "internet.h"
#include "netuser.h"
#include "iface.h"
#include "ip.h"
#include "icmp.h"

static int fraghandle(struct ip *ip,struct mbuf **bpp);
static void ip_timeout(void *arg);
static void free_reasm(struct reasm *rp);
static void freefrag(struct frag *fp);
static struct reasm *lookup_reasm(struct ip *ip);
static struct reasm *creat_reasm(struct ip *ip);
static struct frag *newfrag(uint offset,uint last,struct mbuf **bpp);
void ttldec(struct iface *ifp);

struct mib_entry Ip_mib[20] = {
	"",			0,
	"ipForwarding",		1,
	"ipDefaultTTL",		MAXTTL,
	"ipInReceives",		0,
	"ipInHdrErrors",	0,
	"ipInAddrErrors",	0,
	"ipForwDatagrams",	0,
	"ipInUnknownProtos",	0,
	"ipInDiscards",		0,
	"ipInDelivers",		0,
	"ipOutRequests",	0,
	"ipOutDiscards",	0,
	"ipOutNoRoutes",	0,
	"ipReasmTimeout",	TLB,
	"ipReasmReqds",		0,
	"ipReasmOKs",		0,
	"ipReasmFails",		0,
	"ipFragOKs",		0,
	"ipFragFails",		0,
	"ipFragCreates",	0,
};

struct reasm *Reasmq;
uint Id_cntr = 0;	/* Datagram serial number */
static struct raw_ip *Raw_ip;
int Ip_trace = 0;

#define	INSERT	0
#define	APPEND	1
#define	PREPEND	2

/* Send an IP datagram. Modeled after the example interface on p 32 of
 * RFC 791
 */
int
ip_send(
int32 source,			/* source address */
int32 dest,			/* Destination address */
char protocol,			/* Protocol */
char tos,			/* Type of service */
char ttl,			/* Time-to-live */
struct mbuf **bpp,		/* Data portion of datagram */
uint length,			/* Optional length of data portion */
uint id,			/* Optional identification */
char df				/* Don't-fragment flag */
){
	struct ip ip;			/* IP header */

	ipOutRequests++;

	if(bpp == NULL)
		return -1;
	if(source == INADDR_ANY)
		source = locaddr(dest);
	if(length == 0 && *bpp != NULL)
		length = len_p(*bpp);
	if(id == 0)
		id = Id_cntr++;
	if(ttl == 0)
		ttl = ipDefaultTTL;

	/* Fill in IP header */
	ip.version = IPVERSION;
	ip.tos = tos;
	ip.length = IPLEN + length;
	ip.id = id;
	ip.offset = 0;
	ip.flags.mf = 0;
	ip.flags.df = df;
	ip.flags.congest = 0;
	ip.ttl = ttl;
	ip.protocol = protocol;
	ip.source = source;
	ip.dest = dest;
	ip.optlen = 0;
	if(Ip_trace)
		dumpip(NULL,&ip,*bpp,0);

	htonip(&ip,bpp,IP_CS_NEW);
	if(ismyaddr(ip.dest)){
		/* Pretend it has been sent by the loopback interface before
		 * it appears in the receive queue
		 */
#ifdef	SIM
		net_sim(bpp);
#else
		net_route(&Loopback,bpp);
#endif
		Loopback.ipsndcnt++;
		Loopback.rawsndcnt++;
		Loopback.lastsent = secclock();
	} else
		net_route(NULL,bpp);
	return 0;
}

/* Reassemble incoming IP fragments and dispatch completed datagrams
 * to the proper transport module
 */
void
ip_recv(
struct iface *iface,	/* Incoming interface */
struct ip *ip,		/* Extracted IP header */
struct mbuf **bpp,	/* Data portion */
int rxbroadcast,	/* True if received on subnet broadcast address */
int32 spi		/* Security association, if any */
){
	/* Function to call with completed datagram */
	struct raw_ip *rp;
	struct mbuf *bp1;
	int rxcnt = 0;
	struct iplink *ipp;

	/* If we have a complete packet, call the next layer
	 * to handle the result. Note that fraghandle passes back
	 * a length field that does NOT include the IP header
	 */
	if(bpp == NULL || fraghandle(ip,bpp) == -1)
		return;		/* Not done yet */

	/* Trim data segment if necessary. */
	trim_mbuf(bpp,ip->length - (IPLEN + ip->optlen));

	ipInDelivers++;
	if(Ip_trace)
		dumpip(iface,ip,*bpp,spi);

	for(rp = Raw_ip;rp != NULL;rp = rp->next){
		if(rp->protocol != ip->protocol)
			continue;
		rxcnt++;
		/* Duplicate the data portion, and put the header back on */
		dup_p(&bp1,*bpp,0,len_p(*bpp));
		if(bp1 != NULL){
			htonip(ip,&bp1,IP_CS_OLD);
			enqueue(&rp->rcvq,&bp1);
			if(rp->r_upcall != NULL)
				(*rp->r_upcall)(rp);
		} else {
			free_p(&bp1);
		}
	}
	/* Look it up in the transport protocol table */
	for(ipp = Iplink;ipp->funct != NULL;ipp++){
		if(ipp->proto == ip->protocol)
			break;
	}
	if(ipp->funct != NULL){
		/* Found, call transport protocol */
		(*ipp->funct)(iface,ip,bpp,rxbroadcast,spi);
	} else {
		/* Not found */
		if(rxcnt == 0){
			/* Send an ICMP Protocol Unknown response... */
			ipInUnknownProtos++;
			/* ...unless it's a broadcast */
			if(!rxbroadcast){
				icmp_output(ip,*bpp,ICMP_DEST_UNREACH,
				 ICMP_PROT_UNREACH,NULL);
			}
		}
		free_p(bpp);
	}
}
/* Handle IP packets encapsulated inside IP */
void
ipip_recv(
struct iface *iface,	/* Incoming interface */
struct ip *ip,		/* Extracted IP header */
struct mbuf **bpp,	/* Data portion */
int rxbroadcast,	/* True if received on subnet broadcast address */
int32 spi
){
	net_route(&Encap,bpp);
}

/* Process IP datagram fragments
 * If datagram is complete, return its length (MINUS header);
 * otherwise return -1
 */
static int
fraghandle(
struct ip *ip,		/* IP header, host byte order */
struct mbuf **bpp	/* The fragment itself */
){
	struct reasm *rp; /* Pointer to reassembly descriptor */
	struct frag *lastfrag,*nextfrag,*tfp;
	struct mbuf *tbp;
	uint i;
	uint last;		/* Index of first byte beyond fragment */

	last = ip->offset + ip->length - (IPLEN + ip->optlen);

	rp = lookup_reasm(ip);
	if(ip->offset == 0 && !ip->flags.mf){
		/* Complete datagram received. Discard any earlier fragments */
		if(rp != NULL){
			free_reasm(rp);
			ipReasmOKs++;
		}
		return ip->length;
	}
	ipReasmReqds++;
	if(rp == NULL){
		/* First fragment; create new reassembly descriptor */
		if((rp = creat_reasm(ip)) == NULL){
			/* No space for descriptor, drop fragment */
			ipReasmFails++;
			free_p(bpp);
			return -1;
		}
	}
	/* Keep restarting timer as long as we keep getting fragments */
	stop_timer(&rp->timer);
	start_timer(&rp->timer);

	/* If this is the last fragment, we now know how long the
	 * entire datagram is; record it
	 */
	if(!ip->flags.mf)
		rp->length = last;

	/* Set nextfrag to the first fragment which begins after us,
	 * and lastfrag to the last fragment which begins before us
	 */
	lastfrag = NULL;
	for(nextfrag = rp->fraglist;nextfrag != NULL;nextfrag = nextfrag->next){
		if(nextfrag->offset > ip->offset)
			break;
		lastfrag = nextfrag;
	}
	/* Check for overlap with preceeding fragment */
	if(lastfrag != NULL  && ip->offset < lastfrag->last){
		/* Strip overlap from new fragment */
		i = lastfrag->last - ip->offset;
		pullup(bpp,NULL,i);
		if(*bpp == NULL)
			return -1;	/* Nothing left */
		ip->offset += i;
	}
	/* Look for overlap with succeeding segments */
	for(; nextfrag != NULL; nextfrag = tfp){
		tfp = nextfrag->next;	/* save in case we delete fp */

		if(nextfrag->offset >= last)
			break;	/* Past our end */
		/* Trim the front of this entry; if nothing is
		 * left, remove it.
		 */
		i = last - nextfrag->offset;
		pullup(&nextfrag->buf,NULL,i);
		if(nextfrag->buf == NULL){
			/* superseded; delete from list */
			if(nextfrag->prev != NULL)
				nextfrag->prev->next = nextfrag->next;
			else
				rp->fraglist = nextfrag->next;
			if(tfp->next != NULL)
				nextfrag->next->prev = nextfrag->prev;
			freefrag(nextfrag);
		} else
			nextfrag->offset = last;
	}
	/* Lastfrag now points, as before, to the fragment before us;
	 * nextfrag points at the next fragment. Check to see if we can
	 * join to either or both fragments.
	 */
	i = INSERT;
	if(lastfrag != NULL && lastfrag->last == ip->offset)
		i |= APPEND;
	if(nextfrag != NULL && nextfrag->offset == last)
		i |= PREPEND;
	switch(i){
	case INSERT:	/* Insert new desc between lastfrag and nextfrag */
		tfp = newfrag(ip->offset,last,bpp);
		tfp->prev = lastfrag;
		tfp->next = nextfrag;
		if(lastfrag != NULL)
			lastfrag->next = tfp;	/* Middle of list */
		else
			rp->fraglist = tfp;	/* First on list */
		if(nextfrag != NULL)
			nextfrag->prev = tfp;
		break;

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美精品丝袜中出| 亚洲精品综合在线| 日韩精品在线网站| 欧美日韩大陆在线| 欧洲视频一区二区| 欧美少妇一区二区| 欧美三级中文字幕在线观看| 在线观看日韩av先锋影音电影院| 91看片淫黄大片一级| 91一区二区三区在线观看| 91麻豆蜜桃一区二区三区| 色婷婷av一区二区三区大白胸 | 成人高清视频免费观看| 成人国产精品免费| 色综合天天综合网天天狠天天| 色综合婷婷久久| 欧美日韩国产影片| 日韩一卡二卡三卡国产欧美| 欧美一区二区三区免费在线看| 日韩一级黄色大片| 国产亚洲欧美在线| 中文在线资源观看网站视频免费不卡| 欧美极品aⅴ影院| 亚洲精品乱码久久久久| 日本美女一区二区三区| 紧缚奴在线一区二区三区| 成人在线一区二区三区| 日本精品视频一区二区| 在线成人免费视频| 欧美不卡123| 国产精品电影一区二区| 亚洲精品视频在线看| 亚洲成人在线观看视频| 精品亚洲成av人在线观看| 成人性生交大合| 色先锋aa成人| 日韩一区二区三区电影在线观看| 国产清纯白嫩初高生在线观看91| 亚洲欧美日韩中文播放 | 亚洲国产综合色| 青椒成人免费视频| 成人免费毛片片v| 欧美另类z0zxhd电影| 亚洲福利一二三区| 美女脱光内衣内裤视频久久网站| 高清国产一区二区| 欧美专区亚洲专区| 26uuu国产日韩综合| 1024国产精品| 日本午夜精品视频在线观看| 国产成人精品1024| 欧美日本在线观看| 国产欧美精品国产国产专区| 亚洲国产一区二区视频| 国产精品一区免费在线观看| 在线影院国内精品| 国产女人aaa级久久久级| 亚洲成a天堂v人片| 粉嫩av一区二区三区| 欧美色精品在线视频| 精品国产一区二区三区久久影院 | 欧美浪妇xxxx高跟鞋交| 日韩精品中文字幕在线不卡尤物| 国产欧美日韩视频在线观看| 亚洲免费观看视频| 青青草国产成人av片免费| 从欧美一区二区三区| 欧美在线播放高清精品| 久久亚洲春色中文字幕久久久| 亚洲欧美激情视频在线观看一区二区三区 | 中日韩av电影| 调教+趴+乳夹+国产+精品| 国产尤物一区二区| 欧美私人免费视频| 久久精品人人做人人爽人人| 亚洲一区二区精品视频| 国产美女一区二区| 国产成人99久久亚洲综合精品| 日韩精品一区国产麻豆| 亚洲精选在线视频| 国产精品香蕉一区二区三区| 欧美精品一卡两卡| 成人欧美一区二区三区黑人麻豆| 看国产成人h片视频| 91成人免费电影| 久久久久久久av麻豆果冻| 亚洲成av人片在www色猫咪| 成人一区二区三区视频在线观看| 精品捆绑美女sm三区| 亚洲精选在线视频| 国产不卡视频一区二区三区| 欧美一级高清片| 亚洲精品久久7777| 丁香婷婷综合色啪| 欧美成人激情免费网| 亚洲一区在线电影| 99久久99久久精品免费看蜜桃| 欧美日韩高清一区二区三区| 亚洲精品久久嫩草网站秘色| 成人丝袜视频网| 久久中文娱乐网| 麻豆成人久久精品二区三区小说| 欧美日韩中文另类| 亚洲欧美日韩国产综合| 成人av资源在线| 久久久国产精品麻豆| 日韩国产一二三区| 精品久久人人做人人爱| 日韩电影在线一区二区三区| 在线观看视频欧美| 亚洲激情成人在线| 91视频在线观看| 成人欧美一区二区三区黑人麻豆| 国产成人精品综合在线观看| 久久久综合精品| 国产在线视频一区二区三区| 在线播放中文字幕一区| 亚洲精品亚洲人成人网| 欧美日韩一区精品| 亚洲一区二区三区四区在线观看 | 在线日韩一区二区| www国产成人免费观看视频 深夜成人网| 精品一区二区三区日韩| 欧美第一区第二区| 蜜桃av一区二区三区| 欧美一区在线视频| 九一九一国产精品| 2019国产精品| 国产成人免费在线| 久久久国产精华| 色婷婷久久久综合中文字幕| 亚洲同性同志一二三专区| 91丨九色丨蝌蚪富婆spa| 亚洲色图第一区| 欧美亚洲一区二区三区四区| 午夜精品爽啪视频| 91精品国产91综合久久蜜臀| 麻豆免费看一区二区三区| 久久亚洲综合色一区二区三区| 国产精品1区2区3区在线观看| 国产欧美日韩不卡免费| 国产99久久久国产精品| 国产精品萝li| 在线观看不卡视频| 秋霞电影一区二区| 久久久久88色偷偷免费| 国产黑丝在线一区二区三区| 国产三级三级三级精品8ⅰ区| 风间由美一区二区av101| 欧美一区二区日韩| 成人中文字幕在线| 亚洲一级二级三级| 欧美一级二级三级蜜桃| 粉嫩嫩av羞羞动漫久久久| 一区二区三区波多野结衣在线观看 | 欧美一区二区黄色| 国产乱色国产精品免费视频| 成人欧美一区二区三区小说| 欧洲精品一区二区三区在线观看| 美女视频一区二区| 国产精品久久网站| 欧美日韩卡一卡二| 狠狠色综合色综合网络| 亚洲色图制服诱惑 | 懂色av中文一区二区三区| 亚洲视频图片小说| 91精品国产品国语在线不卡| 国产精品一区二区久久精品爱涩| 国产偷国产偷精品高清尤物 | 欧美一区二区三区视频免费| 福利电影一区二区三区| 水野朝阳av一区二区三区| 国产偷国产偷精品高清尤物 | 国产一区在线不卡| 国产精品久久久久aaaa| 欧美日韩精品一区二区三区蜜桃| 国产一区二区网址| 亚洲大片免费看| 国产免费观看久久| 91精品国产高清一区二区三区| 成人高清伦理免费影院在线观看| 亚洲国产精品精华液网站| 亚洲精品在线观看网站| 欧美日韩精品一区二区三区四区| 国产99一区视频免费| 亚洲va韩国va欧美va| 国产亚洲女人久久久久毛片| 色香色香欲天天天影视综合网| 国精产品一区一区三区mba桃花| 伊人性伊人情综合网| 久久人人爽爽爽人久久久| 欧美日韩成人高清| 色综合天天综合狠狠| 国产精品一区二区免费不卡| 视频一区二区国产| 亚洲日本在线看| 久久久久9999亚洲精品| 91精品国产综合久久久久久漫画| 色综合久久天天| 成人免费视频一区|