Expose lwIP's DNS API in zts_* API. Fix preprocessor build bug
This commit is contained in:
@@ -17,11 +17,20 @@
|
||||
* Custom signal handler
|
||||
*/
|
||||
|
||||
#include "ZeroTierSockets.h"
|
||||
#include "Signals.hpp"
|
||||
#ifdef ZTS_ENABLE_PYTHON
|
||||
/**
|
||||
* In some situations (Python comes to mind) a signal may not make its
|
||||
* way to libzt, for this reason we make sure to define a custom signal
|
||||
* handler that can at least process SIGTERMs
|
||||
*/
|
||||
#define ZTS_ENABLE_CUSTOM_SIGNAL_HANDLERS 1
|
||||
#endif
|
||||
|
||||
#ifdef ZTS_ENABLE_CUSTOM_SIGNAL_HANDLERS
|
||||
|
||||
#include "ZeroTierSockets.h"
|
||||
#include "Signals.hpp"
|
||||
|
||||
#include <signal.h>
|
||||
#include <execinfo.h>
|
||||
#include <cstdlib>
|
||||
|
||||
@@ -21,6 +21,9 @@
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/inet.h"
|
||||
#include "lwip/stats.h"
|
||||
#include "lwip/netdb.h"
|
||||
#include "lwip/dns.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
|
||||
#include "ZeroTierSockets.h"
|
||||
|
||||
@@ -294,23 +297,54 @@ int zts_shutdown(int fd, int how)
|
||||
return lwip_shutdown(fd, how);
|
||||
}
|
||||
|
||||
int zts_add_dns_nameserver(struct zts_sockaddr *addr)
|
||||
struct zts_hostent *zts_gethostbyname(const char *name)
|
||||
{
|
||||
if (!(_serviceStateFlags & ZTS_STATE_NET_SERVICE_RUNNING)) {
|
||||
return NULL;
|
||||
}
|
||||
if (!name) {
|
||||
return NULL;
|
||||
}
|
||||
return (struct zts_hostent *)lwip_gethostbyname(name);
|
||||
}
|
||||
|
||||
int zts_dns_set_server(uint8_t index, const zts_ip_addr *addr)
|
||||
{
|
||||
if (!(_serviceStateFlags & ZTS_STATE_NET_SERVICE_RUNNING)) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
}
|
||||
return ZTS_ERR_SERVICE; // TODO
|
||||
if (index >= DNS_MAX_SERVERS) {
|
||||
return ZTS_ERR_ARG;
|
||||
}
|
||||
if (!addr) {
|
||||
return ZTS_ERR_ARG;
|
||||
}
|
||||
dns_setserver(index, (const ip_addr_t *)addr);
|
||||
return ZTS_ERR_OK;
|
||||
}
|
||||
|
||||
int zts_del_dns_nameserver(struct zts_sockaddr *addr)
|
||||
const zts_ip_addr *zts_dns_get_server(uint8_t index)
|
||||
{
|
||||
if (!(_serviceStateFlags & ZTS_STATE_NET_SERVICE_RUNNING)) {
|
||||
return ZTS_ERR_SERVICE;
|
||||
return NULL;
|
||||
}
|
||||
return ZTS_ERR_SERVICE; // TODO
|
||||
if (index >= DNS_MAX_SERVERS) {
|
||||
return NULL;
|
||||
}
|
||||
return (const zts_ip_addr *)dns_getserver(index);
|
||||
}
|
||||
|
||||
const char *zts_inet_ntop(int af, const void *src, char *dst,zts_socklen_t size)
|
||||
char *zts_ipaddr_ntoa(const zts_ip_addr *addr)
|
||||
{
|
||||
return ipaddr_ntoa((ip_addr_t *)addr);
|
||||
}
|
||||
|
||||
int zts_ipaddr_aton(const char *cp, zts_ip_addr *addr)
|
||||
{
|
||||
return ipaddr_aton(cp, (ip_addr_t *)addr);
|
||||
}
|
||||
|
||||
const char *zts_inet_ntop(int af, const void *src, char *dst, zts_socklen_t size)
|
||||
{
|
||||
return lwip_inet_ntop(af,src,dst,size);
|
||||
}
|
||||
|
||||
@@ -224,11 +224,6 @@ void _lwip_driver_shutdown();
|
||||
*/
|
||||
void _lwip_remove_netif(void *netif);
|
||||
|
||||
/**
|
||||
* @brief Initialize and start the DNS client
|
||||
*/
|
||||
void _lwip_dns_init();
|
||||
|
||||
/**
|
||||
* @brief Starts DHCP timers
|
||||
*/
|
||||
|
||||
@@ -887,14 +887,14 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_zts_sendto(int jarg1, void * jarg2, unsigne
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_zts_sendmsg(int jarg1, void * jarg2, int jarg3) {
|
||||
void * jresult ;
|
||||
int arg1 ;
|
||||
msghdr *arg2 = (msghdr *) 0 ;
|
||||
zts_msghdr *arg2 = (zts_msghdr *) 0 ;
|
||||
int arg3 ;
|
||||
ssize_t result;
|
||||
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (msghdr *)jarg2;
|
||||
arg2 = (zts_msghdr *)jarg2;
|
||||
arg3 = (int)jarg3;
|
||||
result = zts_sendmsg(arg1,(msghdr const *)arg2,arg3);
|
||||
result = zts_sendmsg(arg1,(zts_msghdr const *)arg2,arg3);
|
||||
jresult = new ssize_t((const ssize_t &)result);
|
||||
return jresult;
|
||||
}
|
||||
@@ -942,12 +942,12 @@ SWIGEXPORT void * SWIGSTDCALL CSharp_zts_recvfrom(int jarg1, void * jarg2, unsig
|
||||
SWIGEXPORT void * SWIGSTDCALL CSharp_zts_recvmsg(int jarg1, void * jarg2, int jarg3) {
|
||||
void * jresult ;
|
||||
int arg1 ;
|
||||
msghdr *arg2 = (msghdr *) 0 ;
|
||||
zts_msghdr *arg2 = (zts_msghdr *) 0 ;
|
||||
int arg3 ;
|
||||
ssize_t result;
|
||||
|
||||
arg1 = (int)jarg1;
|
||||
arg2 = (msghdr *)jarg2;
|
||||
arg2 = (zts_msghdr *)jarg2;
|
||||
arg3 = (int)jarg3;
|
||||
result = zts_recvmsg(arg1,arg2,arg3);
|
||||
jresult = new ssize_t((const ssize_t &)result);
|
||||
@@ -1032,8 +1032,8 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_shutdown(int jarg1, int jarg2) {
|
||||
return jresult;
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_add_dns_nameserver(zts_sockaddr* jarg1) {
|
||||
/*
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_dns_set_server(zts_sockaddr* jarg1) {
|
||||
int jresult ;
|
||||
zts_sockaddr *arg1 = (zts_sockaddr *) 0 ;
|
||||
int result;
|
||||
@@ -1045,7 +1045,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_add_dns_nameserver(zts_sockaddr* jarg1) {
|
||||
}
|
||||
|
||||
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_del_dns_nameserver(zts_sockaddr* jarg1) {
|
||||
SWIGEXPORT int SWIGSTDCALL CSharp_zts_dns_get_server(zts_sockaddr* jarg1) {
|
||||
int jresult ;
|
||||
zts_sockaddr *arg1 = (zts_sockaddr *) 0 ;
|
||||
int result;
|
||||
@@ -1055,6 +1055,7 @@ SWIGEXPORT int SWIGSTDCALL CSharp_zts_del_dns_nameserver(zts_sockaddr* jarg1) {
|
||||
jresult = result;
|
||||
return jresult;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
SWIGEXPORT char * SWIGSTDCALL CSharp_zts_inet_ntop(int jarg1, void * jarg2, char * jarg3, unsigned short jarg4) {
|
||||
|
||||
@@ -64,7 +64,6 @@ class _SwigNonDynamicMeta(type):
|
||||
import weakref
|
||||
|
||||
ZTS_ENABLE_PYTHON = _libzt.ZTS_ENABLE_PYTHON
|
||||
ZTS_ENABLE_CUSTOM_SIGNAL_HANDLERS = _libzt.ZTS_ENABLE_CUSTOM_SIGNAL_HANDLERS
|
||||
ZTS_EVENT_NODE_UP = _libzt.ZTS_EVENT_NODE_UP
|
||||
ZTS_EVENT_NODE_ONLINE = _libzt.ZTS_EVENT_NODE_ONLINE
|
||||
ZTS_EVENT_NODE_OFFLINE = _libzt.ZTS_EVENT_NODE_OFFLINE
|
||||
@@ -740,12 +739,76 @@ ZTS_SHUT_RDWR = _libzt.ZTS_SHUT_RDWR
|
||||
|
||||
def zts_shutdown(fd, how):
|
||||
return _libzt.zts_shutdown(fd, how)
|
||||
class zts_hostent(object):
|
||||
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
|
||||
__repr__ = _swig_repr
|
||||
h_name = property(_libzt.zts_hostent_h_name_get, _libzt.zts_hostent_h_name_set)
|
||||
h_aliases = property(_libzt.zts_hostent_h_aliases_get, _libzt.zts_hostent_h_aliases_set)
|
||||
h_addrtype = property(_libzt.zts_hostent_h_addrtype_get, _libzt.zts_hostent_h_addrtype_set)
|
||||
h_length = property(_libzt.zts_hostent_h_length_get, _libzt.zts_hostent_h_length_set)
|
||||
h_addr_list = property(_libzt.zts_hostent_h_addr_list_get, _libzt.zts_hostent_h_addr_list_set)
|
||||
|
||||
def zts_add_dns_nameserver(addr):
|
||||
return _libzt.zts_add_dns_nameserver(addr)
|
||||
def __init__(self):
|
||||
_libzt.zts_hostent_swiginit(self, _libzt.new_zts_hostent())
|
||||
__swig_destroy__ = _libzt.delete_zts_hostent
|
||||
|
||||
def zts_del_dns_nameserver(addr):
|
||||
return _libzt.zts_del_dns_nameserver(addr)
|
||||
# Register zts_hostent in _libzt:
|
||||
_libzt.zts_hostent_swigregister(zts_hostent)
|
||||
|
||||
|
||||
def zts_gethostbyname(name):
|
||||
return _libzt.zts_gethostbyname(name)
|
||||
ZTS_IPADDR_TYPE_V4 = _libzt.ZTS_IPADDR_TYPE_V4
|
||||
ZTS_IPADDR_TYPE_V6 = _libzt.ZTS_IPADDR_TYPE_V6
|
||||
ZTS_IPADDR_TYPE_ANY = _libzt.ZTS_IPADDR_TYPE_ANY
|
||||
class zts_ip4_addr(object):
|
||||
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
|
||||
__repr__ = _swig_repr
|
||||
addr = property(_libzt.zts_ip4_addr_addr_get, _libzt.zts_ip4_addr_addr_set)
|
||||
|
||||
def __init__(self):
|
||||
_libzt.zts_ip4_addr_swiginit(self, _libzt.new_zts_ip4_addr())
|
||||
__swig_destroy__ = _libzt.delete_zts_ip4_addr
|
||||
|
||||
# Register zts_ip4_addr in _libzt:
|
||||
_libzt.zts_ip4_addr_swigregister(zts_ip4_addr)
|
||||
|
||||
class zts_ip6_addr(object):
|
||||
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
|
||||
__repr__ = _swig_repr
|
||||
addr = property(_libzt.zts_ip6_addr_addr_get, _libzt.zts_ip6_addr_addr_set)
|
||||
|
||||
def __init__(self):
|
||||
_libzt.zts_ip6_addr_swiginit(self, _libzt.new_zts_ip6_addr())
|
||||
__swig_destroy__ = _libzt.delete_zts_ip6_addr
|
||||
|
||||
# Register zts_ip6_addr in _libzt:
|
||||
_libzt.zts_ip6_addr_swigregister(zts_ip6_addr)
|
||||
|
||||
class zts_ip_addr(object):
|
||||
thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag")
|
||||
__repr__ = _swig_repr
|
||||
type = property(_libzt.zts_ip_addr_type_get, _libzt.zts_ip_addr_type_set)
|
||||
|
||||
def __init__(self):
|
||||
_libzt.zts_ip_addr_swiginit(self, _libzt.new_zts_ip_addr())
|
||||
__swig_destroy__ = _libzt.delete_zts_ip_addr
|
||||
|
||||
# Register zts_ip_addr in _libzt:
|
||||
_libzt.zts_ip_addr_swigregister(zts_ip_addr)
|
||||
|
||||
|
||||
def zts_dns_set_server(index, addr):
|
||||
return _libzt.zts_dns_set_server(index, addr)
|
||||
|
||||
def zts_dns_get_server(index):
|
||||
return _libzt.zts_dns_get_server(index)
|
||||
|
||||
def zts_ipaddr_ntoa(addr):
|
||||
return _libzt.zts_ipaddr_ntoa(addr)
|
||||
|
||||
def zts_ipaddr_aton(cp, addr):
|
||||
return _libzt.zts_ipaddr_aton(cp, addr)
|
||||
|
||||
def zts_inet_ntop(af, src, dst, size):
|
||||
return _libzt.zts_inet_ntop(af, src, dst, size)
|
||||
|
||||
@@ -1199,7 +1199,7 @@ happening sooner than they should.
|
||||
* transport.
|
||||
*/
|
||||
#if !defined LWIP_DNS || defined __DOXYGEN__
|
||||
#define LWIP_DNS 0
|
||||
#define LWIP_DNS 1
|
||||
#endif
|
||||
|
||||
/** DNS maximum number of entries to maintain locally. */
|
||||
@@ -1710,7 +1710,7 @@ happening sooner than they should.
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LWIP_NETIF_EXT_STATUS_CALLBACK==1: Support an extended callback function
|
||||
* LWIP_NETIF_EXT_STATUS_CALLBACK==1: Support an extended callback function
|
||||
* for several netif related event that supports multiple subscribers.
|
||||
* @see netif_ext_status_callback
|
||||
*/
|
||||
@@ -2324,7 +2324,7 @@ happening sooner than they should.
|
||||
* All addresses that have a scope according to the default policy (link-local
|
||||
* unicast addresses, interface-local and link-local multicast addresses) should
|
||||
* now have a zone set on them before being passed to the core API, although
|
||||
* lwIP will currently attempt to select a zone on the caller's behalf when
|
||||
* lwIP will currently attempt to select a zone on the caller's behalf when
|
||||
* necessary. Applications that directly assign IPv6 addresses to interfaces
|
||||
* (which is NOT recommended) must now ensure that link-local addresses carry
|
||||
* the netif's zone. See the new ip6_zone.h header file for more information and
|
||||
@@ -2962,8 +2962,8 @@ happening sooner than they should.
|
||||
* - src: source eth address
|
||||
* - dst: destination eth address
|
||||
* - eth_type: ethernet type to packet to be sent\n
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
* Return values:
|
||||
* - <0: Packet shall not contain VLAN header.
|
||||
* - 0 <= return value <= 0xFFFF: Packet shall contain VLAN header. Return value is prio_vid in host byte order.
|
||||
@@ -3451,4 +3451,4 @@ happening sooner than they should.
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* LWIP_HDR_OPT_H */
|
||||
#endif /* LWIP_HDR_OPT_H */
|
||||
|
||||
Reference in New Issue
Block a user