summaryrefslogtreecommitdiff
path: root/src/SDK_LWIPStack.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/SDK_LWIPStack.hpp')
-rw-r--r--src/SDK_LWIPStack.hpp68
1 files changed, 57 insertions, 11 deletions
diff --git a/src/SDK_LWIPStack.hpp b/src/SDK_LWIPStack.hpp
index 0a86402..74e9b23 100644
--- a/src/SDK_LWIPStack.hpp
+++ b/src/SDK_LWIPStack.hpp
@@ -60,15 +60,17 @@ struct tcp_pcb;
#define LWIP_HTONS_SIG u16_t x
#define LWIP_NTOHS_SIG u16_t x
#define IPADDR_NTOA_SIG const ip_addr_t *addr
-#if defined(LWIP_VERSION_2) // 2.0.0+
- #define ETHARP_OUTPUT_SIG struct netif *netif, struct pbuf *q, const ip_addr_t *ipaddr
-#else // 1.4.1
- #define ETHARP_OUTPUT_SIG struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr
-#endif
+
+#define ETHIP6_OUTPUT_SIG struct netif *netif, struct pbuf *q, const ip6_addr_t *ip6addr
+#define ETHARP_OUTPUT_SIG struct netif *netif, struct pbuf *q, const ip6_addr_t *ipaddr
+//#define ETHARP_OUTPUT_SIG struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr
+#define NETIF_ADD_SIG struct netif *netif, void *state, netif_init_fn init, netif_input_fn input
+//#define NETIF_ADD_SIG struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, ip_addr_t *gw, void *state, netif_init_fn init, netif_input_fn input
+
+
#define ETHERNET_INPUT_SIG struct pbuf *p, struct netif *netif
#define IP_INPUT_SIG struct pbuf *p, struct netif *inp
#define NETIF_SET_DEFAULT_SIG struct netif *netif
-#define NETIF_ADD_SIG struct netif *netif, ip_addr_t *ipaddr, ip_addr_t *netmask, ip_addr_t *gw, void *state, netif_init_fn init, netif_input_fn input
#define NETIF_SET_UP_SIG struct netif *netif
#define NETIF_POLL_SIG struct netif *netif
@@ -100,11 +102,16 @@ struct tcp_pcb;
#define TCP_ACCEPT_SIG struct tcp_pcb * pcb, err_t (* accept)(void * arg, struct tcp_pcb * newpcb, err_t err)
#define TCP_LISTEN_SIG struct tcp_pcb * pcb
#define TCP_LISTEN_WITH_BACKLOG_SIG struct tcp_pcb * pcb, u8_t backlog
-#define TCP_BIND_SIG struct tcp_pcb * pcb, ip_addr_t * ipaddr, u16_t port
+#define TCP_BIND_SIG struct tcp_pcb * pcb, const ip_addr_t * ipaddr, u16_t port
#define TCP_INPUT_SIG struct pbuf *p, struct netif *inp
void dwr(int level, const char *fmt, ... );
+#define NETIF_IP6_ADDR_SET_STATE_SIG struct netif* netif, s8_t addr_idx, u8_t state
+#define NETIF_LOOPIF_INIT_SIG struct netif *netif
+#define NETIF_CREATE_IP6_LINKLOCAL_ADDRESS_SIG struct netif *netif, u8_t from_mac_48bit
+//#define NETIF_SET_ADDR_SIG struct netif *netif, const ip4_addr_t *ipaddr, const ip4_addr_t *netmask, const ip4_addr_t *gw
+
namespace ZeroTier {
/**
@@ -129,7 +136,16 @@ namespace ZeroTier {
dlclose(_libref);
#endif
}
-
+
+ void (*_netif_init)(void);
+ void (*_nd6_tmr)(void);
+ void (*_netif_ip6_addr_set_state)(NETIF_IP6_ADDR_SET_STATE_SIG);
+ void (*_netif_loopif_init)(NETIF_LOOPIF_INIT_SIG);
+ void (*_netif_create_ip6_linklocal_address)(NETIF_CREATE_IP6_LINKLOCAL_ADDRESS_SIG);
+ err_t (*_ethip6_output)(ETHIP6_OUTPUT_SIG);
+
+ // void (*_netif_set_addr)(NETIF_SET_ADDR_SIG);
+
void (*_lwip_init)();
err_t (*_tcp_write)(TCP_WRITE_SIG);
void (*_tcp_sent)(TCP_SENT_SIG);
@@ -202,6 +218,14 @@ namespace ZeroTier {
#endif
#ifdef __STATIC_LWIP__ // Set static references (for use in iOS)
+
+ _netif_init = (void(*)(void))&netif_init;
+ _nd6_tmr = (void(*)(void))&nd6_tmr;
+ _netif_ip6_addr_set_state = (void(*)(NETIF_IP6_ADDR_SET_STATE_SIG))&netif_ip6_addr_set_state;
+ _netif_loopif_init = (void(*)(NETIF_LOOPIF_INIT_SIG))&netif_loopif_init;
+ _netif_create_ip6_linklocal_address = (void(*)(NETIF_CREATE_IP6_LINKLOCAL_ADDRESS_SIG))&netif_create_ip6_linklocal_address;
+ _ethip6_output = (err_t(*)(ETHIP6_OUTPUT_SIG))&ethip6_output;
+
_ethernet_input = (err_t(*)(ETHERNET_INPUT_SIG))&ethernet_input;
_etharp_output = (err_t(*)(ETHARP_OUTPUT_SIG))&etharp_output;
_lwip_init = (void(*)(void))&lwip_init;
@@ -247,7 +271,16 @@ namespace ZeroTier {
if(_libref == NULL)
DEBUG_ERROR("dlerror(): %s", dlerror());
-
+
+ _netif_init = (void(*)(void))dlsym(_libref, "netif_init");
+ _nd6_tmr = (void(*)(void))dlsym(_libref, "nd6_tmr");
+ _netif_ip6_addr_set_state = (void(*)(NETIF_IP6_ADDR_SET_STATE_SIG))dlsym(_libref, "netif_ip6_addr_set_state");
+ _netif_loopif_init = (void(*)(NETIF_LOOPIF_INIT_SIG))dlsym(_libref, "netif_loopif_init");
+ _netif_create_ip6_linklocal_address = (void(*)(NETIF_CREATE_IP6_LINKLOCAL_ADDRESS_SIG))dlsym(_libref, "netif_create_ip6_linklocal_address");
+ _ethip6_output = (err_t(*)(ETHIP6_OUTPUT_SIG))dlsym(_libref, "ethip6_output");
+
+ // _netif_set_addr = (void(*))(NETIF_SET_ADDR_SIG))dlsym(_libref, "netif_set_addr");
+
_ethernet_input = (err_t(*)(ETHERNET_INPUT_SIG))dlsym(_libref, "ethernet_input");
_etharp_output = (err_t(*)(ETHARP_OUTPUT_SIG))dlsym(_libref, "etharp_output");
_lwip_init = (void(*)(void))dlsym(_libref, "lwip_init");
@@ -298,6 +331,13 @@ namespace ZeroTier {
dlclose(_libref);
}
+ inline void __netif_init(void) throw() { Mutex::Lock _l(_lock); _netif_init(); }
+ inline void __nd6_tmr(void) throw() { Mutex::Lock _l(_lock); _nd6_tmr(); }
+ inline void __netif_ip6_addr_set_state(NETIF_IP6_ADDR_SET_STATE_SIG) throw() { Mutex::Lock _l(_lock); _netif_ip6_addr_set_state(netif, addr_idx, state); }
+ inline void __netif_loopif_init(NETIF_LOOPIF_INIT_SIG) throw() { Mutex::Lock _l(_lock); _netif_loopif_init(netif); }
+ inline void __netif_create_ip6_linklocal_address(NETIF_CREATE_IP6_LINKLOCAL_ADDRESS_SIG) throw() { Mutex::Lock _l(_lock); _netif_create_ip6_linklocal_address(netif, from_mac_48bit); }
+ // inline void __netif_set_addr(NETIF_SET_ADDR_SIG) throw() { Mutex::Lock _l(_lock); _netif_set_addr(netif, ipaddr, netmask, gw); }
+
inline void __lwip_init() throw() { Mutex::Lock _l(_lock); return _lwip_init(); }
inline err_t __tcp_write(TCP_WRITE_SIG) throw() { Mutex::Lock _l(_lock); return _tcp_write(pcb,arg,len,apiflags); }
inline void __tcp_sent(TCP_SENT_SIG) throw() { Mutex::Lock _l(_lock); return _tcp_sent(pcb,sent); }
@@ -332,12 +372,18 @@ namespace ZeroTier {
inline u16_t __lwip_htons(LWIP_HTONS_SIG) throw() { Mutex::Lock _l(_lock); return _lwip_htons(x); }
inline u16_t __lwip_ntohs(LWIP_NTOHS_SIG) throw() { Mutex::Lock _l(_lock); return _lwip_ntohs(x); }
inline char* __ipaddr_ntoa(IPADDR_NTOA_SIG) throw() { Mutex::Lock _l(_lock); return _ipaddr_ntoa(addr); }
- inline err_t __etharp_output(ETHARP_OUTPUT_SIG) throw() { Mutex::Lock _l(_lock); return _etharp_output(netif,q,ipaddr); }
+
+
+ inline err_t __ethip6_output(ETHIP6_OUTPUT_SIG) throw() { Mutex::Lock _l(_lock); return _ethip6_output(netif,q,ip6addr); }
+ //inline err_t __etharp_output(ETHARP_OUTPUT_SIG) throw() { Mutex::Lock _l(_lock); return _etharp_output(netif,q,ipaddr); }
+ inline struct netif * __netif_add(NETIF_ADD_SIG) throw() { Mutex::Lock _l(_lock); return _netif_add(netif,state,init,input); }
+ //inline struct netif * __netif_add(NETIF_ADD_SIG) throw() { Mutex::Lock _l(_lock); return _netif_add(netif,ipaddr,netmask,gw,state,init,input); }
+
+
inline err_t __ethernet_input(ETHERNET_INPUT_SIG) throw() { Mutex::Lock _l(_lock); return _ethernet_input(p,netif); }
inline void __tcp_input(TCP_INPUT_SIG) throw() { Mutex::Lock _l(_lock); return _tcp_input(p,inp); }
inline err_t __ip_input(IP_INPUT_SIG) throw() { Mutex::Lock _l(_lock); return _ip_input(p,inp); }
inline void __netif_set_default(NETIF_SET_DEFAULT_SIG) throw() { Mutex::Lock _l(_lock); return _netif_set_default(netif); }
- inline struct netif * __netif_add(NETIF_ADD_SIG) throw() { Mutex::Lock _l(_lock); return _netif_add(netif,ipaddr,netmask,gw,state,init,input); }
inline void __netif_set_up(NETIF_SET_UP_SIG) throw() { Mutex::Lock _l(_lock); return _netif_set_up(netif); }
};