From 729e24da781fd152cdf42057eef1b4ba7a18202a Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Fri, 20 Feb 2015 00:01:05 +0100 Subject: [PATCH] PPP, PPPoS, added sub-ioctl commands Allow low level drivers to extend ioctl call, moved PPPoS ioctl commands to pppos.c. --- src/include/netif/ppp/ppp_impl.h | 2 ++ src/include/netif/ppp/pppos.h | 1 - src/netif/ppp/ppp.c | 14 +++----------- src/netif/ppp/pppoe.c | 1 + src/netif/ppp/pppol2tp.c | 1 + src/netif/ppp/pppos.c | 28 +++++++++++++++++++++------- 6 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/include/netif/ppp/ppp_impl.h b/src/include/netif/ppp/ppp_impl.h index cde5dcfd..c6f16fc3 100644 --- a/src/include/netif/ppp/ppp_impl.h +++ b/src/include/netif/ppp/ppp_impl.h @@ -163,6 +163,8 @@ struct link_callbacks { void (*recv_config)(ppp_pcb *pcb, void *ctx, u32_t accm); /* configure TCP header compression */ void (*vj_config)(ppp_pcb *pcb, void *ctx, int vjcomp, int cidcomp, int maxcid); + /* Get and set parameters for the given connection. */ + int (*ioctl)(ppp_pcb *pcb, void *ctx, int cmd, void *arg); }; /* diff --git a/src/include/netif/ppp/pppos.h b/src/include/netif/ppp/pppos.h index 9e9727f6..9cc52474 100644 --- a/src/include/netif/ppp/pppos.h +++ b/src/include/netif/ppp/pppos.h @@ -102,7 +102,6 @@ void pppos_input(ppp_pcb *ppp, u_char* data, int len); * * You may use them if you REALLY know what you are doing. */ -sio_fd_t pppos_get_fd(pppos_pcb *pppos); int pppos_vjc_comp(pppos_pcb *pppos, struct pbuf *pb); int pppos_vjc_uncomp(pppos_pcb *pppos, struct pbuf *pb); diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index c305aaec..65ed2610 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -368,18 +368,10 @@ ppp_ioctl(ppp_pcb *pcb, int cmd, void *arg) return PPPERR_PARAM; break; -#if PPPOS_SUPPORT - case PPPCTLG_FD: /* Get the fd associated with the ppp */ - if (arg) { - *(sio_fd_t *)arg = pppos_get_fd((pppos_pcb*)pcb->link_ctx_cb); - return PPPERR_NONE; - } - return PPPERR_PARAM; - break; -#endif /* PPPOS_SUPPORT */ - default: - break; + if (pcb->link_cb->ioctl) { + return pcb->link_cb->ioctl(pcb, pcb->link_ctx_cb, cmd, arg); + } } return PPPERR_PARAM; diff --git a/src/netif/ppp/pppoe.c b/src/netif/ppp/pppoe.c index 703c7ca8..8dce7ae5 100644 --- a/src/netif/ppp/pppoe.c +++ b/src/netif/ppp/pppoe.c @@ -156,6 +156,7 @@ static const struct link_callbacks pppoe_callbacks = { pppoe_netif_output, NULL, NULL, + NULL, NULL }; diff --git a/src/netif/ppp/pppol2tp.c b/src/netif/ppp/pppol2tp.c index 9c55fc94..4f086650 100644 --- a/src/netif/ppp/pppol2tp.c +++ b/src/netif/ppp/pppol2tp.c @@ -105,6 +105,7 @@ static const struct link_callbacks pppol2tp_callbacks = { pppol2tp_netif_output, NULL, NULL, + NULL, NULL }; diff --git a/src/netif/ppp/pppos.c b/src/netif/ppp/pppos.c index f681d73e..358fe6db 100644 --- a/src/netif/ppp/pppos.c +++ b/src/netif/ppp/pppos.c @@ -89,6 +89,7 @@ static void pppos_disconnect(ppp_pcb *ppp, void *ctx); static err_t pppos_destroy(ppp_pcb *ppp, void *ctx); static void pppos_send_config(ppp_pcb *ppp, void *ctx, u32_t accm); static void pppos_recv_config(ppp_pcb *ppp, void *ctx, u32_t accm); +static int pppos_ioctl(ppp_pcb *pcb, void *ctx, int cmd, void *arg); #if VJ_SUPPORT static void pppos_vjc_config(ppp_pcb *ppp, void *ctx, int vjcomp, int cidcomp, int maxcid); #endif /* VJ_SUPPORT */ @@ -112,10 +113,11 @@ static const struct link_callbacks pppos_callbacks = { pppos_send_config, pppos_recv_config, #if VJ_SUPPORT - pppos_vjc_config + pppos_vjc_config, #else /* VJ_SUPPORT */ - NULL + NULL, #endif /* VJ_SUPPORT */ + pppos_ioctl }; /* PPP's Asynchronous-Control-Character-Map. The mask array is used @@ -809,13 +811,25 @@ pppos_recv_config(ppp_pcb *ppp, void *ctx, u32_t accm) pppos->in_accm[0], pppos->in_accm[1], pppos->in_accm[2], pppos->in_accm[3])); } -sio_fd_t -pppos_get_fd(pppos_pcb *pppos) +static int +pppos_ioctl(ppp_pcb *pcb, void *ctx, int cmd, void *arg) { - if (!pppos_exist(pppos)) { - return 0; + pppos_pcb *pppos = (pppos_pcb *)ctx; + LWIP_UNUSED_ARG(pcb); + + switch(cmd) { + case PPPCTLG_FD: /* Get the fd associated with the ppp */ + if (!arg) { + goto fail; + } + *(sio_fd_t *)arg = pppos->fd; + return PPPERR_NONE; + + default: ; } - return pppos->fd; + +fail: + return PPPERR_PARAM; } #if VJ_SUPPORT