[quake3] Mergine unix_net.c and win_net.c questions

Ludwig Nussel ludwig.nussel at suse.de
Wed Aug 15 13:22:23 EDT 2007


Matt Turner wrote:
> I'm in the process of mergining unix_net.c and win_net.c, and I have a
> few questions.
> 
> 1) In Sys_IsLANAddress, why does the windows version check if IP is
> loopback and not check if the address is an internal class {A,B,C}
> address as in unix_net.c? The following code checks if IP is loopback
> in win_net.c.
> 
> if( adr.ip[0] == 127 && adr.ip[1] == 0 && adr.ip[2] == 0 && adr.ip[3] == 1 ) {
> 		return qtrue;
> }
> 
>  The following code is in unix_net.c, but not in win_net.c.
> 
> 	if(adr.ip[0] == 10)
> 		return qtrue;
> 	if(adr.ip[0] == 172 && (adr.ip[1]&0xf0) == 16)
> 		return qtrue;
> 	if(adr.ip[0] == 192 && adr.ip[1] == 168)
> 		return qtrue;

Those checks were added by me to prevent LAN servers from contacting
the master server. The localIP checks below that code probably have
the same intention but don't work on Linux as localIP isn't properly
set there.

> 2) Sys_GetPacket: Why does the following code come after the series of
> if()s in win_net.c but before the if()s in unix_net.c?
> 
> SockadrToNetadr( &from, net_from );
> net_message->readcount = 0;

I guess you have to understand the code to judge where the correct
place is.

> 3) Why is NET_Sleep empty on Windows?

Maybe noone cared if the dedicated server burns cpu cycles on
Windows.

> 4) The last lines in NET_OpenIP in unix_net.c and win_net.c respectively are:
> 
> Com_Error(ERR_FATAL, "Couldn't allocate IP port\n");
> Com_Printf("WARNING: Couldn't allocate IP port\n");
>
> Why are they different? Any reason, or can we consolidate the code
> path and eliminate one of them?

It cannot be fatal on windows as creating the ipx socket might
succeed instead. There should probably be a check that ensures that
either ip or ipx is present. Maybe IPX support should just be
dropped.

> The merged common functions are attached, with the exception of
> NET_GetLocalAddress.

There are lots of ugly #ifdef in there now. It would be good to get rid
of them as far as possible e.g. by #define SOCKET_ERROR -1, #define
SOCKET int and by keeping really windows specific bits in win_net.c

cu
Ludwig

-- 
 (o_   Ludwig Nussel
 //\   SUSE LINUX Products GmbH, Development
 V_/_  http://www.suse.de/








More information about the quake3 mailing list