diff -u thd1.51/Makefile thd1.52/Makefile
--- thd1.51/Makefile	Fri Oct 30 01:06:26 1992
+++ thd1.52/Makefile	Sat Dec 28 02:45:02 1996
@@ -7,7 +7,7 @@
 TARGET	= trekhopd
 UTSLIBS	= -lbsd -lsocket
 
-CFLAGS	= -O -s
+CFLAGS	= -O2 -s -Wall
 #CFLAGS	= -g
 LIBS	=
 
diff -u thd1.51/README thd1.52/README
--- thd1.51/README	Fri Sep  3 22:34:16 1993
+++ thd1.52/README	Sat Dec 28 02:45:02 1996
@@ -1,6 +1,9 @@
-trekhopd v1.50 - Netrek firewall hop daemon
-By Andy McFadden (fadden@uts.amdahl.com)
+trekhopd v1.52 - Netrek firewall hop daemon
+By Andy McFadden (fadden@netcom.com)
 Updated: 03-Sep-93
+Updated: 27-Dec-96 by Otmar Lendl (lendl@cosy.sbg.ac.at)
+	( Fixed a few bugs to get it running under Linux.
+	  Plus a lot of code-cleanups to make gcc -Wall happy. )
 
 
 OVERVIEW:
@@ -388,6 +391,7 @@
 - Return some sort of meaningful error result when unable to establish
   a connection.
 - Make sure all the byte ordering problems are gone.
+  (fixed that one in 1.52)
 
-Send all bug reports to fadden@uts.amdahl.com.
+Send all bug reports to fadden@netcom.com.
 
Common subdirectories: thd1.51/client and thd1.52/client
diff -u thd1.51/main.c thd1.52/main.c
--- thd1.51/main.c	Mon Dec 13 19:27:34 1993
+++ thd1.52/main.c	Sat Dec 28 02:45:02 1996
@@ -2,12 +2,19 @@
  * main.c - args, configuration, logging
  *
  * trekhopd (Netrek firewall hop daemon)
- * By Andy McFadden
+ * By Andy McFadden (with fixes from Otmar Lendl)
  */
 #include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
 #include <string.h>
 #include <signal.h>
+#include <time.h>
 #include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
 #include "thd.h"
 
 
@@ -31,7 +38,7 @@
  */
 static FILE *logfp = NULL;	/* log file */
 static int do_log = TRUE;	/* set from config file */
-static int truncate = 0;	/* truncate log file on startup? */
+static int truncate_log = 0;	/* truncate_log log file on startup? */
 
 
 /*
@@ -299,10 +306,10 @@
     if (!do_log) return;
 
     /* prepare the log file */
-    if (!truncate)
+    if (!truncate_log)
 	ostr = "a";	/* just append */
     else
-	ostr = "w";	/* truncate */
+	ostr = "w";	/* truncate_log */
 
     if ((logfp = fopen(LOGFILE, ostr)) == NULL) {
 	perror("ERROR: can't open log file for writing");
@@ -318,7 +325,7 @@
 
 
 /* fatal signal received */
-static int
+static void
 sig_death(sig)
 int sig;
 {
@@ -330,7 +337,7 @@
 
 
 /* ejection signal receieved */
-static int
+static void
 sig_eject(sig)
 int sig;
 {
@@ -342,7 +349,7 @@
 
 
 /* reconfigure signal receieved */
-static int
+static void
 sig_reconfig(sig)
 int sig;
 {
@@ -355,7 +362,7 @@
 
 /* put #of active connections in log */
 /* (also puts info on active connections in USERFILE) */
-static int
+static void
 sig_count(sig)
 int sig;
 {
@@ -399,7 +406,7 @@
 	    verbose++;
 	    break;
 	case 't':
-	    truncate++;
+	    truncate_log++;
 	    break;
 	case 'p':	/* overrides thdrc setting */
 	    listen_port = atoi(optarg);
diff -u thd1.51/meta.c thd1.52/meta.c
--- thd1.51/meta.c	Tue Sep 29 21:22:15 1992
+++ thd1.52/meta.c	Sat Dec 28 02:45:02 1996
@@ -2,9 +2,10 @@
  * meta.c - handle metaserver stuff (added as an afterthought)
  *
  * trekhopd (Netrek firewall hop daemon)
- * By Andy McFadden
+ * By Andy McFadden (with fixes from Otmar Lendl)
  */
 #include <stdio.h>
+#include <unistd.h>
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/time.h>
@@ -19,8 +20,8 @@
  * globals
  */
 int meta_port = 2520;			/* where to contact metaserver */
-char *meta_host = "sickdog.cs.berkeley.edu";
-
+char default_meta_host[100] = "metaserver.ecst.csuchico.edu";
+char *meta_host = default_meta_host;	/* gcc/linux barfed on original code*/
 
 /*
  * private stuff
@@ -57,7 +58,7 @@
 
     /* accept connection from client */
     length = sizeof(struct sockaddr_in);
-    if ((csock = accept(fd, &addr, &length)) < 0) {
+    if ((csock = accept(fd, (struct sockaddr *) &addr, &length)) < 0) {
 	perror("WARNING: metaserver accept failed");
 	return (-1);
     }
@@ -74,7 +75,7 @@
     }
     hp = gethostbyaddr((char *) &addr.sin_addr.s_addr, sizeof(long), AF_INET);
     if (hp != NULL)
-	host = hp->h_name;
+	host = (char *) hp->h_name;
     else
 	host = inet_ntoa(addr.sin_addr);
 
@@ -116,7 +117,7 @@
 	perror("unable to set NB mode for connect");
 	return (-1);
     }
-    if (connect(ssock, &addr, sizeof(addr)) < 0) {
+    if (connect(ssock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
 	if (errno != EINPROGRESS) {
 	    perror("connect (metaserver connection)");
 	    log_msg("%.2d connection to metaserver failed", csock);
diff -u thd1.51/thd.c thd1.52/thd.c
--- thd1.51/thd.c	Tue May 17 23:07:13 1994
+++ thd1.52/thd.c	Sat Dec 28 02:45:02 1996
@@ -2,9 +2,12 @@
  * thd.c - the meaty part
  *
  * trekhopd (Netrek firewall hop daemon)
- * By Andy McFadden
+ * By Andy McFadden (with fixes from Otmar Lendl)
  */
 #include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/time.h>
@@ -15,6 +18,13 @@
 #include <errno.h>
 #include "thd.h"
 
+
+/*
+ * declarations
+ */
+static int write_data( int fd, char *buf, int count);
+void printUdpInfo(int sock);
+
 /*
  * globals
  */
@@ -66,7 +76,7 @@
     long  client_addr;
     char  server_host[MAXHOSTLEN];
     long  server_addr;
-    int   tcp_client_port;
+    int   tcp_client_port;	/* all in network byte order */
     int   tcp_server_port;
     int   udp_client_port;
     int   udp_server_port;
@@ -249,6 +259,7 @@
     struct hostent *hp;
     time_t t;
     int length, port;
+    unsigned int remote_ip;
     int i, j, newsock;
     char *cp, *host;
 
@@ -257,7 +268,7 @@
     /* accept the new connection */
     /* (could make this nonblocking as well, but that's too painful) */
     length = sizeof(struct sockaddr_in);
-    if ((newsock = accept(sock, &sin, &length)) < 0) {
+    if ((newsock = accept(sock,(struct sockaddr *) &sin, &length)) < 0) {
 	int err = errno;
 	if (verbose) perror("WARNING: accept failed");
 	log_msg("accept() failed, err=%d\n", err);
@@ -275,17 +286,18 @@
     }
     hp = gethostbyaddr((char *) &sin.sin_addr.s_addr, sizeof(long), AF_INET);
     if (hp != NULL)
-	host = hp->h_name;
+	host = (char *) hp->h_name;
     else
 	host = inet_ntoa(sin.sin_addr);
     port = ntohs(sin.sin_port);
 
 
     /* validate the source host against localnet */
-    oh.octet_addr[0] =(unsigned char)( sin.sin_addr.s_addr        & 0x000000ff);
-    oh.octet_addr[1] =(unsigned char)((sin.sin_addr.s_addr >> 8 ) & 0x000000ff);
-    oh.octet_addr[2] =(unsigned char)((sin.sin_addr.s_addr >> 16) & 0x000000ff);
-    oh.octet_addr[3] =(unsigned char)((sin.sin_addr.s_addr >> 24) & 0x000000ff);
+    remote_ip = ntohl(sin.sin_addr.s_addr);
+    oh.octet_addr[0] =(unsigned char)( remote_ip        & 0x000000ff);
+    oh.octet_addr[1] =(unsigned char)((remote_ip >> 8 ) & 0x000000ff);
+    oh.octet_addr[2] =(unsigned char)((remote_ip >> 16) & 0x000000ff);
+    oh.octet_addr[3] =(unsigned char)((remote_ip >> 24) & 0x000000ff);
 
     lp = localnet;	/* don't forget, this can be NULL */
     for (i = 0; i < localnet_count; i++, lp++) {
@@ -319,7 +331,7 @@
 
     strncpy(news->client_host, host, MAXHOSTLEN);
     news->client_addr = sin.sin_addr.s_addr;
-    news->tcp_client_port = port;
+    news->tcp_client_port = htons(port);
     news->tcp_client.sock = newsock;
 
     /* set up this fd, so info gets sent to TCP server port */
@@ -433,7 +445,7 @@
 	log_msg("fcntl(F_SETFL-delay) failed, err=%d", errno);
 	return (-1);
     }
-    if (connect(sock, &addr, sizeof(addr)) < 0) {
+    if (connect(sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
 	if (errno != EINPROGRESS) {
 	    log_msg("conect(server) failed, err=%d", errno);
 	    close(sock);
@@ -475,13 +487,13 @@
 	addr.sin_family = AF_INET;
 	addr.sin_addr.s_addr = htonl(INADDR_ANY);
 	addr.sin_port = 0;
-	if (bind(usock, &addr, sizeof(addr)) < 0) {
+	if (bind(usock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
 	    log_msg("%.2d unable to bind(1), err=%d", usock, errno);
 	    close(usock);
 	    return (-1);
 	}
 	len = sizeof(addr);
-	if (getsockname(usock, &addr, &len) < 0) {
+	if (getsockname(usock, (struct sockaddr *) &addr, &len) < 0) {
 	    log_msg("getsockname(1) failed, err=%d\n", errno);
 	    close(usock);
 	    return (-1);
@@ -503,14 +515,16 @@
 	    log_msg("socket(DGRAM-2) failed, err=%d\n", errno);
 	    return (-1);
 	}
+	addr.sin_family = AF_INET;
+	addr.sin_addr.s_addr = htonl(INADDR_ANY);
 	addr.sin_port = 0;
-	if (bind(usock, &addr, sizeof(addr)) < 0) {
+	if (bind(usock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
 	    log_msg("%.2d unable to bind(2), err=%d", usock, errno);
 	    close(usock);
 	    return (-1);
 	}
 	len = sizeof(addr);
-	if (getsockname(usock, &addr, &len) < 0) {
+	if (getsockname(usock, (struct sockaddr *) &addr, &len) < 0) {
 	    log_msg("getsockname(2) failed, err=%d\n", errno);
 	    close(usock);
 	    return (-1);
@@ -519,7 +533,7 @@
 
 	addr.sin_addr.s_addr = sp->client_addr;
 	addr.sin_port = htons(gw_local_port);
-	if (connect(usock, &addr, sizeof(addr)) < 0) {
+	if (connect(usock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
 	    log_msg("%.2d UDP connect failed, err=%d", usock, errno);
 	    close(usock);
 	    return (-1);
@@ -590,7 +604,7 @@
 
     /* form up and send the reply */
     len = sizeof(saddr);
-    if (getpeername(sock, &saddr, &len) < 0) {
+    if (getpeername(sock, (struct sockaddr *) &saddr, &len) < 0) {
 	/* will get an ENOTCONN if the connect() failed; no big deal */
 	if (errno == ENOTCONN)
 	    log_msg("%.2d getpeername() - earlier connect() failed", sock);
@@ -606,7 +620,7 @@
     *lp++ = htonl(sp->gw_serv_port);
     *lp++ = htonl(sp->gw_port);
     *lp++ = htonl(serv_port);
-    if (write_data(sp->tcp_client.sock, &reply, sizeof(reply)) < 0) {
+    if (write_data(sp->tcp_client.sock,(char *) &reply, sizeof(reply)) < 0) {
 	log_msg("%.2d unable to send reply to client", sp->tcp_client.sock);
 	/* ack!  keep going, maybe nobody will notice */
     }
@@ -619,26 +633,26 @@
 /*
  * debug
  */
-printUdpInfo(sock)
+void printUdpInfo(sock)
 int sock;
 {
     struct sockaddr_in addr;
     int len;
 
     len = sizeof(addr);
-    if (getsockname(sock, &addr, &len) < 0) {
+    if (getsockname(sock, (struct sockaddr *) &addr, &len) < 0) {
 /*      if (verbose) perror("printUdpInfo: getsockname");*/
         return;
     }
-    log_msg("+ LOCAL: addr=0x%x, family=%d, port=%d\n", addr.sin_addr.s_addr,
-        addr.sin_family, ntohs(addr.sin_port));
+    log_msg("+ LOCAL: addr=0x%08x, family=%d, port=%d\n", 
+	ntohl(addr.sin_addr.s_addr), addr.sin_family, ntohs(addr.sin_port));
 
-    if (getpeername(sock, &addr, &len) < 0) {
+    if (getpeername(sock, (struct sockaddr *) &addr, &len) < 0) {
 /*      if (verbose) perror("printUdpInfo: getpeername");*/
         return;
     }
-    log_msg("+ PEER : addr=0x%x, family=%d, port=%d\n", addr.sin_addr.s_addr,
-        addr.sin_family, ntohs(addr.sin_port));
+    log_msg("+ PEER : addr=0x%08x, family=%d, port=%d\n", 
+	ntohl(addr.sin_addr.s_addr), addr.sin_family, ntohs(addr.sin_port));
 }
 
 
@@ -662,7 +676,8 @@
 
     usock = sp->udp_server.sock;
     length = sizeof(from);
-    if ((cc = recvfrom(usock, rdbuf, RDBUF_SIZE, 0, &from, &length)) <= 0) {
+    if ((cc = recvfrom(usock, rdbuf, RDBUF_SIZE, 0,
+		(struct sockaddr *)  &from, &length)) <= 0) {
 	if (verbose) perror("bad recvfrom");
 	log_msg("%.2d bad UDP recvfrom", usock);
 	return (-1);
@@ -672,7 +687,7 @@
 	/* this is the "calvin" bug - advertised IP addr != from.addr */
 	if (verbose) printf("%.2d strange UDP host addr\n", usock);
 	log_msg("%.2d note: UDP from 0x%.8lx, expected from 0x%.8lx\n",
-	    usock, from.sin_addr.s_addr, sp->server_addr);
+	    usock, ntohl(from.sin_addr.s_addr), sp->server_addr);
 	/* check for weird charon glitch */
 	if (ntohs(from.sin_port) < 1024) {
 	    log_msg("%.2d WHOA: bogus source address, addr not changed", usock);
@@ -681,7 +696,7 @@
 	sp->server_addr = from.sin_addr.s_addr;
     }
 
-    if (ntohs(from.sin_port) != sp->udp_server_port) {
+    if (from.sin_port != sp->udp_server_port) {
 	/* new connection or we just got reconnected */
 	hp = gethostbyaddr((char *) &from.sin_addr.s_addr,sizeof(long),AF_INET);
 	if (sp->udp_server_port == -1) {
@@ -692,10 +707,10 @@
 						    inet_ntoa(from.sin_addr));
 	}
 
-	sp->udp_server_port = ntohs(from.sin_port);
+	sp->udp_server_port = from.sin_port;
 
 	log_msg("%.2d UDP connection complete to server port %d", usock,
-	    sp->udp_server_port);
+	    ntohs(sp->udp_server_port));
 
 	if (sp->udp_when == (time_t) 0)
 	    sp->udp_when = time(0);
@@ -724,7 +739,8 @@
     addr.sin_addr.s_addr = sp->server_addr;
     length = sizeof(addr);
     for ( ; count ; count -= n, buf += n) {
-	if ((n = sendto(sp->udp_server.sock, buf, count, 0, &addr, length))<0) {
+	if ((n = sendto(sp->udp_server.sock, buf, count, 0, 
+		(struct sockaddr *) &addr, length))<0) {
 	    if (verbose) perror("sendto");
 	    log_msg("%.2d UDP sendto, err=%d", sp->udp_server.sock, errno);
 	    return (-1);
@@ -1041,7 +1057,7 @@
     addr.sin_family = AF_INET;
     addr.sin_addr.s_addr = htonl(INADDR_ANY);
     addr.sin_port = htons(listen_port);
-    if (bind(lsock, &addr, sizeof(addr)) < 0) {
+    if (bind(lsock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
 	if (verbose) perror("ERROR: unable to bind to socket");
 	log_msg("exit: unable to bind to listen socket, err=%d", errno);
 	exit(1);
@@ -1069,7 +1085,7 @@
 	addr.sin_family = AF_INET;
 	addr.sin_addr.s_addr = htonl(INADDR_ANY);
 	addr.sin_port = htons(meta_listen_port);
-	if (bind(mlsock, &addr, sizeof(addr)) < 0) {
+	if (bind(mlsock, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
 	    if (verbose) perror("ERROR: unable to bind to socket");
 	    log_msg("WARNING: unable to bind to meta socket, err=%d", errno);
 	}
diff -u thd1.51/thd.h thd1.52/thd.h
--- thd1.51/thd.h	Mon Dec 13 19:27:11 1993
+++ thd1.52/thd.h	Sat Dec 28 02:45:02 1996
@@ -8,7 +8,7 @@
 /* files - adjust to taste */
 #define LOGFILE		"thdlog"
 #define CONFIGFILE	"thdrc"
-#define USERFILE	"/tmp/thd.users"
+#define USERFILE	"thd.users"
 
 
 
@@ -51,6 +51,9 @@
 	   handle_meta(/*int fd*/);
 extern char *strcasestr(/*char *str, char *pat*/);
 extern char *ctime();
+int act_count();
+int connect_meta(int fd);
+void log_msg();
 
 /* global variables */
 extern int verbose,
@@ -62,8 +65,7 @@
 	   local_origin_only,
 	   localnet_count,
 	   kill_all;
-extern char *prog,
-	    *meta_host;
+extern char *prog, *meta_host;
 extern SERVER *approved;
 extern OCTET_HOST *localnet;
 
Only in thd1.52: thdlog
Only in thd1.52: thdrc
diff -u thd1.51/util.c thd1.52/util.c
--- thd1.51/util.c	Tue Sep 29 21:22:15 1992
+++ thd1.52/util.c	Sat Dec 28 02:45:02 1996
@@ -2,7 +2,7 @@
  * util.c - stuff which ought to be in clib (IMHO)
  *
  * trekhopd (Netrek firewall hop daemon)
- * By Andy McFadden
+ * By Andy McFadden 
  */
 #include <stdio.h>
 #include <ctype.h>
