From 22958342f12a2a907bbe52b797b17ad84ebd5457 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Fri, 20 May 2016 12:03:17 -0400 Subject: [PATCH] headers: move inclusion of networking APIs to Infohash --- include/opendht/infohash.h | 19 +++++++++++++------ include/opendht/node.h | 2 -- include/opendht/value.h | 12 ------------ 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/include/opendht/infohash.h b/include/opendht/infohash.h index ac54a7b7..5bd0ae8f 100644 --- a/include/opendht/infohash.h +++ b/include/opendht/infohash.h @@ -21,6 +21,18 @@ #include <msgpack.hpp> +#ifndef _WIN32 +#include <netinet/in.h> +#include <netdb.h> +#ifdef __ANDROID__ +typedef uint16_t in_port_t; +#endif +#else +#include <ws2tcpip.h> +typedef uint16_t sa_family_t; +typedef uint16_t in_port_t; +#endif + #include <iostream> #include <iomanip> #include <array> @@ -197,12 +209,7 @@ public: }; -static constexpr InfoHash zeroes {}; -static constexpr InfoHash ones = {std::array<uint8_t, HASH_LEN>{{ - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF -}}}; +static constexpr const InfoHash zeroes {}; struct NodeExport { InfoHash id; diff --git a/include/opendht/node.h b/include/opendht/node.h index 63ee310a..cd2813bc 100644 --- a/include/opendht/node.h +++ b/include/opendht/node.h @@ -24,8 +24,6 @@ #include "utils.h" #include "infohash.h" -#include <arpa/inet.h> - #include <list> namespace dht { diff --git a/include/opendht/value.h b/include/opendht/value.h index 23dbd7e4..e652ce54 100644 --- a/include/opendht/value.h +++ b/include/opendht/value.h @@ -26,18 +26,6 @@ #include <msgpack.hpp> -#ifndef _WIN32 -#include <netinet/in.h> -#include <netdb.h> -#ifdef __ANDROID__ -typedef uint16_t in_port_t; -#endif -#else -#include <ws2tcpip.h> -typedef uint16_t sa_family_t; -typedef uint16_t in_port_t; -#endif - #include <string> #include <sstream> #include <bitset> -- GitLab