[quake3] Mergine unix_net.c and win_net.c questions
Ludwig Nussel
ludwig.nussel at suse.de
Wed Aug 15 14:15:19 EDT 2007
Matt Turner wrote:
> On 8/15/07, Ludwig Nussel <ludwig.nussel at suse.de> wrote:
> > 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.
>
> So the correct thing to do here is to perform all checks, regardless
> of platform?
Sure. Ideally localIP should be properly set as well. There is code
that retrieves local IP addresses via netlink inside #ifdef MACOS_X.
That code looks familiar, it probably just works on Linux as well.
> > > 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
>
> I thought about #defining SOCKET_ERROR -1 and stuff like that, but I
> wasn't sure if that would be acceptable. Is it?
Sure. Maybe SOCKET_ERROR is just -1 on Windows as well? In that case
just write -1.
cu
Ludwig
--
(o_ Ludwig Nussel
//\ SUSE LINUX Products GmbH, Development
V_/_ http://www.suse.de/
More information about the quake3
mailing list