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

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

?? ip.c

?? TCPIP協議包
?? 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一区二区三区免费野_久草精品视频
久久综合久久综合九色| 在线日韩国产精品| 日本欧美一区二区在线观看| 中文字幕中文字幕在线一区 | 国产精品九色蝌蚪自拍| 精品国产一区二区三区忘忧草 | 成人a级免费电影| 狠狠色狠狠色综合系列| 久久精品999| 久久精品国产色蜜蜜麻豆| 日韩二区在线观看| 日本不卡一二三区黄网| 麻豆精品一区二区三区| 国产剧情一区二区三区| 波多野结衣中文一区| 成人动漫一区二区在线| 成人aa视频在线观看| 色香蕉久久蜜桃| 欧美区在线观看| 精品久久99ma| 中文字幕制服丝袜一区二区三区 | 亚洲婷婷在线视频| 亚洲国产美国国产综合一区二区| 午夜伦理一区二区| 国产在线不卡一卡二卡三卡四卡| 成人一区二区三区中文字幕| 91网站最新网址| 精品视频资源站| 久久久久久99久久久精品网站| 国产精品狼人久久影院观看方式| 亚洲亚洲精品在线观看| 久久疯狂做爰流白浆xx| 色婷婷久久久综合中文字幕| 日韩欧美久久久| 亚洲色图制服诱惑| 激情深爱一区二区| 色综合久久99| 日韩精品一区二区三区视频播放 | 精品99久久久久久| 成人免费在线视频观看| 奇米精品一区二区三区四区 | 免费的国产精品| 91在线观看成人| 日韩欧美一级二级三级| 亚洲精品国产高清久久伦理二区| 久久激情综合网| 欧美日韩一区中文字幕| 国产精品福利在线播放| 国内精品写真在线观看| 欧美色综合天天久久综合精品| 久久久久97国产精华液好用吗| 亚洲午夜久久久久久久久电影院 | 91在线丨porny丨国产| 日韩视频免费直播| 亚洲国产成人av| 日本乱人伦一区| 欧美国产国产综合| 国产在线精品一区二区夜色 | 中文字幕av一区 二区| 久久狠狠亚洲综合| 欧美电影一区二区三区| 一区二区三区中文字幕电影| 夫妻av一区二区| 久久久美女毛片| 国产在线一区观看| 日韩一级免费观看| 日韩精品视频网| 欧美二区在线观看| 午夜电影一区二区三区| 在线亚洲一区观看| 亚洲免费av高清| 91福利区一区二区三区| 亚洲三级小视频| 色吧成人激情小说| 亚洲色欲色欲www| 日本精品免费观看高清观看| 国产精品福利一区二区| 不卡电影免费在线播放一区| 中文字幕高清一区| 成人ar影院免费观看视频| 国产精品乱人伦| 色素色在线综合| 亚洲最快最全在线视频| 欧美日韩在线三区| 久久精品国产色蜜蜜麻豆| 日韩精品一区在线| 国产69精品久久99不卡| 国产精品免费看片| 91在线无精精品入口| 亚洲综合色视频| 欧美一区二视频| 国产超碰在线一区| 一区二区三区四区亚洲| 欧美一区二区视频免费观看| 国产麻豆日韩欧美久久| 国产精品久久久久久久岛一牛影视| 国产盗摄精品一区二区三区在线| 国产精品视频一二三| 91国模大尺度私拍在线视频| 亚洲成人免费看| 久久午夜电影网| 97精品国产97久久久久久久久久久久 | 色一区在线观看| 日韩精品福利网| 久久麻豆一区二区| 91高清在线观看| 精彩视频一区二区三区| 国产精品国产三级国产有无不卡 | 99久久精品一区二区| 午夜国产精品一区| 亚洲国产成人一区二区三区| 欧美综合亚洲图片综合区| 精品一区二区在线播放| 综合色天天鬼久久鬼色| 欧美大片日本大片免费观看| 99国产精品国产精品毛片| 五月天久久比比资源色| 亚洲国产激情av| 欧美一二三区精品| 色菇凉天天综合网| 国内久久精品视频| 午夜在线成人av| 综合久久给合久久狠狠狠97色| 欧美日本精品一区二区三区| 成人黄页在线观看| 老色鬼精品视频在线观看播放| 中文字幕人成不卡一区| 久久综合九色综合欧美就去吻| 欧美色视频一区| 99re这里都是精品| 国产资源精品在线观看| 日韩国产欧美在线观看| 亚洲在线免费播放| 亚洲欧美一区二区不卡| 欧美国产日韩亚洲一区| 26uuu亚洲综合色欧美| 欧美日韩国产不卡| 欧美性videosxxxxx| 92国产精品观看| 成人av免费在线观看| 国产成人午夜精品5599| 久久国产精品第一页| 久久激情综合网| 美日韩一区二区| 日韩av二区在线播放| 亚洲小说春色综合另类电影| 亚洲自拍欧美精品| 亚洲激情图片一区| 亚洲另类在线一区| 综合av第一页| 一区二区理论电影在线观看| 亚洲色图20p| 亚洲欧美国产三级| 亚洲欧美日韩系列| 亚洲美女精品一区| 亚洲国产裸拍裸体视频在线观看乱了| **欧美大码日韩| 亚洲老妇xxxxxx| 亚洲一区在线视频观看| 亚洲国产视频网站| 青青草原综合久久大伊人精品优势 | 国产欧美日韩在线视频| 久久先锋资源网| 欧美韩国日本一区| 亚洲人吸女人奶水| 性做久久久久久免费观看欧美| 天天操天天色综合| 久久国内精品自在自线400部| 美国十次综合导航| 成人午夜免费视频| 在线免费视频一区二区| 欧美私模裸体表演在线观看| 欧美精品视频www在线观看| 精品三级av在线| 国产精品日日摸夜夜摸av| 亚洲精品国产精品乱码不99| 三级欧美韩日大片在线看| 久久av资源网| 99久久99久久精品免费看蜜桃| 欧洲在线/亚洲| 欧美va亚洲va在线观看蝴蝶网| 精品久久久久久久久久久久包黑料 | 免费黄网站欧美| 福利一区二区在线观看| 欧美色偷偷大香| 久久精品视频一区| 亚洲美女区一区| 另类小说欧美激情| 一本色道久久加勒比精品 | 国产成人av电影| 色成人在线视频| 久久香蕉国产线看观看99| 亚洲精品国产无套在线观| 蜜臀久久久久久久| 不卡av在线免费观看| 日韩三级免费观看| 一区二区视频在线看| 国产一区二区三区久久久| 欧美性猛交xxxxxx富婆| 国产精品久久久久影院老司|