diff -Naur old/SDL_net-1.2.8/SDLnet.c new/SDL_net-1.2.8/SDLnet.c --- old/SDL_net-1.2.8/SDLnet.c 2012-01-15 08:20:10.000000000 +0530 +++ new/SDL_net-1.2.8/SDLnet.c 2015-04-15 16:13:24.095052100 +0530 @@ -1,22 +1,22 @@ /* - SDL_net: An example cross-platform network library for use with SDL - Copyright (C) 1997-2012 Sam Lantinga +SDL_net: An example cross-platform network library for use with SDL +Copyright (C) 1997-2012 Sam Lantinga - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not +claim that you wrote the original software. If you use this software +in a product, an acknowledgment in the product documentation would be +appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be +misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. */ /* $Id$ */ @@ -38,7 +38,7 @@ /* Since the UNIX/Win32/BeOS code is so different from MacOS, we'll just have two completely different sections here. -*/ + */ static int SDLNet_started = 0; #ifndef __USE_W32_SOCKETS @@ -111,10 +111,93 @@ } } +/* SDLNet_SocktoIP and SDLNet_IPtoSock functions are added by : Nitin Jain (nitin.j4@samsung.com) */ + +#ifdef DUAL_IP +void SDLNet_SocktoIP(const struct sockaddr *sock, IPaddress *ip) +{ + if(sock->sa_family == AF_INET) + { + struct sockaddr_in *addr = (struct sockaddr_in *) sock; + inet_ntop(AF_INET, &(addr->sin_addr), ip->ipstr, INET_ADDRSTRLEN); + ip->f_type = AF_INET; + ip->port = addr->sin_port; + + } + else if(sock->sa_family == AF_INET6) + { + struct sockaddr_in6 *addr = (struct sockaddr_in6 *) sock; + inet_ntop(AF_INET6, &(addr->sin6_addr), ip->ipstr, INET6_ADDRSTRLEN); + ip->f_type = AF_INET6; + ip->port = addr->sin6_port; + } + else + SDLNet_SetError("Wrong Family Type : SDLNet_SocktoIP \n"); +} + +void SDLNet_IPtoSock(const IPaddress *ip, struct sockaddr *sock) +{ + if(ip->f_type == AF_INET) + { + struct sockaddr_in *addr = (struct sockaddr_in *) sock; + addr->sin_family = AF_INET; + addr->sin_port = ip->port; + inet_pton(AF_INET, ip->ipstr , &(addr->sin_addr)); + } + else if(ip->f_type == AF_INET6) + { + struct sockaddr_in6 *addr = (struct sockaddr_in6 *) sock; + addr->sin6_family = AF_INET6; + addr->sin6_port = ip->port; + inet_pton(AF_INET6, ip->ipstr, &(addr->sin6_addr)); + } + else + SDLNet_SetError("Wrong Family Type : SDLNet_IPtoSock \n"); +} +#endif + /* Resolve a host name and port to an IP address in network form */ int SDLNet_ResolveHost(IPaddress *address, const char *host, Uint16 port) { int retval = 0; +#ifdef DUAL_IP + char buff[PORTLEN]; + struct addrinfo *addrinfo; + struct addrinfo hints; + memset(&hints, 0, sizeof(hints)); + snprintf(buff,PORTLEN,"%d",port); + + if( host == NULL) + { + address->sockflag = 0; + hints.ai_family = AF_UNSPEC; + hints.ai_flags = AI_PASSIVE; + hints.ai_socktype = 0; + hints.ai_protocol = 0; + } + else + { + address->sockflag= 1; + hints.ai_family = AF_UNSPEC; + hints.ai_flags = 0; + hints.ai_socktype = 0; + hints.ai_protocol = 0; + } + retval = getaddrinfo(host, buff, &hints, &addrinfo); + + if(retval) + { + SDLNet_SetError("getnameinfo fails with Err value: %d\n", retval); + } + else + { + if(addrinfo) + { + SDLNet_SocktoIP(addrinfo->ai_addr, address); + freeaddrinfo(addrinfo); + } + } +#else /* Perform the actual host resolution */ if ( host == NULL ) { @@ -132,8 +215,8 @@ } } } +#endif address->port = SDL_SwapBE16(port); - /* Return the status */ return(retval); } @@ -142,13 +225,30 @@ If the ip couldn't be resolved, this function returns NULL, otherwise a pointer to a static buffer containing the hostname is returned. Note that this function is not thread-safe. -*/ + */ /* Written by Miguel Angel Blanch. * Main Programmer of Arianne RPG. * http://come.to/arianne_rpg */ const char *SDLNet_ResolveIP(const IPaddress *ip) { +#ifdef DUAL_IP + int error = 0; + int s_len = 0; + struct sockaddr_storage sock; + SDLNet_IPtoSock(ip, (struct sockaddr *)&sock); + s_len = sizeof(struct sockaddr_storage); + error = getnameinfo((struct sockaddr *)&sock, s_len, ip->h_name, HOSTLEN, NULL,0, 0); + if(error) + { + SDLNet_SetError("getnameinfo fails\n"); + return NULL; + } + else + { + return (const char *)ip->h_name; + } +#else struct hostent *hp; struct in_addr in; @@ -159,13 +259,14 @@ in.s_addr = ip->host; return inet_ntoa(in); +#endif } int SDLNet_GetLocalAddresses(IPaddress *addresses, int maxcount) { int count = 0; #ifdef SIOCGIFCONF -/* Defined on Mac OS X */ + /* Defined on Mac OS X */ #ifndef _SIZEOF_ADDR_IFREQ #define _SIZEOF_ADDR_IFREQ sizeof #endif @@ -173,9 +274,13 @@ struct ifconf conf; char data[4096]; struct ifreq *ifr; +#ifdef DUAL_IP + sock = socket(AF_INET6, SOCK_DGRAM, 0); +#else struct sockaddr_in *sock_addr; - sock = socket(AF_INET, SOCK_DGRAM, 0); +#endif + if ( sock == INVALID_SOCKET ) { return 0; } @@ -189,6 +294,12 @@ ifr = (struct ifreq*)data; while ((char*)ifr < data+conf.ifc_len) { +#ifdef DUAL_IP + if (count < maxcount) { + SDLNet_SocktoIP(&ifr->ifr_addr , &addresses[count]); + } + ++count; +#else if (ifr->ifr_addr.sa_family == AF_INET) { if (count < maxcount) { sock_addr = (struct sockaddr_in*)&ifr->ifr_addr; @@ -197,40 +308,41 @@ } ++count; } +#endif ifr = (struct ifreq*)((char*)ifr + _SIZEOF_ADDR_IFREQ(*ifr)); } closesocket(sock); #elif defined(__WIN32__) - PIP_ADAPTER_INFO pAdapterInfo; - PIP_ADAPTER_INFO pAdapter; - PIP_ADDR_STRING pAddress; - DWORD dwRetVal = 0; - ULONG ulOutBufLen = sizeof (IP_ADAPTER_INFO); - - pAdapterInfo = (IP_ADAPTER_INFO *) SDL_malloc(sizeof (IP_ADAPTER_INFO)); - if (pAdapterInfo == NULL) { - return 0; - } - - if ((dwRetVal = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen)) == ERROR_BUFFER_OVERFLOW) { - pAdapterInfo = (IP_ADAPTER_INFO *) SDL_realloc(pAdapterInfo, ulOutBufLen); - if (pAdapterInfo == NULL) { + PIP_ADAPTER_INFO pAdapterInfo; + PIP_ADAPTER_INFO pAdapter; + PIP_ADDR_STRING pAddress; + DWORD dwRetVal = 0; + ULONG ulOutBufLen = sizeof (IP_ADAPTER_INFO); + + pAdapterInfo = (IP_ADAPTER_INFO *) SDL_malloc(sizeof (IP_ADAPTER_INFO)); + if (pAdapterInfo == NULL) { return 0; - } - dwRetVal = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen); - } - - if (dwRetVal == NO_ERROR) { - for (pAdapter = pAdapterInfo; pAdapter; pAdapter = pAdapter->Next) { - for (pAddress = &pAdapterInfo->IpAddressList; pAddress; pAddress = pAddress->Next) { - if (count < maxcount) { - addresses[count].host = inet_addr(pAddress->IpAddress.String); - addresses[count].port = 0; + } + + if ((dwRetVal = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen)) == ERROR_BUFFER_OVERFLOW) { + pAdapterInfo = (IP_ADAPTER_INFO *) SDL_realloc(pAdapterInfo, ulOutBufLen); + if (pAdapterInfo == NULL) { + return 0; + } + dwRetVal = GetAdaptersInfo(pAdapterInfo, &ulOutBufLen); + } + + if (dwRetVal == NO_ERROR) { + for (pAdapter = pAdapterInfo; pAdapter; pAdapter = pAdapter->Next) { + for (pAddress = &pAdapterInfo->IpAddressList; pAddress; pAddress = pAddress->Next) { + if (count < maxcount) { + addresses[count].host = inet_addr(pAddress->IpAddress.String); + addresses[count].port = 0; + } + ++count; } - ++count; } - } - } + } SDL_free(pAdapterInfo); #endif return count; diff -Naur old/SDL_net-1.2.8/SDL_net.h new/SDL_net-1.2.8/SDL_net.h --- old/SDL_net-1.2.8/SDL_net.h 2012-01-15 08:20:10.000000000 +0530 +++ new/SDL_net-1.2.8/SDL_net.h 2015-04-15 16:13:50.693052100 +0530 @@ -28,6 +28,12 @@ #include "SDL_endian.h" #include "SDL_version.h" #include "begin_code.h" +#include + +#ifdef DUAL_IP +#define HOSTLEN 1024 +#define PORTLEN 6 +#endif @@ -70,8 +76,19 @@ /***********************************************************************/ typedef struct { - Uint32 host; /* 32-bit IPv4 host address */ Uint16 port; /* 16-bit protocol port */ + +/* DUAL_IP macro enables both, IPv4 and IPv6 support for SDL_net + Fields under DUAL_IP added by : Nitin Jain (nitin.j4@samsung.com) +*/ +#ifdef DUAL_IP + char ipstr[INET6_ADDRSTRLEN]; /* 128-bit IPv6 or 32-bit IPv4 host address in string format */ + Uint8 f_type; /* Family type - AF_INET or AF_INET6 */ + Uint8 sockflag; /* If 1 then act as a client, if 0 then act as a server */ + char h_name[HOSTLEN]; /* Host name */ +#else + Uint32 host; /* 32-bit IPv4 host address */ +#endif } IPaddress; /* Resolve a host name and port to an IP address in network form. @@ -193,7 +210,11 @@ internally in network (big endian) byte order, in addresses, etc. This allows other systems to send to this socket via a known port. */ +#ifdef DUAL_IP +extern DECLSPEC UDPsocket SDLCALL SDLNet_UDP_Open(Uint16 port, const char *host); +#else extern DECLSPEC UDPsocket SDLCALL SDLNet_UDP_Open(Uint16 port); +#endif /* Set the percentage of simulated packet loss for packets sent on the socket. */ diff -Naur old/SDL_net-1.2.8/SDLnetsys.h new/SDL_net-1.2.8/SDLnetsys.h --- old/SDL_net-1.2.8/SDLnetsys.h 2012-01-15 08:20:10.000000000 +0530 +++ new/SDL_net-1.2.8/SDLnetsys.h 2015-04-13 13:11:03.823789800 +0530 @@ -62,6 +62,9 @@ #include #include #include +#ifdef DUAL_IP +#include "SDL_net.h" +#endif #endif /* WIN32 */ /* FIXME: What platforms need this? */ @@ -79,6 +82,10 @@ #define SOCKET int #define INVALID_SOCKET -1 #define SOCKET_ERROR -1 +#ifdef DUAL_IP +void SDLNet_SocktoIP(const struct sockaddr *sock, IPaddress *ip); +void SDLNet_IPtoSock(const IPaddress *ip, struct sockaddr *sock); +#endif #endif /* __USE_W32_SOCKETS */ #ifdef __USE_W32_SOCKETS diff -Naur old/SDL_net-1.2.8/SDLnetTCP.c new/SDL_net-1.2.8/SDLnetTCP.c --- old/SDL_net-1.2.8/SDLnetTCP.c 2012-01-15 08:20:10.000000000 +0530 +++ new/SDL_net-1.2.8/SDLnetTCP.c 2015-04-15 10:39:41.458073500 +0530 @@ -46,7 +46,11 @@ TCPsocket SDLNet_TCP_Open(IPaddress *ip) { TCPsocket sock; +#ifdef DUAL_IP + struct sockaddr_in6 sock_addr; +#else struct sockaddr_in sock_addr; +#endif /* Allocate a TCP socket structure */ sock = (TCPsocket)malloc(sizeof(*sock)); @@ -54,13 +58,88 @@ SDLNet_SetError("Out of memory"); goto error_return; } +#ifdef DUAL_IP + if(ip->sockflag) + { + int retval = 0; + struct addrinfo *addrinfo , *p; + struct addrinfo hints; + memset(&hints, 0, sizeof(hints)); + char buff[PORTLEN]; + snprintf(buff,PORTLEN,"%d",SDL_SwapBE16(ip->port)); + + hints.ai_family = AF_UNSPEC; + hints.ai_flags = 0; + hints.ai_socktype = SOCK_STREAM; + hints.ai_protocol = 0; - /* Open the socket */ - sock->channel = socket(AF_INET, SOCK_STREAM, 0); - if ( sock->channel == INVALID_SOCKET ) { - SDLNet_SetError("Couldn't create socket"); - goto error_return; + retval = getaddrinfo(ip->ipstr, buff, &hints, &addrinfo); + if(retval) + { + SDLNet_SetError("SDLNet_TCP_Open fails with Err number : %d\n", retval); + goto error_return; + + } + + sock->channel = -1; + for(p = addrinfo; p != NULL; p = p->ai_next) + { + if ((sock->channel = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) + { + continue; + } + if (connect(sock->channel, p->ai_addr, p->ai_addrlen) == -1) + { + close(sock->channel); + continue; + } + else + { + sock->sflag = 0; + SDLNet_SocktoIP(p->ai_addr, &sock->remoteAddress); + break; + } + } + + freeaddrinfo(p); } + else + { + int ok = 1; + sock->channel = socket(AF_INET6, SOCK_STREAM, 0); + if ( sock->channel == INVALID_SOCKET ) { + SDLNet_SetError("Couldn't create socket"); + goto error_return; + } + + setsockopt(sock->channel, SOL_SOCKET, SO_REUSEADDR, (char*)&ok, sizeof(ok)); + + + memset(&sock_addr, 0, sizeof(sock_addr)); + sock_addr.sin6_family = AF_INET6; + sock_addr.sin6_addr = in6addr_any; + sock_addr.sin6_port = ip->port; + + if ( bind(sock->channel, (struct sockaddr *)&sock_addr, sizeof(sock_addr)) == SOCKET_ERROR ) { + SDLNet_SetError("Couldn't bind to local port"); + goto error_return; + } + + if ( listen(sock->channel, 5) == SOCKET_ERROR ) { + SDLNet_SetError("Couldn't listen to local port"); + goto error_return; + } + sock->sflag = 1; + SDLNet_SocktoIP((struct sockaddr *)&sock_addr, &sock->remoteAddress); + } + +#else + /* Open the socket */ + sock->channel = socket(AF_INET, SOCK_STREAM, 0); + if ( sock->channel == INVALID_SOCKET ) { + SDLNet_SetError("Couldn't create socket"); + goto error_return; + } /* Connect to remote, or bind locally, as appropriate */ if ( (ip->host != INADDR_NONE) && (ip->host != INADDR_ANY) ) { @@ -135,20 +214,20 @@ #else #warning How do we set non-blocking mode on other operating systems? #endif + sock->sflag = 1; } - sock->ready = 0; - #ifdef TCP_NODELAY /* Set the nodelay TCP option for real-time games */ { int yes = 1; setsockopt(sock->channel, IPPROTO_TCP, TCP_NODELAY, (char*)&yes, sizeof(yes)); } #endif /* TCP_NODELAY */ - /* Fill in the channel host address */ sock->remoteAddress.host = sock_addr.sin_addr.s_addr; sock->remoteAddress.port = sock_addr.sin_port; +#endif // DUAL_IP + sock->ready = 0; /* The socket is ready */ return(sock); @@ -164,7 +243,12 @@ TCPsocket SDLNet_TCP_Accept(TCPsocket server) { TCPsocket sock; +#ifdef DUAL_IP + struct sockaddr_in6 sock_addr; +#else struct sockaddr_in sock_addr; +#endif + socklen_t sock_alen; /* Only server sockets can accept */ @@ -201,8 +285,13 @@ fcntl(sock->channel, F_SETFL, flags & ~O_NONBLOCK); } #endif /* WIN32 */ + +#ifdef DUAL_IP + SDLNet_SocktoIP((struct sockaddr *) &sock_addr, &sock->remoteAddress); +#else sock->remoteAddress.host = sock_addr.sin_addr.s_addr; sock->remoteAddress.port = sock_addr.sin_port; +#endif sock->sflag = 0; sock->ready = 0; diff -Naur old/SDL_net-1.2.8/SDLnetUDP.c new/SDL_net-1.2.8/SDLnetUDP.c --- old/SDL_net-1.2.8/SDLnetUDP.c 2012-01-15 08:20:10.000000000 +0530 +++ new/SDL_net-1.2.8/SDLnetUDP.c 2015-04-15 10:53:45.250072600 +0530 @@ -137,11 +137,13 @@ /* Open a UDP network socket If 'port' is non-zero, the UDP socket is bound to a fixed local port. */ +#ifdef DUAL_IP +UDPsocket SDLNet_UDP_Open(Uint16 port, const char *host) +#else UDPsocket SDLNet_UDP_Open(Uint16 port) +#endif { UDPsocket sock; - struct sockaddr_in sock_addr; - socklen_t sock_len; /* Allocate a UDP socket structure */ sock = (UDPsocket)malloc(sizeof(*sock)); @@ -150,6 +152,71 @@ goto error_return; } memset(sock, 0, sizeof(*sock)); +#ifdef DUAL_IP + if(port) + { + struct sockaddr_in6 sock_addr; + memset(&sock_addr, 0, sizeof(sock_addr)); + + /* Open the socket */ + sock->channel = socket(AF_INET6, SOCK_DGRAM, 0); + if ( sock->channel == INVALID_SOCKET ) + { + SDLNet_SetError("Couldn't create socket"); + goto error_return; + } + + + sock_addr.sin6_family = AF_INET6; + sock_addr.sin6_addr = in6addr_any; + sock_addr.sin6_port = SDL_SwapBE16(port); + + /* Bind the socket for listening */ + if ( bind(sock->channel, (struct sockaddr *)&sock_addr, + sizeof(sock_addr)) == SOCKET_ERROR ) { + SDLNet_SetError("Couldn't bind to local port"); + goto error_return; + } + + /* Fill in the channel host address */ + + SDLNet_SocktoIP((struct sockaddr *)&sock_addr, &sock->address); +#ifdef SO_BROADCAST + /* Allow LAN broadcasts with the socket */ + { int yes = 1; + setsockopt(sock->channel, SOL_SOCKET, SO_BROADCAST, (char*)&yes, sizeof(yes)); + } +#endif + } + else + { + struct addrinfo *addrinfo , *p; + struct addrinfo hints; + char buff[PORTLEN]; + + memset(&hints, 0, sizeof hints); + snprintf(buff,PORTLEN,"%d",port); + + hints.ai_family = AF_UNSPEC; // use IPv4 or IPv6 + hints.ai_socktype = SOCK_DGRAM; + + getaddrinfo(host, buff, &hints, &addrinfo); + + for(p = addrinfo; p != NULL; p = p->ai_next) + { + if( (sock->channel = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) + { + continue; + } + SDLNet_SocktoIP(p->ai_addr, &sock->address); + break; + } + freeaddrinfo(addrinfo); + } + +#else + struct sockaddr_in sock_addr; + socklen_t sock_len; memset(&sock_addr, 0, sizeof(sock_addr)); /* Open the socket */ @@ -171,15 +238,14 @@ SDLNet_SetError("Couldn't bind to local port"); goto error_return; } - + /* Get the bound address and port */ sock_len = sizeof(sock_addr); if ( getsockname(sock->channel, (struct sockaddr *)&sock_addr, &sock_len) < 0 ) { -perror("getsockname"); + perror("getsockname"); SDLNet_SetError("Couldn't get socket address"); goto error_return; } - /* Fill in the channel host address */ sock->address.host = sock_addr.sin_addr.s_addr; sock->address.port = sock_addr.sin_port; @@ -192,11 +258,11 @@ #endif #ifdef IP_ADD_MEMBERSHIP /* Receive LAN multicast packets on 224.0.0.1 - This automatically works on Mac OS X, Linux and BSD, but needs + This automatically works on Mac OS X, Linux and BSD, but needs this code on Windows. */ /* A good description of multicast can be found here: - http://www.docs.hp.com/en/B2355-90136/ch05s05.html + http://www.docs.hp.com/en/B2355-90136/ch05s05.html */ /* FIXME: Add support for joining arbitrary groups to the API */ { @@ -209,6 +275,8 @@ } #endif +#endif + /* The socket is ready */ return(sock); @@ -330,8 +398,13 @@ struct UDP_channel *binding; int status; int sock_len; +#ifdef DUAL_IP + struct sockaddr_storage sock_addr; +#else struct sockaddr_in sock_addr; +#endif + if ( sock == NULL ) { SDLNet_SetError("Passed a NULL socket"); return(0); @@ -356,9 +429,13 @@ if ( packets[i]->channel < 0 ) { +#ifdef DUAL_IP + SDLNet_IPtoSock(&packets[i]->address, (struct sockaddr *)&sock_addr); +#else sock_addr.sin_addr.s_addr = packets[i]->address.host; sock_addr.sin_port = packets[i]->address.port; sock_addr.sin_family = AF_INET; +#endif status = sendto(sock->channel, packets[i]->data, packets[i]->len, 0, (struct sockaddr *)&sock_addr,sock_len); @@ -379,12 +456,17 @@ for ( j=binding->numbound-1; j>=0; --j ) { +#ifdef DUAL_IP + SDLNet_IPtoSock(&binding->address[j], (struct sockaddr *)&sock_addr); +#else sock_addr.sin_addr.s_addr = binding->address[j].host; sock_addr.sin_port = binding->address[j].port; sock_addr.sin_family = AF_INET; +#endif status = sendto(sock->channel, packets[i]->data, packets[i]->len, 0, (struct sockaddr *)&sock_addr,sock_len); + if ( status >= 0 ) { packets[i]->status = status; @@ -442,7 +524,11 @@ int numrecv, i, j; struct UDP_channel *binding; socklen_t sock_len; +#ifdef DUAL_IP + struct sockaddr_storage sock_addr; +#else struct sockaddr_in sock_addr; +#endif if ( sock == NULL ) { return(0); @@ -452,7 +538,6 @@ while ( packets[numrecv] && SocketReady(sock->channel) ) { UDPpacket *packet; - packet = packets[numrecv]; sock_len = sizeof(sock_addr); @@ -462,8 +547,12 @@ &sock_len); if ( packet->status >= 0 ) { packet->len = packet->status; +#ifdef DUAL_IP + SDLNet_SocktoIP((struct sockaddr *)&sock_addr , &packet->address); +#else packet->address.host = sock_addr.sin_addr.s_addr; packet->address.port = sock_addr.sin_port; +#endif packet->channel = -1; for (i=(SDLNET_MAX_UDPCHANNELS-1); i>=0; --i ) @@ -472,8 +561,13 @@ for ( j=binding->numbound-1; j>=0; --j ) { +#ifdef DUAL_IP + if(!(strcmp(packet->address.ipstr , binding->address[j].ipstr)) && + (packet->address.port == binding->address[j].port) ) +#else if ( (packet->address.host == binding->address[j].host) && (packet->address.port == binding->address[j].port) ) +#endif { packet->channel = i; goto foundit; /* break twice */ diff -Naur old/SDL_net-1.2.8/showinterfaces.c new/SDL_net-1.2.8/showinterfaces.c --- old/SDL_net-1.2.8/showinterfaces.c 2012-01-15 08:20:10.000000000 +0530 +++ new/SDL_net-1.2.8/showinterfaces.c 2015-04-15 16:14:19.047052000 +0530 @@ -26,16 +26,20 @@ { IPaddress addresses[MAX_ADDRESSES]; int i, count; - count = SDLNet_GetLocalAddresses(addresses, MAX_ADDRESSES); + printf("Found %d local addresses\n", count); for ( i = 0; i < count; ++i ) { +#ifdef DUAL_IP + printf("%d: %s - %s\n", i+1,addresses[i].ipstr,SDLNet_ResolveIP(&addresses[i])); +#else printf("%d: %d.%d.%d.%d - %s\n", i+1, (addresses[i].host >> 0) & 0xFF, (addresses[i].host >> 8) & 0xFF, (addresses[i].host >> 16) & 0xFF, (addresses[i].host >> 24) & 0xFF, SDLNet_ResolveIP(&addresses[i])); +#endif } return 0; }