mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-08-24 23:25:58 +00:00
protent prototype switched from unit to ppp_pcb
This commit is contained in:
parent
4b7e3af77c
commit
4a8ff6d824
@ -711,9 +711,9 @@ void upper_layers_down(ppp_pcb *pcb) {
|
||||
if (!protp->enabled_flag)
|
||||
continue;
|
||||
if (protp->protocol != PPP_LCP && protp->lowerdown != NULL)
|
||||
(*protp->lowerdown)(pcb->unit);
|
||||
(*protp->lowerdown)(pcb);
|
||||
if (protp->protocol < 0xC000 && protp->close != NULL)
|
||||
(*protp->close)(pcb->unit, "LCP down");
|
||||
(*protp->close)(pcb, "LCP down");
|
||||
}
|
||||
pcb->num_np_open = 0;
|
||||
pcb->num_np_up = 0;
|
||||
@ -742,7 +742,7 @@ void link_established(ppp_pcb *pcb) {
|
||||
for (i = 0; (protp = protocols[i]) != NULL; ++i)
|
||||
if (protp->protocol != PPP_LCP && protp->enabled_flag
|
||||
&& protp->lowerup != NULL)
|
||||
(*protp->lowerup)(pcb->unit);
|
||||
(*protp->lowerup)(pcb);
|
||||
}
|
||||
|
||||
#if 0 /* UNUSED */
|
||||
@ -979,7 +979,7 @@ void continue_networks(ppp_pcb *pcb) {
|
||||
&& protp->protocol != PPP_ECP
|
||||
#endif /* ECP_SUPPORT */
|
||||
&& protp->enabled_flag && protp->open != NULL) {
|
||||
(*protp->open)(0);
|
||||
(*protp->open)(pcb);
|
||||
++pcb->num_np_open;
|
||||
}
|
||||
|
||||
@ -1083,7 +1083,7 @@ void auth_withpeer_fail(ppp_pcb *pcb, int protocol) {
|
||||
* we can do except wait for that.
|
||||
*/
|
||||
ppp_ioctl(pcb, PPPCTLS_ERRCODE, &errcode);
|
||||
lcp_close(pcb->unit, "Failed to authenticate ourselves to peer");
|
||||
lcp_close(pcb, "Failed to authenticate ourselves to peer");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -91,9 +91,9 @@ static option_t chap_option_list[] = {
|
||||
/*
|
||||
* Prototypes.
|
||||
*/
|
||||
static void chap_init(int unit);
|
||||
static void chap_lowerup(int unit);
|
||||
static void chap_lowerdown(int unit);
|
||||
static void chap_init(ppp_pcb *pcb);
|
||||
static void chap_lowerup(ppp_pcb *pcb);
|
||||
static void chap_lowerdown(ppp_pcb *pcb);
|
||||
#if PPP_SERVER
|
||||
static void chap_timeout(void *arg);
|
||||
static void chap_generate_challenge(ppp_pcb *pcb);
|
||||
@ -108,8 +108,8 @@ static void chap_respond(ppp_pcb *pcb, int id,
|
||||
unsigned char *pkt, int len);
|
||||
static void chap_handle_status(ppp_pcb *pcb, int code, int id,
|
||||
unsigned char *pkt, int len);
|
||||
static void chap_protrej(int unit);
|
||||
static void chap_input(int unit, unsigned char *pkt, int pktlen);
|
||||
static void chap_protrej(ppp_pcb *pcb);
|
||||
static void chap_input(ppp_pcb *pcb, unsigned char *pkt, int pktlen);
|
||||
#if PRINTPKT_SUPPORT
|
||||
static int chap_print_pkt(unsigned char *p, int plen,
|
||||
void (*printer) (void *, char *, ...), void *arg);
|
||||
@ -121,8 +121,7 @@ static struct chap_digest_type *chap_digests;
|
||||
/*
|
||||
* chap_init - reset to initial state.
|
||||
*/
|
||||
static void chap_init(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void chap_init(ppp_pcb *pcb) {
|
||||
|
||||
memset(&pcb->chap_client, 0, sizeof(chap_client_state));
|
||||
#if PPP_SERVER
|
||||
@ -148,8 +147,7 @@ void chap_register_digest(struct chap_digest_type *dp) {
|
||||
/*
|
||||
* chap_lowerup - we can start doing stuff now.
|
||||
*/
|
||||
static void chap_lowerup(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void chap_lowerup(ppp_pcb *pcb) {
|
||||
|
||||
pcb->chap_client.flags |= LOWERUP;
|
||||
#if PPP_SERVER
|
||||
@ -159,8 +157,7 @@ static void chap_lowerup(int unit) {
|
||||
#endif /* PPP_SERVER */
|
||||
}
|
||||
|
||||
static void chap_lowerdown(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void chap_lowerdown(ppp_pcb *pcb) {
|
||||
|
||||
pcb->chap_client.flags = 0;
|
||||
#if PPP_SERVER
|
||||
@ -502,8 +499,7 @@ static void chap_handle_status(ppp_pcb *pcb, int code, int id,
|
||||
}
|
||||
}
|
||||
|
||||
static void chap_input(int unit, unsigned char *pkt, int pktlen) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void chap_input(ppp_pcb *pcb, unsigned char *pkt, int pktlen) {
|
||||
unsigned char code, id;
|
||||
int len;
|
||||
|
||||
@ -532,8 +528,7 @@ static void chap_input(int unit, unsigned char *pkt, int pktlen) {
|
||||
}
|
||||
}
|
||||
|
||||
static void chap_protrej(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void chap_protrej(ppp_pcb *pcb) {
|
||||
|
||||
#if PPP_SERVER
|
||||
if (pcb->chap_server.flags & TIMEOUT_PENDING) {
|
||||
|
@ -96,11 +96,11 @@ static option_t eap_option_list[] = {
|
||||
/*
|
||||
* Protocol entry points.
|
||||
*/
|
||||
static void eap_init(int unit);
|
||||
static void eap_input(int unit, u_char *inp, int inlen);
|
||||
static void eap_protrej(int unit);
|
||||
static void eap_lowerup(int unit);
|
||||
static void eap_lowerdown(int unit);
|
||||
static void eap_init(ppp_pcb *pcb);
|
||||
static void eap_input(ppp_pcb *pcb, u_char *inp, int inlen);
|
||||
static void eap_protrej(ppp_pcb *pcb);
|
||||
static void eap_lowerup(ppp_pcb *pcb);
|
||||
static void eap_lowerdown(ppp_pcb *pcb);
|
||||
#if PRINTPKT_SUPPORT
|
||||
static int eap_printpkt(u_char *inp, int inlen,
|
||||
void (*)(void *arg, char *fmt, ...), void *arg);
|
||||
@ -195,11 +195,9 @@ enum eap_state_code esc;
|
||||
* eap_init - Initialize state for an EAP user. This is currently
|
||||
* called once by main() during start-up.
|
||||
*/
|
||||
static void eap_init(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void eap_init(ppp_pcb *pcb) {
|
||||
|
||||
BZERO(&pcb->eap, sizeof(eap_state));
|
||||
pcb->eap.es_unit = unit;
|
||||
#if PPP_SERVER
|
||||
pcb->eap.es_server.ea_timeout = EAP_DEFTIMEOUT;
|
||||
pcb->eap.es_server.ea_maxrequests = EAP_DEFTRANSMITS;
|
||||
@ -955,8 +953,7 @@ void *arg;
|
||||
* return to closed state so that those two routines will do the right
|
||||
* thing.
|
||||
*/
|
||||
static void eap_lowerup(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void eap_lowerup(ppp_pcb *pcb) {
|
||||
|
||||
/* Discard any (possibly authenticated) peer name. */
|
||||
#if PPP_SERVER
|
||||
@ -980,8 +977,7 @@ static void eap_lowerup(int unit) {
|
||||
*
|
||||
* Cancel all timeouts and return to initial state.
|
||||
*/
|
||||
static void eap_lowerdown(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void eap_lowerdown(ppp_pcb *pcb) {
|
||||
|
||||
if (eap_client_active(pcb) && pcb->eap.es_client.ea_timeout > 0) {
|
||||
UNTIMEOUT(eap_client_timeout, pcb);
|
||||
@ -1014,8 +1010,7 @@ static void eap_lowerdown(int unit) {
|
||||
* This shouldn't happen. If it does, it represents authentication
|
||||
* failure.
|
||||
*/
|
||||
static void eap_protrej(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void eap_protrej(ppp_pcb *pcb) {
|
||||
|
||||
if (eap_client_active(pcb)) {
|
||||
error("EAP authentication failed due to Protocol-Reject");
|
||||
@ -1027,7 +1022,7 @@ static void eap_protrej(int unit) {
|
||||
auth_peer_fail(pcb, PPP_EAP);
|
||||
}
|
||||
#endif /* PPP_SERVER */
|
||||
eap_lowerdown(unit);
|
||||
eap_lowerdown(pcb);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2029,8 +2024,7 @@ static void eap_failure(ppp_pcb *pcb, u_char *inp, int id, int len) {
|
||||
/*
|
||||
* eap_input - Handle received EAP message.
|
||||
*/
|
||||
static void eap_input(int unit, u_char *inp, int inlen) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void eap_input(ppp_pcb *pcb, u_char *inp, int inlen) {
|
||||
u_char code, id;
|
||||
int len;
|
||||
|
||||
|
@ -71,6 +71,7 @@
|
||||
*/
|
||||
typedef struct fsm {
|
||||
int unit; /* Interface unit number */
|
||||
void *pcb; /* FIXME: Temporary */
|
||||
int protocol; /* Data Link Layer Protocol field value */
|
||||
int state; /* State */
|
||||
int flags; /* Contains option bits */
|
||||
|
@ -249,13 +249,13 @@ static option_t ipcp_option_list[] = {
|
||||
/*
|
||||
* Protocol entry points from main code.
|
||||
*/
|
||||
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);
|
||||
static void ipcp_init(ppp_pcb *pcb);
|
||||
static void ipcp_open(ppp_pcb *pcb);
|
||||
static void ipcp_close(ppp_pcb *pcb, char *reason);
|
||||
static void ipcp_lowerup(ppp_pcb *pcb);
|
||||
static void ipcp_lowerdown(ppp_pcb *pcb);
|
||||
static void ipcp_input(ppp_pcb *pcb, u_char *p, int len);
|
||||
static void ipcp_protrej(ppp_pcb *pcb);
|
||||
#if PRINTPKT_SUPPORT
|
||||
static int ipcp_printpkt(u_char *p, int plen,
|
||||
void (*printer) (void *, char *, ...), void *arg);
|
||||
@ -584,14 +584,14 @@ parse_dotted_ip(p, vp)
|
||||
/*
|
||||
* ipcp_init - Initialize IPCP.
|
||||
*/
|
||||
static void ipcp_init(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void ipcp_init(ppp_pcb *pcb) {
|
||||
fsm *f = &pcb->ipcp_fsm;
|
||||
|
||||
ipcp_options *wo = &pcb->ipcp_wantoptions;
|
||||
ipcp_options *ao = &pcb->ipcp_allowoptions;
|
||||
|
||||
f->unit = unit;
|
||||
f->unit = pcb->unit;
|
||||
f->pcb = (void*)pcb;
|
||||
f->protocol = PPP_IPCP;
|
||||
f->callbacks = &ipcp_callbacks;
|
||||
fsm_init(f);
|
||||
@ -638,8 +638,7 @@ static void ipcp_init(int unit) {
|
||||
/*
|
||||
* ipcp_open - IPCP is allowed to come up.
|
||||
*/
|
||||
static void ipcp_open(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void ipcp_open(ppp_pcb *pcb) {
|
||||
fsm *f = &pcb->ipcp_fsm;
|
||||
fsm_open(f);
|
||||
ipcp_is_open = 1;
|
||||
@ -649,8 +648,7 @@ static void ipcp_open(int unit) {
|
||||
/*
|
||||
* ipcp_close - Take IPCP down.
|
||||
*/
|
||||
static void ipcp_close(int unit, char *reason) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void ipcp_close(ppp_pcb *pcb, char *reason) {
|
||||
fsm *f = &pcb->ipcp_fsm;
|
||||
fsm_close(f, reason);
|
||||
}
|
||||
@ -659,8 +657,7 @@ static void ipcp_close(int unit, char *reason) {
|
||||
/*
|
||||
* ipcp_lowerup - The lower layer is up.
|
||||
*/
|
||||
static void ipcp_lowerup(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void ipcp_lowerup(ppp_pcb *pcb) {
|
||||
fsm *f = &pcb->ipcp_fsm;
|
||||
fsm_lowerup(f);
|
||||
}
|
||||
@ -669,8 +666,7 @@ static void ipcp_lowerup(int unit) {
|
||||
/*
|
||||
* ipcp_lowerdown - The lower layer is down.
|
||||
*/
|
||||
static void ipcp_lowerdown(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void ipcp_lowerdown(ppp_pcb *pcb) {
|
||||
fsm *f = &pcb->ipcp_fsm;
|
||||
fsm_lowerdown(f);
|
||||
}
|
||||
@ -679,8 +675,7 @@ static void ipcp_lowerdown(int unit) {
|
||||
/*
|
||||
* ipcp_input - Input IPCP packet.
|
||||
*/
|
||||
static void ipcp_input(int unit, u_char *p, int len) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void ipcp_input(ppp_pcb *pcb, u_char *p, int len) {
|
||||
fsm *f = &pcb->ipcp_fsm;
|
||||
fsm_input(f, p, len);
|
||||
}
|
||||
@ -691,8 +686,7 @@ static void ipcp_input(int unit, u_char *p, int len) {
|
||||
*
|
||||
* Pretend the lower layer went down, so we shut up.
|
||||
*/
|
||||
static void ipcp_protrej(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void ipcp_protrej(ppp_pcb *pcb) {
|
||||
fsm *f = &pcb->ipcp_fsm;
|
||||
fsm_lowerdown(f);
|
||||
}
|
||||
@ -1776,12 +1770,12 @@ static void ipcp_up(fsm *f) {
|
||||
if (!(go->neg_addr || go->old_addrs) && (wo->neg_addr || wo->old_addrs)
|
||||
&& wo->ouraddr != 0) {
|
||||
error("Peer refused to agree to our IP address");
|
||||
ipcp_close(f->unit, "Refused our IP address");
|
||||
ipcp_close(f->pcb, "Refused our IP address");
|
||||
return;
|
||||
}
|
||||
if (go->ouraddr == 0) {
|
||||
error("Could not determine local IP address");
|
||||
ipcp_close(f->unit, "Could not determine local IP address");
|
||||
ipcp_close(f->pcb, "Could not determine local IP address");
|
||||
return;
|
||||
}
|
||||
if (ho->hisaddr == 0 && !noremoteip) {
|
||||
@ -1889,7 +1883,7 @@ static void ipcp_up(fsm *f) {
|
||||
#if PPP_DEBUG
|
||||
warn("Interface configuration failed");
|
||||
#endif /* PPP_DEBUG */
|
||||
ipcp_close(f->unit, "Interface configuration failed");
|
||||
ipcp_close(f->pcb, "Interface configuration failed");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@ -1899,7 +1893,7 @@ static void ipcp_up(fsm *f) {
|
||||
#if PPP_DEBUG
|
||||
warn("Interface failed to come up");
|
||||
#endif /* PPP_DEBUG */
|
||||
ipcp_close(f->unit, "Interface configuration failed");
|
||||
ipcp_close(f->pcb, "Interface configuration failed");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -241,8 +241,8 @@ static void lcp_rprotrej (fsm *, u_char *, int);
|
||||
* routines to send LCP echos to peer
|
||||
*/
|
||||
|
||||
static void lcp_echo_lowerup(int unit);
|
||||
static void lcp_echo_lowerdown(int unit);
|
||||
static void lcp_echo_lowerup(ppp_pcb *pcb);
|
||||
static void lcp_echo_lowerdown(ppp_pcb *pcb);
|
||||
static void LcpEchoTimeout (void *);
|
||||
static void lcp_received_echo_reply (fsm *, int, u_char *, int);
|
||||
static void LcpSendEchoRequest (fsm *);
|
||||
@ -272,9 +272,9 @@ static fsm_callbacks lcp_callbacks = { /* LCP callback routines */
|
||||
* Some of these are called directly.
|
||||
*/
|
||||
|
||||
static void lcp_init(int unit);
|
||||
static void lcp_input(int unit, u_char *p, int len);
|
||||
static void lcp_protrej(int unit);
|
||||
static void lcp_init(ppp_pcb *pcb);
|
||||
static void lcp_input(ppp_pcb *pcb, u_char *p, int len);
|
||||
static void lcp_protrej(ppp_pcb *pcb);
|
||||
#if PRINTPKT_SUPPORT
|
||||
static int lcp_printpkt(u_char *p, int plen,
|
||||
void (*printer) (void *, char *, ...), void *arg);
|
||||
@ -369,13 +369,13 @@ printendpoint(opt, printer, arg)
|
||||
/*
|
||||
* lcp_init - Initialize LCP.
|
||||
*/
|
||||
static void lcp_init(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void lcp_init(ppp_pcb *pcb) {
|
||||
fsm *f = &pcb->lcp_fsm;
|
||||
lcp_options *wo = &pcb->lcp_wantoptions;
|
||||
lcp_options *ao = &pcb->lcp_allowoptions;
|
||||
|
||||
f->unit = unit;
|
||||
f->unit = pcb->unit;
|
||||
f->pcb = (void*)pcb;
|
||||
f->protocol = PPP_LCP;
|
||||
f->callbacks = &lcp_callbacks;
|
||||
|
||||
@ -413,12 +413,12 @@ static void lcp_init(int unit) {
|
||||
* Set transmit escape for the flag and escape characters plus anything
|
||||
* set for the allowable options.
|
||||
*/
|
||||
memset(xmit_accm[unit], 0, sizeof(xmit_accm[0]));
|
||||
xmit_accm[unit][15] = 0x60;
|
||||
xmit_accm[unit][0] = (u_char)((ao->asyncmap & 0xFF));
|
||||
xmit_accm[unit][1] = (u_char)((ao->asyncmap >> 8) & 0xFF);
|
||||
xmit_accm[unit][2] = (u_char)((ao->asyncmap >> 16) & 0xFF);
|
||||
xmit_accm[unit][3] = (u_char)((ao->asyncmap >> 24) & 0xFF);
|
||||
memset(xmit_accm[pcb->unit], 0, sizeof(xmit_accm[0]));
|
||||
xmit_accm[pcb->unit][15] = 0x60;
|
||||
xmit_accm[pcb->unit][0] = (u_char)((ao->asyncmap & 0xFF));
|
||||
xmit_accm[pcb->unit][1] = (u_char)((ao->asyncmap >> 8) & 0xFF);
|
||||
xmit_accm[pcb->unit][2] = (u_char)((ao->asyncmap >> 16) & 0xFF);
|
||||
xmit_accm[pcb->unit][3] = (u_char)((ao->asyncmap >> 24) & 0xFF);
|
||||
LCPDEBUG(("lcp_init: xmit_accm=%X %X %X %X\n",
|
||||
xmit_accm[unit][0],
|
||||
xmit_accm[unit][1],
|
||||
@ -431,8 +431,7 @@ static void lcp_init(int unit) {
|
||||
/*
|
||||
* lcp_open - LCP is allowed to come up.
|
||||
*/
|
||||
void lcp_open(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
void lcp_open(ppp_pcb *pcb) {
|
||||
fsm *f = &pcb->lcp_fsm;
|
||||
lcp_options *wo = &pcb->lcp_wantoptions;
|
||||
|
||||
@ -448,8 +447,7 @@ void lcp_open(int unit) {
|
||||
/*
|
||||
* lcp_close - Take LCP down.
|
||||
*/
|
||||
void lcp_close(int unit, char *reason) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
void lcp_close(ppp_pcb *pcb, char *reason) {
|
||||
fsm *f = &pcb->lcp_fsm;
|
||||
int oldstate;
|
||||
|
||||
@ -480,8 +478,7 @@ void lcp_close(int unit, char *reason) {
|
||||
/*
|
||||
* lcp_lowerup - The lower layer is up.
|
||||
*/
|
||||
void lcp_lowerup(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
void lcp_lowerup(ppp_pcb *pcb) {
|
||||
lcp_options *wo = &pcb->lcp_wantoptions;
|
||||
#if PPPOS_SUPPORT
|
||||
lcp_options *ao = &pcb->lcp_allowoptions;
|
||||
@ -493,19 +490,19 @@ void lcp_lowerup(int unit) {
|
||||
* if we are going to ask for A/C and protocol compression.
|
||||
*/
|
||||
#if PPPOS_SUPPORT
|
||||
ppp_set_xaccm(pcb, &xmit_accm[unit]);
|
||||
ppp_set_xaccm(pcb, &xmit_accm[pcb->unit]);
|
||||
#endif /* PPPOS_SUPPORT */
|
||||
if (ppp_send_config(pcb, PPP_MRU, 0xffffffff, 0, 0) < 0
|
||||
|| ppp_recv_config(pcb, PPP_MRU, (lax_recv? 0: 0xffffffff),
|
||||
wo->neg_pcompression, wo->neg_accompression) < 0)
|
||||
return;
|
||||
peer_mru[unit] = PPP_MRU;
|
||||
peer_mru[pcb->unit] = PPP_MRU;
|
||||
|
||||
#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);
|
||||
ao->asyncmap = (u_long)xmit_accm[f->unit][0]
|
||||
| ((u_long)xmit_accm[pcb->unit][1] << 8)
|
||||
| ((u_long)xmit_accm[pcb->unit][2] << 16)
|
||||
| ((u_long)xmit_accm[pcb->unit][3] << 24);
|
||||
LCPDEBUG(("lcp_lowerup: asyncmap=%X %X %X %X\n",
|
||||
xmit_accm[unit][3],
|
||||
xmit_accm[unit][2],
|
||||
@ -524,8 +521,7 @@ void lcp_lowerup(int unit) {
|
||||
/*
|
||||
* lcp_lowerdown - The lower layer is down.
|
||||
*/
|
||||
void lcp_lowerdown(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
void lcp_lowerdown(ppp_pcb *pcb) {
|
||||
fsm *f = &pcb->lcp_fsm;
|
||||
|
||||
if (f->flags & DELAYED_UP) {
|
||||
@ -552,8 +548,7 @@ static void lcp_delayed_up(void *arg) {
|
||||
/*
|
||||
* lcp_input - Input LCP packet.
|
||||
*/
|
||||
static void lcp_input(int unit, u_char *p, int len) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void lcp_input(ppp_pcb *pcb, u_char *p, int len) {
|
||||
fsm *f = &pcb->lcp_fsm;
|
||||
|
||||
if (f->flags & DELAYED_UP) {
|
||||
@ -657,7 +652,7 @@ lcp_rprotrej(f, inp, len)
|
||||
else
|
||||
#endif /* PPP_PROTOCOLNAME */
|
||||
dbglog("Protocol-Reject for 0x%x received", prot);
|
||||
(*protp->protrej)(f->unit);
|
||||
(*protp->protrej)(f->pcb);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -675,8 +670,7 @@ lcp_rprotrej(f, inp, len)
|
||||
* lcp_protrej - A Protocol-Reject was received.
|
||||
*/
|
||||
/*ARGSUSED*/
|
||||
static void lcp_protrej(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void lcp_protrej(ppp_pcb *pcb) {
|
||||
/*
|
||||
* Can't reject LCP!
|
||||
*/
|
||||
@ -688,8 +682,7 @@ static void lcp_protrej(int unit) {
|
||||
/*
|
||||
* lcp_sprotrej - Send a Protocol-Reject for some protocol.
|
||||
*/
|
||||
void lcp_sprotrej(int unit, u_char *p, int len) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
void lcp_sprotrej(ppp_pcb *pcb, u_char *p, int len) {
|
||||
fsm *f = &pcb->lcp_fsm;
|
||||
/*
|
||||
* Send back the protocol and the information field of the
|
||||
@ -1536,7 +1529,7 @@ lcp_nakci(f, p, len, treat_as_reject)
|
||||
if (++try.numloops >= lcp_loopbackfail) {
|
||||
notice("Serial line is looped back.");
|
||||
pcb->status = EXIT_LOOPBACK;
|
||||
lcp_close(f->unit, "Loopback detected");
|
||||
lcp_close(f->pcb, "Loopback detected");
|
||||
}
|
||||
} else
|
||||
try.numloops = 0;
|
||||
@ -2296,7 +2289,7 @@ lcp_up(f)
|
||||
if (ho->neg_mru)
|
||||
peer_mru[f->unit] = ho->mru;
|
||||
|
||||
lcp_echo_lowerup(f->unit); /* Enable echo messages */
|
||||
lcp_echo_lowerup(f->pcb); /* Enable echo messages */
|
||||
|
||||
link_established(pcb);
|
||||
}
|
||||
@ -2314,7 +2307,7 @@ lcp_down(f)
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
|
||||
lcp_echo_lowerdown(f->unit);
|
||||
lcp_echo_lowerdown(f->pcb);
|
||||
|
||||
link_down(pcb);
|
||||
|
||||
@ -2613,7 +2606,7 @@ void LcpLinkFailure (f)
|
||||
info("No response to %d echo-requests", lcp_echos_pending);
|
||||
notice("Serial link appears to be disconnected.");
|
||||
pc->status = EXIT_PEER_DEAD;
|
||||
lcp_close(f->unit, "Peer not responding");
|
||||
lcp_close(f->pcb, "Peer not responding");
|
||||
}
|
||||
}
|
||||
|
||||
@ -2742,8 +2735,7 @@ LcpSendEchoRequest (f)
|
||||
* lcp_echo_lowerup - Start the timer for the LCP frame
|
||||
*/
|
||||
|
||||
static void lcp_echo_lowerup(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void lcp_echo_lowerup(ppp_pcb *pcb) {
|
||||
fsm *f = &pcb->lcp_fsm;
|
||||
|
||||
/* Clear the parameters for generating echo frames */
|
||||
@ -2760,8 +2752,7 @@ static void lcp_echo_lowerup(int unit) {
|
||||
* lcp_echo_lowerdown - Stop the timer for the LCP frame
|
||||
*/
|
||||
|
||||
static void lcp_echo_lowerdown(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void lcp_echo_lowerdown(ppp_pcb *pcb) {
|
||||
fsm *f = &pcb->lcp_fsm;
|
||||
|
||||
if (lcp_echo_timer_running != 0) {
|
||||
|
@ -48,6 +48,8 @@
|
||||
#ifndef LCP_H
|
||||
#define LCP_H
|
||||
|
||||
#include "ppp.h"
|
||||
|
||||
/*
|
||||
* Options.
|
||||
*/
|
||||
@ -88,57 +90,6 @@
|
||||
/* 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.
|
||||
*/
|
||||
typedef struct lcp_options {
|
||||
bool passive; /* Don't die if we don't get a response */
|
||||
bool silent; /* Wait for the other end to start first */
|
||||
bool restart; /* Restart vs. exit after close */
|
||||
bool neg_mru; /* Negotiate the MRU? */
|
||||
bool neg_asyncmap; /* Negotiate the async map? */
|
||||
#if PAP_SUPPORT
|
||||
bool neg_upap; /* Ask for UPAP authentication? */
|
||||
#endif /* PAP_SUPPORT */
|
||||
#if CHAP_SUPPORT
|
||||
bool neg_chap; /* Ask for CHAP authentication? */
|
||||
#endif /* CHAP_SUPPORT */
|
||||
#if EAP_SUPPORT
|
||||
bool neg_eap; /* Ask for EAP authentication? */
|
||||
#endif /* EAP_SUPPORT */
|
||||
bool neg_magicnumber; /* Ask for magic number? */
|
||||
bool neg_pcompression; /* HDLC Protocol Field Compression? */
|
||||
bool neg_accompression; /* HDLC Address/Control Field Compression? */
|
||||
#if LQR_SUPPORT
|
||||
bool neg_lqr; /* Negotiate use of Link Quality Reports */
|
||||
#endif /* LQR_SUPPORT */
|
||||
bool neg_cbcp; /* Negotiate use of CBCP */
|
||||
bool neg_mrru; /* negotiate multilink MRRU */
|
||||
bool neg_ssnhf; /* negotiate short sequence numbers */
|
||||
bool neg_endpoint; /* negotiate endpoint discriminator */
|
||||
int mru; /* Value of MRU */
|
||||
int mrru; /* Value of MRRU, and multilink enable */
|
||||
#if CHAP_SUPPORT
|
||||
u_char chap_mdtype; /* which MD types (hashing algorithm) */
|
||||
#endif /* CHAP_SUPPORT */
|
||||
u_int32_t asyncmap; /* Value of async map */
|
||||
u_int32_t magicnumber;
|
||||
int numloops; /* Number of loops during magic number neg. */
|
||||
#if LQR_SUPPORT
|
||||
u_int32_t lqr_period; /* Reporting period for LQR 1/100ths second */
|
||||
#endif /* LQR_SUPPORT */
|
||||
struct epdisc endpoint; /* endpoint discriminator */
|
||||
} lcp_options;
|
||||
|
||||
#if PPPOS_SUPPORT
|
||||
extern ext_accm xmit_accm[];
|
||||
#endif /* #if PPPOS_SUPPORT */
|
||||
@ -147,11 +98,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 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 */
|
||||
void lcp_open(ppp_pcb *pcb);
|
||||
void lcp_close(ppp_pcb *pcb, char *reason);
|
||||
void lcp_lowerup(ppp_pcb *pcb);
|
||||
void lcp_lowerdown(ppp_pcb *pcb);
|
||||
void lcp_sprotrej(ppp_pcb *pcb, u_char *p, int len); /* send protocol reject */
|
||||
|
||||
extern struct protent lcp_protent;
|
||||
|
||||
|
@ -267,7 +267,7 @@ ppp_pcb *ppp_new(void) {
|
||||
* Initialize each protocol.
|
||||
*/
|
||||
for (i = 0; (protp = protocols[i]) != NULL; ++i)
|
||||
(*protp->init)(pd);
|
||||
(*protp->init)(pcb);
|
||||
|
||||
return pcb;
|
||||
}
|
||||
@ -475,21 +475,21 @@ ppp_sighup(ppp_pcb *pcb)
|
||||
/** Initiate LCP open request */
|
||||
static void ppp_start(ppp_pcb *pcb) {
|
||||
PPPDEBUG(LOG_DEBUG, ("ppp_start: unit %d\n", pcb->unit));
|
||||
lcp_open(pcb->unit); /* Start protocol */
|
||||
lcp_lowerup(pcb->unit);
|
||||
lcp_open(pcb); /* Start protocol */
|
||||
lcp_lowerup(pcb);
|
||||
PPPDEBUG(LOG_DEBUG, ("ppp_start: finished\n"));
|
||||
}
|
||||
|
||||
/** LCP close request */
|
||||
static void ppp_stop(ppp_pcb *pcb) {
|
||||
PPPDEBUG(LOG_DEBUG, ("ppp_stop: unit %d\n", pcb->unit));
|
||||
lcp_close(pcb->unit, "User request");
|
||||
lcp_close(pcb, "User request");
|
||||
}
|
||||
|
||||
/** Called when carrier/link is lost */
|
||||
static void ppp_hup(ppp_pcb *pcb) {
|
||||
PPPDEBUG(LOG_DEBUG, ("ppp_hup: unit %d\n", pcb->unit));
|
||||
lcp_lowerdown(pcb->unit);
|
||||
lcp_lowerdown(pcb);
|
||||
link_terminated(pcb);
|
||||
}
|
||||
|
||||
@ -599,7 +599,7 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) {
|
||||
for (i = 0; (protp = protocols[i]) != NULL; ++i) {
|
||||
if (protp->protocol == protocol && protp->enabled_flag) {
|
||||
pb = ppp_singlebuf(pb);
|
||||
(*protp->input)(pcb->unit, pb->payload, pb->len);
|
||||
(*protp->input)(pcb, pb->payload, pb->len);
|
||||
goto out;
|
||||
}
|
||||
#if 0 /* UNUSED
|
||||
@ -632,7 +632,7 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) {
|
||||
LWIP_ASSERT("pbuf_header failed\n", 0);
|
||||
goto drop;
|
||||
}
|
||||
lcp_sprotrej(pcb->unit, pb->payload, pb->len);
|
||||
lcp_sprotrej(pcb, pb->payload, pb->len);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -89,7 +89,6 @@ typedef unsigned char bool;
|
||||
#endif
|
||||
|
||||
#include "fsm.h"
|
||||
#include "lcp.h"
|
||||
#include "ipcp.h"
|
||||
|
||||
|
||||
@ -227,12 +226,61 @@ typedef struct ppp_pcb_rx_s {
|
||||
} ppp_pcb_rx;
|
||||
#endif /* PPPOS_SUPPORT */
|
||||
|
||||
/* 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.
|
||||
*/
|
||||
typedef struct lcp_options {
|
||||
bool passive; /* Don't die if we don't get a response */
|
||||
bool silent; /* Wait for the other end to start first */
|
||||
bool restart; /* Restart vs. exit after close */
|
||||
bool neg_mru; /* Negotiate the MRU? */
|
||||
bool neg_asyncmap; /* Negotiate the async map? */
|
||||
#if PAP_SUPPORT
|
||||
bool neg_upap; /* Ask for UPAP authentication? */
|
||||
#endif /* PAP_SUPPORT */
|
||||
#if CHAP_SUPPORT
|
||||
bool neg_chap; /* Ask for CHAP authentication? */
|
||||
#endif /* CHAP_SUPPORT */
|
||||
#if EAP_SUPPORT
|
||||
bool neg_eap; /* Ask for EAP authentication? */
|
||||
#endif /* EAP_SUPPORT */
|
||||
bool neg_magicnumber; /* Ask for magic number? */
|
||||
bool neg_pcompression; /* HDLC Protocol Field Compression? */
|
||||
bool neg_accompression; /* HDLC Address/Control Field Compression? */
|
||||
#if LQR_SUPPORT
|
||||
bool neg_lqr; /* Negotiate use of Link Quality Reports */
|
||||
#endif /* LQR_SUPPORT */
|
||||
bool neg_cbcp; /* Negotiate use of CBCP */
|
||||
bool neg_mrru; /* negotiate multilink MRRU */
|
||||
bool neg_ssnhf; /* negotiate short sequence numbers */
|
||||
bool neg_endpoint; /* negotiate endpoint discriminator */
|
||||
int mru; /* Value of MRU */
|
||||
int mrru; /* Value of MRRU, and multilink enable */
|
||||
#if CHAP_SUPPORT
|
||||
u_char chap_mdtype; /* which MD types (hashing algorithm) */
|
||||
#endif /* CHAP_SUPPORT */
|
||||
u_int32_t asyncmap; /* Value of async map */
|
||||
u_int32_t magicnumber;
|
||||
int numloops; /* Number of loops during magic number neg. */
|
||||
#if LQR_SUPPORT
|
||||
u_int32_t lqr_period; /* Reporting period for LQR 1/100ths second */
|
||||
#endif /* LQR_SUPPORT */
|
||||
struct epdisc endpoint; /* endpoint discriminator */
|
||||
} lcp_options;
|
||||
|
||||
/*
|
||||
* Each interface is described by upap structure.
|
||||
*/
|
||||
#if PAP_SUPPORT
|
||||
typedef struct upap_state {
|
||||
int us_unit; /* Interface unit number */
|
||||
char *us_user; /* User */
|
||||
int us_userlen; /* User length */
|
||||
char *us_passwd; /* Password */
|
||||
@ -314,7 +362,6 @@ struct eap_auth {
|
||||
#define EAP_MAX_CHALLENGE_LENGTH 24
|
||||
#endif
|
||||
typedef struct eap_state {
|
||||
int es_unit; /* Interface unit number */
|
||||
struct eap_auth es_client; /* Client (authenticatee) data */
|
||||
#if PPP_SERVER
|
||||
struct eap_auth es_server; /* Server (authenticator) data */
|
||||
|
@ -221,7 +221,7 @@ struct ppp_idle {
|
||||
};
|
||||
|
||||
/* FIXME: make endpoint discriminator optional */
|
||||
/* FIXME: moved temporarily to lcp.h */
|
||||
/* FIXME: moved temporarily to ppp.h */
|
||||
|
||||
/* values for epdisc.class */
|
||||
#define EPD_NULL 0 /* null discriminator, no data */
|
||||
@ -269,19 +269,19 @@ extern int maxoctets_timeout; /* Timeout for check of octets limit */
|
||||
struct protent {
|
||||
u_short protocol; /* PPP protocol number */
|
||||
/* Initialization procedure */
|
||||
void (*init) (int unit);
|
||||
void (*init) (ppp_pcb *pcb);
|
||||
/* Process a received packet */
|
||||
void (*input) (int unit, u_char *pkt, int len);
|
||||
void (*input) (ppp_pcb *pcb, u_char *pkt, int len);
|
||||
/* Process a received protocol-reject */
|
||||
void (*protrej) (int unit);
|
||||
void (*protrej) (ppp_pcb *pcb);
|
||||
/* Lower layer has come up */
|
||||
void (*lowerup) (int unit);
|
||||
void (*lowerup) (ppp_pcb *pcb);
|
||||
/* Lower layer has gone down */
|
||||
void (*lowerdown) (int unit);
|
||||
void (*lowerdown) (ppp_pcb *pcb);
|
||||
/* Open the protocol */
|
||||
void (*open) (int unit);
|
||||
void (*open) (ppp_pcb *pcb);
|
||||
/* Close the protocol */
|
||||
void (*close) (int unit, char *reason);
|
||||
void (*close) (ppp_pcb *pcb, char *reason);
|
||||
#if PRINTPKT_SUPPORT
|
||||
/* Print a packet in readable form */
|
||||
int (*printpkt) (u_char *pkt, int len,
|
||||
@ -292,7 +292,7 @@ struct protent {
|
||||
* should we remove this entry and save some flash ?
|
||||
*/
|
||||
/* Process a received data packet */
|
||||
void (*datainput) (int unit, u_char *pkt, int len);
|
||||
void (*datainput) (ppp_pcb *pcb, u_char *pkt, int len);
|
||||
bool enabled_flag; /* 0 if protocol is disabled */
|
||||
#if PRINTPKT_SUPPORT
|
||||
char *name; /* Text name of protocol */
|
||||
|
@ -80,11 +80,11 @@ static option_t pap_option_list[] = {
|
||||
/*
|
||||
* Protocol entry points.
|
||||
*/
|
||||
static void upap_init(int unit);
|
||||
static void upap_lowerup(int unit);
|
||||
static void upap_lowerdown(int unit);
|
||||
static void upap_input(int unit, u_char *inpacket, int l);
|
||||
static void upap_protrej(int unit);
|
||||
static void upap_init(ppp_pcb *pcb);
|
||||
static void upap_lowerup(ppp_pcb *pcb);
|
||||
static void upap_lowerdown(ppp_pcb *pcb);
|
||||
static void upap_input(ppp_pcb *pcb, u_char *inpacket, int l);
|
||||
static void upap_protrej(ppp_pcb *pcb);
|
||||
#if PRINTPKT_SUPPORT
|
||||
static int upap_printpkt(u_char *p, int plen, void (*printer) (void *, char *, ...), void *arg);
|
||||
#endif /* PRINTPKT_SUPPORT */
|
||||
@ -135,10 +135,7 @@ static void upap_sresp(ppp_pcb *pcb, u_char code, u_char id, char *msg, int msgl
|
||||
/*
|
||||
* upap_init - Initialize a UPAP unit.
|
||||
*/
|
||||
static void upap_init(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
|
||||
pcb->upap.us_unit = unit;
|
||||
static void upap_init(ppp_pcb *pcb) {
|
||||
pcb->upap.us_user = NULL;
|
||||
pcb->upap.us_userlen = 0;
|
||||
pcb->upap.us_passwd = NULL;
|
||||
@ -240,8 +237,7 @@ static void upap_reqtimeout(void *arg) {
|
||||
*
|
||||
* Start authenticating if pending.
|
||||
*/
|
||||
static void upap_lowerup(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void upap_lowerup(ppp_pcb *pcb) {
|
||||
|
||||
if (pcb->upap.us_clientstate == UPAPCS_INITIAL)
|
||||
pcb->upap.us_clientstate = UPAPCS_CLOSED;
|
||||
@ -266,8 +262,7 @@ static void upap_lowerup(int unit) {
|
||||
*
|
||||
* Cancel all timeouts.
|
||||
*/
|
||||
static void upap_lowerdown(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void upap_lowerdown(ppp_pcb *pcb) {
|
||||
|
||||
if (pcb->upap.us_clientstate == UPAPCS_AUTHREQ) /* Timeout pending? */
|
||||
UNTIMEOUT(upap_timeout, pcb); /* Cancel timeout */
|
||||
@ -288,8 +283,7 @@ static void upap_lowerdown(int unit) {
|
||||
*
|
||||
* This shouldn't happen. In any case, pretend lower layer went down.
|
||||
*/
|
||||
static void upap_protrej(int unit) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void upap_protrej(ppp_pcb *pcb) {
|
||||
|
||||
if (pcb->upap.us_clientstate == UPAPCS_AUTHREQ) {
|
||||
error("PAP authentication failed due to protocol-reject");
|
||||
@ -301,15 +295,14 @@ static void upap_protrej(int unit) {
|
||||
auth_peer_fail(pcb, PPP_PAP);
|
||||
}
|
||||
#endif /* PPP_SERVER */
|
||||
upap_lowerdown(unit);
|
||||
upap_lowerdown(pcb);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* upap_input - Input UPAP packet.
|
||||
*/
|
||||
static void upap_input(int unit, u_char *inpacket, int l) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[unit];
|
||||
static void upap_input(ppp_pcb *pcb, u_char *inpacket, int l) {
|
||||
u_char *inp;
|
||||
u_char code, id;
|
||||
int len;
|
||||
|
Loading…
Reference in New Issue
Block a user