diff options
Diffstat (limited to '3rdParty/LibNATPMP/src/libnatpmp/getgateway.c')
-rw-r--r-- | 3rdParty/LibNATPMP/src/libnatpmp/getgateway.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/3rdParty/LibNATPMP/src/libnatpmp/getgateway.c b/3rdParty/LibNATPMP/src/libnatpmp/getgateway.c index 3a3f9a6..dfb9f3e 100644 --- a/3rdParty/LibNATPMP/src/libnatpmp/getgateway.c +++ b/3rdParty/LibNATPMP/src/libnatpmp/getgateway.c @@ -1,34 +1,34 @@ -/* $Id: getgateway.c,v 1.24 2014/03/31 12:41:35 nanard Exp $ */ +/* $Id: getgateway.c,v 1.25 2014/04/22 10:28:57 nanard Exp $ */ /* libnatpmp -Copyright (c) 2007-2011, Thomas BERNARD +Copyright (c) 2007-2014, Thomas BERNARD All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <stdio.h> #include <ctype.h> #ifndef WIN32 #include <netinet/in.h> #endif @@ -40,67 +40,60 @@ POSSIBILITY OF SUCH DAMAGE. * Parsing /proc/net/route is for linux. * sysctl is the way to access such informations on BSD systems. * Many systems should provide route information through raw PF_ROUTE * sockets. * In MS Windows, default gateway is found by looking into the registry * or by using GetBestRoute(). */ #ifdef __linux__ #define USE_PROC_NET_ROUTE #undef USE_SOCKET_ROUTE #undef USE_SYSCTL_NET_ROUTE #endif #if defined(BSD) || defined(__FreeBSD_kernel__) #undef USE_PROC_NET_ROUTE #define USE_SOCKET_ROUTE #undef USE_SYSCTL_NET_ROUTE #endif #ifdef __APPLE__ #undef USE_PROC_NET_ROUTE #undef USE_SOCKET_ROUTE #define USE_SYSCTL_NET_ROUTE #endif #if (defined(sun) && defined(__SVR4)) #undef USE_PROC_NET_ROUTE #define USE_SOCKET_ROUTE #undef USE_SYSCTL_NET_ROUTE #endif -#if !defined(USE_PROC_NET_ROUTE) && !defined(USE_SOCKET_ROUTE) && !defined(USE_SYSCTL_NET_ROUTE) && !defined(WIN32) -int getdefaultgateway(in_addr_t * addr) -{ - return -1; -} -#endif - #ifdef WIN32 #undef USE_PROC_NET_ROUTE #undef USE_SOCKET_ROUTE #undef USE_SYSCTL_NET_ROUTE //#define USE_WIN32_CODE #define USE_WIN32_CODE_2 #endif #ifdef __CYGWIN__ #undef USE_PROC_NET_ROUTE #undef USE_SOCKET_ROUTE #undef USE_SYSCTL_NET_ROUTE #define USE_WIN32_CODE #include <stdarg.h> #include <w32api/windef.h> #include <w32api/winbase.h> #include <w32api/winreg.h> #endif #ifdef __HAIKU__ #include <stdlib.h> #include <unistd.h> #include <net/if.h> #include <sys/sockio.h> #define USE_HAIKU_CODE #endif #ifdef USE_SYSCTL_NET_ROUTE #include <stdlib.h> #include <sys/sysctl.h> @@ -545,31 +538,36 @@ int getdefaultgateway(in_addr_t *addr) goto fail; } for (interface = buffer; (uint8_t *)interface < (uint8_t *)buffer + config.ifc_len; ) { struct route_entry route = interface->ifr_route; int intfSize; if (route.flags & (RTF_GATEWAY | RTF_DEFAULT)) { *addr = ((struct sockaddr_in *)route.gateway)->sin_addr.s_addr; ret = 0; break; } intfSize = sizeof(route) + IF_NAMESIZE; if (route.destination != NULL) { intfSize += route.destination->sa_len; } if (route.mask != NULL) { intfSize += route.mask->sa_len; } if (route.gateway != NULL) { intfSize += route.gateway->sa_len; } interface = (struct ifreq *)((uint8_t *)interface + intfSize); } fail: free(buffer); close(fd); return ret; } #endif /* #ifdef USE_HAIKU_CODE */ - +#if !defined(USE_PROC_NET_ROUTE) && !defined(USE_SOCKET_ROUTE) && !defined(USE_SYSCTL_NET_ROUTE) && !defined(USE_WIN32_CODE) && !defined(USE_WIN32_CODE_2) && !defined(USE_HAIKU_CODE) +int getdefaultgateway(in_addr_t * addr) +{ + return -1; +} +#endif |