diff --git a/src/netif/ppp/auth.c b/src/netif/ppp/auth.c index 41844e3d..b0183508 100644 --- a/src/netif/ppp/auth.c +++ b/src/netif/ppp/auth.c @@ -763,6 +763,7 @@ link_established(unit) lcp_options *ho = &lcp_hisoptions[unit]; int i; struct protent *protp; + ppp_control *pc = &ppp_control_list[unit]; /* * Tell higher-level protocols that LCP is up. @@ -818,13 +819,13 @@ link_established(unit) #if PPP_SERVER #if EAP_SUPPORT if (go->neg_eap) { - eap_authpeer(unit, ppp_settings.our_name); + eap_authpeer(unit, pc->settings.our_name); auth |= EAP_PEER; } else #endif /* EAP_SUPPORT */ #if CHAP_SUPPORT if (go->neg_chap) { - chap_auth_peer(unit, ppp_settings.our_name, CHAP_DIGEST(go->chap_mdtype)); + chap_auth_peer(unit, pc->settings.our_name, CHAP_DIGEST(go->chap_mdtype)); auth |= CHAP_PEER; } else #endif /* CHAP_SUPPORT */ @@ -839,19 +840,19 @@ link_established(unit) #if EAP_SUPPORT if (ho->neg_eap) { - eap_authwithpeer(unit, ppp_settings.user); + eap_authwithpeer(unit, pc->settings.user); auth |= EAP_WITHPEER; } else #endif /* EAP_SUPPORT */ #if CHAP_SUPPORT if (ho->neg_chap) { - chap_auth_with_peer(unit, ppp_settings.user, CHAP_DIGEST(ho->chap_mdtype)); + chap_auth_with_peer(unit, pc->settings.user, CHAP_DIGEST(ho->chap_mdtype)); auth |= CHAP_WITHPEER; } else #endif /* CHAP_SUPPORT */ #if PAP_SUPPORT if (ho->neg_upap) { - upap_authwithpeer(unit, ppp_settings.user, ppp_settings.passwd); + upap_authwithpeer(unit, pc->settings.user, pc->settings.passwd); auth |= PAP_WITHPEER; } else #endif /* PAP_SUPPORT */ @@ -1216,7 +1217,7 @@ np_up(unit, proto) tlim = (*idle_time_hook)(NULL); else #endif /* UNUSED */ - tlim = ppp_settings.idle_time_limit; + tlim = pc->settings.idle_time_limit; if (tlim > 0) TIMEOUT(check_idle, NULL, tlim); @@ -1224,8 +1225,8 @@ np_up(unit, proto) * Set a timeout to close the connection once the maximum * connect time has expired. */ - if (ppp_settings.maxconnect > 0) - TIMEOUT(connect_time_expired, 0, ppp_settings.maxconnect); + if (pc->settings.maxconnect > 0) + TIMEOUT(connect_time_expired, 0, pc->settings.maxconnect); #ifdef MAXOCTETS if (maxoctets > 0) @@ -1335,7 +1336,7 @@ check_idle(arg) } else { #endif /* UNUSED */ itime = LWIP_MIN(idle.xmit_idle, idle.recv_idle); - tlim = ppp_settings.idle_time_limit - itime; + tlim = pc->settings.idle_time_limit - itime; #if 0 /* UNUSED */ } #endif /* UNUSED */ @@ -1516,25 +1517,26 @@ auth_reset(unit) { lcp_options *go = &lcp_gotoptions[unit]; lcp_options *ao = &lcp_allowoptions[unit]; + ppp_control *pc = &ppp_control_list[unit]; - if( ppp_settings.passwd[0] ) { + if( pc->settings.passwd[0] ) { #if PAP_SUPPORT - ao->neg_upap = !ppp_settings.refuse_pap; + ao->neg_upap = !pc->settings.refuse_pap; #endif /* PAP_SUPPORT */ #if EAP_SUPPORT - ao->neg_eap = !ppp_settings.refuse_eap; + ao->neg_eap = !pc->settings.refuse_eap; #endif /* EAP_SUPPORT */ #if CHAP_SUPPORT ao->chap_mdtype = MDTYPE_NONE; - if(!ppp_settings.refuse_chap) + if(!pc->settings.refuse_chap) ao->chap_mdtype |= MDTYPE_MD5; #if MSCHAP_SUPPORT - if(!ppp_settings.refuse_mschap) + if(!pc->settings.refuse_mschap) ao->chap_mdtype |= MDTYPE_MICROSOFT; - if(!ppp_settings.refuse_mschap_v2) + if(!pc->settings.refuse_mschap_v2) ao->chap_mdtype |= MDTYPE_MICROSOFT_V2; #endif /* MSCHAP_SUPPORT */ @@ -1988,22 +1990,23 @@ get_secret(unit, client, server, secret, secret_len, am_server) int am_server; { int len; + ppp_control *pc = &ppp_control_list[unit]; LWIP_UNUSED_ARG(unit); LWIP_UNUSED_ARG(server); LWIP_UNUSED_ARG(am_server); - if(!client || !client[0] || strcmp(client, ppp_settings.user)) { + if(!client || !client[0] || strcmp(client, pc->settings.user)) { return 0; } - len = (int)strlen(ppp_settings.passwd); + len = (int)strlen(pc->settings.passwd); if (len > MAXSECRETLEN) { error("Secret for %s on %s is too long", client, server); len = MAXSECRETLEN; } - MEMCPY(secret, ppp_settings.passwd, len); + MEMCPY(secret, pc->settings.passwd, len); *secret_len = len; return 1; diff --git a/src/netif/ppp/chap-new.c b/src/netif/ppp/chap-new.c index d9ecd1e0..0251d0ff 100644 --- a/src/netif/ppp/chap-new.c +++ b/src/netif/ppp/chap-new.c @@ -480,6 +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]; if ((cs->flags & (LOWERUP | AUTH_STARTED)) != (LOWERUP | AUTH_STARTED)) return; /* not ready */ @@ -492,8 +493,8 @@ chap_respond(struct chap_client_state *cs, int id, slprintf(rname, sizeof(rname), "%.*v", nlen, pkt + clen + 1); /* Microsoft doesn't send their name back in the PPP packet */ - if (ppp_settings.explicit_remote || (ppp_settings.remote_name[0] != 0 && rname[0] == 0)) - strlcpy(rname, ppp_settings.remote_name, sizeof(rname)); + if (pc->settings.explicit_remote || (pc->settings.remote_name[0] != 0 && rname[0] == 0)) + strlcpy(rname, pc->settings.remote_name, sizeof(rname)); /* get secret for authenticating ourselves with the specified host */ if (!get_secret(0, cs->name, rname, secret, &secret_len, 0)) { diff --git a/src/netif/ppp/eap.c b/src/netif/ppp/eap.c index af50d789..5f6f0001 100644 --- a/src/netif/ppp/eap.c +++ b/src/netif/ppp/eap.c @@ -1333,6 +1333,7 @@ u_char *inp; int id; int len; { + ppp_control *pc = &ppp_control_list[esp->es_unit]; u_char typenum; u_char vallen; int secret_len; @@ -1451,9 +1452,9 @@ int len; } /* In case the remote doesn't give us his name. */ - if (ppp_settings.explicit_remote || - (ppp_settings.remote_name[0] != '\0' && vallen == len)) - strlcpy(rhostname, ppp_settings.remote_name, sizeof (rhostname)); + if (pc->settings.explicit_remote || + (pc->settings.remote_name[0] != '\0' && vallen == len)) + strlcpy(rhostname, pc->settings.remote_name, sizeof (rhostname)); /* * Get the secret for authenticating ourselves with diff --git a/src/netif/ppp/ipcp.c b/src/netif/ppp/ipcp.c index bb7eaf58..1ab2d95f 100644 --- a/src/netif/ppp/ipcp.c +++ b/src/netif/ppp/ipcp.c @@ -721,6 +721,7 @@ static void ipcp_resetci(f) fsm *f; { + ppp_control *pc = &ppp_control_list[f->unit]; ipcp_options *wo = &ipcp_wantoptions[f->unit]; ipcp_options *go = &ipcp_gotoptions[f->unit]; ipcp_options *ao = &ipcp_allowoptions[f->unit]; @@ -731,8 +732,8 @@ ipcp_resetci(f) wo->accept_local = 1; if (wo->hisaddr == 0) wo->accept_remote = 1; - wo->req_dns1 = ppp_settings.usepeerdns; /* Request DNS addresses from the peer */ - wo->req_dns2 = ppp_settings.usepeerdns; + wo->req_dns1 = pc->settings.usepeerdns; /* Request DNS addresses from the peer */ + wo->req_dns2 = pc->settings.usepeerdns; *go = *wo; if (!ask_for_local) go->ouraddr = 0; @@ -1800,6 +1801,7 @@ ipcp_up(f) fsm *f; { u_int32_t mask; + ppp_control *pc = &ppp_control_list[f->unit]; ipcp_options *ho = &ipcp_hisoptions[f->unit]; ipcp_options *go = &ipcp_gotoptions[f->unit]; ipcp_options *wo = &ipcp_wantoptions[f->unit]; @@ -1844,7 +1846,7 @@ ipcp_up(f) if (go->dnsaddr[1]) script_setenv("DNS2", ip_ntoa(go->dnsaddr[1]), 0); #endif /* UNUSED */ - if (ppp_settings.usepeerdns && (go->dnsaddr[0] || go->dnsaddr[1])) { + if (pc->settings.usepeerdns && (go->dnsaddr[0] || go->dnsaddr[1])) { sdns(f->unit, go->dnsaddr[0], go->dnsaddr[1]); #if 0 /* UNUSED */ script_setenv("USEPEERDNS", "1", 0); diff --git a/src/netif/ppp/lcp.c b/src/netif/ppp/lcp.c index 38b3829c..8a38f119 100644 --- a/src/netif/ppp/lcp.c +++ b/src/netif/ppp/lcp.c @@ -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]; /* * Don't use A/C or protocol compression on transmission, * but accept A/C and protocol compressed packets @@ -526,9 +526,9 @@ lcp_lowerup(unit) xmit_accm[unit][0])); #endif /* PPPOS_SUPPORT */ - if (ppp_settings.listen_time != 0) { + if (pc->settings.listen_time != 0) { f->flags |= DELAYED_UP; - TIMEOUTMS(lcp_delayed_up, f, ppp_settings.listen_time); + TIMEOUTMS(lcp_delayed_up, f, pc->settings.listen_time); } else fsm_lowerup(f); } diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index 06d4ce93..ea32cf62 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -282,18 +282,6 @@ PACK_STRUCT_END /* Initialize the PPP subsystem. */ int ppp_init(void) { - int i; - struct protent *protp; - -#if PPP_STATS_SUPPORT - link_stats_valid = 0; -#endif /* PPP_STATS_SUPPORT */ - - /* FIXME: Remove that, do a user provided ppp_settings with a ppp_settings init function */ - memset(&ppp_settings, 0, sizeof(ppp_settings)); - ppp_settings.usepeerdns = 1; - ppp_settings.persist = 1; - ppp_set_auth(PPPAUTHTYPE_NONE, NULL, NULL); /* * Initialize magic number generator now so that protocols may @@ -301,51 +289,82 @@ int ppp_init(void) { */ magic_init(); + return 0; +} + +/* Create a new PPP session. */ +int ppp_new(void) { + int i, pd; + ppp_control *pc; + struct protent *protp; + + /* Find a free PPP session descriptor. */ + for (pd = 0; pd < NUM_PPP && ppp_control_list[pd].open_flag != 0; pd++); + if (pd >= NUM_PPP) + return PPPERR_OPEN; + + pc = &ppp_control_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; + new_phase(pd, PHASE_INITIALIZE); + + /* memset(&pc->settings, 0, sizeof(ppp_settings)); -- already done previously */ + pc->settings.usepeerdns = 1; + pc->settings.persist = 1; + /* * Initialize each protocol. */ for (i = 0; (protp = protocols[i]) != NULL; ++i) - (*protp->init)(0); + (*protp->init)(pd); - return 0; + return pd; } -void ppp_set_auth(enum ppp_auth_type authtype, const char *user, const char *passwd) { +void ppp_set_auth(int unit, enum ppp_auth_type authtype, const char *user, const char *passwd) { + ppp_control *pc = &ppp_control_list[unit]; + /* 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 - ppp_settings.refuse_pap = 0; + pc->settings.refuse_pap = 0; #endif /* PAP_SUPPORT */ #if CHAP_SUPPORT #if PAP_SUPPORT - ppp_settings.refuse_pap = 1; + pc->settings.refuse_pap = 1; #endif /* PAP_SUPPORT */ - ppp_settings.refuse_chap = 0; + pc->settings.refuse_chap = 0; #endif /* CHAP_SUPPORT */ #if MSCHAP_SUPPORT #if PAP_SUPPORT - ppp_settings.refuse_pap = 1; + pc->settings.refuse_pap = 1; #endif /* PAP_SUPPORT */ - ppp_settings.refuse_chap = 1; - ppp_settings.refuse_mschap = 1; - ppp_settings.refuse_mschap_v2 = 0; + pc->settings.refuse_chap = 1; + pc->settings.refuse_mschap = 1; + pc->settings.refuse_mschap_v2 = 0; #endif /* MSCHAP_SUPPORT */ #if EAP_SUPPORT #if PAP_SUPPORT - ppp_settings.refuse_pap = 1; + pc->settings.refuse_pap = 1; #endif/* PAP_SUPPORT */ #if CHAP_SUPPORT - ppp_settings.refuse_chap = 1; + pc->settings.refuse_chap = 1; #if MSCHAP_SUPPORT - ppp_settings.refuse_mschap = 1; - ppp_settings.refuse_mschap_v2 = 1; + pc->settings.refuse_mschap = 1; + pc->settings.refuse_mschap_v2 = 1; #endif /* MSCHAP_SUPPORT */ #endif /* CHAP_SUPPORT */ - ppp_settings.refuse_eap = 0; + pc->settings.refuse_eap = 0; #endif /* EAP_SUPPORT */ /* FIXME: re-enable that */ @@ -399,17 +418,17 @@ void ppp_set_auth(enum ppp_auth_type authtype, const char *user, const char *pas #endif if(user) { - strncpy(ppp_settings.user, user, sizeof(ppp_settings.user)-1); - ppp_settings.user[sizeof(ppp_settings.user)-1] = '\0'; + strncpy(pc->settings.user, user, sizeof(pc->settings.user)-1); + pc->settings.user[sizeof(pc->settings.user)-1] = '\0'; } else { - ppp_settings.user[0] = '\0'; + pc->settings.user[0] = '\0'; } if(passwd) { - strncpy(ppp_settings.passwd, passwd, sizeof(ppp_settings.passwd)-1); - ppp_settings.passwd[sizeof(ppp_settings.passwd)-1] = '\0'; + strncpy(pc->settings.passwd, passwd, sizeof(pc->settings.passwd)-1); + pc->settings.passwd[sizeof(pc->settings.passwd)-1] = '\0'; } else { - ppp_settings.passwd[0] = '\0'; + pc->settings.passwd[0] = '\0'; } } @@ -424,33 +443,21 @@ void ppp_set_auth(enum ppp_auth_type authtype, const char *user, const char *pas * * pppOpen() is directly defined to this function. */ -int ppp_over_serial_open(sio_fd_t fd, ppp_link_status_cb_fn link_status_cb, void *link_status_ctx) { - ppp_control *pc; - int pd; +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]; /* PPP is single-threaded: without a callback, * there is no way to know when the link is up. */ if (link_status_cb == NULL) return PPPERR_PARAM; - /* Find a free PPP session descriptor. */ - for (pd = 0; pd < NUM_PPP && ppp_control_list[pd].open_flag != 0; pd++); - if (pd >= NUM_PPP) - return PPPERR_OPEN; - - pc = &ppp_control_list[pd]; /* input pbuf left over from last session? */ ppp_free_current_input_packet(&pc->rx); - /* @todo: is this correct or do I overwrite something? */ - memset(pc, 0, sizeof(ppp_control)); - pc->rx.pd = pd; - pc->rx.fd = fd; - pc->open_flag = 1; pc->fd = fd; - pc->status = EXIT_OK; - new_phase(pd, PHASE_INITIALIZE); + pc->rx.pd = unit; + pc->rx.fd = fd; #if VJ_SUPPORT vj_compress_init(&pc->vj_comp); @@ -470,12 +477,12 @@ int ppp_over_serial_open(sio_fd_t fd, ppp_link_status_cb_fn link_status_cb, void * Start the connection and handle incoming events (packet or timeout). */ PPPDEBUG(LOG_INFO, ("ppp_over_serial_open: unit %d: Connecting\n", pd)); - ppp_start(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); #endif /* PPP_INPROC_OWNTHREAD */ - return pd; + return unit; } /* @@ -495,10 +502,9 @@ void ppp_set_xaccm(int unit, ext_accm *accm) { #if PPPOE_SUPPORT static void ppp_over_ethernet_link_status_cb(int pd, int state); -int ppp_over_ethernet_open(struct netif *ethif, const char *service_name, const char *concentrator_name, +int ppp_over_ethernet_open(int unit, 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; - int pd; + ppp_control *pc = &ppp_control_list[unit]; LWIP_UNUSED_ARG(service_name); LWIP_UNUSED_ARG(concentrator_name); @@ -508,39 +514,28 @@ int ppp_over_ethernet_open(struct netif *ethif, const char *service_name, const if (link_status_cb == NULL) return PPPERR_PARAM; - /* Find a free PPP session descriptor. Critical region? */ - for (pd = 0; pd < NUM_PPP && ppp_control_list[pd].open_flag != 0; pd++); - if (pd >= NUM_PPP) - pd = PPPERR_OPEN; - - pc = &ppp_control_list[pd]; - memset(pc, 0, sizeof(ppp_control)); - pc->open_flag = 1; pc->ethif = ethif; - pc->status = EXIT_OK; - - new_phase(pd, PHASE_INITIALIZE); pc->link_status_cb = link_status_cb; pc->link_status_ctx = link_status_ctx; - lcp_wantoptions[pd].mru = ethif->mtu-PPPOE_HEADERLEN-2; /* two byte PPP protocol discriminator, then IP data */ - lcp_wantoptions[pd].neg_asyncmap = 0; - lcp_wantoptions[pd].neg_pcompression = 0; - lcp_wantoptions[pd].neg_accompression = 0; + 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_allowoptions[pd].mru = ethif->mtu-PPPOE_HEADERLEN-2; /* two byte PPP protocol discriminator, then IP data */ - lcp_allowoptions[pd].neg_asyncmap = 0; - lcp_allowoptions[pd].neg_pcompression = 0; - lcp_allowoptions[pd].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; - if(pppoe_create(ethif, pd, ppp_over_ethernet_link_status_cb, &pc->pppoe_sc) != ERR_OK) { + if(pppoe_create(ethif, unit, ppp_over_ethernet_link_status_cb, &pc->pppoe_sc) != ERR_OK) { pc->open_flag = 0; return PPPERR_OPEN; } - pppoe_connect(pc->pppoe_sc, ppp_settings.persist); - return pd; + pppoe_connect(pc->pppoe_sc, pc->settings.persist); + return unit; } #if 0 /* UNUSED */ @@ -1782,10 +1777,10 @@ static void ppp_over_ethernet_link_status_cb(int pd, int state) { pc = &ppp_control_list[pd]; /* Reconnect if persist mode is enabled */ - if(ppp_settings.persist) { + if(pc->settings.persist) { if(pc->link_status_cb) pc->link_status_cb(pc->link_status_ctx, pc->err_code ? pc->err_code : pppoe_err_code, NULL); - pppoe_connect(pc->pppoe_sc, ppp_settings.persist); + pppoe_connect(pc->pppoe_sc, pc->settings.persist); return; } diff --git a/src/netif/ppp/ppp.h b/src/netif/ppp/ppp.h index 06c425a9..1350a26d 100644 --- a/src/netif/ppp/ppp.h +++ b/src/netif/ppp/ppp.h @@ -88,6 +88,46 @@ typedef unsigned char u_char; *** PUBLIC DATA TYPES *** ************************/ +typedef struct ppp_settings_s { + + u_int disable_defaultip : 1; /* Don't use hostname for default IP addrs */ + u_int auth_required : 1; /* Peer is required to authenticate */ + u_int explicit_remote : 1; /* remote_name specified with remotename opt */ +#if PAP_SUPPORT + u_int refuse_pap : 1; /* Don't wanna auth. ourselves with PAP */ +#endif /* PAP_SUPPORT */ +#if CHAP_SUPPORT + u_int refuse_chap : 1; /* Don't wanna auth. ourselves with CHAP */ +#endif /* CHAP_SUPPORT */ +#if MSCHAP_SUPPORT + u_int refuse_mschap : 1; /* Don't wanna auth. ourselves with MS-CHAP */ + u_int refuse_mschap_v2 : 1; /* Don't wanna auth. ourselves with MS-CHAPv2 */ +#endif /* MSCHAP_SUPPORT */ +#if EAP_SUPPORT + u_int refuse_eap : 1; /* Don't wanna auth. ourselves with EAP */ +#endif /* EAP_SUPPORT */ + u_int usehostname : 1; /* Use hostname for our_name */ + u_int usepeerdns : 1; /* Ask peer for DNS adds */ + u_int persist : 1; /* Persist mode, always try to reopen the connection */ +#if PRINTPKT_SUPPORT + u_int hide_password : 1; /* Hide password in dumped packets */ +#endif /* PRINTPKT_SUPPORT */ + + u16_t listen_time; /* time to listen first (ms), waiting for peer to send LCP packet */ + + /* FIXME: make it a compile time option */ + u16_t idle_time_limit; /* Disconnect if idle for this many seconds */ + int maxconnect; /* Maximum connect time (seconds) */ + + char user [MAXNAMELEN + 1]; /* Username for PAP */ + char passwd [MAXSECRETLEN + 1]; /* Password for PAP, secret for CHAP */ +#if PPP_SERVER + char our_name [MAXNAMELEN + 1]; /* Our name for authentication purposes */ +#endif /* PPP_SERVER */ + /* FIXME: make it a compile time option */ + char remote_name[MAXNAMELEN + 1]; /* Peer's name for authentication */ +} ppp_settings; + struct ppp_addrs { ip_addr_t our_ipaddr, his_ipaddr, netmask, dns1, dns2; }; @@ -100,6 +140,9 @@ struct ppp_addrs { /* Initialize the PPP subsystem. */ int ppp_init(void); +/* Create a new PPP session, returns a PPP descriptor. */ +int ppp_new(void); + /* Warning: Using ppp_auth_type_ANY might have security consequences. * RFC 1994 says: * @@ -130,7 +173,7 @@ enum ppp_auth_type { PPPAUTHTYPE_NONE }; -void ppp_set_auth(enum ppp_auth_type authtype, const char *user, const char *passwd); +void ppp_set_auth(int unit, 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); @@ -147,14 +190,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(sio_fd_t fd, ppp_link_status_cb_fn link_status_cb, void *link_status_ctx); +int ppp_over_serial_open(int unit, 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(struct netif *ethif, const char *service_name, const char *concentrator_name, +int ppp_over_ethernet_open(int unit, 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 */ diff --git a/src/netif/ppp/ppp_impl.h b/src/netif/ppp/ppp_impl.h index b6247c0b..34eaf11b 100644 --- a/src/netif/ppp/ppp_impl.h +++ b/src/netif/ppp/ppp_impl.h @@ -391,50 +391,6 @@ struct pppd_stats { }; #endif /* PPP_STATS_SUPPORT */ -/* FIXME: fill the struct below with option.c global variables */ - -struct ppp_settings { - - u_int disable_defaultip : 1; /* Don't use hostname for default IP addrs */ - u_int auth_required : 1; /* Peer is required to authenticate */ - u_int explicit_remote : 1; /* remote_name specified with remotename opt */ -#if PAP_SUPPORT - u_int refuse_pap : 1; /* Don't wanna auth. ourselves with PAP */ -#endif /* PAP_SUPPORT */ -#if CHAP_SUPPORT - u_int refuse_chap : 1; /* Don't wanna auth. ourselves with CHAP */ -#endif /* CHAP_SUPPORT */ -#if MSCHAP_SUPPORT - u_int refuse_mschap : 1; /* Don't wanna auth. ourselves with MS-CHAP */ - u_int refuse_mschap_v2 : 1; /* Don't wanna auth. ourselves with MS-CHAPv2 */ -#endif /* MSCHAP_SUPPORT */ -#if EAP_SUPPORT - u_int refuse_eap : 1; /* Don't wanna auth. ourselves with EAP */ -#endif /* EAP_SUPPORT */ - u_int usehostname : 1; /* Use hostname for our_name */ - u_int usepeerdns : 1; /* Ask peer for DNS adds */ - u_int persist : 1; /* Persist mode, always try to reopen the connection */ -#if PRINTPKT_SUPPORT - u_int hide_password : 1; /* Hide password in dumped packets */ -#endif /* PRINTPKT_SUPPORT */ - - u16_t listen_time; /* time to listen first (ms) */ - - /* FIXME: make it a compile time option */ - u16_t idle_time_limit; /* Disconnect if idle for this many seconds */ - int maxconnect; /* Maximum connect time (seconds) */ - - char user [MAXNAMELEN + 1]; /* Username for PAP */ - char passwd [MAXSECRETLEN + 1]; /* Password for PAP, secret for CHAP */ -#if PPP_SERVER - char our_name [MAXNAMELEN + 1]; /* Our name for authentication purposes */ -#endif /* PPP_SERVER */ - /* FIXME: make it a compile time option */ - char remote_name[MAXNAMELEN + 1]; /* Peer's name for authentication */ -}; - -struct ppp_settings ppp_settings; - /* * PPP interface RX control block. */ @@ -464,6 +420,8 @@ typedef struct ppp_control_rx_s { * 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 */ diff --git a/src/netif/ppp/upap.c b/src/netif/ppp/upap.c index 61a46eb7..fda03f49 100644 --- a/src/netif/ppp/upap.c +++ b/src/netif/ppp/upap.c @@ -655,6 +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]; if (plen < UPAP_HEADERLEN) return 0; @@ -688,7 +689,7 @@ upap_printpkt(p, plen, printer, arg) printer(arg, " user="); print_string(user, ulen, printer, arg); printer(arg, " password="); - if (!ppp_settings.hide_password) + if (!pc->settings.hide_password) print_string(pwd, wlen, printer, arg); else printer(arg, "");