mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-02-21 18:40:12 +00:00
removed fsm->unit
This commit is contained in:
parent
4a8ff6d824
commit
f10ddea305
@ -60,13 +60,13 @@
|
||||
#include "fsm.h"
|
||||
|
||||
static void fsm_timeout (void *);
|
||||
static void fsm_rconfreq (fsm *, int, u_char *, int);
|
||||
static void fsm_rconfack (fsm *, int, u_char *, int);
|
||||
static void fsm_rconfnakrej (fsm *, int, int, u_char *, int);
|
||||
static void fsm_rtermreq (fsm *, int, u_char *, int);
|
||||
static void fsm_rtermack (fsm *);
|
||||
static void fsm_rcoderej (fsm *, u_char *, int);
|
||||
static void fsm_sconfreq (fsm *, int);
|
||||
static void fsm_rconfreq(fsm *f, u_char id, u_char *inp, int len);
|
||||
static void fsm_rconfack(fsm *f, int id, u_char *inp, int len);
|
||||
static void fsm_rconfnakrej(fsm *f, int code, int id, u_char *inp, int len);
|
||||
static void fsm_rtermreq(fsm *f, int id, u_char *p, int len);
|
||||
static void fsm_rtermack(fsm *f);
|
||||
static void fsm_rcoderej(fsm *f, u_char *inp, int len);
|
||||
static void fsm_sconfreq(fsm *f, int retransmit);
|
||||
|
||||
#define PROTO_NAME(f) ((f)->callbacks->proto_name)
|
||||
|
||||
@ -78,10 +78,7 @@ int peer_mru[NUM_PPP];
|
||||
*
|
||||
* Initialize fsm state.
|
||||
*/
|
||||
void
|
||||
fsm_init(f)
|
||||
fsm *f;
|
||||
{
|
||||
void fsm_init(fsm *f) {
|
||||
f->state = INITIAL;
|
||||
f->flags = 0;
|
||||
f->id = 0; /* XXX Start with random id? */
|
||||
@ -96,10 +93,7 @@ fsm_init(f)
|
||||
/*
|
||||
* fsm_lowerup - The lower layer is up.
|
||||
*/
|
||||
void
|
||||
fsm_lowerup(f)
|
||||
fsm *f;
|
||||
{
|
||||
void fsm_lowerup(fsm *f) {
|
||||
switch( f->state ){
|
||||
case INITIAL:
|
||||
f->state = CLOSED;
|
||||
@ -127,10 +121,7 @@ fsm_lowerup(f)
|
||||
*
|
||||
* Cancel all timeouts and inform upper layers.
|
||||
*/
|
||||
void
|
||||
fsm_lowerdown(f)
|
||||
fsm *f;
|
||||
{
|
||||
void fsm_lowerdown(fsm *f) {
|
||||
switch( f->state ){
|
||||
case CLOSED:
|
||||
f->state = INITIAL;
|
||||
@ -171,10 +162,7 @@ fsm_lowerdown(f)
|
||||
/*
|
||||
* fsm_open - Link is allowed to come up.
|
||||
*/
|
||||
void
|
||||
fsm_open(f)
|
||||
fsm *f;
|
||||
{
|
||||
void fsm_open(fsm *f) {
|
||||
switch( f->state ){
|
||||
case INITIAL:
|
||||
f->state = STARTING;
|
||||
@ -212,11 +200,7 @@ fsm_open(f)
|
||||
* Cancel any timeout running, notify upper layers we're done, and
|
||||
* send a terminate-request message as configured.
|
||||
*/
|
||||
static void
|
||||
terminate_layer(f, nextstate)
|
||||
fsm *f;
|
||||
int nextstate;
|
||||
{
|
||||
static void terminate_layer(fsm *f, int nextstate) {
|
||||
if( f->state != OPENED )
|
||||
UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */
|
||||
else if( f->callbacks->down )
|
||||
@ -251,11 +235,7 @@ terminate_layer(f, nextstate)
|
||||
* Cancel timeouts and either initiate close or possibly go directly to
|
||||
* the CLOSED state.
|
||||
*/
|
||||
void
|
||||
fsm_close(f, reason)
|
||||
fsm *f;
|
||||
char *reason;
|
||||
{
|
||||
void fsm_close(fsm *f, char *reason) {
|
||||
f->term_reason = reason;
|
||||
f->term_reason_len = (reason == NULL? 0: strlen(reason));
|
||||
switch( f->state ){
|
||||
@ -282,10 +262,7 @@ fsm_close(f, reason)
|
||||
/*
|
||||
* fsm_timeout - Timeout expired.
|
||||
*/
|
||||
static void
|
||||
fsm_timeout(arg)
|
||||
void *arg;
|
||||
{
|
||||
static void fsm_timeout(void *arg) {
|
||||
fsm *f = (fsm *) arg;
|
||||
|
||||
switch (f->state) {
|
||||
@ -336,12 +313,7 @@ fsm_timeout(arg)
|
||||
/*
|
||||
* fsm_input - Input packet.
|
||||
*/
|
||||
void
|
||||
fsm_input(f, inpacket, l)
|
||||
fsm *f;
|
||||
u_char *inpacket;
|
||||
int l;
|
||||
{
|
||||
void fsm_input(fsm *f, u_char *inpacket, int l) {
|
||||
u_char *inp;
|
||||
u_char code, id;
|
||||
int len;
|
||||
@ -415,13 +387,7 @@ fsm_input(f, inpacket, l)
|
||||
/*
|
||||
* fsm_rconfreq - Receive Configure-Request.
|
||||
*/
|
||||
static void
|
||||
fsm_rconfreq(f, id, inp, len)
|
||||
fsm *f;
|
||||
u_char id;
|
||||
u_char *inp;
|
||||
int len;
|
||||
{
|
||||
static void fsm_rconfreq(fsm *f, u_char id, u_char *inp, int len) {
|
||||
int code, reject_if_disagree;
|
||||
|
||||
switch( f->state ){
|
||||
@ -486,13 +452,7 @@ fsm_rconfreq(f, id, inp, len)
|
||||
/*
|
||||
* fsm_rconfack - Receive Configure-Ack.
|
||||
*/
|
||||
static void
|
||||
fsm_rconfack(f, id, inp, len)
|
||||
fsm *f;
|
||||
int id;
|
||||
u_char *inp;
|
||||
int len;
|
||||
{
|
||||
static void fsm_rconfack(fsm *f, int id, u_char *inp, int len) {
|
||||
if (id != f->reqid || f->seen_ack) /* Expected id? */
|
||||
return; /* Nope, toss... */
|
||||
if( !(f->callbacks->ackci? (*f->callbacks->ackci)(f, inp, len):
|
||||
@ -544,13 +504,7 @@ fsm_rconfack(f, id, inp, len)
|
||||
/*
|
||||
* fsm_rconfnakrej - Receive Configure-Nak or Configure-Reject.
|
||||
*/
|
||||
static void
|
||||
fsm_rconfnakrej(f, code, id, inp, len)
|
||||
fsm *f;
|
||||
int code, id;
|
||||
u_char *inp;
|
||||
int len;
|
||||
{
|
||||
static void fsm_rconfnakrej(fsm *f, int code, int id, u_char *inp, int len) {
|
||||
int ret;
|
||||
int treat_as_reject;
|
||||
|
||||
@ -613,13 +567,7 @@ fsm_rconfnakrej(f, code, id, inp, len)
|
||||
/*
|
||||
* fsm_rtermreq - Receive Terminate-Req.
|
||||
*/
|
||||
static void
|
||||
fsm_rtermreq(f, id, p, len)
|
||||
fsm *f;
|
||||
int id;
|
||||
u_char *p;
|
||||
int len;
|
||||
{
|
||||
static void fsm_rtermreq(fsm *f, int id, u_char *p, int len) {
|
||||
switch (f->state) {
|
||||
case ACKRCVD:
|
||||
case ACKSENT:
|
||||
@ -646,10 +594,7 @@ fsm_rtermreq(f, id, p, len)
|
||||
/*
|
||||
* fsm_rtermack - Receive Terminate-Ack.
|
||||
*/
|
||||
static void
|
||||
fsm_rtermack(f)
|
||||
fsm *f;
|
||||
{
|
||||
static void fsm_rtermack(fsm *f) {
|
||||
switch (f->state) {
|
||||
case CLOSING:
|
||||
UNTIMEOUT(fsm_timeout, f);
|
||||
@ -681,12 +626,7 @@ fsm_rtermack(f)
|
||||
/*
|
||||
* fsm_rcoderej - Receive an Code-Reject.
|
||||
*/
|
||||
static void
|
||||
fsm_rcoderej(f, inp, len)
|
||||
fsm *f;
|
||||
u_char *inp;
|
||||
int len;
|
||||
{
|
||||
static void fsm_rcoderej(fsm *f, u_char *inp, int len) {
|
||||
u_char code, id;
|
||||
|
||||
if (len < HEADERLEN) {
|
||||
@ -707,10 +647,7 @@ fsm_rcoderej(f, inp, len)
|
||||
*
|
||||
* Treat this as a catastrophic error (RXJ-).
|
||||
*/
|
||||
void
|
||||
fsm_protreject(f)
|
||||
fsm *f;
|
||||
{
|
||||
void fsm_protreject(fsm *f) {
|
||||
switch( f->state ){
|
||||
case CLOSING:
|
||||
UNTIMEOUT(fsm_timeout, f); /* Cancel timeout */
|
||||
@ -750,11 +687,8 @@ fsm_protreject(f)
|
||||
/*
|
||||
* fsm_sconfreq - Send a Configure-Request.
|
||||
*/
|
||||
static void
|
||||
fsm_sconfreq(f, retransmit)
|
||||
fsm *f;
|
||||
int retransmit;
|
||||
{
|
||||
static void fsm_sconfreq(fsm *f, int retransmit) {
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
u_char *outp;
|
||||
int cilen;
|
||||
|
||||
@ -780,8 +714,8 @@ fsm_sconfreq(f, retransmit)
|
||||
outp = outpacket_buf + PPP_HDRLEN + HEADERLEN;
|
||||
if( f->callbacks->cilen && f->callbacks->addci ){
|
||||
cilen = (*f->callbacks->cilen)(f);
|
||||
if( cilen > peer_mru[f->unit] - HEADERLEN )
|
||||
cilen = peer_mru[f->unit] - HEADERLEN;
|
||||
if( cilen > peer_mru[pcb->unit] - HEADERLEN )
|
||||
cilen = peer_mru[pcb->unit] - HEADERLEN;
|
||||
if (f->callbacks->addci)
|
||||
(*f->callbacks->addci)(f, outp, &cilen);
|
||||
} else
|
||||
@ -801,21 +735,15 @@ fsm_sconfreq(f, retransmit)
|
||||
*
|
||||
* Used for all packets sent to our peer by this module.
|
||||
*/
|
||||
void
|
||||
fsm_sdata(f, code, id, data, datalen)
|
||||
fsm *f;
|
||||
u_char code, id;
|
||||
u_char *data;
|
||||
int datalen;
|
||||
{
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
void fsm_sdata(fsm *f, u_char code, u_char id, u_char *data, int datalen) {
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
u_char *outp;
|
||||
int outlen;
|
||||
|
||||
/* Adjust length to be smaller than MTU */
|
||||
outp = outpacket_buf;
|
||||
if (datalen > peer_mru[f->unit] - HEADERLEN)
|
||||
datalen = peer_mru[f->unit] - HEADERLEN;
|
||||
if (datalen > peer_mru[pcb->unit] - HEADERLEN)
|
||||
datalen = peer_mru[pcb->unit] - HEADERLEN;
|
||||
if (datalen && data != outp + PPP_HDRLEN + HEADERLEN)
|
||||
MEMCPY(outp + PPP_HDRLEN + HEADERLEN, data, datalen);
|
||||
outlen = datalen + HEADERLEN;
|
||||
|
@ -70,8 +70,7 @@
|
||||
* Each FSM is described by an fsm structure and fsm callbacks.
|
||||
*/
|
||||
typedef struct fsm {
|
||||
int unit; /* Interface unit number */
|
||||
void *pcb; /* FIXME: Temporary */
|
||||
void *pcb; /* PPP Interface */ /* FIXME: try to use ppp_pcb here */
|
||||
int protocol; /* Data Link Layer Protocol field value */
|
||||
int state; /* State */
|
||||
int flags; /* Contains option bits */
|
||||
@ -159,14 +158,14 @@ typedef struct fsm_callbacks {
|
||||
/*
|
||||
* Prototypes
|
||||
*/
|
||||
void fsm_init (fsm *);
|
||||
void fsm_lowerup (fsm *);
|
||||
void fsm_lowerdown (fsm *);
|
||||
void fsm_open (fsm *);
|
||||
void fsm_close (fsm *, char *);
|
||||
void fsm_input (fsm *, u_char *, int);
|
||||
void fsm_protreject (fsm *);
|
||||
void fsm_sdata (fsm *, int, int, u_char *, int);
|
||||
void fsm_init(fsm *f);
|
||||
void fsm_lowerup(fsm *f);
|
||||
void fsm_lowerdown(fsm *f);
|
||||
void fsm_open(fsm *f);
|
||||
void fsm_close(fsm *f, char *reason);
|
||||
void fsm_input(fsm *f, u_char *inpacket, int l);
|
||||
void fsm_protreject(fsm *f);
|
||||
void fsm_sdata(fsm *f, u_char code, u_char id, u_char *data, int datalen);
|
||||
|
||||
|
||||
/*
|
||||
|
@ -590,7 +590,6 @@ static void ipcp_init(ppp_pcb *pcb) {
|
||||
ipcp_options *wo = &pcb->ipcp_wantoptions;
|
||||
ipcp_options *ao = &pcb->ipcp_allowoptions;
|
||||
|
||||
f->unit = pcb->unit;
|
||||
f->pcb = (void*)pcb;
|
||||
f->protocol = PPP_IPCP;
|
||||
f->callbacks = &ipcp_callbacks;
|
||||
@ -697,7 +696,7 @@ static void ipcp_protrej(ppp_pcb *pcb) {
|
||||
* Called by fsm_sconfreq, Send Configure Request.
|
||||
*/
|
||||
static void ipcp_resetci(fsm *f) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
ipcp_options *wo = &pcb->ipcp_wantoptions;
|
||||
ipcp_options *go = &pcb->ipcp_gotoptions;
|
||||
ipcp_options *ao = &pcb->ipcp_allowoptions;
|
||||
@ -730,7 +729,7 @@ static void ipcp_resetci(fsm *f) {
|
||||
* Called by fsm_sconfreq, Send Configure Request.
|
||||
*/
|
||||
static int ipcp_cilen(fsm *f) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
ipcp_options *go = &pcb->ipcp_gotoptions;
|
||||
ipcp_options *wo = &pcb->ipcp_wantoptions;
|
||||
ipcp_options *ho = &pcb->ipcp_hisoptions;
|
||||
@ -772,7 +771,7 @@ static int ipcp_cilen(fsm *f) {
|
||||
* Called by fsm_sconfreq, Send Configure Request.
|
||||
*/
|
||||
static void ipcp_addci(fsm *f, u_char *ucp, int *lenp) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
ipcp_options *go = &pcb->ipcp_gotoptions;
|
||||
int len = *lenp;
|
||||
|
||||
@ -875,7 +874,7 @@ static void ipcp_addci(fsm *f, u_char *ucp, int *lenp) {
|
||||
* 1 - Ack was good.
|
||||
*/
|
||||
static int ipcp_ackci(fsm *f, u_char *p, int len) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
ipcp_options *go = &pcb->ipcp_gotoptions;
|
||||
u_short cilen, citype, cishort;
|
||||
u_int32_t cilong;
|
||||
@ -996,7 +995,7 @@ bad:
|
||||
* 1 - Nak was good.
|
||||
*/
|
||||
static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
ipcp_options *go = &pcb->ipcp_gotoptions;
|
||||
u_char cimaxslotindex, cicflag;
|
||||
u_char citype, cilen, *next;
|
||||
@ -1240,7 +1239,7 @@ bad:
|
||||
* Callback from fsm_rconfnakrej.
|
||||
*/
|
||||
static int ipcp_rejci(fsm *f, u_char *p, int len) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
ipcp_options *go = &pcb->ipcp_gotoptions;
|
||||
u_char cimaxslotindex, ciflag, cilen;
|
||||
u_short cishort;
|
||||
@ -1390,7 +1389,7 @@ bad:
|
||||
* len = Length of requested CIs
|
||||
*/
|
||||
static int ipcp_reqci(fsm *f, u_char *inp, int *len, int reject_if_disagree) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
ipcp_options *wo = &pcb->ipcp_wantoptions;
|
||||
ipcp_options *ho = &pcb->ipcp_hisoptions;
|
||||
ipcp_options *ao = &pcb->ipcp_allowoptions;
|
||||
@ -1753,7 +1752,7 @@ ip_demand_conf(u)
|
||||
* Configure the IP network interface appropriately and bring it up.
|
||||
*/
|
||||
static void ipcp_up(fsm *f) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
u_int32_t mask;
|
||||
ipcp_options *ho = &pcb->ipcp_hisoptions;
|
||||
ipcp_options *go = &pcb->ipcp_gotoptions;
|
||||
@ -1912,12 +1911,12 @@ static void ipcp_up(fsm *f) {
|
||||
if (wo->default_route)
|
||||
if (sifdefaultroute(pcb, go->ouraddr, ho->hisaddr,
|
||||
wo->replace_default_route))
|
||||
default_route_set[f->unit] = 1;
|
||||
default_route_set[pcb->unit] = 1;
|
||||
|
||||
/* Make a proxy ARP entry if requested. */
|
||||
if (ho->hisaddr != 0 && wo->proxy_arp)
|
||||
if (sifproxyarp(pcb, ho->hisaddr))
|
||||
proxy_arp_set[f->unit] = 1;
|
||||
proxy_arp_set[pcb->unit] = 1;
|
||||
|
||||
wo->ouraddr = go->ouraddr;
|
||||
|
||||
@ -1954,7 +1953,7 @@ static void ipcp_up(fsm *f) {
|
||||
* and delete routes through it.
|
||||
*/
|
||||
static void ipcp_down(fsm *f) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
ipcp_options *ho = &pcb->ipcp_hisoptions;
|
||||
ipcp_options *go = &pcb->ipcp_gotoptions;
|
||||
|
||||
@ -1997,7 +1996,7 @@ static void ipcp_down(fsm *f) {
|
||||
{
|
||||
sifnpmode(pcb, PPP_IP, NPMODE_DROP);
|
||||
sifdown(pcb);
|
||||
ipcp_clear_addrs(f->unit, go->ouraddr,
|
||||
ipcp_clear_addrs(pcb->unit, go->ouraddr,
|
||||
ho->hisaddr, 0);
|
||||
cdns(pcb, go->dnsaddr[0], go->dnsaddr[1]);
|
||||
}
|
||||
@ -2036,7 +2035,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(fsm *f) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
if (ipcp_is_open) {
|
||||
ipcp_is_open = 0;
|
||||
np_finished(pcb, PPP_IP);
|
||||
|
@ -223,19 +223,19 @@ static u_char nak_buffer[PPP_MRU]; /* where we construct a nak packet */
|
||||
/*
|
||||
* Callbacks for fsm code. (CI = Configuration Information)
|
||||
*/
|
||||
static void lcp_resetci (fsm *); /* Reset our CI */
|
||||
static int lcp_cilen (fsm *); /* Return length of our CI */
|
||||
static void lcp_addci (fsm *, u_char *, int *); /* Add our CI to pkt */
|
||||
static int lcp_ackci (fsm *, u_char *, int); /* Peer ack'd our CI */
|
||||
static int lcp_nakci (fsm *, u_char *, int, int); /* Peer nak'd our CI */
|
||||
static int lcp_rejci (fsm *, u_char *, int); /* Peer rej'd our CI */
|
||||
static int lcp_reqci (fsm *, u_char *, int *, int); /* Rcv peer CI */
|
||||
static void lcp_up (fsm *); /* We're UP */
|
||||
static void lcp_down (fsm *); /* We're DOWN */
|
||||
static void lcp_resetci(fsm *f); /* Reset our CI */
|
||||
static int lcp_cilen(fsm *f); /* Return length of our CI */
|
||||
static void lcp_addci(fsm *f, u_char *ucp, int *lenp); /* Add our CI to pkt */
|
||||
static int lcp_ackci(fsm *f, u_char *p, int len); /* Peer ack'd our CI */
|
||||
static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject); /* Peer nak'd our CI */
|
||||
static int lcp_rejci(fsm *f, u_char *p, int len); /* Peer rej'd our CI */
|
||||
static int lcp_reqci(fsm *f, u_char *inp, int *lenp, int reject_if_disagree); /* Rcv peer CI */
|
||||
static void lcp_up(fsm *f); /* We're UP */
|
||||
static void lcp_down(fsm *f); /* We're DOWN */
|
||||
static void lcp_starting (fsm *); /* We need lower layer up */
|
||||
static void lcp_finished (fsm *); /* We need lower layer down */
|
||||
static int lcp_extcode (fsm *, int, int, u_char *, int);
|
||||
static void lcp_rprotrej (fsm *, u_char *, int);
|
||||
static int lcp_extcode(fsm *f, int code, int id, u_char *inp, int len);
|
||||
static void lcp_rprotrej(fsm *f, u_char *inp, int len);
|
||||
|
||||
/*
|
||||
* routines to send LCP echos to peer
|
||||
@ -243,11 +243,11 @@ static void lcp_rprotrej (fsm *, u_char *, int);
|
||||
|
||||
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 *);
|
||||
static void LcpLinkFailure (fsm *);
|
||||
static void LcpEchoCheck (fsm *);
|
||||
static void LcpEchoTimeout(void *arg);
|
||||
static void lcp_received_echo_reply(fsm *f, int id, u_char *inp, int len);
|
||||
static void LcpSendEchoRequest(fsm *f);
|
||||
static void LcpLinkFailure(fsm *f);
|
||||
static void LcpEchoCheck(fsm *f);
|
||||
|
||||
static fsm_callbacks lcp_callbacks = { /* LCP callback routines */
|
||||
lcp_resetci, /* Reset our Configuration Information */
|
||||
@ -374,7 +374,6 @@ static void lcp_init(ppp_pcb *pcb) {
|
||||
lcp_options *wo = &pcb->lcp_wantoptions;
|
||||
lcp_options *ao = &pcb->lcp_allowoptions;
|
||||
|
||||
f->unit = pcb->unit;
|
||||
f->pcb = (void*)pcb;
|
||||
f->protocol = PPP_LCP;
|
||||
f->callbacks = &lcp_callbacks;
|
||||
@ -499,7 +498,7 @@ void lcp_lowerup(ppp_pcb *pcb) {
|
||||
peer_mru[pcb->unit] = PPP_MRU;
|
||||
|
||||
#if PPPOS_SUPPORT
|
||||
ao->asyncmap = (u_long)xmit_accm[f->unit][0]
|
||||
ao->asyncmap = (u_long)xmit_accm[pcb->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);
|
||||
@ -562,14 +561,8 @@ static void lcp_input(ppp_pcb *pcb, u_char *p, int len) {
|
||||
/*
|
||||
* lcp_extcode - Handle a LCP-specific code.
|
||||
*/
|
||||
static int
|
||||
lcp_extcode(f, code, id, inp, len)
|
||||
fsm *f;
|
||||
int code, id;
|
||||
u_char *inp;
|
||||
int len;
|
||||
{
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
static int lcp_extcode(fsm *f, int code, int id, u_char *inp, int len) {
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
u_char *magp;
|
||||
|
||||
@ -607,12 +600,7 @@ lcp_extcode(f, code, id, inp, len)
|
||||
*
|
||||
* Figure out which protocol is rejected and inform it.
|
||||
*/
|
||||
static void
|
||||
lcp_rprotrej(f, inp, len)
|
||||
fsm *f;
|
||||
u_char *inp;
|
||||
int len;
|
||||
{
|
||||
static void lcp_rprotrej(fsm *f, u_char *inp, int len) {
|
||||
int i;
|
||||
struct protent *protp;
|
||||
u_short prot;
|
||||
@ -699,11 +687,8 @@ void lcp_sprotrej(ppp_pcb *pcb, u_char *p, int len) {
|
||||
/*
|
||||
* lcp_resetci - Reset our CI.
|
||||
*/
|
||||
static void
|
||||
lcp_resetci(f)
|
||||
fsm *f;
|
||||
{
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
static void lcp_resetci(fsm *f) {
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
lcp_options *wo = &pcb->lcp_wantoptions;
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
lcp_options *ao = &pcb->lcp_allowoptions;
|
||||
@ -722,7 +707,7 @@ lcp_resetci(f)
|
||||
#endif /* HAVE_MULTILINK */
|
||||
if (noendpoint)
|
||||
ao->neg_endpoint = 0;
|
||||
peer_mru[f->unit] = PPP_MRU;
|
||||
peer_mru[pcb->unit] = PPP_MRU;
|
||||
auth_reset(pcb);
|
||||
}
|
||||
|
||||
@ -730,11 +715,8 @@ lcp_resetci(f)
|
||||
/*
|
||||
* lcp_cilen - Return length of our CI.
|
||||
*/
|
||||
static int
|
||||
lcp_cilen(f)
|
||||
fsm *f;
|
||||
{
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
static int lcp_cilen(fsm *f) {
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
|
||||
#define LENCIVOID(neg) ((neg) ? CILEN_VOID : 0)
|
||||
@ -795,13 +777,8 @@ lcp_cilen(f)
|
||||
/*
|
||||
* lcp_addci - Add our desired CIs to a packet.
|
||||
*/
|
||||
static void
|
||||
lcp_addci(f, ucp, lenp)
|
||||
fsm *f;
|
||||
u_char *ucp;
|
||||
int *lenp;
|
||||
{
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
static void lcp_addci(fsm *f, u_char *ucp, int *lenp) {
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
u_char *start_ucp = ucp;
|
||||
|
||||
@ -911,13 +888,8 @@ lcp_addci(f, ucp, lenp)
|
||||
* 0 - Ack was bad.
|
||||
* 1 - Ack was good.
|
||||
*/
|
||||
static int
|
||||
lcp_ackci(f, p, len)
|
||||
fsm *f;
|
||||
u_char *p;
|
||||
int len;
|
||||
{
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
static int lcp_ackci(fsm *f, u_char *p, int len) {
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
u_char cilen, citype, cichar;
|
||||
u_short cishort;
|
||||
@ -1094,14 +1066,8 @@ bad:
|
||||
* 0 - Nak was bad.
|
||||
* 1 - Nak was good.
|
||||
*/
|
||||
static int
|
||||
lcp_nakci(f, p, len, treat_as_reject)
|
||||
fsm *f;
|
||||
u_char *p;
|
||||
int len;
|
||||
int treat_as_reject;
|
||||
{
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) {
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
lcp_options *wo = &pcb->lcp_wantoptions;
|
||||
u_char citype, cichar, *next;
|
||||
@ -1553,13 +1519,8 @@ bad:
|
||||
* 0 - Reject was bad.
|
||||
* 1 - Reject was good.
|
||||
*/
|
||||
static int
|
||||
lcp_rejci(f, p, len)
|
||||
fsm *f;
|
||||
u_char *p;
|
||||
int len;
|
||||
{
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
static int lcp_rejci(fsm *f, u_char *p, int len) {
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
u_char cichar;
|
||||
u_short cishort;
|
||||
@ -1783,15 +1744,12 @@ 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
|
||||
* lenp = Length of requested CIs
|
||||
*/
|
||||
static int
|
||||
lcp_reqci(f, inp, lenp, reject_if_disagree)
|
||||
fsm *f;
|
||||
u_char *inp; /* Requested CIs */
|
||||
int *lenp; /* Length of requested CIs */
|
||||
int reject_if_disagree;
|
||||
{
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
static int lcp_reqci(fsm *f, u_char *inp, int *lenp, int reject_if_disagree) {
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
lcp_options *ho = &pcb->lcp_hisoptions;
|
||||
lcp_options *ao = &pcb->lcp_allowoptions;
|
||||
@ -2248,11 +2206,8 @@ endswitch:
|
||||
/*
|
||||
* lcp_up - LCP has come UP.
|
||||
*/
|
||||
static void
|
||||
lcp_up(f)
|
||||
fsm *f;
|
||||
{
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
static void lcp_up(fsm *f) {
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
lcp_options *wo = &pcb->lcp_wantoptions;
|
||||
lcp_options *ho = &pcb->lcp_hisoptions;
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
@ -2287,7 +2242,7 @@ lcp_up(f)
|
||||
go->neg_pcompression, go->neg_accompression);
|
||||
|
||||
if (ho->neg_mru)
|
||||
peer_mru[f->unit] = ho->mru;
|
||||
peer_mru[pcb->unit] = ho->mru;
|
||||
|
||||
lcp_echo_lowerup(f->pcb); /* Enable echo messages */
|
||||
|
||||
@ -2300,11 +2255,8 @@ lcp_up(f)
|
||||
*
|
||||
* Alert other protocols.
|
||||
*/
|
||||
static void
|
||||
lcp_down(f)
|
||||
fsm *f;
|
||||
{
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
static void lcp_down(fsm *f) {
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
|
||||
lcp_echo_lowerdown(f->pcb);
|
||||
@ -2315,7 +2267,7 @@ lcp_down(f)
|
||||
ppp_recv_config(pcb, PPP_MRU,
|
||||
(go->neg_asyncmap? go->asyncmap: 0xffffffff),
|
||||
go->neg_pcompression, go->neg_accompression);
|
||||
peer_mru[f->unit] = PPP_MRU;
|
||||
peer_mru[pcb->unit] = PPP_MRU;
|
||||
}
|
||||
|
||||
|
||||
@ -2323,7 +2275,7 @@ lcp_down(f)
|
||||
* lcp_starting - LCP needs the lower layer up.
|
||||
*/
|
||||
static void lcp_starting(fsm *f) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
link_required(pcb);
|
||||
}
|
||||
|
||||
@ -2332,7 +2284,7 @@ static void lcp_starting(fsm *f) {
|
||||
* lcp_finished - LCP has finished with the lower layer.
|
||||
*/
|
||||
static void lcp_finished(fsm *f) {
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
link_terminated(pcb);
|
||||
}
|
||||
|
||||
@ -2597,11 +2549,8 @@ static int lcp_printpkt(u_char *p, int plen,
|
||||
* Time to shut down the link because there is nothing out there.
|
||||
*/
|
||||
|
||||
static
|
||||
void LcpLinkFailure (f)
|
||||
fsm *f;
|
||||
{
|
||||
ppp_pcb *pc = &ppp_pcb_list[f->unit];
|
||||
static void LcpLinkFailure(fsm *f) {
|
||||
ppp_pcb *pc = f->pcb;
|
||||
if (f->state == OPENED) {
|
||||
info("No response to %d echo-requests", lcp_echos_pending);
|
||||
notice("Serial link appears to be disconnected.");
|
||||
@ -2614,10 +2563,7 @@ void LcpLinkFailure (f)
|
||||
* Timer expired for the LCP echo requests from this process.
|
||||
*/
|
||||
|
||||
static void
|
||||
LcpEchoCheck (f)
|
||||
fsm *f;
|
||||
{
|
||||
static void LcpEchoCheck(fsm *f) {
|
||||
LcpSendEchoRequest (f);
|
||||
if (f->state != OPENED)
|
||||
return;
|
||||
@ -2635,10 +2581,7 @@ LcpEchoCheck (f)
|
||||
* LcpEchoTimeout - Timer expired on the LCP echo
|
||||
*/
|
||||
|
||||
static void
|
||||
LcpEchoTimeout (arg)
|
||||
void *arg;
|
||||
{
|
||||
static void LcpEchoTimeout(void *arg) {
|
||||
if (lcp_echo_timer_running != 0) {
|
||||
lcp_echo_timer_running = 0;
|
||||
LcpEchoCheck ((fsm *) arg);
|
||||
@ -2649,14 +2592,8 @@ LcpEchoTimeout (arg)
|
||||
* LcpEchoReply - LCP has received a reply to the echo
|
||||
*/
|
||||
|
||||
static void
|
||||
lcp_received_echo_reply (f, id, inp, len)
|
||||
fsm *f;
|
||||
int id;
|
||||
u_char *inp;
|
||||
int len;
|
||||
{
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
static void lcp_received_echo_reply(fsm *f, int id, u_char *inp, int len) {
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
u_int32_t magic;
|
||||
|
||||
@ -2680,11 +2617,8 @@ lcp_received_echo_reply (f, id, inp, len)
|
||||
* LcpSendEchoRequest - Send an echo request frame to the peer
|
||||
*/
|
||||
|
||||
static void
|
||||
LcpSendEchoRequest (f)
|
||||
fsm *f;
|
||||
{
|
||||
ppp_pcb *pcb = &ppp_pcb_list[f->unit];
|
||||
static void LcpSendEchoRequest(fsm *f) {
|
||||
ppp_pcb *pcb = f->pcb;
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
u_int32_t lcp_magic;
|
||||
u_char pkt[4], *pktp;
|
||||
|
Loading…
x
Reference in New Issue
Block a user