summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorAndreas Baumann <abaumann@yahoo.com>2009-04-05 17:34:14 +0200
committerAndreas Baumann <abaumann@yahoo.com>2009-04-05 17:34:14 +0200
commitc392ae0e621842db18f10cdfd4c87ac9b60e4a92 (patch)
tree35351239e84df1fe3958d1b4b406a56c4d55d6b9 /include
parentd356c2255a39e89f8c5696b81d9e57c53ad74dc1 (diff)
downloadwolfbones-c392ae0e621842db18f10cdfd4c87ac9b60e4a92.tar.gz
wolfbones-c392ae0e621842db18f10cdfd4c87ac9b60e4a92.tar.bz2
started with a server test2 (networking), started to create a public helper include file network.h
Diffstat (limited to 'include')
-rw-r--r--include/wolf/network/network.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/include/wolf/network/network.h b/include/wolf/network/network.h
new file mode 100644
index 0000000..34f5511
--- /dev/null
+++ b/include/wolf/network/network.h
@@ -0,0 +1,65 @@
+/*
+ Copyright (C) 2008 Andreas Baumann <abaumann@yahoo.com>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef WOLF_NETWORK_H
+#define WOLF_NETWORK_H
+
+/**
+ * @addtogroup wolf_networking support for networking
+ * @{
+ */
+
+/**
+ * @file network.h
+ * @brief Portable helper functions for networking
+ * @author Andreas Baumann <abaumann@yahoo.com>
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "port/sys.h"
+
+#if defined HAVE_IPV6
+/**
+ * @brief defined when we have proper IPv6 ready on the system
+ */
+#define WOLF_NETWORK_HAVE_IPV6
+#endif
+
+/**
+ * helper union to avoid anti-aliasing warnings in old network functions like getpeername,
+ * use instead of struct sockaddr_storage when declaring socket address variables which need
+ * proper alignment
+ */
+typedef union wolf_network_sockaddr_union_t {
+ struct sockaddr_storage storage;
+ struct sockaddr_in in;
+#ifdef WOLF_NETWORK_HAVE_IPV6
+ struct sockaddr_in6 in6;
+#endif
+ struct sockaddr addr;
+} wolf_network_sockaddr_union_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+/** @} */ /* @addtogroup wolf_networking */
+
+#endif /* ifndef WOLF_NETWORK_H */