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

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

?? ip_nat_core.c

?? 優龍2410linux2.6.8內核源代碼
?? C
?? 第 1 頁 / 共 3 頁
字號:
/* NAT for netfilter; shared with compatibility layer. *//* (C) 1999-2001 Paul `Rusty' Russell * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */#include <linux/module.h>#include <linux/types.h>#include <linux/timer.h>#include <linux/skbuff.h>#include <linux/netfilter_ipv4.h>#include <linux/vmalloc.h>#include <net/checksum.h>#include <net/icmp.h>#include <net/ip.h>#include <net/tcp.h>  /* For tcp_prot in getorigdst */#include <linux/icmp.h>#include <linux/udp.h>#define ASSERT_READ_LOCK(x) MUST_BE_READ_LOCKED(&ip_nat_lock)#define ASSERT_WRITE_LOCK(x) MUST_BE_WRITE_LOCKED(&ip_nat_lock)#include <linux/netfilter_ipv4/ip_conntrack.h>#include <linux/netfilter_ipv4/ip_conntrack_core.h>#include <linux/netfilter_ipv4/ip_conntrack_protocol.h>#include <linux/netfilter_ipv4/ip_nat.h>#include <linux/netfilter_ipv4/ip_nat_protocol.h>#include <linux/netfilter_ipv4/ip_nat_core.h>#include <linux/netfilter_ipv4/ip_nat_helper.h>#include <linux/netfilter_ipv4/ip_conntrack_helper.h>#include <linux/netfilter_ipv4/listhelp.h>#if 0#define DEBUGP printk#else#define DEBUGP(format, args...)#endifDECLARE_RWLOCK(ip_nat_lock);DECLARE_RWLOCK_EXTERN(ip_conntrack_lock);/* Calculated at init based on memory size */static unsigned int ip_nat_htable_size;static struct list_head *bysource;static struct list_head *byipsproto;LIST_HEAD(protos);LIST_HEAD(helpers);extern struct ip_nat_protocol unknown_nat_protocol;/* We keep extra hashes for each conntrack, for fast searching. */static inline size_thash_by_ipsproto(u_int32_t src, u_int32_t dst, u_int16_t proto){	/* Modified src and dst, to ensure we don't create two           identical streams. */	return (src + dst + proto) % ip_nat_htable_size;}static inline size_thash_by_src(const struct ip_conntrack_manip *manip, u_int16_t proto){	/* Original src, to ensure we map it consistently if poss. */	return (manip->ip + manip->u.all + proto) % ip_nat_htable_size;}/* Noone using conntrack by the time this called. */static void ip_nat_cleanup_conntrack(struct ip_conntrack *conn){	struct ip_nat_info *info = &conn->nat.info;	unsigned int hs, hp;	if (!info->initialized)		return;	IP_NF_ASSERT(info->bysource.conntrack);	IP_NF_ASSERT(info->byipsproto.conntrack);	hs = hash_by_src(&conn->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src,	                 conn->tuplehash[IP_CT_DIR_ORIGINAL]	                 .tuple.dst.protonum);	hp = hash_by_ipsproto(conn->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip,	                      conn->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip,	                      conn->tuplehash[IP_CT_DIR_REPLY]	                      .tuple.dst.protonum);	WRITE_LOCK(&ip_nat_lock);	LIST_DELETE(&bysource[hs], &info->bysource);	LIST_DELETE(&byipsproto[hp], &info->byipsproto);	WRITE_UNLOCK(&ip_nat_lock);}/* We do checksum mangling, so if they were wrong before they're still * wrong.  Also works for incomplete packets (eg. ICMP dest * unreachables.) */u_int16_tip_nat_cheat_check(u_int32_t oldvalinv, u_int32_t newval, u_int16_t oldcheck){	u_int32_t diffs[] = { oldvalinv, newval };	return csum_fold(csum_partial((char *)diffs, sizeof(diffs),				      oldcheck^0xFFFF));}static inline int cmp_proto(const struct ip_nat_protocol *i, int proto){	return i->protonum == proto;}struct ip_nat_protocol *find_nat_proto(u_int16_t protonum){	struct ip_nat_protocol *i;	MUST_BE_READ_LOCKED(&ip_nat_lock);	i = LIST_FIND(&protos, cmp_proto, struct ip_nat_protocol *, protonum);	if (!i)		i = &unknown_nat_protocol;	return i;}/* Is this tuple already taken? (not by us) */intip_nat_used_tuple(const struct ip_conntrack_tuple *tuple,		  const struct ip_conntrack *ignored_conntrack){	/* Conntrack tracking doesn't keep track of outgoing tuples; only	   incoming ones.  NAT means they don't have a fixed mapping,	   so we invert the tuple and look for the incoming reply.	   We could keep a separate hash if this proves too slow. */	struct ip_conntrack_tuple reply;	invert_tuplepr(&reply, tuple);	return ip_conntrack_tuple_taken(&reply, ignored_conntrack);}/* Does tuple + the source manip come within the range mr */static intin_range(const struct ip_conntrack_tuple *tuple,	 const struct ip_conntrack_manip *manip,	 const struct ip_nat_multi_range *mr){	struct ip_nat_protocol *proto = find_nat_proto(tuple->dst.protonum);	unsigned int i;	struct ip_conntrack_tuple newtuple = { *manip, tuple->dst };	for (i = 0; i < mr->rangesize; i++) {		/* If we are allowed to map IPs, then we must be in the		   range specified, otherwise we must be unchanged. */		if (mr->range[i].flags & IP_NAT_RANGE_MAP_IPS) {			if (ntohl(newtuple.src.ip) < ntohl(mr->range[i].min_ip)			    || (ntohl(newtuple.src.ip)				> ntohl(mr->range[i].max_ip)))				continue;		} else {			if (newtuple.src.ip != tuple->src.ip)				continue;		}		if (!(mr->range[i].flags & IP_NAT_RANGE_PROTO_SPECIFIED)		    || proto->in_range(&newtuple, IP_NAT_MANIP_SRC,				       &mr->range[i].min, &mr->range[i].max))			return 1;	}	return 0;}static inline intsrc_cmp(const struct ip_nat_hash *i,	const struct ip_conntrack_tuple *tuple,	const struct ip_nat_multi_range *mr){	return (i->conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum		== tuple->dst.protonum		&& i->conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip		== tuple->src.ip		&& i->conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.all		== tuple->src.u.all		&& in_range(tuple,			    &i->conntrack->tuplehash[IP_CT_DIR_ORIGINAL]			    .tuple.src,			    mr));}/* Only called for SRC manip */static struct ip_conntrack_manip *find_appropriate_src(const struct ip_conntrack_tuple *tuple,		     const struct ip_nat_multi_range *mr){	unsigned int h = hash_by_src(&tuple->src, tuple->dst.protonum);	struct ip_nat_hash *i;	MUST_BE_READ_LOCKED(&ip_nat_lock);	i = LIST_FIND(&bysource[h], src_cmp, struct ip_nat_hash *, tuple, mr);	if (i)		return &i->conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src;	else		return NULL;}#ifdef CONFIG_IP_NF_NAT_LOCAL/* If it's really a local destination manip, it may need to do a   source manip too. */static intdo_extra_mangle(u_int32_t var_ip, u_int32_t *other_ipp){	struct flowi fl = { .nl_u = { .ip4_u = { .daddr = var_ip } } };	struct rtable *rt;	/* FIXME: IPTOS_TOS(iph->tos) --RR */	if (ip_route_output_key(&rt, &fl) != 0) {		DEBUGP("do_extra_mangle: Can't get route to %u.%u.%u.%u\n",		       NIPQUAD(var_ip));		return 0;	}	*other_ipp = rt->rt_src;	ip_rt_put(rt);	return 1;}#endif/* Simple way to iterate through all. */static inline int fake_cmp(const struct ip_nat_hash *i,			   u_int32_t src, u_int32_t dst, u_int16_t protonum,			   unsigned int *score,			   const struct ip_conntrack *conntrack){	/* Compare backwards: we're dealing with OUTGOING tuples, and           inside the conntrack is the REPLY tuple.  Don't count this           conntrack. */	if (i->conntrack != conntrack	    && i->conntrack->tuplehash[IP_CT_DIR_REPLY].tuple.src.ip == dst	    && i->conntrack->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip == src	    && (i->conntrack->tuplehash[IP_CT_DIR_REPLY].tuple.dst.protonum		== protonum))		(*score)++;	return 0;}static inline unsigned intcount_maps(u_int32_t src, u_int32_t dst, u_int16_t protonum,	   const struct ip_conntrack *conntrack){	unsigned int score = 0;	unsigned int h;	MUST_BE_READ_LOCKED(&ip_nat_lock);	h = hash_by_ipsproto(src, dst, protonum);	LIST_FIND(&byipsproto[h], fake_cmp, struct ip_nat_hash *,	          src, dst, protonum, &score, conntrack);	return score;}/* For [FUTURE] fragmentation handling, we want the least-used   src-ip/dst-ip/proto triple.  Fairness doesn't come into it.  Thus   if the range specifies 1.2.3.4 ports 10000-10005 and 1.2.3.5 ports   1-65535, we don't do pro-rata allocation based on ports; we choose   the ip with the lowest src-ip/dst-ip/proto usage.   If an allocation then fails (eg. all 6 ports used in the 1.2.3.4   range), we eliminate that and try again.  This is not the most   efficient approach, but if you're worried about that, don't hand us   ranges you don't really have.  */static struct ip_nat_range *find_best_ips_proto(struct ip_conntrack_tuple *tuple,		    const struct ip_nat_multi_range *mr,		    const struct ip_conntrack *conntrack,		    unsigned int hooknum){	unsigned int i;	struct {		const struct ip_nat_range *range;		unsigned int score;		struct ip_conntrack_tuple tuple;	} best = { NULL,  0xFFFFFFFF };	u_int32_t *var_ipp, *other_ipp, saved_ip, orig_dstip;	static unsigned int randomness;	if (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC) {		var_ipp = &tuple->src.ip;		saved_ip = tuple->dst.ip;		other_ipp = &tuple->dst.ip;	} else {		var_ipp = &tuple->dst.ip;		saved_ip = tuple->src.ip;		other_ipp = &tuple->src.ip;	}	/* Don't do do_extra_mangle unless necessary (overrides           explicit socket bindings, for example) */	orig_dstip = tuple->dst.ip;	IP_NF_ASSERT(mr->rangesize >= 1);	for (i = 0; i < mr->rangesize; i++) {		/* Host order */		u_int32_t minip, maxip, j;		/* Don't do ranges which are already eliminated. */		if (mr->range[i].flags & IP_NAT_RANGE_FULL) {			continue;		}		if (mr->range[i].flags & IP_NAT_RANGE_MAP_IPS) {			minip = ntohl(mr->range[i].min_ip);			maxip = ntohl(mr->range[i].max_ip);		} else			minip = maxip = ntohl(*var_ipp);		randomness++;		for (j = 0; j < maxip - minip + 1; j++) {			unsigned int score;			*var_ipp = htonl(minip + (randomness + j) 					 % (maxip - minip + 1));			/* Reset the other ip in case it was mangled by			 * do_extra_mangle last time. */			*other_ipp = saved_ip;#ifdef CONFIG_IP_NF_NAT_LOCAL			if (hooknum == NF_IP_LOCAL_OUT			    && *var_ipp != orig_dstip			    && !do_extra_mangle(*var_ipp, other_ipp)) {				DEBUGP("Range %u %u.%u.%u.%u rt failed!\n",				       i, NIPQUAD(*var_ipp));				/* Can't route?  This whole range part is				 * probably screwed, but keep trying				 * anyway. */				continue;			}#endif			/* Count how many others map onto this. */			score = count_maps(tuple->src.ip, tuple->dst.ip,					   tuple->dst.protonum, conntrack);			if (score < best.score) {				/* Optimization: doesn't get any better than				   this. */				if (score == 0)					return (struct ip_nat_range *)						&mr->range[i];

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国产乱码久久| 中文字幕亚洲一区二区av在线| 亚洲欧美一区二区三区孕妇| www.欧美精品一二区| 中文字幕在线观看不卡视频| 不卡一区二区三区四区| 亚洲欧洲精品天堂一级| 日本精品视频一区二区三区| 亚洲香肠在线观看| 日韩欧美国产一区在线观看| 国产精品二三区| 国产激情视频一区二区三区欧美 | 欧美精品一区二区久久久| 久久精品国产久精国产| 国产日韩一级二级三级| 色综合视频在线观看| 日韩国产成人精品| 亚洲国产成人一区二区三区| 日本乱码高清不卡字幕| 狠狠色2019综合网| 亚洲欧美色图小说| 日韩精品一区二区三区三区免费| 国产成人福利片| 亚洲一区视频在线观看视频| 亚洲精品一区二区三区在线观看| 99久久精品免费| 老司机精品视频在线| 国产精品久久久久久久久快鸭| 欧美日韩1区2区| 粉嫩aⅴ一区二区三区四区五区| 亚洲一二三区视频在线观看| 2欧美一区二区三区在线观看视频| 99久久国产综合色|国产精品| 奇米精品一区二区三区四区 | 国产精品对白交换视频| 91麻豆精品国产91| 99re视频精品| 国产一区中文字幕| 亚洲午夜免费福利视频| 欧美韩日一区二区三区| 日韩一区二区三区观看| 色美美综合视频| 国产精品一区二区无线| 日韩精品久久理论片| 亚洲欧美另类久久久精品2019| 精品国产一区二区三区忘忧草| 在线看国产日韩| 99视频精品免费视频| 国产精品一二三区| 奇米精品一区二区三区在线观看 | 国产尤物一区二区在线 | 激情小说欧美图片| 午夜精品国产更新| 一区二区三区欧美| 国产精品国产三级国产aⅴ原创 | 国产精品美女久久久久av爽李琼| 日韩欧美国产精品一区| 91精品免费观看| 欧美日韩亚洲高清一区二区| 色偷偷一区二区三区| 99天天综合性| 99久久伊人精品| 97久久精品人人做人人爽| 成人免费毛片高清视频| 高清国产一区二区三区| 国产一区二区三区精品欧美日韩一区二区三区 | 91麻豆精品国产91久久久更新时间| 色哟哟一区二区在线观看| gogo大胆日本视频一区| 大白屁股一区二区视频| 国产成人免费视频一区| 国产成人综合亚洲网站| 国产精品一二三四五| 国产成a人无v码亚洲福利| 国内精品写真在线观看| 久久99热这里只有精品| 久久99国产精品免费网站| 久久精品国产99久久6| 久久精品国产网站| 国产麻豆精品一区二区| 国产成人精品免费| 99久久伊人精品| 欧美亚洲综合色| 欧美剧情电影在线观看完整版免费励志电影 | 欧美国产亚洲另类动漫| 国产精品久久久久久久久久久免费看| ●精品国产综合乱码久久久久| 亚洲欧美日韩在线播放| 亚洲一区二区成人在线观看| 天天色天天操综合| 国内久久精品视频| 国产91在线观看丝袜| 91网址在线看| 欧美日韩免费高清一区色橹橹 | 欧美疯狂性受xxxxx喷水图片| 欧美精品aⅴ在线视频| 日韩午夜电影在线观看| 国产三级欧美三级| 亚洲精品成人a在线观看| 日韩国产欧美三级| 激情深爱一区二区| 99久久精品国产导航| 欧美精品丝袜中出| 亚洲国产精品黑人久久久| 亚洲综合在线观看视频| 免费视频一区二区| 成人精品视频网站| 91精品在线麻豆| 中文字幕国产一区二区| 亚洲国产日日夜夜| 国产精品456露脸| 欧美主播一区二区三区美女| 日韩欧美国产综合一区| 亚洲人123区| 久久国产精品无码网站| 91麻豆swag| 久久婷婷色综合| 亚洲妇熟xx妇色黄| 国产不卡在线视频| 欧美一区二区在线免费播放| 欧美高清一级片在线观看| 婷婷久久综合九色国产成人 | 欧美日韩中文一区| 中文字幕欧美激情| 丝袜亚洲另类欧美| 91视频一区二区三区| 日韩女优视频免费观看| 玉米视频成人免费看| 国产精品资源在线观看| 欧美日本乱大交xxxxx| 国产精品久久久久影院亚瑟| 麻豆久久一区二区| 欧美主播一区二区三区| 欧美国产日韩一二三区| 久久精品国产一区二区三区免费看 | 国产成人av一区二区三区在线| 欧美日韩在线观看一区二区| 日本一区二区三区视频视频| 肉色丝袜一区二区| 色综合一区二区三区| 国产欧美一区二区三区在线看蜜臀 | 舔着乳尖日韩一区| 色久综合一二码| 国产精品区一区二区三区| 精品在线播放午夜| 欧美一二三四区在线| 亚洲成人一区二区在线观看| 99综合电影在线视频| 国产精品卡一卡二| 国产mv日韩mv欧美| 国产日韩欧美麻豆| 国模冰冰炮一区二区| 日韩免费电影一区| 日本欧美一区二区| 91精品国产黑色紧身裤美女| 午夜精品久久久久久| 欧美日韩www| 日韩精品电影在线观看| 欧美日本视频在线| 日韩高清在线电影| 欧美一区二区久久久| 日韩和欧美一区二区三区| 在线电影国产精品| 日本成人在线网站| 日韩女同互慰一区二区| 精东粉嫩av免费一区二区三区| 日韩美女在线视频| 狠狠色丁香婷婷综合久久片| 26uuu另类欧美亚洲曰本| 狠狠色综合播放一区二区| 久久综合九色综合欧美亚洲| 黄色资源网久久资源365| 欧美电影免费观看高清完整版在| 美女视频黄 久久| 亚洲精品一区二区三区香蕉| 国产精品一级片| 国产精品对白交换视频| 国产亚洲精品超碰| 成人一区在线看| 一区二区三区中文字幕精品精品| 一本一道久久a久久精品| 夜色激情一区二区| 日韩一区二区三区四区| 国产精品18久久久久久久久 | 国产欧美精品国产国产专区| 成人ar影院免费观看视频| 亚洲精品日韩综合观看成人91| 在线观看日韩av先锋影音电影院| 久久成人羞羞网站| 国产女人18毛片水真多成人如厕| 成人动漫中文字幕| 亚洲国产综合人成综合网站| 69堂国产成人免费视频| 国产精品99久久不卡二区| 亚洲日本欧美天堂| 欧美一区二区女人| www.亚洲免费av| 日韩经典一区二区| 国产女同性恋一区二区| 欧美日韩成人在线|