From 7132893863c0c9d5e4e52fd94c7854621258d8a7 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Mon, 16 Feb 2015 23:22:00 +0100 Subject: [PATCH] PPP, PPPoS, re-enabled PPPCTLG_FD Found a fine way to get PPP fd without making this call crash for for PPPoE or PPPoL2TP. --- src/include/netif/ppp/pppos.h | 4 ++++ src/netif/ppp/ppp.c | 4 ++-- src/netif/ppp/pppos.c | 9 +++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/include/netif/ppp/pppos.h b/src/include/netif/ppp/pppos.h index 57fca08e..5b89803b 100644 --- a/src/include/netif/ppp/pppos.h +++ b/src/include/netif/ppp/pppos.h @@ -37,6 +37,9 @@ #ifndef PPPOS_H #define PPPOS_H +#include "lwip/sys.h" +#include "lwip/sio.h" + #include "ppp.h" #include "vj.h" @@ -61,6 +64,7 @@ ppp_pcb *ppp_over_serial_create(struct netif *pppif, sio_fd_t fd, void pppos_input(ppp_pcb *ppp, u_char* data, int len); +sio_fd_t pppos_get_fd(pppos_pcb *pppos); void pppos_vjc_config(pppos_pcb *pppos, int vjcomp, int cidcomp, int maxcid); 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 2a446a65..bc022806 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -773,10 +773,10 @@ ppp_ioctl(ppp_pcb *pcb, int cmd, void *arg) return PPPERR_PARAM; break; -#if 0/*PPPOS_SUPPORT*/ +#if PPPOS_SUPPORT case PPPCTLG_FD: /* Get the fd associated with the ppp */ if (arg) { - *(sio_fd_t *)arg = pcb->fd; + *(sio_fd_t *)arg = pppos_get_fd((pppos_pcb*)pcb->link_ctx_cb); return PPPERR_NONE; } return PPPERR_PARAM; diff --git a/src/netif/ppp/pppos.c b/src/netif/ppp/pppos.c index 8c5715fe..5536f15a 100644 --- a/src/netif/ppp/pppos.c +++ b/src/netif/ppp/pppos.c @@ -743,6 +743,15 @@ drop: } #endif /* PPP_INPROC_MULTITHREADED */ +sio_fd_t +pppos_get_fd(pppos_pcb *pppos) +{ + if (!pppos_exist(pppos)) { + return 0; + } + return pppos->fd; +} + #if VJ_SUPPORT void pppos_vjc_config(pppos_pcb *pppos, int vjcomp, int cidcomp, int maxcid)