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

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

?? mp.c

?? ppp協議實現源代碼
?? C
?? 第 1 頁 / 共 2 頁
字號:
/* * Multilink PPP example code. * * Assumptions: * *	Input data is in linear buffers, which probably *	isn't the case for many implementations, and input *	buffers have sufficient leading and trailing padding *	to allow for any expansion necessary. * *	Strict adherence to RFC 1661 is desired, which may not *	necessarily be the case for the protocol field. * *	Underlying machine has 8-bit bytes and a fairly modern *	architecture. * * This code may be used for any purpose as long as the author's * copyright is cited in any source code distributed.  This code * is also available electronically from the author's web site. * * http://people.ne.mediaone.net/carlson/ppp * * http://www.workingcode.com/ppp * * Copyright 1997 by James Carlson and Working Code */#include <stdlib.h>#include <syslog.h>#include "sysdep.h"#include "mp.h"/* Contains information for a single fragment awaiting reassembly. */struct mp_fragment {    struct mp_fragment *next;	/* Next fragment in sequence */    int length;			/* Length of this fragment */    uint32 seq;			/* Sequence number */    octet flags;		/* Begin/end flags */    octet data[1];		/* Data */};/* State data needed for MP level between bundle and links */struct mp_state {    struct mp_state *next;	/* Next MP bundle in system */    struct ppp_link *lptr;	/* Pointer to bundle-level session */    struct ppp_link *links;	/* Pointer to member links */    struct ppp_link *in_on;	/* Link over which last packet arrived */    struct ppp_link *next_out_link;	/* Next output link to use */    int numlinks;		/* Number member links */    BOOLEAN snd_short_seq;	/* Send short sequence numbers */    BOOLEAN rcv_short_seq;	/* Accept short sequence numbers */    uint32 send_seq;		/* Next sequence number to send */    struct mp_fragment *frags;	/* List of received fragments */};/* List of all MP sessions in system */static struct mp_state *global_mp_list = NULL;/* * Locate a given NCP handler by PPP protocol ID. */static struct xcp_state *find_xcp(struct ppp_link *lptr, uint16 proto){    struct xcp_state *xcp;    for (xcp = lptr->xcp_list; xcp != NULL; xcp = xcp->next)	if (xcp->proto == proto)	    break;    return xcp;}/* * Send an LCP reject for an unknown protocol. */static voidsend_lcp_protocol_reject(struct ppp_link *lptr, uint16 proto,			 octet *indata, int inlen){    struct xcp_state *xcp;    xcp = find_xcp(lptr,PPP_PROTO_LCP);    if (xcp == NULL || xcp->state != Opened)	return;    syslog(LOG_DEBUG,"Unknown protocol %04X; rejecting.",proto);    /* Add LCP protocol reject header */    indata -= 6;    indata[0] = PROTO_REJ;    indata[1] = ++xcp->id_number;    indata[2] = inlen >> 8;    indata[3] = inlen & 0xFF;    indata[4] = proto >> 8;    indata[5] = proto & 0xFF;    inlen += 6;    (*xcp->send_data)(xcp,indata,inlen);}/* * Next level handler above HDLC or AHDLC.  Assumes that CRC has been * verified and removed, and that all escaping (transparency) * characters have been handled.  The PPP processing continues here by * decoding the address and control fields, then by demultiplexing * based on the PPP protocol number. */voidlink_receive(struct ppp_link *lptr, octet *indata, int inlen){    uint16 proto;    struct xcp_state *xcp;    if (inlen < 2)	return;    /* Handle address and control field compression */    if (lptr->acfc_in) {	if (indata[0] == 0xFF && indata[1] == 0x03) {	    indata += 2;	    inlen -= 2;	}    } else {	if (indata[0] != 0xFF || indata[1] != 0x03) {	    lptr->frame_drops++;	    return;	}	indata += 2;	inlen -= 2;    }    /* Handle protocol field compression */    if (lptr->pfc_in) {	if (inlen < 1)	    return;	proto = *indata++;	inlen--;	if (!(proto & 1)) {	    if (inlen < 1)		return;	    proto = (proto << 8) | *indata++;	    inlen--;	}    } else {	if (inlen < 2)	    return;	proto = (indata[0] << 8) | indata[1];	inlen -= 2;	indata += 2;    }    /* Discard frames with illegal protocol fields. */    if ((proto & 0x101) != 1) {	lptr->frame_drops++;	return;    }    /*     * If per-link ECP is used, then we have to do this first.  This     * must be done here because demultiplexing when MP is in use is     * done at the MP bundle level, not at the link level.     *     * For better security, it may be desirable to discard any non-LCP,     * non-ECP packets when ECP is in open state.  This provides some     * protection against attackers who are able to insert data on the     * line.     */    if (lptr->ecp_in_use && proto == PPP_PROTO_EP_LINK) {	xcp = find_xcp(lptr,proto);	indata = ecp_decrypt(xcp,indata,&inlen);	if (indata == NULL)	    return;	if (inlen < 1)	    return;	proto = *indata++;	inlen--;	if (!(proto & 1)) {	    if (inlen < 1)		return;	    proto = (proto << 8) | *indata++;	    inlen--;	}    }    /*     * If we're doing per-link CCP, then we have to do it before normal     * demultiplexing because CCP usually needs to inspect all data and     * because demultiplexing on an MP system is done at the bundle     * level.     */    if (lptr->ccp_in_use) {	xcp = find_xcp(lptr,PPP_PROTO_CP_LINK);	if (proto == PPP_PROTO_CP_LINK) {	    indata = ccp_uncompress(xcp,indata,&inlen);	    if (indata == NULL)		return;	    if (inlen < 1)		return;	    proto = *indata++;	    inlen--;	    if (!(proto & 1)) {		if (inlen < 1)		    return;		proto = (proto << 8) | *indata++;		inlen--;	    }	} else	    ccp_uncompressed(xcp,proto,indata,inlen);    }    /*     * If we're a link in an MP bundle, then send to NCP at bundle level     * when necessary.  Most LCP messages should be handled at the link     * level.  Protocol-Reject (code 8), though, should go to the bundle     * level, since it is used to shut down NCPs.  One might consider     * sending the Time-Remaining message to the bundle level as well,     * depending on system architecture.     *     * Note that LCP should disconnect this link from the bundle if it     * leaves the Open state.     */    if (lptr->mp != NULL &&	(proto != PPP_PROTO_LCP || indata[0] == 8)) {	lptr->mp->in_on = lptr;	xcp = find_xcp(lptr->mp->lptr,proto);    } else	xcp = find_xcp(lptr,proto);    /* Dispatch to appropriate handler now. */    if (xcp != NULL)	(*xcp->handler)(xcp,indata,inlen);    else {	/* No handler for this protocol, log it and reject it. */	send_lcp_protocol_reject(lptr,proto,indata,inlen);    }}/* * Add address, control, and protocol fields. */static intadd_acf_and_pf(struct ppp_link *lptr, octet *outdata, uint16 proto){    octet *ood = outdata;    if (lptr->pfc_out && (proto & 0xFF00) == 0)	*--outdata = proto & 0xFF;    else {	*--outdata = proto & 0xFF;	*--outdata = proto >> 8;    }    if (!lptr->acfc_out && proto != PPP_PROTO_LCP) {	*--outdata = 0x03;	*--outdata = 0xFF;    }    return ood-outdata;}/* * Standard (non-MP) PPP output routine. */static voidnormal_output(struct ppp_link *link, octet *outdata, int outlen, uint16 proto){    int i;    i = add_acf_and_pf(link,outdata,proto);    outdata -= i;    outlen += i;    (*link->user_output)(link->handle,outdata,outlen);}/* * This routine replaces the normal link_output routine for the bundle * level PPP link. */static voidmp_output(struct ppp_link *lptr, octet *outdata, int outlen, uint16 proto){    struct mp_state *mp = lptr->mp;    struct ppp_link *ind_lptr;    int fragsize,len,hdrsize;    octet flags;    /* Prepend a compressed protocol ID field */    if (proto <= 0xFF) {	*--outdata = proto;	outlen++;    } else { 	*--outdata = proto & 0xFF;	*--outdata = proto >> 8;	outlen += 2;    }    /* Figure output fragment size */    if (outlen < MIN_FRAG_SIZE)	fragsize = outlen;    else	fragsize = (outlen+mp->numlinks-1)/mp->numlinks;    if (mp->snd_short_seq)	hdrsize = 2;    else	hdrsize = 4;    /* Loop over packet and transmit fragments. */    flags = MP_BEGIN;    ind_lptr = mp->next_out_link;    while (outlen > 0) {	if (ind_lptr == NULL) {	    ind_lptr = mp->links;	    if (ind_lptr == NULL)		break;	}	len = outlen;	if (len > fragsize)	    len = fragsize;	if (len > ind_lptr->mtu-hdrsize)	    len = ind_lptr->mtu-hdrsize;	if ((outlen -= len) == 0)	    flags |= MP_END;	/*	 * Add an MP header.  WARNING:  Corrupts previous output data!	 * The link_output routine has to block until all data have been	 * copied into a local buffer or transmitted.  (Scatter/gather	 * is the usual way to handle this, but not in this simple	 * example.)	 */	*--outdata = mp->send_seq & 0xFF;	if (mp->snd_short_seq)	    *--outdata = ((mp->send_seq>>8) & 0xF) | flags;	else {	    *--outdata = (mp->send_seq>>8) & 0xFF;	    *--outdata = (mp->send_seq>>16) & 0xFF;	    *--outdata = flags;	    len += 2;	}	len += 2;	(*ind_lptr->link_output)(ind_lptr,outdata,len,PPP_PROTO_MP);	flags = 0;	outdata += len;	mp->send_seq++;	ind_lptr = ind_lptr->next;    }    mp->next_out_link = ind_lptr;}/* * MP input handler.  Does reassembly and demultiplexing. * * The modular arithmetic tests done are a little tricky, so they're * commented with the equivalent regular arithmetic test. * * Comments indicating where the PPP system can be notified of lost * packets are also included, as are notes identifying peer * misbehavior. * * "link" is bundle level state pointer.  "lptr" is link level for * received data. */static voidmp_handler(struct xcp_state *mpxcp, octet *indata, int inlen){    struct ppp_link *lptr,*link = mpxcp->link, *ltmp;    struct mp_state *mp = link->mp;    struct mp_fragment *frag,*newfrag,*start,*nextf;    int flags;    uint32 newseq,thisseq,sbit,smask,minseq;    static char buffer[MAX_MRRU];    char *bp;    uint16 proto;    struct xcp_state *xcp;    /* Get pointer to link on which this message came in. */    lptr = mp->in_on;    /* Decode MP flags and sequence number. */    flags = indata[0];    if (mp->rcv_short_seq) {	if (inlen < 2 || (indata[0] & 0x30) != 0) {	    syslog(LOG_NOTICE,"corrupted MP header");	    return;	}	newseq = ((indata[0] & 0xF) << 8) | indata[1];	indata += 2;	inlen -= 2;	sbit = 0x800;    } else {	if (inlen < 4 || (indata[0] & 0x3F) != 0) {	    syslog(LOG_NOTICE,"corrupted MP header");	    return;	}	newseq = (indata[1] << 16) | (indata[2] << 8) | indata[3];	indata += 4;	inlen -= 4;	sbit = 0x800000;    }    smask = (sbit << 1) - 1;    /* if newseq < lptr->seq */    if (((newseq-lptr->seq) & sbit) != 0) {	syslog(LOG_DEBUG,"out-of-order packet %lu on link %p",newseq,lptr);	return;    }    /* Find minimum sequence number over all links and save at bundle level. */    minseq = lptr->seq = newseq;    for (ltmp = mp->links; ltmp != NULL; ltmp = ltmp->next)	/* if ltmp->seq < minseq */	if (((ltmp->seq-minseq) & sbit) != 0)	    minseq = ltmp->seq;    link->seq = minseq;    /* syslog(LOG_DEBUG,"handling sequence %lu; minimum is %lu",newseq,       minseq);*/    /* Create fragment record for this new message. */    newfrag = (struct mp_fragment *)malloc(sizeof(*newfrag)+inlen);    if (newfrag == NULL) {	syslog(LOG_ERR,"MP storage allocation failure; fragment dropped.");	if (flags & MP_END)	    /* Packet has been dropped. */	    link->frame_drops++;	return;    }    newfrag->flags = flags;    newfrag->seq = newseq;    newfrag->length = inlen;    memcpy(newfrag->data,indata,inlen);    /* If this new fragment is before the first one, then enqueue it now. */    if ((frag = mp->frags) == NULL ||	/* newseq < frag->seq */	((newseq-frag->seq) & sbit) != 0) {	newfrag->next = frag;	mp->frags = newfrag;	newfrag = NULL;    }    /* Loop over fragments and update the list */    start = NULL;    frag = mp->frags;    if (frag->flags & MP_BEGIN)	start = frag;    mp->frags = NULL;    while (start != NULL || newfrag != NULL) {    nextfrag:	thisseq = frag->seq;	nextf = frag->next;	/* Drop any duplicate fragments */	if (newfrag != NULL && thisseq == newseq) {	    syslog(LOG_DEBUG,"dropped duplicate sequence %lu",thisseq);	    free(newfrag);	    newfrag = NULL;

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人久久18免费网站麻豆| 亚洲午夜av在线| 91精品午夜视频| 欧美日韩国产影片| 欧美午夜在线一二页| 欧美在线短视频| 国产一区二区三区精品欧美日韩一区二区三区 | 成人福利在线看| 欧美一级在线观看| 亚洲永久免费av| 成人激情校园春色| 久久久久久免费毛片精品| 日韩国产在线观看| 日韩一级成人av| 亚洲天堂av一区| 成人一道本在线| 久久综合九色综合久久久精品综合| 亚洲成人自拍网| 在线一区二区三区四区| 1000精品久久久久久久久| 国产精品一卡二卡| 26uuu国产电影一区二区| 奇米影视7777精品一区二区| 欧美日韩亚洲综合一区二区三区| 亚洲欧洲另类国产综合| 成人av免费在线观看| 久久久国产综合精品女国产盗摄| 久久aⅴ国产欧美74aaa| 欧美一级二级三级乱码| 视频一区中文字幕国产| 欧美日韩国产小视频在线观看| 亚洲综合免费观看高清在线观看| 色狠狠av一区二区三区| 亚洲综合精品久久| 欧美在线不卡视频| 亚洲综合激情小说| 欧美体内she精高潮| 天天综合色天天综合色h| 欧美高清视频www夜色资源网| 欧美bbbbb| 色综合天天综合网国产成人综合天| 欧美中文字幕一二三区视频| 精品va天堂亚洲国产| 一区二区三区不卡视频在线观看| 久久99精品国产麻豆不卡| 91免费看`日韩一区二区| 久久综合丝袜日本网| 亚洲国产aⅴ成人精品无吗| 国产91富婆露脸刺激对白| 欧美三片在线视频观看| 国产精品女人毛片| 美日韩一级片在线观看| 在线精品观看国产| 亚洲欧洲无码一区二区三区| 久久99精品国产.久久久久久| 色婷婷激情一区二区三区| 久久精品欧美一区二区三区麻豆 | 一区二区三区四区蜜桃| 国产高清无密码一区二区三区| 欧美日韩在线三区| 亚洲人xxxx| 成人免费视频免费观看| 26uuu精品一区二区三区四区在线| 亚洲线精品一区二区三区八戒| 99久久伊人网影院| 2020日本不卡一区二区视频| 日韩av电影天堂| 欧美精品 国产精品| 五月综合激情婷婷六月色窝| 色吊一区二区三区| 樱花草国产18久久久久| 91精品福利视频| 亚洲精品一二三区| 在线欧美一区二区| 亚洲一区在线观看视频| 色婷婷综合久久久中文一区二区| 中文字幕中文字幕一区二区| 大白屁股一区二区视频| 国产精品国产自产拍在线| 成a人片国产精品| 综合久久综合久久| 欧美三级日韩三级国产三级| 亚洲第一主播视频| 91精品在线一区二区| 久久精品国产网站| 久久精品男人的天堂| 成人午夜av在线| 一区在线中文字幕| 欧美色欧美亚洲另类二区| 奇米精品一区二区三区四区| 精品捆绑美女sm三区| 丁香啪啪综合成人亚洲小说| 国产精品美女久久久久aⅴ| 一本大道久久a久久综合| 亚洲综合免费观看高清完整版| 欧美美女喷水视频| 久久国产人妖系列| 国产女同互慰高潮91漫画| 一本高清dvd不卡在线观看| 亚洲成av人片在线观看无码| 日韩欧美的一区| 成人免费毛片嘿嘿连载视频| 一区二区三区中文字幕电影| 欧美精品乱人伦久久久久久| 国产毛片精品视频| 亚洲精品乱码久久久久久久久| 欧美日韩aaaaa| 国产乱人伦精品一区二区在线观看 | 亚洲福中文字幕伊人影院| 欧美一级一级性生活免费录像| 国产高清久久久| 午夜精品福利视频网站| 日本一区二区三级电影在线观看| caoporm超碰国产精品| 亚洲成人av一区| 久久亚洲欧美国产精品乐播| 在线视频国产一区| 国产一区二区三区免费观看| 日韩精品一区二区三区三区免费| 99re视频这里只有精品| 91免费国产视频网站| 色噜噜偷拍精品综合在线| 色狠狠一区二区三区香蕉| 欧美丝袜丝交足nylons| 欧美老女人第四色| 日韩视频在线观看一区二区| 日韩欧美国产综合一区| 久久婷婷国产综合精品青草| 久久久久久**毛片大全| 国产精品你懂的在线欣赏| 亚洲精品乱码久久久久| 婷婷综合另类小说色区| 另类小说一区二区三区| 国产一区二区三区免费观看| av在线播放一区二区三区| 色就色 综合激情| 日韩午夜精品电影| 亚洲国产精品成人综合色在线婷婷| 日本一区二区三区高清不卡| 亚洲美女少妇撒尿| 国产成人精品三级| 成人精品视频.| 欧美丝袜自拍制服另类| 久久综合久久99| 亚洲欧洲国产日韩| 视频一区二区三区中文字幕| 国内成人精品2018免费看| 99久久99久久精品国产片果冻 | 在线播放国产精品二区一二区四区| 欧美一区二区福利视频| 国产欧美一区二区三区网站| 一区二区三区日本| 国产一区二区久久| 日本精品裸体写真集在线观看| 欧美一区二区三区男人的天堂| 日本一区二区视频在线观看| 午夜精品免费在线| 成a人片国产精品| 欧美一区二区三区思思人| 中文字幕在线观看不卡视频| 秋霞午夜av一区二区三区| 成人免费福利片| 日韩欧美在线一区二区三区| 亚洲人妖av一区二区| 老司机精品视频一区二区三区| zzijzzij亚洲日本少妇熟睡| 日韩欧美一区在线| 亚洲综合成人在线视频| 国产成人免费视频网站高清观看视频| 欧美日韩一区二区三区高清| 奇米影视一区二区三区小说| 蜜芽一区二区三区| 国产精品2024| 91香蕉视频污| 欧美一区二区精品久久911| 欧美成人一区二区| 国产精品久久久久毛片软件| 亚洲黄色小视频| 久久99国产精品久久| av欧美精品.com| 欧美高清视频www夜色资源网| 久久婷婷一区二区三区| 日韩理论电影院| 美女任你摸久久| www.爱久久.com| 制服丝袜av成人在线看| 久久九九久久九九| 亚洲综合一区二区精品导航| 青青草国产成人99久久| 成人av在线电影| 日韩午夜在线观看| 中文字幕中文字幕在线一区| 秋霞电影一区二区| 99久久精品国产导航| 日韩一级片在线播放| 亚洲视频一二区| 精品在线播放午夜| 在线看国产一区二区| 精品三级av在线| 欧美美女一区二区三区|