From 9778b1411c5af07622819cd8f62bfbb3bac71eb4 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Wed, 11 Mar 2015 00:58:09 +0100 Subject: [PATCH] PPP, PPPoS, TCPIP: add packet input path for point to point interfaces (only PPPoS for now) through the TCPIP API !NO_SYS users may now use as well the TCPIP API for PPPoS input data, this way they can disable PPP_INPROC_MULTITHREADED and run pppos_input() inside the lwIP thread, which fixes, at least for them, all the threading issues related to PPP_INPROC_MULTITHREADED. --- src/api/tcpip.c | 7 +++++++ src/netif/ppp/pppos.c | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/api/tcpip.c b/src/api/tcpip.c index fc8a7867..1880bc1b 100644 --- a/src/api/tcpip.c +++ b/src/api/tcpip.c @@ -114,6 +114,13 @@ tcpip_thread(void *arg) ethernet_input(msg->msg.inp.p, msg->msg.inp.netif); } else #endif /* LWIP_ETHERNET */ +#if PPPOS_SUPPORT + /* FIXME: can be generalized to all point to point interfaces */ + if ((msg->msg.inp.netif->flags & NETIF_FLAG_BROADCAST) == 0 + && msg->msg.inp.netif->input) { + msg->msg.inp.netif->input(msg->msg.inp.p, msg->msg.inp.netif); + } else +#endif /* PPPOS_SUPPORT */ #if LWIP_IPV6 if (((*(u8_t*)(msg->msg.inp.p->payload)) & 0xf0) == 0x60) { ip6_input(msg->msg.inp.p, msg->msg.inp.netif); diff --git a/src/netif/ppp/pppos.c b/src/netif/ppp/pppos.c index 89d112a4..2dce3403 100644 --- a/src/netif/ppp/pppos.c +++ b/src/netif/ppp/pppos.c @@ -68,6 +68,9 @@ static err_t pppos_netif_input(ppp_pcb *ppp, void *ctx, struct pbuf *p, u16_t pr #endif /* VJ_SUPPORT */ /* Prototypes for procedures local to this file. */ +#if !NO_SYS +static err_t pppos_input_sys(struct pbuf *p, struct netif *inp); +#endif /* !NO_SYS */ #if PPP_INPROC_MULTITHREADED static void pppos_input_callback(void *arg); #endif /* PPP_INPROC_MULTITHREADED */ @@ -200,6 +203,9 @@ ppp_pcb *pppos_create(struct netif *pppif, sio_fd_t fd, pppos->ppp = ppp; pppos->fd = fd; +#if !NO_SYS + ppp->netif->input = pppos_input_sys; +#endif /* !NO_SYS */ ppp_link_set_callbacks(ppp, &pppos_callbacks, pppos); return ppp; } @@ -521,6 +527,19 @@ pppos_destroy(ppp_pcb *ppp, void *ctx) return ERR_OK; } +#if !NO_SYS +static err_t pppos_input_sys(struct pbuf *p, struct netif *inp) { + ppp_pcb *ppp = (ppp_pcb*)inp->state; + struct pbuf *n; + + for (n = p; n; n = n->next) { + pppos_input(ppp, (u8_t*)n->payload, n->len); + } + pbuf_free(p); + return ERR_OK; +} +#endif /* !NO_SYS */ + /** PPPoS input helper struct, must be packed since it is stored * to pbuf->payload, which might be unaligned. */ #if PPP_INPROC_MULTITHREADED