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

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

?? ip.c

?? 提供TCP/IP的詳細信息
?? C
?? 第 1 頁 / 共 2 頁
字號:
#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.
 */
#include "global.h"
#include "mbuf.h"
#include "timer.h"
#include "internet.h"
#include "netuser.h"
#include "iface.h"
#include "pktdrvr.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(uint16 offset,uint16 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;
uint16 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 */
uint16 length,			/* Optional length of data portion */
uint16 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 */
	register struct raw_ip *rp;
	struct mbuf *bp1;
	int rxcnt = 0;
	register 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 */
){
	register struct reasm *rp; /* Pointer to reassembly descriptor */
	struct frag *lastfrag,*nextfrag,*tfp;
	struct mbuf *tbp;
	uint16 i;
	uint16 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;
	case APPEND:	/* Append to lastfrag */
		append(&lastfrag->buf,bpp);
		lastfrag->last = last;	/* Extend forward */
		break;
	case PREPEND:	/* Prepend to nextfrag */
		tbp = nextfrag->buf;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
蜜桃久久av一区| 日韩毛片视频在线看| 久久不见久久见中文字幕免费| 日韩午夜精品电影| 久久99精品久久久久久国产越南 | 欧美日韩黄视频| 午夜不卡在线视频| 欧美tickling挠脚心丨vk| 国产精品自拍av| 国产精品国产三级国产aⅴ入口| 色又黄又爽网站www久久| 亚洲v中文字幕| 精品国产乱码久久久久久图片 | 波多野结衣中文字幕一区 | 欧美高清视频不卡网| 丝袜亚洲另类丝袜在线| 亚洲精品在线电影| 99热精品国产| 日本不卡123| 国产精品免费视频网站| 欧美剧情电影在线观看完整版免费励志电影 | 亚洲大型综合色站| 欧美精品一区视频| 在线看一区二区| 激情深爱一区二区| 亚洲精品成a人| 日韩视频中午一区| 91在线无精精品入口| 六月丁香婷婷色狠狠久久| 国产精品污污网站在线观看| 欧美日韩一级二级| 99久久99久久精品免费观看| 日本美女一区二区三区| 国产精品美女久久久久av爽李琼 | 88在线观看91蜜桃国自产| 国产精品资源网站| 日韩成人午夜精品| 一区二区三区毛片| 国产欧美日韩精品在线| 91精品在线免费| 91在线视频播放| 国产精品一二三四| 日韩成人一区二区| 亚洲国产精品一区二区久久 | 亚洲精品乱码久久久久久| 日韩精品中文字幕在线一区| 色综合久久久网| 国产福利一区二区三区| 美腿丝袜亚洲综合| 午夜精品一区在线观看| 亚洲欧美激情小说另类| 久久久不卡网国产精品二区| 正在播放亚洲一区| 欧美日韩不卡视频| 欧美做爰猛烈大尺度电影无法无天| 国产一区二区三区黄视频 | 中文字幕亚洲视频| 久久久影院官网| 精品国产区一区| 日韩一区二区高清| 欧美电影一区二区三区| 欧美中文字幕一区二区三区亚洲 | 欧美日本一区二区| 日本高清不卡视频| 91视频一区二区| av电影天堂一区二区在线| 夫妻av一区二区| 国产一区美女在线| 精品夜夜嗨av一区二区三区| 青青青伊人色综合久久| 五月天婷婷综合| 亚洲mv大片欧洲mv大片精品| 亚洲一二三区不卡| 亚洲国产婷婷综合在线精品| 亚洲一区在线观看免费观看电影高清 | 国产自产2019最新不卡| 久久99久久99| 国产一区中文字幕| 成人黄色av网站在线| 成人免费高清在线| 成人黄色免费短视频| 91网页版在线| 欧美在线综合视频| 欧美三日本三级三级在线播放| 欧美亚洲国产bt| 在线不卡中文字幕播放| 欧美久久久久久久久久| 91精品国产欧美一区二区18| 精品欧美久久久| 中文字幕电影一区| 自拍偷拍亚洲欧美日韩| 亚洲成人免费影院| 精品一区二区三区免费视频| 国产成人免费xxxxxxxx| 91丨国产丨九色丨pron| 在线观看日韩电影| 日韩精品一区在线观看| 国产精品免费网站在线观看| 一区二区三区四区中文字幕| 天天综合天天综合色| 久久电影国产免费久久电影 | 99这里都是精品| 欧美色视频在线观看| 日韩免费成人网| 欧美激情综合在线| 一级日本不卡的影视| 另类调教123区| 波多野结衣一区二区三区| 欧美丝袜丝交足nylons| 欧美精品一区二区三| 亚洲精品一卡二卡| 久久精品国产精品青草| 99久久99久久久精品齐齐| 91精品国产91久久综合桃花| 亚洲国产成人午夜在线一区| 亚洲一区二区三区不卡国产欧美| 美腿丝袜亚洲色图| 91久久线看在观草草青青| 欧美一三区三区四区免费在线看| 国产亚洲精品7777| 午夜电影一区二区三区| 成人av网址在线观看| 91.com在线观看| 国产精品久久久久影院色老大| 亚洲精品精品亚洲| 狠狠久久亚洲欧美| 欧美在线视频日韩| 国产精品视频线看| 久久精品国产秦先生| 91国产福利在线| 久久综合久久综合久久综合| 亚洲国产精品人人做人人爽| 国产91精品欧美| 精品乱码亚洲一区二区不卡| 亚洲电影一级黄| 一本大道av一区二区在线播放 | 综合激情成人伊人| 国产一区二区三区免费| 欧美一区永久视频免费观看| 亚洲欧洲成人精品av97| 国产精品自拍一区| 精品国产成人系列| 天堂在线亚洲视频| 色偷偷88欧美精品久久久| 国产日韩欧美激情| 久久99国产精品免费网站| 欧美三电影在线| 一区二区三区在线视频免费| 成人av在线影院| 国产亚洲一区二区三区四区| 美女视频黄 久久| 欧美日韩亚洲高清一区二区| 亚洲欧美日韩久久| av电影在线观看不卡| 亚洲国产精品ⅴa在线观看| 国产综合色在线视频区| 欧美一级欧美一级在线播放| 亚洲图片欧美视频| 91九色02白丝porn| 亚洲特级片在线| 色婷婷香蕉在线一区二区| 亚洲免费观看高清完整版在线| 成人激情小说网站| 国产精品久久久久aaaa| 成人在线综合网站| 亚洲国产精品ⅴa在线观看| 粉嫩蜜臀av国产精品网站| 中文乱码免费一区二区| 成人av中文字幕| 中文字幕字幕中文在线中不卡视频| 成人午夜av电影| 亚洲人成网站在线| 欧美天堂一区二区三区| 午夜精品久久久久久久| 欧美美女激情18p| 日韩国产欧美一区二区三区| 欧美一区二区在线免费观看| 免费看黄色91| 久久久久久久性| 成人精品视频一区二区三区尤物| 国产精品热久久久久夜色精品三区| 成人免费视频一区二区| 亚洲美女在线国产| 欧美久久婷婷综合色| 裸体歌舞表演一区二区| 久久久久久久久久久久久久久99| 国产成人免费视频| 亚洲精品高清视频在线观看| 91精品国产综合久久婷婷香蕉| 男女性色大片免费观看一区二区| 欧美大片一区二区| 国产馆精品极品| 中文字幕视频一区二区三区久| 色综合色狠狠综合色| 亚洲图片欧美综合| 26uuu成人网一区二区三区| 91视频91自| 久久国产综合精品| 1024成人网色www| 日韩一区国产二区欧美三区|