/* 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" #include "errors.h" #if defined LINUX #include /* for sockaddr_storage */ #include /* for sockaddr_in */ #else #if defined OPENBSD #include /* for u_int8_t, uid_t, etc */ #include /* for sockaddr_storage */ #include /* for sockaddr_in */ #else #if defined NETBSD #include /* for sockaddr_storage */ #include /* for sockaddr_in */ #else #if defined FREEBSD #include /* for sockaddr_storage */ #include /* for sockaddr_in */ #else #if defined SUNOS #include #include #else #if defined _WIN32 #define WIN32_MEAN_AND_LEAN #include #else #error Check includes first! #endif /* defined _WIN32 */ #endif /* defined SUNOS */ #endif /* defined FREEBSD */ #endif /* defined NETBSD */ #endif /* defined OPENBSD */ #endif /* defined LINUX */ /** * helper union to avoid anti-aliasing warnings in old network functions like getpeername, * used 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 HAVE_IPV6 struct sockaddr_in6 in6; #endif struct sockaddr addr; } wolf_network_sockaddr_union_t; /** * Set a file descriptor non-blocking, Unix-specific, and more important, doesn't * work on all kind of descriptors! */ wolf_error_t wolf_network_set_nonblocking( int fd ); #ifdef __cplusplus } #endif /** @} */ /* @addtogroup wolf_networking */ #endif /* ifndef WOLF_NETWORK_H */