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

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

?? mp.c

?? PPP協議C語言源代碼
?? C
字號:

#include "net.h"
#include "local.h"
#include "support.h"
#include "ppp.h"

#define MP_START  0x80  /* Start of Multilink reconstructed frame */
#define MP_END    0x40  /* End of Multilink reconstructed frame */


struct MPbundle {
    char linkno;
    char addclass;
    char addlen;
    char addr[20];
    unsigned long rxseq;
    unsigned long txseq;
    MESS *queue;
};

/* Each interface has a bundle that it belongs to. */
static char MPno[NNETS];

/*
** Potentially, each interface could be using PPP with Multi-link
** and not bundle.  This makes for NNETS possible bundles.
*/
static struct MPbundle MPbundle[NNETS];


/*
** * * * * * *
** mpInit()    Put Multilink in its default state
**
** void mpInit(int netno)
**
** PARAMETERS:
**  (in) int netno              A network number
**
** DESCRIPTION:
**  This function will place the Multilink Protocol for yfnet in its default
**  state so that negotiations may proceed correctly on a particular link.
** * * * * * *
*/
void mpInit(int netno)
{
    memset((char *)&MPbundle[netno], 0, sizeof(MPbundle[netno]));
    MPno[netno] = -1;
}


/*
** * * * * * *
** mpShut()    Make Multilink not ready on a link
**
** void mpShut(int netno);
**
** PARAMETERS:
**  (in) int netno              A network number
**
** DESCRIPTION:
**  This function will stop the Multilink protocol on a particular link.
**
*/
void mpShut(int netno)
{
    MPno[netno] = -1;
}


/*
** * * * * * *
** mpStart()    Make MP ready to negotiate
**
** void mpStart(int netno);
**
** PARAMETERS:
**  (in) int netno              A network number
**
** DESCRIPTION:
**  This function will
** * * * * * *
*/
void mpStart(int netno)
{
    nets[netno].hw.opt5 = MPmrru | MPendd;
    MPno[netno] = -1;
}


/*
** * * * * * *
** mpFindBundle()    Find or create an MP bundle
**
** int mpFindBundle(int netno, int addclass, int addlen, char *addr);
**
** PARAMETERS:
**  (in) int netno              A network number
**  (in) int addclass           The class of the bundle
**  (in) int addlen             The length of the bundle name
**  (in) char *addr             The bundle name
**
** RETURNS
**  #                           The MP bundle number
**
** DESCRIPTION:
**  This function will find an MP bundle to associate this link with.
**  If it cannot find an appropriate bundle in existance, it will
**  create one.
** * * * * * *
*/
int mpFindBundle(int netno, int addclass, int addlen, char *addr)
{
    int i1, i2, i3, new;
    struct MPbundle *MPptr;

    new = 1;
    BLOCKPREE();
    for (i1=0,i2=-1; i1<NNETS; i1++) {
        MPptr = &MPbundle[i1];
        for (i3=0; i3<NNETS; i3++)
            if (MPno[i3] == i1)
                goto lab26;
        i2 = i1;
        continue;
lab26:
        if (MPptr->addclass == addclass &&
            MPptr->addlen == addlen &&
            memcmp(MPptr->addr, addr, i1) == 0)
        {
            i2 = i1;
            new = 0;
            break;
        }
    }
    MPno[netno] = (char)i2;
    if (i2 != -1) {
        MPptr = &MPbundle[i2];
        if (new) {
            MPptr->txseq = MPptr->rxseq = 0;
            MPptr->addclass = (char)addclass;
            MPptr->addlen = (char)addlen;
            Nmemcpy(MPptr->addr, addr, addlen);
        }
    }
    RESUMEPREE();
    return i2;
}


/*
** * * * * * *
** mpScreen()    Screen an MP fragment
**
** int mpScreen(MESS *mess);
**
** PARAMETERS:
**  (in/out) MESS *mess         A message buffer (MP fragment)
**
** RETURNS
**  protocol                    PPP protocol packet to process
**  0                           Got a fragment
** -1                           Failure, reject packet
**
** DESCRIPTION:
**  This function will receive either fragmented or unfragmented MP frames.
**
** * * * * * *
*/
int mpScreen(MESS *mess)
{
    int i1, i2, i3, i4, netno;
    unsigned short protocol;
    unsigned char *cp, *cp2;
    unsigned long ul1;
    MESS *mp, *mp3;
    struct MPbundle *MPptr;
    struct NET *netp;
    union {unsigned char c[4]; short s[2]; long l;} UL;

    netno = mess->netno;
    netp = &nets[netno];
    if ((netp->hw.opt5 & MPmrru) == 0)
        return -1;
    cp = (unsigned char *)mess + mess->offset;
    MPptr = &MPbundle[MPno[netno]];

   /* Get start/stop flags */
    i1 = *cp & (MP_START | MP_END);

   /* Get fragment sequence number */
    if (netp->hw.opt5 & MPsnhf) {
        ul1 = *cp++ & 0xf;          /* |B|E|0|0|    sequence number    | */
    }
    else {
        cp++;
        ul1 = *cp++;                /* |B|E|0|0|0|0|0|0|sequence number| */
        ul1 = ul1 << 8 + *cp++;     /* |      sequence number (L)      | */
    }
    ul1 = ul1 << 8 + *cp++;
    MPptr->rxseq = ul1;

   /*
    ** If the protocol value is 0xff03, the peer is probably sending the
    ** address and control fields from the AHDLC frame in the MP packet.
    ** The solution is to strip those values here.  However, if the peer
    ** also encapsulates the checksum, we cannot handle that very easily.
    ** Perhaps the end of the message - 2 will be the location of the
    ** extra checksum.  The normal checksum would be at the end of the
    ** message.
    */
    if (cp[0] == 0xff && cp[1] == 0x03)
        cp += 2;

   /* Get protocol value of fragment (Multilink data field) */
    UL.c[0] = *cp++;
#if COMPRESSION & 1
    if ((netp->hw.remopts & COMPpcmp) && (UL.c[0] & 1)) {
        UL.c[1] = UL.c[0];
        UL.c[0] = 0;
    }
    else
#endif
        UL.c[1] = *cp++;
    protocol = UL.s[0];

   /*
    ** Move start fragment to fixed network data location if necessary.
    **
    ** cp2 points to the start of the network data and the network data
    ** needs to be at mess + MESSH_SZ + LHDRSZ.  The input routine (comec)
    ** should handle the alignment, but if the peer does not correctly
    ** format their fragment due to inconsistant protocol compression or
    ** incorrect address/control insertion, we must adjust.
    */
    i2 = cp - (unsigned char *)mess - MESSH_SZ - LHDRSZ;
    if (i1 & MP_START && i2) {
#if NTRACE >= 7
        Nprintf("PPP MP: Packet adjusted [%d]\n", i2);
#endif
        mess->mlen -= i2;
        cp2 = (unsigned char *)mess + MESSH_SZ + LHDRSZ;
        i2 = mess->mlen - MESSH_SZ - LHDRSZ;
        if (cp > cp2)
            while (i2--)
                *cp2++ = *cp++;
        else
            while (i2--)
                *cp++ = *cp2++;
        PH(mess)->protocol = protocol;
    }

   /* Save important values in the link layer header */
    PH(mess)->MPflags = i1;
    PH(mess)->bseqno = PH(mess)->eseqno = (short)ul1;
    mess->timems = TimeMS();

   /*
    ** Scan MP fragment queue and find the fragment before and after
    ** the current one based on the sequence number.
    */
    mp3 = (MESS *)&MPptr->queue;
    for (i2=0, mp = mp3->next; mp; i2++, mp3 = mp, mp = mp->next)
        if (PH(mp)->bseqno - (short)ul1 > 0)
            break;


   /* If the packet is a new fragment */
    if (i1 & MP_START)
        goto newpacket;

   /* Otherwise, the packet must be prepended/appended to another */

    i3 = 0;
    if (i2 == 0)
        goto lab11;
   /* Append new data */
    if ((short)ul1 - PH(mp3)->eseqno == 1) {
        i4 = mess->mlen - MESSH_SZ - LHDRSZ;
        if (mp3->mlen + i4 > MAXBUF)
            return -1;
        i3 = 1;
        Nmemcpy((char *)mp3+mp3->mlen, (char *)mess+MESSH_SZ+LHDRSZ, i4);
        mp3->mlen += i4;
        PH(mp3)->eseqno = (short)ul1;
        PH(mp3)->MPflags |= i1;
        mess = mp3;
    }
lab11:
    if (mp == 0)
        goto lab12;
   /* Prepend new data */
    if (PH(mp)->bseqno - (short)ul1 == 1) {
        i4 = mp->mlen - MESSH_SZ - LHDRSZ;
        if (mess->mlen + i4 > MAXBUF)
            return -1;
        i3 |= 2;
        Nmemcpy((char *)mess+mess->mlen, (char *)mp+MESSH_SZ+LHDRSZ, i4);
        mess->mlen += i4;
        PH(mess)->eseqno++;
        PH(mess)->MPflags |= PH(mp)->MPflags;
        mess->next = mp->next;
        Nrelbuf(mp);
    }
lab12:
    if (i3 == 0) {
newpacket:
        if (i2 > MPBUF)
            return -1;
        mp3->next = mess;
        mess->next = mp;
    }

   /*
    ** If the top of queue is a whole packet, unqueue and use it.
    **
    ** If all member links of the bundle have overshot the missing sequence
    ** number for a fragment packet, assume that it will never be completed
    ** and discard it.
    **
    ** ul1 is the running minimum sequence number.
    */
    for (i1 = 0; i1 < NNETS; i1++) {
        i3 = MPno[i1];
        if (i3 != -1 && i3 == MPno[netno])
            if (ul1 - MPbundle[i3].rxseq > 0)
                ul1 = MPbundle[i3].rxseq;
    }
    mp3 = (MESS *)&MPptr->queue;            /* scan the queue */
    for (mp = mp3->next; mp; mp3 = mp,mp = mp->next) {
       /* If a reconstructed frame is found, return the protocol */
        if ((PH(mp)->MPflags & (MP_START | MP_END)) == (MP_START | MP_END)) {
            mp3->next = mp->next;
            return protocol;
        }
        if ((short)ul1 - PH(mp)->eseqno <= 0)
            break;
        mp3->next = mp->next;
        Nrelbuf(mp);
    }
    return 0;   /* No reconstructed packets to return */
}


/*
** * * * * * *
** mpWrite()    Write a Multilink packet
**
** int mpWrite(int netno, unsigned char **cpp);
**
** PARAMETERS:
**  (in) int netno              A network number
**  (in/out) char **cpp         A pointer to the packet head pointer
**
** RETURNS
**  #                           The network number to transmit on
**
** DESCRIPTION:
**  This function will encapsulate a frame with the Multilink headers.
** * * * * * *
*/
int mpWrite(int netno, unsigned char **cpp)
{
    int i1;
    char *cp = *cpp;
    struct MPbundle *MPptr;
    union {unsigned char c[4]; short s[2]; long l;} UL;

    i1 = MPno[netno];
    MPptr = &MPbundle[i1];
    for (;;)
        if ((netno = MPptr->linkno++) >= NNETS)
            MPptr->linkno = 0;
        else if (MPno[netno] == i1)
            break;

    *--cp = MPptr->txseq;           /* Sequence (long format) */
    *--cp = MPptr->txseq >> 8;
    *--cp = MPptr->txseq >> 16;
    *--cp = 0xc0;                   /* Both beginning and ending flags */
    *--cp = 0x3d;                   /* Protocol code */
#if COMPRESSION & 1
    if ((nets[netno].hw.remopts & COMPpcmp) == 0)
#endif
        *--cp = 0;
    MPptr->txseq++;

    *cpp = cp;
    return netno;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产在线视视频有精品| 在线影院国内精品| 一本一道综合狠狠老| 欧美丰满少妇xxxbbb| 国产女同互慰高潮91漫画| 一区二区三区在线播| 国产中文字幕一区| 欧美日韩在线不卡| 中文字幕不卡在线观看| 青青草一区二区三区| 欧美优质美女网站| 中文字幕乱码日本亚洲一区二区| 亚洲成a人片综合在线| av亚洲精华国产精华| 精品理论电影在线观看| 天天综合网 天天综合色| av一区二区不卡| 国产人久久人人人人爽| 激情国产一区二区| 欧美久久高跟鞋激| 依依成人精品视频| 99久久婷婷国产| 国产肉丝袜一区二区| 日本欧美一区二区三区乱码| 色久综合一二码| **欧美大码日韩| 不卡高清视频专区| 国产精品视频第一区| 国产揄拍国内精品对白| 欧美电影免费提供在线观看| 亚洲已满18点击进入久久| 成人av资源站| 国产精品久久久久影院亚瑟| 国产宾馆实践打屁股91| 久久中文娱乐网| 麻豆国产精品官网| 26uuu色噜噜精品一区二区| 精品写真视频在线观看| 欧美成人女星排行榜| 久久 天天综合| 欧美精品一区二区蜜臀亚洲| 国模冰冰炮一区二区| 久久久久久久久久久久久久久99| 韩国成人在线视频| 国产日韩三级在线| 成人爱爱电影网址| 亚洲卡通动漫在线| 欧美日免费三级在线| 香蕉av福利精品导航| 欧美一区二区三区免费在线看| 五月天激情综合| 日韩欧美不卡一区| 成人综合激情网| 亚洲人成电影网站色mp4| 欧美综合色免费| 日韩精品每日更新| 久久精品欧美一区二区三区麻豆| 成人亚洲一区二区一| 亚洲美女视频在线| 91麻豆精品国产自产在线观看一区| 婷婷开心久久网| 久久久午夜电影| 99在线精品视频| 日韩高清不卡一区二区三区| 欧美mv和日韩mv的网站| 成人av在线播放网站| 一区二区三区四区不卡在线| 欧美精品九九99久久| 国产精品系列在线播放| 亚洲激情五月婷婷| 欧美成人国产一区二区| 不卡视频一二三四| 日韩**一区毛片| 日本一区二区三区在线不卡| 91精彩视频在线| 国模冰冰炮一区二区| 亚洲综合色噜噜狠狠| 精品国产一区二区三区忘忧草| 99久久综合国产精品| 日韩二区在线观看| 国产精品免费免费| 日韩一卡二卡三卡国产欧美| 成人黄页毛片网站| 男女性色大片免费观看一区二区 | 亚洲超碰97人人做人人爱| 欧美成人一区二区三区在线观看| 91影院在线免费观看| 美女视频一区在线观看| 亚洲欧洲制服丝袜| 精品国产伦一区二区三区观看体验| jlzzjlzz欧美大全| 国产一区二区三区在线观看精品| 亚洲一二三专区| 国产精品短视频| 久久久亚洲国产美女国产盗摄| 欧美日韩国产乱码电影| 99视频国产精品| 国产一区二区三区久久久| 亚洲成av人片在线| 亚洲精品国产无天堂网2021| 欧美国产一区二区在线观看| 欧美一卡二卡三卡四卡| 欧美日韩国产一级片| 91国产福利在线| 91小视频免费看| 成人app下载| 国产成人丝袜美腿| 国产麻豆视频一区二区| 免费xxxx性欧美18vr| 天天操天天干天天综合网| 亚洲视频小说图片| 亚洲国产精品国自产拍av| 精品乱人伦一区二区三区| 欧美老年两性高潮| 欧美色偷偷大香| 在线亚洲免费视频| 色猫猫国产区一区二在线视频| 成人免费视频caoporn| 国产福利91精品一区二区三区| 韩日av一区二区| 黄页网站大全一区二区| 国产精品18久久久久久vr| 国产精品综合二区| 成人免费视频网站在线观看| 成人美女视频在线看| 91视频www| 欧美午夜理伦三级在线观看| 欧美三级乱人伦电影| 在线成人免费视频| 精品少妇一区二区三区在线播放 | 亚洲国产cao| 天天影视涩香欲综合网 | 老司机精品视频线观看86| 日韩电影在线一区| 久久www免费人成看片高清| 国产一区二区三区不卡在线观看| 韩国av一区二区三区在线观看| 国产在线观看免费一区| 国产成人丝袜美腿| 日本伦理一区二区| 91精品国产品国语在线不卡| 久久精品在这里| 亚洲免费视频中文字幕| 亚洲va在线va天堂| 国产麻豆精品在线观看| 99国产精品视频免费观看| 欧美日韩免费电影| 久久综合狠狠综合久久综合88| 一区在线观看视频| 视频一区二区三区中文字幕| 激情小说亚洲一区| 色综合久久综合网欧美综合网| 欧美日产在线观看| 国产精品色在线| 天天综合网 天天综合色| 国产精品中文字幕日韩精品| 91在线视频观看| 日韩欧美国产电影| 一区二区三区四区蜜桃| 极品少妇xxxx精品少妇偷拍 | 91麻豆国产自产在线观看| 天天综合天天做天天综合| 国产寡妇亲子伦一区二区| 粉嫩欧美一区二区三区高清影视 | 国产精品久久久久久亚洲毛片 | 久久精品亚洲麻豆av一区二区| 国产亚洲成av人在线观看导航| 精品剧情v国产在线观看在线| 精品国产一区二区国模嫣然| 国产欧美日韩亚州综合 | 欧美一级片免费看| 久久久综合精品| 亚洲欧美日韩久久精品| 午夜精品久久久久久久久久久| 成人一区二区三区中文字幕| 色播五月激情综合网| 欧美电视剧免费全集观看| 国产欧美日韩综合| 亚洲高清三级视频| 韩国欧美国产1区| 成人中文字幕合集| 欧美日韩另类国产亚洲欧美一级| 中文字幕日韩欧美一区二区三区| 亚洲va天堂va国产va久| 波多野结衣中文字幕一区 | 91老师片黄在线观看| 日韩一区二区在线播放| 中文字幕欧美一区| 成人黄色片在线观看| 在线不卡a资源高清| 国产精品久久久久久妇女6080| 日韩精品1区2区3区| 99久久综合精品| 久久久久久久综合| 日本成人在线视频网站| 色综合久久久久综合| 欧美成人一级视频| 久久99国产精品久久99| 欧美日韩精品欧美日韩精品一 | 色婷婷精品久久二区二区蜜臂av |