mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-08-24 23:25:58 +00:00
IPCP and LCP structures moved to ppp_pcb
This commit is contained in:
parent
19238a910c
commit
4b7e3af77c
@ -731,7 +731,7 @@ void link_established(ppp_pcb *pcb) {
|
||||
#if PPP_SERVER
|
||||
lcp_options *go = &lcp_gotoptions[pcb->unit];
|
||||
#endif /* #if PPP_SERVER */
|
||||
lcp_options *ho = &lcp_hisoptions[pcb->unit];
|
||||
lcp_options *ho = &pcb->lcp_hisoptions;
|
||||
int i;
|
||||
struct protent *protp;
|
||||
|
||||
@ -1444,8 +1444,8 @@ auth_check_options()
|
||||
* to use for authenticating ourselves and/or the peer.
|
||||
*/
|
||||
void auth_reset(ppp_pcb *pcb) {
|
||||
lcp_options *go = &lcp_gotoptions[pcb->unit];
|
||||
lcp_options *ao = &lcp_allowoptions[pcb->unit];
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
lcp_options *ao = &pcb->lcp_allowoptions;
|
||||
|
||||
if( pcb->settings.passwd[0] ) {
|
||||
|
||||
|
@ -45,6 +45,9 @@
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef FSM_H
|
||||
#define FSM_H
|
||||
|
||||
/*
|
||||
* Packet header = Code, id, length.
|
||||
*/
|
||||
@ -170,4 +173,5 @@ void fsm_sdata (fsm *, int, int, u_char *, int);
|
||||
*/
|
||||
extern int peer_mru[]; /* currently negotiated peer MRU (per unit) */
|
||||
|
||||
#endif /* FSM_H */
|
||||
#endif /* PPP_SUPPORT */
|
||||
|
@ -65,14 +65,11 @@
|
||||
#include "ipcp.h"
|
||||
|
||||
/* global vars */
|
||||
ipcp_options ipcp_wantoptions[NUM_PPP]; /* Options that we want to request */
|
||||
ipcp_options ipcp_gotoptions[NUM_PPP]; /* Options that peer ack'd */
|
||||
ipcp_options ipcp_allowoptions[NUM_PPP]; /* Options we allow peer to request */
|
||||
ipcp_options ipcp_hisoptions[NUM_PPP]; /* Options that we ack'd */
|
||||
|
||||
u_int32_t netmask = 0; /* IP netmask to set on interface */
|
||||
|
||||
#if 0 /* UNUSED */
|
||||
bool disable_defaultip = 0; /* Don't use hostname for default IP adrs */
|
||||
#endif /* UNUSED */
|
||||
bool noremoteip = 0; /* Let him have no IP address */
|
||||
|
||||
#if 0 /* UNUSED */
|
||||
@ -106,18 +103,16 @@ static char netmask_str[20]; /* string form of netmask value */
|
||||
/*
|
||||
* Callbacks for fsm code. (CI = Configuration Information)
|
||||
*/
|
||||
static void ipcp_resetci (fsm *); /* Reset our CI */
|
||||
static int ipcp_cilen (fsm *); /* Return length of our CI */
|
||||
static void ipcp_addci (fsm *, u_char *, int *); /* Add our CI */
|
||||
static int ipcp_ackci (fsm *, u_char *, int); /* Peer ack'd our CI */
|
||||
static int ipcp_nakci (fsm *, u_char *, int, int);/* Peer nak'd our CI */
|
||||
static int ipcp_rejci (fsm *, u_char *, int); /* Peer rej'd our CI */
|
||||
static int ipcp_reqci (fsm *, u_char *, int *, int); /* Rcv CI */
|
||||
static void ipcp_up (fsm *); /* We're UP */
|
||||
static void ipcp_down (fsm *); /* We're DOWN */
|
||||
static void ipcp_finished (fsm *); /* Don't need lower layer */
|
||||
|
||||
fsm ipcp_fsm[NUM_PPP]; /* IPCP fsm structure */
|
||||
static void ipcp_resetci(fsm *f); /* Reset our CI */
|
||||
static int ipcp_cilen(fsm *f); /* Return length of our CI */
|
||||
static void ipcp_addci(fsm *f, u_char *ucp, int *lenp); /* Add our CI */
|
||||
static int ipcp_ackci(fsm *f, u_char *p, int len); /* Peer ack'd our CI */
|
||||
static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject);/* Peer nak'd our CI */
|
||||
static int ipcp_rejci(fsm *f, u_char *p, int len); /* Peer rej'd our CI */
|
||||
static int ipcp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree); /* Rcv CI */
|
||||
static void ipcp_up(fsm *f); /* We're UP */
|
||||
static void ipcp_down(fsm *f); /* We're DOWN */
|
||||
static void ipcp_finished(fsm *f); /* Don't need lower layer */
|
||||
|
||||
static fsm_callbacks ipcp_callbacks = { /* IPCP callback routines */
|
||||
ipcp_resetci, /* Reset our Configuration Information */
|
||||
@ -254,16 +249,16 @@ static option_t ipcp_option_list[] = {
|
||||
/*
|
||||
* Protocol entry points from main code.
|
||||
*/
|
||||
static void ipcp_init (int);
|
||||
static void ipcp_open (int);
|
||||
static void ipcp_close (int, char *);
|
||||
static void ipcp_lowerup (int);
|
||||
static void ipcp_lowerdown (int);
|
||||
static void ipcp_input (int, u_char *, int);
|
||||
static void ipcp_protrej (int);
|
||||
static void ipcp_init(int unit);
|
||||
static void ipcp_open(int unit);
|
||||
static void ipcp_close(int unit, char *reason);
|
||||
static void ipcp_lowerup(int unit);
|
||||
static void ipcp_lowerdown(int unit);
|
||||
static void ipcp_input(int unit, u_char *p, int len);
|
||||
static void ipcp_protrej(int unit);
|
||||
#if PRINTPKT_SUPPORT
|
||||
static int ipcp_printpkt (u_char *, int,
|
||||
void (*) (void *, char *, ...), void *);
|
||||
static int ipcp_printpkt(u_char *p, int plen,
|
||||
void (*printer) (void *, char *, ...), void *arg);
|
||||
#endif /* PRINTPKT_SUPPORT */
|
||||
#if PPP_OPTIONS
|
||||
static void ip_check_options (void);
|
||||
@ -589,18 +584,17 @@ parse_dotted_ip(p, vp)
|
||||
/*
|
||||
* ipcp_init - Initialize IPCP.
|
||||
*/
|
||||
static void
|
||||
ipcp_init(unit)
|
||||
int unit;
|
||||
{
|
||||
fsm *f = &ipcp_fsm[unit];
|
||||
ipcp_options *wo = &ipcp_wantoptions[unit];
|
||||
ipcp_options *ao = &ipcp_allowoptions[unit];
|
||||
static void ipcp_init(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
fsm *f = &pcb->ipcp_fsm;
|
||||
|
||||
ipcp_options *wo = &pcb->ipcp_wantoptions;
|
||||
ipcp_options *ao = &pcb->ipcp_allowoptions;
|
||||
|
||||
f->unit = unit;
|
||||
f->protocol = PPP_IPCP;
|
||||
f->callbacks = &ipcp_callbacks;
|
||||
fsm_init(&ipcp_fsm[unit]);
|
||||
fsm_init(f);
|
||||
|
||||
/*
|
||||
* Some 3G modems use repeated IPCP NAKs as a way of stalling
|
||||
@ -644,11 +638,10 @@ ipcp_init(unit)
|
||||
/*
|
||||
* ipcp_open - IPCP is allowed to come up.
|
||||
*/
|
||||
static void
|
||||
ipcp_open(unit)
|
||||
int unit;
|
||||
{
|
||||
fsm_open(&ipcp_fsm[unit]);
|
||||
static void ipcp_open(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
fsm *f = &pcb->ipcp_fsm;
|
||||
fsm_open(f);
|
||||
ipcp_is_open = 1;
|
||||
}
|
||||
|
||||
@ -656,47 +649,40 @@ ipcp_open(unit)
|
||||
/*
|
||||
* ipcp_close - Take IPCP down.
|
||||
*/
|
||||
static void
|
||||
ipcp_close(unit, reason)
|
||||
int unit;
|
||||
char *reason;
|
||||
{
|
||||
fsm_close(&ipcp_fsm[unit], reason);
|
||||
static void ipcp_close(int unit, char *reason) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
fsm *f = &pcb->ipcp_fsm;
|
||||
fsm_close(f, reason);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ipcp_lowerup - The lower layer is up.
|
||||
*/
|
||||
static void
|
||||
ipcp_lowerup(unit)
|
||||
int unit;
|
||||
{
|
||||
fsm_lowerup(&ipcp_fsm[unit]);
|
||||
static void ipcp_lowerup(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
fsm *f = &pcb->ipcp_fsm;
|
||||
fsm_lowerup(f);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ipcp_lowerdown - The lower layer is down.
|
||||
*/
|
||||
static void
|
||||
ipcp_lowerdown(unit)
|
||||
int unit;
|
||||
{
|
||||
fsm_lowerdown(&ipcp_fsm[unit]);
|
||||
static void ipcp_lowerdown(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
fsm *f = &pcb->ipcp_fsm;
|
||||
fsm_lowerdown(f);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ipcp_input - Input IPCP packet.
|
||||
*/
|
||||
static void
|
||||
ipcp_input(unit, p, len)
|
||||
int unit;
|
||||
u_char *p;
|
||||
int len;
|
||||
{
|
||||
fsm_input(&ipcp_fsm[unit], p, len);
|
||||
static void ipcp_input(int unit, u_char *p, int len) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
fsm *f = &pcb->ipcp_fsm;
|
||||
fsm_input(f, p, len);
|
||||
}
|
||||
|
||||
|
||||
@ -705,11 +691,10 @@ ipcp_input(unit, p, len)
|
||||
*
|
||||
* Pretend the lower layer went down, so we shut up.
|
||||
*/
|
||||
static void
|
||||
ipcp_protrej(unit)
|
||||
int unit;
|
||||
{
|
||||
fsm_lowerdown(&ipcp_fsm[unit]);
|
||||
static void ipcp_protrej(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
fsm *f = &pcb->ipcp_fsm;
|
||||
fsm_lowerdown(f);
|
||||
}
|
||||
|
||||
|
||||
@ -717,14 +702,11 @@ ipcp_protrej(unit)
|
||||
* ipcp_resetci - Reset our CI.
|
||||
* Called by fsm_sconfreq, Send Configure Request.
|
||||
*/
|
||||
static void
|
||||
ipcp_resetci(f)
|
||||
fsm *f;
|
||||
{
|
||||
ppp_pcb *pc = &ppp_pcb_list[f->unit];
|
||||
ipcp_options *wo = &ipcp_wantoptions[f->unit];
|
||||
ipcp_options *go = &ipcp_gotoptions[f->unit];
|
||||
ipcp_options *ao = &ipcp_allowoptions[f->unit];
|
||||
static void ipcp_resetci(fsm *f) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
ipcp_options *wo = &pcb->ipcp_wantoptions;
|
||||
ipcp_options *go = &pcb->ipcp_gotoptions;
|
||||
ipcp_options *ao = &pcb->ipcp_allowoptions;
|
||||
|
||||
wo->req_addr = (wo->neg_addr || wo->old_addrs) &&
|
||||
(ao->neg_addr || ao->old_addrs);
|
||||
@ -732,8 +714,8 @@ ipcp_resetci(f)
|
||||
wo->accept_local = 1;
|
||||
if (wo->hisaddr == 0)
|
||||
wo->accept_remote = 1;
|
||||
wo->req_dns1 = pc->settings.usepeerdns; /* Request DNS addresses from the peer */
|
||||
wo->req_dns2 = pc->settings.usepeerdns;
|
||||
wo->req_dns1 = pcb->settings.usepeerdns; /* Request DNS addresses from the peer */
|
||||
wo->req_dns2 = pcb->settings.usepeerdns;
|
||||
*go = *wo;
|
||||
if (!ask_for_local)
|
||||
go->ouraddr = 0;
|
||||
@ -745,7 +727,7 @@ ipcp_resetci(f)
|
||||
}
|
||||
}
|
||||
#endif /* UNUSED */
|
||||
BZERO(&ipcp_hisoptions[f->unit], sizeof(ipcp_options));
|
||||
BZERO(&pcb->ipcp_hisoptions, sizeof(ipcp_options));
|
||||
}
|
||||
|
||||
|
||||
@ -753,13 +735,11 @@ ipcp_resetci(f)
|
||||
* ipcp_cilen - Return length of our CI.
|
||||
* Called by fsm_sconfreq, Send Configure Request.
|
||||
*/
|
||||
static int
|
||||
ipcp_cilen(f)
|
||||
fsm *f;
|
||||
{
|
||||
ipcp_options *go = &ipcp_gotoptions[f->unit];
|
||||
ipcp_options *wo = &ipcp_wantoptions[f->unit];
|
||||
ipcp_options *ho = &ipcp_hisoptions[f->unit];
|
||||
static int ipcp_cilen(fsm *f) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
ipcp_options *go = &pcb->ipcp_gotoptions;
|
||||
ipcp_options *wo = &pcb->ipcp_wantoptions;
|
||||
ipcp_options *ho = &pcb->ipcp_hisoptions;
|
||||
|
||||
#define LENCIADDRS(neg) (neg ? CILEN_ADDRS : 0)
|
||||
#define LENCIVJ(neg, old) (neg ? (old? CILEN_COMPRESS : CILEN_VJ) : 0)
|
||||
@ -797,13 +777,9 @@ ipcp_cilen(f)
|
||||
* ipcp_addci - Add our desired CIs to a packet.
|
||||
* Called by fsm_sconfreq, Send Configure Request.
|
||||
*/
|
||||
static void
|
||||
ipcp_addci(f, ucp, lenp)
|
||||
fsm *f;
|
||||
u_char *ucp;
|
||||
int *lenp;
|
||||
{
|
||||
ipcp_options *go = &ipcp_gotoptions[f->unit];
|
||||
static void ipcp_addci(fsm *f, u_char *ucp, int *lenp) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
ipcp_options *go = &pcb->ipcp_gotoptions;
|
||||
int len = *lenp;
|
||||
|
||||
#define ADDCIADDRS(opt, neg, val1, val2) \
|
||||
@ -904,13 +880,9 @@ ipcp_addci(f, ucp, lenp)
|
||||
* 0 - Ack was bad.
|
||||
* 1 - Ack was good.
|
||||
*/
|
||||
static int
|
||||
ipcp_ackci(f, p, len)
|
||||
fsm *f;
|
||||
u_char *p;
|
||||
int len;
|
||||
{
|
||||
ipcp_options *go = &ipcp_gotoptions[f->unit];
|
||||
static int ipcp_ackci(fsm *f, u_char *p, int len) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
ipcp_options *go = &pcb->ipcp_gotoptions;
|
||||
u_short cilen, citype, cishort;
|
||||
u_int32_t cilong;
|
||||
u_char cimaxslotindex, cicflag;
|
||||
@ -1029,14 +1001,9 @@ bad:
|
||||
* 0 - Nak was bad.
|
||||
* 1 - Nak was good.
|
||||
*/
|
||||
static int
|
||||
ipcp_nakci(f, p, len, treat_as_reject)
|
||||
fsm *f;
|
||||
u_char *p;
|
||||
int len;
|
||||
int treat_as_reject;
|
||||
{
|
||||
ipcp_options *go = &ipcp_gotoptions[f->unit];
|
||||
static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
ipcp_options *go = &pcb->ipcp_gotoptions;
|
||||
u_char cimaxslotindex, cicflag;
|
||||
u_char citype, cilen, *next;
|
||||
u_short cishort;
|
||||
@ -1278,13 +1245,9 @@ bad:
|
||||
* ipcp_rejci - Reject some of our CIs.
|
||||
* Callback from fsm_rconfnakrej.
|
||||
*/
|
||||
static int
|
||||
ipcp_rejci(f, p, len)
|
||||
fsm *f;
|
||||
u_char *p;
|
||||
int len;
|
||||
{
|
||||
ipcp_options *go = &ipcp_gotoptions[f->unit];
|
||||
static int ipcp_rejci(fsm *f, u_char *p, int len) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
ipcp_options *go = &pcb->ipcp_gotoptions;
|
||||
u_char cimaxslotindex, ciflag, cilen;
|
||||
u_short cishort;
|
||||
u_int32_t cilong;
|
||||
@ -1428,17 +1391,15 @@ bad:
|
||||
* Returns: CONFACK, CONFNAK or CONFREJ and input packet modified
|
||||
* appropriately. If reject_if_disagree is non-zero, doesn't return
|
||||
* CONFNAK; returns CONFREJ if it can't return CONFACK.
|
||||
*
|
||||
* inp = Requested CIs
|
||||
* len = Length of requested CIs
|
||||
*/
|
||||
static int
|
||||
ipcp_reqci(f, inp, len, reject_if_disagree)
|
||||
fsm *f;
|
||||
u_char *inp; /* Requested CIs */
|
||||
int *len; /* Length of requested CIs */
|
||||
int reject_if_disagree;
|
||||
{
|
||||
ipcp_options *wo = &ipcp_wantoptions[f->unit];
|
||||
ipcp_options *ho = &ipcp_hisoptions[f->unit];
|
||||
ipcp_options *ao = &ipcp_allowoptions[f->unit];
|
||||
static int ipcp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
ipcp_options *wo = &pcb->ipcp_wantoptions;
|
||||
ipcp_options *ho = &pcb->ipcp_hisoptions;
|
||||
ipcp_options *ao = &pcb->ipcp_allowoptions;
|
||||
u_char *cip, *next; /* Pointer to current and next CIs */
|
||||
u_short cilen, citype; /* Parsed len, type */
|
||||
u_short cishort; /* Parsed short value */
|
||||
@ -1797,15 +1758,12 @@ ip_demand_conf(u)
|
||||
*
|
||||
* Configure the IP network interface appropriately and bring it up.
|
||||
*/
|
||||
static void
|
||||
ipcp_up(f)
|
||||
fsm *f;
|
||||
{
|
||||
static void ipcp_up(fsm *f) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
u_int32_t mask;
|
||||
ipcp_options *ho = &ipcp_hisoptions[f->unit];
|
||||
ipcp_options *go = &ipcp_gotoptions[f->unit];
|
||||
ipcp_options *wo = &ipcp_wantoptions[f->unit];
|
||||
ipcp_options *ho = &pcb->ipcp_hisoptions;
|
||||
ipcp_options *go = &pcb->ipcp_gotoptions;
|
||||
ipcp_options *wo = &pcb->ipcp_wantoptions;
|
||||
|
||||
IPCPDEBUG(("ipcp: up"));
|
||||
|
||||
@ -1957,17 +1915,17 @@ ipcp_up(f)
|
||||
sifnpmode(pcb, PPP_IP, NPMODE_PASS);
|
||||
|
||||
/* assign a default route through the interface if required */
|
||||
if (ipcp_wantoptions[f->unit].default_route)
|
||||
if (wo->default_route)
|
||||
if (sifdefaultroute(pcb, go->ouraddr, ho->hisaddr,
|
||||
wo->replace_default_route))
|
||||
default_route_set[f->unit] = 1;
|
||||
|
||||
/* Make a proxy ARP entry if requested. */
|
||||
if (ho->hisaddr != 0 && ipcp_wantoptions[f->unit].proxy_arp)
|
||||
if (ho->hisaddr != 0 && wo->proxy_arp)
|
||||
if (sifproxyarp(pcb, ho->hisaddr))
|
||||
proxy_arp_set[f->unit] = 1;
|
||||
|
||||
ipcp_wantoptions[0].ouraddr = go->ouraddr;
|
||||
wo->ouraddr = go->ouraddr;
|
||||
|
||||
notice("local IP address %I", go->ouraddr);
|
||||
if (ho->hisaddr != 0)
|
||||
@ -2001,11 +1959,11 @@ ipcp_up(f)
|
||||
* Take the IP network interface down, clear its addresses
|
||||
* and delete routes through it.
|
||||
*/
|
||||
static void
|
||||
ipcp_down(f)
|
||||
fsm *f;
|
||||
{
|
||||
static void ipcp_down(fsm *f) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
ipcp_options *ho = &pcb->ipcp_hisoptions;
|
||||
ipcp_options *go = &pcb->ipcp_gotoptions;
|
||||
|
||||
IPCPDEBUG(("ipcp: down"));
|
||||
#if PPP_STATS_SUPPORT
|
||||
/* XXX a bit IPv4-centric here, we only need to get the stats
|
||||
@ -2045,9 +2003,9 @@ ipcp_down(f)
|
||||
{
|
||||
sifnpmode(pcb, PPP_IP, NPMODE_DROP);
|
||||
sifdown(pcb);
|
||||
ipcp_clear_addrs(f->unit, ipcp_gotoptions[f->unit].ouraddr,
|
||||
ipcp_hisoptions[f->unit].hisaddr, 0);
|
||||
cdns(pcb, ipcp_gotoptions[f->unit].dnsaddr[0], ipcp_gotoptions[f->unit].dnsaddr[1]);
|
||||
ipcp_clear_addrs(f->unit, go->ouraddr,
|
||||
ho->hisaddr, 0);
|
||||
cdns(pcb, go->dnsaddr[0], go->dnsaddr[1]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2083,10 +2041,7 @@ static void ipcp_clear_addrs(int unit, u_int32_t ouraddr, u_int32_t hisaddr, boo
|
||||
/*
|
||||
* ipcp_finished - possibly shut down the lower layers.
|
||||
*/
|
||||
static void
|
||||
ipcp_finished(f)
|
||||
fsm *f;
|
||||
{
|
||||
static void ipcp_finished(fsm *f) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
if (ipcp_is_open) {
|
||||
ipcp_is_open = 0;
|
||||
@ -2116,13 +2071,8 @@ static char *ipcp_codenames[] = {
|
||||
"TermReq", "TermAck", "CodeRej"
|
||||
};
|
||||
|
||||
static int
|
||||
ipcp_printpkt(p, plen, printer, arg)
|
||||
u_char *p;
|
||||
int plen;
|
||||
void (*printer) (void *, char *, ...);
|
||||
void *arg;
|
||||
{
|
||||
static int ipcp_printpkt(u_char *p, int plen,
|
||||
void (*printer) (void *, char *, ...), void *arg) {
|
||||
int code, id, len, olen;
|
||||
u_char *pstart, *optend;
|
||||
u_short cishort;
|
||||
|
@ -45,6 +45,9 @@
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef IPCP_H
|
||||
#define IPCP_H
|
||||
|
||||
/*
|
||||
* Options.
|
||||
*/
|
||||
@ -89,16 +92,11 @@ typedef struct ipcp_options {
|
||||
u_int32_t winsaddr[2]; /* Primary and secondary MS WINS entries */
|
||||
} ipcp_options;
|
||||
|
||||
extern fsm ipcp_fsm[];
|
||||
extern ipcp_options ipcp_wantoptions[];
|
||||
extern ipcp_options ipcp_gotoptions[];
|
||||
extern ipcp_options ipcp_allowoptions[];
|
||||
extern ipcp_options ipcp_hisoptions[];
|
||||
|
||||
#if 0 /* UNUSED, already defined by lwIP */
|
||||
char *ip_ntoa (u_int32_t);
|
||||
#endif /* UNUSED, already defined by lwIP */
|
||||
|
||||
extern struct protent ipcp_protent;
|
||||
|
||||
#endif /* IPCP_H */
|
||||
#endif /* PPP_SUPPORT */
|
||||
|
@ -70,7 +70,7 @@
|
||||
/* steal a bit in fsm flags word */
|
||||
#define DELAYED_UP 0x100
|
||||
|
||||
static void lcp_delayed_up (void *);
|
||||
static void lcp_delayed_up(void *arg);
|
||||
|
||||
/*
|
||||
* LCP-related command-line options.
|
||||
@ -209,11 +209,6 @@ static option_t lcp_option_list[] = {
|
||||
#endif /* PPP_OPTIONS */
|
||||
|
||||
/* global vars */
|
||||
fsm lcp_fsm[NUM_PPP]; /* LCP fsm structure (global)*/
|
||||
lcp_options lcp_wantoptions[NUM_PPP]; /* Options that we want to request */
|
||||
lcp_options lcp_gotoptions[NUM_PPP]; /* Options that peer ack'd */
|
||||
lcp_options lcp_allowoptions[NUM_PPP]; /* Options we allow peer to request */
|
||||
lcp_options lcp_hisoptions[NUM_PPP]; /* Options that we ack'd */
|
||||
#if PPPOS_SUPPORT
|
||||
ext_accm xmit_accm[NUM_PPP]; /* extended transmit ACCM */
|
||||
#endif /* PPPOS_SUPPORT */
|
||||
@ -246,8 +241,8 @@ static void lcp_rprotrej (fsm *, u_char *, int);
|
||||
* routines to send LCP echos to peer
|
||||
*/
|
||||
|
||||
static void lcp_echo_lowerup (int);
|
||||
static void lcp_echo_lowerdown (int);
|
||||
static void lcp_echo_lowerup(int unit);
|
||||
static void lcp_echo_lowerdown(int unit);
|
||||
static void LcpEchoTimeout (void *);
|
||||
static void lcp_received_echo_reply (fsm *, int, u_char *, int);
|
||||
static void LcpSendEchoRequest (fsm *);
|
||||
@ -277,12 +272,12 @@ static fsm_callbacks lcp_callbacks = { /* LCP callback routines */
|
||||
* Some of these are called directly.
|
||||
*/
|
||||
|
||||
static void lcp_init (int);
|
||||
static void lcp_input (int, u_char *, int);
|
||||
static void lcp_protrej (int);
|
||||
static void lcp_init(int unit);
|
||||
static void lcp_input(int unit, u_char *p, int len);
|
||||
static void lcp_protrej(int unit);
|
||||
#if PRINTPKT_SUPPORT
|
||||
static int lcp_printpkt (u_char *, int,
|
||||
void (*) (void *, char *, ...), void *);
|
||||
static int lcp_printpkt(u_char *p, int plen,
|
||||
void (*printer) (void *, char *, ...), void *arg);
|
||||
#endif /* PRINTPKT_SUPPORT */
|
||||
|
||||
struct protent lcp_protent = {
|
||||
@ -374,14 +369,11 @@ printendpoint(opt, printer, arg)
|
||||
/*
|
||||
* lcp_init - Initialize LCP.
|
||||
*/
|
||||
static void
|
||||
lcp_init(unit)
|
||||
int unit;
|
||||
{
|
||||
static void lcp_init(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
fsm *f = &lcp_fsm[unit];
|
||||
lcp_options *wo = &lcp_wantoptions[unit];
|
||||
lcp_options *ao = &lcp_allowoptions[unit];
|
||||
fsm *f = &pcb->lcp_fsm;
|
||||
lcp_options *wo = &pcb->lcp_wantoptions;
|
||||
lcp_options *ao = &pcb->lcp_allowoptions;
|
||||
|
||||
f->unit = unit;
|
||||
f->protocol = PPP_LCP;
|
||||
@ -439,12 +431,10 @@ lcp_init(unit)
|
||||
/*
|
||||
* lcp_open - LCP is allowed to come up.
|
||||
*/
|
||||
void
|
||||
lcp_open(unit)
|
||||
int unit;
|
||||
{
|
||||
fsm *f = &lcp_fsm[unit];
|
||||
lcp_options *wo = &lcp_wantoptions[unit];
|
||||
void lcp_open(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
fsm *f = &pcb->lcp_fsm;
|
||||
lcp_options *wo = &pcb->lcp_wantoptions;
|
||||
|
||||
f->flags &= ~(OPT_PASSIVE | OPT_SILENT);
|
||||
if (wo->passive)
|
||||
@ -458,13 +448,9 @@ lcp_open(unit)
|
||||
/*
|
||||
* lcp_close - Take LCP down.
|
||||
*/
|
||||
void
|
||||
lcp_close(unit, reason)
|
||||
int unit;
|
||||
char *reason;
|
||||
{
|
||||
void lcp_close(int unit, char *reason) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
fsm *f = &lcp_fsm[unit];
|
||||
fsm *f = &pcb->lcp_fsm;
|
||||
int oldstate;
|
||||
|
||||
if (pcb->phase != PHASE_DEAD && pcb->phase != PHASE_MASTER)
|
||||
@ -494,13 +480,13 @@ lcp_close(unit, reason)
|
||||
/*
|
||||
* lcp_lowerup - The lower layer is up.
|
||||
*/
|
||||
void
|
||||
lcp_lowerup(unit)
|
||||
int unit;
|
||||
{
|
||||
void lcp_lowerup(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
lcp_options *wo = &lcp_wantoptions[unit];
|
||||
fsm *f = &lcp_fsm[unit];
|
||||
lcp_options *wo = &pcb->lcp_wantoptions;
|
||||
#if PPPOS_SUPPORT
|
||||
lcp_options *ao = &pcb->lcp_allowoptions;
|
||||
#endif /* PPPOS_SUPPORT */
|
||||
fsm *f = &pcb->lcp_fsm;
|
||||
/*
|
||||
* Don't use A/C or protocol compression on transmission,
|
||||
* but accept A/C and protocol compressed packets
|
||||
@ -515,8 +501,8 @@ lcp_lowerup(unit)
|
||||
return;
|
||||
peer_mru[unit] = PPP_MRU;
|
||||
|
||||
#if PPPOS_SUPPORT
|
||||
lcp_allowoptions[unit].asyncmap = (u_long)xmit_accm[unit][0]
|
||||
#if PPPOS_SUPPORT
|
||||
ao->asyncmap = (u_long)xmit_accm[unit][0]
|
||||
| ((u_long)xmit_accm[unit][1] << 8)
|
||||
| ((u_long)xmit_accm[unit][2] << 16)
|
||||
| ((u_long)xmit_accm[unit][3] << 24);
|
||||
@ -538,27 +524,22 @@ lcp_lowerup(unit)
|
||||
/*
|
||||
* lcp_lowerdown - The lower layer is down.
|
||||
*/
|
||||
void
|
||||
lcp_lowerdown(unit)
|
||||
int unit;
|
||||
{
|
||||
fsm *f = &lcp_fsm[unit];
|
||||
void lcp_lowerdown(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
fsm *f = &pcb->lcp_fsm;
|
||||
|
||||
if (f->flags & DELAYED_UP) {
|
||||
f->flags &= ~DELAYED_UP;
|
||||
UNTIMEOUT(lcp_delayed_up, f);
|
||||
} else
|
||||
fsm_lowerdown(&lcp_fsm[unit]);
|
||||
fsm_lowerdown(f);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* lcp_delayed_up - Bring the lower layer up now.
|
||||
*/
|
||||
static void
|
||||
lcp_delayed_up(arg)
|
||||
void *arg;
|
||||
{
|
||||
static void lcp_delayed_up(void *arg) {
|
||||
fsm *f = arg;
|
||||
|
||||
if (f->flags & DELAYED_UP) {
|
||||
@ -571,13 +552,9 @@ lcp_delayed_up(arg)
|
||||
/*
|
||||
* lcp_input - Input LCP packet.
|
||||
*/
|
||||
static void
|
||||
lcp_input(unit, p, len)
|
||||
int unit;
|
||||
u_char *p;
|
||||
int len;
|
||||
{
|
||||
fsm *f = &lcp_fsm[unit];
|
||||
static void lcp_input(int unit, u_char *p, int len) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
fsm *f = &pcb->lcp_fsm;
|
||||
|
||||
if (f->flags & DELAYED_UP) {
|
||||
f->flags &= ~DELAYED_UP;
|
||||
@ -597,6 +574,8 @@ lcp_extcode(f, code, id, inp, len)
|
||||
u_char *inp;
|
||||
int len;
|
||||
{
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
u_char *magp;
|
||||
|
||||
switch( code ){
|
||||
@ -608,7 +587,7 @@ lcp_extcode(f, code, id, inp, len)
|
||||
if (f->state != OPENED)
|
||||
break;
|
||||
magp = inp;
|
||||
PUTLONG(lcp_gotoptions[f->unit].magicnumber, magp);
|
||||
PUTLONG(go->magicnumber, magp);
|
||||
fsm_sdata(f, ECHOREP, id, inp, len);
|
||||
break;
|
||||
|
||||
@ -696,27 +675,22 @@ lcp_rprotrej(f, inp, len)
|
||||
* lcp_protrej - A Protocol-Reject was received.
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
static void
|
||||
lcp_protrej(unit)
|
||||
int unit;
|
||||
{
|
||||
static void lcp_protrej(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
/*
|
||||
* Can't reject LCP!
|
||||
*/
|
||||
error("Received Protocol-Reject for LCP!");
|
||||
fsm_protreject(&lcp_fsm[unit]);
|
||||
fsm_protreject(&pcb->lcp_fsm);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* lcp_sprotrej - Send a Protocol-Reject for some protocol.
|
||||
*/
|
||||
void
|
||||
lcp_sprotrej(unit, p, len)
|
||||
int unit;
|
||||
u_char *p;
|
||||
int len;
|
||||
{
|
||||
void lcp_sprotrej(int unit, u_char *p, int len) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
fsm *f = &pcb->lcp_fsm;
|
||||
/*
|
||||
* Send back the protocol and the information field of the
|
||||
* rejected packet. We only get here if LCP is in the OPENED state.
|
||||
@ -724,7 +698,7 @@ lcp_sprotrej(unit, p, len)
|
||||
p += 2;
|
||||
len -= 2;
|
||||
|
||||
fsm_sdata(&lcp_fsm[unit], PROTREJ, ++lcp_fsm[unit].id,
|
||||
fsm_sdata(f, PROTREJ, ++f->id,
|
||||
p, len);
|
||||
}
|
||||
|
||||
@ -737,9 +711,9 @@ lcp_resetci(f)
|
||||
fsm *f;
|
||||
{
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
lcp_options *wo = &lcp_wantoptions[f->unit];
|
||||
lcp_options *go = &lcp_gotoptions[f->unit];
|
||||
lcp_options *ao = &lcp_allowoptions[f->unit];
|
||||
lcp_options *wo = &pcb->lcp_wantoptions;
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
lcp_options *ao = &pcb->lcp_allowoptions;
|
||||
|
||||
wo->magicnumber = magic();
|
||||
wo->numloops = 0;
|
||||
@ -767,7 +741,8 @@ static int
|
||||
lcp_cilen(f)
|
||||
fsm *f;
|
||||
{
|
||||
lcp_options *go = &lcp_gotoptions[f->unit];
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
|
||||
#define LENCIVOID(neg) ((neg) ? CILEN_VOID : 0)
|
||||
#if CHAP_SUPPORT
|
||||
@ -833,7 +808,8 @@ lcp_addci(f, ucp, lenp)
|
||||
u_char *ucp;
|
||||
int *lenp;
|
||||
{
|
||||
lcp_options *go = &lcp_gotoptions[f->unit];
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
u_char *start_ucp = ucp;
|
||||
|
||||
#define ADDCIVOID(opt, neg) \
|
||||
@ -948,7 +924,8 @@ lcp_ackci(f, p, len)
|
||||
u_char *p;
|
||||
int len;
|
||||
{
|
||||
lcp_options *go = &lcp_gotoptions[f->unit];
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
u_char cilen, citype, cichar;
|
||||
u_short cishort;
|
||||
u_int32_t cilong;
|
||||
@ -1131,9 +1108,9 @@ lcp_nakci(f, p, len, treat_as_reject)
|
||||
int len;
|
||||
int treat_as_reject;
|
||||
{
|
||||
ppp_pcb *pc = &ppp_pcb_list[f->unit];
|
||||
lcp_options *go = &lcp_gotoptions[f->unit];
|
||||
lcp_options *wo = &lcp_wantoptions[f->unit];
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
lcp_options *wo = &pcb->lcp_wantoptions;
|
||||
u_char citype, cichar, *next;
|
||||
u_short cishort;
|
||||
u_int32_t cilong;
|
||||
@ -1558,7 +1535,7 @@ lcp_nakci(f, p, len, treat_as_reject)
|
||||
if (looped_back) {
|
||||
if (++try.numloops >= lcp_loopbackfail) {
|
||||
notice("Serial line is looped back.");
|
||||
pc->status = EXIT_LOOPBACK;
|
||||
pcb->status = EXIT_LOOPBACK;
|
||||
lcp_close(f->unit, "Loopback detected");
|
||||
}
|
||||
} else
|
||||
@ -1589,7 +1566,8 @@ lcp_rejci(f, p, len)
|
||||
u_char *p;
|
||||
int len;
|
||||
{
|
||||
lcp_options *go = &lcp_gotoptions[f->unit];
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
u_char cichar;
|
||||
u_short cishort;
|
||||
u_int32_t cilong;
|
||||
@ -1820,9 +1798,10 @@ lcp_reqci(f, inp, lenp, reject_if_disagree)
|
||||
int *lenp; /* Length of requested CIs */
|
||||
int reject_if_disagree;
|
||||
{
|
||||
lcp_options *go = &lcp_gotoptions[f->unit];
|
||||
lcp_options *ho = &lcp_hisoptions[f->unit];
|
||||
lcp_options *ao = &lcp_allowoptions[f->unit];
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
lcp_options *ho = &pcb->lcp_hisoptions;
|
||||
lcp_options *ao = &pcb->lcp_allowoptions;
|
||||
u_char *cip, *next; /* Pointer to current and next CIs */
|
||||
int cilen, citype, cichar; /* Parsed len, type, char value */
|
||||
u_short cishort; /* Parsed short value */
|
||||
@ -2281,10 +2260,10 @@ lcp_up(f)
|
||||
fsm *f;
|
||||
{
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
lcp_options *wo = &lcp_wantoptions[f->unit];
|
||||
lcp_options *ho = &lcp_hisoptions[f->unit];
|
||||
lcp_options *go = &lcp_gotoptions[f->unit];
|
||||
lcp_options *ao = &lcp_allowoptions[f->unit];
|
||||
lcp_options *wo = &pcb->lcp_wantoptions;
|
||||
lcp_options *ho = &pcb->lcp_hisoptions;
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
lcp_options *ao = &pcb->lcp_allowoptions;
|
||||
int mtu, mru;
|
||||
|
||||
if (!go->neg_magicnumber)
|
||||
@ -2333,7 +2312,7 @@ lcp_down(f)
|
||||
fsm *f;
|
||||
{
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
lcp_options *go = &lcp_gotoptions[f->unit];
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
|
||||
lcp_echo_lowerdown(f->unit);
|
||||
|
||||
@ -2376,13 +2355,8 @@ static char *lcp_codenames[] = {
|
||||
"TimeRem"
|
||||
};
|
||||
|
||||
static int
|
||||
lcp_printpkt(p, plen, printer, arg)
|
||||
u_char *p;
|
||||
int plen;
|
||||
void (*printer) (void *, char *, ...);
|
||||
void *arg;
|
||||
{
|
||||
static int lcp_printpkt(u_char *p, int plen,
|
||||
void (*printer) (void *, char *, ...), void *arg) {
|
||||
int code, id, len, olen, i;
|
||||
u_char *pstart, *optend;
|
||||
u_short cishort;
|
||||
@ -2689,6 +2663,8 @@ lcp_received_echo_reply (f, id, inp, len)
|
||||
u_char *inp;
|
||||
int len;
|
||||
{
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
u_int32_t magic;
|
||||
|
||||
/* Check the magic number - don't count replies from ourselves. */
|
||||
@ -2697,8 +2673,8 @@ lcp_received_echo_reply (f, id, inp, len)
|
||||
return;
|
||||
}
|
||||
GETLONG(magic, inp);
|
||||
if (lcp_gotoptions[f->unit].neg_magicnumber
|
||||
&& magic == lcp_gotoptions[f->unit].magicnumber) {
|
||||
if (go->neg_magicnumber
|
||||
&& magic == go->magicnumber) {
|
||||
warn("appear to have received our own echo-reply!");
|
||||
return;
|
||||
}
|
||||
@ -2715,6 +2691,8 @@ static void
|
||||
LcpSendEchoRequest (f)
|
||||
fsm *f;
|
||||
{
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
u_int32_t lcp_magic;
|
||||
u_char pkt[4], *pktp;
|
||||
|
||||
@ -2752,7 +2730,7 @@ LcpSendEchoRequest (f)
|
||||
* Make and send the echo request frame.
|
||||
*/
|
||||
if (f->state == OPENED) {
|
||||
lcp_magic = lcp_gotoptions[f->unit].magicnumber;
|
||||
lcp_magic = go->magicnumber;
|
||||
pktp = pkt;
|
||||
PUTLONG(lcp_magic, pktp);
|
||||
fsm_sdata(f, ECHOREQ, lcp_echo_number++ & 0xFF, pkt, pktp - pkt);
|
||||
@ -2764,11 +2742,9 @@ LcpSendEchoRequest (f)
|
||||
* lcp_echo_lowerup - Start the timer for the LCP frame
|
||||
*/
|
||||
|
||||
static void
|
||||
lcp_echo_lowerup (unit)
|
||||
int unit;
|
||||
{
|
||||
fsm *f = &lcp_fsm[unit];
|
||||
static void lcp_echo_lowerup(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
fsm *f = &pcb->lcp_fsm;
|
||||
|
||||
/* Clear the parameters for generating echo frames */
|
||||
lcp_echos_pending = 0;
|
||||
@ -2784,11 +2760,9 @@ lcp_echo_lowerup (unit)
|
||||
* lcp_echo_lowerdown - Stop the timer for the LCP frame
|
||||
*/
|
||||
|
||||
static void
|
||||
lcp_echo_lowerdown (unit)
|
||||
int unit;
|
||||
{
|
||||
fsm *f = &lcp_fsm[unit];
|
||||
static void lcp_echo_lowerdown(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
fsm *f = &pcb->lcp_fsm;
|
||||
|
||||
if (lcp_echo_timer_running != 0) {
|
||||
UNTIMEOUT (LcpEchoTimeout, f);
|
||||
|
@ -45,6 +45,9 @@
|
||||
#include "lwip/opt.h"
|
||||
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#ifndef LCP_H
|
||||
#define LCP_H
|
||||
|
||||
/*
|
||||
* Options.
|
||||
*/
|
||||
@ -85,6 +88,15 @@
|
||||
/* Value used as data for CI_CALLBACK option */
|
||||
#define CBCP_OPT 6 /* Use callback control protocol */
|
||||
|
||||
/* FIXME: moved temporarily from ppp.h */
|
||||
/* An endpoint discriminator, used with multilink. */
|
||||
#define MAX_ENDP_LEN 20 /* maximum length of discriminator value */
|
||||
struct epdisc {
|
||||
unsigned char class;
|
||||
unsigned char length;
|
||||
unsigned char value[MAX_ENDP_LEN];
|
||||
};
|
||||
|
||||
/*
|
||||
* The state of options is described by an lcp_options structure.
|
||||
*/
|
||||
@ -127,11 +139,6 @@ typedef struct lcp_options {
|
||||
struct epdisc endpoint; /* endpoint discriminator */
|
||||
} lcp_options;
|
||||
|
||||
extern fsm lcp_fsm[];
|
||||
extern lcp_options lcp_wantoptions[];
|
||||
extern lcp_options lcp_gotoptions[];
|
||||
extern lcp_options lcp_allowoptions[];
|
||||
extern lcp_options lcp_hisoptions[];
|
||||
#if PPPOS_SUPPORT
|
||||
extern ext_accm xmit_accm[];
|
||||
#endif /* #if PPPOS_SUPPORT */
|
||||
@ -140,11 +147,11 @@ extern ext_accm xmit_accm[];
|
||||
#define MINMRU 128 /* No MRUs below this */
|
||||
#define MAXMRU 16384 /* Normally limit MRU to this */
|
||||
|
||||
void lcp_open (int);
|
||||
void lcp_close (int, char *);
|
||||
void lcp_lowerup (int);
|
||||
void lcp_lowerdown (int);
|
||||
void lcp_sprotrej (int, u_char *, int); /* send protocol reject */
|
||||
void lcp_open(int unit);
|
||||
void lcp_close(int unit, char *reason);
|
||||
void lcp_lowerup(int unit);
|
||||
void lcp_lowerdown(int unit);
|
||||
void lcp_sprotrej(int unit, u_char *p, int len); /* send protocol reject */
|
||||
|
||||
extern struct protent lcp_protent;
|
||||
|
||||
@ -152,4 +159,5 @@ extern struct protent lcp_protent;
|
||||
before deciding the link is looped-back. */
|
||||
#define DEFLOOPBACKFAIL 10
|
||||
|
||||
#endif /* LCP_H */
|
||||
#endif /* PPP_SUPPORT */
|
||||
|
@ -389,6 +389,9 @@ static void ppp_over_ethernet_link_status_cb(ppp_pcb *pcb, int state);
|
||||
int ppp_over_ethernet_open(ppp_pcb *pcb, struct netif *ethif, const char *service_name, const char *concentrator_name,
|
||||
ppp_link_status_cb_fn link_status_cb, void *link_status_ctx) {
|
||||
|
||||
lcp_options *wo = &pcb->lcp_wantoptions;
|
||||
lcp_options *ao = &pcb->lcp_allowoptions;
|
||||
|
||||
LWIP_UNUSED_ARG(service_name);
|
||||
LWIP_UNUSED_ARG(concentrator_name);
|
||||
|
||||
@ -402,15 +405,15 @@ int ppp_over_ethernet_open(ppp_pcb *pcb, struct netif *ethif, const char *servic
|
||||
pcb->link_status_cb = link_status_cb;
|
||||
pcb->link_status_ctx = link_status_ctx;
|
||||
|
||||
lcp_wantoptions[pcb->unit].mru = ethif->mtu-PPPOE_HEADERLEN-2; /* two byte PPP protocol discriminator, then IP data */
|
||||
lcp_wantoptions[pcb->unit].neg_asyncmap = 0;
|
||||
lcp_wantoptions[pcb->unit].neg_pcompression = 0;
|
||||
lcp_wantoptions[pcb->unit].neg_accompression = 0;
|
||||
wo->mru = ethif->mtu-PPPOE_HEADERLEN-2; /* two byte PPP protocol discriminator, then IP data */
|
||||
wo->neg_asyncmap = 0;
|
||||
wo->neg_pcompression = 0;
|
||||
wo->neg_accompression = 0;
|
||||
|
||||
lcp_allowoptions[pcb->unit].mru = ethif->mtu-PPPOE_HEADERLEN-2; /* two byte PPP protocol discriminator, then IP data */
|
||||
lcp_allowoptions[pcb->unit].neg_asyncmap = 0;
|
||||
lcp_allowoptions[pcb->unit].neg_pcompression = 0;
|
||||
lcp_allowoptions[pcb->unit].neg_accompression = 0;
|
||||
ao->mru = ethif->mtu-PPPOE_HEADERLEN-2; /* two byte PPP protocol discriminator, then IP data */
|
||||
ao->neg_asyncmap = 0;
|
||||
ao->neg_pcompression = 0;
|
||||
ao->neg_accompression = 0;
|
||||
|
||||
if(pppoe_create(ethif, pcb, ppp_over_ethernet_link_status_cb, &pcb->pppoe_sc) != ERR_OK) {
|
||||
pcb->open_flag = 0;
|
||||
@ -515,7 +518,7 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) {
|
||||
/*
|
||||
* Toss all non-LCP packets unless LCP is OPEN.
|
||||
*/
|
||||
if (protocol != PPP_LCP && lcp_fsm[0].state != OPENED) {
|
||||
if (protocol != PPP_LCP && pcb->lcp_fsm.state != OPENED) {
|
||||
dbglog("Discarded non-LCP packet when LCP not open");
|
||||
goto drop;
|
||||
}
|
||||
|
@ -47,7 +47,6 @@
|
||||
|
||||
#include "vj.h"
|
||||
|
||||
|
||||
/** PPP_INPROC_MULTITHREADED==1 call ppp_input using tcpip_callback().
|
||||
* Set this to 0 if pppos_input_proc is called inside tcpip_thread or with NO_SYS==1.
|
||||
* Default is 1 for NO_SYS==0 (multithreaded) and 0 for NO_SYS==1 (single-threaded).
|
||||
@ -89,6 +88,10 @@ typedef unsigned char u_char;
|
||||
typedef unsigned char bool;
|
||||
#endif
|
||||
|
||||
#include "fsm.h"
|
||||
#include "lcp.h"
|
||||
#include "ipcp.h"
|
||||
|
||||
|
||||
/*************************
|
||||
*** PUBLIC DEFINITIONS ***
|
||||
@ -391,6 +394,19 @@ typedef struct ppp_pcb_s {
|
||||
#if EAP_SUPPORT
|
||||
eap_state eap;
|
||||
#endif /* EAP_SUPPORT */
|
||||
|
||||
fsm lcp_fsm; /* LCP fsm structure */
|
||||
lcp_options lcp_wantoptions; /* Options that we want to request */
|
||||
lcp_options lcp_gotoptions; /* Options that peer ack'd */
|
||||
lcp_options lcp_allowoptions; /* Options we allow peer to request */
|
||||
lcp_options lcp_hisoptions; /* Options that we ack'd */
|
||||
|
||||
fsm ipcp_fsm; /* IPCP fsm structure */
|
||||
ipcp_options ipcp_wantoptions; /* Options that we want to request */
|
||||
ipcp_options ipcp_gotoptions; /* Options that peer ack'd */
|
||||
ipcp_options ipcp_allowoptions; /* Options we allow peer to request */
|
||||
ipcp_options ipcp_hisoptions; /* Options that we ack'd */
|
||||
|
||||
} ppp_pcb;
|
||||
|
||||
/************************
|
||||
|
@ -221,14 +221,7 @@ struct ppp_idle {
|
||||
};
|
||||
|
||||
/* FIXME: make endpoint discriminator optional */
|
||||
|
||||
/* An endpoint discriminator, used with multilink. */
|
||||
#define MAX_ENDP_LEN 20 /* maximum length of discriminator value */
|
||||
struct epdisc {
|
||||
unsigned char class;
|
||||
unsigned char length;
|
||||
unsigned char value[MAX_ENDP_LEN];
|
||||
};
|
||||
/* FIXME: moved temporarily to lcp.h */
|
||||
|
||||
/* values for epdisc.class */
|
||||
#define EPD_NULL 0 /* null discriminator, no data */
|
||||
|
Loading…
Reference in New Issue
Block a user