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

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

?? netauth.c

?? 一個tcp/ip協(xié)議棧,帶有PPP、IP、TCP、UDP等協(xié)議
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*****************************************************************************
* netauth.c - Network Authentication and Phase Control program file.
*
* Copyright (c) 1997 by Global Election Systems Inc.  All rights reserved.
*
* 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.
*   Ported from public pppd code.
*****************************************************************************/
/*
 * auth.c - PPP authentication and phase control.
 *
 * 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) 1989 Carnegie Mellon 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 Carnegie Mellon 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.
 */

#include "netconf.h"

#include <string.h>
#include "net.h"
#include "netbuf.h"
#include "nettimer.h"
#include "netfsm.h"
#include "netlcp.h"
#include "netpap.h"
#include "netchap.h"
#include "netauth.h"
#include "netppp.h"
#include "netipcp.h"
#include "netos.h"

#if CBCP_SUPPORT > 0
#include "netcbcp.h"
#endif

#include <malloc.h>
#include <stdio.h>
#include "netdebug.h"


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

/* Bits in auth_pending[] */
#define PAP_WITHPEER    1
#define PAP_PEER    2
#define CHAP_WITHPEER   4
#define CHAP_PEER   8


                                                                    
/************************/
/*** LOCAL DATA TYPES ***/
/************************/
/* Used for storing a sequence of words.  Usually malloced. */
struct wordlist {
    struct wordlist *next;
    char        word[1];
};



/***********************************/
/*** LOCAL FUNCTION DECLARATIONS ***/
/***********************************/
extern char *crypt __P((const char *, const char *));

/* Prototypes for procedures local to this file. */

static void network_phase __P((int));
static void check_idle __P((void *));
static void connect_time_expired __P((void *));
#ifdef XXX
static int  login __P((char *, char *, char **, int *));
#endif
static void logout __P((void));
static int  null_login __P((int));
static int  get_pap_passwd __P((int));
static int  have_pap_secret __P((void));
static int  have_chap_secret __P((char *, char *, u_int32_t));
static int  ip_addr_check __P((u_int32_t, struct wordlist *));
#if PAP_SUPPORT > 0 || CHAP_SUPPORT > 0
static void set_allowed_addrs(int unit, struct wordlist *addrs);
static void free_wordlist __P((struct wordlist *));
#endif
#if CBCP_SUPPORT > 0
static void callback_phase __P((int));
#endif


/******************************/
/*** PUBLIC DATA STRUCTURES ***/
/******************************/


/*****************************/
/*** LOCAL DATA STRUCTURES ***/
/*****************************/
#if PAP_SUPPORT > 0 || CHAP_SUPPORT > 0
/* The name by which the peer authenticated itself to us. */
static char peer_authname[MAXNAMELEN];
#endif

/* Records which authentication operations haven't completed yet. */
static int auth_pending[NUM_PPP];

/* Set if we have successfully called login() */
static int logged_in;

/* Set if we have run the /etc/ppp/auth-up script. */
static int did_authup;

/* List of addresses which the peer may use. */
static struct wordlist *addresses[NUM_PPP];

/* Number of network protocols which we have opened. */
static int num_np_open;

/* Number of network protocols which have come up. */
static int num_np_up;

#if PAP_SUPPORT > 0 || CHAP_SUPPORT > 0
/* Set if we got the contents of passwd[] from the pap-secrets file. */
static int passwd_from_file;
#endif



/***********************************/
/*** PUBLIC FUNCTION DEFINITIONS ***/
/***********************************/
/*
 * An Open on LCP has requested a change from Dead to Establish phase.
 * Do what's necessary to bring the physical layer up.
 */
#pragma argsused
void link_required(int unit)
{
    AUTHDEBUG((LOG_INFO, "link_required: %d", unit));
}

/*
 * LCP has terminated the link; go to the Dead phase and take the
 * physical layer down.
 */
#pragma argsused
void link_terminated(int unit)
{
    AUTHDEBUG((LOG_INFO, "link_terminated: %d", unit));
    
    if (lcp_phase[unit] == PHASE_DEAD)
        return;
    if (logged_in)
        logout();
    lcp_phase[unit] = PHASE_DEAD;
    trace(LOG_NOTICE, "Connection terminated.");
}

/*
 * LCP has gone down; it will either die or try to re-establish.
 */
void link_down(int unit)
{
    int i;
    struct protent *protp;
    
    AUTHDEBUG((LOG_INFO, "link_down: %d", unit));
    if (did_authup) {
        /* XXX Do link down processing. */
        did_authup = 0;
    }
    for (i = 0; (protp = protocols[i]) != NULL; ++i) {
        if (!protp->enabled_flag)
            continue;
        if (protp->protocol != PPP_LCP && protp->lowerdown != NULL)
            (*protp->lowerdown)(unit);
        if (protp->protocol < 0xC000 && protp->close != NULL)
            (*protp->close)(unit, "LCP down");
    }
    num_np_open = 0;
    num_np_up = 0;
    if (lcp_phase[unit] != PHASE_DEAD)
        lcp_phase[unit] = PHASE_TERMINATE;
}

/*
 * The link is established.
 * Proceed to the Dead, Authenticate or Network phase as appropriate.
 */
void link_established(int unit)
{
    int auth;
    int i;
    struct protent *protp;
    lcp_options *wo = &lcp_wantoptions[unit];
    lcp_options *go = &lcp_gotoptions[unit];
#if PAP_SUPPORT > 0 || CHAP_SUPPORT > 0
    lcp_options *ho = &lcp_hisoptions[unit];
#endif
    
    AUTHDEBUG((LOG_INFO, "link_established: %d", unit));
    /*
     * Tell higher-level protocols that LCP is up.
     */
    for (i = 0; (protp = protocols[i]) != NULL; ++i)
        if (protp->protocol != PPP_LCP && protp->enabled_flag
                && protp->lowerup != NULL)
            (*protp->lowerup)(unit);
    
    if (auth_required && !(go->neg_chap || go->neg_upap)) {
        /*
         * We wanted the peer to authenticate itself, and it refused:
         * treat it as though it authenticated with PAP using a username
         * of "" and a password of "".  If that's not OK, boot it out.
         */
        if (!wo->neg_upap || !null_login(unit)) {
            trace(LOG_WARNING, "peer refused to authenticate");
            lcp_close(unit, "peer refused to authenticate");
            return;
        }
    }
    
    lcp_phase[unit] = PHASE_AUTHENTICATE;
    auth = 0;
#if CHAP_SUPPORT > 0
    if (go->neg_chap) {
        ChapAuthPeer(unit, our_name, go->chap_mdtype);
        auth |= CHAP_PEER;
    } 
#endif
#if PAP_SUPPORT > 0 && CHAP_SUPPORT > 0
    else
#endif
#if PAP_SUPPORT > 0
    if (go->neg_upap) {
        upap_authpeer(unit);
        auth |= PAP_PEER;
    }
#endif
#if CHAP_SUPPORT > 0
    if (ho->neg_chap) {
        ChapAuthWithPeer(unit, user, ho->chap_mdtype);
        auth |= CHAP_WITHPEER;
    }
#endif
#if PAP_SUPPORT > 0 && CHAP_SUPPORT > 0
    else
#endif
#if PAP_SUPPORT > 0
    if (ho->neg_upap) {
        if (passwd[0] == 0) {
            passwd_from_file = 1;
            if (!get_pap_passwd(unit))
                trace(LOG_ERR, "No secret found for PAP login");
        }
        upap_authwithpeer(unit, user, passwd);
        auth |= PAP_WITHPEER;
    }
#endif
    auth_pending[unit] = auth;
    
    if (!auth)
        network_phase(unit);
}


/*
 * The peer has failed to authenticate himself using `protocol'.
 */
#pragma argsused
void auth_peer_fail(int unit, int protocol)
{
    AUTHDEBUG((LOG_INFO, "auth_peer_fail: %d proto=%X", unit, protocol));
    /*
     * Authentication failure: take the link down
     */
    lcp_close(unit, "Authentication failed");
}


#if PAP_SUPPORT > 0 || CHAP_SUPPORT > 0
/*
 * The peer has been successfully authenticated using `protocol'.
 */
void auth_peer_success(int unit, int protocol, char *name, int namelen)
{
    int bit;
    
    AUTHDEBUG((LOG_INFO, "auth_peer_success: %d proto=%X", unit, protocol));
    switch (protocol) {
    case PPP_CHAP:
        bit = CHAP_PEER;
        break;
    case PPP_PAP:
        bit = PAP_PEER;
        break;
    default:
        trace(LOG_WARNING, "auth_peer_success: unknown protocol %x",
               protocol);
        return;
    }
    
    /*
     * Save the authenticated name of the peer for later.
     */
    if (namelen > sizeof(peer_authname) - 1)
        namelen = sizeof(peer_authname) - 1;
    BCOPY(name, peer_authname, namelen);
    peer_authname[namelen] = 0;
    
    /*
     * If there is no more authentication still to be done,
     * proceed to the network (or callback) phase.
     */
    if ((auth_pending[unit] &= ~bit) == 0)
        network_phase(unit);
}

/*
 * We have failed to authenticate ourselves to the peer using `protocol'.
 */
#pragma argsused
void auth_withpeer_fail(int unit, int protocol)
{
    int errCode = PPPERR_AUTHFAIL;
    
    AUTHDEBUG((LOG_INFO, "auth_withpeer_fail: %d proto=%X", unit, protocol));
    if (passwd_from_file)
        BZERO(passwd, MAXSECRETLEN);
    /* 
     * XXX Warning: the unit number indicates the interface which is
     * not necessarily the PPP connection.  It works here as long
     * as we are only supporting PPP interfaces.
     */
    pppIOCtl(unit, PPPCTLS_ERRCODE, &errCode);

    /*
     * We've failed to authenticate ourselves to our peer.
     * He'll probably take the link down, and there's not much
     * we can do except wait for that.
     */
}

/*
 * We have successfully authenticated ourselves with the peer using `protocol'.
 */
void auth_withpeer_success(int unit, int protocol)
{
    int bit;
    
    AUTHDEBUG((LOG_INFO, "auth_withpeer_success: %d proto=%X", unit, protocol));
    switch (protocol) {
    case PPP_CHAP:
        bit = CHAP_WITHPEER;
        break;
    case PPP_PAP:
        if (passwd_from_file)
            BZERO(passwd, MAXSECRETLEN);
        bit = PAP_WITHPEER;
        break;
    default:
        trace(LOG_WARNING, "auth_peer_success: unknown protocol %x",
               protocol);
        bit = 0;
    }
    
    /*
     * If there is no more authentication still being done,
     * proceed to the network (or callback) phase.
     */
    if ((auth_pending[unit] &= ~bit) == 0)
        network_phase(unit);
}
#endif


/*
 * np_up - a network protocol has come up.
 */
#pragma argsused
void np_up(int unit, int proto)
{
    AUTHDEBUG((LOG_INFO, "np_up: %d proto=%X", unit, proto));
    if (num_np_up == 0) {
	AUTHDEBUG((LOG_INFO, "np_up: maxconnect=%d idle_time_limit=%d",maxconnect,idle_time_limit));
        /*
         * At this point we consider that the link has come up successfully.
         */
        if (idle_time_limit > 0)
            TIMEOUT(check_idle, NULL, idle_time_limit);
        
        /*
         * Set a timeout to close the connection once the maximum
         * connect time has expired.
         */
        if (maxconnect > 0)
            TIMEOUT(connect_time_expired, 0, maxconnect);
    }
    ++num_np_up;
}

/*

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
91性感美女视频| 成人午夜激情在线| 欧美一区中文字幕| 日韩高清不卡一区二区| 欧美午夜在线观看| 亚洲国产欧美日韩另类综合 | 99久久精品国产导航| 亚洲欧洲www| 在线观看视频一区| 视频一区中文字幕国产| 欧美一区二区大片| 国产suv精品一区二区三区| 国产精品久久久久桃色tv| 97se亚洲国产综合在线| 亚洲精品欧美综合四区| 6080日韩午夜伦伦午夜伦| 毛片av一区二区| 中文字幕 久热精品 视频在线| k8久久久一区二区三区| 亚洲国产三级在线| 欧美成人a∨高清免费观看| 99这里只有久久精品视频| 一区二区免费在线播放| 26uuuu精品一区二区| 91丨porny丨在线| 免费看精品久久片| 国产精品久久久久影视| 欧美日韩国产美女| 91视频免费播放| 亚洲成人午夜影院| 日本一区二区视频在线观看| 91精品福利在线| 久久99深爱久久99精品| 亚洲人亚洲人成电影网站色| 日韩精品中文字幕在线一区| 99久久久久久| 另类小说一区二区三区| 日韩毛片一二三区| 欧美mv日韩mv国产| 欧美日韩精品一区视频| 国产成人综合视频| 日韩中文字幕一区二区三区| 中文字幕视频一区| 2欧美一区二区三区在线观看视频 337p粉嫩大胆噜噜噜噜噜91av | 综合色中文字幕| 精品国产一区二区三区久久久蜜月 | 97久久超碰国产精品电影| 久久精品国产999大香线蕉| 亚洲精品日产精品乱码不卡| 国产无人区一区二区三区| 欧美日韩国产首页| 国产成人综合网| 秋霞成人午夜伦在线观看| 亚洲欧美日韩系列| 久久久久久久久久看片| 欧美军同video69gay| 91性感美女视频| 波多野结衣91| 成人综合婷婷国产精品久久| 久久99久久久欧美国产| 天天综合色天天综合色h| 亚洲免费视频成人| 中文字幕一区二区三区蜜月| 久久久精品日韩欧美| 精品国产免费人成电影在线观看四季| 欧美性色aⅴ视频一区日韩精品| bt欧美亚洲午夜电影天堂| 极品美女销魂一区二区三区 | 亚洲成人自拍一区| 亚洲黄色小说网站| 国产精品情趣视频| 国产婷婷一区二区| 国产色综合久久| 久久久久久久精| 久久毛片高清国产| 久久久精品天堂| 国产日韩高清在线| 国产欧美日本一区二区三区| 久久影院午夜片一区| 日韩视频一区在线观看| 日韩一区二区三区四区| 日韩一区二区三区免费看 | 色94色欧美sute亚洲线路一ni| 成+人+亚洲+综合天堂| av资源站一区| 色综合av在线| 欧美美女网站色| 精品久久国产字幕高潮| 久久夜色精品国产噜噜av| 国产亚洲成av人在线观看导航| 国产日韩欧美在线一区| 中文字幕在线观看不卡视频| 亚洲欧美日韩人成在线播放| 亚洲高清免费观看| 久久电影网站中文字幕| 国产成人在线视频免费播放| voyeur盗摄精品| 欧美日韩三级一区| 日韩欧美在线123| 国产无遮挡一区二区三区毛片日本| 国产精品久久久久一区二区三区共| 亚洲欧美日韩国产一区二区三区| 亚洲成a人片综合在线| 久久国产视频网| 成人va在线观看| 欧美日韩国产高清一区二区| 日韩视频一区二区在线观看| 中文字幕精品在线不卡| 一区二区高清在线| 久久疯狂做爰流白浆xx| 91亚洲精品久久久蜜桃| 日韩一区二区高清| 中文字幕精品—区二区四季| 亚洲国产精品自拍| 国产精品一区二区在线播放 | 精品一区二区三区在线观看| 丁香婷婷综合网| 欧美精品在线观看一区二区| 国产午夜亚洲精品理论片色戒 | 精品一二三四区| 色婷婷综合久色| 久久婷婷一区二区三区| 亚洲成人一区二区在线观看| 国产一区二区电影| 欧美日韩视频第一区| 中文字幕精品一区二区精品绿巨人| 偷拍自拍另类欧美| 成人av网站在线| 日韩免费高清av| 亚洲精选视频在线| 国产大陆亚洲精品国产| 91麻豆精品国产91久久久更新时间| 国产精品免费久久久久| 久久精品理论片| 欧洲中文字幕精品| 国产精品色在线观看| 美国三级日本三级久久99 | 激情小说欧美图片| 欧美午夜精品久久久久久孕妇| 国产三级久久久| 久久99精品久久久久久动态图| 在线中文字幕一区二区| 国产精品久久久久久久久晋中 | 成人午夜视频在线| 日韩欧美成人一区| 亚洲国产一区二区a毛片| 成人激情午夜影院| 国产欧美视频一区二区| 美女久久久精品| 欧美绝品在线观看成人午夜影视| 亚洲免费观看高清完整版在线观看 | 欧美亚洲国产一区在线观看网站| 国产欧美精品一区aⅴ影院| 精品无人区卡一卡二卡三乱码免费卡 | 国产欧美日韩久久| 国产一区二区三区不卡在线观看| 欧美一区二区免费观在线| 亚洲第一电影网| 欧美日韩国产天堂| 亚洲成人中文在线| 欧美卡1卡2卡| 日本特黄久久久高潮| 欧美一区二视频| 日韩av电影一区| 精品精品欲导航| 精品在线免费观看| 久久综合九色综合97_久久久| 精品一区二区三区免费播放| 日韩欧美一区二区三区在线| 免费人成精品欧美精品| 日韩午夜av一区| 国产尤物一区二区在线| 久久精品视频在线免费观看| 国产综合久久久久久鬼色 | 美女久久久精品| 久久影院午夜论| 成人一区二区在线观看| 亚洲欧洲另类国产综合| 色综合久久中文综合久久97| 中文字幕日韩一区| 色狠狠色狠狠综合| 亚洲va天堂va国产va久| 日韩午夜三级在线| 久99久精品视频免费观看| 国产区在线观看成人精品| 波多野结衣中文字幕一区| 亚洲欧美色图小说| 91麻豆精品国产91久久久久久| 韩国三级电影一区二区| 国产精品污网站| 91官网在线免费观看| 日本亚洲三级在线| 欧美激情资源网| 在线区一区二视频| 美女视频一区二区三区| 国产午夜久久久久| 欧美在线免费播放| 精品制服美女丁香| 玉米视频成人免费看| 欧美电影免费观看高清完整版|