diff options
author | Tim Angus <tim@ngus.net> | 2011-01-24 22:07:34 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2013-01-03 00:17:54 +0000 |
commit | f96ae257eab6fae9b4b4f4409c58dbce6915ac35 (patch) | |
tree | c9828a3c3726d4b260493a710fd1f2f9f7bc6056 /src/qcommon/net_ip.c | |
parent | a0101a6294268ef392b3fa4ecad12706e6cf4cf3 (diff) |
* Merge ioq3-r1813
Diffstat (limited to 'src/qcommon/net_ip.c')
-rw-r--r-- | src/qcommon/net_ip.c | 73 |
1 files changed, 35 insertions, 38 deletions
diff --git a/src/qcommon/net_ip.c b/src/qcommon/net_ip.c index 2be40a86..c1e527c5 100644 --- a/src/qcommon/net_ip.c +++ b/src/qcommon/net_ip.c @@ -310,11 +310,11 @@ static qboolean Sys_StringToSockaddr(const char *s, struct sockaddr *sadr, int s if(search) { - if(res->ai_addrlen > sadr_len) - res->ai_addrlen = sadr_len; + if(search->ai_addrlen > sadr_len) + search->ai_addrlen = sadr_len; - memcpy(sadr, res->ai_addr, res->ai_addrlen); - freeaddrinfo(res); + memcpy(sadr, search->ai_addr, search->ai_addrlen); + freeaddrinfo(search); return qtrue; } @@ -853,9 +853,6 @@ int NET_IPSocket( char *net_interface, int port, int *err ) { // make it broadcast capable if( setsockopt( newsocket, SOL_SOCKET, SO_BROADCAST, (char *) &i, sizeof(i) ) == SOCKET_ERROR ) { Com_Printf( "WARNING: NET_IPSocket: setsockopt SO_BROADCAST: %s\n", NET_ErrorString() ); - - // it is not that bad if this one fails. -// return newsocket; } if( !net_interface || !net_interface[0]) { @@ -1035,28 +1032,28 @@ void NET_JoinMulticast6(void) if(curgroup.ipv6mr_interface) { if (setsockopt(multicast6_socket, IPPROTO_IPV6, IPV6_MULTICAST_IF, - (char *) &curgroup.ipv6mr_interface, sizeof(curgroup.ipv6mr_interface)) < 0) + (char *) &curgroup.ipv6mr_interface, sizeof(curgroup.ipv6mr_interface)) < 0) { - Com_Printf("NET_JoinMulticast6: Couldn't set scope on multicast socket: %s\n", NET_ErrorString()); + Com_Printf("NET_JoinMulticast6: Couldn't set scope on multicast socket: %s\n", NET_ErrorString()); - if(multicast6_socket != ip6_socket) - { - closesocket(multicast6_socket); - multicast6_socket = INVALID_SOCKET; - return; + if(multicast6_socket != ip6_socket) + { + closesocket(multicast6_socket); + multicast6_socket = INVALID_SOCKET; + return; } } - } - - if (setsockopt(multicast6_socket, IPPROTO_IPV6, IPV6_JOIN_GROUP, (char *) &curgroup, sizeof(curgroup))) - { - Com_Printf("NET_JoinMulticast6: Couldn't join multicast group: %s\n", NET_ErrorString()); - - if(multicast6_socket != ip6_socket) - { - closesocket(multicast6_socket); - multicast6_socket = INVALID_SOCKET; - return; + } + + if (setsockopt(multicast6_socket, IPPROTO_IPV6, IPV6_JOIN_GROUP, (char *) &curgroup, sizeof(curgroup))) + { + Com_Printf("NET_JoinMulticast6: Couldn't join multicast group: %s\n", NET_ErrorString()); + + if(multicast6_socket != ip6_socket) + { + closesocket(multicast6_socket); + multicast6_socket = INVALID_SOCKET; + return; } } } @@ -1253,10 +1250,10 @@ void NET_OpenSocks( int port ) { /* ===================== -NET_GetLocalAddress +NET_AddLocalAddress ===================== */ -void NET_AddLocalAddress(char *ifname, struct sockaddr *addr, struct sockaddr *netmask) +static void NET_AddLocalAddress(char *ifname, struct sockaddr *addr, struct sockaddr *netmask) { int addrlen; sa_family_t family; @@ -1294,7 +1291,7 @@ void NET_AddLocalAddress(char *ifname, struct sockaddr *addr, struct sockaddr *n } #if defined(__linux__) || defined(MACOSX) || defined(__BSD__) -void NET_GetLocalAddress(void) +static void NET_GetLocalAddress(void) { struct ifaddrs *ifap, *search; @@ -1315,10 +1312,10 @@ void NET_GetLocalAddress(void) } } #else -void NET_GetLocalAddress( void ) { +static void NET_GetLocalAddress( void ) { char hostname[256]; - struct addrinfo hint; - struct addrinfo *res = NULL; + struct addrinfo hint; + struct addrinfo *res = NULL; if(gethostname( hostname, 256 ) == SOCKET_ERROR) return; @@ -1334,7 +1331,7 @@ void NET_GetLocalAddress( void ) { { struct sockaddr_in mask4; struct sockaddr_in6 mask6; - struct addrinfo *search; + struct addrinfo *search; /* On operating systems where it's more difficult to find out the configured interfaces, we'll just assume a * netmask with all bits set. */ @@ -1476,27 +1473,27 @@ static qboolean NET_GetCvars( void ) { #else net_mcast6iface = Cvar_Get( "net_mcast6iface", "", CVAR_LATCH | CVAR_ARCHIVE ); #endif - modified += net_mcast6iface->modified; + modified += net_mcast6iface->modified; net_mcast6iface->modified = qfalse; net_socksEnabled = Cvar_Get( "net_socksEnabled", "0", CVAR_LATCH | CVAR_ARCHIVE ); - modified += net_socksEnabled->modified; + modified += net_socksEnabled->modified; net_socksEnabled->modified = qfalse; net_socksServer = Cvar_Get( "net_socksServer", "", CVAR_LATCH | CVAR_ARCHIVE ); - modified += net_socksServer->modified; + modified += net_socksServer->modified; net_socksServer->modified = qfalse; net_socksPort = Cvar_Get( "net_socksPort", "1080", CVAR_LATCH | CVAR_ARCHIVE ); - modified += net_socksPort->modified; + modified += net_socksPort->modified; net_socksPort->modified = qfalse; net_socksUsername = Cvar_Get( "net_socksUsername", "", CVAR_LATCH | CVAR_ARCHIVE ); - modified += net_socksUsername->modified; + modified += net_socksUsername->modified; net_socksUsername->modified = qfalse; net_socksPassword = Cvar_Get( "net_socksPassword", "", CVAR_LATCH | CVAR_ARCHIVE ); - modified += net_socksPassword->modified; + modified += net_socksPassword->modified; net_socksPassword->modified = qfalse; return modified ? qtrue : qfalse; |