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

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

?? iproute.c

?? 這是新華龍(www.xhl.xom.xn)開發的
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* Lower half of IP, consisting of gateway routines
 * Includes routing and options processing code
 *
 */
#include "config.h"
#include "global.h"
#include "mbuf.h"
#include "iface.h"
#include "timer.h"
#include "internet.h"
#include "ip.h"
#include "tcp.h"
#include "netuser.h"
#include "icmp.h"
#include "rip.h"
#include "trace.h"
#include "pktdrvr.h"
#include "bootp.h"
#ifdef	IPSEC
#include "ipsec.h"
#endif

struct route *Routes[32][HASHMOD];	/* Routing table */
struct route R_default = {		/* Default route entry */
	NULL, NULL,
	0,0,0,
	RIP_INFINITY		/* Init metric to infinity */
};

static struct rt_cache Rt_cache[HASHMOD];
int32 Rtlookups;
int32 Rtchits;

static int q_pkt(struct iface *iface,int32 gateway,struct ip *ip,
	struct mbuf **bpp,int ckgood);

/* Initialize modulo lookup table used by hash_ip() in pcgen.asm */
void
ipinit(void)
{
	int i;

	for(i=0;i<256;i++)
		Hashtab[i] = i % HASHMOD;
}

/* Route an IP datagram. This is the "hopper" through which all IP datagrams,
 * coming or going, must pass.
 *
 * "rxbroadcast" is set to indicate that the packet came in on a subnet
 * broadcast. The router will kick the packet upstairs regardless of the
 * IP destination address.
 */
int
ip_route(
struct iface *i_iface,	/* Input interface */
struct mbuf **bpp,	/* Input packet */
int rxbroadcast		/* True if packet had link broadcast address */
){
	struct ip ip;			/* IP header being processed */
	uint16 ip_len;			/* IP header length */
	uint16 length;			/* Length of data portion */
	int32 gateway;			/* Gateway IP address */
	register struct route *rp;	/* Route table entry */
	struct iface *iface;		/* Output interface, possibly forwarded */
	uint16 offset;			/* Starting offset of current datagram */
	uint16 mf_flag;			/* Original datagram MF flag */
	int strict = 0;			/* Strict source routing flag */
	uint16 opt_len;		/* Length of current option */
	uint8 *opt;		/* -> beginning of current option */
	int i;
	int ckgood = IP_CS_OLD; /* Has good checksum without modification */
	int pointer;		/* Relative pointer index for sroute/rroute */

	if(i_iface != NULL){
		ipInReceives++;	/* Not locally generated */
		i_iface->iprecvcnt++;
	}
	if(len_p(*bpp) < IPLEN){
		/* The packet is shorter than a legal IP header */
		ipInHdrErrors++;
		free_p(bpp);
		return -1;
	}
	/* Sneak a peek at the IP header's IHL field to find its length */
	ip_len = ((*bpp)->data[0] & 0xf) << 2;
	if(ip_len < IPLEN){
		/* The IP header length field is too small */
		ipInHdrErrors++;
		free_p(bpp);
		return -1;
	}
	if(cksum(NULL,*bpp,ip_len) != 0){
		/* Bad IP header checksum; discard */
		ipInHdrErrors++;
		free_p(bpp);
		return -1;
	}
	/* Extract IP header */
	ntohip(&ip,bpp);

	if(ip.version != IPVERSION){
		/* We can't handle this version of IP */
		ipInHdrErrors++;
		free_p(bpp);
		return -1;
	}
	/* If we're running low on memory, return a source quench */
	if(!rxbroadcast && availmem() != 0)
		icmp_output(&ip,*bpp,ICMP_QUENCH,0,NULL);

	/* Process options, if any. Also compute length of secondary IP
	 * header in case fragmentation is needed later
	 */
	strict = 0;
	for(i=0;i<ip.optlen;i += opt_len){
		/* First check for the two special 1-byte options */
		switch(ip.options[i] & OPT_NUMBER){
		case IP_EOL:
			goto no_opt;	/* End of options list, we're done */
		case IP_NOOP:
			opt_len = 1;
			continue;	/* No operation, skip to next option */
		}
		/* Not a 1-byte option, so ensure that there's at least
		 * two bytes of option left, that the option length is
		 * at least two, and that there's enough space left for
		 * the specified option length.
		 */
		if(ip.optlen - i < 2
		 || ((opt_len = ip.options[i+1]) < 2)
		 || ip.optlen - i < opt_len){
			/* Truncated option, send ICMP and drop packet */
			if(!rxbroadcast){
				union icmp_args icmp_args;

				icmp_args.pointer = IPLEN + i;
				icmp_output(&ip,*bpp,ICMP_PARAM_PROB,0,&icmp_args);
			}
			free_p(bpp);
			return -1;
		}
		opt = &ip.options[i];

		switch(opt[0] & OPT_NUMBER){
		case IP_SSROUTE:	/* Strict source route & record route */
			strict = 1;	/* note fall-thru */
		case IP_LSROUTE:	/* Loose source route & record route */
			/* Source routes are ignored unless we're in the
			 * destination field
			 */
			if(opt_len < 3){
				/* Option is too short to be a legal sroute.
				 * Send an ICMP message and drop it.
				 */
				if(!rxbroadcast){
					union icmp_args icmp_args;

					icmp_args.pointer = IPLEN + i;
					icmp_output(&ip,*bpp,ICMP_PARAM_PROB,0,&icmp_args);
				}
				free_p(bpp);
				return -1;
			}
			if(ismyaddr(ip.dest) == NULL)
				break;	/* Skip to next option */
			pointer = opt[2];
			if(pointer + 4 > opt_len)
				break;	/* Route exhausted; it's for us */

			/* Put address for next hop into destination field,
			 * put our address into the route field, and bump
			 * the pointer. We've already ensured enough space.
			 */
			ip.dest = get32(&opt[pointer]);
			put32(&opt[pointer],locaddr(ip.dest));
			opt[2] += 4;
			ckgood = IP_CS_NEW;
			break;
		case IP_RROUTE:	/* Record route */
			if(opt_len < 3){
				/* Option is too short to be a legal rroute.
				 * Send an ICMP message and drop it.
				 */
				if(!rxbroadcast){
					union icmp_args icmp_args;

					icmp_args.pointer = IPLEN + i;
					icmp_output(&ip,*bpp,ICMP_PARAM_PROB,0,&icmp_args);
				}
				free_p(bpp);
				return -1;
			}				
			pointer = opt[2];
			if(pointer + 4 > opt_len){
				/* Route area exhausted; send an ICMP msg */
				if(!rxbroadcast){
					union icmp_args icmp_args;

					icmp_args.pointer = IPLEN + i;
					icmp_output(&ip,*bpp,ICMP_PARAM_PROB,0,&icmp_args);
				}
				/* Also drop if odd-sized */
				if(pointer != opt_len){
					free_p(bpp);
					return -1;
				}
			} else {
				/* Add our address to the route.
				 * We've already ensured there's enough space.
				 */
				put32(&opt[pointer],locaddr(ip.dest));
	 			opt[2] += 4;
				ckgood = IP_CS_NEW;
			}
			break;
		}
	}
no_opt:

	/* See if it's a broadcast or addressed to us, and kick it upstairs */
	if(ismyaddr(ip.dest) != NULL || rxbroadcast ||
		(WantBootp && bootp_validPacket(&ip, *bpp))){
#ifdef	GWONLY
	/* We're only a gateway, we have no host level protocols */
		if(!rxbroadcast)
			icmp_output(&ip,*bpp,ICMP_DEST_UNREACH,
			 ICMP_PROT_UNREACH,NULL);
		ipInUnknownProtos++;
		free_p(bpp);
#else
		ip_recv(i_iface,&ip,bpp,rxbroadcast,0);
#endif
		return 0;
	}
	/* Packet is not destined to us. If it originated elsewhere, count
	 * it as a forwarded datagram.
	 */
	if(i_iface != NULL)
		ipForwDatagrams++;

	/* Adjust the header checksum to allow for the modified TTL */		
	ip.checksum += 0x100;
	if((ip.checksum & 0xff00) == 0)
		ip.checksum++;	/* end-around carry */

	/* Decrement TTL and discard if zero. We don't have to check
	 * rxbroadcast here because it's already been checked
	 */
	if(--ip.ttl == 0){
		/* Send ICMP "Time Exceeded" message */
		icmp_output(&ip,*bpp,ICMP_TIME_EXCEED,0,NULL);
		ipInHdrErrors++;
		free_p(bpp);
		return -1;
	}
	/* Look up target address in routing table */
	if((rp = rt_lookup(ip.dest)) == NULL){
		/* No route exists, return unreachable message (we already
		 * know this can't be a broadcast)
		 */
		icmp_output(&ip,*bpp,ICMP_DEST_UNREACH,ICMP_HOST_UNREACH,NULL);
		free_p(bpp);
		ipOutNoRoutes++;
		return -1;
	}
	rp->uses++;

	/* Check for output forwarding and divert if necessary */
	iface = rp->iface;
	if(iface->forw != NULL)
		iface = iface->forw;

	/* Find gateway; zero gateway in routing table means "send direct" */
	if(rp->gateway == 0)
		gateway = ip.dest;
	else
		gateway = rp->gateway;

	if(strict && gateway != ip.dest){
		/* Strict source routing requires a direct entry
		 * Again, we know this isn't a broadcast
		 */
		icmp_output(&ip,*bpp,ICMP_DEST_UNREACH,ICMP_ROUTE_FAIL,NULL);
		free_p(bpp);
		ipOutNoRoutes++;
		return -1;
	}
#ifdef	IPSEC
	if(sec_output(iface,&ip,bpp) != 0){
		/* We inserted a security header, recompute hdr checksum */
		ckgood = IP_CS_NEW;	/* Recompute IP checksum */
	}
#endif
	if(ip.length <= iface->mtu){
		/* Datagram smaller than interface MTU; put header
		 * back on and send normally.
		 */
		return q_pkt(iface,gateway,&ip,bpp,ckgood);
	}
	/* Fragmentation needed */
	if(ip.flags.df){
		/* Don't Fragment set; return ICMP message and drop */
		union icmp_args icmp_args;

		icmp_args.mtu = iface->mtu;
		icmp_output(&ip,*bpp,ICMP_DEST_UNREACH,ICMP_FRAG_NEEDED,&icmp_args);
		free_p(bpp);
		ipFragFails++;
		return -1;
	}
	/* Create fragments */
	offset = ip.offset;		/* Remember starting offset */
	mf_flag = ip.flags.mf;		/* Save original MF flag */
	length = ip.length - ip_len;	/* Length of data portion */
	while(length != 0){		/* As long as there's data left */
		uint16 fragsize;		/* Size of this fragment's data */
		struct mbuf *f_data;	/* Data portion of fragment */

		/* After the first fragment, should remove those
		 * options that aren't supposed to be copied on fragmentation
		 */
		if(length + ip_len <= iface->mtu){
			/* Last fragment; send all that remains */
			fragsize = length;
			ip.flags.mf = mf_flag;	/* Pass original MF flag */
		} else {
			/* More to come, so send multiple of 8 bytes */
			fragsize = (iface->mtu - ip_len) & 0xfff8;
			ip.flags.mf = 1;
		}
		ip.length = fragsize + ip_len;

		/* Duplicate the fragment */
		dup_p(&f_data,*bpp,ip.offset-offset,fragsize);
		if(f_data == NULL){
			free_p(bpp);
			ipFragFails++;
			return -1;
		}
		if(q_pkt(iface,gateway,&ip,&f_data,IP_CS_NEW) == -1){
			free_p(bpp);
			ipFragFails++;
			return -1;
		}
		ipFragCreates++;
		ip.offset += fragsize;
		length -= fragsize;
	}
	ipFragOKs++;
	free_p(bpp);
	return 0;
}
/* Direct IP input routine for packets without link-level header */
void
ip_proc(
struct iface *iface,
struct mbuf **bpp
){
	ip_route(iface,bpp,0);
}

/* Add an IP datagram to an interface output queue, sorting first by
 * the precedence field in the IP header, and secondarily by an
 * "interactive" flag set by peeking at the transport layer to see
 * if the packet belongs to what appears to be an interactive session.
 * A layer violation, yes, but a useful one...
 */
static int
q_pkt(
struct iface *iface,
int32 gateway,
struct ip *ip,
struct mbuf **bpp,
int ckgood
){
	struct mbuf *tlast,*tbp;
	struct tcp tcp;
	struct qhdr qhdr,qtmp;
	int i;

	iface->ipsndcnt++;
	htonip(ip,bpp,ckgood);

	/* create priority field consisting of tos with 2 unused
	 * low order bits stripped, one of which we'll use as an
	 * "interactive" flag.
	 */
	qhdr.tos = (ip->tos & 0xfc);

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久久久久久久久久电影 | 亚洲gay无套男同| 欧美aⅴ一区二区三区视频| 国产91露脸合集magnet| 欧美私人免费视频| 久久久久久久av麻豆果冻| 亚洲大片一区二区三区| 成人中文字幕电影| 精品国产乱码久久久久久图片| 亚洲欧美二区三区| 成人免费高清视频在线观看| 欧美成人乱码一区二区三区| 亚洲最大色网站| 波多野结衣中文字幕一区| 4438x成人网最大色成网站| 亚洲乱码国产乱码精品精可以看| 国产原创一区二区| 日韩三级电影网址| 同产精品九九九| 91欧美激情一区二区三区成人| 国产视频一区不卡| 黑人巨大精品欧美黑白配亚洲| 欧美高清视频www夜色资源网| 亚洲乱码国产乱码精品精的特点| 国产激情精品久久久第一区二区 | 中文字幕不卡的av| 国产精品99久久久| 2欧美一区二区三区在线观看视频| 午夜激情综合网| 精品视频资源站| 亚洲与欧洲av电影| 欧美综合一区二区| 一区二区三区在线观看视频| 91免费精品国自产拍在线不卡| 中文字幕一区二区不卡| 成人激情动漫在线观看| 国产精品家庭影院| 日本福利一区二区| 亚洲午夜久久久久久久久久久| 色婷婷av一区二区三区大白胸| 一级特黄大欧美久久久| 欧美色综合网站| 日本一道高清亚洲日美韩| 欧美日本免费一区二区三区| 日韩福利视频网| 欧美成人性战久久| 国产成人福利片| 亚洲欧美一区二区三区极速播放 | 欧美成人bangbros| 激情六月婷婷久久| 中文字幕欧美激情| 欧美午夜在线一二页| 午夜精品在线视频一区| 欧美成人综合网站| 成人亚洲精品久久久久软件| 亚洲免费视频中文字幕| 色美美综合视频| 免费成人av在线播放| 欧美激情一区在线| 欧美日韩不卡视频| 国产精品1区2区3区| 亚洲免费观看高清在线观看| 欧美日韩国产电影| 国产成人在线视频网址| 亚洲综合成人在线| 欧美精品一区二区在线观看| 北条麻妃国产九九精品视频| 亚洲成a人v欧美综合天堂下载| 欧美va在线播放| 97成人超碰视| 极品少妇xxxx偷拍精品少妇| 日韩美女视频一区| 精品国产91洋老外米糕| 91视视频在线观看入口直接观看www | 91麻豆精品国产91久久久久久| 国产精品乡下勾搭老头1| 亚洲国产精品久久人人爱蜜臀| 精品久久久网站| 欧洲在线/亚洲| 国产精品1区2区3区| 天堂成人免费av电影一区| 欧美国产精品中文字幕| 777xxx欧美| 一本色道久久综合亚洲91 | 亚洲成人激情av| 国产午夜精品久久久久久免费视| 欧美日韩国产一级| 不卡在线视频中文字幕| 国产一区二区三区免费观看| 日日夜夜精品视频免费| 亚洲图片激情小说| 亚洲国产精品99久久久久久久久| 欧美一区二区三区四区久久| 一本一道波多野结衣一区二区| 国产精品99久久久久久宅男| 免费欧美在线视频| 日韩精品一二三四| 亚洲综合网站在线观看| 亚洲欧美经典视频| 中文字幕亚洲电影| 日本一区二区三区在线观看| 欧美大度的电影原声| 欧美精品自拍偷拍动漫精品| 91精品办公室少妇高潮对白| 白白色 亚洲乱淫| 国产a久久麻豆| 国产精品一二三区| 国产麻豆视频一区二区| 国内精品伊人久久久久影院对白| 麻豆中文一区二区| 人人精品人人爱| 亚洲a一区二区| 日韩有码一区二区三区| 日日夜夜免费精品| 免费在线观看日韩欧美| 日本麻豆一区二区三区视频| 日韩—二三区免费观看av| 日韩精品五月天| 免费精品99久久国产综合精品| 日韩精品电影一区亚洲| 日本成人在线视频网站| 久久精品国产第一区二区三区| 麻豆久久久久久| 韩国三级中文字幕hd久久精品| 国产乱淫av一区二区三区| 国产福利91精品| 丁香六月综合激情| 91国偷自产一区二区三区观看| 欧美日韩一区二区三区四区| 欧美另类高清zo欧美| 欧美一区在线视频| 久久一区二区三区国产精品| 久久精品亚洲乱码伦伦中文| 国产精品久久久久影院| 亚洲精品日韩一| 三级精品在线观看| 国产高清不卡二三区| 91美女蜜桃在线| 884aa四虎影成人精品一区| 欧美不卡在线视频| ...av二区三区久久精品| 亚洲妇熟xx妇色黄| 国产一区二区美女| 色狠狠av一区二区三区| 日韩欧美中文字幕精品| 中文乱码免费一区二区| 天堂一区二区在线免费观看| 国产主播一区二区三区| 91高清视频免费看| 2023国产一二三区日本精品2022| 中国av一区二区三区| 天堂成人免费av电影一区| 高清不卡一区二区| 欧美日韩精品一区二区天天拍小说| 精品国产伦一区二区三区免费 | 亚洲超丰满肉感bbw| 国内精品在线播放| 欧美综合天天夜夜久久| 久久精品视频一区| 亚洲国产精品久久一线不卡| 国产福利视频一区二区三区| 欧美美女一区二区| 国产精品大尺度| 日本特黄久久久高潮| 91在线丨porny丨国产| 日韩欧美国产一区二区在线播放| 亚洲四区在线观看| 国内精品自线一区二区三区视频| 欧美少妇一区二区| 亚洲丝袜自拍清纯另类| 久久精品二区亚洲w码| 欧美日韩国产经典色站一区二区三区 | 国产精品一级二级三级| 69堂国产成人免费视频| 亚洲男人天堂一区| 粉嫩高潮美女一区二区三区| 欧美一级xxx| 污片在线观看一区二区| 色香蕉久久蜜桃| 亚洲欧洲精品一区二区精品久久久| 老司机精品视频导航| 欧美日本在线一区| 一区二区高清视频在线观看| 99久久er热在这里只有精品15 | 日韩欧美国产系列| 性做久久久久久免费观看| 色综合久久综合网97色综合| 中日韩免费视频中文字幕| 国产成人免费在线视频| 精品久久久久久久久久久久久久久 | 欧美日本在线播放| 亚洲午夜激情网站| 色偷偷久久一区二区三区| 亚洲欧美偷拍三级| av日韩在线网站| 18涩涩午夜精品.www| 99国产精品久久久久| 亚洲视频在线一区观看| av网站一区二区三区| 亚洲精品乱码久久久久久黑人|