From 5f3dc97eef6eb8ea60a9e3a96c48762c50a0d7fe Mon Sep 17 00:00:00 2001 From: Ansa89 Date: Tue, 8 Mar 2016 13:30:45 +0100 Subject: [PATCH] NAT traversal: move TOX_TRAVERSAL_TYPE into tox.h --- other/apidsl/tox.in.h | 27 +++++++++++++++++++++++++++ toxcore/Messenger.h | 1 + toxcore/network.h | 28 +--------------------------- toxcore/tox.c | 6 +++--- toxcore/tox.h | 29 ++++++++++++++++++++++++++++- 5 files changed, 60 insertions(+), 31 deletions(-) diff --git a/other/apidsl/tox.in.h b/other/apidsl/tox.in.h index 577515b1..0a8e581d 100644 --- a/other/apidsl/tox.in.h +++ b/other/apidsl/tox.in.h @@ -348,6 +348,28 @@ enum class PROXY_TYPE { SOCKS5, } +/** + * Type of technology used to try to traverse a NAT. + */ +enum class TRAVERSAL_TYPE { + /** + * Don't use any particular technology. + */ + NONE, + /** + * Use UPnP technology. + */ + UPNP, + /** + * Use NAT-PMP technology. + */ + NATPMP, + /** + * Use both UPnP and NAT-PMP technologies. + */ + ALL, +} + /** * Type of savedata to create the Tox instance from. */ @@ -393,6 +415,11 @@ static class options { */ bool udp_enabled; + /** + * Try to traverse a NAT. + */ + TRAVERSAL_TYPE traversal_type; + namespace proxy { /** * Pass communications through a proxy. diff --git a/toxcore/Messenger.h b/toxcore/Messenger.h index a7e81c8c..bfdfac4b 100644 --- a/toxcore/Messenger.h +++ b/toxcore/Messenger.h @@ -26,6 +26,7 @@ #ifndef MESSENGER_H #define MESSENGER_H +#include "tox.h" #include "friend_requests.h" #include "friend_connection.h" diff --git a/toxcore/network.h b/toxcore/network.h index f77fa2f2..4f0b06d7 100644 --- a/toxcore/network.h +++ b/toxcore/network.h @@ -34,6 +34,7 @@ #include #include #include +#include "tox.h" #if defined(_WIN32) || defined(__WIN32__) || defined (WIN32) /* Put win32 includes here */ #ifndef WINVER @@ -165,33 +166,6 @@ typedef struct { } IP_Port; -/** - * Type of technology used to try to traverse a NAT. - */ -typedef enum TOX_TRAVERSAL_TYPE { - - /** - * Don't use any particular technology. - */ - TOX_TRAVERSAL_TYPE_NONE, - - /** - * Use UPnP technology. - */ - TOX_TRAVERSAL_TYPE_UPNP, - - /** - * Use NAT-PMP technology. - */ - TOX_TRAVERSAL_TYPE_NATPMP, - - /** - * Use both UPnP and NAT-PMP technologies. - */ - TOX_TRAVERSAL_TYPE_ALL, - -} TOX_TRAVERSAL_TYPE; - /* Does the IP6 struct a contain an IPv4 address in an IPv6 one? */ #define IPV6_IPV4_IN_V6(a) ((a.uint64[0] == 0) && (a.uint32[2] == htonl (0xffff))) diff --git a/toxcore/tox.c b/toxcore/tox.c index 08824b1f..50ed5433 100644 --- a/toxcore/tox.c +++ b/toxcore/tox.c @@ -25,15 +25,15 @@ #include "config.h" #endif +#define TOX_DEFINED +typedef struct Messenger Tox; + #include "Messenger.h" #include "group.h" #include "logger.h" #include "../toxencryptsave/defines.h" -#define TOX_DEFINED -typedef struct Messenger Tox; - #include "tox.h" #define SET_ERROR_PARAMETER(param, x) {if(param) {*param = x;}} diff --git a/toxcore/tox.h b/toxcore/tox.h index 549a11b8..43e28145 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h @@ -27,7 +27,6 @@ #include #include #include -#include "network.h" #ifdef __cplusplus extern "C" { @@ -361,6 +360,34 @@ typedef enum TOX_PROXY_TYPE { } TOX_PROXY_TYPE; +/** + * Type of technology used to try to traverse a NAT. + */ +typedef enum TOX_TRAVERSAL_TYPE { + + /** + * Don't use any particular technology. + */ + TOX_TRAVERSAL_TYPE_NONE, + + /** + * Use UPnP technology. + */ + TOX_TRAVERSAL_TYPE_UPNP, + + /** + * Use NAT-PMP technology. + */ + TOX_TRAVERSAL_TYPE_NATPMP, + + /** + * Use both UPnP and NAT-PMP technologies. + */ + TOX_TRAVERSAL_TYPE_ALL, + +} TOX_TRAVERSAL_TYPE; + + /** * Type of savedata to create the Tox instance from. */