From 444646b65edbf3fc6449e9e0a07bda6979cee5c3 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Sat, 9 Jun 2012 23:06:45 +0200 Subject: [PATCH] renamed ppp_control to ppp_pcb, replaced unit number to ppp_pcb in all ppp.h declared functions --- src/netif/ppp/auth.c | 22 +-- src/netif/ppp/chap-new.c | 2 +- src/netif/ppp/eap.c | 2 +- src/netif/ppp/ipcp.c | 4 +- src/netif/ppp/lcp.c | 8 +- src/netif/ppp/ppp.c | 291 +++++++++++++++++++-------------------- src/netif/ppp/ppp.h | 92 +++++++++++-- src/netif/ppp/ppp_impl.h | 67 +-------- src/netif/ppp/upap.c | 2 +- 9 files changed, 244 insertions(+), 246 deletions(-) diff --git a/src/netif/ppp/auth.c b/src/netif/ppp/auth.c index b0183508..7e5d546b 100644 --- a/src/netif/ppp/auth.c +++ b/src/netif/ppp/auth.c @@ -633,7 +633,7 @@ void link_terminated(unit) int unit; { - ppp_control *pc = &ppp_control_list[unit]; + ppp_pcb *pc = &ppp_pcb_list[unit]; if (pc->phase == PHASE_DEAD || pc->phase == PHASE_MASTER) return; new_phase(unit, PHASE_DISCONNECT); @@ -712,7 +712,7 @@ void link_down(unit) int unit; { - ppp_control *pc = &ppp_control_list[unit]; + ppp_pcb *pc = &ppp_pcb_list[unit]; #if PPP_NOTIFY notify(link_down_notifier, 0); #endif /* #if PPP_NOTIFY */ @@ -763,7 +763,7 @@ link_established(unit) lcp_options *ho = &lcp_hisoptions[unit]; int i; struct protent *protp; - ppp_control *pc = &ppp_control_list[unit]; + ppp_pcb *pc = &ppp_pcb_list[unit]; /* * Tell higher-level protocols that LCP is up. @@ -1114,7 +1114,7 @@ void auth_withpeer_fail(unit, protocol) int unit, protocol; { - ppp_control *pc = &ppp_control_list[unit]; + ppp_pcb *pcb = &ppp_pcb_list[unit]; int errcode = PPPERR_AUTHFAIL; /* * We've failed to authenticate ourselves to our peer. @@ -1122,14 +1122,14 @@ auth_withpeer_fail(unit, protocol) * is no point in persisting without any way to get updated * authentication secrets. */ - pc->status = EXIT_AUTH_TOPEER_FAILED; + pcb->status = EXIT_AUTH_TOPEER_FAILED; /* * We've failed to authenticate ourselves to our peer. * He'll probably take the link down, and there's not much * we can do except wait for that. */ - ppp_ioctl(unit, PPPCTLS_ERRCODE, &errcode); + ppp_ioctl(pcb, PPPCTLS_ERRCODE, &errcode); lcp_close(unit, "Failed to authenticate ourselves to peer"); } @@ -1203,7 +1203,7 @@ np_up(unit, proto) int unit, proto; { int tlim; - ppp_control *pc = &ppp_control_list[unit]; + ppp_pcb *pc = &ppp_pcb_list[unit]; if (num_np_up == 0) { /* @@ -1323,7 +1323,7 @@ check_idle(arg) void *arg; { /* FIXME: fix forced unit 0 */ - ppp_control *pc = &ppp_control_list[0]; + ppp_pcb *pc = &ppp_pcb_list[0]; struct ppp_idle idle; time_t itime; int tlim; @@ -1361,7 +1361,7 @@ connect_time_expired(arg) void *arg; { /* FIXME: fix forced unit 0 */ - ppp_control *pc = &ppp_control_list[0]; + ppp_pcb *pc = &ppp_pcb_list[0]; info("Connect time expired"); pc->status = EXIT_CONNECT_TIME; lcp_close(0, "Connect time expired"); /* Close connection */ @@ -1517,7 +1517,7 @@ auth_reset(unit) { lcp_options *go = &lcp_gotoptions[unit]; lcp_options *ao = &lcp_allowoptions[unit]; - ppp_control *pc = &ppp_control_list[unit]; + ppp_pcb *pc = &ppp_pcb_list[unit]; if( pc->settings.passwd[0] ) { @@ -1990,7 +1990,7 @@ get_secret(unit, client, server, secret, secret_len, am_server) int am_server; { int len; - ppp_control *pc = &ppp_control_list[unit]; + ppp_pcb *pc = &ppp_pcb_list[unit]; LWIP_UNUSED_ARG(unit); LWIP_UNUSED_ARG(server); diff --git a/src/netif/ppp/chap-new.c b/src/netif/ppp/chap-new.c index 0251d0ff..62556c52 100644 --- a/src/netif/ppp/chap-new.c +++ b/src/netif/ppp/chap-new.c @@ -480,7 +480,7 @@ chap_respond(struct chap_client_state *cs, int id, unsigned char response[RESP_MAX_PKTLEN]; char rname[MAXNAMELEN+1]; char secret[MAXSECRETLEN+1]; - ppp_control *pc = &ppp_control_list[0]; + ppp_pcb *pc = &ppp_pcb_list[0]; if ((cs->flags & (LOWERUP | AUTH_STARTED)) != (LOWERUP | AUTH_STARTED)) return; /* not ready */ diff --git a/src/netif/ppp/eap.c b/src/netif/ppp/eap.c index 5f6f0001..0e382313 100644 --- a/src/netif/ppp/eap.c +++ b/src/netif/ppp/eap.c @@ -1333,7 +1333,7 @@ u_char *inp; int id; int len; { - ppp_control *pc = &ppp_control_list[esp->es_unit]; + ppp_pcb *pc = &ppp_pcb_list[esp->es_unit]; u_char typenum; u_char vallen; int secret_len; diff --git a/src/netif/ppp/ipcp.c b/src/netif/ppp/ipcp.c index 1ab2d95f..2434b5f1 100644 --- a/src/netif/ppp/ipcp.c +++ b/src/netif/ppp/ipcp.c @@ -721,7 +721,7 @@ static void ipcp_resetci(f) fsm *f; { - ppp_control *pc = &ppp_control_list[f->unit]; + ppp_pcb *pc = &ppp_pcb_list[f->unit]; ipcp_options *wo = &ipcp_wantoptions[f->unit]; ipcp_options *go = &ipcp_gotoptions[f->unit]; ipcp_options *ao = &ipcp_allowoptions[f->unit]; @@ -1801,7 +1801,7 @@ ipcp_up(f) fsm *f; { u_int32_t mask; - ppp_control *pc = &ppp_control_list[f->unit]; + ppp_pcb *pc = &ppp_pcb_list[f->unit]; ipcp_options *ho = &ipcp_hisoptions[f->unit]; ipcp_options *go = &ipcp_gotoptions[f->unit]; ipcp_options *wo = &ipcp_wantoptions[f->unit]; diff --git a/src/netif/ppp/lcp.c b/src/netif/ppp/lcp.c index 8a38f119..9fb77307 100644 --- a/src/netif/ppp/lcp.c +++ b/src/netif/ppp/lcp.c @@ -462,7 +462,7 @@ lcp_close(unit, reason) int unit; char *reason; { - ppp_control *pc = &ppp_control_list[unit]; + ppp_pcb *pc = &ppp_pcb_list[unit]; fsm *f = &lcp_fsm[unit]; int oldstate; @@ -499,7 +499,7 @@ lcp_lowerup(unit) { lcp_options *wo = &lcp_wantoptions[unit]; fsm *f = &lcp_fsm[unit]; - ppp_control *pc = &ppp_control_list[unit]; + ppp_pcb *pc = &ppp_pcb_list[unit]; /* * Don't use A/C or protocol compression on transmission, * but accept A/C and protocol compressed packets @@ -1129,7 +1129,7 @@ lcp_nakci(f, p, len, treat_as_reject) int len; int treat_as_reject; { - ppp_control *pc = &ppp_control_list[f->unit]; + ppp_pcb *pc = &ppp_pcb_list[f->unit]; lcp_options *go = &lcp_gotoptions[f->unit]; lcp_options *wo = &lcp_wantoptions[f->unit]; u_char citype, cichar, *next; @@ -2632,7 +2632,7 @@ static void LcpLinkFailure (f) fsm *f; { - ppp_control *pc = &ppp_control_list[f->unit]; + ppp_pcb *pc = &ppp_pcb_list[f->unit]; if (f->state == OPENED) { info("No response to %d echo-requests", lcp_echos_pending); notice("Serial link appears to be disconnected."); diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index ea32cf62..6b5ea415 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -242,9 +242,9 @@ static void ppp_hup(int pd); #if PPP_INPROC_OWNTHREAD static void ppp_input_thread(void *arg); #endif /* PPP_INPROC_OWNTHREAD */ -static void ppp_drop(ppp_control_rx *pcrx); -static void pppos_input_proc(ppp_control_rx *pcrx, u_char *s, int l); -static void ppp_free_current_input_packet(ppp_control_rx *pcrx); +static void ppp_drop(ppp_pcb_rx *pcrx); +static void pppos_input_proc(ppp_pcb_rx *pcrx, u_char *s, int l); +static void ppp_free_current_input_packet(ppp_pcb_rx *pcrx); #endif /* PPPOS_SUPPORT */ static err_t ppp_netif_init_cb(struct netif *netif); @@ -293,30 +293,30 @@ int ppp_init(void) { } /* Create a new PPP session. */ -int ppp_new(void) { +ppp_pcb *ppp_new(void) { int i, pd; - ppp_control *pc; + ppp_pcb *pcb; struct protent *protp; /* Find a free PPP session descriptor. */ - for (pd = 0; pd < NUM_PPP && ppp_control_list[pd].open_flag != 0; pd++); + for (pd = 0; pd < NUM_PPP && ppp_pcb_list[pd].open_flag != 0; pd++); if (pd >= NUM_PPP) - return PPPERR_OPEN; + return NULL; - pc = &ppp_control_list[pd]; + pcb = &ppp_pcb_list[pd]; #if PPP_STATS_SUPPORT link_stats_valid = 0; #endif /* PPP_STATS_SUPPORT */ - memset(pc, 0, sizeof(ppp_control)); - pc->open_flag = 1; - pc->status = EXIT_OK; + memset(pcb, 0, sizeof(ppp_pcb)); + pcb->unit = pd; + pcb->open_flag = 1; + pcb->status = EXIT_OK; new_phase(pd, PHASE_INITIALIZE); - /* memset(&pc->settings, 0, sizeof(ppp_settings)); -- already done previously */ - pc->settings.usepeerdns = 1; - pc->settings.persist = 1; + pcb->settings.usepeerdns = 1; + pcb->settings.persist = 1; /* * Initialize each protocol. @@ -324,47 +324,46 @@ int ppp_new(void) { for (i = 0; (protp = protocols[i]) != NULL; ++i) (*protp->init)(pd); - return pd; + return pcb; } -void ppp_set_auth(int unit, enum ppp_auth_type authtype, const char *user, const char *passwd) { - ppp_control *pc = &ppp_control_list[unit]; +void ppp_set_auth(ppp_pcb *pcb, enum ppp_auth_type authtype, const char *user, const char *passwd) { /* FIXME: the following may look stupid, but this is just an easy way * to check different auth by changing compile time option */ #if PAP_SUPPORT - pc->settings.refuse_pap = 0; + pcb->settings.refuse_pap = 0; #endif /* PAP_SUPPORT */ #if CHAP_SUPPORT #if PAP_SUPPORT - pc->settings.refuse_pap = 1; + pcb->settings.refuse_pap = 1; #endif /* PAP_SUPPORT */ - pc->settings.refuse_chap = 0; + pcb->settings.refuse_chap = 0; #endif /* CHAP_SUPPORT */ #if MSCHAP_SUPPORT #if PAP_SUPPORT - pc->settings.refuse_pap = 1; + pcb->settings.refuse_pap = 1; #endif /* PAP_SUPPORT */ - pc->settings.refuse_chap = 1; - pc->settings.refuse_mschap = 1; - pc->settings.refuse_mschap_v2 = 0; + pcb->settings.refuse_chap = 1; + pcb->settings.refuse_mschap = 1; + pcb->settings.refuse_mschap_v2 = 0; #endif /* MSCHAP_SUPPORT */ #if EAP_SUPPORT #if PAP_SUPPORT - pc->settings.refuse_pap = 1; + pcb->settings.refuse_pap = 1; #endif/* PAP_SUPPORT */ #if CHAP_SUPPORT - pc->settings.refuse_chap = 1; + pcb->settings.refuse_chap = 1; #if MSCHAP_SUPPORT - pc->settings.refuse_mschap = 1; - pc->settings.refuse_mschap_v2 = 1; + pcb->settings.refuse_mschap = 1; + pcb->settings.refuse_mschap_v2 = 1; #endif /* MSCHAP_SUPPORT */ #endif /* CHAP_SUPPORT */ - pc->settings.refuse_eap = 0; + pcb->settings.refuse_eap = 0; #endif /* EAP_SUPPORT */ /* FIXME: re-enable that */ @@ -418,17 +417,17 @@ void ppp_set_auth(int unit, enum ppp_auth_type authtype, const char *user, const #endif if(user) { - strncpy(pc->settings.user, user, sizeof(pc->settings.user)-1); - pc->settings.user[sizeof(pc->settings.user)-1] = '\0'; + strncpy(pcb->settings.user, user, sizeof(pcb->settings.user)-1); + pcb->settings.user[sizeof(pcb->settings.user)-1] = '\0'; } else { - pc->settings.user[0] = '\0'; + pcb->settings.user[0] = '\0'; } if(passwd) { - strncpy(pc->settings.passwd, passwd, sizeof(pc->settings.passwd)-1); - pc->settings.passwd[sizeof(pc->settings.passwd)-1] = '\0'; + strncpy(pcb->settings.passwd, passwd, sizeof(pcb->settings.passwd)-1); + pcb->settings.passwd[sizeof(pcb->settings.passwd)-1] = '\0'; } else { - pc->settings.passwd[0] = '\0'; + pcb->settings.passwd[0] = '\0'; } } @@ -443,8 +442,7 @@ void ppp_set_auth(int unit, enum ppp_auth_type authtype, const char *user, const * * pppOpen() is directly defined to this function. */ -int ppp_over_serial_open(int unit, sio_fd_t fd, ppp_link_status_cb_fn link_status_cb, void *link_status_ctx) { - ppp_control *pc = &ppp_control_list[unit]; +int ppp_over_serial_open(ppp_pcb *pcb, sio_fd_t fd, ppp_link_status_cb_fn link_status_cb, void *link_status_ctx) { /* PPP is single-threaded: without a callback, * there is no way to know when the link is up. */ @@ -452,26 +450,26 @@ int ppp_over_serial_open(int unit, sio_fd_t fd, ppp_link_status_cb_fn link_statu return PPPERR_PARAM; /* input pbuf left over from last session? */ - ppp_free_current_input_packet(&pc->rx); + ppp_free_current_input_packet(&pcb->rx); - pc->fd = fd; + pcb->fd = fd; - pc->rx.pd = unit; - pc->rx.fd = fd; + pcb->rx.pd = unit; + pcb->rx.fd = fd; #if VJ_SUPPORT - vj_compress_init(&pc->vj_comp); + vj_compress_init(&pcb->vj_comp); #endif /* VJ_SUPPORT */ /* * Default the in and out accm so that escape and flag characters * are always escaped. */ - pc->rx.in_accm[15] = 0x60; /* no need to protect since RX is not running */ - pc->out_accm[15] = 0x60; + pcb->rx.in_accm[15] = 0x60; /* no need to protect since RX is not running */ + pcb->out_accm[15] = 0x60; - pc->link_status_cb = link_status_cb; - pc->link_status_ctx = link_status_ctx; + pcb->link_status_cb = link_status_cb; + pcb->link_status_ctx = link_status_ctx; /* * Start the connection and handle incoming events (packet or timeout). @@ -479,7 +477,7 @@ int ppp_over_serial_open(int unit, sio_fd_t fd, ppp_link_status_cb_fn link_statu PPPDEBUG(LOG_INFO, ("ppp_over_serial_open: unit %d: Connecting\n", pd)); ppp_start(unit); #if PPP_INPROC_OWNTHREAD - sys_thread_new(PPP_THREAD_NAME, ppp_input_thread, (void*)&pc->rx, PPP_THREAD_STACKSIZE, PPP_THREAD_PRIO); + sys_thread_new(PPP_THREAD_NAME, ppp_input_thread, (void*)&pcb->rx, PPP_THREAD_STACKSIZE, PPP_THREAD_PRIO); #endif /* PPP_INPROC_OWNTHREAD */ return unit; @@ -489,22 +487,21 @@ int ppp_over_serial_open(int unit, sio_fd_t fd, ppp_link_status_cb_fn link_statu * ppp_set_xaccm - set the extended transmit ACCM for the interface. */ void ppp_set_xaccm(int unit, ext_accm *accm) { - SMEMCPY(ppp_control_list[unit].out_accm, accm, sizeof(ext_accm)); + SMEMCPY(ppp_pcb_list[unit].out_accm, accm, sizeof(ext_accm)); PPPDEBUG(LOG_INFO, ("ppp_set_xaccm[%d]: out_accm=%X %X %X %X\n", unit, - ppp_control_list[unit].out_accm[0], - ppp_control_list[unit].out_accm[1], - ppp_control_list[unit].out_accm[2], - ppp_control_list[unit].out_accm[3])); + ppp_pcb_list[unit].out_accm[0], + ppp_pcb_list[unit].out_accm[1], + ppp_pcb_list[unit].out_accm[2], + ppp_pcb_list[unit].out_accm[3])); } #endif /* PPPOS_SUPPORT */ #if PPPOE_SUPPORT static void ppp_over_ethernet_link_status_cb(int pd, int state); -int ppp_over_ethernet_open(int unit, 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_control *pc = &ppp_control_list[unit]; LWIP_UNUSED_ARG(service_name); LWIP_UNUSED_ARG(concentrator_name); @@ -514,38 +511,38 @@ int ppp_over_ethernet_open(int unit, struct netif *ethif, const char *service_na if (link_status_cb == NULL) return PPPERR_PARAM; - pc->ethif = ethif; + pcb->ethif = ethif; - pc->link_status_cb = link_status_cb; - pc->link_status_ctx = link_status_ctx; + pcb->link_status_cb = link_status_cb; + pcb->link_status_ctx = link_status_ctx; - lcp_wantoptions[unit].mru = ethif->mtu-PPPOE_HEADERLEN-2; /* two byte PPP protocol discriminator, then IP data */ - lcp_wantoptions[unit].neg_asyncmap = 0; - lcp_wantoptions[unit].neg_pcompression = 0; - lcp_wantoptions[unit].neg_accompression = 0; + lcp_wantoptions[pcb->unit].mru = ethif->mtu-PPPOE_HEADERLEN-2; /* two byte PPP protocol discriminator, then IP data */ + lcp_wantoptions[pcb->unit].neg_asyncmap = 0; + lcp_wantoptions[pcb->unit].neg_pcompression = 0; + lcp_wantoptions[pcb->unit].neg_accompression = 0; - lcp_allowoptions[unit].mru = ethif->mtu-PPPOE_HEADERLEN-2; /* two byte PPP protocol discriminator, then IP data */ - lcp_allowoptions[unit].neg_asyncmap = 0; - lcp_allowoptions[unit].neg_pcompression = 0; - lcp_allowoptions[unit].neg_accompression = 0; + lcp_allowoptions[pcb->unit].mru = ethif->mtu-PPPOE_HEADERLEN-2; /* two byte PPP protocol discriminator, then IP data */ + lcp_allowoptions[pcb->unit].neg_asyncmap = 0; + lcp_allowoptions[pcb->unit].neg_pcompression = 0; + lcp_allowoptions[pcb->unit].neg_accompression = 0; - if(pppoe_create(ethif, unit, ppp_over_ethernet_link_status_cb, &pc->pppoe_sc) != ERR_OK) { - pc->open_flag = 0; + if(pppoe_create(ethif, pcb->unit, ppp_over_ethernet_link_status_cb, &pcb->pppoe_sc) != ERR_OK) { + pcb->open_flag = 0; return PPPERR_OPEN; } - pppoe_connect(pc->pppoe_sc, pc->settings.persist); - return unit; + pppoe_connect(pcb->pppoe_sc, pcb->settings.persist); + return pcb->unit; } #if 0 /* UNUSED */ void ppp_over_ethernet_close(int pd) { - ppp_control* pc = &ppp_control_list[pd]; + ppp_pcb* pc = &ppp_pcb_list[pd]; /* *TJL* There's no lcp_deinit */ lcp_close(pd, NULL); - pppoe_destroy(&pc->netif); + pppoe_destroy(&pcb->netif); } #endif /* UNUSED */ #endif /* PPPOE_SUPPORT */ @@ -555,30 +552,29 @@ void ppp_over_ethernet_close(int pd) { * Any outstanding packets in the queues are dropped. * Return 0 on success, an error code on failure. */ int -ppp_close(int pd) +ppp_close(ppp_pcb *pcb) { - ppp_control *pc = &ppp_control_list[pd]; int st = 0; PPPDEBUG(LOG_DEBUG, ("ppp_close() called\n")); /* Disconnect */ #if PPPOE_SUPPORT - if(pc->ethif) { - PPPDEBUG(LOG_DEBUG, ("ppp_close: unit %d kill_link -> ppp_stop\n", pd)); - pc->err_code = PPPERR_USER; + if(pcb->ethif) { + PPPDEBUG(LOG_DEBUG, ("ppp_close: unit %d kill_link -> ppp_stop\n", pcb->unit)); + pcb->err_code = PPPERR_USER; /* This will leave us at PHASE_DEAD. */ - ppp_stop(pd); + ppp_stop(pcb->unit); } else #endif /* PPPOE_SUPPORT */ { #if PPPOS_SUPPORT - PPPDEBUG(LOG_DEBUG, ("ppp_close: unit %d kill_link -> ppp_stop\n", pd)); - pc->err_code = PPPERR_USER; + PPPDEBUG(LOG_DEBUG, ("ppp_close: unit %d kill_link -> ppp_stop\n", pcb->unit)); + pcb->err_code = PPPERR_USER; /* This will leave us at PHASE_DEAD. */ - ppp_stop(pd); + ppp_stop(pcb->unit); #if PPP_INPROC_OWNTHREAD - ppp_receive_wakeup(pd); + ppp_receive_wakeup(pcb->unit); #endif /* PPP_INPROC_OWNTHREAD */ #endif /* PPPOS_SUPPORT */ } @@ -588,10 +584,10 @@ ppp_close(int pd) /* This function is called when carrier is lost on the PPP channel. */ void -ppp_sighup(int pd) +ppp_sighup(ppp_pcb *pcb) { - PPPDEBUG(LOG_DEBUG, ("ppp_sighup: unit %d sig_hup -> ppp_hup\n", pd)); - ppp_hup(pd); + PPPDEBUG(LOG_DEBUG, ("ppp_sighup: unit %d sig_hup -> ppp_hup\n", pcb->unit)); + ppp_hup(pcb->unit); } @@ -632,7 +628,7 @@ ppp_hup(int pd) * or it is used in output ? have to find out... */ static void ppp_input(int unit, void *arg) { - ppp_control *pc = &ppp_control_list[unit]; + ppp_pcb *pc = &ppp_pcb_list[unit]; struct pbuf *nb = (struct pbuf *)arg; u16_t protocol; int pd; @@ -646,8 +642,8 @@ static void ppp_input(int unit, void *arg) { } LINK_STATS_INC(link.recv); - snmp_inc_ifinucastpkts(&ppp_control_list[pd].netif); - snmp_add_ifinoctets(&ppp_control_list[pd].netif, nb->tot_len); + snmp_inc_ifinucastpkts(&ppp_pcb_list[pd].netif); + snmp_add_ifinoctets(&ppp_pcb_list[pd].netif, nb->tot_len); /* * Toss all non-LCP packets unless LCP is OPEN. @@ -692,8 +688,8 @@ static void ppp_input(int unit, void *arg) { * Clip off the VJ header and prepend the rebuilt TCP/IP header and * pass the result to IP. */ - if ((vj_uncompress_tcp(&nb, &ppp_control_list[pd].vj_comp) >= 0) && (ppp_control_list[pd].netif.input)) { - ppp_control_list[pd].netif.input(nb, &ppp_control_list[pd].netif); + if ((vj_uncompress_tcp(&nb, &ppp_pcb_list[pd].vj_comp) >= 0) && (ppp_pcb_list[pd].netif.input)) { + ppp_pcb_list[pd].netif.input(nb, &ppp_pcb_list[pd].netif); return; } /* Something's wrong so drop it. */ @@ -706,8 +702,8 @@ static void ppp_input(int unit, void *arg) { * Process the TCP/IP header for VJ header compression and then pass * the packet to IP. */ - if ((vj_uncompress_uncomp(nb, &ppp_control_list[pd].vj_comp) >= 0) && ppp_control_list[pd].netif.input) { - ppp_control_list[pd].netif.input(nb, &ppp_control_list[pd].netif); + if ((vj_uncompress_uncomp(nb, &ppp_pcb_list[pd].vj_comp) >= 0) && ppp_pcb_list[pd].netif.input) { + ppp_pcb_list[pd].netif.input(nb, &ppp_pcb_list[pd].netif); return; } /* Something's wrong so drop it. */ @@ -717,8 +713,8 @@ static void ppp_input(int unit, void *arg) { case PPP_IP: /* Internet Protocol */ PPPDEBUG(LOG_INFO, ("ppp_input[%d]: ip in pbuf len=%d\n", pd, nb->len)); - if (ppp_control_list[pd].netif.input) { - ppp_control_list[pd].netif.input(nb, &ppp_control_list[pd].netif); + if (ppp_pcb_list[pd].netif.input) { + ppp_pcb_list[pd].netif.input(nb, &ppp_pcb_list[pd].netif); return; } break; @@ -773,7 +769,7 @@ static void ppp_input(int unit, void *arg) { drop: LINK_STATS_INC(link.drop); - snmp_inc_ifindiscards(&ppp_control_list[pd].netif); + snmp_inc_ifindiscards(&ppp_pcb_list[pd].netif); out: pbuf_free(nb); @@ -801,8 +797,8 @@ out: * Clip off the VJ header and prepend the rebuilt TCP/IP header and * pass the result to IP. */ - if ((vj_uncompress_tcp(&nb, &ppp_control_list[pd].vj_comp) >= 0) && (ppp_control_list[pd].netif.input)) { - ppp_control_list[pd].netif.input(nb, &ppp_control_list[pd].netif); + if ((vj_uncompress_tcp(&nb, &ppp_pcb_list[pd].vj_comp) >= 0) && (ppp_pcb_list[pd].netif.input)) { + ppp_pcb_list[pd].netif.input(nb, &ppp_pcb_list[pd].netif); return; } /* Something's wrong so drop it. */ @@ -820,8 +816,8 @@ out: * Process the TCP/IP header for VJ header compression and then pass * the packet to IP. */ - if ((vj_uncompress_uncomp(nb, &ppp_control_list[pd].vj_comp) >= 0) && ppp_control_list[pd].netif.input) { - ppp_control_list[pd].netif.input(nb, &ppp_control_list[pd].netif); + if ((vj_uncompress_uncomp(nb, &ppp_pcb_list[pd].vj_comp) >= 0) && ppp_pcb_list[pd].netif.input) { + ppp_pcb_list[pd].netif.input(nb, &ppp_pcb_list[pd].netif); return; } /* Something's wrong so drop it. */ @@ -836,8 +832,8 @@ out: case PPP_IP: /* Internet Protocol */ PPPDEBUG(LOG_INFO, ("ppp_input[%d]: ip in pbuf len=%d\n", pd, nb->len)); - if (ppp_control_list[pd].netif.input) { - ppp_control_list[pd].netif.input(nb, &ppp_control_list[pd].netif); + if (ppp_pcb_list[pd].netif.input) { + ppp_pcb_list[pd].netif.input(nb, &ppp_pcb_list[pd].netif); return; } break; @@ -937,8 +933,8 @@ static void ppp_receive_wakeup(int pd) { PPPDEBUG(LOG_DEBUG, ("ppp_receive_wakeup: unit %d\n", pd)); - if (ppp_control_list[pd].open_flag != 0) { - sio_read_abort(ppp_control_list[pd].fd); + if (ppp_pcb_list[pd].open_flag != 0) { + sio_read_abort(ppp_pcb_list[pd].fd); } } #endif /* PPP_INPROC_OWNTHREAD */ @@ -986,7 +982,7 @@ void ppp_input_over_ethernet(int pd, struct pbuf *pb) { drop: LINK_STATS_INC(link.drop); - snmp_inc_ifindiscards(&ppp_control_list[pd].netif); + snmp_inc_ifindiscards(&ppp_pcb_list[pd].netif); pbuf_free(pb); return; } @@ -1020,7 +1016,7 @@ static void ppp_input_thread(void *arg) { int count; - ppp_control_rx *pcrx = arg; + ppp_pcb_rx *pcrx = arg; while (phase != PHASE_DEAD) { count = sio_read(pcrx->fd, pcrx->rxbuf, PPPOS_RX_BUFSIZE); @@ -1037,7 +1033,7 @@ ppp_input_thread(void *arg) #if PPPOS_SUPPORT static void -pppos_put(ppp_control *pc, struct pbuf *nb) +pppos_put(ppp_pcb *pc, struct pbuf *nb) { struct pbuf *b; int c; @@ -1104,7 +1100,7 @@ ppp_append(u_char c, struct pbuf *nb, ext_accm *out_accm) */ static err_t ppp_netif_output(struct netif *netif, struct pbuf *pb, ip_addr_t *ipaddr) { int pd = (int)(size_t)netif->state; - ppp_control *pc = &ppp_control_list[pd]; + ppp_pcb *pc = &ppp_pcb_list[pd]; #if PPPOS_SUPPORT u_short protocol = PPP_IP; u_int fcs_out = PPP_INITFCS; @@ -1251,7 +1247,7 @@ static err_t ppp_netif_output(struct netif *netif, struct pbuf *pb, ip_addr_t *i #if PPPOE_SUPPORT static err_t ppp_netif_output_over_ethernet(int pd, struct pbuf *p) { - ppp_control *pc = &ppp_control_list[pd]; + ppp_pcb *pc = &ppp_pcb_list[pd]; struct pbuf *pb; u_short protocol = PPP_IP; int i=0; @@ -1295,32 +1291,31 @@ static err_t ppp_netif_output_over_ethernet(int pd, struct pbuf *p) { /* Get and set parameters for the given connection. * Return 0 on success, an error code on failure. */ int -ppp_ioctl(int pd, int cmd, void *arg) +ppp_ioctl(ppp_pcb *pcb, int cmd, void *arg) { - ppp_control *pc = &ppp_control_list[pd]; int st = 0; - if (pd < 0 || pd >= NUM_PPP) { + if (pcb->unit < 0 || pcb->unit >= NUM_PPP) { st = PPPERR_PARAM; } else { switch(cmd) { case PPPCTLG_UPSTATUS: /* Get the PPP up status. */ if (arg) { - *(int *)arg = (int)(pc->if_up); + *(int *)arg = (int)(pcb->if_up); } else { st = PPPERR_PARAM; } break; case PPPCTLS_ERRCODE: /* Set the PPP error code. */ if (arg) { - pc->err_code = *(int *)arg; + pcb->err_code = *(int *)arg; } else { st = PPPERR_PARAM; } break; case PPPCTLG_ERRCODE: /* Get the PPP error code. */ if (arg) { - *(int *)arg = (int)(pc->err_code); + *(int *)arg = (int)(pcb->err_code); } else { st = PPPERR_PARAM; } @@ -1328,7 +1323,7 @@ ppp_ioctl(int pd, int cmd, void *arg) #if PPPOS_SUPPORT case PPPCTLG_FD: /* Get the fd associated with the ppp */ if (arg) { - *(sio_fd_t *)arg = pc->fd; + *(sio_fd_t *)arg = pcb->fd; } else { st = PPPERR_PARAM; } @@ -1349,7 +1344,7 @@ ppp_ioctl(int pd, int cmd, void *arg) * -1 Failed to write to device */ int ppp_write(int pd, const u_char *s, int n) { - ppp_control *pc = &ppp_control_list[pd]; + ppp_pcb *pc = &ppp_pcb_list[pd]; #if PPPOS_SUPPORT u_char c; u_int fcs_out; @@ -1422,7 +1417,7 @@ int ppp_write(int pd, const u_char *s, int n) { #if PPPOE_SUPPORT static int ppp_write_over_ethernet(int pd, const u_char *s, int n) { - ppp_control *pc = &ppp_control_list[pd]; + ppp_pcb *pc = &ppp_pcb_list[pd]; struct pbuf *pb; /* skip address & flags */ @@ -1467,7 +1462,7 @@ static int ppp_write_over_ethernet(int pd, const u_char *s, int n) { * Drop the input packet. */ static void -ppp_free_current_input_packet(ppp_control_rx *pcrx) +ppp_free_current_input_packet(ppp_pcb_rx *pcrx) { if (pcrx->in_head != NULL) { if (pcrx->in_tail && (pcrx->in_tail != pcrx->in_head)) { @@ -1483,7 +1478,7 @@ ppp_free_current_input_packet(ppp_control_rx *pcrx) * Drop the input packet and increase error counters. */ static void -ppp_drop(ppp_control_rx *pcrx) +ppp_drop(ppp_pcb_rx *pcrx) { if (pcrx->in_head != NULL) { #if 0 @@ -1493,11 +1488,11 @@ ppp_drop(ppp_control_rx *pcrx) } ppp_free_current_input_packet(pcrx); #if VJ_SUPPORT - vj_uncompress_err(&ppp_control_list[pcrx->pd].vj_comp); + vj_uncompress_err(&ppp_pcb_list[pcrx->pd].vj_comp); #endif /* VJ_SUPPORT */ LINK_STATS_INC(link.drop); - snmp_inc_ifindiscards(&ppp_control_list[pcrx->pd].netif); + snmp_inc_ifindiscards(&ppp_pcb_list[pcrx->pd].netif); } #if !PPP_INPROC_OWNTHREAD @@ -1509,9 +1504,9 @@ ppp_drop(ppp_control_rx *pcrx) * @param len length of received data */ void -pppos_input(int pd, u_char* data, int len) +pppos_input(ppp_pcb *pcb, u_char* data, int len) { - pppos_input_proc(&ppp_control_list[pd].rx, data, len); + pppos_input_proc(pcb->rx, data, len); } #endif @@ -1519,7 +1514,7 @@ pppos_input(int pd, u_char* data, int len) * Process a received octet string. */ static void -pppos_input_proc(ppp_control_rx *pcrx, u_char *s, int l) +pppos_input_proc(ppp_pcb_rx *pcrx, u_char *s, int l) { struct pbuf *next_pbuf; u_char cur_char; @@ -1592,7 +1587,7 @@ pppos_input_proc(ppp_control_rx *pcrx, u_char *s, int l) PPPDEBUG(LOG_ERR, ("pppos_input_proc[%d]: tcpip_callback() failed, dropping packet\n", pcrx->pd)); pbuf_free(inp); LINK_STATS_INC(link.drop); - snmp_inc_ifindiscards(&ppp_control_list[pcrx->pd].netif); + snmp_inc_ifindiscards(&ppp_pcb_list[pcrx->pd].netif); } #else /* PPP_INPROC_MULTITHREADED */ ppp_input(inp); @@ -1751,7 +1746,7 @@ struct pbuf * ppp_singlebuf(struct pbuf *p) { #if PPPOE_SUPPORT static void ppp_over_ethernet_link_status_cb(int pd, int state) { int pppoe_err_code = PPPERR_NONE; - ppp_control *pc; + ppp_pcb *pc; switch(state) { @@ -1774,7 +1769,7 @@ static void ppp_over_ethernet_link_status_cb(int pd, int state) { break; } - pc = &ppp_control_list[pd]; + pc = &ppp_pcb_list[pd]; /* Reconnect if persist mode is enabled */ if(pc->settings.persist) { @@ -1805,17 +1800,17 @@ void ppp_link_terminated(int pd) { PPPDEBUG(LOG_DEBUG, ("ppp_link_terminated: unit %d\n", pd)); #if PPPOE_SUPPORT - if (ppp_control_list[pd].ethif) { - pppoe_disconnect(ppp_control_list[pd].pppoe_sc); + if (ppp_pcb_list[pd].ethif) { + pppoe_disconnect(ppp_pcb_list[pd].pppoe_sc); } else #endif /* PPPOE_SUPPORT */ { #if PPPOS_SUPPORT - ppp_control* pc; + ppp_pcb* pc; #if PPP_INPROC_OWNTHREAD ppp_receive_wakeup(pd); #endif /* PPP_INPROC_OWNTHREAD */ - pc = &ppp_control_list[pd]; + pc = &ppp_pcb_list[pd]; PPPDEBUG(LOG_DEBUG, ("ppp_link_terminated: unit %d: link_status_cb=%p err_code=%d\n", pd, pc->link_status_cb, pc->err_code)); if (pc->link_status_cb) { @@ -1838,9 +1833,9 @@ void ppp_link_terminated(int pd) { * @see netif_set_status_callback */ void -ppp_set_netif_statuscallback(int pd, netif_status_callback_fn status_callback) +ppp_set_netif_statuscallback(ppp_pcb *pcb, netif_status_callback_fn status_callback) { - netif_set_status_callback(&ppp_control_list[pd].netif, status_callback); + netif_set_status_callback(pcb->netif, status_callback); } #endif /* LWIP_NETIF_STATUS_CALLBACK */ @@ -1853,9 +1848,9 @@ ppp_set_netif_statuscallback(int pd, netif_status_callback_fn status_callback) * @see netif_set_link_callback */ void -ppp_set_netif_linkcallback(int pd, netif_status_callback_fn link_callback) +ppp_set_netif_linkcallback(ppp_pcb *pcb, netif_status_callback_fn link_callback) { - netif_set_link_callback(&ppp_control_list[pd].netif, link_callback); + netif_set_link_callback(pcb->netif, link_callback); } #endif /* LWIP_NETIF_LINK_CALLBACK */ @@ -1868,7 +1863,7 @@ ppp_set_netif_linkcallback(int pd, netif_status_callback_fn link_callback) * new_phase - signal the start of a new phase of pppd's operation. */ void new_phase(int unit, int p) { - ppp_control *pc = &ppp_control_list[unit]; + ppp_pcb *pc = &ppp_pcb_list[unit]; pc->phase = p; #if PPP_NOTIFY /* The one willing notify support should add here the code to be notified of phase changes */ @@ -1880,7 +1875,7 @@ void new_phase(int unit, int p) { * the ppp interface. */ int ppp_send_config(int unit, int mtu, u_int32_t accm, int pcomp, int accomp) { - ppp_control *pc = &ppp_control_list[unit]; + ppp_pcb *pc = &ppp_pcb_list[unit]; #if PPPOS_SUPPORT int i; #endif /* PPPOS_SUPPORT */ @@ -1914,7 +1909,7 @@ int ppp_send_config(int unit, int mtu, u_int32_t accm, int pcomp, int accomp) { */ int ppp_recv_config(int unit, int mru, u_int32_t accm, int pcomp, int accomp) { #if PPPOS_SUPPORT - ppp_control *pc = &ppp_control_list[unit]; + ppp_pcb *pc = &ppp_pcb_list[unit]; int i; SYS_ARCH_DECL_PROTECT(lev); #endif /* PPPOS_SUPPORT */ @@ -1951,7 +1946,7 @@ int ppp_recv_config(int unit, int mru, u_int32_t accm, int pcomp, int accomp) { */ int sifaddr (int unit, u_int32_t our_adr, u_int32_t his_adr, u_int32_t net_mask) { - ppp_control *pc = &ppp_control_list[unit]; + ppp_pcb *pc = &ppp_pcb_list[unit]; int st = 1; if (unit < 0 || unit >= NUM_PPP || !pc->open_flag) { @@ -1972,7 +1967,7 @@ int sifaddr (int unit, u_int32_t our_adr, u_int32_t his_adr, * through the interface if possible. */ int cifaddr (int unit, u_int32_t our_adr, u_int32_t his_adr) { - ppp_control *pc = &ppp_control_list[unit]; + ppp_pcb *pc = &ppp_pcb_list[unit]; int st = 1; LWIP_UNUSED_ARG(our_adr); @@ -1993,7 +1988,7 @@ int cifaddr (int unit, u_int32_t our_adr, u_int32_t his_adr) { * sdns - Config the DNS servers */ int sdns (int unit, u_int32_t ns1, u_int32_t ns2) { - ppp_control *pc = &ppp_control_list[unit]; + ppp_pcb *pc = &ppp_pcb_list[unit]; int st = 1; if (unit < 0 || unit >= NUM_PPP || !pc->open_flag) { @@ -2012,7 +2007,7 @@ int sdns (int unit, u_int32_t ns1, u_int32_t ns2) { * cdns - Clear the DNS servers */ int cdns (int unit, u_int32_t ns1, u_int32_t ns2) { - ppp_control *pc = &ppp_control_list[unit]; + ppp_pcb *pc = &ppp_pcb_list[unit]; int st = 1; LWIP_UNUSED_ARG(ns1); @@ -2033,7 +2028,7 @@ int cdns (int unit, u_int32_t ns1, u_int32_t ns2) { */ int sifup(int u) { - ppp_control *pc = &ppp_control_list[u]; + ppp_pcb *pc = &ppp_pcb_list[u]; int st = 1; if (u < 0 || u >= NUM_PPP || !pc->open_flag) { @@ -2066,7 +2061,7 @@ int sifup(int u) * down if there are no remaining protocols. */ int sifdown(int unit) { - ppp_control *pc = &ppp_control_list[unit]; + ppp_pcb *pc = &ppp_pcb_list[unit]; int st = 1; if (unit < 0 || unit >= NUM_PPP || !pc->open_flag) { @@ -2099,7 +2094,7 @@ int sifnpmode(int u, int proto, enum NPmode mode) { * netif_set_mtu - set the MTU on the PPP network interface. */ void netif_set_mtu(int unit, int mtu) { - ppp_control *pc = &ppp_control_list[unit]; + ppp_pcb *pc = &ppp_pcb_list[unit]; /* Validate parameters. */ if (unit < 0 || unit >= NUM_PPP || !pc->open_flag) @@ -2112,7 +2107,7 @@ void netif_set_mtu(int unit, int mtu) { * netif_get_mtu - get PPP interface MTU */ int netif_get_mtu(int unit) { - ppp_control *pc = &ppp_control_list[unit]; + ppp_pcb *pc = &ppp_pcb_list[unit]; /* Validate parameters. */ if (unit < 0 || unit >= NUM_PPP || !pc->open_flag) @@ -2134,7 +2129,7 @@ int netif_get_mtu(int unit) { * ppp connection when it has come up. */ int sifdefaultroute(int unit, u_int32_t ouraddr, u_int32_t gateway, bool replace) { - ppp_control *pc = &ppp_control_list[unit]; + ppp_pcb *pc = &ppp_pcb_list[unit]; int st = 1; LWIP_UNUSED_ARG(ouraddr); @@ -2158,7 +2153,7 @@ int sifdefaultroute(int unit, u_int32_t ouraddr, u_int32_t gateway, bool replace * cifdefaultroute - delete a default route through the address given. */ int cifdefaultroute(int unit, u_int32_t ouraddr, u_int32_t gateway) { - ppp_control *pc = &ppp_control_list[unit]; + ppp_pcb *pc = &ppp_pcb_list[unit]; int st = 1; LWIP_UNUSED_ARG(ouraddr); @@ -2200,7 +2195,7 @@ int cifproxyarp(int unit, u_int32_t his_adr) { */ int sifvjcomp(int u, int vjcomp, int cidcomp, int maxcid) { #if PPPOS_SUPPORT && VJ_SUPPORT - ppp_control *pc = &ppp_control_list[u]; + ppp_pcb *pc = &ppp_pcb_list[u]; pc->vj_enabled = vjcomp; pc->vj_comp.compressSlot = cidcomp; diff --git a/src/netif/ppp/ppp.h b/src/netif/ppp/ppp.h index 1350a26d..2ecef6a8 100644 --- a/src/netif/ppp/ppp.h +++ b/src/netif/ppp/ppp.h @@ -88,6 +88,9 @@ typedef unsigned char u_char; *** PUBLIC DATA TYPES *** ************************/ +/* + * PPP configuration. + */ typedef struct ppp_settings_s { u_int disable_defaultip : 1; /* Don't use hostname for default IP addrs */ @@ -132,6 +135,71 @@ struct ppp_addrs { ip_addr_t our_ipaddr, his_ipaddr, netmask, dns1, dns2; }; +/* + * PPP interface RX control block. + */ +typedef struct ppp_pcb_rx_s { + /** unit number / ppp descriptor */ + int pd; + /** the rx file descriptor */ + sio_fd_t fd; + /** receive buffer - encoded data is stored here */ +#if PPPOS_SUPPORT && PPP_INPROC_OWNTHREAD + u_char rxbuf[PPPOS_RX_BUFSIZE]; +#endif /* PPPOS_SUPPORT && PPP_INPROC_OWNTHREAD */ + +#if PPPOS_SUPPORT + /* The input packet. */ + struct pbuf *in_head, *in_tail; + + u16_t in_protocol; /* The input protocol code. */ + u16_t in_fcs; /* Input Frame Check Sequence value. */ + ppp_dev_states in_state; /* The input process state. */ + char in_escaped; /* Escape next character. */ + ext_accm in_accm; /* Async-Ctl-Char-Map for input. */ +#endif /* PPPOS_SUPPORT */ +} ppp_pcb_rx; + +/* + * PPP interface control block. + */ +typedef struct ppp_pcb_s { + ppp_settings settings; + int unit; + + ppp_pcb_rx rx; + char open_flag; /* True when in use. */ + u8_t phase; /* where the link is at */ + u8_t status; /* exit status */ +#if PPPOE_SUPPORT + struct netif *ethif; + struct pppoe_softc *pppoe_sc; +#endif /* PPPOE_SUPPORT */ + int if_up; /* True when the interface is up. */ + int err_code; /* Code indicating why interface is down. */ +#if PPPOS_SUPPORT + sio_fd_t fd; /* File device ID of port. */ +#endif /* PPPOS_SUPPORT */ + u16_t mtu; /* Peer's mru */ + int pcomp; /* Does peer accept protocol compression? */ + int accomp; /* Does peer accept addr/ctl compression? */ + u_long last_xmit; /* Time of last transmission. */ +#if PPPOS_SUPPORT + ext_accm out_accm; /* Async-Ctl-Char-Map for output. */ +#endif /* PPPOS_SUPPORT */ +#if PPPOS_SUPPORT && VJ_SUPPORT + int vj_enabled; /* Flag indicating VJ compression enabled. */ + struct vjcompress vj_comp; /* Van Jacobson compression header. */ +#endif /* PPPOS_SUPPORT && VJ_SUPPORT */ + + struct netif netif; + + struct ppp_addrs addrs; + + void (*link_status_cb)(void *ctx, int err_code, void *arg); + void *link_status_ctx; + +} ppp_pcb; /************************ *** PUBLIC FUNCTIONS *** @@ -140,10 +208,10 @@ struct ppp_addrs { /* Initialize the PPP subsystem. */ int ppp_init(void); -/* Create a new PPP session, returns a PPP descriptor. */ -int ppp_new(void); +/* Create a new PPP session, returns a PPP PCB structure. */ +ppp_pcb *ppp_new(void); -/* Warning: Using ppp_auth_type_ANY might have security consequences. +/* Warning: Using PPPAUTHTYPE_ANY might have security consequences. * RFC 1994 says: * * In practice, within or associated with each PPP server, there is a @@ -173,7 +241,7 @@ enum ppp_auth_type { PPPAUTHTYPE_NONE }; -void ppp_set_auth(int unit, enum ppp_auth_type authtype, const char *user, const char *passwd); +void ppp_set_auth(ppp_pcb *pcb, enum ppp_auth_type authtype, const char *user, const char *passwd); /* Link status callback function prototype */ typedef void (*ppp_link_status_cb_fn)(void *ctx, int errcode, void *arg); @@ -190,14 +258,14 @@ typedef void (*ppp_link_status_cb_fn)(void *ctx, int errcode, void *arg); * Return a new PPP connection descriptor on success or * an error code (negative) on failure. */ -int ppp_over_serial_open(int unit, sio_fd_t fd, ppp_link_status_cb_fn link_status_cb, void *link_status_ctx); +int ppp_over_serial_open(ppp_pcb *pcb, sio_fd_t fd, ppp_link_status_cb_fn link_status_cb, void *link_status_ctx); #endif /* PPPOS_SUPPORT */ #if PPPOE_SUPPORT /* * Open a new PPP Over Ethernet (PPPoE) connection. */ -int ppp_over_ethernet_open(int unit, 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); #endif /* PPPOE_SUPPORT */ @@ -206,18 +274,18 @@ int ppp_over_ethernet_open(int unit, struct netif *ethif, const char *service_na * Any outstanding packets in the queues are dropped. * Return 0 on success, an error code on failure. */ -int ppp_close(int pd); +int ppp_close(ppp_pcb *pcb); /* * Indicate to the PPP process that the line has disconnected. */ -void ppp_sighup(int pd); +void ppp_sighup(ppp_pcb *pcb); /* * Get and set parameters for the given connection. * Return 0 on success, an error code on failure. */ -int ppp_ioctl(int pd, int cmd, void *arg); +int ppp_ioctl(ppp_pcb *pcb, int cmd, void *arg); #if PPPOS_SUPPORT && !PPP_INPROC_OWNTHREAD /* @@ -225,17 +293,17 @@ int ppp_ioctl(int pd, int cmd, void *arg); * If PPP_INPROC_OWNTHREAD==1, a seperate input thread using the blocking * sio_read() is used, so this is deactivated. */ -void pppos_input(int pd, u_char* data, int len); +void pppos_input(ppp_pcb *pcb, u_char* data, int len); #endif /* PPPOS_SUPPORT && !PPP_INPROC_OWNTHREAD */ #if LWIP_NETIF_STATUS_CALLBACK /* Set an lwIP-style status-callback for the selected PPP device */ -void ppp_set_netif_statuscallback(int pd, netif_status_callback_fn status_callback); +void ppp_set_netif_statuscallback(ppp_pcb *pcb, netif_status_callback_fn status_callback); #endif /* LWIP_NETIF_STATUS_CALLBACK */ #if LWIP_NETIF_LINK_CALLBACK /* Set an lwIP-style link-callback for the selected PPP device */ -void ppp_set_netif_linkcallback(int pd, netif_status_callback_fn link_callback); +void ppp_set_netif_linkcallback(ppp_pcb *pcb, netif_status_callback_fn link_callback); #endif /* LWIP_NETIF_LINK_CALLBACK */ diff --git a/src/netif/ppp/ppp_impl.h b/src/netif/ppp/ppp_impl.h index 34eaf11b..5251865f 100644 --- a/src/netif/ppp/ppp_impl.h +++ b/src/netif/ppp/ppp_impl.h @@ -391,72 +391,7 @@ struct pppd_stats { }; #endif /* PPP_STATS_SUPPORT */ -/* - * PPP interface RX control block. - */ -typedef struct ppp_control_rx_s { - /** unit number / ppp descriptor */ - int pd; - /** the rx file descriptor */ - sio_fd_t fd; - /** receive buffer - encoded data is stored here */ -#if PPPOS_SUPPORT && PPP_INPROC_OWNTHREAD - u_char rxbuf[PPPOS_RX_BUFSIZE]; -#endif /* PPPOS_SUPPORT && PPP_INPROC_OWNTHREAD */ - -#if PPPOS_SUPPORT - /* The input packet. */ - struct pbuf *in_head, *in_tail; - - u16_t in_protocol; /* The input protocol code. */ - u16_t in_fcs; /* Input Frame Check Sequence value. */ - ppp_dev_states in_state; /* The input process state. */ - char in_escaped; /* Escape next character. */ - ext_accm in_accm; /* Async-Ctl-Char-Map for input. */ -#endif /* PPPOS_SUPPORT */ -} ppp_control_rx; - -/* - * PPP interface control block. - */ -typedef struct ppp_control_s { - ppp_settings settings; - - ppp_control_rx rx; - char open_flag; /* True when in use. */ - u8_t phase; /* where the link is at */ - u8_t status; /* exit status */ -#if PPPOE_SUPPORT - struct netif *ethif; - struct pppoe_softc *pppoe_sc; -#endif /* PPPOE_SUPPORT */ - int if_up; /* True when the interface is up. */ - int err_code; /* Code indicating why interface is down. */ -#if PPPOS_SUPPORT - sio_fd_t fd; /* File device ID of port. */ -#endif /* PPPOS_SUPPORT */ - u16_t mtu; /* Peer's mru */ - int pcomp; /* Does peer accept protocol compression? */ - int accomp; /* Does peer accept addr/ctl compression? */ - u_long last_xmit; /* Time of last transmission. */ -#if PPPOS_SUPPORT - ext_accm out_accm; /* Async-Ctl-Char-Map for output. */ -#endif /* PPPOS_SUPPORT */ -#if PPPOS_SUPPORT && VJ_SUPPORT - int vj_enabled; /* Flag indicating VJ compression enabled. */ - struct vjcompress vj_comp; /* Van Jacobson compression header. */ -#endif /* PPPOS_SUPPORT && VJ_SUPPORT */ - - struct netif netif; - - struct ppp_addrs addrs; - - void (*link_status_cb)(void *ctx, int err_code, void *arg); - void *link_status_ctx; - -} ppp_control; - -ppp_control ppp_control_list[NUM_PPP]; /* The PPP interface control blocks. */ +ppp_pcb ppp_pcb_list[NUM_PPP]; /* The PPP interface control blocks. */ /* PPP flow functions */ diff --git a/src/netif/ppp/upap.c b/src/netif/ppp/upap.c index fda03f49..cd8d2c2b 100644 --- a/src/netif/ppp/upap.c +++ b/src/netif/ppp/upap.c @@ -655,7 +655,7 @@ upap_printpkt(p, plen, printer, arg) int mlen, ulen, wlen; char *user, *pwd, *msg; u_char *pstart; - ppp_control *pc = &ppp_control_list[0]; + ppp_pcb *pc = &ppp_pcb_list[0]; if (plen < UPAP_HEADERLEN) return 0;