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

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

?? nr3.c

?? 這是新華龍(www.xhl.xom.xn)開發的
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* net/rom level 3 low level processing
 */

#include <stdio.h>
#include <ctype.h>
#include "global.h"
#include "mbuf.h"
#include "iface.h"
#include "pktdrvr.h"
#include "netuser.h"
#include "arp.h"
#include "slip.h"
#include "ax25.h"
#include "netrom.h"
#include "nr4.h"
#include "lapb.h"
#include "socket.h"
#include "trace.h"
#include "ip.h"
#include "commands.h"

static int accept_bc(uint8 *addr,unsigned ifnum);
static struct nr_bind *find_best(struct nr_bind *list,unsigned obso);
static struct nr_bind *find_binding(struct nr_bind *list,struct nrnbr_tab *neighbor);
static struct nrnbr_tab *find_nrnbr(uint8 *, unsigned);
static struct nrnf_tab *find_nrnf(uint8 *, unsigned);
static struct nr_bind *find_worst(struct nr_bind *list);
static int ismycall(uint8 *addr);
#ifdef	notdef
static uint8 *nr_getroute(uint8 *);
#endif
static struct raw_nr *Raw_nr;

/* Nodes message broadcast address: "NODES" in shifted ASCII */
uint8 Nr_nodebc[AXALEN] = {
	'N'<<1, 'O'<<1, 'D'<<1, 'E'<<1, 'S'<<1, ' '<<1,
	('0'<<1) | E
};

struct nriface Nrifaces[NRNUMIFACE];
unsigned Nr_numiface;
struct nrnbr_tab *Nrnbr_tab[NRNUMCHAINS];
struct nrroute_tab *Nrroute_tab[NRNUMCHAINS];
struct nrnf_tab *Nrnf_tab[NRNUMCHAINS];
unsigned Nr_nfmode = NRNF_NOFILTER;
unsigned short Nr_ttl = 64;
static unsigned Obso_init = 6;
static unsigned Obso_minbc = 5;
static unsigned Nr_maxroutes = 5;
static unsigned Nr_autofloor = 1;
int Nr_verbose = 0;
struct iface *Nr_iface;

/* send a NET/ROM layer 3 datagram */
void
nr3output(
uint8 *dest,
struct mbuf **data
){
	struct nr3hdr n3hdr;
	struct mbuf *n3b;

	memcpy(n3hdr.dest,dest,AXALEN);	/* copy destination field */
	n3hdr.ttl = Nr_ttl;	/* time to live from initializer parm */

	if((n3b = htonnr3(&n3hdr)) == NULL){
		free_p(data);
		return;
	}
	append(&n3b, data);
	/* The null interface indicates that the packet needs to have */
	/* an appropriate source address inserted by nr_route */
	nr_route(&n3b,NULL);
}

/* send IP datagrams across a net/rom network connection */
int
nr_send(
struct mbuf **bpp,
struct iface *iface,
int32 gateway,
uint8 tos
){
	struct arp_tab *arp;

	dump(iface,IF_TRACE_OUT,*bpp);
	iface->rawsndcnt++;
	iface->lastsent = secclock();
	if((arp = arp_lookup(ARP_NETROM,gateway)) == NULL){
		free_p(bpp);	/* drop the packet if no route */
		return -1;
	}
	nr_sendraw(arp->hw_addr, NRPROTO_IP, NRPROTO_IP, bpp);
	return 0;
}

/* Send arbitrary protocol data on top of a NET/ROM connection */
void
nr_sendraw(
uint8 *dest,
unsigned family,
unsigned proto,
struct mbuf **data
){
	struct mbuf *pbp;
	struct nr4hdr n4hdr;

	/* Create a "network extension" transport header */
	n4hdr.opcode = NR4OPPID;
	n4hdr.u.pid.family = family;
	n4hdr.u.pid.proto = proto;

	if((pbp = htonnr4(&n4hdr)) == NULL){
		free_p(data);
		return;
	}
	append(&pbp,data);		/* Append the data to that */
	nr3output(dest, &pbp); /* and pass off to level 3 code */
}

/* Arrange for receipt of raw NET/ROM datagrams */
struct raw_nr *
raw_nr(protocol)
uint8 protocol;
{
	register struct raw_nr *rp;

	rp = (struct raw_nr *)callocw(1,sizeof(struct raw_nr));
	rp->protocol = protocol;
	rp->next = Raw_nr;
	if(rp->next != NULL)
		rp->next->prev = rp;
	Raw_nr = rp;
	return rp;
}
/* Free a raw NET/ROM descriptor */
void
del_rnr(rpp)
struct raw_nr *rpp;
{
	register struct raw_nr *rp;

	/* Do sanity check on arg */
	for(rp = Raw_nr;rp != NULL;rp = rp->next)
		if(rp == rpp)
			break;
	if(rp == NULL)
		return;	/* Doesn't exist */

	/* Unlink */
	if(rp->prev != NULL)
		rp->prev->next = rp->next;
	else
		Raw_nr = rp->next;
	if(rp->next != NULL)
		rp->next->prev = rp->prev;
	/* Free resources */
	free_q(&rp->rcvq);
	free(rp);
}

/* Figure out if a call is assigned to one of my net/rom
 * interfaces.
 */
static int
ismycall(addr)
uint8 *addr;
{
	register int i;
	int found = 0;
	
	for(i = 0; i < Nr_numiface; i++)
		if(addreq(Nrifaces[i].iface->hwaddr,addr)){
			found = 1;
			break;
		}

	return found;
}


/* Route net/rom network layer packets.
 */
void
nr_route(bpp, iaxp)
struct mbuf **bpp;			/* network packet */
struct ax25_cb *iaxp;			/* incoming ax25 control block */
{
	struct nr3hdr n3hdr;
	struct nr4hdr n4hdr;
	struct ax25_cb *axp;
	struct mbuf *hbp, *pbp;
	struct raw_nr *rnr;
	register struct nrnbr_tab *np;
	register struct nrroute_tab *rp;
	register struct nr_bind *bindp;
	struct iface *iface;
	unsigned ifnum;
	
	if(ntohnr3(&n3hdr,bpp) == -1){
		free_p(bpp);
		return;
	}
	/* If this isn't an internally generated network packet,
	 * give the router a chance to record a route back to the
	 * sender, in case they aren't in the local node's routing
	 * table yet.
	 */
	if(iaxp != NULL && ax_lookup(iaxp->remote) != NULL){
			
		/* find the interface number */
		for(ifnum = 0; ifnum < Nr_numiface; ifnum++)
			if(iaxp->iface == Nrifaces[ifnum].iface)
				break;

		if(ifnum == Nr_numiface){	/* Not a net/rom interface! */
			free_p(bpp);
			return;
		}
		/* Add (possibly) a zero-quality recorded route via */
		/* the neighbor from which this packet was received */
		/* Note that this doesn't work with digipeated neighbors. */
		
		(void) nr_routeadd("      ",n3hdr.source,ifnum,0,iaxp->remote,0,1);
	}

	/* A packet from me, to me, can only be one thing:
	 * a horrible routing loop.  This will probably result
	 * from a bad manual ARP entry, but we should fix these
	 * obscure errors as we find them.
	 */
	if(ismycall(n3hdr.dest)){
		/* Toss if from me, or if we can't read the header */
		if(iaxp == NULL || ntohnr4(&n4hdr,bpp) == -1){
			free_p(bpp);
		} else if((n4hdr.opcode & NR4OPCODE) == NR4OPPID){
			for(rnr = Raw_nr;rnr!=NULL;rnr = rnr->next){
				if(rnr->protocol!=n4hdr.u.pid.family ||
				 rnr->protocol != n4hdr.u.pid.proto)
					continue;
				/* Duplicate the data portion, and put the
				 * level 3 header back on
				 */
				dup_p(&pbp,*bpp,0,len_p(*bpp));
				if(pbp != NULL &&
				 (hbp = htonnr3(&n3hdr)) != NULL){
					append(&hbp,&pbp);
					enqueue(&rnr->rcvq,&hbp);
				} else {
					free_p(&pbp);
					free_p(&hbp);
				}
			}
			/* IP does not use a NET/ROM level 3 socket */
			if(n4hdr.u.pid.family == NRPROTO_IP
			 && n4hdr.u.pid.proto == NRPROTO_IP)
				ip_route(iaxp->iface,bpp,0);
			else		/* we don't do this proto */
				free_p(bpp);
		} else {
			/* Must be net/rom transport: */
			nr4input(&n4hdr,bpp);
		}
		return;
	}
	if((rp = find_nrroute(n3hdr.dest)) == NULL){
		/* no route, drop the packet */
		free_p(bpp);
		return;
	}
	if((bindp = find_best(rp->routes,1)) == NULL){
		/* This shouldn't happen yet, but might if we add */
		/* dead route detection */
		free_p(bpp);
		return;
	}

	np = bindp->via;
	iface = Nrifaces[np->iface].iface;

	/* Now check to see if iaxp is null.  That is */
	/* a signal that the packet originates here, */
	/* so we need to insert the callsign of the appropriate  */
	/* interface */
	if(iaxp == NULL)
		memcpy(n3hdr.source,iface->hwaddr,AXALEN);
	
	/* Make sure there is a connection to the neighbor */
	if((axp = find_ax25(np->call)) == NULL ||
		(axp->state != LAPB_CONNECTED && axp->state != LAPB_RECOVERY)){
		/* Open a new connection or reinitialize old one */
		/* hwaddr has been advanced to point to neighbor + digis */
		axp = open_ax25(iface,iface->hwaddr,np->call, AX_ACTIVE, Axwindow, s_arcall, s_atcall, s_ascall,-1);
		if(axp == NULL){
			free_p(bpp);
			return;
		}
	}
		
	if(--n3hdr.ttl == 0){	/* the packet's time to live is over! */
		free_p(bpp);
		return;
	}
	/* now format network header */
	if((pbp = htonnr3(&n3hdr)) == NULL){
		free_p(bpp);
		return;
	}
	append(&pbp,bpp);		/* append data to header */

	/* put AX.25 PID on front */
	pushdown(&pbp,NULL,1);
	pbp->data[0] = PID_NETROM;

	if((pbp = segmenter(&pbp,axp->paclen)) == NULL){
		free_p(&pbp);
		return;
	}
	send_ax25(axp,&pbp,-1);	/* pass it off to ax25 code */
}
	

/* Perform a nodes broadcast on interface # ifno in the net/rom
 * interface table.
 */
void
nr_bcnodes(ifno)
unsigned ifno;
{
	struct mbuf *hbp, *dbp, *savehdr;
	struct nrroute_tab *rp;
	struct nrnbr_tab *np;
	struct nr_bind * bp;
	struct nr3dest nrdest;
	int i, didsend = 0, numdest = 0;
	register uint8 *cp;
	struct iface *axif = Nrifaces[ifno].iface;
	
	/* prepare the header */
	if((hbp = alloc_mbuf(NR3NODEHL)) == NULL)
		return;
		
	hbp->cnt = NR3NODEHL;	
	
	*hbp->data = NR3NODESIG;
	memcpy(hbp->data+1,Nrifaces[ifno].alias,ALEN);

	/* Some people don't want to advertise any routes; they
	 * just want to be a terminal node.  In that case we just
	 * want to send our call and alias and be done with it.
	 */

	if(!Nr_verbose){
		(*axif->output)(axif, Nr_nodebc, axif->hwaddr,
				PID_NETROM, &hbp);	/* send it */
		return;
	}

	/* make a copy of the header in case we need to send more than */
	/* one packet */
	savehdr = copy_p(hbp,NR3NODEHL);

	/* now scan through the routing table, finding the best routes */
	/* and their neighbors.  create destination subpackets and append */
	/* them to the header */
	for(i = 0; i < NRNUMCHAINS; i++){
		for(rp = Nrroute_tab[i]; rp != NULL; rp = rp->next){
			/* look for best, non-obsolescent route */
			if((bp = find_best(rp->routes,0)) == NULL)
				continue;	/* no non-obsolescent routes found */
			if(bp->quality == 0)	/* this is a loopback route */
				continue;	/* we never broadcast these */
			np = bp->via;
			/* insert best neighbor */
			memcpy(nrdest.neighbor,np->call,AXALEN);
			/* insert destination from route table */
			memcpy(nrdest.dest,rp->call,AXALEN);
			/* insert alias from route table */
			strcpy(nrdest.alias,rp->alias);
			/* insert quality from binding */
			nrdest.quality = bp->quality;
			/* create a network format destination subpacket */
			if((dbp = htonnrdest(&nrdest)) == NULL){
				free_p(&hbp);	/* drop the whole idea ... */
				free_p(&savehdr);
				return;
			}
			/* we now have a partially filled packet */
			didsend = 0;	
			append(&hbp,&dbp);/* append to header and others */
			/* see if we have appended as many destinations
			 * as we can fit into a single broadcast.  If we
			 * have, go ahead and send them out.
			 */
			if(++numdest == NRDESTPERPACK){	/* filled it up */
				/* indicate that we did broadcast */
				didsend = 1;
				/* reset the destination counter */
				numdest = 0;
				(*axif->output)(axif, Nr_nodebc, axif->hwaddr,
				 PID_NETROM,&hbp);	/* send it */
				/* new header */
				hbp = copy_p(savehdr,NR3NODEHL);
			}
		}
	}

	/* Now, here is something totally weird.  If our interfaces */
	/* have different callsigns than this one, advertise a very */
	/* high quality route to them.  Is this a good idea?  I don't */
	/* know.  However, it allows us to simulate a bunch of net/roms */
	/* hooked together with a diode matrix coupler. */
	for(i = 0; i < Nr_numiface; i++){
		if(i == ifno)
			continue;		/* don't bother with ours */
		cp = Nrifaces[i].iface->hwaddr;
		if(!addreq((uint8 *)axif->hwaddr,cp)){
			/* both destination and neighbor address */
			memcpy(nrdest.dest,cp,AXALEN);
			memcpy(nrdest.neighbor,cp,AXALEN);
			/* alias of the interface */
			strcpy(nrdest.alias,Nrifaces[i].alias);
			/* and the very highest quality */
			nrdest.quality = 255;
			/* create a network format destination subpacket */
			if((dbp = htonnrdest(&nrdest)) == NULL){
				free_p(&hbp);	/* drop the whole idea ... */
				free_p(&savehdr);
				return;
			}
			/* we now have a partially filled packet */
			didsend = 0;	
			/* append to header and others */
			append(&hbp,&dbp);
			if(++numdest == NRDESTPERPACK){	/* filled it up */
				/* indicate that we did broadcast */
				didsend = 1;
				/* reset the destination counter */
				numdest = 0;
				(*axif->output)(axif, Nr_nodebc, axif->hwaddr,
				 PID_NETROM,&hbp);	/* send it */
				/* new header */
				hbp = copy_p(savehdr,NR3NODEHL);
			}
		}
	}
			
	/* If we have a partly filled packet left over, or we never */
	/* sent one at all, we broadcast: */
	if(!didsend || numdest > 0)
		(*axif->output)(axif, Nr_nodebc, axif->hwaddr,PID_NETROM, &hbp);

	/* free the header copies */
	if(numdest == 0)
		free_p(&hbp);
	free_p(&savehdr);
}

/* attach the net/rom interface.  no parms for now. */
int
nr_attach(argc,argv,p)
int argc;
char *argv[];
void *p;
{
	if(Nr_iface != (struct iface *)0){
		printf("netrom interface already attached\n");
		return -1;
	}
	Nr_iface = (struct iface *)callocw(1,sizeof(struct iface));
	Nr_iface->addr = Ip_addr;

	/* The strdup is needed to keep the detach routine happy (it'll
	 * free the allocated memory)
	 */
	Nr_iface->name = strdup("netrom");
	if(Nr_iface->hwaddr == NULL){
		Nr_iface->hwaddr = mallocw(AXALEN);
		memcpy(Nr_iface->hwaddr,Mycall,AXALEN);
	}
	Nr_iface->mtu = NR4MAXINFO;
	setencap(Nr_iface,"NETROM");
	Nr_iface->next = Ifaces;
	Ifaces = Nr_iface;
	memcpy(Nr4user,Mycall,AXALEN);
	Nr_iface->txproc = newproc("nr tx",512,if_tx,0,Nr_iface,NULL,0);
	return 0;
}

/* This function checks an ax.25 address and interface number against
 * the filter table and mode, and returns 1 if the address is to be
 * accepted, and 0 if it is to be filtered out.
 */

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
18成人在线观看| 热久久一区二区| 91在线播放网址| 亚洲色图欧洲色图| 91精彩视频在线| 五月天国产精品| 日韩欧美激情四射| 国产成人自拍网| 国产精品久久久久天堂| 欧美影视一区二区三区| 日本欧美在线看| 久久久久久久久伊人| av毛片久久久久**hd| 亚洲成a人v欧美综合天堂下载| 欧美一区二区三区在线观看| 日韩欧美区一区二| 懂色av中文一区二区三区| 亚洲精品久久久久久国产精华液| 欧美影院精品一区| 久久国产三级精品| 一区免费观看视频| 欧美另类变人与禽xxxxx| 精品亚洲国产成人av制服丝袜| 中文字幕精品—区二区四季| 欧美午夜寂寞影院| 狠狠久久亚洲欧美| 亚洲精品国产一区二区精华液| 5566中文字幕一区二区电影| 国产成人免费在线视频| 一区二区三区不卡视频| 精品三级av在线| av高清久久久| 免费成人美女在线观看| 久久久久一区二区三区四区| 色又黄又爽网站www久久| 免费高清视频精品| 中文字幕在线一区免费| 91精选在线观看| av在线免费不卡| 免费的国产精品| 中文字幕在线播放不卡一区| 7777精品伊人久久久大香线蕉的 | 国产精品国产成人国产三级 | 婷婷综合另类小说色区| 久久久久青草大香线综合精品| 日本高清不卡aⅴ免费网站| 激情综合一区二区三区| 一区二区三区加勒比av| 久久久国际精品| 欧美日本韩国一区二区三区视频| 国产乱码字幕精品高清av| 亚洲成人免费电影| 国产精品久久久久一区| 欧美刺激午夜性久久久久久久| 99精品欧美一区二区三区综合在线| 青娱乐精品在线视频| 亚洲精品视频一区| 久久久久久久久免费| 欧美丰满少妇xxxxx高潮对白| 丁香六月综合激情| 久久精品国产99久久6| 亚洲最色的网站| 中文字幕 久热精品 视频在线| 日韩一区二区视频在线观看| 一本一本大道香蕉久在线精品| 国产精品亚洲一区二区三区在线| 香蕉成人伊视频在线观看| av一区二区久久| 国产精品99久久久久久久女警| 日韩精品国产精品| 一区二区三区不卡在线观看 | 日韩欧美自拍偷拍| 欧美视频在线播放| 91网站视频在线观看| 国产精品456| 久久国产精品露脸对白| 婷婷中文字幕一区三区| 亚洲女女做受ⅹxx高潮| 中文字幕二三区不卡| 欧美精品一区二区三| 91精品国产黑色紧身裤美女| 精品视频资源站| 色香色香欲天天天影视综合网| 丁香婷婷综合色啪| 国产激情视频一区二区三区欧美 | 国产精品自拍一区| 欧美zozozo| 欧美日韩国产123区| 欧美丝袜第三区| 在线欧美日韩精品| 色诱亚洲精品久久久久久| av亚洲精华国产精华精| 成人免费黄色在线| 国产成人午夜精品5599| 国产一区二区美女诱惑| 极品少妇xxxx偷拍精品少妇| 蜜桃av噜噜一区二区三区小说| 日日骚欧美日韩| 亚洲444eee在线观看| 亚洲一区精品在线| 一区二区三区四区精品在线视频| 亚洲免费av高清| 亚洲卡通欧美制服中文| 亚洲精品中文字幕乱码三区| 亚洲人成精品久久久久久| 亚洲人成伊人成综合网小说| 亚洲视频一二三区| 一区二区三区四区蜜桃| 亚洲综合丝袜美腿| 午夜精品久久久久久不卡8050| 五月天丁香久久| 男男视频亚洲欧美| 捆绑调教一区二区三区| 狠狠v欧美v日韩v亚洲ⅴ| 国产真实乱偷精品视频免| 国产寡妇亲子伦一区二区| 成人中文字幕在线| av成人免费在线观看| 91麻豆蜜桃一区二区三区| 色婷婷综合五月| 欧美日韩日本视频| 91精品国产高清一区二区三区| 日韩一级视频免费观看在线| 精品国产伦一区二区三区免费| 久久99热狠狠色一区二区| 久久精品国产亚洲5555| 国产激情偷乱视频一区二区三区| 大桥未久av一区二区三区中文| 91在线丨porny丨国产| 在线看一区二区| 欧美一区三区四区| 久久久av毛片精品| 国产精品传媒入口麻豆| 亚洲永久免费av| 免费成人你懂的| 国产.欧美.日韩| 在线精品视频小说1| 欧美一区二区三区小说| 久久亚洲精华国产精华液| 中文字幕制服丝袜成人av| 亚洲午夜在线观看视频在线| 精品国产一区a| 国产欧美视频在线观看| 裸体一区二区三区| 国产91色综合久久免费分享| 久久国产精品99久久久久久老狼| 老司机免费视频一区二区三区| 国产不卡视频一区| 色综合久久久网| 欧美一区二区在线不卡| 久久精品人人做人人爽97| 自拍偷拍欧美精品| 日韩国产高清在线| 国产成人综合精品三级| 一区二区三区中文在线观看| 日本成人在线看| 成人av手机在线观看| 欧美日韩国产免费| 久久影院视频免费| 亚洲综合色噜噜狠狠| 久久99精品国产.久久久久久| av电影在线观看完整版一区二区| 欧美精品在欧美一区二区少妇| 久久久99免费| 亚洲国产精品久久一线不卡| 久久91精品久久久久久秒播| 99久久99久久综合| 日韩欧美一区电影| 日韩毛片视频在线看| 久久精品久久久精品美女| 91丨九色丨黑人外教| 日韩免费电影一区| 亚洲精品综合在线| 国产精品伊人色| 欧美美女直播网站| 国产精品剧情在线亚洲| 卡一卡二国产精品| 在线观看免费一区| 国产色婷婷亚洲99精品小说| 亚洲成人黄色小说| 成人免费电影视频| 日韩免费视频线观看| 洋洋av久久久久久久一区| 国产精品自拍在线| 免费成人在线网站| 日本韩国欧美一区二区三区| 久久伊99综合婷婷久久伊| 亚洲成人免费影院| 成人黄色大片在线观看| 精品欧美乱码久久久久久1区2区| 一区二区三区四区蜜桃| 国产成人精品免费一区二区| 欧美一级免费观看| 一区二区在线观看免费视频播放| 国产老肥熟一区二区三区| 制服丝袜亚洲播放| 一区二区三区高清在线| 成人免费视频免费观看| 精品99一区二区| 日韩高清在线观看|