IPCP and LCP structures moved to ppp_pcb

This commit is contained in:
Sylvain Rochet 2012-06-16 02:13:50 +02:00
parent 19238a910c
commit 4b7e3af77c
9 changed files with 244 additions and 298 deletions

View File

@ -731,7 +731,7 @@ void link_established(ppp_pcb *pcb) {
#if PPP_SERVER #if PPP_SERVER
lcp_options *go = &lcp_gotoptions[pcb->unit]; lcp_options *go = &lcp_gotoptions[pcb->unit];
#endif /* #if PPP_SERVER */ #endif /* #if PPP_SERVER */
lcp_options *ho = &lcp_hisoptions[pcb->unit]; lcp_options *ho = &pcb->lcp_hisoptions;
int i; int i;
struct protent *protp; struct protent *protp;
@ -1444,8 +1444,8 @@ auth_check_options()
* to use for authenticating ourselves and/or the peer. * to use for authenticating ourselves and/or the peer.
*/ */
void auth_reset(ppp_pcb *pcb) { void auth_reset(ppp_pcb *pcb) {
lcp_options *go = &lcp_gotoptions[pcb->unit]; lcp_options *go = &pcb->lcp_gotoptions;
lcp_options *ao = &lcp_allowoptions[pcb->unit]; lcp_options *ao = &pcb->lcp_allowoptions;
if( pcb->settings.passwd[0] ) { if( pcb->settings.passwd[0] ) {

View File

@ -45,6 +45,9 @@
#include "lwip/opt.h" #include "lwip/opt.h"
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.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. * 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) */ extern int peer_mru[]; /* currently negotiated peer MRU (per unit) */
#endif /* FSM_H */
#endif /* PPP_SUPPORT */ #endif /* PPP_SUPPORT */

View File

@ -65,14 +65,11 @@
#include "ipcp.h" #include "ipcp.h"
/* global vars */ /* 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 */ 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 */ bool disable_defaultip = 0; /* Don't use hostname for default IP adrs */
#endif /* UNUSED */
bool noremoteip = 0; /* Let him have no IP address */ bool noremoteip = 0; /* Let him have no IP address */
#if 0 /* UNUSED */ #if 0 /* UNUSED */
@ -106,18 +103,16 @@ static char netmask_str[20]; /* string form of netmask value */
/* /*
* Callbacks for fsm code. (CI = Configuration Information) * Callbacks for fsm code. (CI = Configuration Information)
*/ */
static void ipcp_resetci (fsm *); /* Reset our CI */ static void ipcp_resetci(fsm *f); /* Reset our CI */
static int ipcp_cilen (fsm *); /* Return length of our CI */ static int ipcp_cilen(fsm *f); /* Return length of our CI */
static void ipcp_addci (fsm *, u_char *, int *); /* Add our CI */ static void ipcp_addci(fsm *f, u_char *ucp, int *lenp); /* Add our CI */
static int ipcp_ackci (fsm *, u_char *, int); /* Peer ack'd our CI */ static int ipcp_ackci(fsm *f, u_char *p, int len); /* Peer ack'd our CI */
static int ipcp_nakci (fsm *, u_char *, int, int);/* Peer nak'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 *, u_char *, int); /* Peer rej'd our CI */ static int ipcp_rejci(fsm *f, u_char *p, int len); /* Peer rej'd our CI */
static int ipcp_reqci (fsm *, u_char *, int *, int); /* Rcv CI */ static int ipcp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree); /* Rcv CI */
static void ipcp_up (fsm *); /* We're UP */ static void ipcp_up(fsm *f); /* We're UP */
static void ipcp_down (fsm *); /* We're DOWN */ static void ipcp_down(fsm *f); /* We're DOWN */
static void ipcp_finished (fsm *); /* Don't need lower layer */ static void ipcp_finished(fsm *f); /* Don't need lower layer */
fsm ipcp_fsm[NUM_PPP]; /* IPCP fsm structure */
static fsm_callbacks ipcp_callbacks = { /* IPCP callback routines */ static fsm_callbacks ipcp_callbacks = { /* IPCP callback routines */
ipcp_resetci, /* Reset our Configuration Information */ ipcp_resetci, /* Reset our Configuration Information */
@ -254,16 +249,16 @@ static option_t ipcp_option_list[] = {
/* /*
* Protocol entry points from main code. * Protocol entry points from main code.
*/ */
static void ipcp_init (int); static void ipcp_init(int unit);
static void ipcp_open (int); static void ipcp_open(int unit);
static void ipcp_close (int, char *); static void ipcp_close(int unit, char *reason);
static void ipcp_lowerup (int); static void ipcp_lowerup(int unit);
static void ipcp_lowerdown (int); static void ipcp_lowerdown(int unit);
static void ipcp_input (int, u_char *, int); static void ipcp_input(int unit, u_char *p, int len);
static void ipcp_protrej (int); static void ipcp_protrej(int unit);
#if PRINTPKT_SUPPORT #if PRINTPKT_SUPPORT
static int ipcp_printpkt (u_char *, int, static int ipcp_printpkt(u_char *p, int plen,
void (*) (void *, char *, ...), void *); void (*printer) (void *, char *, ...), void *arg);
#endif /* PRINTPKT_SUPPORT */ #endif /* PRINTPKT_SUPPORT */
#if PPP_OPTIONS #if PPP_OPTIONS
static void ip_check_options (void); static void ip_check_options (void);
@ -589,18 +584,17 @@ parse_dotted_ip(p, vp)
/* /*
* ipcp_init - Initialize IPCP. * ipcp_init - Initialize IPCP.
*/ */
static void static void ipcp_init(int unit) {
ipcp_init(unit) ppp_pcb *pcb = &ppp_pcb_list[unit];
int unit; fsm *f = &pcb->ipcp_fsm;
{
fsm *f = &ipcp_fsm[unit]; ipcp_options *wo = &pcb->ipcp_wantoptions;
ipcp_options *wo = &ipcp_wantoptions[unit]; ipcp_options *ao = &pcb->ipcp_allowoptions;
ipcp_options *ao = &ipcp_allowoptions[unit];
f->unit = unit; f->unit = unit;
f->protocol = PPP_IPCP; f->protocol = PPP_IPCP;
f->callbacks = &ipcp_callbacks; f->callbacks = &ipcp_callbacks;
fsm_init(&ipcp_fsm[unit]); fsm_init(f);
/* /*
* Some 3G modems use repeated IPCP NAKs as a way of stalling * 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. * ipcp_open - IPCP is allowed to come up.
*/ */
static void static void ipcp_open(int unit) {
ipcp_open(unit) ppp_pcb *pcb = &ppp_pcb_list[unit];
int unit; fsm *f = &pcb->ipcp_fsm;
{ fsm_open(f);
fsm_open(&ipcp_fsm[unit]);
ipcp_is_open = 1; ipcp_is_open = 1;
} }
@ -656,47 +649,40 @@ ipcp_open(unit)
/* /*
* ipcp_close - Take IPCP down. * ipcp_close - Take IPCP down.
*/ */
static void static void ipcp_close(int unit, char *reason) {
ipcp_close(unit, reason) ppp_pcb *pcb = &ppp_pcb_list[unit];
int unit; fsm *f = &pcb->ipcp_fsm;
char *reason; fsm_close(f, reason);
{
fsm_close(&ipcp_fsm[unit], reason);
} }
/* /*
* ipcp_lowerup - The lower layer is up. * ipcp_lowerup - The lower layer is up.
*/ */
static void static void ipcp_lowerup(int unit) {
ipcp_lowerup(unit) ppp_pcb *pcb = &ppp_pcb_list[unit];
int unit; fsm *f = &pcb->ipcp_fsm;
{ fsm_lowerup(f);
fsm_lowerup(&ipcp_fsm[unit]);
} }
/* /*
* ipcp_lowerdown - The lower layer is down. * ipcp_lowerdown - The lower layer is down.
*/ */
static void static void ipcp_lowerdown(int unit) {
ipcp_lowerdown(unit) ppp_pcb *pcb = &ppp_pcb_list[unit];
int unit; fsm *f = &pcb->ipcp_fsm;
{ fsm_lowerdown(f);
fsm_lowerdown(&ipcp_fsm[unit]);
} }
/* /*
* ipcp_input - Input IPCP packet. * ipcp_input - Input IPCP packet.
*/ */
static void static void ipcp_input(int unit, u_char *p, int len) {
ipcp_input(unit, p, len) ppp_pcb *pcb = &ppp_pcb_list[unit];
int unit; fsm *f = &pcb->ipcp_fsm;
u_char *p; fsm_input(f, p, len);
int len;
{
fsm_input(&ipcp_fsm[unit], p, len);
} }
@ -705,11 +691,10 @@ ipcp_input(unit, p, len)
* *
* Pretend the lower layer went down, so we shut up. * Pretend the lower layer went down, so we shut up.
*/ */
static void static void ipcp_protrej(int unit) {
ipcp_protrej(unit) ppp_pcb *pcb = &ppp_pcb_list[unit];
int unit; fsm *f = &pcb->ipcp_fsm;
{ fsm_lowerdown(f);
fsm_lowerdown(&ipcp_fsm[unit]);
} }
@ -717,14 +702,11 @@ ipcp_protrej(unit)
* ipcp_resetci - Reset our CI. * ipcp_resetci - Reset our CI.
* Called by fsm_sconfreq, Send Configure Request. * Called by fsm_sconfreq, Send Configure Request.
*/ */
static void static void ipcp_resetci(fsm *f) {
ipcp_resetci(f) ppp_pcb *pcb = &ppp_pcb_list[f->unit];
fsm *f; ipcp_options *wo = &pcb->ipcp_wantoptions;
{ ipcp_options *go = &pcb->ipcp_gotoptions;
ppp_pcb *pc = &ppp_pcb_list[f->unit]; ipcp_options *ao = &pcb->ipcp_allowoptions;
ipcp_options *wo = &ipcp_wantoptions[f->unit];
ipcp_options *go = &ipcp_gotoptions[f->unit];
ipcp_options *ao = &ipcp_allowoptions[f->unit];
wo->req_addr = (wo->neg_addr || wo->old_addrs) && wo->req_addr = (wo->neg_addr || wo->old_addrs) &&
(ao->neg_addr || ao->old_addrs); (ao->neg_addr || ao->old_addrs);
@ -732,8 +714,8 @@ ipcp_resetci(f)
wo->accept_local = 1; wo->accept_local = 1;
if (wo->hisaddr == 0) if (wo->hisaddr == 0)
wo->accept_remote = 1; wo->accept_remote = 1;
wo->req_dns1 = pc->settings.usepeerdns; /* Request DNS addresses from the peer */ wo->req_dns1 = pcb->settings.usepeerdns; /* Request DNS addresses from the peer */
wo->req_dns2 = pc->settings.usepeerdns; wo->req_dns2 = pcb->settings.usepeerdns;
*go = *wo; *go = *wo;
if (!ask_for_local) if (!ask_for_local)
go->ouraddr = 0; go->ouraddr = 0;
@ -745,7 +727,7 @@ ipcp_resetci(f)
} }
} }
#endif /* UNUSED */ #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. * ipcp_cilen - Return length of our CI.
* Called by fsm_sconfreq, Send Configure Request. * Called by fsm_sconfreq, Send Configure Request.
*/ */
static int static int ipcp_cilen(fsm *f) {
ipcp_cilen(f) ppp_pcb *pcb = &ppp_pcb_list[f->unit];
fsm *f; ipcp_options *go = &pcb->ipcp_gotoptions;
{ ipcp_options *wo = &pcb->ipcp_wantoptions;
ipcp_options *go = &ipcp_gotoptions[f->unit]; ipcp_options *ho = &pcb->ipcp_hisoptions;
ipcp_options *wo = &ipcp_wantoptions[f->unit];
ipcp_options *ho = &ipcp_hisoptions[f->unit];
#define LENCIADDRS(neg) (neg ? CILEN_ADDRS : 0) #define LENCIADDRS(neg) (neg ? CILEN_ADDRS : 0)
#define LENCIVJ(neg, old) (neg ? (old? CILEN_COMPRESS : CILEN_VJ) : 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. * ipcp_addci - Add our desired CIs to a packet.
* Called by fsm_sconfreq, Send Configure Request. * Called by fsm_sconfreq, Send Configure Request.
*/ */
static void static void ipcp_addci(fsm *f, u_char *ucp, int *lenp) {
ipcp_addci(f, ucp, lenp) ppp_pcb *pcb = &ppp_pcb_list[f->unit];
fsm *f; ipcp_options *go = &pcb->ipcp_gotoptions;
u_char *ucp;
int *lenp;
{
ipcp_options *go = &ipcp_gotoptions[f->unit];
int len = *lenp; int len = *lenp;
#define ADDCIADDRS(opt, neg, val1, val2) \ #define ADDCIADDRS(opt, neg, val1, val2) \
@ -904,13 +880,9 @@ ipcp_addci(f, ucp, lenp)
* 0 - Ack was bad. * 0 - Ack was bad.
* 1 - Ack was good. * 1 - Ack was good.
*/ */
static int static int ipcp_ackci(fsm *f, u_char *p, int len) {
ipcp_ackci(f, p, len) ppp_pcb *pcb = &ppp_pcb_list[f->unit];
fsm *f; ipcp_options *go = &pcb->ipcp_gotoptions;
u_char *p;
int len;
{
ipcp_options *go = &ipcp_gotoptions[f->unit];
u_short cilen, citype, cishort; u_short cilen, citype, cishort;
u_int32_t cilong; u_int32_t cilong;
u_char cimaxslotindex, cicflag; u_char cimaxslotindex, cicflag;
@ -1029,14 +1001,9 @@ bad:
* 0 - Nak was bad. * 0 - Nak was bad.
* 1 - Nak was good. * 1 - Nak was good.
*/ */
static int static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) {
ipcp_nakci(f, p, len, treat_as_reject) ppp_pcb *pcb = &ppp_pcb_list[f->unit];
fsm *f; ipcp_options *go = &pcb->ipcp_gotoptions;
u_char *p;
int len;
int treat_as_reject;
{
ipcp_options *go = &ipcp_gotoptions[f->unit];
u_char cimaxslotindex, cicflag; u_char cimaxslotindex, cicflag;
u_char citype, cilen, *next; u_char citype, cilen, *next;
u_short cishort; u_short cishort;
@ -1278,13 +1245,9 @@ bad:
* ipcp_rejci - Reject some of our CIs. * ipcp_rejci - Reject some of our CIs.
* Callback from fsm_rconfnakrej. * Callback from fsm_rconfnakrej.
*/ */
static int static int ipcp_rejci(fsm *f, u_char *p, int len) {
ipcp_rejci(f, p, len) ppp_pcb *pcb = &ppp_pcb_list[f->unit];
fsm *f; ipcp_options *go = &pcb->ipcp_gotoptions;
u_char *p;
int len;
{
ipcp_options *go = &ipcp_gotoptions[f->unit];
u_char cimaxslotindex, ciflag, cilen; u_char cimaxslotindex, ciflag, cilen;
u_short cishort; u_short cishort;
u_int32_t cilong; u_int32_t cilong;
@ -1428,17 +1391,15 @@ bad:
* Returns: CONFACK, CONFNAK or CONFREJ and input packet modified * Returns: CONFACK, CONFNAK or CONFREJ and input packet modified
* appropriately. If reject_if_disagree is non-zero, doesn't return * appropriately. If reject_if_disagree is non-zero, doesn't return
* CONFNAK; returns CONFREJ if it can't return CONFACK. * CONFNAK; returns CONFREJ if it can't return CONFACK.
*
* inp = Requested CIs
* len = Length of requested CIs
*/ */
static int static int ipcp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) {
ipcp_reqci(f, inp, len, reject_if_disagree) ppp_pcb *pcb = &ppp_pcb_list[f->unit];
fsm *f; ipcp_options *wo = &pcb->ipcp_wantoptions;
u_char *inp; /* Requested CIs */ ipcp_options *ho = &pcb->ipcp_hisoptions;
int *len; /* Length of requested CIs */ ipcp_options *ao = &pcb->ipcp_allowoptions;
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];
u_char *cip, *next; /* Pointer to current and next CIs */ u_char *cip, *next; /* Pointer to current and next CIs */
u_short cilen, citype; /* Parsed len, type */ u_short cilen, citype; /* Parsed len, type */
u_short cishort; /* Parsed short value */ u_short cishort; /* Parsed short value */
@ -1797,15 +1758,12 @@ ip_demand_conf(u)
* *
* Configure the IP network interface appropriately and bring it up. * Configure the IP network interface appropriately and bring it up.
*/ */
static void static void ipcp_up(fsm *f) {
ipcp_up(f)
fsm *f;
{
ppp_pcb *pcb = &ppp_pcb_list[f->unit]; ppp_pcb *pcb = &ppp_pcb_list[f->unit];
u_int32_t mask; u_int32_t mask;
ipcp_options *ho = &ipcp_hisoptions[f->unit]; ipcp_options *ho = &pcb->ipcp_hisoptions;
ipcp_options *go = &ipcp_gotoptions[f->unit]; ipcp_options *go = &pcb->ipcp_gotoptions;
ipcp_options *wo = &ipcp_wantoptions[f->unit]; ipcp_options *wo = &pcb->ipcp_wantoptions;
IPCPDEBUG(("ipcp: up")); IPCPDEBUG(("ipcp: up"));
@ -1957,17 +1915,17 @@ ipcp_up(f)
sifnpmode(pcb, PPP_IP, NPMODE_PASS); sifnpmode(pcb, PPP_IP, NPMODE_PASS);
/* assign a default route through the interface if required */ /* 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, if (sifdefaultroute(pcb, go->ouraddr, ho->hisaddr,
wo->replace_default_route)) wo->replace_default_route))
default_route_set[f->unit] = 1; default_route_set[f->unit] = 1;
/* Make a proxy ARP entry if requested. */ /* 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)) if (sifproxyarp(pcb, ho->hisaddr))
proxy_arp_set[f->unit] = 1; proxy_arp_set[f->unit] = 1;
ipcp_wantoptions[0].ouraddr = go->ouraddr; wo->ouraddr = go->ouraddr;
notice("local IP address %I", go->ouraddr); notice("local IP address %I", go->ouraddr);
if (ho->hisaddr != 0) if (ho->hisaddr != 0)
@ -2001,11 +1959,11 @@ ipcp_up(f)
* Take the IP network interface down, clear its addresses * Take the IP network interface down, clear its addresses
* and delete routes through it. * and delete routes through it.
*/ */
static void static void ipcp_down(fsm *f) {
ipcp_down(f)
fsm *f;
{
ppp_pcb *pcb = &ppp_pcb_list[f->unit]; ppp_pcb *pcb = &ppp_pcb_list[f->unit];
ipcp_options *ho = &pcb->ipcp_hisoptions;
ipcp_options *go = &pcb->ipcp_gotoptions;
IPCPDEBUG(("ipcp: down")); IPCPDEBUG(("ipcp: down"));
#if PPP_STATS_SUPPORT #if PPP_STATS_SUPPORT
/* XXX a bit IPv4-centric here, we only need to get the stats /* 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); sifnpmode(pcb, PPP_IP, NPMODE_DROP);
sifdown(pcb); sifdown(pcb);
ipcp_clear_addrs(f->unit, ipcp_gotoptions[f->unit].ouraddr, ipcp_clear_addrs(f->unit, go->ouraddr,
ipcp_hisoptions[f->unit].hisaddr, 0); ho->hisaddr, 0);
cdns(pcb, ipcp_gotoptions[f->unit].dnsaddr[0], ipcp_gotoptions[f->unit].dnsaddr[1]); 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. * ipcp_finished - possibly shut down the lower layers.
*/ */
static void static void ipcp_finished(fsm *f) {
ipcp_finished(f)
fsm *f;
{
ppp_pcb *pcb = &ppp_pcb_list[f->unit]; ppp_pcb *pcb = &ppp_pcb_list[f->unit];
if (ipcp_is_open) { if (ipcp_is_open) {
ipcp_is_open = 0; ipcp_is_open = 0;
@ -2116,13 +2071,8 @@ static char *ipcp_codenames[] = {
"TermReq", "TermAck", "CodeRej" "TermReq", "TermAck", "CodeRej"
}; };
static int static int ipcp_printpkt(u_char *p, int plen,
ipcp_printpkt(p, plen, printer, arg) void (*printer) (void *, char *, ...), void *arg) {
u_char *p;
int plen;
void (*printer) (void *, char *, ...);
void *arg;
{
int code, id, len, olen; int code, id, len, olen;
u_char *pstart, *optend; u_char *pstart, *optend;
u_short cishort; u_short cishort;

View File

@ -45,6 +45,9 @@
#include "lwip/opt.h" #include "lwip/opt.h"
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ #if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
#ifndef IPCP_H
#define IPCP_H
/* /*
* Options. * Options.
*/ */
@ -89,16 +92,11 @@ typedef struct ipcp_options {
u_int32_t winsaddr[2]; /* Primary and secondary MS WINS entries */ u_int32_t winsaddr[2]; /* Primary and secondary MS WINS entries */
} ipcp_options; } 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 */ #if 0 /* UNUSED, already defined by lwIP */
char *ip_ntoa (u_int32_t); char *ip_ntoa (u_int32_t);
#endif /* UNUSED, already defined by lwIP */ #endif /* UNUSED, already defined by lwIP */
extern struct protent ipcp_protent; extern struct protent ipcp_protent;
#endif /* IPCP_H */
#endif /* PPP_SUPPORT */ #endif /* PPP_SUPPORT */

View File

@ -70,7 +70,7 @@
/* steal a bit in fsm flags word */ /* steal a bit in fsm flags word */
#define DELAYED_UP 0x100 #define DELAYED_UP 0x100
static void lcp_delayed_up (void *); static void lcp_delayed_up(void *arg);
/* /*
* LCP-related command-line options. * LCP-related command-line options.
@ -209,11 +209,6 @@ static option_t lcp_option_list[] = {
#endif /* PPP_OPTIONS */ #endif /* PPP_OPTIONS */
/* global vars */ /* 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 #if PPPOS_SUPPORT
ext_accm xmit_accm[NUM_PPP]; /* extended transmit ACCM */ ext_accm xmit_accm[NUM_PPP]; /* extended transmit ACCM */
#endif /* PPPOS_SUPPORT */ #endif /* PPPOS_SUPPORT */
@ -246,8 +241,8 @@ static void lcp_rprotrej (fsm *, u_char *, int);
* routines to send LCP echos to peer * routines to send LCP echos to peer
*/ */
static void lcp_echo_lowerup (int); static void lcp_echo_lowerup(int unit);
static void lcp_echo_lowerdown (int); static void lcp_echo_lowerdown(int unit);
static void LcpEchoTimeout (void *); static void LcpEchoTimeout (void *);
static void lcp_received_echo_reply (fsm *, int, u_char *, int); static void lcp_received_echo_reply (fsm *, int, u_char *, int);
static void LcpSendEchoRequest (fsm *); static void LcpSendEchoRequest (fsm *);
@ -277,12 +272,12 @@ static fsm_callbacks lcp_callbacks = { /* LCP callback routines */
* Some of these are called directly. * Some of these are called directly.
*/ */
static void lcp_init (int); static void lcp_init(int unit);
static void lcp_input (int, u_char *, int); static void lcp_input(int unit, u_char *p, int len);
static void lcp_protrej (int); static void lcp_protrej(int unit);
#if PRINTPKT_SUPPORT #if PRINTPKT_SUPPORT
static int lcp_printpkt (u_char *, int, static int lcp_printpkt(u_char *p, int plen,
void (*) (void *, char *, ...), void *); void (*printer) (void *, char *, ...), void *arg);
#endif /* PRINTPKT_SUPPORT */ #endif /* PRINTPKT_SUPPORT */
struct protent lcp_protent = { struct protent lcp_protent = {
@ -374,14 +369,11 @@ printendpoint(opt, printer, arg)
/* /*
* lcp_init - Initialize LCP. * lcp_init - Initialize LCP.
*/ */
static void static void lcp_init(int unit) {
lcp_init(unit)
int unit;
{
ppp_pcb *pcb = &ppp_pcb_list[unit]; ppp_pcb *pcb = &ppp_pcb_list[unit];
fsm *f = &lcp_fsm[unit]; fsm *f = &pcb->lcp_fsm;
lcp_options *wo = &lcp_wantoptions[unit]; lcp_options *wo = &pcb->lcp_wantoptions;
lcp_options *ao = &lcp_allowoptions[unit]; lcp_options *ao = &pcb->lcp_allowoptions;
f->unit = unit; f->unit = unit;
f->protocol = PPP_LCP; f->protocol = PPP_LCP;
@ -439,12 +431,10 @@ lcp_init(unit)
/* /*
* lcp_open - LCP is allowed to come up. * lcp_open - LCP is allowed to come up.
*/ */
void void lcp_open(int unit) {
lcp_open(unit) ppp_pcb *pcb = &ppp_pcb_list[unit];
int unit; fsm *f = &pcb->lcp_fsm;
{ lcp_options *wo = &pcb->lcp_wantoptions;
fsm *f = &lcp_fsm[unit];
lcp_options *wo = &lcp_wantoptions[unit];
f->flags &= ~(OPT_PASSIVE | OPT_SILENT); f->flags &= ~(OPT_PASSIVE | OPT_SILENT);
if (wo->passive) if (wo->passive)
@ -458,13 +448,9 @@ lcp_open(unit)
/* /*
* lcp_close - Take LCP down. * lcp_close - Take LCP down.
*/ */
void void lcp_close(int unit, char *reason) {
lcp_close(unit, reason)
int unit;
char *reason;
{
ppp_pcb *pcb = &ppp_pcb_list[unit]; ppp_pcb *pcb = &ppp_pcb_list[unit];
fsm *f = &lcp_fsm[unit]; fsm *f = &pcb->lcp_fsm;
int oldstate; int oldstate;
if (pcb->phase != PHASE_DEAD && pcb->phase != PHASE_MASTER) if (pcb->phase != PHASE_DEAD && pcb->phase != PHASE_MASTER)
@ -494,13 +480,13 @@ lcp_close(unit, reason)
/* /*
* lcp_lowerup - The lower layer is up. * lcp_lowerup - The lower layer is up.
*/ */
void void lcp_lowerup(int unit) {
lcp_lowerup(unit)
int unit;
{
ppp_pcb *pcb = &ppp_pcb_list[unit]; ppp_pcb *pcb = &ppp_pcb_list[unit];
lcp_options *wo = &lcp_wantoptions[unit]; lcp_options *wo = &pcb->lcp_wantoptions;
fsm *f = &lcp_fsm[unit]; #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, * Don't use A/C or protocol compression on transmission,
* but accept A/C and protocol compressed packets * but accept A/C and protocol compressed packets
@ -515,8 +501,8 @@ lcp_lowerup(unit)
return; return;
peer_mru[unit] = PPP_MRU; peer_mru[unit] = PPP_MRU;
#if PPPOS_SUPPORT #if PPPOS_SUPPORT
lcp_allowoptions[unit].asyncmap = (u_long)xmit_accm[unit][0] ao->asyncmap = (u_long)xmit_accm[unit][0]
| ((u_long)xmit_accm[unit][1] << 8) | ((u_long)xmit_accm[unit][1] << 8)
| ((u_long)xmit_accm[unit][2] << 16) | ((u_long)xmit_accm[unit][2] << 16)
| ((u_long)xmit_accm[unit][3] << 24); | ((u_long)xmit_accm[unit][3] << 24);
@ -538,27 +524,22 @@ lcp_lowerup(unit)
/* /*
* lcp_lowerdown - The lower layer is down. * lcp_lowerdown - The lower layer is down.
*/ */
void void lcp_lowerdown(int unit) {
lcp_lowerdown(unit) ppp_pcb *pcb = &ppp_pcb_list[unit];
int unit; fsm *f = &pcb->lcp_fsm;
{
fsm *f = &lcp_fsm[unit];
if (f->flags & DELAYED_UP) { if (f->flags & DELAYED_UP) {
f->flags &= ~DELAYED_UP; f->flags &= ~DELAYED_UP;
UNTIMEOUT(lcp_delayed_up, f); UNTIMEOUT(lcp_delayed_up, f);
} else } else
fsm_lowerdown(&lcp_fsm[unit]); fsm_lowerdown(f);
} }
/* /*
* lcp_delayed_up - Bring the lower layer up now. * lcp_delayed_up - Bring the lower layer up now.
*/ */
static void static void lcp_delayed_up(void *arg) {
lcp_delayed_up(arg)
void *arg;
{
fsm *f = arg; fsm *f = arg;
if (f->flags & DELAYED_UP) { if (f->flags & DELAYED_UP) {
@ -571,13 +552,9 @@ lcp_delayed_up(arg)
/* /*
* lcp_input - Input LCP packet. * lcp_input - Input LCP packet.
*/ */
static void static void lcp_input(int unit, u_char *p, int len) {
lcp_input(unit, p, len) ppp_pcb *pcb = &ppp_pcb_list[unit];
int unit; fsm *f = &pcb->lcp_fsm;
u_char *p;
int len;
{
fsm *f = &lcp_fsm[unit];
if (f->flags & DELAYED_UP) { if (f->flags & DELAYED_UP) {
f->flags &= ~DELAYED_UP; f->flags &= ~DELAYED_UP;
@ -597,6 +574,8 @@ lcp_extcode(f, code, id, inp, len)
u_char *inp; u_char *inp;
int len; int len;
{ {
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
lcp_options *go = &pcb->lcp_gotoptions;
u_char *magp; u_char *magp;
switch( code ){ switch( code ){
@ -608,7 +587,7 @@ lcp_extcode(f, code, id, inp, len)
if (f->state != OPENED) if (f->state != OPENED)
break; break;
magp = inp; magp = inp;
PUTLONG(lcp_gotoptions[f->unit].magicnumber, magp); PUTLONG(go->magicnumber, magp);
fsm_sdata(f, ECHOREP, id, inp, len); fsm_sdata(f, ECHOREP, id, inp, len);
break; break;
@ -696,27 +675,22 @@ lcp_rprotrej(f, inp, len)
* lcp_protrej - A Protocol-Reject was received. * lcp_protrej - A Protocol-Reject was received.
*/ */
/*ARGSUSED*/ /*ARGSUSED*/
static void static void lcp_protrej(int unit) {
lcp_protrej(unit) ppp_pcb *pcb = &ppp_pcb_list[unit];
int unit;
{
/* /*
* Can't reject LCP! * Can't reject LCP!
*/ */
error("Received Protocol-Reject for 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. * lcp_sprotrej - Send a Protocol-Reject for some protocol.
*/ */
void void lcp_sprotrej(int unit, u_char *p, int len) {
lcp_sprotrej(unit, p, len) ppp_pcb *pcb = &ppp_pcb_list[unit];
int unit; fsm *f = &pcb->lcp_fsm;
u_char *p;
int len;
{
/* /*
* Send back the protocol and the information field of the * Send back the protocol and the information field of the
* rejected packet. We only get here if LCP is in the OPENED state. * rejected packet. We only get here if LCP is in the OPENED state.
@ -724,7 +698,7 @@ lcp_sprotrej(unit, p, len)
p += 2; p += 2;
len -= 2; len -= 2;
fsm_sdata(&lcp_fsm[unit], PROTREJ, ++lcp_fsm[unit].id, fsm_sdata(f, PROTREJ, ++f->id,
p, len); p, len);
} }
@ -737,9 +711,9 @@ lcp_resetci(f)
fsm *f; fsm *f;
{ {
ppp_pcb *pcb = &ppp_pcb_list[f->unit]; ppp_pcb *pcb = &ppp_pcb_list[f->unit];
lcp_options *wo = &lcp_wantoptions[f->unit]; lcp_options *wo = &pcb->lcp_wantoptions;
lcp_options *go = &lcp_gotoptions[f->unit]; lcp_options *go = &pcb->lcp_gotoptions;
lcp_options *ao = &lcp_allowoptions[f->unit]; lcp_options *ao = &pcb->lcp_allowoptions;
wo->magicnumber = magic(); wo->magicnumber = magic();
wo->numloops = 0; wo->numloops = 0;
@ -767,7 +741,8 @@ static int
lcp_cilen(f) lcp_cilen(f)
fsm *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) #define LENCIVOID(neg) ((neg) ? CILEN_VOID : 0)
#if CHAP_SUPPORT #if CHAP_SUPPORT
@ -833,7 +808,8 @@ lcp_addci(f, ucp, lenp)
u_char *ucp; u_char *ucp;
int *lenp; 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; u_char *start_ucp = ucp;
#define ADDCIVOID(opt, neg) \ #define ADDCIVOID(opt, neg) \
@ -948,7 +924,8 @@ lcp_ackci(f, p, len)
u_char *p; u_char *p;
int len; 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_char cilen, citype, cichar;
u_short cishort; u_short cishort;
u_int32_t cilong; u_int32_t cilong;
@ -1131,9 +1108,9 @@ lcp_nakci(f, p, len, treat_as_reject)
int len; int len;
int treat_as_reject; int treat_as_reject;
{ {
ppp_pcb *pc = &ppp_pcb_list[f->unit]; ppp_pcb *pcb = &ppp_pcb_list[f->unit];
lcp_options *go = &lcp_gotoptions[f->unit]; lcp_options *go = &pcb->lcp_gotoptions;
lcp_options *wo = &lcp_wantoptions[f->unit]; lcp_options *wo = &pcb->lcp_wantoptions;
u_char citype, cichar, *next; u_char citype, cichar, *next;
u_short cishort; u_short cishort;
u_int32_t cilong; u_int32_t cilong;
@ -1558,7 +1535,7 @@ lcp_nakci(f, p, len, treat_as_reject)
if (looped_back) { if (looped_back) {
if (++try.numloops >= lcp_loopbackfail) { if (++try.numloops >= lcp_loopbackfail) {
notice("Serial line is looped back."); notice("Serial line is looped back.");
pc->status = EXIT_LOOPBACK; pcb->status = EXIT_LOOPBACK;
lcp_close(f->unit, "Loopback detected"); lcp_close(f->unit, "Loopback detected");
} }
} else } else
@ -1589,7 +1566,8 @@ lcp_rejci(f, p, len)
u_char *p; u_char *p;
int len; 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_char cichar;
u_short cishort; u_short cishort;
u_int32_t cilong; u_int32_t cilong;
@ -1820,9 +1798,10 @@ lcp_reqci(f, inp, lenp, reject_if_disagree)
int *lenp; /* Length of requested CIs */ int *lenp; /* Length of requested CIs */
int reject_if_disagree; int reject_if_disagree;
{ {
lcp_options *go = &lcp_gotoptions[f->unit]; ppp_pcb *pcb = &ppp_pcb_list[f->unit];
lcp_options *ho = &lcp_hisoptions[f->unit]; lcp_options *go = &pcb->lcp_gotoptions;
lcp_options *ao = &lcp_allowoptions[f->unit]; lcp_options *ho = &pcb->lcp_hisoptions;
lcp_options *ao = &pcb->lcp_allowoptions;
u_char *cip, *next; /* Pointer to current and next CIs */ u_char *cip, *next; /* Pointer to current and next CIs */
int cilen, citype, cichar; /* Parsed len, type, char value */ int cilen, citype, cichar; /* Parsed len, type, char value */
u_short cishort; /* Parsed short value */ u_short cishort; /* Parsed short value */
@ -2281,10 +2260,10 @@ lcp_up(f)
fsm *f; fsm *f;
{ {
ppp_pcb *pcb = &ppp_pcb_list[f->unit]; ppp_pcb *pcb = &ppp_pcb_list[f->unit];
lcp_options *wo = &lcp_wantoptions[f->unit]; lcp_options *wo = &pcb->lcp_wantoptions;
lcp_options *ho = &lcp_hisoptions[f->unit]; lcp_options *ho = &pcb->lcp_hisoptions;
lcp_options *go = &lcp_gotoptions[f->unit]; lcp_options *go = &pcb->lcp_gotoptions;
lcp_options *ao = &lcp_allowoptions[f->unit]; lcp_options *ao = &pcb->lcp_allowoptions;
int mtu, mru; int mtu, mru;
if (!go->neg_magicnumber) if (!go->neg_magicnumber)
@ -2333,7 +2312,7 @@ lcp_down(f)
fsm *f; fsm *f;
{ {
ppp_pcb *pcb = &ppp_pcb_list[f->unit]; 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); lcp_echo_lowerdown(f->unit);
@ -2376,13 +2355,8 @@ static char *lcp_codenames[] = {
"TimeRem" "TimeRem"
}; };
static int static int lcp_printpkt(u_char *p, int plen,
lcp_printpkt(p, plen, printer, arg) void (*printer) (void *, char *, ...), void *arg) {
u_char *p;
int plen;
void (*printer) (void *, char *, ...);
void *arg;
{
int code, id, len, olen, i; int code, id, len, olen, i;
u_char *pstart, *optend; u_char *pstart, *optend;
u_short cishort; u_short cishort;
@ -2689,6 +2663,8 @@ lcp_received_echo_reply (f, id, inp, len)
u_char *inp; u_char *inp;
int len; int len;
{ {
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
lcp_options *go = &pcb->lcp_gotoptions;
u_int32_t magic; u_int32_t magic;
/* Check the magic number - don't count replies from ourselves. */ /* Check the magic number - don't count replies from ourselves. */
@ -2697,8 +2673,8 @@ lcp_received_echo_reply (f, id, inp, len)
return; return;
} }
GETLONG(magic, inp); GETLONG(magic, inp);
if (lcp_gotoptions[f->unit].neg_magicnumber if (go->neg_magicnumber
&& magic == lcp_gotoptions[f->unit].magicnumber) { && magic == go->magicnumber) {
warn("appear to have received our own echo-reply!"); warn("appear to have received our own echo-reply!");
return; return;
} }
@ -2715,6 +2691,8 @@ static void
LcpSendEchoRequest (f) LcpSendEchoRequest (f)
fsm *f; fsm *f;
{ {
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
lcp_options *go = &pcb->lcp_gotoptions;
u_int32_t lcp_magic; u_int32_t lcp_magic;
u_char pkt[4], *pktp; u_char pkt[4], *pktp;
@ -2752,7 +2730,7 @@ LcpSendEchoRequest (f)
* Make and send the echo request frame. * Make and send the echo request frame.
*/ */
if (f->state == OPENED) { if (f->state == OPENED) {
lcp_magic = lcp_gotoptions[f->unit].magicnumber; lcp_magic = go->magicnumber;
pktp = pkt; pktp = pkt;
PUTLONG(lcp_magic, pktp); PUTLONG(lcp_magic, pktp);
fsm_sdata(f, ECHOREQ, lcp_echo_number++ & 0xFF, pkt, pktp - pkt); 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 * lcp_echo_lowerup - Start the timer for the LCP frame
*/ */
static void static void lcp_echo_lowerup(int unit) {
lcp_echo_lowerup (unit) ppp_pcb *pcb = &ppp_pcb_list[unit];
int unit; fsm *f = &pcb->lcp_fsm;
{
fsm *f = &lcp_fsm[unit];
/* Clear the parameters for generating echo frames */ /* Clear the parameters for generating echo frames */
lcp_echos_pending = 0; lcp_echos_pending = 0;
@ -2784,11 +2760,9 @@ lcp_echo_lowerup (unit)
* lcp_echo_lowerdown - Stop the timer for the LCP frame * lcp_echo_lowerdown - Stop the timer for the LCP frame
*/ */
static void static void lcp_echo_lowerdown(int unit) {
lcp_echo_lowerdown (unit) ppp_pcb *pcb = &ppp_pcb_list[unit];
int unit; fsm *f = &pcb->lcp_fsm;
{
fsm *f = &lcp_fsm[unit];
if (lcp_echo_timer_running != 0) { if (lcp_echo_timer_running != 0) {
UNTIMEOUT (LcpEchoTimeout, f); UNTIMEOUT (LcpEchoTimeout, f);

View File

@ -45,6 +45,9 @@
#include "lwip/opt.h" #include "lwip/opt.h"
#if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */ #if PPP_SUPPORT /* don't build if not configured for use in lwipopts.h */
#ifndef LCP_H
#define LCP_H
/* /*
* Options. * Options.
*/ */
@ -85,6 +88,15 @@
/* Value used as data for CI_CALLBACK option */ /* Value used as data for CI_CALLBACK option */
#define CBCP_OPT 6 /* Use callback control protocol */ #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. * The state of options is described by an lcp_options structure.
*/ */
@ -127,11 +139,6 @@ typedef struct lcp_options {
struct epdisc endpoint; /* endpoint discriminator */ struct epdisc endpoint; /* endpoint discriminator */
} lcp_options; } 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 #if PPPOS_SUPPORT
extern ext_accm xmit_accm[]; extern ext_accm xmit_accm[];
#endif /* #if PPPOS_SUPPORT */ #endif /* #if PPPOS_SUPPORT */
@ -140,11 +147,11 @@ extern ext_accm xmit_accm[];
#define MINMRU 128 /* No MRUs below this */ #define MINMRU 128 /* No MRUs below this */
#define MAXMRU 16384 /* Normally limit MRU to this */ #define MAXMRU 16384 /* Normally limit MRU to this */
void lcp_open (int); void lcp_open(int unit);
void lcp_close (int, char *); void lcp_close(int unit, char *reason);
void lcp_lowerup (int); void lcp_lowerup(int unit);
void lcp_lowerdown (int); void lcp_lowerdown(int unit);
void lcp_sprotrej (int, u_char *, int); /* send protocol reject */ void lcp_sprotrej(int unit, u_char *p, int len); /* send protocol reject */
extern struct protent lcp_protent; extern struct protent lcp_protent;
@ -152,4 +159,5 @@ extern struct protent lcp_protent;
before deciding the link is looped-back. */ before deciding the link is looped-back. */
#define DEFLOOPBACKFAIL 10 #define DEFLOOPBACKFAIL 10
#endif /* LCP_H */
#endif /* PPP_SUPPORT */ #endif /* PPP_SUPPORT */

View File

@ -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, 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) { 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(service_name);
LWIP_UNUSED_ARG(concentrator_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_cb = link_status_cb;
pcb->link_status_ctx = link_status_ctx; 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 */ wo->mru = ethif->mtu-PPPOE_HEADERLEN-2; /* two byte PPP protocol discriminator, then IP data */
lcp_wantoptions[pcb->unit].neg_asyncmap = 0; wo->neg_asyncmap = 0;
lcp_wantoptions[pcb->unit].neg_pcompression = 0; wo->neg_pcompression = 0;
lcp_wantoptions[pcb->unit].neg_accompression = 0; wo->neg_accompression = 0;
lcp_allowoptions[pcb->unit].mru = ethif->mtu-PPPOE_HEADERLEN-2; /* two byte PPP protocol discriminator, then IP data */ ao->mru = ethif->mtu-PPPOE_HEADERLEN-2; /* two byte PPP protocol discriminator, then IP data */
lcp_allowoptions[pcb->unit].neg_asyncmap = 0; ao->neg_asyncmap = 0;
lcp_allowoptions[pcb->unit].neg_pcompression = 0; ao->neg_pcompression = 0;
lcp_allowoptions[pcb->unit].neg_accompression = 0; ao->neg_accompression = 0;
if(pppoe_create(ethif, pcb, ppp_over_ethernet_link_status_cb, &pcb->pppoe_sc) != ERR_OK) { if(pppoe_create(ethif, pcb, ppp_over_ethernet_link_status_cb, &pcb->pppoe_sc) != ERR_OK) {
pcb->open_flag = 0; 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. * 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"); dbglog("Discarded non-LCP packet when LCP not open");
goto drop; goto drop;
} }

View File

@ -47,7 +47,6 @@
#include "vj.h" #include "vj.h"
/** PPP_INPROC_MULTITHREADED==1 call ppp_input using tcpip_callback(). /** 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. * 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). * 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; typedef unsigned char bool;
#endif #endif
#include "fsm.h"
#include "lcp.h"
#include "ipcp.h"
/************************* /*************************
*** PUBLIC DEFINITIONS *** *** PUBLIC DEFINITIONS ***
@ -391,6 +394,19 @@ typedef struct ppp_pcb_s {
#if EAP_SUPPORT #if EAP_SUPPORT
eap_state eap; eap_state eap;
#endif /* EAP_SUPPORT */ #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; } ppp_pcb;
/************************ /************************

View File

@ -221,14 +221,7 @@ struct ppp_idle {
}; };
/* FIXME: make endpoint discriminator optional */ /* FIXME: make endpoint discriminator optional */
/* FIXME: moved temporarily to lcp.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];
};
/* values for epdisc.class */ /* values for epdisc.class */
#define EPD_NULL 0 /* null discriminator, no data */ #define EPD_NULL 0 /* null discriminator, no data */