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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? nr4.c

?? TCPIP協(xié)議包
?? 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;
		}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩在线电影| 国产精品护士白丝一区av| 国产婷婷色一区二区三区四区| 国产精品久久久久影院| 三级成人在线视频| 91丨porny丨在线| 精品精品欲导航| 亚洲福利电影网| 99久久精品免费看国产免费软件| 欧美变态凌虐bdsm| 亚洲gay无套男同| 色偷偷一区二区三区| 久久久久久影视| 精品在线亚洲视频| 91精品国产入口在线| 洋洋av久久久久久久一区| 成人av在线资源网| 中文字幕第一页久久| 国产成人一级电影| 久久亚洲影视婷婷| 精品亚洲porn| 欧美mv日韩mv亚洲| 久草热8精品视频在线观看| 欧美精品高清视频| 亚洲成人av电影在线| 欧美日韩一区二区在线视频| 亚洲日本在线视频观看| 成人av网站在线观看| 国产精品蜜臀av| av中文字幕不卡| 1024亚洲合集| 色视频一区二区| 亚洲国产日日夜夜| 欧美日韩国产欧美日美国产精品| 亚洲自拍偷拍麻豆| 欧美性高清videossexo| 亚洲成精国产精品女| 欧美日韩国产精选| 日本免费新一区视频| 欧美电影免费观看高清完整版在 | 亚洲高清在线视频| 欧美日本国产视频| 青草av.久久免费一区| 日韩一区二区三区三四区视频在线观看| 偷偷要91色婷婷| 精品日韩一区二区三区免费视频| 精品无码三级在线观看视频| 久久午夜羞羞影院免费观看| 国产精品一区二区在线播放| 中文在线资源观看网站视频免费不卡| 99riav久久精品riav| 亚洲综合色丁香婷婷六月图片| 欧美日韩亚洲丝袜制服| 蜜桃av一区二区三区电影| 久久久久久久久久久99999| 粉嫩av亚洲一区二区图片| 亚洲少妇屁股交4| 3d动漫精品啪啪1区2区免费| 精品一区二区三区久久| 中文字幕av不卡| 欧美电影影音先锋| 国产乱妇无码大片在线观看| 国产精品国产三级国产普通话99| 欧美优质美女网站| 国产精品资源站在线| 亚洲欧美福利一区二区| 欧美一二三在线| 99热精品国产| 精品一区二区免费视频| 一区在线播放视频| 欧美一区二区三区四区在线观看| 国产做a爰片久久毛片| 一区二区三区在线不卡| 欧美电影免费提供在线观看| 99综合影院在线| 久久97超碰色| 亚洲综合色区另类av| 日本一区二区三区四区| 欧美丰满少妇xxxbbb| 成人精品国产免费网站| 久久成人麻豆午夜电影| 亚洲激情中文1区| 欧美电影一区二区| www.99精品| 国产一区二区三区蝌蚪| 日韩福利视频导航| 一区二区高清视频在线观看| 国产欧美精品一区二区三区四区 | 国产午夜精品一区二区三区嫩草| 欧美丝袜自拍制服另类| 成人av午夜影院| 国产福利一区在线| 久久疯狂做爰流白浆xx| 视频在线观看一区| 午夜精品福利久久久| 一区二区三区久久| 亚洲色图制服诱惑| 国产精品久久国产精麻豆99网站| 91精品中文字幕一区二区三区| 色狠狠一区二区| 91影院在线免费观看| av在线不卡电影| 波多野结衣中文字幕一区二区三区 | 九一九一国产精品| 图片区小说区国产精品视频| 亚洲高清中文字幕| 亚洲国产精品久久人人爱| 一区二区三区在线观看视频| 亚洲视频在线观看三级| 国产精品久久久久桃色tv| 欧美激情资源网| 国产精品无人区| 国产精品免费av| 亚洲视频你懂的| 樱花草国产18久久久久| 亚洲伦理在线免费看| 亚洲夂夂婷婷色拍ww47| 亚洲麻豆国产自偷在线| 亚洲精品乱码久久久久久黑人| 中文字幕欧美一| 亚洲欧美日本在线| 亚洲最大成人综合| 亚洲国产wwwccc36天堂| 蜜臀av一级做a爰片久久| 久久99精品国产.久久久久久| 老司机免费视频一区二区| 国产一区二区三区不卡在线观看 | 国产欧美精品国产国产专区| 亚洲国产精品激情在线观看| 亚洲三级理论片| 亚洲电影中文字幕在线观看| 日韩精品乱码av一区二区| 美女被吸乳得到大胸91| 成人在线视频首页| 色婷婷综合激情| 日韩欧美视频一区| 中文字幕精品在线不卡| 亚洲激情图片qvod| 国产乱理伦片在线观看夜一区| 成人av资源站| 欧美蜜桃一区二区三区| 2021中文字幕一区亚洲| 综合激情成人伊人| 亚洲大片在线观看| 国产很黄免费观看久久| 一本色道久久综合亚洲91| 日韩欧美国产1| 中文字幕亚洲不卡| 视频一区二区三区入口| 成人午夜看片网址| 欧美日韩另类国产亚洲欧美一级| 精品国产精品网麻豆系列| 自拍偷自拍亚洲精品播放| 日韩黄色一级片| av一区二区久久| 欧美一区二区三区思思人| 国产精品国产三级国产aⅴ入口| 亚洲精品国产第一综合99久久| 日本亚洲三级在线| 99精品视频在线免费观看| 日韩一级二级三级精品视频| 亚洲天堂久久久久久久| 久久精品久久精品| 欧美亚洲日本一区| 亚洲国产精品黑人久久久| 日韩高清欧美激情| 色噜噜久久综合| 欧美激情一区不卡| 韩国av一区二区三区| 欧美日韩精品欧美日韩精品| 国产精品久久久久aaaa樱花| 美女一区二区久久| 欧美私模裸体表演在线观看| 中文字幕亚洲精品在线观看| 国产曰批免费观看久久久| 欧美老人xxxx18| 一卡二卡欧美日韩| www.66久久| 国产精品天天摸av网| 国产美女视频一区| 日韩免费视频线观看| 亚洲国产你懂的| 色噜噜狠狠成人网p站| 国产精品久久久久毛片软件| 国产中文字幕精品| 欧美成人vr18sexvr| 视频精品一区二区| 欧美一区二区三区的| 韩日欧美一区二区三区| 欧美区视频在线观看| 亚洲成人精品一区| 欧美色视频在线| 亚洲影视资源网| 精品视频在线视频| 亚洲.国产.中文慕字在线| 欧美人与性动xxxx| 日韩精品一级二级 | 国产精品久久毛片av大全日韩| 国产一区二区在线视频| 精品国产电影一区二区|