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

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

?? chap.c

?? ppp協(xié)議的lwip源代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*** WARNING - THIS HAS NEVER BEEN FINISHED ***/
/*****************************************************************************
* chap.c - Network Challenge Handshake Authentication Protocol program file.
*
* Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc.
* 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
*
* 03-01-01 Marc Boucher <marc@mbsi.ca>
*   Ported to lwIP.
* 97-12-04 Guy Lancaster <lancasterg@acm.org>, Global Election Systems Inc.
*	Original based on BSD chap.c.
*****************************************************************************/
/*
 * chap.c - Challenge Handshake Authentication Protocol.
 *
 * Copyright (c) 1993 The Australian National University.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms are permitted
 * provided that the above copyright notice and this paragraph are
 * duplicated in all such forms and that any documentation,
 * advertising materials, and other materials related to such
 * distribution and use acknowledge that the software was developed
 * by the Australian National University.  The name of the University
 * may not be used to endorse or promote products derived from this
 * software without specific prior written permission.
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 * Copyright (c) 1991 Gregory M. Christy.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms are permitted
 * provided that the above copyright notice and this paragraph are
 * duplicated in all such forms and that any documentation,
 * advertising materials, and other materials related to such
 * distribution and use acknowledge that the software was developed
 * by Gregory M. Christy.  The name of the author may not be used to
 * endorse or promote products derived from this software without
 * specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 */

#include "pppconf.h"
#if PPP_SUPPORT > 0
#include "ppp.h"
#include "magic.h"

#if CHAP_SUPPORT > 0

#include "randm.h"
#include "auth.h"
#include "md5.h"
#include "chap.h"
#include "chpms.h"
#include "pppdebug.h"


/*************************/
/*** LOCAL DEFINITIONS ***/
/*************************/


/************************/
/*** LOCAL DATA TYPES ***/
/************************/


/***********************************/
/*** LOCAL FUNCTION DECLARATIONS ***/
/***********************************/
/*
 * Protocol entry points.
 */
static void ChapInit (int);
static void ChapLowerUp (int);
static void ChapLowerDown (int);
static void ChapInput (int, u_char *, int);
static void ChapProtocolReject (int);
static int  ChapPrintPkt (u_char *, int,
			      void (*) (void *, char *, ...), void *);

static void ChapChallengeTimeout (void *);
static void ChapResponseTimeout (void *);
static void ChapReceiveChallenge (chap_state *, u_char *, int, int);
static void ChapRechallenge (void *);
static void ChapReceiveResponse (chap_state *, u_char *, int, int);
static void ChapReceiveSuccess(chap_state *cstate, u_char *inp, u_char id, int len);
static void ChapReceiveFailure(chap_state *cstate, u_char *inp, u_char id, int len);
static void ChapSendStatus (chap_state *, int);
static void ChapSendChallenge (chap_state *);
static void ChapSendResponse (chap_state *);
static void ChapGenChallenge (chap_state *);


/******************************/
/*** PUBLIC DATA STRUCTURES ***/
/******************************/
chap_state chap[NUM_PPP];		/* CHAP state; one for each unit */

struct protent chap_protent = {
    PPP_CHAP,
    ChapInit,
    ChapInput,
    ChapProtocolReject,
    ChapLowerUp,
    ChapLowerDown,
    NULL,
    NULL,
#if 0
    ChapPrintPkt,
    NULL,
#endif
    1,
    "CHAP",
#if 0
    NULL,
    NULL,
    NULL
#endif
};



/*****************************/
/*** LOCAL DATA STRUCTURES ***/
/*****************************/
static char *ChapCodenames[] = {
	"Challenge", "Response", "Success", "Failure"
};



/***********************************/
/*** PUBLIC FUNCTION DEFINITIONS ***/
/***********************************/
/*
 * ChapAuthWithPeer - Authenticate us with our peer (start client).
 *
 */
void ChapAuthWithPeer(int unit, char *our_name, int digest)
{
	chap_state *cstate = &chap[unit];
	
	cstate->resp_name = our_name;
	cstate->resp_type = digest;
	
	if (cstate->clientstate == CHAPCS_INITIAL ||
			cstate->clientstate == CHAPCS_PENDING) {
		/* lower layer isn't up - wait until later */
		cstate->clientstate = CHAPCS_PENDING;
		return;
	}
	
	/*
	 * We get here as a result of LCP coming up.
	 * So even if CHAP was open before, we will 
	 * have to re-authenticate ourselves.
	 */
	cstate->clientstate = CHAPCS_LISTEN;
}


/*
 * ChapAuthPeer - Authenticate our peer (start server).
 */
void ChapAuthPeer(int unit, char *our_name, int digest)
{
	chap_state *cstate = &chap[unit];
	
	cstate->chal_name = our_name;
	cstate->chal_type = digest;
	
	if (cstate->serverstate == CHAPSS_INITIAL ||
			cstate->serverstate == CHAPSS_PENDING) {
		/* lower layer isn't up - wait until later */
		cstate->serverstate = CHAPSS_PENDING;
		return;
	}
	
	ChapGenChallenge(cstate);
	ChapSendChallenge(cstate);		/* crank it up dude! */
	cstate->serverstate = CHAPSS_INITIAL_CHAL;
}




/**********************************/
/*** LOCAL FUNCTION DEFINITIONS ***/
/**********************************/
/*
 * ChapInit - Initialize a CHAP unit.
 */
static void ChapInit(int unit)
{
	chap_state *cstate = &chap[unit];
	
	BZERO(cstate, sizeof(*cstate));
	cstate->unit = unit;
	cstate->clientstate = CHAPCS_INITIAL;
	cstate->serverstate = CHAPSS_INITIAL;
	cstate->timeouttime = CHAP_DEFTIMEOUT;
	cstate->max_transmits = CHAP_DEFTRANSMITS;
	/* random number generator is initialized in magic_init */
}


/*
 * ChapChallengeTimeout - Timeout expired on sending challenge.
 */
static void ChapChallengeTimeout(void *arg)
{
	chap_state *cstate = (chap_state *) arg;
	
	/* if we aren't sending challenges, don't worry.  then again we */
	/* probably shouldn't be here either */
	if (cstate->serverstate != CHAPSS_INITIAL_CHAL &&
			cstate->serverstate != CHAPSS_RECHALLENGE)
		return;
	
	if (cstate->chal_transmits >= cstate->max_transmits) {
		/* give up on peer */
		ppp_trace(LOG_ERR, "Peer failed to respond to CHAP challenge\n");
		cstate->serverstate = CHAPSS_BADAUTH;
		auth_peer_fail(cstate->unit, PPP_CHAP);
		return;
	}
	
	ChapSendChallenge(cstate);		/* Re-send challenge */
}


/*
 * ChapResponseTimeout - Timeout expired on sending response.
 */
static void ChapResponseTimeout(void *arg)
{
	chap_state *cstate = (chap_state *) arg;
	
	/* if we aren't sending a response, don't worry. */
	if (cstate->clientstate != CHAPCS_RESPONSE)
		return;
	
	ChapSendResponse(cstate);		/* re-send response */
}


/*
 * ChapRechallenge - Time to challenge the peer again.
 */
static void ChapRechallenge(void *arg)
{
	chap_state *cstate = (chap_state *) arg;
	
	/* if we aren't sending a response, don't worry. */
	if (cstate->serverstate != CHAPSS_OPEN)
		return;
	
	ChapGenChallenge(cstate);
	ChapSendChallenge(cstate);
	cstate->serverstate = CHAPSS_RECHALLENGE;
}


/*
 * ChapLowerUp - The lower layer is up.
 *
 * Start up if we have pending requests.
 */
static void ChapLowerUp(int unit)
{
	chap_state *cstate = &chap[unit];
	
	if (cstate->clientstate == CHAPCS_INITIAL)
		cstate->clientstate = CHAPCS_CLOSED;
	else if (cstate->clientstate == CHAPCS_PENDING)
		cstate->clientstate = CHAPCS_LISTEN;
	
	if (cstate->serverstate == CHAPSS_INITIAL)
		cstate->serverstate = CHAPSS_CLOSED;
	else if (cstate->serverstate == CHAPSS_PENDING) {
		ChapGenChallenge(cstate);
		ChapSendChallenge(cstate);
		cstate->serverstate = CHAPSS_INITIAL_CHAL;
	}
}


/*
 * ChapLowerDown - The lower layer is down.
 *
 * Cancel all timeouts.
 */
static void ChapLowerDown(int unit)
{
	chap_state *cstate = &chap[unit];
	
	/* Timeout(s) pending?  Cancel if so. */
	if (cstate->serverstate == CHAPSS_INITIAL_CHAL ||
			cstate->serverstate == CHAPSS_RECHALLENGE)
		UNTIMEOUT(ChapChallengeTimeout, cstate);
	else if (cstate->serverstate == CHAPSS_OPEN
			&& cstate->chal_interval != 0)
		UNTIMEOUT(ChapRechallenge, cstate);
	if (cstate->clientstate == CHAPCS_RESPONSE)
		UNTIMEOUT(ChapResponseTimeout, cstate);
	
	cstate->clientstate = CHAPCS_INITIAL;
	cstate->serverstate = CHAPSS_INITIAL;
}


/*
 * ChapProtocolReject - Peer doesn't grok CHAP.
 */
static void ChapProtocolReject(int unit)
{
	chap_state *cstate = &chap[unit];
	
	if (cstate->serverstate != CHAPSS_INITIAL &&
			cstate->serverstate != CHAPSS_CLOSED)
		auth_peer_fail(unit, PPP_CHAP);
	if (cstate->clientstate != CHAPCS_INITIAL &&
			cstate->clientstate != CHAPCS_CLOSED)
		auth_withpeer_fail(unit, PPP_CHAP);
	ChapLowerDown(unit);		/* shutdown chap */
}


/*
 * ChapInput - Input CHAP packet.
 */
static void ChapInput(int unit, u_char *inpacket, int packet_len)
{
	chap_state *cstate = &chap[unit];
	u_char *inp;
	u_char code, id;
	int len;
	
	/*
	 * Parse header (code, id and length).
	 * If packet too short, drop it.
	 */
	inp = inpacket;
	if (packet_len < CHAP_HEADERLEN) {
		CHAPDEBUG((LOG_INFO, "ChapInput: rcvd short header.\n"));
		return;
	}
	GETCHAR(code, inp);
	GETCHAR(id, inp);
	GETSHORT(len, inp);
	if (len < CHAP_HEADERLEN) {
		CHAPDEBUG((LOG_INFO, "ChapInput: rcvd illegal length.\n"));
		return;
	}
	if (len > packet_len) {
		CHAPDEBUG((LOG_INFO, "ChapInput: rcvd short packet.\n"));
		return;
	}
	len -= CHAP_HEADERLEN;
	
	/*
	 * Action depends on code (as in fact it usually does :-).
	 */
	switch (code) {
	case CHAP_CHALLENGE:
		ChapReceiveChallenge(cstate, inp, id, len);
		break;
	
	case CHAP_RESPONSE:
		ChapReceiveResponse(cstate, inp, id, len);
		break;
	
	case CHAP_FAILURE:
		ChapReceiveFailure(cstate, inp, id, len);
		break;
	
	case CHAP_SUCCESS:
		ChapReceiveSuccess(cstate, inp, id, len);
		break;
	
	default:				/* Need code reject? */
		ppp_trace(LOG_WARNING, "Unknown CHAP code (%d) received.\n", code);
		break;
	}
}


/*
 * ChapReceiveChallenge - Receive Challenge and send Response.
 */
static void ChapReceiveChallenge(chap_state *cstate, u_char *inp, int id, int len)
{
	int rchallenge_len;
	u_char *rchallenge;
	int secret_len;
	char secret[MAXSECRETLEN];
	char rhostname[256];
	MD5_CTX mdContext;
	u_char hash[MD5_SIGNATURE_SIZE];
	
	CHAPDEBUG((LOG_INFO, "ChapReceiveChallenge: Rcvd id %d.\n", id));
	if (cstate->clientstate == CHAPCS_CLOSED ||
		cstate->clientstate == CHAPCS_PENDING) {
		CHAPDEBUG((LOG_INFO, "ChapReceiveChallenge: in state %d\n",
			   cstate->clientstate));
		return;
	}
	
	if (len < 2) {
		CHAPDEBUG((LOG_INFO, "ChapReceiveChallenge: rcvd short packet.\n"));

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91丨九色porny丨蝌蚪| 欧美日本国产视频| 色婷婷综合五月| 欧美大片在线观看| 欧美高清在线精品一区| 亚洲综合网站在线观看| 国产一区二区三区黄视频| 日本道色综合久久| 久久一日本道色综合| 香蕉成人伊视频在线观看| 国产精品一色哟哟哟| 欧美群妇大交群中文字幕| 国产精品福利影院| 国产一区免费电影| 欧美一区二区三区思思人| 亚洲乱码精品一二三四区日韩在线 | 亚洲人成亚洲人成在线观看图片| 日韩精品91亚洲二区在线观看| 暴力调教一区二区三区| 日韩免费视频一区| 亚洲6080在线| 欧美性大战久久久久久久蜜臀 | 欧美成人伊人久久综合网| 亚洲人妖av一区二区| 懂色中文一区二区在线播放| 日韩一区二区在线看片| 亚洲成av人影院在线观看网| 91蜜桃传媒精品久久久一区二区| 久久久久9999亚洲精品| 久久精品av麻豆的观看方式| 制服丝袜中文字幕一区| 亚洲图片欧美综合| 91国在线观看| 亚洲免费在线观看视频| 97久久精品人人做人人爽| 日本一区二区三区在线不卡| 国产麻豆精品久久一二三| 亚洲精品在线观看视频| 裸体歌舞表演一区二区| 日韩一级精品视频在线观看| 日韩avvvv在线播放| 欧美群妇大交群中文字幕| 亚洲电影一级黄| 欧美日韩国产免费一区二区 | 国产精品丝袜久久久久久app| 国产伦精品一区二区三区视频青涩 | 国产成人午夜99999| 久久久91精品国产一区二区三区| 国产一区二区三区黄视频 | 国产精品久久久久久久久快鸭| 国产91精品久久久久久久网曝门| 国产午夜精品一区二区| 成人福利视频在线| 亚洲美女一区二区三区| 欧美无人高清视频在线观看| 亚洲1区2区3区视频| 日韩一区二区影院| 国内精品免费**视频| 亚洲国产精品激情在线观看| 91网站视频在线观看| 亚洲成人先锋电影| 日韩欧美国产综合一区| 高清不卡一区二区在线| 亚洲免费观看视频| 欧美日本韩国一区二区三区视频| 精品中文字幕一区二区小辣椒| 日本一区免费视频| 色呦呦一区二区三区| 日韩va亚洲va欧美va久久| 欧美精品一区二区精品网| 不卡的av电影在线观看| 亚洲va欧美va人人爽| 26uuuu精品一区二区| 99精品视频一区二区三区| 亚欧色一区w666天堂| 久久亚区不卡日本| 91九色最新地址| 久久超碰97中文字幕| 国产精品福利在线播放| 欧美一区二区视频在线观看2022| 高清国产一区二区三区| 偷拍与自拍一区| 中文字幕乱码亚洲精品一区| 欧美美女一区二区在线观看| 东方aⅴ免费观看久久av| 天使萌一区二区三区免费观看| 久久久.com| 91精品国产色综合久久不卡蜜臀 | 日本欧美在线观看| 国产精品日产欧美久久久久| 欧美丰满少妇xxxxx高潮对白| 成人av电影免费观看| 免费视频最近日韩| 综合中文字幕亚洲| 久久精品这里都是精品| 欧美日韩一区国产| av不卡免费电影| 国产一区二区0| 日本成人中文字幕在线视频| 亚洲免费视频中文字幕| 国产丝袜在线精品| 日韩欧美中文一区| 欧美日韩一区二区三区高清| 一本久道久久综合中文字幕| 懂色一区二区三区免费观看| 国精品**一区二区三区在线蜜桃| 亚洲超丰满肉感bbw| ...av二区三区久久精品| 久久久久久久一区| 日韩一级大片在线| 欧美日韩精品欧美日韩精品一| 91尤物视频在线观看| 国产 日韩 欧美大片| 国模套图日韩精品一区二区| 蜜臀av性久久久久蜜臀aⅴ四虎| 天天影视网天天综合色在线播放| 亚洲六月丁香色婷婷综合久久 | 亚洲天堂2016| 最新欧美精品一区二区三区| 国产欧美一区二区三区在线老狼 | 国产一区激情在线| 免费av网站大全久久| 日韩不卡手机在线v区| 日本中文字幕一区| 日韩专区中文字幕一区二区| 五月天精品一区二区三区| 亚洲一区日韩精品中文字幕| 亚洲一区二区三区四区在线 | 99久久综合色| 99re热这里只有精品视频| 不卡视频在线观看| 99久久国产综合色|国产精品| 91蜜桃网址入口| 欧洲中文字幕精品| 欧美日韩国产bt| 日韩一区二区三区观看| 久久亚洲春色中文字幕久久久| 久久久久久久久久电影| 欧美激情一区二区在线| 中文天堂在线一区| 亚洲人成精品久久久久久| 亚洲精品ww久久久久久p站| 亚洲不卡一区二区三区| 日韩电影在线免费观看| 极品少妇xxxx精品少妇偷拍| 粉嫩aⅴ一区二区三区四区| 色一情一乱一乱一91av| 欧美日韩夫妻久久| 久久五月婷婷丁香社区| 国产精品久久久爽爽爽麻豆色哟哟| 亚洲少妇30p| 天堂精品中文字幕在线| 国产精品伊人色| 日本乱码高清不卡字幕| 欧美一三区三区四区免费在线看| 久久美女高清视频| 亚洲精选一二三| 久久精品国内一区二区三区| www.av亚洲| 日韩一区二区三区免费看| 中文字幕二三区不卡| 婷婷亚洲久悠悠色悠在线播放| 久久国产日韩欧美精品| 91视频国产资源| 日韩三级高清在线| 亚洲日本青草视频在线怡红院| 免费人成黄页网站在线一区二区| 不卡一区在线观看| 欧美大白屁股肥臀xxxxxx| 亚洲欧美日韩国产另类专区 | 精品一区二区三区在线观看| 99久久精品国产一区二区三区| 欧美一级夜夜爽| 中文字幕亚洲欧美在线不卡| 久久精品国产在热久久| 色婷婷亚洲精品| 久久九九久精品国产免费直播| 日韩一区欧美二区| 99v久久综合狠狠综合久久| 欧美成人精品高清在线播放 | 色婷婷亚洲精品| 亚洲国产精品成人综合色在线婷婷| 天天操天天综合网| 95精品视频在线| 久久久99精品久久| 蜜臀av一区二区在线观看| 在线观看国产一区二区| 国产精品嫩草影院av蜜臀| 久久66热re国产| 欧美肥胖老妇做爰| 亚洲猫色日本管| 成人av网站大全| 久久青草欧美一区二区三区| 日韩成人一区二区| 欧日韩精品视频| 亚洲免费视频成人| 91影院在线观看| 亚洲欧美偷拍另类a∨色屁股| 成人午夜免费电影| 久久精品无码一区二区三区|