From c392ae0e621842db18f10cdfd4c87ac9b60e4a92 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Sun, 5 Apr 2009 17:34:14 +0200 Subject: started with a server test2 (networking), started to create a public helper include file network.h --- include/wolf/network/network.h | 65 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 include/wolf/network/network.h (limited to 'include') 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 + + 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 . +*/ + +#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 + */ + +#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 */ -- cgit v1.2.3-54-g00ecf