From: fadden@uts.amdahl.com (Andy McFadden)
Newsgroups: rec.games.netrek
Subject: Re: SGI UDP v1.0 binary -- Bug! (plus some gateway stuff)
Date: 14 Apr 92 20:35:04 GMT
Distribution: na
Organization: Amdahl Corporation, Sunnyvale CA

In article <1992Apr14.191808.13881@shinobu.sgi.com> mikey@sgi.com writes:
>There is a bug in the netrek/udp sources so that if you have something
>like:
>
>	udp.geometry:	40x9+1018+372
>
>in your .xtrekrc then the UDP menu will be created with only 9 entries
>instead of 10.  This will cause a memory overrun and eventually, a bad
>free when you bring up the menu.
>
>So, don't do this.  Thanks to George for helping me track this down.

Don't try to set the window size at all.  Just do the +1018+372 stuff.  I'd
hate to release a new udpopt.c and have everybody's clients die because
of what's in their .xtrekrc.

Note that this applies to other windows as well; for example, the options
window gets real confused if you give it an amputated geometry setting.

Incidentally, compiling with -DGATEWAY results in a menu with 11 items on it;
all the more reason to leave the size alone.

>                 Mike Yang        Silicon Graphics, Inc.
>               mikey@sgi.com           415/335-1786


If you're running UDP through a gateway, you should already have this in
main() in netrek/main.c:

-----
    if (showStats)                      /* Default showstats are on. */
        W_MapWindow(statwin);

#ifdef GATEWAY
    /* pick a nice set of UDP ports */
    getUdpPort();
#endif

    /* Get input until the player quits or dies */
    input();
-----

Replace the stub at the end with this routine:

----- cut here -----
#ifdef GATEWAY
static struct udpmap_t {
    int uid;
    int serv_port;
    int port;
    int local_port;
} udpmap[] = {
    /*          5000, 5001, 5000 */		/* generic */
    { 1290,     5010, 5011, 5010 },             /* fadden */
    { 757,      5020, 5021, 5020 },             /* user2 */
};
#define MAPSIZE (sizeof(udpmap) / sizeof(struct udpmap_t))

getUdpPort()
{
    int i;
    uid_t uid;

    gw_mach = "charon";
    uid = getuid();

    for (i = 0; i < MAPSIZE; i++) {
        if (uid == udpmap[i].uid) {
            gw_serv_port = udpmap[i].serv_port;
            gw_port = udpmap[i].port;
            gw_local_port = udpmap[i].local_port;
            return;
        }
    }

    /* not recognized; use default UDP port */
    gw_serv_port = 5000;
    gw_port = 5001;
    gw_local_port = 5000;
}
#endif
----- cut here -----

The ports will appear as the 11th item in the UDP options menu.  You should
put the port triplets into your .gwrc.

Incidentally, I had some problems with getting connections when I specified
more than one UDP port in my .gwrc... about 90% of the connection attempts
would fail with a ghostbust message (that's TCP; UDP not involved).  I put
some more perror()s into gw this morning and the problem went away.  I don't
understand it.

Anyway, if you're having massive problems with connections, leave at most
one UDP port declaration in your .gwrc and try again.  I can also send you
the newer version of gw (no new features, just some minor fixes... I'd like
to figure out what the problem was before I post it though).

-- 
fadden@uts.amdahl.com (Andy McFadden)
[ Above opinions are mine, Amdahl has nothing to do with them, etc, etc. ]