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

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

?? net.c

?? UCOS-ii對于網絡的支持代碼
?? C
字號:
/*****************************************************************************
* net.c - Network Globals program file.
*
* portions Copyright (c) 1997 by Global Election Systems Inc.
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice and the following disclaimer are included verbatim in any 
* distributions. No written agreement, license, or royalty fee is required
* for any of the authorized uses.
*
* THIS SOFTWARE IS PROVIDED BY THE 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 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.
*
******************************************************************************
* REVISION HISTORY
*
* 97-12-08 Guy Lancaster <lancasterg@acm.org>, Global Election Systems Inc.
*	Original.
*****************************************************************************/

#include "typedefs.h"
#include <string.h>
#include "stdio.h"
#include "netbuf.h"
#include "devio.h"

#include "net.h"
#include "netmagic.h"
#include "netppp.h"
#include "netip.h"
#include "nettcp.h"

#include "debug.h"


/******************************/
/*** PUBLIC DATA STRUCTURES ***/
/******************************/
u_short	idle_time_limit = 0;	/* Disconnect if idle for this many seconds */
int	maxconnect = 0;				/* Maximum connect time */
int	refuse_pap = 0;				/* Don't wanna auth. ourselves with PAP */
int	refuse_chap = 0;			/* Don't wanna auth. ourselves with CHAP */

char hostname[MAXNAMELEN + 1];	/* Our hostname */
char user[MAXNAMELEN + 1];		/* Username for PAP */
char passwd[MAXSECRETLEN + 1];	/* Password for PAP */
char our_name[MAXNAMELEN + 1];	/* Our name for authentication purposes */
char remote_name[MAXNAMELEN + 1]; /* Peer's name for authentication */
int	explicit_remote = 0;		/* remote_name specified with remotename opt */
int	usehostname = 0;			/* Use hostname for our_name */

u_int32_t	netMask;			/* IP netmask to set on interface */
u_int32_t	localHost;			/* Our IP address in */


/***********************************/
/*** PUBLIC FUNCTION DEFINITIONS ***/
/***********************************/
/*
 * netInit - Initialize the network communications subsystem.
 */
void netInit(void)
{
	strcpy(hostname, LOCALHOST);
	user[0] = '\0';
	passwd[0] = '\0';
	our_name[0] = '\0';
	remote_name[0] = '\0';
	explicit_remote = 0;
	magicInit();
	ipInit();
	pppInit();
	tcpInit();
}

/*
 * Set the login user name and password for login and authentication
 *	purposes.  Using globals this way is rather hokey but until we
 *	fix some other things (like implementing a 2 stop PPP open),
 *	this will do for now.
 */
void netSetLogin(const char *luser, const char *lpassword)
{
	strncpy(user, luser, MAXNAMELEN);
	user[MAXNAMELEN] = '\0';
	strncpy(passwd, lpassword, MAXNAMELEN);
	passwd[MAXNAMELEN] = '\0';
}

/*
 * gethostbyname - Look up host name.
 * Return host's netent if found, otherwise NULL.
 */
#pragma argsused
struct hostent	*gethostbyname (const char *hn)
{
	return NULL;
}


/* Convert a host long to a network long.  */
u_long htonl (u_long __arg)
{
	asm {
		mov  ax, word ptr [__arg];
		xchg ah, al;
		xchg ax, word ptr [__arg + 2];
		xchg ah, al;
		mov  word ptr [__arg], ax;
	}
	return __arg;
}

/* Convert a host short to a network short.  */
u_short htons (u_short __arg)
{
	asm {
		mov  ax, word ptr [__arg];
		xchg ah, al;
		mov  word ptr [__arg], ax;
	}
	return __arg;
}

/* Convert a network long to a host long.  */
u_long ntohl (u_long __arg)
{
	asm {
		mov  ax, word ptr [__arg];
		xchg ah, al;
		xchg ax, word ptr [__arg + 2];
		xchg ah, al;
		mov  word ptr [__arg], ax;
	}
	return __arg;
}

/* Convert a network short to a host short.  */
u_short ntohs (u_short __arg)
{
	asm {
		mov  ax, word ptr [__arg];
		xchg ah, al;
		mov  word ptr [__arg], ax;
	}
	return __arg;
}


/*
 * inChkSum - Compute the internet ones complement 16 bit checksum for a given
 * length of a network buffer chain starting at offset off0.
 * Return the checksum in network byte order.
 */
#define ADDCARRY(x)  (x > 65535 ? x -= 65535 : x)
#define REDUCE {l_util.l = sum; sum = (u_long)l_util.s[0] + (u_long)l_util.s[1]; ADDCARRY(sum);}
u_short inChkSum(NBuf *nb, int len, int off0)
{
	register u_short *w;
	register long sum = 0;
	register int bufLen = 0;
	register NBuf *n0 = nb;
	int byte_swapped = 0;

	union {
		char	c[2];
		u_short	s;
	} s_util;
	union {
		u_short s[2];
		long	l;
	} l_util;

	/* Ensure that there is enough data for the offset. */
	if (nb->len <= off0)
		return -1;
	
	/*
	 * Adjust buffer start for the offset.
	 */
	nb->len -= off0;
	nb->data += off0;
	for (;n0 && len; n0 = n0->nextBuf) {
		if (n0->len <= 0)
			continue;
		w = nBUFTOPTR(n0, u_short *);
		if (bufLen == -1) {
			/*
			 * The first byte of this nBuf is the continuation
			 * of a word spanning between this nBuf and the
			 * last nBuf.
			 *
			 * s_util.c[0] is already saved when scanning previous 
			 * nBuf.
			 */
			s_util.c[1] = *(char *)w;
			sum += s_util.s;
			w = (u_short *)((char *)w + 1);
			bufLen = n0->len - 1;
			len--;
		} else
			bufLen = n0->len;
		if (len < bufLen)
			bufLen = len;
		len -= bufLen;
		/*
		 * Force to even boundary.
		 */
		if ((1 & (int) w) && (bufLen > 0)) {
			REDUCE;
			sum <<= 8;
			s_util.c[0] = *(u_char *)w;
			w = (u_short *)((char *)w + 1);
			bufLen--;
			byte_swapped = 1;
		}
		/*
		 * Unroll the loop to make overhead from
		 * branches &c small.
		 */
		while ((bufLen -= 32) >= 0) {
			sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3];
			sum += w[4]; sum += w[5]; sum += w[6]; sum += w[7];
			sum += w[8]; sum += w[9]; sum += w[10]; sum += w[11];
			sum += w[12]; sum += w[13]; sum += w[14]; sum += w[15];
			w += 16;
		}
		bufLen += 32;
		while ((bufLen -= 8) >= 0) {
			sum += w[0]; sum += w[1]; sum += w[2]; sum += w[3];
			w += 4;
		}
		bufLen += 8;
		if (bufLen == 0 && byte_swapped == 0)
			continue;
		REDUCE;
		while ((bufLen -= 2) >= 0) {
			sum += *w++;
		}
		if (byte_swapped) {
			REDUCE;
			sum <<= 8;
			byte_swapped = 0;
			if (bufLen == -1) {
				s_util.c[1] = *(char *)w;
				sum += s_util.s;
				bufLen = 0;
			} else
				bufLen = -1;
		} else if (bufLen == -1)
			s_util.c[0] = *(char *)w;
	}
	/*
	 * Reset buffer start for the offset.
	 */
	nb->len += off0;
	nb->data -= off0;
	
	if (len)
		IPDEBUG((LOG_ERR, TL_IP, "inChkSum: out of data"));
	if (bufLen == -1) {
		/* The last nBuf has odd # of bytes. Follow the
		   standard (the odd byte may be shifted left by 8 bits
		   or not as determined by endian-ness of the machine) */
		s_util.c[1] = 0;
		sum += s_util.s;
	}
	REDUCE;
	return ((u_short)(~sum) & 0xffff);
}


/*
 * print_string - print a readable representation of a string using
 * printer.
 */
void print_string(
	char *p,
	int len,
	void (*printer) __P((void *, char *, ...)),
	void *arg
)
{
	int c;
	
	printer(arg, "\"");
	for (; len > 0; --len) {
		c = *p++;
		if (' ' <= c && c <= '~') {
			if (c == '\\' || c == '"')
				printer(arg, "\\");
			printer(arg, "%c", c);
		} else {
			switch (c) {
			case '\n':
				printer(arg, "\\n");
				break;
			case '\r':
				printer(arg, "\\r");
				break;
			case '\t':
				printer(arg, "\\t");
				break;
			default:
				printer(arg, "\\%.3o", c);
			}
		}
	}
	printer(arg, "\"");
}


/*
 * bcmp - Compare a string of bytes and return non-zero if they differ.
 * Note: This differs from strncmp() in that nulls are not recognized
 *    as delimiters.
 */
int bcmp(u_char *s0, u_char *s1, int len)
{
	for (len--; len >= 0; len--)
		if (s0[len] != s1[len])
			return -1;
	return 0;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区久久| 欧美国产欧美综合| 在线视频一区二区免费| 不卡视频在线看| 国产成人精品免费看| 国产精品一二三四五| 韩国女主播成人在线观看| 激情小说亚洲一区| 国产美女一区二区三区| 国产91丝袜在线播放九色| 成人免费av资源| 91视频xxxx| 欧美精品免费视频| 精品久久久久久无| 欧美国产成人在线| 亚洲乱码精品一二三四区日韩在线| 亚洲免费毛片网站| 午夜精品影院在线观看| 男人操女人的视频在线观看欧美| 看电影不卡的网站| 欧美高清激情brazzers| 欧美一区日本一区韩国一区| 欧美xxxxx牲另类人与| 国产喂奶挤奶一区二区三区| 亚洲欧美日本韩国| 青青草97国产精品免费观看无弹窗版| 免费不卡在线观看| 成人av资源下载| 欧美美女直播网站| 久久久精品欧美丰满| 中文字幕一区二区日韩精品绯色| 亚洲成av人片在线观看| 精品中文av资源站在线观看| 99视频精品免费视频| 91精品国产色综合久久ai换脸 | 国产精品你懂的| 亚洲成av人片在线观看无码| 国产精品资源网站| 日本高清视频一区二区| 久久久久久久综合| 亚洲成在线观看| av在线不卡观看免费观看| 91精品国产欧美一区二区| 国产精品久久一级| 奇米色777欧美一区二区| 99精品视频在线免费观看| 日韩一级片网址| 亚洲综合一区在线| 国产精品原创巨作av| 欧美精品一级二级| 亚洲激情第一区| 国产成人精品亚洲777人妖 | 久久女同精品一区二区| 亚洲一区二区精品久久av| 黑人巨大精品欧美一区| 欧美美女一区二区在线观看| 1区2区3区欧美| 成人永久免费视频| 日韩欧美高清一区| 性欧美大战久久久久久久久| 一本色道综合亚洲| 国产精品网站导航| 国产91色综合久久免费分享| 2023国产精品| 麻豆精品视频在线| 日韩一区二区三区av| 亚洲成人午夜电影| 欧美视频一区二| 一区二区三区在线视频免费| 99久久婷婷国产综合精品电影| 日本一区二区视频在线| 国内精品伊人久久久久av影院| 欧美岛国在线观看| 激情图区综合网| 久久天天做天天爱综合色| 另类人妖一区二区av| 欧美一区二区久久| 免费成人你懂的| 欧美第一区第二区| 精品一区二区三区久久久| 日韩久久久精品| 国产综合一区二区| 日本一区免费视频| 91同城在线观看| 一个色综合av| 91精品国产品国语在线不卡| 蜜桃视频一区二区三区在线观看| 日韩欧美一级在线播放| 国产自产高清不卡| 国产无人区一区二区三区| 成人18视频日本| 亚洲午夜电影在线观看| 欧美一区二区女人| 国产精品亚洲午夜一区二区三区 | 欧美一区二区美女| 精品一区二区三区香蕉蜜桃| 久久久午夜精品理论片中文字幕| 成人av第一页| 亚洲国产日韩在线一区模特 | 国产精品看片你懂得| 91蝌蚪porny成人天涯| 香蕉成人伊视频在线观看| 欧美一级电影网站| 成人动漫在线一区| 午夜精品久久久久久| 精品对白一区国产伦| 色综合久久天天| 精品系列免费在线观看| 成人欧美一区二区三区小说| 欧美日韩你懂得| 福利一区二区在线观看| 亚洲国产精品久久不卡毛片| 久久精品一区二区三区四区| 91豆麻精品91久久久久久| 青青草精品视频| 亚洲免费视频中文字幕| 精品国产成人系列| 一本大道久久a久久精二百| 久99久精品视频免费观看| 亚洲精品成人精品456| 久久久久久久电影| 欧美裸体一区二区三区| 成人app软件下载大全免费| 久久精品国产精品亚洲综合| 亚洲精品ww久久久久久p站| 国产欧美精品国产国产专区| 91精品国产福利在线观看| 色一情一伦一子一伦一区| 粉嫩13p一区二区三区| 奇米色一区二区| 午夜欧美电影在线观看| 中文字幕一区二区三区在线观看| 日韩精品中文字幕一区二区三区| 欧美亚洲高清一区| 91麻豆国产自产在线观看| 国产精品小仙女| 国产一级精品在线| 精品午夜久久福利影院| 五月婷婷久久综合| 亚洲国产日产av| 一区二区三区四区在线| 国产精品久久久久一区| 欧美经典一区二区| 久久久国际精品| 国产亚洲精品久| 久久香蕉国产线看观看99| 欧美大片免费久久精品三p| 91麻豆精品久久久久蜜臀| 欧美精品一二三| 欧美日韩亚洲不卡| 欧美精品欧美精品系列| 欧美精品久久天天躁| 91精品国产91久久综合桃花| 欧美日韩一本到| 91精品综合久久久久久| 欧美一区二区日韩一区二区| 日韩女优av电影| 久久精品一区二区三区四区 | 色综合中文综合网| 高清不卡一二三区| 国产成人欧美日韩在线电影| 国产高清视频一区| av一本久道久久综合久久鬼色| 成人av片在线观看| 在线亚洲一区观看| 欧美美女直播网站| 欧美成人综合网站| 国产亚洲欧美在线| 亚洲天堂中文字幕| 亚洲大片在线观看| 裸体歌舞表演一区二区| 国产成人高清视频| 91在线视频网址| 欧美电影一区二区三区| 欧美mv日韩mv亚洲| 18欧美乱大交hd1984| 亚洲第一搞黄网站| 国产一区二区三区av电影 | 亚洲视频狠狠干| 亚洲国产精品久久不卡毛片| 蜜臀av性久久久久蜜臀aⅴ四虎| 国产精品18久久久久久vr| 91丨porny丨最新| 欧美丰满嫩嫩电影| 国产精品日产欧美久久久久| 一区二区三区视频在线观看| 久久精品国产在热久久| 成人av电影在线| 日韩写真欧美这视频| 自拍偷拍亚洲激情| 麻豆国产91在线播放| 色综合久久中文字幕综合网| 精品国精品自拍自在线| 亚洲色图另类专区| 经典三级在线一区| 欧美日韩激情在线| 综合激情网...| 国产一区二区在线电影| 欧美亚洲国产一卡| 国产精品久久免费看|