mirror of
https://github.com/dhewm/dhewm3.git
synced 2025-03-20 17:51:02 +00:00
Fix POSIX net code for x86_64
Multiplayer working from 32bit dedicated server on FreeBSD with a 64bit Linux client.
This commit is contained in:
parent
30850f8d9c
commit
a8b1d3a364
1 changed files with 9 additions and 11 deletions
|
@ -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],
|
||||
|
|
Loading…
Reference in a new issue