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

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

?? radix.c

?? vxworks下的實現網絡TCPIP協議的原代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* radix.c - common routines for routing engine *//* Copyright 1990-1996 Wind River Systems, Inc. */#include "copyright_wrs.h"/* * Copyright (c) 1988, 1989, 1993 *	The Regents of the University of California.  All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *	This product includes software developed by the University of *	California, Berkeley and its contributors. * 4. Neither the name of the University nor the names of its contributors *    may be used to endorse or promote products derived from this software *    without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * *	@(#)radix.c	8.5 (Berkeley) 5/19/95 *//*modification history--------------------01d,27mar00,pul  remove reference to printRouteNode01c,11nov99,pul  modify rn_walktree to show multiple routes01b,02jul97,vin  fixed warnings.01a,03mar96,vin  created from BSD4.4lite2.*//* * Routines to build and maintain radix trees for routing lookups. */#include "vxWorks.h"#include "stdlib.h"#include "logLib.h"#include "string.h"#include "net/domain.h"#include "net/systm.h"#include "net/radix.h"int	max_keylen;struct radix_mask *rn_mkfreelist;struct radix_node_head *mask_rnhead;static char *addmask_key;static char normal_chars[] = {0, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, -1};static char *rn_zeros, *rn_ones;#define rn_masktop (mask_rnhead->rnh_treetop)#undef Bcmp#define Bcmp(a, b, l) (l == 0 ? 0 : bcmp((caddr_t)(a), (caddr_t)(b), (u_long)l))/* * The data structure for the keys is a radix tree with one way * branching removed.  The index rn_b at an internal node n represents a bit * position to be tested.  The tree is arranged so that all descendants * of a node n have keys whose bits all agree up to position rn_b - 1. * (We say the index of n is rn_b.) * * There is at least one descendant which has a one bit at position rn_b, * and at least one with a zero there. * * A route is determined by a pair of key and mask.  We require that the * bit-wise logical and of the key and mask to be the key. * We define the index of a route to associated with the mask to be * the first bit number in the mask where 0 occurs (with bit number 0 * representing the highest order bit). *  * We say a mask is normal if every bit is 0, past the index of the mask. * If a node n has a descendant (k, m) with index(m) == index(n) == rn_b, * and m is a normal mask, then the route applies to every descendant of n. * If the index(m) < rn_b, this implies the trailing last few bits of k * before bit b are all 0, (and hence consequently true of every descendant * of n), so the route applies to all descendants of the node as well. *  * Similar logic shows that a non-normal mask m such that * index(m) <= index(n) could potentially apply to many children of n. * Thus, for each non-host route, we attach its mask to a list at an internal * node as high in the tree as we can go.  * * The present version of the code makes use of normal routes in short- * circuiting an explict mask and compare operation when testing whether * a key satisfies a normal route, and also in remembering the unique leaf * that governs a subtree. */struct radix_node *rn_search(v_arg, head)	void *v_arg;	struct radix_node *head;{	register struct radix_node *x;	register caddr_t v;	for (x = head, v = v_arg; x->rn_b >= 0;) {		if (x->rn_bmask & v[x->rn_off])			x = x->rn_r;		else			x = x->rn_l;	}	return (x);}struct radix_node *rn_search_m(v_arg, head, m_arg)	struct radix_node *head;	void *v_arg, *m_arg;{	register struct radix_node *x;	register caddr_t v = v_arg, m = m_arg;	for (x = head; x->rn_b >= 0;) {		if ((x->rn_bmask & m[x->rn_off]) &&		    (x->rn_bmask & v[x->rn_off]))			x = x->rn_r;		else			x = x->rn_l;	}	return x;}intrn_refines(m_arg, n_arg)	void *m_arg, *n_arg;{	register caddr_t m = m_arg, n = n_arg;	register caddr_t lim, lim2 = lim = n + *(u_char *)n;	int longer = (*(u_char *)n++) - (int)(*(u_char *)m++);	int masks_are_equal = 1;	if (longer > 0)		lim -= longer;	while (n < lim) {		if (*n & ~(*m))			return 0;		if (*n++ != *m++)			masks_are_equal = 0;	}	while (n < lim2)		if (*n++)			return 0;	if (masks_are_equal && (longer < 0))		for (lim2 = m - longer; m < lim2; )			if (*m++)				return 1;	return (!masks_are_equal);}struct radix_node *rn_lookup(v_arg, m_arg, head)	void *v_arg, *m_arg;	struct radix_node_head *head;{	register struct radix_node *x;	caddr_t netmask = 0;	if (m_arg) {		if ((x = rn_addmask(m_arg, 1, head->rnh_treetop->rn_off)) == 0)			return (0);		netmask = x->rn_key;	}	x = rn_match(v_arg, head);	if (x && netmask) {		while (x && x->rn_mask != netmask)			x = x->rn_dupedkey;	}	return x;}static intrn_satsifies_leaf(trial, leaf, skip)	char *trial;	register struct radix_node *leaf;	int skip;{	register char *cp = trial, *cp2 = leaf->rn_key, *cp3 = leaf->rn_mask;	char *cplim;	int length = min(*(u_char *)cp, *(u_char *)cp2);	if (cp3 == 0)		cp3 = rn_ones;	else		length = min(length, *(u_char *)cp3);	cplim = cp + length; cp3 += skip; cp2 += skip;	for (cp += skip; cp < cplim; cp++, cp2++, cp3++)		if ((*cp ^ *cp2) & *cp3)			return 0;	return 1;}struct radix_node *rn_match(v_arg, head)	void *v_arg;	struct radix_node_head *head;{	caddr_t v = v_arg;	register struct radix_node *t = head->rnh_treetop, *x;	register caddr_t cp = v, cp2;	caddr_t cplim;	struct radix_node *saved_t, *top = t;	int off = t->rn_off, vlen = *(u_char *)cp, matched_off;	register int test, b, rn_b;	/*	 * Open code rn_search(v, top) to avoid overhead of extra	 * subroutine call.	 */	for (; t->rn_b >= 0; ) {		if (t->rn_bmask & cp[t->rn_off])			t = t->rn_r;		else			t = t->rn_l;	}	/*	 * See if we match exactly as a host destination	 * or at least learn how many bits match, for normal mask finesse.	 *	 * It doesn't hurt us to limit how many bytes to check	 * to the length of the mask, since if it matches we had a genuine	 * match and the leaf we have is the most specific one anyway;	 * if it didn't match with a shorter length it would fail	 * with a long one.  This wins big for class B&C netmasks which	 * are probably the most common case...	 */	if (t->rn_mask)		vlen = *(u_char *)t->rn_mask;	cp += off; cp2 = t->rn_key + off; cplim = v + vlen;	for (; cp < cplim; cp++, cp2++)		if (*cp != *cp2)			goto on1;	/*	 * This extra grot is in case we are explicitly asked	 * to look up the default.  Ugh!	 */	if ((t->rn_flags & RNF_ROOT) && t->rn_dupedkey)		t = t->rn_dupedkey;	return t;on1:	test = (*cp ^ *cp2) & 0xff; /* find first bit that differs */	for (b = 7; (test >>= 1) > 0;)		b--;	matched_off = cp - v;	b += matched_off << 3;	rn_b = -1 - b;	/*	 * If there is a host route in a duped-key chain, it will be first.	 */	if ((saved_t = t)->rn_mask == 0)		t = t->rn_dupedkey;	for (; t; t = t->rn_dupedkey)		/*		 * Even if we don't match exactly as a host,		 * we may match if the leaf we wound up at is		 * a route to a net.		 */		if (t->rn_flags & RNF_NORMAL) {			if (rn_b <= t->rn_b)				return t;		} else if (rn_satsifies_leaf(v, t, matched_off))				return t;	t = saved_t;	/* start searching up the tree */	do {		register struct radix_mask *m;		t = t->rn_p;		m = t->rn_mklist;		if (m) {			/*			 * If non-contiguous masks ever become important			 * we can restore the masking and open coding of			 * the search and satisfaction test and put the			 * calculation of "off" back before the "do".			 */			do {				if (m->rm_flags & RNF_NORMAL) {					if (rn_b <= m->rm_b)						return (m->rm_leaf);				} else {					off = min(t->rn_off, matched_off);					x = rn_search_m(v, t, m->rm_mask);					while (x && x->rn_mask != m->rm_mask)						x = x->rn_dupedkey;					if (x && rn_satsifies_leaf(v, x, off))						    return x;				}			m = m->rm_mklist;			} while (m);		}	} while (t != top);	return 0;}		#ifdef RN_DEBUGint	rn_nodenum;struct	radix_node *rn_clist;int	rn_saveinfo;int	rn_debug =  1;#endifstruct radix_node *rn_newpair(v, b, nodes)	void *v;	int b;	struct radix_node nodes[2];{	register struct radix_node *tt = nodes, *t = tt + 1;	t->rn_b = b; t->rn_bmask = 0x80 >> (b & 7);	t->rn_l = tt; t->rn_off = b >> 3;	tt->rn_b = -1; tt->rn_key = (caddr_t)v; tt->rn_p = t;	tt->rn_flags = t->rn_flags = RNF_ACTIVE;#ifdef RN_DEBUG	tt->rn_info = rn_nodenum++; t->rn_info = rn_nodenum++;	tt->rn_twin = t; tt->rn_ybro = rn_clist; rn_clist = tt;#endif	return t;}struct radix_node *rn_insert(v_arg, head, dupentry, nodes)	void *v_arg;	struct radix_node_head *head;	int *dupentry;	struct radix_node nodes[2];{	caddr_t v = v_arg;	struct radix_node *top = head->rnh_treetop;	int head_off = top->rn_off, vlen = (int)*((u_char *)v);	register struct radix_node *t = rn_search(v_arg, top);	register caddr_t cp = v + head_off;	register int b;	struct radix_node *tt;    	/*	 * Find first bit at which v and t->rn_key differ	 */    {	register caddr_t cp2 = t->rn_key + head_off;	register int cmp_res;	caddr_t cplim = v + vlen;	while (cp < cplim)		if (*cp2++ != *cp++)			goto on1;	*dupentry = 1;	return t;on1:	*dupentry = 0;	cmp_res = (cp[-1] ^ cp2[-1]) & 0xff;	for (b = (cp - v) << 3; cmp_res; b--)		cmp_res >>= 1;    }    {	register struct radix_node *p, *x = top;	cp = v;	do {		p = x;		if (cp[x->rn_off] & x->rn_bmask) 			x = x->rn_r;		else x = x->rn_l;	} while (b > (unsigned) x->rn_b); /* x->rn_b < b && x->rn_b >= 0 */#ifdef RN_DEBUG	if (rn_debug)		log(LOG_DEBUG, "rn_insert: Going In:\n"), traverse(p);#endif	t = rn_newpair(v_arg, b, nodes); tt = t->rn_l;	if ((cp[p->rn_off] & p->rn_bmask) == 0)		p->rn_l = t;	else		p->rn_r = t;	x->rn_p = t; t->rn_p = p; /* frees x, p as temp vars below */	if ((cp[t->rn_off] & t->rn_bmask) == 0) {		t->rn_r = x;	} else {		t->rn_r = tt; t->rn_l = x;	}#ifdef RN_DEBUG	if (rn_debug)		log(LOG_DEBUG, "rn_insert: Coming Out:\n"), traverse(p);#endif    }	return (tt);}struct radix_node *rn_addmask(n_arg, search, skip)	int search, skip;	void *n_arg;{	caddr_t netmask = (caddr_t)n_arg;	register struct radix_node *x;	register caddr_t cp, cplim;	register int b = 0, mlen, j;	int maskduplicated, m0, isnormal;	struct radix_node *saved_x;	static int last_zeroed = 0;	if ((mlen = *(u_char *)netmask) > max_keylen)		mlen = max_keylen;	if (skip == 0)		skip = 1;	if (mlen <= skip)		return (mask_rnhead->rnh_nodes);	if (skip > 1)		Bcopy(rn_ones + 1, addmask_key + 1, skip - 1);	if ((m0 = mlen) > skip)		Bcopy(netmask + skip, addmask_key + skip, mlen - skip);	/*	 * Trim trailing zeroes.	 */	for (cp = addmask_key + mlen; (cp > addmask_key) && cp[-1] == 0;)		cp--;	mlen = cp - addmask_key;	if (mlen <= skip) {		if (m0 >= last_zeroed)			last_zeroed = mlen;		return (mask_rnhead->rnh_nodes);	}	if (m0 < last_zeroed)		Bzero(addmask_key + m0, last_zeroed - m0);	*addmask_key = last_zeroed = mlen;	x = rn_search(addmask_key, rn_masktop);	if (Bcmp(addmask_key, x->rn_key, mlen) != 0)		x = 0;	if (x || search)		return (x);	R_Malloc(x, struct radix_node *, max_keylen + 2 * sizeof (*x));	if ((saved_x = x) == 0)		return (0);	Bzero(x, max_keylen + 2 * sizeof (*x));	netmask = cp = (caddr_t)(x + 2);	Bcopy(addmask_key, cp, mlen);	x = rn_insert(cp, mask_rnhead, &maskduplicated, x);	if (maskduplicated) {		logMsg("rn_addmask: mask impossibly already in tree",		       0,0,0,0,0,0);		Free(saved_x);		return (x);	}	/*	 * Calculate index of mask, and check for normalcy.	 */	cplim = netmask + mlen; isnormal = 1;	for (cp = netmask + skip; (cp < cplim) && *(u_char *)cp == 0xff;)		cp++;	if (cp != cplim) {		for (j = 0x80; (j & *cp) != 0; j >>= 1)  

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美特级限制片免费在线观看| 久久久不卡网国产精品二区| 欧美一级欧美三级在线观看 | 肉肉av福利一精品导航| 日韩高清不卡一区二区三区| 国产凹凸在线观看一区二区| 欧美日韩亚洲高清一区二区| 国产网红主播福利一区二区| 午夜欧美视频在线观看| 成人免费看的视频| 欧美日韩国产高清一区二区| 欧美经典一区二区| 日韩av网站免费在线| 成+人+亚洲+综合天堂| 欧美一区二区国产| 亚洲欧美日韩在线不卡| 国内久久婷婷综合| 欧美日韩亚洲另类| 亚洲欧美日韩一区| 免费在线成人网| 欧美中文一区二区三区| 婷婷综合久久一区二区三区| 日韩欧美国产综合在线一区二区三区| 精品综合久久久久久8888| 天天综合色天天| 国产成人亚洲综合a∨猫咪| 欧美一区二区久久| 日日夜夜免费精品视频| 在线免费观看一区| 亚洲九九爱视频| 成人福利视频在线看| 久久亚洲影视婷婷| 麻豆成人在线观看| 在线成人午夜影院| 午夜精品久久久久影视| 欧美性猛交一区二区三区精品| 综合网在线视频| av不卡免费在线观看| 国产精品麻豆视频| 成人永久aaa| 国产精品美女视频| 风流少妇一区二区| 日本一区二区成人在线| 国产高清久久久久| 国产婷婷色一区二区三区| 国产一区二区三区| 久久九九影视网| 成人av手机在线观看| 综合久久久久久久| 在线免费视频一区二区| 亚洲成人动漫在线免费观看| 欧美高清视频一二三区 | 久久色在线视频| 国产激情视频一区二区三区欧美 | 欧美色偷偷大香| 婷婷国产v国产偷v亚洲高清| 欧美猛男超大videosgay| 午夜成人免费电影| 精品国产伦一区二区三区观看方式| 国产一二三精品| 亚洲欧洲精品天堂一级| 欧美亚日韩国产aⅴ精品中极品| 日韩精品国产精品| 久久久久久久综合狠狠综合| 成人动漫一区二区在线| 一区二区在线观看视频| 欧美日韩性生活| 国产一区亚洲一区| 1000部国产精品成人观看| 欧美视频中文一区二区三区在线观看| 免费日韩伦理电影| 欧美国产精品中文字幕| 欧美最新大片在线看| 青青草97国产精品免费观看无弹窗版| 日本一区二区三区久久久久久久久不| 日本韩国精品在线| 免费成人在线视频观看| 国产欧美一区二区精品秋霞影院| 欧美亚洲综合一区| 国产综合色精品一区二区三区| 亚洲女人****多毛耸耸8| 7777精品伊人久久久大香线蕉| 国产成人免费视频| 五月天国产精品| 亚洲人123区| 久久久99精品久久| 欧美一区日韩一区| 91首页免费视频| 国内不卡的二区三区中文字幕 | 99视频精品全部免费在线| 亚洲成a人v欧美综合天堂下载 | 狠狠色丁香婷婷综合| 亚洲日本在线天堂| 久久久蜜臀国产一区二区| 欧美性三三影院| gogo大胆日本视频一区| 美国av一区二区| 亚洲一区二区三区精品在线| 欧美激情一区二区三区不卡 | gogo大胆日本视频一区| 精品一区中文字幕| 午夜免费久久看| 亚洲男同性恋视频| 久久精品人人做人人综合| 日韩一区二区三区三四区视频在线观看 | 精品一区二区三区的国产在线播放| 亚洲免费av观看| 日本一二三四高清不卡| 日韩一区二区在线观看| 欧美日韩成人综合天天影院 | 懂色av中文字幕一区二区三区| 美女视频一区二区| 午夜私人影院久久久久| 亚洲精品菠萝久久久久久久| 国产精品国产三级国产三级人妇 | 国产精品久久影院| 欧美激情中文不卡| 久久一夜天堂av一区二区三区| 日韩精品一区二区三区中文不卡| 欧美高清视频不卡网| 欧美日韩高清影院| 欧美日韩免费一区二区三区视频| 91国内精品野花午夜精品| 色呦呦一区二区三区| 91麻豆精品一区二区三区| 97精品超碰一区二区三区| 9l国产精品久久久久麻豆| 成人激情电影免费在线观看| 丁香六月久久综合狠狠色| 国产成人啪午夜精品网站男同| 国产不卡视频一区二区三区| 国产高清不卡一区| 国产91精品露脸国语对白| 成人免费毛片嘿嘿连载视频| 99精品视频一区二区| 欧美亚洲国产一区在线观看网站 | 日韩专区中文字幕一区二区| 天堂午夜影视日韩欧美一区二区| 日韩成人av影视| 国产一区二区三区久久悠悠色av| 国产精品一区二区你懂的| 国产sm精品调教视频网站| 成人激情校园春色| 欧美天堂亚洲电影院在线播放| 8v天堂国产在线一区二区| 欧美tk—视频vk| 国产午夜精品久久久久久久| 亚洲人精品午夜| 视频一区二区国产| 国产精品资源在线观看| 99久久99久久久精品齐齐| 欧美性受xxxx黑人xyx性爽| 欧美高清你懂得| 欧美激情综合在线| 精品电影一区二区| 国产精品久久久久久久久免费丝袜| 韩国精品久久久| 91精品蜜臀在线一区尤物| 亚洲精品国产a久久久久久 | av成人动漫在线观看| 欧美日韩精品是欧美日韩精品| 日韩欧美成人激情| 日韩一区有码在线| 美美哒免费高清在线观看视频一区二区 | 欧美日本国产视频| 亚洲欧美日韩电影| 91色porny| 亚洲四区在线观看| 国产东北露脸精品视频| 精品国产自在久精品国产| 日本vs亚洲vs韩国一区三区| 欧美日韩一级片在线观看| 亚洲一区二区三区四区五区黄| 91久久精品一区二区二区| 国产精品久久午夜| av一本久道久久综合久久鬼色| 中文一区二区在线观看| 国产一区二区伦理片| 久久久久久久电影| 国产在线精品一区二区三区不卡 | 麻豆精品精品国产自在97香蕉| 欧美人xxxx| 日本不卡一区二区| 日韩限制级电影在线观看| 免费观看日韩电影| 欧美精品一区二区三区久久久| 国产精品一区在线| 国产欧美日韩三级| av一二三不卡影片| 亚洲精品成人在线| 69堂精品视频| 国产一区在线观看视频| 国产精品午夜免费| 99re热这里只有精品免费视频| 亚洲女同ⅹxx女同tv| 欧美日韩精品一区二区三区蜜桃| 麻豆国产精品官网| 国产精品视频你懂的| 91久久国产综合久久| 日本强好片久久久久久aaa|