From 3d684cda230da82bcde7d7d39590343fde174cee Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Sun, 26 Jun 2016 20:26:35 +0200 Subject: [PATCH] PPP, PPPoS, SERVER: remove useless struct ppp_addrs* argument from pppos_listen Now that we have helpers to set those members externaly, pppos_listen struct ppp_addrs* argument does not add any value. In addition it was not a well chosen design choice because the user needed to keep a copy of struct ppp_addrs when listening again for a new connection. --- src/include/netif/ppp/ppp.h | 5 +---- src/include/netif/ppp/ppp_impl.h | 2 +- src/include/netif/ppp/pppapi.h | 7 +------ src/netif/ppp/ppp.c | 7 ++----- src/netif/ppp/pppapi.c | 5 ++--- src/netif/ppp/pppos.c | 25 ++++--------------------- 6 files changed, 11 insertions(+), 40 deletions(-) diff --git a/src/include/netif/ppp/ppp.h b/src/include/netif/ppp/ppp.h index b9f302cd..98d60790 100644 --- a/src/include/netif/ppp/ppp.h +++ b/src/include/netif/ppp/ppp.h @@ -505,13 +505,10 @@ err_t ppp_connect(ppp_pcb *pcb, u16_t holdoff); * * This can only be called if PPP is in the dead phase. * - * Local and remote interface IP addresses, as well as DNS are - * provided through a previously filled struct ppp_addrs. - * * If this port connects to a modem, the modem connection must be * established before calling this. */ -err_t ppp_listen(ppp_pcb *pcb, const struct ppp_addrs *addrs); +err_t ppp_listen(ppp_pcb *pcb); #endif /* PPP_SERVER */ /* diff --git a/src/include/netif/ppp/ppp_impl.h b/src/include/netif/ppp/ppp_impl.h index 7e6f3390..b98d6286 100644 --- a/src/include/netif/ppp/ppp_impl.h +++ b/src/include/netif/ppp/ppp_impl.h @@ -141,7 +141,7 @@ struct link_callbacks { err_t (*connect) (ppp_pcb *pcb, void *ctx); #if PPP_SERVER /* Listen for an incoming connection (Passive mode) */ - err_t (*listen) (ppp_pcb *pcb, void *ctx, const struct ppp_addrs *addrs); + err_t (*listen) (ppp_pcb *pcb, void *ctx); #endif /* PPP_SERVER */ /* End a connection (i.e. initiate disconnect phase) */ void (*disconnect) (ppp_pcb *pcb, void *ctx); diff --git a/src/include/netif/ppp/pppapi.h b/src/include/netif/ppp/pppapi.h index 1d72e266..c5974e1e 100644 --- a/src/include/netif/ppp/pppapi.h +++ b/src/include/netif/ppp/pppapi.h @@ -92,11 +92,6 @@ struct pppapi_msg_msg { struct { u16_t holdoff; } connect; -#if PPP_SERVER - struct { - API_MSG_M_DEF_C(struct ppp_addrs, addrs); - } listen; -#endif /* PPP_SERVER */ struct { u8_t nocarrier; } close; @@ -133,7 +128,7 @@ ppp_pcb *pppapi_pppol2tp_create(struct netif *pppif, struct netif *netif, ip_add #endif /* PPPOL2TP_SUPPORT */ err_t pppapi_connect(ppp_pcb *pcb, u16_t holdoff); #if PPP_SERVER -err_t pppapi_listen(ppp_pcb *pcb, struct ppp_addrs *addrs); +err_t pppapi_listen(ppp_pcb *pcb); #endif /* PPP_SERVER */ err_t pppapi_close(ppp_pcb *pcb, u8_t nocarrier); err_t pppapi_free(ppp_pcb *pcb); diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index c48959b2..70db122c 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -274,13 +274,10 @@ err_t ppp_connect(ppp_pcb *pcb, u16_t holdoff) { * * This can only be called if PPP is in the dead phase. * - * Local and remote interface IP addresses, as well as DNS are - * provided through a previously filled struct ppp_addrs. - * * If this port connects to a modem, the modem connection must be * established before calling this. */ -err_t ppp_listen(ppp_pcb *pcb, const struct ppp_addrs *addrs) { +err_t ppp_listen(ppp_pcb *pcb) { if (pcb->phase != PPP_PHASE_DEAD) { return ERR_ALREADY; } @@ -288,7 +285,7 @@ err_t ppp_listen(ppp_pcb *pcb, const struct ppp_addrs *addrs) { PPPDEBUG(LOG_DEBUG, ("ppp_listen[%d]\n", pcb->netif->num)); if (pcb->link_cb->listen) { - return pcb->link_cb->listen(pcb, pcb->link_ctx_cb, addrs); + return pcb->link_cb->listen(pcb, pcb->link_ctx_cb); } return ERR_IF; } diff --git a/src/netif/ppp/pppapi.c b/src/netif/ppp/pppapi.c index 9120a549..8dc54f80 100644 --- a/src/netif/ppp/pppapi.c +++ b/src/netif/ppp/pppapi.c @@ -321,7 +321,7 @@ pppapi_do_ppp_listen(struct tcpip_api_call_data *m) { struct pppapi_msg *msg = (struct pppapi_msg *)m; - return ppp_listen(msg->msg.ppp, API_EXPR_REF(msg->msg.msg.listen.addrs)); + return ppp_listen(msg->msg.ppp); } /** @@ -329,14 +329,13 @@ pppapi_do_ppp_listen(struct tcpip_api_call_data *m) * tcpip_thread context. */ err_t -pppapi_listen(ppp_pcb *pcb, struct ppp_addrs *addrs) +pppapi_listen(ppp_pcb *pcb) { err_t err; PPPAPI_VAR_DECLARE(msg); PPPAPI_VAR_ALLOC(msg); PPPAPI_VAR_REF(msg).msg.ppp = pcb; - PPPAPI_VAR_REF(msg).msg.msg.listen.addrs = PPPAPI_VAR_REF(addrs); err = tcpip_api_call(pppapi_do_ppp_listen, &PPPAPI_VAR_REF(msg).call); PPPAPI_VAR_FREE(msg); return err; diff --git a/src/netif/ppp/pppos.c b/src/netif/ppp/pppos.c index 38a2b786..47548d54 100644 --- a/src/netif/ppp/pppos.c +++ b/src/netif/ppp/pppos.c @@ -58,7 +58,7 @@ static err_t pppos_write(ppp_pcb *ppp, void *ctx, struct pbuf *p); static err_t pppos_netif_output(ppp_pcb *ppp, void *ctx, struct pbuf *pb, u16_t protocol); static err_t pppos_connect(ppp_pcb *ppp, void *ctx); #if PPP_SERVER -static err_t pppos_listen(ppp_pcb *ppp, void *ctx, const struct ppp_addrs *addrs); +static err_t pppos_listen(ppp_pcb *ppp, void *ctx); #endif /* PPP_SERVER */ static void pppos_disconnect(ppp_pcb *ppp, void *ctx); static err_t pppos_destroy(ppp_pcb *ppp, void *ctx); @@ -332,15 +332,9 @@ pppos_connect(ppp_pcb *ppp, void *ctx) #if PPP_SERVER static err_t -pppos_listen(ppp_pcb *ppp, void *ctx, const struct ppp_addrs *addrs) +pppos_listen(ppp_pcb *ppp, void *ctx) { pppos_pcb *pppos = (pppos_pcb *)ctx; -#if PPP_IPV4_SUPPORT - ipcp_options *ipcp_wo; -#if LWIP_DNS - ipcp_options *ipcp_ao; -#endif /* LWIP_DNS */ -#endif /* PPP_IPV4_SUPPORT */ lcp_options *lcp_wo; PPPOS_DECL_PROTECT(lev); @@ -363,21 +357,10 @@ pppos_listen(ppp_pcb *ppp, void *ctx, const struct ppp_addrs *addrs) } #endif /* PPP_AUTH_SUPPORT */ -#if PPP_IPV4_SUPPORT - ipcp_wo = &ppp->ipcp_wantoptions; - ipcp_wo->ouraddr = ip4_addr_get_u32(&addrs->our_ipaddr); - ipcp_wo->hisaddr = ip4_addr_get_u32(&addrs->his_ipaddr); -#if LWIP_DNS +#if PPP_IPV4_SUPPORT && LWIP_DNS /* Don't accept DNS from peer */ ppp->settings.usepeerdns = 0; - - ipcp_ao = &ppp->ipcp_allowoptions; - ipcp_ao->dnsaddr[0] = ip4_addr_get_u32(&addrs->dns1); - ipcp_ao->dnsaddr[1] = ip4_addr_get_u32(&addrs->dns2); -#endif /* LWIP_DNS */ -#else /* PPP_IPV4_SUPPORT */ - LWIP_UNUSED_ARG(addrs); -#endif /* PPP_IPV4_SUPPORT */ +#endif /* PPP_IPV4_SUPPORT && LWIP_DNS */ /* * Default the in and out accm so that escape and flag characters