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

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

?? nr4.c

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

#include <stdio.h>
#include "global.h"
#include "mbuf.h"
#include "timer.h"
#include "ax25.h"
#include "lapb.h"
#include "netrom.h"
#include "nr4.h"
#include <ctype.h>

#undef NR4DEBUG

/* Globals: */

/* The circuit table */

struct nr4circp Nr4circuits[NR4MAXCIRC];

/* Various limits */

unsigned short Nr4window = 4;		/* Max window to negotiate */
unsigned short Nr4retries = 10;	/* Max retries */
unsigned short Nr4qlimit = 2048;	/* Max bytes on receive queue */

/* Timers */

int32 Nr4irtt = 15000;			/* Initial round trip time */
int32 Nr4acktime = 3000;		/* ACK delay timer */
int32 Nr4choketime = 180000;		/* CHOKEd state timeout */

static void nr4ackours(struct nr4cb *, unsigned, int);
static void nr4choke(struct nr4cb *);
static void nr4gotnak(struct nr4cb *, unsigned);
static void nr4rframe(struct nr4cb *, unsigned, struct mbuf **);

/* This function is called when a net/rom layer four frame */
/* is discovered inside a datagram addressed to us */

void
nr4input(hdr,bpp)
struct nr4hdr *hdr;
struct mbuf **bpp;
{
	struct nr4hdr rhdr;
	struct nr4cb *cb, *cb2;
	int op;
	unsigned window;
	int acceptc;		/* indicates that connection should be accepted */
	int newconn;		/* indicates that this is a new incoming */
						/* connection.  You'll see. */
	int gotchoke;		/* The choke flag was set in this packet */		
	int i;
	
	op = hdr->opcode & NR4OPCODE;	/* Mask off flags */
	
	if(op == NR4OPCONRQ){			/* process connect request first */
		acceptc = 1;
		newconn = 0;

		/* These fields are sent regardless of success */
		rhdr.yourindex = hdr->u.conreq.myindex;
		rhdr.yourid = hdr->u.conreq.myid;

		/* Check to see if we have already received a connect */
		/* request for this circuit. */
		if((cb = match_n4circ(hdr->u.conreq.myindex,
		 hdr->u.conreq.myid,hdr->u.conreq.user,hdr->u.conreq.node))
		 == NULL){	/* No existing circuit if NULL */

			/* Try to get a new circuit */
			if((cb = new_n4circ()) == NULL)
				acceptc = 0;
			/* See if we have any listening sockets */
			for(i = 0; i < NR4MAXCIRC; i++){
				if((cb2 = Nr4circuits[i].ccb) == NULL)
				continue;/* not an open circuit */
				if(cb2->state == NR4STLISTEN)
					/* A listener was found */
					break;
			}
			if(i == NR4MAXCIRC){ /* We are refusing connects */
				acceptc = 0;
				free_n4circ(cb);
			}
			if(acceptc){
				/* Load the listeners settings */
				cb->clone = cb2->clone;
				cb->user = cb2->user;
				cb->t_upcall = cb2->t_upcall;
				cb->s_upcall = cb2->s_upcall;
				cb->r_upcall = cb2->r_upcall;
				ASSIGN(cb->local,cb2->local);

				/* Window is set to min of the offered
				 * and local windows
				 */
				window = hdr->u.conreq.window > Nr4window ?
						 Nr4window : hdr->u.conreq.window;

				if(init_nr4window(cb, window) == -1){
					free_n4circ(cb);
					acceptc = 0;
				} else {
					/* Set up control block */
					cb->yournum = hdr->u.conreq.myindex;
					cb->yourid = hdr->u.conreq.myid;
					memcpy(cb->remote.user,
					       hdr->u.conreq.user,AXALEN);
					memcpy(cb->remote.node,
					       hdr->u.conreq.node,AXALEN);
					/* Default round trip time */
					cb->srtt = Nr4irtt;
					/* set up timers, window pointers */
					nr4defaults(cb);
					cb->state = NR4STDISC;
					newconn = 1;
				} /* End if window successfully allocated */
			}	/* End if new circuit available */
		 } /* End if no existing circuit matching parameters */

		/* Now set up response */
		if(!acceptc){
			rhdr.opcode = NR4OPCONAK | NR4CHOKE;/* choke means reject */
			rhdr.u.conack.myindex = 0;
			rhdr.u.conack.myid = 0;
			rhdr.u.conack.window = 0;
		} else {
			rhdr.opcode = NR4OPCONAK;
			rhdr.u.conack.myindex = cb->mynum;
			rhdr.u.conack.myid = cb->myid;
			rhdr.u.conack.window = cb->window;
		}
		nr4sframe(hdr->u.conreq.node, &rhdr, NULL);

		/* Why, you ask, do we wait until now for the state change
		 * upcall?  Well, it's like this:  if the state change triggers
		 * something like the mailbox to send its banner, the banner
		 * would have gone out *before* the conn ack if we'd done this
		 * in the code above.  This is what happens when you don't plan
		 * too well.  Learn from my mistakes :-)
		 */
		if(newconn)
			nr4state(cb, NR4STCON);/* connected (no 3-way handshake) */
			
		free_p(bpp);
		return;
	} /* end connect request code */

	/* validate circuit number */
	if((cb = get_n4circ(hdr->yourindex, hdr->yourid)) == NULL){
		free_p(bpp);
		return;
	}

	/* Check for choke flag */
	if(hdr->opcode & NR4CHOKE)
		gotchoke = 1;
	else
		gotchoke = 0;
	
	/* Here's where the interesting stuff gets done */
	switch(cb->state){
	case NR4STCPEND:
		switch(op){
		case NR4OPCONAK:
			/* Save the round trip time for later use */
			i = dur_timer(&cb->tcd) - read_timer(&cb->tcd);
			stop_timer(&cb->tcd);
			if(gotchoke){		/* connect rejected */
				cb->dreason = NR4RREFUSED;
				nr4state(cb, NR4STDISC);
				break;
			}
			cb->yournum = hdr->u.conack.myindex;
			cb->yourid = hdr->u.conack.myid;
			window = hdr->u.conack.window > Nr4window ?
					 Nr4window : hdr->u.conack.window;

			if(init_nr4window(cb, window) == -1){
				cb->dreason = NR4RRESET;
				nr4state(cb, NR4STDISC);
			} else {
				nr4defaults(cb);	/* set up timers, window pointers */
				
				if(cb->cdtries == 1)	/* No retries */
					/* Use measured rtt */
					cb->srtt = i;
				else
					/* else use default */
					cb->srtt = Nr4irtt;
					
				nr4state(cb, NR4STCON);
				nr4output(cb);		/* start sending anything on the txq */
			}
			break;
		default:
			/* We can't respond to anything else without
			 * Their ID and index
			 */
		  	free_p(bpp);
			return;
		}
		break;
	case NR4STCON:
		switch(op){
		case NR4OPDISRQ:
			/* format reply packet */
			rhdr.opcode = NR4OPDISAK;
			rhdr.yourindex = cb->yournum;
			rhdr.yourid = cb->yourid;
			nr4sframe(cb->remote.node,&rhdr,NULL);
			cb->dreason = NR4RREMOTE;
			nr4state(cb, NR4STDISC);
			break;
		  case NR4OPINFO:
			/* Do receive frame processing */
		  	nr4rframe(cb, hdr->u.info.txseq, bpp);

			/* Reset the choke flag if no longer choked.  Processing
			 * the ACK will kick things off again.
			 */
			if(cb->choked && !gotchoke){
				stop_timer(&cb->tchoke);
				cb->choked = 0;
			}
				
			/* We delay processing the receive sequence number until
			 * now, because the ACK might pull more off the txq and send
			 * it, and we want the implied ACK in those frames to be right
			 *
			 * Only process NAKs if the choke flag is off.  It appears
			 * that NAKs should never be sent with choke on, by the way,
			 * but you never know, considering that there is no official
			 * standard for this protocol
			 */
			if(hdr->opcode & NR4NAK && !gotchoke)
				nr4gotnak(cb, hdr->u.info.rxseq);

			/* We always do ACK processing, too, since the NAK of one
			 * packet may be the implied ACK of another.  The gotchoke
			 * flag is used to prevent sending any new frames, since
			 * we are just going to purge them next anyway if this is
			 * the first time we've seen the choke flag.  If we are
			 * already choked, this call will return immediately.
			 */
			nr4ackours(cb, hdr->u.info.rxseq, gotchoke);

			/* If we haven't seen the choke flag before, purge the
			 * send window and set the timer and the flag.
			 */
			if(!cb->choked && gotchoke)
				nr4choke(cb);
			break;
		  case NR4OPACK:
			if(cb->choked && !gotchoke){
				/* clear choke if appropriate */
				stop_timer(&cb->tchoke);
				cb->choked = 0;
			}	
		  	if(hdr->opcode & NR4NAK && !gotchoke)
				nr4gotnak(cb, hdr->u.ack.rxseq);	/* process NAKs */
				
		  	nr4ackours(cb, hdr->u.ack.rxseq, gotchoke); /* and ACKs */

			if(!cb->choked && gotchoke)	/* First choke seen */
				nr4choke(cb);		/* Set choke status */

			break;
		}
		break;
	case NR4STDPEND:
		switch(op){
		case NR4OPDISAK:
		  	cb->dreason = NR4RNORMAL;
			nr4state(cb, NR4STDISC);
			break;
		case NR4OPINFO:
			/* We can still do receive frame processing until
			 * the disconnect acknowledge arrives, but we won't
			 * bother to process ACKs, since we've flushed our
			 * transmit buffers and queue already.
			 */
		  	nr4rframe(cb, hdr->u.info.txseq, bpp);
			break;
		}
	}	/* End switch(state) */
}


/* Send a net/rom layer 4 frame.  *bpp should be NULL unless the frame
 * type is info.
 */
void
nr4sframe(
uint8 *dest,
struct nr4hdr *hdr,
struct mbuf **bpp
){
	struct mbuf *n4b;

	if((n4b = htonnr4(hdr)) == NULL){
		free_p(bpp);
		return;
	} else {
		append(&n4b, bpp);
		nr3output(dest, &n4b);
	}
}

/* Receive frame processing */
static void
nr4rframe(
struct nr4cb *cb,
unsigned rxseq,
struct mbuf **bpp
){
	struct nr4hdr rhdr;
	unsigned window = cb->window;
	unsigned rxbuf = rxseq % window;
	unsigned newdata = 0;		/* whether to upcall */

#ifdef NR4DEBUG
	printf("Processing received info\n");
#endif

	/* If we're choked, just reset the ACK timer to blast out
	 * another CHOKE indication after the ackdelay
	 */
	if(cb->qfull){
		start_timer(&cb->tack);
		return;
	}
	
	/* If frame is out of sequence, it is either due to a lost frame
	 * or a retransmission of one seen earlier.  We do not want to NAK
	 * the latter, as the far end would see this as a requirement to
	 * retransmit the expected frame, which is probably already in the
	 * pipeline.  This in turn would cause another out-of-sequence
	 * condition, another NAK, and the process would repeat indefinitely.
	 * Therefore, if the frame is out-of-sequence, but within the last
	 * 'n' frames by sequence number ('n' being the window size), just
	 * accept it and discard it.  Else, NAK it if we haven't already.
	 *	(Modified by Rob Stampfli, kd8wk, 9 Jan 1990)
	 */
	if(rxseq != cb->rxpected && !cb->naksent){
#ifdef NR4DEBUG
		printf("Frame out of sequence -- expected %u, got %u.\n",
			   cb->rxpected, rxseq);
#endif				
		if(nr4between(cb->rxpected,
		   (rxseq + window) & NR4SEQMASK, cb->rxpastwin))
			/* just a repeat of old frame -- queue ack for
			 * expected frame
			 */
			start_timer(&cb->tack);
		else {			/* really bogus -- a NAKable frame */
			rhdr.opcode = NR4OPACK | NR4NAK;
			rhdr.yourindex = cb->yournum;
			rhdr.yourid = cb->yourid;
			rhdr.u.ack.rxseq = cb->rxpected;
			nr4sframe(cb->remote.node,&rhdr,NULL);
		
			/* Now make sure we don't send any more of these until
			 * we see some good data.  Otherwise full window
			 * retransmissions would result in a flurry of NAKs
			 */
		
			cb->naksent = 1;
		}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美一级在线免费| 亚洲精品一区在线观看| 91欧美一区二区| 国产suv精品一区二区6| 大白屁股一区二区视频| 成人激情动漫在线观看| a亚洲天堂av| 99综合影院在线| 色播五月激情综合网| 欧美中文字幕一区二区三区 | 国产精品女同互慰在线看 | 91美女视频网站| 91国模大尺度私拍在线视频| 色妞www精品视频| 欧美日韩激情一区| 欧美成人a在线| 国产欧美一区二区三区在线看蜜臀 | 国产一区在线观看视频| 国产一区二区三区久久悠悠色av| 国产成人午夜片在线观看高清观看| 成人性生交大合| 91天堂素人约啪| 欧美人与z0zoxxxx视频| 欧美成人精品3d动漫h| 亚洲国产精品国自产拍av| 亚洲综合色区另类av| 蜜桃精品视频在线| 成人av片在线观看| 制服丝袜亚洲网站| 日本一区二区成人| 亚洲午夜一区二区| 国产一区二区美女| 欧美性色黄大片| 玉米视频成人免费看| 亚洲午夜视频在线| 久久电影网站中文字幕| 色综合久久综合网97色综合 | 欧美日韩视频在线第一区| 日韩欧美的一区二区| ●精品国产综合乱码久久久久| 奇米影视一区二区三区| 波多野结衣在线一区| 欧美一区二区三区婷婷月色| 国产精品久线观看视频| 九色综合狠狠综合久久| 欧美图区在线视频| 日本一区二区三区在线不卡| 免费欧美日韩国产三级电影| 91一区二区在线| 久久综合给合久久狠狠狠97色69| 一区二区三区精品久久久| 欧美亚洲动漫制服丝袜| 国产日产欧产精品推荐色 | 中文字幕中文字幕在线一区 | 亚洲激情在线激情| 国产乱码精品一区二区三区五月婷| 精品视频全国免费看| 国产精品丝袜久久久久久app| 日本不卡1234视频| 欧美另类videos死尸| 亚洲人成网站精品片在线观看| 久国产精品韩国三级视频| 欧美日韩色一区| 一区二区三区免费观看| 一本到不卡精品视频在线观看 | 美女精品自拍一二三四| 欧美性xxxxxx少妇| 亚洲美女区一区| 91女神在线视频| 亚洲男人的天堂在线aⅴ视频| 成人教育av在线| 日韩一区欧美一区| 成人精品国产福利| 欧美国产日韩精品免费观看| 蜜臀国产一区二区三区在线播放| 色噜噜夜夜夜综合网| 亚洲美女屁股眼交| 色噜噜偷拍精品综合在线| 国产精品电影院| 色老汉一区二区三区| 亚洲欧美日韩国产另类专区| 91日韩精品一区| 亚洲最大成人综合| 欧美日本不卡视频| 秋霞午夜鲁丝一区二区老狼| 欧美mv日韩mv亚洲| 国产成人精品三级| 亚洲人妖av一区二区| 欧美亚一区二区| 奇米色一区二区| 久久久精品一品道一区| 成人一区在线看| 亚洲综合自拍偷拍| 亚洲欧洲韩国日本视频 | 色婷婷久久久综合中文字幕 | 3d动漫精品啪啪一区二区竹菊| 亚洲sss视频在线视频| 91精品视频网| 国产一区二区导航在线播放| 国产精品传媒在线| 国产精品三级在线观看| caoporen国产精品视频| 亚洲一级在线观看| 2019国产精品| 91网站在线播放| 日本va欧美va欧美va精品| 国产亚洲一本大道中文在线| 91视频在线观看| 美日韩一级片在线观看| 国产精品毛片无遮挡高清| 欧美在线一二三四区| 精品在线免费观看| 久久青草国产手机看片福利盒子| 久久精品国产亚洲一区二区三区| 久久免费美女视频| 日本精品视频一区二区三区| 蓝色福利精品导航| 亚洲天堂网中文字| 精品欧美乱码久久久久久 | 国产亚洲欧美日韩日本| 欧洲视频一区二区| 成人免费视频app| 免费国产亚洲视频| 一卡二卡欧美日韩| 国产三级精品视频| 欧美一二三区精品| 欧美写真视频网站| 成人午夜在线免费| 精品一区二区三区在线播放| 亚洲国产综合在线| 亚洲你懂的在线视频| 国产精品每日更新| 国产天堂亚洲国产碰碰| 欧美成人r级一区二区三区| 欧美久久久久久久久| 色综合久久综合网97色综合| 成人性色生活片免费看爆迷你毛片| 久久国产人妖系列| 蜜桃久久精品一区二区| 日韩电影免费在线看| 亚洲国产精品尤物yw在线观看| 亚洲视频一区二区在线| 国产午夜精品久久久久久久 | 国产精品进线69影院| 久久综合九色综合97婷婷女人| 91精品国产色综合久久久蜜香臀| 一区视频在线播放| 欧美剧情片在线观看| av在线播放一区二区三区| 高潮精品一区videoshd| 精品一区二区在线播放| 麻豆国产精品一区二区三区 | 成人激情开心网| 风间由美中文字幕在线看视频国产欧美| 男人操女人的视频在线观看欧美| 日欧美一区二区| 天使萌一区二区三区免费观看| 亚洲成av人片在www色猫咪| 亚洲电影第三页| 亚洲va欧美va人人爽| 日本不卡视频在线| 紧缚奴在线一区二区三区| 国产精品一级二级三级| 成人午夜电影小说| 成人av资源在线观看| 色婷婷精品大在线视频| 欧美日韩小视频| 日韩限制级电影在线观看| 久久久久久久久97黄色工厂| 精品一区二区三区久久| 天天影视色香欲综合网老头| 日韩精彩视频在线观看| 激情五月婷婷综合网| 成人免费高清在线| 在线国产亚洲欧美| 日韩欧美国产电影| 国产精品女人毛片| 午夜免费欧美电影| 国产成人一级电影| 欧美日韩亚洲综合在线 欧美亚洲特黄一级 | 99这里都是精品| 欧美精品自拍偷拍| 久久久国产精品不卡| 亚洲另类色综合网站| 久久国内精品视频| av一区二区三区黑人| 337p亚洲精品色噜噜狠狠| 久久精品欧美一区二区三区不卡| 亚洲欧美激情小说另类| 美女精品一区二区| 色婷婷精品大在线视频 | 欧美日韩精品欧美日韩精品| 日韩精品专区在线影院观看| 国产精品国产精品国产专区不蜜| 日韩激情中文字幕| 99re视频精品| 亚洲精品在线免费观看视频| 亚洲欧美日本韩国| 国产大陆精品国产| 欧美一级欧美一级在线播放|