Mergine unix_net.c and win_net.c questions

Matt Turner mattst88 at gmail.com
Tue Aug 14 17:51:04 EDT 2007


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;

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;

3) Why is NET_Sleep empty 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?

5) Also in NET_OpenIP, in unix_net.c and win_net.c respectively are:
//unix
	ip = Cvar_Get("net_ip", "localhost", 0);
	port = Cvar_Get("net_port", va("%i", PORT_SERVER), 0)->value;

//win
	ip = Cvar_Get("net_ip", "localhost", CVAR_LATCH);
	port = Cvar_Get("net_port", va( "%i", PORT_SERVER ), CVAR_LATCH)->integer;

Why are they different? Any reason, or can we consolidate the code
path and eliminate one of them?

6) Here are a list of functions specific to unix_net.c and win_net.c

unix_net.c
char	*NET_BaseAdrToString (netadr_t a)

win_net.c
void NET_OpenSocks( int port )
int NET_IPXSocket( int port )
void NET_OpenIPX( void )
static qboolean NET_GetCvars( void )
void NET_Config( qboolean enableNetworking )
void NET_Restart( void )

NET_BaseAdrToString appears only in unix_net.c, and is never called.
Can it be removed? Why are the other functions only in win_net.c?

7) Relating to the previous question, if IPX functions are
Windows-only, why are there IPX declarations in unix_net.c?

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

Let's get this finished and off the TODO list Need feedback and patches :)

Matt Turner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: net.c
Type: text/x-csrc
Size: 21802 bytes
Desc: not available
URL: <http://icculus.org/pipermail/quake3/attachments/20070814/361b2111/attachment.c>


More information about the quake3 mailing list