From a8b1d3a3642e4416914b932337f8d3d5c09f741c Mon Sep 17 00:00:00 2001 From: dhewg Date: Sat, 10 Dec 2011 18:52:24 +0100 Subject: [PATCH] Fix POSIX net code for x86_64 Multiplayer working from 32bit dedicated server on FreeBSD with a 64bit Linux client. --- neo/sys/posix/posix_net.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/neo/sys/posix/posix_net.cpp b/neo/sys/posix/posix_net.cpp index 30ef44dc..43b180a5 100644 --- a/neo/sys/posix/posix_net.cpp +++ b/neo/sys/posix/posix_net.cpp @@ -52,8 +52,8 @@ idCVar net_ip( "net_ip", "localhost", CVAR_SYSTEM, "local IP address" ); idCVar net_port( "net_port", "", CVAR_SYSTEM | CVAR_INTEGER, "local IP port number" ); typedef struct { - unsigned long ip; - unsigned long mask; + unsigned int ip; + unsigned int mask; } net_interface; #define MAX_INTERFACES 32 @@ -115,7 +115,7 @@ static bool ExtractPort( const char *src, char *buf, int bufsize, int *port ) { *p = '\0'; *port = strtol( p+1, NULL, 10 ); if ( ( *port == 0 && errno == EINVAL ) || - ( ( *port == LONG_MIN || *port == LONG_MAX ) && errno == ERANGE ) ) { + ( ( *port == INT_MIN || *port == INT_MAX ) && errno == ERANGE ) ) { return false; } return true; @@ -207,8 +207,7 @@ Sys_IsLANAddress */ bool Sys_IsLANAddress( const netadr_t adr ) { int i; - unsigned long *p_ip; - unsigned long ip; + unsigned int ip; #if ID_NOLANADDRESS common->Printf( "Sys_IsLANAddress: ID_NOLANADDRESS\n" ); @@ -228,8 +227,7 @@ bool Sys_IsLANAddress( const netadr_t adr ) { } for ( i = 0; i < num_interfaces; i++ ) { - p_ip = (unsigned long *)&adr.ip[0]; - ip = ntohl( *p_ip ); + ip = ntohl( adr.ip[0] ); if( ( netint[i].ip & netint[i].mask ) == ( ip & netint[i].mask ) ) { return true; } @@ -299,8 +297,8 @@ void Sys_InitNetworking(void) if ( !ifp->ifa_netmask ) continue; - ip = ntohl( *( unsigned long *)&ifp->ifa_addr->sa_data[2] ); - mask = ntohl( *( unsigned long *)&ifp->ifa_netmask->sa_data[2] ); + ip = ntohl( *( unsigned int *)&ifp->ifa_addr->sa_data[2] ); + mask = ntohl( *( unsigned int *)&ifp->ifa_netmask->sa_data[2] ); if ( ip == INADDR_LOOPBACK ) { common->Printf( "loopback\n" ); @@ -348,7 +346,7 @@ void Sys_InitNetworking(void) if ( ifr->ifr_addr.sa_family != AF_INET ) { common->Printf( "not AF_INET\n" ); } else { - ip = ntohl( *( unsigned long *)&ifr->ifr_addr.sa_data[2] ); + ip = ntohl( *( unsigned int *)&ifr->ifr_addr.sa_data[2] ); if ( ip == INADDR_LOOPBACK ) { common->Printf( "loopback\n" ); } else { @@ -361,7 +359,7 @@ void Sys_InitNetworking(void) if ( ioctl( s, SIOCGIFNETMASK, ifr ) < 0 ) { common->Printf( " SIOCGIFNETMASK failed: %s\n", strerror( errno ) ); } else { - mask = ntohl( *( unsigned long *)&ifr->ifr_addr.sa_data[2] ); + mask = ntohl( *( unsigned int *)&ifr->ifr_addr.sa_data[2] ); if ( ip != INADDR_LOOPBACK ) { common->Printf( "/%d.%d.%d.%d\n", (unsigned char)ifr->ifr_addr.sa_data[2],