diff -urN clussed-19981214/CHANGELOG clussed-19981221/CHANGELOG --- clussed-19981214/CHANGELOG Mon Dec 14 00:58:09 1998 +++ clussed-19981221/CHANGELOG Mon Dec 21 19:40:06 1998 @@ -5,4 +5,17 @@ and made the linker scripts initially work. Touched the networking bits a little bit. Can start working out the PC linking protocol and networking and real features next. + +Mon Dec 21 19:36:55 EET 1998 + Fixed outgoing connections things. + Added stuff with per-socket errnos. + Cleaned up logging. + Added GDBM linking and the db.c wrapper, made f_luser.c use it. + Added cfile.c, now containing files_init() and files_close(). + Added INSTALL "document". + Made it stay alive even without interface.conf and links.conf. + Added data/ and etc/ directories. + Added short comments in the beginning of (mostly) all c files. + Added 'make snap' for making source snapshots. lazy me + diff -urN clussed-19981214/INSTALL clussed-19981221/INSTALL --- clussed-19981214/INSTALL Thu Jan 1 02:00:00 1970 +++ clussed-19981221/INSTALL Sun Dec 20 18:08:27 1998 @@ -0,0 +1,3 @@ + + Installation of clussed requires kernel ax.25, net/rom and tcp sockets +support. zlib and gdbm libraries are also a must. diff -urN clussed-19981214/Makefile clussed-19981221/Makefile --- clussed-19981214/Makefile Mon Dec 14 00:56:05 1998 +++ clussed-19981221/Makefile Mon Dec 21 19:13:54 1998 @@ -10,20 +10,26 @@ all: compile.h $(EXECS) -back: - rm -f ../clussed.tar.gz - tar cvfz ../clussed.tar.gz * - +back: distclean + @echo "Making backup ..." + (cd ..; rm -f clussed.tar.gz; tar cvfz clussed.tar.gz clussed) + +snap: distclean + @echo "Making snapshot ..." + @Snapshot.sh + clean: - rm -f *.o */*.o *~ */*~ core + @echo "Making clean ..." + rm -f *.o */*.o *~ */*~ core compile.h distclean: clean + @echo "Making distclean ..." rm -f $(EXECS) .c.o: $(CC) $(CFLAGS) -c $< compile.h: dummy - @echo -n "Making compile.h .... " + @echo -n "Making compile.h ... " @echo \#define COMPILE_DATE \"`date +%d-%b-%y`\" > .ver @echo \#define COMPILE_TIME \"`date +%T`\" >> .ver @echo \#define COMPILE_DATETIME \"`date`\" >> .ver @@ -46,7 +52,7 @@ dummy: -CLUSSED_MODULES = hmalloc.o crc.o timer.o cstring.o ctime.o log.o \ +CLUSSED_MODULES = hmalloc.o crc.o timer.o cstring.o ctime.o log.o db.o \ cfgfile.o config.o cfg_iface.o cfg_links.o \ af_inet.o af_ax25.o af_netrom.o \ csock.o telnet.o \ @@ -57,14 +63,16 @@ cmd_cluster.o cmd_sys.o cmd_net.o \ network.o net_link.o net_user.o net_ping.o net_rdb.o net_pc.o \ linker.o ui.o \ - f_dx.o f_ann.o f_wwv.o f_nuser.o f_last.o mid.o \ + cfile.o f_dx.o f_ann.o f_wwv.o f_luser.o f_nuser.o f_last.o mid.o \ lib/libax25.a -CLUSSED_LIBS = -lm -lz +CLUSSED_LIBS = -lm -lz -lgdbm clussed: $(CLUSSED_MODULES) $(LD) -o clussed $(LDFLAGS) $(CLUSSED_LIBS) $(CLUSSED_MODULES) +# uh. should set up some makedepend stuff soon. in the mean time... + version.h: compile.h crc.o: crc.h crc.c log.o: log.h log.c @@ -72,6 +80,7 @@ ctime.o: ctime.h ctime.c timer.o: timer.h timer.c hmalloc.h hmalloc.o: hmalloc.h hmalloc.c log.h +db.o: db.h db.c hmalloc.h log.h cfgfile.o: cfgfile.h cfgfile.c ctypes.h cstring.h log.h hmalloc.h config.o: config.h config.c ctypes.h cfgfile.h cfg_iface.h cfg_links.h \ log.h csock.h cstring.h @@ -87,9 +96,9 @@ login.o: login.h login.c luser.h version.h config.h cstring.h csock.h \ telnet.h main.o: ctime.h cstring.h log.h config.h csock.h timer.h version.h \ - network.h + network.h cfile.h luser.o: luser.h luser.c config.h log.h hmalloc.h version.h csock.h \ - net_user.h + net_user.h f_luser.h cluster.o: cluster.h cluster.c command.h help.h cmd_sys.h cmd_cluster.h \ cmd_net.h network.h net_ping.h command.o: command.h command.c csock.h cfgfile.h @@ -111,9 +120,11 @@ net_rdb.o: net_rdb.h net_rdb.c linker.o: linker.h linker.c hmalloc.h csock.h log.h cfgfile.h ui.o: ui.h ui.c +cfile.o: cfile.h cfile.c f_luser.h f_dx.o: f_dx.h f_dx.c f_ann.o: f_ann.h f_ann.c f_wwv.o: f_wwv.h f_wwv.c +f_luser.o: f_luser.h f_luser.c hmalloc.h log.h db.h config.h cstring.h f_nuser.o: f_nuser.h f_nuser.c hmalloc.h ctypes.h log.h f_last.o: f_last.h f_last.c mid.o: mid.h mid.c diff -urN clussed-19981214/README clussed-19981221/README --- clussed-19981214/README Mon Dec 14 00:52:19 1998 +++ clussed-19981221/README Sun Dec 20 18:08:27 1998 @@ -4,7 +4,8 @@ It isn't useful yet. It's under the GPL, see the file COPYING for details. I hope to get it to somewhat useful state some time before the year 2000... -don't ask any questions yet. Code contributions are welcome. +no, make that 2001. don't ask any questions yet. Code contributions +are welcome. Read the CHANGES file for information on progress. diff -urN clussed-19981214/Snapshot.sh clussed-19981221/Snapshot.sh --- clussed-19981214/Snapshot.sh Thu Jan 1 02:00:00 1970 +++ clussed-19981221/Snapshot.sh Mon Dec 21 19:22:43 1998 @@ -0,0 +1,35 @@ +#!/bin/sh + +DATE=`date +%Y%m%d` +CURRTGZ="clussed-$DATE.tar.gz" +SNAPDIR="snaptmp-$DATE-$$" + +echo "Snapshot.sh: Creating snapshot dated $DATE" +cd .. + +rm -f clussed-$DATE.tar.gz + +PREVTGZ=`ls | grep clussed-*.tar.gz | sort | tail -1` +echo "Previous found in $PREVTGZ" + +echo "Creating $CURRTGZ ..." +mv clussed clussed-$DATE +tar cfz $CURRTGZ clussed-$DATE +mv clussed-$DATE clussed + +mkdir $SNAPDIR +cd $SNAPDIR +echo "Extracting $CURRTGZ ..." +tar xfz ../$CURRTGZ +echo "Extracting $PREVTGZ ..." +tar xfz ../$PREVTGZ +echo "Running diff ..." +diff -urN clussed-* | gzip -c - > ../patch-$DATE.gz +cd .. +echo "Cleaning up ..." +rm -rf $SNAPDIR + +echo "Patch in patch-$DATE.gz" + + + diff -urN clussed-19981214/af_ax25.c clussed-19981221/af_ax25.c --- clussed-19981214/af_ax25.c Thu Apr 2 21:49:24 1998 +++ clussed-19981221/af_ax25.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,10 @@ +/* + * af_ax25.c + * + * AX.25 sockets specific functions + */ + #include #include #include @@ -116,9 +122,6 @@ addrlen = sizeof(struct full_sockaddr_ax25); getsockname(new_fd, (struct sockaddr *)&sockaddr, &addrlen); s->port = hstrdup(ax25_config_get_port(&sockaddr.ax25.fsa_digipeater[0])); - - log(L_SINFO, "New AX.25 connection on fd %d from %s on port %s", - new_fd, s->call, s->port); sock_login(s); } diff -urN clussed-19981214/af_inet.c clussed-19981221/af_inet.c --- clussed-19981214/af_inet.c Thu Apr 2 21:46:44 1998 +++ clussed-19981221/af_inet.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,10 @@ +/* + * af_inet.c + * + * TCP sockets specific functions + */ + #include #include #include @@ -140,9 +146,6 @@ log(L_ERR, "TCP accept() error: %s", strerror(errno)); return; } - - log(L_SINFO, "New TCP connection on fd %d from %s", - new_fd, aptoa(sin.sin_addr, sin.sin_port)); i = 1; ioctl(new_fd, FIONBIO, &i); /* Make the socket non-blocking */ diff -urN clussed-19981214/af_netrom.c clussed-19981221/af_netrom.c --- clussed-19981214/af_netrom.c Thu Apr 2 21:49:43 1998 +++ clussed-19981221/af_netrom.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,10 @@ +/* + * af_netrom.c + * + * NET/ROM sockets specific functions + */ + #include #include #include @@ -116,9 +122,6 @@ addrlen = sizeof(struct full_sockaddr_ax25); s->port = hstrdup(lq->port); - - log(L_SINFO, "New NET/ROM connection on fd %d from %s@%s on port %s", - new_fd, s->call, s->node, s->port); sock_login(s); } diff -urN clussed-19981214/cfg_iface.c clussed-19981221/cfg_iface.c --- clussed-19981214/cfg_iface.c Thu Apr 2 21:43:16 1998 +++ clussed-19981221/cfg_iface.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,10 @@ +/* + * cfg_iface.c + * + * interface.conf directive parsing functions + */ + #include #include #include diff -urN clussed-19981214/cfg_links.c clussed-19981221/cfg_links.c --- clussed-19981214/cfg_links.c Fri Feb 20 14:54:14 1998 +++ clussed-19981221/cfg_links.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,10 @@ +/* + * cfg_links.c + * + * links.conf directive parsing functions + */ + #include "hmalloc.h" #include "network.h" #include "cfg_links.h" @@ -47,6 +53,8 @@ strcpy(link->name, hstrupr(argv[1])); strcpy(link->call, argv[1]); + + link_max++; return 0; } diff -urN clussed-19981214/cfgfile.c clussed-19981221/cfgfile.c --- clussed-19981214/cfgfile.c Sun Jan 4 20:58:25 1998 +++ clussed-19981221/cfgfile.c Sun Dec 20 18:08:27 1998 @@ -1,8 +1,15 @@ +/* + * cfgfile.c + * + * Generic config file parsing routines + */ + #include #include #include #include +#include #include "cfgfile.h" #include "hmalloc.h" @@ -206,8 +213,8 @@ int ret, n = 0; if ((fp = fopen(f, "r")) == NULL) { - log(L_CRIT, "Cannot open %s", f); - exit(1); + log(L_CRIT, "Cannot open %s: %s", f, strerror(errno)); + return -1; } while (fgets(line, CFGLINE_LEN, fp) != NULL) { @@ -215,7 +222,7 @@ ret = cmdparse(cmds, line); if (ret < 0) { log(L_CRIT, "Problem in %s at line %d: %s", f, n, line); - exit(1); + return -2; } } fclose(fp); diff -urN clussed-19981214/cfile.c clussed-19981221/cfile.c --- clussed-19981214/cfile.c Thu Jan 1 02:00:00 1970 +++ clussed-19981221/cfile.c Sun Dec 20 18:08:27 1998 @@ -0,0 +1,13 @@ + +#include "cfile.h" +#include "f_luser.h" + +void files_init(void) +{ + open_luserf(); +} + +void files_close(void) +{ + close_luserf(); +} diff -urN clussed-19981214/cfile.h clussed-19981221/cfile.h --- clussed-19981214/cfile.h Thu Dec 4 00:03:45 1997 +++ clussed-19981221/cfile.h Sun Dec 20 18:08:27 1998 @@ -4,5 +4,8 @@ #define PATHLEN 1024 +extern void files_init(void); +void files_close(void); + #endif diff -urN clussed-19981214/clussed.conf clussed-19981221/clussed.conf --- clussed-19981214/clussed.conf Mon Dec 29 21:52:13 1997 +++ clussed-19981221/clussed.conf Thu Jan 1 02:00:00 1970 @@ -1,27 +0,0 @@ - -# -# Visible hostname -# -HostName funk.oh7lzb.ampr.org - -# -# Cluster callsign -# -Callsign oh7lzb-1 - -# -# Sysop's callsign and name -# -SysopCall oh7lzb -SysopName Hessu - -# -# The QTH of the node (arbitrary string) -# -QTH Koivukylä, Vantaa - -# -# Date string field order: dmy, mdy, ymd or ydm -# -#DateFormat dmy - diff -urN clussed-19981214/cluster.c clussed-19981221/cluster.c --- clussed-19981214/cluster.c Sun Jan 4 19:55:41 1998 +++ clussed-19981221/cluster.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,11 @@ +/* + * cluster.c + * + * Clusse-style linemode terminal cluster user interface + * command list, prompt, cluster event message sending + */ + #include "cluster.h" #include "command.h" #include "help.h" diff -urN clussed-19981214/cmath.h clussed-19981221/cmath.h --- clussed-19981214/cmath.h Thu Dec 4 00:00:00 1997 +++ clussed-19981221/cmath.h Sun Dec 20 18:08:27 1998 @@ -1,6 +1,6 @@ #ifndef CMATH_H -#define CMATH_H 1 +#define CMATH_H typedef char loc_t[7]; diff -urN clussed-19981214/cmd_cluster.c clussed-19981221/cmd_cluster.c --- clussed-19981214/cmd_cluster.c Sun Jan 4 20:48:53 1998 +++ clussed-19981221/cmd_cluster.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,10 @@ +/* + * cmd_cluster.c + * + * cluster user interface commands + */ + #include #include "csock.h" diff -urN clussed-19981214/cmd_net.c clussed-19981221/cmd_net.c --- clussed-19981214/cmd_net.c Mon Dec 29 23:10:11 1997 +++ clussed-19981221/cmd_net.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,10 @@ +/* + * cmd_net.c + * + * cluster network related commands + */ + #include #include diff -urN clussed-19981214/cmd_skeleton.c clussed-19981221/cmd_skeleton.c --- clussed-19981214/cmd_skeleton.c Sat Dec 13 20:16:28 1997 +++ clussed-19981221/cmd_skeleton.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,10 @@ +/* + * cmd_skeleton.c + * + * reference implementation for a dummy command + */ + #include "csock.h" #include "cmd_skeleton.h" diff -urN clussed-19981214/cmd_sys.c clussed-19981221/cmd_sys.c --- clussed-19981214/cmd_sys.c Sun Dec 13 20:43:53 1998 +++ clussed-19981221/cmd_sys.c Sun Dec 20 18:08:27 1998 @@ -1,11 +1,15 @@ +/* + * cmd_sys.c + * + * Clusse system related commands + */ + #include "csock.h" #include "cmd_sys.h" #include "cstring.h" #include "version.h" #include "hmalloc.h" - -char cs_statechrs[] = "?iCdD"; /* * diff -urN clussed-19981214/command.c clussed-19981221/command.c --- clussed-19981214/command.c Sat Dec 13 21:03:47 1997 +++ clussed-19981221/command.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,13 @@ +/* + * command.c + * + * command parser for the user interface + * + * TODO: don't use parse_args from cfgfile, but a simpler one + * (we don't wand trigraph escapes and stuff here!!) + */ + #include #include "command.h" diff -urN clussed-19981214/compile.h clussed-19981221/compile.h --- clussed-19981214/compile.h Mon Dec 14 00:49:08 1998 +++ clussed-19981221/compile.h Thu Jan 1 02:00:00 1970 @@ -1,10 +0,0 @@ -#define COMPILE_DATE "14-Dec-98" -#define COMPILE_TIME "00:49:07" -#define COMPILE_DATETIME "Mon Dec 14 00:49:07 EET 1998" -#define COMPILE_BY "root" -#define COMPILE_HOST "funk.oh7lzb.ampr.org" -#define COMPILE_DOMAIN "koivukyla.hoas.fi" -#define COMPILE_OS "Linux" -#define COMPILE_KERNEL COMPILE_OS " 2.0.36" -#define COMPILE_PLATFORM "i586" -#define COMPILER "gcc version 2.7.2.3" diff -urN clussed-19981214/config.c clussed-19981221/config.c --- clussed-19981214/config.c Sun Jan 18 21:02:03 1998 +++ clussed-19981221/config.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,10 @@ +/* + * config.c + * + * configuration file reading and command lists + */ + #include #include "config.h" @@ -54,8 +60,15 @@ void read_config(void) { - read_cfgfile(CONFIG_F, cfg_cmds); - read_cfgfile(INTCONFIG_F, cfg_cmds); + int i; + + if (read_cfgfile(CONFIG_F, cfg_cmds)) + exit(1); + if ((i = read_cfgfile(INTCONFIG_F, cfg_cmds))) { + if (i == -2) + exit(0); + log(L_ERR, "Continuing with no interfaces configured."); + } if (!( (hostname) && (clucall) && (sysop_call) && (sysop_name) && (qth) )) { @@ -64,5 +77,9 @@ } hstrupr((char *)clucall); - read_cfgfile(LINKS_F, links_cmds); + if ((i = read_cfgfile(LINKS_F, links_cmds))) { + if (i == -2) + exit(0); + log(L_ERR, "Continuing with no links configured."); + } } diff -urN clussed-19981214/config.h clussed-19981221/config.h --- clussed-19981214/config.h Sun Jan 18 20:54:04 1998 +++ clussed-19981221/config.h Sun Dec 20 18:08:27 1998 @@ -4,9 +4,11 @@ #include "ctypes.h" -#define CONFIG_F "clussed.conf" -#define INTCONFIG_F "interface.conf" -#define LINKS_F "links.conf" +#define ETC_D "etc/" +#define DATA_D "data/" +#define CONFIG_F ETC_D "clussed.conf" +#define INTCONFIG_F ETC_D "interface.conf" +#define LINKS_F ETC_D "links.conf" extern call_t *clucall; extern char *hostname; diff -urN clussed-19981214/crc.c clussed-19981221/crc.c --- clussed-19981214/crc.c Fri Jan 2 19:02:23 1998 +++ clussed-19981221/crc.c Sun Dec 20 18:08:27 1998 @@ -1,5 +1,8 @@ /* + * + * crc.c + * 32-bit CRC: diff -urN clussed-19981214/csock.c clussed-19981221/csock.c --- clussed-19981214/csock.c Sun Dec 13 22:37:12 1998 +++ clussed-19981221/csock.c Mon Dec 21 18:27:30 1998 @@ -1,4 +1,12 @@ +/* + * csock.c + * + * clusse socket abstraction layer + * buffering, non-blocking network I/O sockets + * supporting telnet, AX.25, NET/ROM + */ + #include #include #include @@ -41,6 +49,35 @@ "NULL" }; +/* + * Convert af_type to str + */ + +char *afstr(int af_type) +{ + static char af_inet_s[] = "TCP"; + static char af_ax25_s[] = "AX.25"; + static char af_nr_s[] = "NET/ROM"; + static char af_rs_s[] = "ROSE"; + static char s[10]; + + switch (af_type) { + case AF_INET: + return af_inet_s; + case AF_AX25: + return af_ax25_s; + case AF_NETROM: + return af_nr_s; + case AF_ROSE: + return af_rs_s; + default: + sprintf(s, "AF_%d", af_type); + return s; + } + + return NULL; +} + /************************************************************************ **** Socket list management ****************************************** ************************************************************************/ @@ -66,6 +103,7 @@ s->prevp = ps; s->next = NULL; s->fd = fd; + s->cs_errno = 0; s->type = cst_unknown; s->state = css_unknown; @@ -148,7 +186,9 @@ struct cscomp_t *c = s->comp; int i; - log(L_SDEBUG, "fd %d: sock_close(): Closing and deallocating socket", s->fd); + log(L_SINFO, "Socket: Disconnected %s: %s%s%s:%s (%d) (%s)", + afstr(s->af_type), (s->call) ? s->call : "", ((s->node) && (s->call)) ? ":" : "", + (s->node) ? s->node : "", s->port, s->fd, strerror(s->cs_errno)); FD_CLR(s->fd, &readfds); FD_CLR(s->fd, &writefds); close(s->fd); @@ -260,13 +300,16 @@ } s->eoltype = inet_eol; s->eol = INET_EOL; - log(L_SDEBUG, "fd %d: sock_connect(): Connecting to AF_INET: %s:%s", s->fd, inet_ntoa(s->sockaddr.inet.sin_addr), s->port); break; default: cs_errno = EPROTONOSUPPORT; goto trouble; } + log(L_SINFO, "Socket: Connecting %s: %s%s%s:%s (%d)", + afstr(s->af_type), (s->call) ? s->call : "", ((s->node) && (s->call)) ? ":" : "", + (s->node) ? s->node : "", s->port, s->fd); + /* * Ok. Now set up a non-blocking connect... */ @@ -300,6 +343,9 @@ void sock_connected(struct csock_t *s) { s->state = css_connected; + log(L_SINFO, "Socket: Connected %s: %s%s%s:%s (%d)", + afstr(s->af_type), (s->call) ? s->call : "", ((s->node) && (s->call)) ? ":" : "", + (s->node) ? s->node : "", s->port, s->fd); if (s->conn_handler) { (*s->conn_handler)(s); @@ -518,9 +564,10 @@ } if (len == -1) { + s->cs_errno = errno; log(L_SDEBUG, "fd %d: sock_read(): read() error: %s", - s->fd, strerror(errno)); - if (errno == EINTR) + s->fd, strerror(s->cs_errno)); + if (s->cs_errno == EINTR) return 0; return -1; } @@ -628,14 +675,16 @@ len = write(s->fd, s->robuf->buf, s->robuf->pos); if (len == -1) { - log(L_SDEBUG, "fd %d: csrflush(): write() error: %s", - s->fd, strerror(errno)); if (errno == EAGAIN) { log(L_SDEBUG, "fd %d: csrflush(): Would block, selecting on write", s->fd); FD_SET(s->fd, &writefds); + } else { + s->cs_errno = errno; + log(L_SDEBUG, "fd %d: csrflush(): write() error: %s", + s->fd, strerror(s->cs_errno)); + if (errno == EINTR) + return 0; } - if (errno == EINTR) - return 0; return -1; } @@ -821,6 +870,10 @@ s->type = cst_incoming; s->state = css_connected; + log(L_SINFO, "Socket: Incoming %s: %s%s%s:%s (%d)", + afstr(s->af_type), (s->call) ? s->call : "", ((s->node) && (s->call)) ? ":" : "", + (s->node) ? s->node : "", s->port, s->fd); + if (s->af_type == AF_INET) auth_login(s); else /* For now, only lusers allowed.... */ @@ -896,14 +949,15 @@ for (s = sockets; (s); s = nexts) { nexts = s->next; if (FD_ISSET(s->fd, &readchk)) { - if (s->state == css_connecting) - sock_connected(s); if ((r = sock_read(s)) < 0) { sock_close(s); continue; - } else + } else { + if (s->state == css_connecting) + sock_connected(s); if (sock_handle(s) == -2) continue; + } } if (FD_ISSET(s->fd, &writechk)) diff -urN clussed-19981214/csock.h clussed-19981221/csock.h --- clussed-19981214/csock.h Sun Dec 13 20:15:32 1998 +++ clussed-19981221/csock.h Sun Dec 20 18:08:27 1998 @@ -69,6 +69,7 @@ struct csock_t { /* Clusse Socket (TM) */ int fd; + int cs_errno; /* Type, state */ enum cstype_t type; diff -urN clussed-19981214/cstring.c clussed-19981221/cstring.c --- clussed-19981214/cstring.c Fri Feb 20 14:50:17 1998 +++ clussed-19981221/cstring.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,10 @@ +/* + * cstring.c + * + * character string manipulation functions + */ + #include #include #include @@ -94,6 +100,43 @@ return -1; return 0; +} + +/* + * Get SSID of a call + */ + +int getssid(const call_t *call) +{ + int ssid = 0; + char *s = (char *)call; + char *p[1]; + + while (*s && *s != '-') + s++; + if (*s == '-') { + if (!isdigit(*++s)) + return 0; + ssid = strtol(s, p, 10); + return ssid; + } + + return 0; +} + +/* + * Truncate SSID of a call + */ + +call_t *truncssid(call_t *call) +{ + char *s = (char *)call; + char *p; + + if ((p = strchr(s, '-'))) + *p = '\0'; + + return call; } /* diff -urN clussed-19981214/cstring.h clussed-19981221/cstring.h --- clussed-19981214/cstring.h Fri Feb 20 14:43:15 1998 +++ clussed-19981221/cstring.h Sun Dec 20 18:08:27 1998 @@ -35,7 +35,11 @@ /* misc */ extern void cstring_init(void); /* Initialize stuff */ extern int isabortstr(char *s); /* Is this an /ex or ctrl-z */ + +/* callsigns */ extern int valid_call(const call_t *call); /* Is this a valid callsign */ +extern int getssid(const call_t *call); /* Get SSID of a call */ +call_t *truncssid(call_t *call); /* Truncate SSID of a call */ /* String translations */ extern char *add_lf(char **s); /* CR => CRLF */ diff -urN clussed-19981214/ctime.c clussed-19981221/ctime.c --- clussed-19981214/ctime.c Mon Dec 29 21:52:01 1997 +++ clussed-19981221/ctime.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,10 @@ +/* + * ctime.c + * + * time manipulation and conversion functions + */ + #include #include Binary files clussed-19981214/data/luser.db and clussed-19981221/data/luser.db differ diff -urN clussed-19981214/db.c clussed-19981221/db.c --- clussed-19981214/db.c Thu Jan 1 02:00:00 1970 +++ clussed-19981221/db.c Sun Dec 20 18:08:27 1998 @@ -0,0 +1,89 @@ + +/* + * db.c + * + * an attempt to make a little bit of separation between the clusse + * code and gdbm, so that it would be a little bit easier to replace + * gdbm with something else, some day, when need arises. + */ + +#include +#include + +#include "db.h" +#include "hmalloc.h" +#include "log.h" + +void db_gdbm_fatal(char *s) +{ + log(L_CRIT, "gdbm fatal: %s (%s)", s, gdbm_strerror(gdbm_errno)); + exit(1); +} + +struct db_t *db_open(char *name) +{ + struct db_t *dbp; + + dbp = hmalloc(sizeof(struct db_t)); + dbp->name = hstrdup(name); + + dbp->f = gdbm_open(dbp->name, 0, GDBM_WRCREAT, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP, db_gdbm_fatal); + + if (!dbp->f) { + log(L_CRIT, "db_open(): gdbm_open() failed for %s: %s", dbp->name, gdbm_strerror(gdbm_errno)); + hfree(dbp->name); + hfree(dbp); + return NULL; + } + + return dbp; +} + +void db_close(struct db_t *dbp) +{ + gdbm_close(dbp->f); + + hfree(dbp->name); + hfree(dbp); +} + +int db_store(struct db_t *dbp, datum key, datum content) +{ + return gdbm_store(dbp->f, key, content, GDBM_REPLACE); +} + +datum db_fetch(struct db_t *dbp, datum key) +{ + return gdbm_fetch(dbp->f, key); +} + +int db_exists(struct db_t *dbp, datum key) +{ + return gdbm_exists(dbp->f, key); +} + +int db_delete(struct db_t *dbp, datum key) +{ + return gdbm_delete(dbp->f, key); +} + +datum db_firstkey(struct db_t *dbp) +{ + return gdbm_firstkey(dbp->f); +} + +datum db_nextkey(struct db_t *dbp, datum key) +{ + return gdbm_nextkey(dbp->f, key); +} + +void db_reorganize(struct db_t *dbp) +{ + gdbm_reorganize(dbp->f); +} + +void db_sync(struct db_t *dbp) +{ + gdbm_sync(dbp->f); +} + diff -urN clussed-19981214/db.h clussed-19981221/db.h --- clussed-19981214/db.h Thu Jan 1 02:00:00 1970 +++ clussed-19981221/db.h Sun Dec 20 18:08:27 1998 @@ -0,0 +1,23 @@ + +#ifndef DB_H +#define DB_H + +#include + +struct db_t { + GDBM_FILE f; + char *name; +}; + +extern struct db_t *db_open(char *name); +extern void db_close(struct db_t *dbp); +extern int db_store(struct db_t *dbp, datum key, datum content); +extern datum db_fetch(struct db_t *dbp, datum key); +extern int db_exists(struct db_t *dbp, datum key); +extern int db_delete(struct db_t *dbp, datum key); +extern datum db_firstkey(struct db_t *dbp); +extern datum db_nextkey(struct db_t *dbp, datum key); +extern void db_reorganize(struct db_t *dbp); +extern void db_sync(struct db_t *dbp); + +#endif diff -urN clussed-19981214/etc/clussed.conf clussed-19981221/etc/clussed.conf --- clussed-19981214/etc/clussed.conf Thu Jan 1 02:00:00 1970 +++ clussed-19981221/etc/clussed.conf Sun Dec 20 18:08:29 1998 @@ -0,0 +1,27 @@ + +# +# Visible hostname +# +HostName funk.oh7lzb.ampr.org + +# +# Cluster callsign +# +Callsign oh7lzb-1 + +# +# Sysop's callsign and name +# +SysopCall oh7lzb +SysopName Hessu + +# +# The QTH of the node (arbitrary string) +# +QTH Koivukylä, Vantaa + +# +# Date string field order: dmy, mdy, ymd or ydm +# +#DateFormat dmy + diff -urN clussed-19981214/etc/interface.conf clussed-19981221/etc/interface.conf --- clussed-19981214/etc/interface.conf Thu Jan 1 02:00:00 1970 +++ clussed-19981221/etc/interface.conf Sun Dec 20 18:08:29 1998 @@ -0,0 +1,37 @@ + +# +# TcpListen: Make clussed listen for connections on a TCP port +# +# TcpListen portname port (listen on all addresses) +# TcpListen portname host:port (listen on one address only) +# TcpListen portname ipaddr:port (without the help of DNS) +# +# The 'portname' is an arbitrary name string which Clusse will use +# in the user interface and logs for this interface. +# +# Feel free to use multiple TcpListen directives. +# + +TcpListen tcp 3690 +TcpListen tcp 3691 compress + +# +# Ax25Listen: Make clussed listen for AX.25 connections +# +# Ax25Listen port:callsign (single callsign on a single port) +# Ax25Listen callsign (the same callsign on all ports) +# + +Ax25Listen oh7lzb-1 +Ax25Listen oh7lzb-7 compress +#Ax25Listen bpq:oh7lzb-2 + +# +# NetromListen: Make clussed listen for NET/ROM connections +# +# NetromListen port (port being defined in nrports) +# + +NetromListen nrcl + + diff -urN clussed-19981214/etc/links.conf clussed-19981221/etc/links.conf --- clussed-19981214/etc/links.conf Thu Jan 1 02:00:00 1970 +++ clussed-19981221/etc/links.conf Sun Dec 20 18:08:29 1998 @@ -0,0 +1,9 @@ + +link oh1rbi-1 +protocol pc +script scripts/oh1rbi.con + +#link oh7rba-1 +#protocol pc +#script oh7rba.con + diff -urN clussed-19981214/f_luser.c clussed-19981221/f_luser.c --- clussed-19981214/f_luser.c Thu Jan 1 02:00:00 1970 +++ clussed-19981221/f_luser.c Sun Dec 20 18:08:27 1998 @@ -0,0 +1,87 @@ + +#include "f_luser.h" +#include "hmalloc.h" +#include "log.h" +#include "db.h" +#include "config.h" +#include "cstring.h" + +#define LUSER_F DATA_D "luser.db" + +struct db_t *luser_db = NULL; + +/* + * Get an entry from the local user file + */ + +struct luserf_t *read_luserf(call_t call) +{ + struct luserf_t *f; + call_t tcall; + datum key, content; + + strcpy(tcall, call); + truncssid(&tcall); + + key.dptr = (void *)&tcall; + key.dsize = strlen(tcall); + + content = db_fetch(luser_db, key); + if (content.dptr) { + if (content.dsize != sizeof(struct luserf_t)) { + log(L_ERR, "read_luserf(): OUCH, db entry of wrong size: %d != %d", content.dsize, sizeof(struct luserf_t)); + hfree(content.dptr); + return NULL; + } + f = (struct luserf_t *)content.dptr; + return f; + } + + return NULL; +} + +/* + * Write an entry to the local user file + */ + +void write_luserf(struct luserf_t *fp) +{ + call_t tcall; + datum key, content; + + strcpy(tcall, fp->call); + truncssid(&tcall); + + key.dptr = (void *)&tcall; + key.dsize = strlen(tcall); + + content.dptr = (void *)fp; + content.dsize = sizeof(struct luserf_t); + + db_store(luser_db, key, content); +} + +/* + * Open local user file + */ + +int open_luserf(void) +{ + luser_db = db_open(LUSER_F); + if (!luser_db) { + log(L_CRIT, "open_luserf(): db_open() failed for %s, abandon ship.", LUSER_F); + exit(1); + } + return 0; +} + +/* + * Close local user file + */ + +int close_luserf(void) +{ + db_close(luser_db); + return 0; +} + diff -urN clussed-19981214/f_luser.h clussed-19981221/f_luser.h --- clussed-19981214/f_luser.h Thu Jan 1 02:00:00 1970 +++ clussed-19981221/f_luser.h Sun Dec 20 18:08:27 1998 @@ -0,0 +1,12 @@ + +#ifndef F_LUSER_H +#define F_LUSER_H + +#include "luser.h" + +extern struct luserf_t *read_luserf(call_t call); +extern void write_luserf(struct luserf_t *f); +extern int open_luserf(void); +extern int close_luserf(void); + +#endif diff -urN clussed-19981214/hmalloc.c clussed-19981221/hmalloc.c --- clussed-19981214/hmalloc.c Sat Jan 3 17:30:21 1998 +++ clussed-19981221/hmalloc.c Sun Dec 20 18:08:27 1998 @@ -1,5 +1,7 @@ /* + * hmalloc.c + * * Replacements for malloc, realloc and free, which never fail, * and might keep statistics on memory allocation... */ @@ -56,8 +58,10 @@ { if (ptr) free(ptr); - else + else { + log(L_DEBUG, "hfree: trying to free null pointer"); hfree_nulls++; + } hfrees++; } diff -urN clussed-19981214/interface.conf clussed-19981221/interface.conf --- clussed-19981214/interface.conf Fri Nov 27 23:26:48 1998 +++ clussed-19981221/interface.conf Thu Jan 1 02:00:00 1970 @@ -1,38 +0,0 @@ - -# -# TcpListen: Make clussed listen for connections on a TCP port -# -# TcpListen portname port (listen on all addresses) -# TcpListen portname host:port (listen on one address only) -# TcpListen portname ipaddr:port (without the help of DNS) -# -# The 'portname' is an arbitrary name string which Clusse will use -# in the user interface and logs for this interface. -# -# Feel free to use multiple TcpListen directives. -# - -TcpListen tcp 3690 -TcpListen tcp 3691 compress - -# -# Ax25Listen: Make clussed listen for AX.25 connections -# -# Ax25Listen port:callsign (single callsign on a single port) -# Ax25Listen callsign (the same callsign on all ports) -# - -Ax25Listen oh7lzb-1 -Ax25Listen oh7lzb-7 compress -#Ax25Listen bpq:oh7lzb-2 - - -# -# NetromListen: Make clussed listen for NET/ROM connections -# -# NetromListen port (port being defined in nrports) -# - -NetromListen nrcl - - diff -urN clussed-19981214/linker.c clussed-19981221/linker.c --- clussed-19981214/linker.c Sun Dec 13 23:26:11 1998 +++ clussed-19981221/linker.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,10 @@ +/* + * linker.c + * + * connection script system for creating outgoing links + */ + #include #include @@ -44,7 +50,11 @@ if (lj->next) lj->next->prevp = lj->prevp; - hfree(lj->script); + if (lj->f) + fclose(lj->f); + if (lj->script) + hfree(lj->script); + hfree(lj); } @@ -196,7 +206,7 @@ return; } - log(L_LINK, "Linker: Script %s failed: Disconnected", lj->script); + log(L_LINK, "Linker: Script %s failed: Disconnected (%s)", lj->script, strerror(s->cs_errno)); end_connect(s, LJ_FAILURE); return; } diff -urN clussed-19981214/links.conf clussed-19981221/links.conf --- clussed-19981214/links.conf Sun Dec 13 16:55:39 1998 +++ clussed-19981221/links.conf Thu Jan 1 02:00:00 1970 @@ -1,9 +0,0 @@ - -link oh1rbi-1 -protocol pc -script scripts/oh1rbi.con - -#link oh7rba-1 -#protocol pc -#script oh7rba.con - diff -urN clussed-19981214/log.c clussed-19981221/log.c --- clussed-19981214/log.c Mon Nov 17 23:17:57 1997 +++ clussed-19981221/log.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,11 @@ +/* + * log.c + * + * logging facility with configurable log levels and + * logging destinations + */ + #include #include #include diff -urN clussed-19981214/login.c clussed-19981221/login.c --- clussed-19981214/login.c Sun Dec 13 18:32:11 1998 +++ clussed-19981221/login.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,11 @@ +/* + * login.c + * + * user login with password authentication for incoming telnet + * connections + */ + #include "login.h" #include "luser.h" #include "version.h" diff -urN clussed-19981214/luser.c clussed-19981221/luser.c --- clussed-19981214/luser.c Sun Dec 13 18:31:50 1998 +++ clussed-19981221/luser.c Sun Dec 20 18:08:27 1998 @@ -1,5 +1,13 @@ + +/* + * luser.c + * + * local user list handling functions + */ + #include +#include #include "config.h" #include "csock.h" @@ -9,6 +17,7 @@ #include "log.h" #include "hmalloc.h" #include "net_user.h" +#include "f_luser.h" struct luser_t *lusers = NULL; @@ -73,7 +82,6 @@ if (lu->next) lu->next->prevp = lu->prevp; -// nuser_free(u->nu); hfree(lu->f); hfree(lu->fl); hfree(lu->str); @@ -120,22 +128,87 @@ } /* + * Create a new luserf structure for a new user + */ + +struct luserf_t *new_luserf(call_t call) +{ + struct luserf_t *f; + + f = hmalloc(sizeof(struct luserf_t)); + strcpy(f->call, call); + truncssid(&f->call); + + f->personal[0] = '\0'; + f->locator[0] = '\0'; + f->loc.latitude = 0; + f->loc.longitude = 0; + f->group = 0; + f->messages = M_DX|M_ANN|M_WWV|M_TALK|M_LUSER|M_LINK; + f->beeps = 0; + f->flags = F_TIMESTAMP|F_FILTER; + f->login_act = 0; + f->charset = 0; + f->prompt = 0; + f->page_length = 24; + f->page_width = 78; + f->language = 0; + f->logins = 0; + f->time = 0; + + return f; +} + +/* + * Select an unique SSID for a new local user + */ + +call_t *select_nucall(const call_t lcall) +{ + call_t call; + static call_t trycall; + int ssid = 0; + + strcpy(call, (char *)lcall); + truncssid(&call); + strcpy(trycall, call); + + while (get_nuser(&trycall) || get_node(&trycall)) { + ssid++; + sprintf((char *)&trycall, "%s-%d", call, ssid); + } + + return &trycall; +} + +/* * Accept a user connection (or not) */ void luser_login(struct csock_t *s) { struct luser_t *lu; + int newuser = 0; - lu = luser_alloc(s); + log(L_LUSER, "User: %s@%s:%s logged in", s->call, s->node, s->port); - log(L_LUSER, "%s@%s/%s logged in", s->call, s->node, s->port); + lu = luser_alloc(s); + lu->f = read_luserf(s->call); + if (!lu->f) { + newuser = 1; + log(L_LUSER, "User: %s is a new user, creating", s->call); + lu->f = new_luserf(s->call); + write_luserf(lu->f); + } + lu->nu = nuser_login(NULL, select_nucall(s->call), localnode, 1); /* OH7LZB Clusse v0.31 - DX Cluster node OH7RBA-1 - 54/6 users, 16/2 nodes */ csprintf(s, "%s - DX Cluster node %s\n", SOFT_STRING, clucall); - csprintf(s, "\nHeavily under construction. Don't touch anything. Warranty void.\n"); + csprintf(s, "%d users, %d known, %d local, %d nodes, %d of %d links\n", kuser_count, nuser_count, luser_count, node_count, link_count, link_max); + csprintf(s, "\nHeavily under construction. If it breaks, you get to keep both pieces.\n"); - lu->nu = nuser_login(NULL, (call_t *)s->call, localnode, 1); + if (newuser) + csprintf(s, "Welcome, new user.\n"); prompt(s); } @@ -146,7 +219,7 @@ void luser_logout(struct csock_t *s) { - log(L_LUSER, "%s@%s/%s logged out", s->call, s->node, s->port); + log(L_LUSER, "User: %s@%s:%s logged out", s->call, s->node, s->port); net_deluser(NULL, s->lu->nu); luser_free(s->lu); } @@ -166,3 +239,4 @@ return 0; } + diff -urN clussed-19981214/main.c clussed-19981221/main.c --- clussed-19981214/main.c Mon Dec 29 22:26:42 1997 +++ clussed-19981221/main.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,31 @@ +/* + * + * Clusse + * Copyright Heikki Hannikainen, OH7LZB 1994-1998 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + */ + +/* + * main.c + * + * the mother of all functions + */ + #include "version.h" #include "ctime.h" #include "cstring.h" @@ -7,6 +34,7 @@ #include "timer.h" #include "network.h" #include "csock.h" +#include "cfile.h" /* * Main @@ -20,6 +48,7 @@ read_config(); /* Read configuration */ timer_init(); /* Initialize timer */ net_init(); /* Cluster networking init */ + files_init(); /* Open data files */ csock_init(); /* Initialize socket code, bind and listen */ log(L_INFO, "%s - ready to serve.", SOFT_STRING); select_loop(); /* Loop ad infinitum */ diff -urN clussed-19981214/net_link.c clussed-19981221/net_link.c --- clussed-19981214/net_link.c Sun Dec 13 23:20:18 1998 +++ clussed-19981221/net_link.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,11 @@ +/* + * net_link.c + * + * This module acts as a multiplexer for outgoing network + * messages to different protocol modules. + */ + #include #include "net_link.h" @@ -37,7 +44,18 @@ pc_talk(talk); } +void link_userdel(struct nuser_t *nu) +{ + pc_userdel(nu); +} + +void link_useraway(struct nuser_t *nu) +{ + pc_useraway(nu); +} + void link_userhere(struct nuser_t *nu) { pc_userhere(nu); } + diff -urN clussed-19981214/net_link.h clussed-19981221/net_link.h --- clussed-19981214/net_link.h Sun Dec 13 22:58:39 1998 +++ clussed-19981221/net_link.h Sun Dec 20 18:08:27 1998 @@ -9,6 +9,8 @@ extern void link_announce(struct ann_t *ann); extern void link_wwv(struct wwv_t *wwv); extern void link_talk(struct talk_t *t); +extern void link_userdel(struct nuser_t *nu); +extern void link_useraway(struct nuser_t *nu); extern void link_userhere(struct nuser_t *nu); #endif diff -urN clussed-19981214/net_pc.c clussed-19981221/net_pc.c --- clussed-19981214/net_pc.c Sun Dec 13 23:33:06 1998 +++ clussed-19981221/net_pc.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,10 @@ +/* + * net_pc.c + * + * PacketCluster (TM) linking "protocol" + */ + #include #include "net_pc.h" @@ -68,6 +74,22 @@ void pc_talk(struct talk_t *talk) { +} + +void pc_userdel(struct nuser_t *nu) +{ + if (pc_hops <= 98) + pc_sendall(nu->node->via, "PC17^%s^%s^%s^\n", nu->call, nu->node->call, hops2pcstr(pc_hops)); +} + +void pc_useraway(struct nuser_t *nu) +{ + if (nu->here && nu->node->hops <= 98) { + /* Only send PC24 if the user did go away for the first + time. Changing the away string doesn"t affect the PC. */ + + pc_sendall(nu->node->via, "PC24^%s^0^%s^\n", nu->call, hops2pcstr(pc_hops)); + } } void pc_userhere(struct nuser_t *nu) diff -urN clussed-19981214/net_pc.h clussed-19981221/net_pc.h --- clussed-19981214/net_pc.h Sun Dec 13 22:58:16 1998 +++ clussed-19981221/net_pc.h Sun Dec 20 18:08:27 1998 @@ -8,9 +8,12 @@ extern int pc_msgstats[51]; -extern char *hops2pcstr(int hops); - -extern void pc_sendall(struct link_t *via, char *fmt, ...); +/* Leave these undefined for now - we really, really don't want them + to be called outside net_pc.c. + + extern char *hops2pcstr(int hops); + extern void pc_sendall(struct link_t *via, char *fmt, ...); +*/ extern void pc_nodedel(struct node_t *n, char *reason); extern void pc_sendloopcheck(struct link_t *l); @@ -20,6 +23,8 @@ extern void pc_announce(struct ann_t *ann); extern void pc_wwv(struct wwv_t *wwv); extern void pc_talk(struct talk_t *t); +extern void pc_userdel(struct nuser_t *nu); +extern void pc_useraway(struct nuser_t *nu); extern void pc_userhere(struct nuser_t *nu); extern void pc_disc_handler(struct csock_t *s); diff -urN clussed-19981214/net_ping.c clussed-19981221/net_ping.c --- clussed-19981214/net_ping.c Mon Dec 29 22:06:47 1997 +++ clussed-19981221/net_ping.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,10 @@ +/* + * net_ping.c + * + * pinging another network node + */ + #include #include diff -urN clussed-19981214/net_ping.h clussed-19981221/net_ping.h --- clussed-19981214/net_ping.h Mon Dec 29 22:01:33 1997 +++ clussed-19981221/net_ping.h Sun Dec 20 18:08:27 1998 @@ -1,6 +1,6 @@ #ifndef NET_PING_H -#define NET_PING_H 1 +#define NET_PING_H #include diff -urN clussed-19981214/net_rdb.h clussed-19981221/net_rdb.h --- clussed-19981214/net_rdb.h Mon Dec 29 12:40:46 1997 +++ clussed-19981221/net_rdb.h Sun Dec 20 18:08:27 1998 @@ -1,6 +1,6 @@ #ifndef NET_RDB_H -#define NET_RDB_H 1 +#define NET_RDB_H #include "network.h" diff -urN clussed-19981214/net_user.c clussed-19981221/net_user.c --- clussed-19981214/net_user.c Sun Dec 13 23:01:58 1998 +++ clussed-19981221/net_user.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,10 @@ +/* + * net_user.c + * + * network user list handling + */ + #include #include @@ -27,16 +33,16 @@ * Delete an user from the user list */ -void free_nuser(struct nuser_t *u) +void free_nuser(struct nuser_t *nu) { - *u->prevp = u->next; - if (u->next) - u->next->prevp = u->prevp; - if (u->away_str) { - hfree(u->away_str); + *nu->prevp = nu->next; + if (nu->next) + nu->next->prevp = nu->prevp; + if (nu->away_str) { + hfree(nu->away_str); away_strings--; } - hfree(u); + hfree(nu); nuser_count--; kuser_count--; } @@ -47,14 +53,14 @@ void free_nusersn(struct node_t *n) { - struct nuser_t *u, *next; + struct nuser_t *nu, *next; - u = nusers; - while (u) { - next = u->next; - if (u->node == n) - free_nuser(u); - u = next; + nu = nusers; + while (nu) { + next = nu->next; + if (nu->node == n) + free_nuser(nu); + nu = next; } } @@ -62,31 +68,31 @@ * Add an user to the list */ -struct nuser_t *insert_nuser(struct nuser_t *u) +struct nuser_t *insert_nuser(struct nuser_t *nu) { struct nuser_t **prevp, *p; prevp = &nusers; p = nusers; - while ((p) && (strcmp(p->call, u->call) < 0)) { + while ((p) && (strcmp(p->call, nu->call) < 0)) { prevp = &p->next; p = p->next; } - *prevp = u; - u->prevp = prevp; - u->next = p; - if (u->next) - u->next->prevp = &u->next; + *prevp = nu; + nu->prevp = prevp; + nu->next = p; + if (nu->next) + nu->next->prevp = &nu->next; nuser_count++; kuser_count++; - + if (nuser_count > nuser_max) /* High water mark */ nuser_max = nuser_count; if (kuser_count > kuser_max) /* High water mark */ kuser_max = kuser_count; - - return u; + + return nu; } /* @@ -123,7 +129,6 @@ l = strlen((char *)call); if (l != 0) { while ((p)) { - /* Match against the _end_ of the call: Copy(p^.call,Length(p^.call) - l + 1,l) = call */ /* Match substring: */ if (strstr(p->call, (char *)call)) { if (!strcmp((char *)call, p->call)) @@ -206,12 +211,8 @@ log(L_NUSER, "%s is away: %s", call, reason); } else log(L_NUSER, "%s is away.", call); - - if (u->here && u->node->hops <= 98) { - /* Only send PC24 if the user did go away for the first - time. Changing the away string doesn"t affect the PC. */ - pc_sendall(l, "PC24^%s^0^%s^\n", call, hops2pcstr(pc_hops)); - } + + link_useraway(u); u->here = 0; u->away_time = time(NULL); user_useraway(u); @@ -221,14 +222,14 @@ * Add an user */ -void net_adduser(struct nuser_t *u) +void net_adduser(struct nuser_t *nu) { int b; struct nuser_t *p, *n; char s[256]; - p = u; - sprintf(s, "PC16^%s", u->node->call); + p = nu; + sprintf(s, "PC16^%s", nu->node->call); b = 0; while (p) { @@ -260,7 +261,7 @@ sprintf(s + strlen(s), "^%s^\n", hops2pcstr(pc_hops)); if (pc_hops <= 98) - pc_sendall(u->node->via, (void *) s); /* !BUG! u might be freed! */ + pc_sendall(nu->node->via, (void *) s); /* !BUG! u might be freed! */ } /* @@ -294,19 +295,18 @@ * Remove a cluster user */ -void net_deluser(struct link_t *l, struct nuser_t *u) +void net_deluser(struct link_t *l, struct nuser_t *nu) { - u->time = time(NULL); - user_userdel(u); + nu->time = time(NULL); + user_userdel(nu); if (l) - log(L_NUSER, "%s@%s logout", u->call, u->node->call); - - if (pc_hops <= 98) - pc_sendall(l, "PC17^%s^%s^%s^\n", u->call, u->node->call, hops2pcstr(pc_hops)); + log(L_NUSER, "%s@%s logout", nu->call, nu->node->call); - u->node->users--; - free_nuser(u); + link_userdel(nu); + + nu->node->users--; + free_nuser(nu); } /* diff -urN clussed-19981214/net_user.h clussed-19981221/net_user.h --- clussed-19981214/net_user.h Mon Dec 29 23:40:19 1997 +++ clussed-19981221/net_user.h Sun Dec 20 18:08:27 1998 @@ -1,6 +1,6 @@ #ifndef NET_USER_H -#define NET_USER_H 1 +#define NET_USER_H #include #include "network.h" @@ -17,8 +17,8 @@ /* User list handling */ void free_nusersn(struct node_t *n); -extern void net_adduser(struct nuser_t *n); -extern void net_deluser(struct link_t *l, struct nuser_t *n); +extern void net_adduser(struct nuser_t *nu); +extern void net_deluser(struct link_t *l, struct nuser_t *nu); extern struct nuser_t *nuser_login(struct link_t *froml, call_t *call, struct node_t *node, int here); extern void nuser_logout(struct link_t *l, call_t *call, @@ -31,7 +31,7 @@ extern void net_here(struct link_t *forml, call_t *call); /* User here */ extern void net_away(struct link_t *froml, call_t *call, char *reason); /* User away */ -extern void net_userdata(struct nuser_t *n, struct link_t *froml, +extern void net_userdata(struct nuser_t *nu, struct link_t *froml, call_t *usercall, int type, char *data); /* User data */ diff -urN clussed-19981214/network.c clussed-19981221/network.c --- clussed-19981214/network.c Sun Dec 13 23:17:19 1998 +++ clussed-19981221/network.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,10 @@ +/* + * network.c + * + * the main workhorse of the cluster networking code + */ + #include #include #include @@ -269,15 +275,15 @@ void init_link_script_end(struct link_t *l, int res) { - log(L_DEBUG, "init_link_script_end(): %s: %d", l->call, res); +// log(L_DEBUG, "init_link_script_end(): %s: %d", l->call, res); - if (res != LJ_SUCCESS) + if (res == LJ_SUCCESS) { + l->sock->eolmode = eol_text; + l->sock->in_handler = pc_handler; + l->sock->disc_handler = pc_disc_handler; + } else link_logout(l->sock); - l->sock->eolmode = eol_text; - l->sock->in_handler = pc_handler; - l->sock->disc_handler = pc_disc_handler; - return; } @@ -296,6 +302,7 @@ l->state = ls_init; l->retry_timer = 0; l->tries++; + l->sock->link = l; } } @@ -374,6 +381,7 @@ struct link_t *l; l = sock->link; + if (l->state != ls_held) { if (l->state != ls_init) { log(L_LINK, "Link to %s failed (%s).", @@ -527,7 +535,7 @@ struct talk_t nt; if (strcmp(t->fromcall, (char *)&clucall)) { - log(L_TALK, "Talk %s > %s: %s", t->fromcall, t->tocall, t->message); + log(L_TALK, "Talk: %s > %s: %s", t->fromcall, t->tocall, t->message); set_homenode(NULL, &t->fromcall, &t->fromnodec, 2); } diff -urN clussed-19981214/network.h clussed-19981221/network.h --- clussed-19981214/network.h Sun Dec 13 22:27:39 1998 +++ clussed-19981221/network.h Sun Dec 20 18:08:27 1998 @@ -1,6 +1,6 @@ #ifndef NETWORK_H -#define NETWORK_H 1 +#define NETWORK_H #include diff -urN clussed-19981214/telnet.c clussed-19981221/telnet.c --- clussed-19981214/telnet.c Fri Jan 2 20:17:15 1998 +++ clussed-19981221/telnet.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,10 @@ +/* + * telnet.c + * + * telnet option negotiation + */ + #include #include "telnet.h" diff -urN clussed-19981214/timer.c clussed-19981221/timer.c --- clussed-19981214/timer.c Sun Jan 4 00:43:53 1998 +++ clussed-19981221/timer.c Sun Dec 20 18:08:27 1998 @@ -1,4 +1,10 @@ +/* + * timer.c + * + * not-so-accurate timer function for timed function calling + */ + #include #include #include diff -urN clussed-19981214/version.h clussed-19981221/version.h --- clussed-19981214/version.h Mon Dec 29 00:36:57 1997 +++ clussed-19981221/version.h Sun Dec 20 18:08:27 1998 @@ -1,6 +1,6 @@ #ifndef VERSION_H -#define VERSION_H 1 +#define VERSION_H #include "compile.h"