From 7ede02ca8bcef78f694619c046e9a39e098d9894 Mon Sep 17 00:00:00 2001 From: goldsimon Date: Thu, 14 Jan 2010 20:04:52 +0000 Subject: [PATCH] Fixed bug #27856: PPP: Set netif link- and status-callback by adding ppp_set_netif_statuscallback()/ppp_set_netif_linkcallback() --- CHANGELOG | 4 ++++ src/netif/ppp/ppp.c | 33 +++++++++++++++++++++++++++++++++ src/netif/ppp/ppp.h | 12 ++++++++---- 3 files changed, 45 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9dc0ed2c..b774a951 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,10 @@ HISTORY ++ New features: + 2010-01-14: Simon Goldschmidt + * ppp.c/.h: Fixed bug #27856: PPP: Set netif link- and status-callback + by adding ppp_set_netif_statuscallback()/ppp_set_netif_linkcallback() + 2010-01-13: Simon Goldschmidt * mem.c: The heap now may be moved to user-defined memory by defining LWIP_RAM_HEAP_POINTER as a void pointer to that memory's address diff --git a/src/netif/ppp/ppp.c b/src/netif/ppp/ppp.c index d1879674..3f9f7fd9 100644 --- a/src/netif/ppp/ppp.c +++ b/src/netif/ppp/ppp.c @@ -107,6 +107,9 @@ #include "netif/ppp_oe.h" #endif /* PPPOE_SUPPORT */ +#include "lwip/tcpip.h" +#include "lwip/api.h" + #include /*************************/ @@ -1951,4 +1954,34 @@ drop: } #endif /* PPPOE_SUPPORT */ +#if LWIP_NETIF_STATUS_CALLBACK +/** Set the status callback of a PPP's netif + * + * @param pd The PPP descriptor returned by pppOpen() + * @param status_callback pointer to the status callback function + * + * @see netif_set_status_callback + */ +void +ppp_set_netif_statuscallback(int pd, netif_status_callback_fn status_callback) +{ + netif_set_status_callback(&pppControl[pd].netif, status_callback); +} +#endif /* LWIP_NETIF_STATUS_CALLBACK */ + +#if LWIP_NETIF_LINK_CALLBACK +/** Set the link callback of a PPP's netif + * + * @param pd The PPP descriptor returned by pppOpen() + * @param link_callback pointer to the link callback function + * + * @see netif_set_link_callback + */ +void +ppp_set_netif_linkcallback(int pd, netif_status_callback_fn link_callback) +{ + netif_set_link_callback(&pppControl[pd].netif, link_callback); +} +#endif /* LWIP_NETIF_LINK_CALLBACK */ + #endif /* PPP_SUPPORT */ diff --git a/src/netif/ppp/ppp.h b/src/netif/ppp/ppp.h index f070b7ed..a8c81135 100644 --- a/src/netif/ppp/ppp.h +++ b/src/netif/ppp/ppp.h @@ -40,11 +40,8 @@ #include "lwip/def.h" #include "lwip/sio.h" -#include "lwip/api.h" -#include "lwip/sockets.h" #include "lwip/stats.h" #include "lwip/mem.h" -#include "lwip/tcpip.h" #include "lwip/netif.h" #include "lwip/sys.h" #include "lwip/timers.h" @@ -107,7 +104,7 @@ * OR MODIFICATIONS. */ -#define TIMEOUT(f, a, t) sys_untimeout((f), (a)); sys_timeout((t)*1000, (f), (a)) +#define TIMEOUT(f, a, t) do { sys_untimeout((f), (a)); sys_timeout((t)*1000, (f), (a)); } while(0) #define UNTIMEOUT(f, a) sys_untimeout((f), (a)) @@ -474,6 +471,13 @@ int cifdefaultroute (int, u32_t, u32_t); /* Get appropriate netmask for address */ u32_t GetMask (u32_t); +#if LWIP_NETIF_STATUS_CALLBACK +void ppp_set_netif_statuscallback(int pd, netif_status_callback_fn status_callback); +#endif /* LWIP_NETIF_STATUS_CALLBACK */ +#if LWIP_NETIF_LINK_CALLBACK +void ppp_set_netif_linkcallback(int pd, netif_status_callback_fn link_callback); +#endif /* LWIP_NETIF_LINK_CALLBACK */ + #endif /* PPP_SUPPORT */ #endif /* PPP_H */