diff -urN clussed-19981221/CHANGELOG clussed-19981224/CHANGELOG --- clussed-19981221/CHANGELOG Mon Dec 21 19:40:06 1998 +++ clussed-19981224/CHANGELOG Thu Dec 24 17:59:22 1998 @@ -19,3 +19,23 @@ Added short comments in the beginning of (mostly) all c files. Added 'make snap' for making source snapshots. lazy me +Thu Dec 24 17:59:06 EET 1998 + + Added cmd_usercfg.c, containing the Name command. Added name and + qth fields in luserf_t, luser.db format changed. + Made f_nuser.c use the db module to actually store data. + Made outgoing AX.25 and NET/ROM connections work. + Made linker grok the failure trigger strings in connection scripts. + Replaced libax25 with version from a loopback-patched utils set. + Added command line parsing (getopt()) in config.c, currently only + for -b handling. Made file names and paths variables + instead of defines, so that they can be changed at run-time. + Moved the run-time environment in the base/ subdirectory. Debugging + runs shall be done with -b base. + Made it compile and work on a system without either AX.25, NETROM + or INET support (hm, probably won't compile on a system without + AF_INET related header files, but at least you can disable TCP + connections support for political correctness or security). + The #defines are in csock.h. + What a great way to spend christmas eve? + diff -urN clussed-19981221/INSTALL clussed-19981224/INSTALL --- clussed-19981221/INSTALL Sun Dec 20 18:08:27 1998 +++ clussed-19981224/INSTALL Thu Dec 24 18:00:18 1998 @@ -1,3 +1,5 @@ - Installation of clussed requires kernel ax.25, net/rom and tcp sockets -support. zlib and gdbm libraries are also a must. + Installation of clussed requires zlib and gdbm libraries. If you wish +clussed to be able to network and/or handle user connections, you also need +kernel AX.25, NET/ROM or TCP sockets support. + diff -urN clussed-19981221/Makefile clussed-19981224/Makefile --- clussed-19981221/Makefile Mon Dec 21 19:13:54 1998 +++ clussed-19981224/Makefile Thu Dec 24 16:10:13 1998 @@ -60,7 +60,7 @@ command.o \ login.o luser.o \ cluster.o help.o \ - cmd_cluster.o cmd_sys.o cmd_net.o \ + cmd_cluster.o cmd_sys.o cmd_net.o cmd_usercfg.o \ network.o net_link.o net_user.o net_ping.o net_rdb.o net_pc.o \ linker.o ui.o \ cfile.o f_dx.o f_ann.o f_wwv.o f_luser.o f_nuser.o f_last.o mid.o \ @@ -83,15 +83,15 @@ 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 + log.h csock.h cstring.h hmalloc.h cfg_iface.o: cfg_iface.h cfg_iface.c csock.h log.h hmalloc.h cstring.h \ af_inet.h af_ax25.h af_netrom.h cfg_links.o: cfg_links.h cfg_links.c network.h hmalloc.h log.h -af_inet.o: af_inet.h af_inet.c csock.h log.h hmalloc.h -af_ax25.o: af_ax25.h af_ax25.c csock.h log.h hmalloc.h +af_inet.o: af_inet.h af_inet.c csock.h log.h hmalloc.h config.h +af_ax25.o: af_ax25.h af_ax25.c csock.h log.h hmalloc.h config.h af_netrom.o: af_netrom.h af_netrom.c csock.h log.h hmalloc.h csock.o: csock.h csock.c af_inet.h af_ax25.h af_netrom.h \ - log.h timer.h luser.h hmalloc.h telnet.h login.h + log.h timer.h luser.h hmalloc.h telnet.h login.h cstring.h telnet.o: telnet.h telnet.c csock.h login.o: login.h login.c luser.h version.h config.h cstring.h csock.h \ telnet.h @@ -100,12 +100,13 @@ luser.o: luser.h luser.c config.h log.h hmalloc.h version.h csock.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 + cmd_net.h cmd_usercfg.h network.h net_ping.h command.o: command.h command.c csock.h cfgfile.h cmd_sys.o: cmd_sys.h cmd_sys.c csock.h version.h hmalloc.h cmd_cluster.o: cmd_cluster.h cmd_cluster.c csock.h hmalloc.h network.h \ cstring.h config.h net_user.h cfgfile.h cmd_net.o: cmd_net.h cmd_net.c csock.h network.h net_user.h +cmd_usercfg.o: cmd_usercfg.h cmd_usercfg.c csock.h luser.h cfgfile.h f_luser.h help.o: help.h help.c csock.h network.o: network.h network.c net_ping.h net_link.h net_pc.h net_user.h \ net_rdb.h mid.h ctime.h config.h ctypes.h luser.h log.h \ @@ -120,7 +121,7 @@ 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 +cfile.o: cfile.h cfile.c f_luser.h f_nuser.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 diff -urN clussed-19981221/README clussed-19981224/README --- clussed-19981221/README Sun Dec 20 18:08:27 1998 +++ clussed-19981224/README Tue Dec 22 03:43:00 1998 @@ -7,7 +7,7 @@ no, make that 2001. don't ask any questions yet. Code contributions are welcome. - Read the CHANGES file for information on progress. + Read the CHANGELOG file for information on progress. - Hessu diff -urN clussed-19981221/Snapshot.sh clussed-19981224/Snapshot.sh --- clussed-19981221/Snapshot.sh Mon Dec 21 19:22:43 1998 +++ clussed-19981224/Snapshot.sh Thu Dec 24 17:56:31 1998 @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash DATE=`date +%Y%m%d` CURRTGZ="clussed-$DATE.tar.gz" @@ -7,11 +7,18 @@ echo "Snapshot.sh: Creating snapshot dated $DATE" cd .. -rm -f clussed-$DATE.tar.gz +if [ -f $CURRTGZ ] ; then + rm -f $CURRTGZ +fi -PREVTGZ=`ls | grep clussed-*.tar.gz | sort | tail -1` +PREVTGZ=`ls clussed-*.tar.gz | sort | tail -1` echo "Previous found in $PREVTGZ" +if [ ! -f $PREVTGZ ] ; then + echo "Previous not found" + exit +fi + echo "Creating $CURRTGZ ..." mv clussed clussed-$DATE tar cfz $CURRTGZ clussed-$DATE @@ -30,6 +37,4 @@ rm -rf $SNAPDIR echo "Patch in patch-$DATE.gz" - - diff -urN clussed-19981221/af_ax25.c clussed-19981224/af_ax25.c --- clussed-19981221/af_ax25.c Sun Dec 20 18:08:27 1998 +++ clussed-19981224/af_ax25.c Thu Dec 24 17:55:05 1998 @@ -14,19 +14,22 @@ #include #include +#include "hmalloc.h" + +#include "csock.h" +#include "af_ax25.h" +#include "log.h" +#include "config.h" + +#ifdef HAVE_AX25 + #include #include #include -#include "hmalloc.h" - #include "axutils.h" #include "axconfig.h" -#include "csock.h" -#include "af_ax25.h" -#include "log.h" - /* * Bind() an ax.25 interface and listen() on it */ @@ -125,3 +128,47 @@ sock_login(s); } + +/* + * Prepare an outgoing ax.25 connection + */ + +int ax25_prepare_outgoing(struct csock_t *s, int argc, char **argv) +{ + char path[20]; + char *portcall; + + if (argc < 2) + log(L_ERR, "ax25_prepare_outgoing(): Not enough arguments, need at least port and destination (digis optional)"); + + portcall = ax25_config_get_addr(argv[0]); + if (!portcall) { + log(L_ERR, "ax25_prepare_outgoing(): Invalid port: %s", argv[0]); + return -1; + } + + sprintf(path, "%s %s", (char *)clucall, portcall); + convert_call(path, &s->sockaddr.ax25); + s->sockaddr.ax25.fsa_ax25.sax25_family = AF_AX25; + s->addrlen = sizeof(struct full_sockaddr_ax25); + + if (bind(s->fd, (struct sockaddr *)&s->sockaddr, s->addrlen) == -1) { + log(L_ERR, "ax25_prepare_outgoing(): AF_AX25: bind(): %s", strerror(errno)); + return -1; + } + + if (convert_call_arglist(&argv[1], &s->sockaddr.ax25) == -1) { + log(L_ERR, "convert_call_arglist failed: %s", strerror(errno)); + return -1; + } + + s->call = strdup(argv[1]); + s->port = strdup(argv[0]); + s->eoltype = ax25_eol; + s->eol = AX25_EOL; + + return 0; +} + +#endif + diff -urN clussed-19981221/af_ax25.h clussed-19981224/af_ax25.h --- clussed-19981221/af_ax25.h Sun Dec 20 18:08:27 1998 +++ clussed-19981224/af_ax25.h Tue Dec 22 02:32:03 1998 @@ -4,7 +4,10 @@ #include "csock.h" -void ax25_listens(void); -void ax25_accept(struct listenq_t *lq); +#ifdef HAVE_AX25 +extern void ax25_listens(void); +extern void ax25_accept(struct listenq_t *lq); +extern int ax25_prepare_outgoing(struct csock_t *s, int argc, char **argv); +#endif #endif diff -urN clussed-19981221/af_inet.c clussed-19981224/af_inet.c --- clussed-19981221/af_inet.c Sun Dec 20 18:08:27 1998 +++ clussed-19981224/af_inet.c Tue Dec 22 02:31:36 1998 @@ -64,6 +64,8 @@ return s; } +#ifdef HAVE_INET + /* * Open up a TCP listening socket */ @@ -162,3 +164,4 @@ sock_login(s); } +#endif diff -urN clussed-19981221/af_inet.h clussed-19981224/af_inet.h --- clussed-19981221/af_inet.h Sun Dec 20 18:08:27 1998 +++ clussed-19981224/af_inet.h Tue Dec 22 02:31:16 1998 @@ -4,10 +4,12 @@ #include "csock.h" -char *aptoa(struct in_addr sin_addr, int sin_port); -char *h_strerror(int i); +extern char *aptoa(struct in_addr sin_addr, int sin_port); +extern char *h_strerror(int i); -void tcp_listens(void); -void tcp_accept(struct listenq_t *lq); +#ifdef HAVE_INET +extern void tcp_listens(void); +extern void tcp_accept(struct listenq_t *lq); +#endif #endif diff -urN clussed-19981221/af_netrom.c clussed-19981224/af_netrom.c --- clussed-19981221/af_netrom.c Sun Dec 20 18:08:27 1998 +++ clussed-19981224/af_netrom.c Thu Dec 24 17:55:27 1998 @@ -14,18 +14,22 @@ #include #include +#include "hmalloc.h" + +#include "csock.h" +#include "af_netrom.h" +#include "log.h" +#include "config.h" + +#ifdef HAVE_NETROM + #include #include #include -#include "hmalloc.h" - #include "axutils.h" #include "nrconfig.h" - -#include "csock.h" -#include "af_netrom.h" -#include "log.h" +#include "procutils.h" /* * Bind() a netrom interface and listen() on it @@ -125,3 +129,55 @@ sock_login(s); } + +/* + * Prepare an outgoing NET/ROM connection + */ + +int netrom_prepare_outgoing(struct csock_t *s, int argc, char **argv) +{ + char path[20]; + char *portcall; + struct proc_nr_nodes *np; + + if (argc < 2) + log(L_ERR, "netrom_prepare_outgoing(): Not enough arguments, need at least port and destination"); + + portcall = nr_config_get_addr(argv[0]); + if (!portcall) { + log(L_ERR, "netrom_prepare_outgoing(): Invalid port: %s", argv[0]); + return -1; + } + + /* Why on earth is this different from ax.25 ????? */ + sprintf(path, "%s %s", portcall, (char *)clucall); + convert_call(path, &s->sockaddr.ax25); + s->sockaddr.ax25.fsa_ax25.sax25_family = AF_NETROM; + s->addrlen = sizeof(struct full_sockaddr_ax25); + + if (bind(s->fd, (struct sockaddr *)&s->sockaddr, s->addrlen) == -1) { + log(L_ERR, "netrom_prepare_outgoing(): AF_NETROM: bind(): %s", strerror(errno)); + return -1; + } + + if ((np = find_node(argv[1], NULL)) == NULL) { + log(L_ERR, "netrom_prepare_outgoing(): No such node: %s", argv[1]); + return -1; + } + + if (convert_call(np->call, &s->sockaddr.ax25) == -1) { + log(L_ERR, "convert_call failed: %s", strerror(errno)); + return -1; + } + s->sockaddr.ax25.fsa_ax25.sax25_family = AF_NETROM; + + s->call = strdup(argv[1]); + s->port = strdup(argv[0]); + s->eoltype = ax25_eol; + s->eol = AX25_EOL; + + return 0; +} + +#endif + diff -urN clussed-19981221/af_netrom.h clussed-19981224/af_netrom.h --- clussed-19981221/af_netrom.h Sun Dec 20 18:08:27 1998 +++ clussed-19981224/af_netrom.h Tue Dec 22 02:49:02 1998 @@ -4,7 +4,10 @@ #include "csock.h" -void netrom_listens(void); -void netrom_accept(struct listenq_t *lq); +#ifdef HAVE_NETROM +extern void netrom_listens(void); +extern void netrom_accept(struct listenq_t *lq); +extern int netrom_prepare_outgoing(struct csock_t *s, int argc, char **argv); +#endif #endif Binary files clussed-19981221/base/data/luser.db and clussed-19981224/base/data/luser.db differ Binary files clussed-19981221/base/data/nuser.db and clussed-19981224/base/data/nuser.db differ diff -urN clussed-19981221/base/etc/clussed.conf clussed-19981224/base/etc/clussed.conf --- clussed-19981221/base/etc/clussed.conf Thu Jan 1 02:00:00 1970 +++ clussed-19981224/base/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-19981221/base/etc/interface.conf clussed-19981224/base/etc/interface.conf --- clussed-19981221/base/etc/interface.conf Thu Jan 1 02:00:00 1970 +++ clussed-19981224/base/etc/interface.conf Tue Dec 22 02:42:55 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-19981221/base/etc/links.conf clussed-19981224/base/etc/links.conf --- clussed-19981221/base/etc/links.conf Thu Jan 1 02:00:00 1970 +++ clussed-19981224/base/etc/links.conf Tue Dec 22 01:50:06 1998 @@ -0,0 +1,13 @@ + +#link oh1rbi-1 +#protocol pc +#script scripts/oh1rbi.con + +link oh7lzb-8 +protocol pc +script scripts/oh7lzb-8.con + +#link oh7rba-1 +#protocol pc +#script scripts/oh7rba.con + diff -urN clussed-19981221/base/scripts/oh1rbi.con clussed-19981224/base/scripts/oh1rbi.con --- clussed-19981221/base/scripts/oh1rbi.con Thu Jan 1 02:00:00 1970 +++ clussed-19981224/base/scripts/oh1rbi.con Sun Dec 20 18:08:29 1998 @@ -0,0 +1,21 @@ + +# +# Connection script for Clusse 0.40 +# + +telnet localhost 3694 +# ax25 lo0 oh7lzb-2 +# netrom nrclu oh7lzb-2 + +#s "c lo0 oh7lzb-2" +#r "connected" "disc" "fail" "err" + +r "login:" +s "oh7lzb-1" + +r "Welcome" +s "i" + +r "LinuxNode" +s "b" + diff -urN clussed-19981221/base/scripts/oh7lzb-8.con clussed-19981224/base/scripts/oh7lzb-8.con --- clussed-19981221/base/scripts/oh7lzb-8.con Thu Jan 1 02:00:00 1970 +++ clussed-19981224/base/scripts/oh7lzb-8.con Thu Dec 24 15:51:14 1998 @@ -0,0 +1,21 @@ + +# +# Connection script for Clusse 0.40 +# + +#telnet localhost 3694 +#ax25 lo0 oh7lzb-2 +netrom nrcl oh7lzb-2 + +#s "c lo0 oh7lzb-2" +#r "connected" "disc" "fail" "err" + +#r "login:" +#s "oh7lzb-1" + +r "Welcome" +s "i" + +r "LinuxNode" +s "b" + diff -urN clussed-19981221/base/scripts/oh7lzb-8.con~ clussed-19981224/base/scripts/oh7lzb-8.con~ --- clussed-19981221/base/scripts/oh7lzb-8.con~ Thu Jan 1 02:00:00 1970 +++ clussed-19981224/base/scripts/oh7lzb-8.con~ Thu Dec 24 15:51:08 1998 @@ -0,0 +1,21 @@ + +# +# Connection script for Clusse 0.40 +# + +#telnet localhost 3694 +#ax25 lo0 oh7lzb-2 +netrom nrcl oh7lzb-2 + +#s "c lo0 oh7lzb-2" +#r "connected" "disc" "fail" "err" + +#r "login:" +#s "oh7lzb-1" + +#r "Welcome" +#s "i" + +r "LinuxNode" +s "b" + diff -urN clussed-19981221/cfg_iface.c clussed-19981224/cfg_iface.c --- clussed-19981221/cfg_iface.c Sun Dec 20 18:08:27 1998 +++ clussed-19981224/cfg_iface.c Tue Dec 22 02:39:50 1998 @@ -12,10 +12,6 @@ #include #include -#include "axutils.h" -#include "axconfig.h" -#include "nrconfig.h" - #include "cfg_iface.h" #include "af_inet.h" #include "af_ax25.h" @@ -25,8 +21,17 @@ #include "hmalloc.h" #include "cstring.h" +#ifdef HAVE_AX25 +#include "axutils.h" +#include "axconfig.h" int ax25_ports_loaded = 0; +#endif + +#ifdef HAVE_NETROM +#include "axutils.h" +#include "nrconfig.h" int netrom_ports_loaded = 0; +#endif /* * Process port options @@ -51,7 +56,8 @@ /* * TcpListen */ - + +#ifdef HAVE_INET int do_tcplisten(struct listenq_t **dest, int argc, char **argv) { struct listenq_t *p; @@ -91,11 +97,13 @@ return listen_options(p, argc - 3, &argv[3]); } +#endif /* * AX25Listen */ +#ifdef HAVE_AX25 int do_ax25listen(struct listenq_t **dest, int argc, char **argv) { struct listenq_t *p; @@ -154,11 +162,13 @@ return listen_options(p, argc - 2, &argv[2]); } +#endif /* * NetromListen */ +#ifdef HAVE_NETROM int do_netromlisten(struct listenq_t **dest, int argc, char **argv) { struct listenq_t *p; @@ -200,4 +210,5 @@ return listen_options(p, argc - 2, &argv[2]); } +#endif diff -urN clussed-19981221/cfg_iface.h clussed-19981224/cfg_iface.h --- clussed-19981221/cfg_iface.h Sun Dec 20 18:08:27 1998 +++ clussed-19981224/cfg_iface.h Tue Dec 22 02:36:25 1998 @@ -4,8 +4,14 @@ #include "csock.h" +#ifdef HAVE_INET extern int do_tcplisten(struct listenq_t **dest, int argc, char **argv); +#endif +#ifdef HAVE_AX25 extern int do_ax25listen(struct listenq_t **dest, int argc, char **argv); +#endif +#ifdef HAVE_NETROM extern int do_netromlisten(struct listenq_t **dest, int argc, char **argv); +#endif #endif diff -urN clussed-19981221/cfile.c clussed-19981224/cfile.c --- clussed-19981221/cfile.c Sun Dec 20 18:08:27 1998 +++ clussed-19981224/cfile.c Mon Dec 21 21:03:12 1998 @@ -1,13 +1,23 @@ +/* + * cfile.c + * + * File modules init/close, and random file related functions that + * don't fit anywhere else + */ + #include "cfile.h" #include "f_luser.h" +#include "f_nuser.h" void files_init(void) { open_luserf(); + open_nuserf(); } void files_close(void) { close_luserf(); + close_nuserf(); } diff -urN clussed-19981221/cluster.c clussed-19981224/cluster.c --- clussed-19981221/cluster.c Sun Dec 20 18:08:27 1998 +++ clussed-19981224/cluster.c Mon Dec 21 20:24:08 1998 @@ -12,6 +12,7 @@ #include "cmd_sys.h" #include "cmd_cluster.h" #include "cmd_net.h" +#include "cmd_usercfg.h" #include "network.h" #include "net_ping.h" @@ -24,6 +25,7 @@ { "help", cmd_help }, { "memory", cmd_memory }, { "nodes", cmd_nodes }, + { "name", cmd_name }, { "sockets", cmd_sockets }, { "talk", cmd_talk }, { "treply", cmd_treply }, diff -urN clussed-19981221/cmd_usercfg.c clussed-19981224/cmd_usercfg.c --- clussed-19981221/cmd_usercfg.c Thu Jan 1 02:00:00 1970 +++ clussed-19981224/cmd_usercfg.c Mon Dec 21 20:39:09 1998 @@ -0,0 +1,32 @@ + +/* + * cmd_usercfg.c + * + * Per-user configuration commands + */ + +#include + +#include "csock.h" +#include "cmd_usercfg.h" +#include "luser.h" +#include "cfgfile.h" +#include "f_luser.h" + +int cmd_name(struct csock_t *s, int argc, char **argv) +{ + if (argc > 1) { + strncpy(s->lu->f->name, argstr(1, argc, argv), sizeof(s->lu->f->name)); + s->lu->f->name[sizeof(s->lu->f->name)-1] = '\0'; + csputs(s, "Thank you. "); + write_luserf(s->lu->f); + } + + if (*s->lu->f->name) + csprintf(s, "Your name is set to: %s\n", s->lu->f->name); + else + csputs(s, "Your name is not set.\n"); + + return 0; +} + diff -urN clussed-19981221/cmd_usercfg.h clussed-19981224/cmd_usercfg.h --- clussed-19981221/cmd_usercfg.h Thu Jan 1 02:00:00 1970 +++ clussed-19981224/cmd_usercfg.h Mon Dec 21 20:09:00 1998 @@ -0,0 +1,9 @@ + +#ifndef CMD_USERCFG_H +#define CMD_USERCFG_H + +#include "csock.h" + +extern int cmd_name(struct csock_t *s, int argc, char **argv); + +#endif diff -urN clussed-19981221/config.c clussed-19981224/config.c --- clussed-19981221/config.c Sun Dec 20 18:08:27 1998 +++ clussed-19981224/config.c Thu Dec 24 16:50:59 1998 @@ -2,10 +2,12 @@ /* * config.c * - * configuration file reading and command lists + * command line parsing, configuration file reading and command lists */ #include +#include +#include #include "config.h" #include "ctypes.h" @@ -15,6 +17,9 @@ #include "log.h" #include "csock.h" #include "cstring.h" +#include "hmalloc.h" + +#define HELP_STRING "Usage: clussed [-b ]" /* * Configuration file commands @@ -31,9 +36,15 @@ { "sysopname", _CFUNC_ do_string, &sysop_name }, { "loglevel", _CFUNC_ do_int, &log_level }, { "logdest", _CFUNC_ do_int, &log_dest }, +#ifdef HAVE_INET { "tcplisten", _CFUNC_ do_tcplisten, &listenq }, +#endif +#ifdef HAVE_AX25 { "ax25listen", _CFUNC_ do_ax25listen, &listenq }, +#endif +#ifdef HAVE_NETROM { "netromlisten", _CFUNC_ do_netromlisten, &listenq }, +#endif { NULL, NULL, NULL } }; @@ -46,13 +57,79 @@ { NULL, NULL, NULL } }; -call_t *clucall; -char *hostname; +char *base_d = NULL; + +char *etc_d = NULL; +char *config_f = NULL; +char *intconfig_f = NULL; +char *links_f = NULL; + +char *data_d = NULL; +char *luser_f = NULL; +char *nuser_f = NULL; + +call_t *clucall = NULL; +char *hostname = NULL; + +call_t *sysop_call = NULL; +char *sysop_name = NULL; +char *qth = NULL; +char *qth_loc = NULL; + +/* + * Parse command line arguments and derive directory and file names + */ -call_t *sysop_call; -char *sysop_name; -char *qth; -char *qth_loc; +void parse_cmdl(int argc, char **argv) +{ + char s[PATHLEN+1]; + char c; + + s[PATHLEN] = '\0'; + + while ((c = getopt(argc, argv, "b:")) != -1) { + switch (c) { + case 'b': + base_d = hstrdup(optarg); + break;; + default: + fprintf(stderr, "%s <%s@%s>\n%s\n", SOFT_STRING, COMPILE_BY, COMPILE_HOST, HELP_STRING); + exit(1); + } + } + + if (base_d) { + if (base_d[strlen(base_d)-1] != '/') { + base_d = hrealloc(base_d, strlen(base_d) + 1); + strcat(base_d, "/"); + } + } else { + snprintf(s, PATHLEN, "./"); + base_d = hstrdup(s); + } + + if (!etc_d) { + snprintf(s, PATHLEN, "%s%s", base_d, ETC_D_N); + etc_d = hstrdup(s); + } + + if (!data_d) { + snprintf(s, PATHLEN, "%s%s", base_d, DATA_D_N); + data_d = hstrdup(s); + } + + snprintf(s, PATHLEN, "%s%s", etc_d, CONFIG_F_N); + config_f = hstrdup(s); + snprintf(s, PATHLEN, "%s%s", etc_d, INTCONFIG_F_N); + intconfig_f = hstrdup(s); + snprintf(s, PATHLEN, "%s%s", etc_d, LINKS_F_N); + links_f = hstrdup(s); + + snprintf(s, PATHLEN, "%s%s", data_d, LUSER_F_N); + luser_f = hstrdup(s); + snprintf(s, PATHLEN, "%s%s", data_d, NUSER_F_N); + nuser_f = hstrdup(s); +} /* * Read configuration files @@ -62,9 +139,9 @@ { int i; - if (read_cfgfile(CONFIG_F, cfg_cmds)) + if (read_cfgfile(config_f, cfg_cmds)) exit(1); - if ((i = read_cfgfile(INTCONFIG_F, cfg_cmds))) { + if ((i = read_cfgfile(intconfig_f, cfg_cmds))) { if (i == -2) exit(0); log(L_ERR, "Continuing with no interfaces configured."); @@ -77,9 +154,10 @@ } hstrupr((char *)clucall); - if ((i = 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-19981221/config.h clussed-19981224/config.h --- clussed-19981221/config.h Sun Dec 20 18:08:27 1998 +++ clussed-19981224/config.h Thu Dec 24 16:51:44 1998 @@ -4,11 +4,22 @@ #include "ctypes.h" -#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 char *base_d; +extern char *etc_d; +extern char *data_d; +extern char *config_f; +extern char *intconfig_f; +extern char *links_f; +extern char *luser_f; +extern char *nuser_f; + +#define ETC_D_N "etc/" +#define CONFIG_F_N "clussed.conf" +#define INTCONFIG_F_N "interface.conf" +#define LINKS_F_N "links.conf" +#define DATA_D_N "data/" +#define LUSER_F_N "luser.db" +#define NUSER_F_N "nuser.db" extern call_t *clucall; extern char *hostname; @@ -18,6 +29,7 @@ extern char *qth; extern char *qth_loc; +extern void parse_cmdl(int argc, char **argv); extern void read_config(void); #endif diff -urN clussed-19981221/csock.c clussed-19981224/csock.c --- clussed-19981221/csock.c Mon Dec 21 18:27:30 1998 +++ clussed-19981224/csock.c Tue Dec 22 12:50:29 1998 @@ -32,6 +32,7 @@ #include "hmalloc.h" #include "telnet.h" #include "login.h" +#include "cstring.h" #define CS_FLUSH 1 #define CS_NOFLUSH 0 @@ -228,9 +229,12 @@ } hfree(s->ibuf.buf); hfree(s->obuf.buf); - hfree(s->call); - hfree(s->node); - hfree(s->port); + if (s->call) + hfree(s->call); + if (s->node) + hfree(s->node); + if (s->port) + hfree(s->port); hfree(s); } @@ -242,13 +246,18 @@ { struct csock_t *s = NULL; +#ifdef HAVE_INET struct hostent *hp; struct servent *sp; struct in_addr inaddr; - int fd; +#endif - switch (af_type) { + int i = 0; + int fd = -1; + switch (af_type) { + +#ifdef HAVE_INET case AF_INET: hp = NULL; if (inet_aton(argv[0], &inaddr) != 0) @@ -260,15 +269,13 @@ goto trouble; } - if ((fd = socket(af_type, SOCK_STREAM, 0)) < 0) { + if ((fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { log(L_ERR, "sock_connect(): socket(): Could not get an AF_INET socket: %s", strerror(errno)); goto trouble; } - if (!(s = sock_alloc(fd, af_type, DEF_BUFLEN_IN, 80, 0))) { - close(fd); + if (!(s = sock_alloc(fd, af_type, DEF_BUFLEN_IN, 80, 0))) goto trouble; - } memset(&s->sockaddr, 0, sizeof(s->sockaddr)); s->addrlen = sizeof(struct in_addr); @@ -288,7 +295,6 @@ } if (s->sockaddr.inet.sin_port == 0) { log(L_ERR, "Unknown service %s", argv[1]); - close(s->fd); goto trouble; } s->node = hstrdup(hp->h_name); @@ -301,8 +307,48 @@ s->eoltype = inet_eol; s->eol = INET_EOL; break; +#endif + +#ifdef HAVE_AX25 + case AF_AX25: + if ((fd = socket(AF_AX25, SOCK_SEQPACKET, 0)) < 0) { + log(L_ERR, "sock_connect(): socket(): Could not get an AF_AX25 socket: %s", strerror(errno)); + goto trouble; + } + + if (!(s = sock_alloc(fd, af_type, DEF_BUFLEN_AX, 80, 0))) + goto trouble; + + for (i = 1; i < argc; i++) + hstrupr(argv[i]); + + if (ax25_prepare_outgoing(s, argc, argv)) + goto trouble; + + break; +#endif + +#ifdef HAVE_NETROM + case AF_NETROM: + if ((fd = socket(AF_NETROM, SOCK_SEQPACKET, 0)) < 0) { + log(L_ERR, "sock_connect(): socket(): Could not get an AF_NETROM socket: %s", strerror(errno)); + goto trouble; + } + + if (!(s = sock_alloc(fd, af_type, DEF_BUFLEN_NR, 80, 0))) + goto trouble; + + for (i = 1; i < argc; i++) + hstrupr(argv[i]); + + if (netrom_prepare_outgoing(s, argc, argv)) + goto trouble; + + break; +#endif + default: - cs_errno = EPROTONOSUPPORT; + log(L_ERR, "Socket: sock_connect() called for unknown af_type"); goto trouble; } @@ -330,6 +376,8 @@ return s; trouble: + if (fd >= 0) + close(fd); if (s) sock_close(s); @@ -650,8 +698,11 @@ in the buffer */ } } else { - if (!(*s->in_handler)(s, s->ibuf.buf, s->ibuf.pos)) + i = (*s->in_handler)(s, s->ibuf.buf, s->ibuf.pos); + if (i == 0) s->ibuf.pos = 0; + else + return i; } return 0; @@ -903,9 +954,15 @@ FD_ZERO(&writefds); set_timer(0, 1, (void *)&csflush_all, NULL); +#ifdef HAVE_INET tcp_listens(); +#endif +#ifdef HAVE_AX25 ax25_listens(); +#endif +#ifdef HAVE_NETROM netrom_listens(); +#endif } /* diff -urN clussed-19981221/csock.h clussed-19981224/csock.h --- clussed-19981221/csock.h Sun Dec 20 18:08:27 1998 +++ clussed-19981224/csock.h Thu Dec 24 16:59:52 1998 @@ -2,6 +2,11 @@ #ifndef CSOCK_H #define CSOCK_H +#define HAVE_INET +#define HAVE_AX25 +#define HAVE_NETROM +#undef HAVE_ROSE + #include #include #include @@ -77,10 +82,18 @@ /* Who, where */ int af_type; - union { - struct full_sockaddr_ax25 ax25; + union { +#ifdef HAVE_AX25 + struct full_sockaddr_ax25 ax25; +#elif HAVE_NETROM + struct full_sockaddr_ax25 ax25; +#endif +#ifdef HAVE_ROSE struct sockaddr_rose rose; +#endif +#ifdef HAVE_INET struct sockaddr_in inet; +#endif } sockaddr; int addrlen; char *call; Binary files clussed-19981221/data/luser.db and clussed-19981224/data/luser.db differ diff -urN clussed-19981221/db.c clussed-19981224/db.c --- clussed-19981221/db.c Sun Dec 20 18:08:27 1998 +++ clussed-19981224/db.c Thu Dec 24 15:57:46 1998 @@ -4,7 +4,7 @@ * * 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. + * gdbm with something else, some day, when need arises. SQL, anyone? 8-) */ #include diff -urN clussed-19981221/etc/clussed.conf clussed-19981224/etc/clussed.conf --- clussed-19981221/etc/clussed.conf Sun Dec 20 18:08:29 1998 +++ clussed-19981224/etc/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-19981221/etc/interface.conf clussed-19981224/etc/interface.conf --- clussed-19981221/etc/interface.conf Sun Dec 20 18:08:29 1998 +++ clussed-19981224/etc/interface.conf Thu Jan 1 02:00:00 1970 @@ -1,37 +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-19981221/etc/links.conf clussed-19981224/etc/links.conf --- clussed-19981221/etc/links.conf Sun Dec 20 18:08:29 1998 +++ clussed-19981224/etc/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-19981221/f_luser.c clussed-19981224/f_luser.c --- clussed-19981221/f_luser.c Sun Dec 20 18:08:27 1998 +++ clussed-19981224/f_luser.c Thu Dec 24 16:12:06 1998 @@ -6,21 +6,19 @@ #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 *read_luserf(call_t *call) { struct luserf_t *f; call_t tcall; datum key, content; - strcpy(tcall, call); + strcpy(tcall, (char *)call); truncssid(&tcall); key.dptr = (void *)&tcall; @@ -67,9 +65,9 @@ int open_luserf(void) { - luser_db = db_open(LUSER_F); + luser_db = db_open(luser_f); if (!luser_db) { - log(L_CRIT, "open_luserf(): db_open() failed for %s, abandon ship.", LUSER_F); + log(L_CRIT, "open_luserf(): db_open() failed for %s, abandon ship.", luser_f); exit(1); } return 0; diff -urN clussed-19981221/f_luser.h clussed-19981224/f_luser.h --- clussed-19981221/f_luser.h Sun Dec 20 18:08:27 1998 +++ clussed-19981224/f_luser.h Mon Dec 21 20:53:44 1998 @@ -4,7 +4,7 @@ #include "luser.h" -extern struct luserf_t *read_luserf(call_t call); +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); diff -urN clussed-19981221/f_nuser.c clussed-19981224/f_nuser.c --- clussed-19981221/f_nuser.c Sun Dec 20 18:08:27 1998 +++ clussed-19981224/f_nuser.c Thu Dec 24 16:13:02 1998 @@ -2,6 +2,11 @@ #include "f_nuser.h" #include "hmalloc.h" #include "log.h" +#include "db.h" +#include "config.h" +#include "cstring.h" + +struct db_t *nuser_db = NULL; /* * Get an entry from the network user file @@ -9,6 +14,27 @@ struct nuserf_t *read_nuserf(call_t *call) { + struct nuserf_t *f; + call_t tcall; + datum key, content; + + strcpy(tcall, (char *)call); + truncssid(&tcall); + + key.dptr = (void *)&tcall; + key.dsize = strlen(tcall); + + content = db_fetch(nuser_db, key); + if (content.dptr) { + if (content.dsize != sizeof(struct nuserf_t)) { + log(L_ERR, "read_nuserf(): OUCH, db entry of wrong size: %d != %d", content.dsize, sizeof(struct nuserf_t)); + hfree(content.dptr); + return NULL; + } + f = (struct nuserf_t *)content.dptr; + return f; + } + return NULL; } @@ -18,6 +44,43 @@ void write_nuserf(struct nuserf_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 nuserf_t); + + db_store(nuser_db, key, content); +} + +/* + * Open network user file + */ + +int open_nuserf(void) +{ + nuser_db = db_open(nuser_f); + if (!nuser_db) { + log(L_CRIT, "open_nuserf(): db_open() failed for %s, abandon ship.", nuser_f); + exit(1); + } + return 0; +} + +/* + * Close network user file + */ + +int close_nuserf(void) +{ + db_close(nuser_db); + return 0; } /* @@ -31,7 +94,7 @@ if (!valid_call(call)) return; - + if (!(fp = read_nuserf(call))) { fp = hmalloc(sizeof(struct nuserf_t)); strcpy(fp->call, (char *)call); diff -urN clussed-19981221/f_nuser.h clussed-19981224/f_nuser.h --- clussed-19981221/f_nuser.h Sun Dec 20 18:08:27 1998 +++ clussed-19981224/f_nuser.h Mon Dec 21 20:55:07 1998 @@ -17,9 +17,14 @@ 7 - Set manually by user or sysop */ time_t time; }; - + extern void set_user_data(struct nuser_t *nu, struct link_t* l, call_t *call, int type, char *value); extern void set_homenode(struct nuser_t *n, call_t *call, call_t *node, int q); + +extern struct nuserf_t *read_nuserf(call_t *call); +extern void write_nuserf(struct nuserf_t *f); +extern int open_nuserf(void); +extern int close_nuserf(void); #endif diff -urN clussed-19981221/help.c clussed-19981224/help.c --- clussed-19981221/help.c Sun Dec 20 18:08:27 1998 +++ clussed-19981224/help.c Tue Dec 22 12:48:22 1998 @@ -4,7 +4,7 @@ int cmd_help(struct csock_t *s, int argc, char **argv) { - csprintf(s, "No help yet...\n"); + csprintf(s, "Help is for wimps. Use the source, luke!\n"); return 0; } diff -urN clussed-19981221/lib/config.h clussed-19981224/lib/config.h --- clussed-19981221/lib/config.h Thu Jan 1 02:00:00 1970 +++ clussed-19981224/lib/config.h Tue Dec 22 03:09:39 1998 @@ -0,0 +1,127 @@ +/* + * This file is used to configure the locations of essential files required + * by ax25-utils. It is modified by the 'configure' script, but once created + * the file config.h may be edited by hand to fit in with non-standard + * systems. + */ + +#ifndef CONFIG_H +#define CONFIG_H + +/* + * Some global #defines for programmers to use for conditional compilation + */ +#define HAVEAX25 +#define HAVEROSE +#define HAVENETROM + + +/* + * The /proc filesystem entries + */ +#define PROC_AX25_FILE "/proc/net/ax25" +#define PROC_AX25_CALLS_FILE "/proc/net/ax25_calls" +#define PROC_AX25_ROUTE_FILE "/proc/net/ax25_route" + +#define PROC_NR_FILE "/proc/net/nr" +#define PROC_NR_NEIGH_FILE "/proc/net/nr_neigh" +#define PROC_NR_NODES_FILE "/proc/net/nr_nodes" + +#define PROC_RS_FILE "/proc/net/rose" +#define PROC_RS_NEIGH_FILE "/proc/net/rose_neigh" +#define PROC_RS_NODES_FILE "/proc/net/rose_nodes" +#define PROC_RS_ROUTES_FILE "/proc/net/rose_routes" + +#define PROC_IP_ROUTE_FILE "/proc/net/route" + +#define PROC_AX25_SYSCTL_DIR "/proc/sys/net/ax25" +#define PROC_NR_SYSCTL_DIR "/proc/sys/net/netrom" +#define PROC_RS_SYSCTL_DIR "/proc/sys/net/rose" + +/* + * THE configuration files + */ +#define CONF_AXPORTS_FILE "/etc/ax25/axports" +#define CONF_NRPORTS_FILE "/etc/ax25/nrports" +#define CONF_RSPORTS_FILE "/etc/ax25/rsports" + +/* + * ax25d specific + */ +#define CONF_AX25D_FILE "/etc/ax25/ax25d.conf" + +/* + * ax25ipd specific + */ +#define CONF_AX25IPD_FILE "/etc/ax25/ax25ipd.conf" + +/* + * ax25routed specific + */ +#define CONF_AX25ROUTED_FILE "/etc/ax25/ax25rtd.conf" +#define DATA_AX25ROUTED_CTL_SOCK "/var/ax25/ax25rtd/control" +#define DATA_AX25ROUTED_AXRT_FILE "/var/ax25/ax25rtd/ax25_route" +#define DATA_AX25ROUTED_IPRT_FILE "/var/ax25/ax25rtd/ip_route" + +/* + * axspawn specific + */ +#define CONF_AXSPAWN_FILE "/etc/ax25/axspawn.conf" +#define CONF_AXSPAWN_PROF_FILE "/etc/ax25/ax25.profile" +#define LOCK_AXSPAWN_FILE "/var/lock/axspawn" + +/* + * mheard specific + */ +#define DATA_MHEARD_FILE "/var/ax25/mheard/mheard.dat" + +/* + * rip98d specific + */ +#define CONF_RIP98D_FILE "/etc/ax25/rip98.conf" + +/* + * rxecho specific + */ +#define CONF_RXECHO_FILE "/etc/ax25/rxecho.conf" + +/* + * netromd specific + */ +#define CONF_NETROMD_FILE "/etc/ax25/nrbroadcast" + +/* + * node specific + */ +#define CONF_NODE_FILE "/etc/ax25/node.conf" +#define CONF_NODE_PERMS_FILE "/etc/ax25/node.perms" +#define CONF_NODE_MOTD_FILE "/etc/ax25/node.motd" +#define CONF_NODE_INFO_FILE "/etc/ax25/node.info" +#define DATA_NODE_LOGIN_FILE "/var/ax25/node/loggedin" +#define DATA_NODE_HELP_DIR "/usr/lib/ax25/node/help/" + +/* + * pms specific + */ +#define CONF_PMS_INFO_FILE "/etc/ax25/pms.info" +#define CONF_PMS_MOTD_FILE "/etc/ax25/pms.motd" +#define DATA_PMS_LOGIN_FILE "/var/ax25/pms/loggedin" +#define DATA_PMS_USERS_FILE "/var/ax25/pms/users" +#define DATA_PMS_HEAD_FILE "/var/ax25/pms/msg.head" +#define DATA_PMS_BODY_FILE "/var/ax25/pms/msg.body" +#define DATA_PMS_TALK_FILE "/var/ax25/pms/talk.pm/pipe.%d" +#define MAIL_DELIVERY_AGENT "/usr/sbin/sendmail %s" +/* #define MY_GATEWAY "hostname.mail.gw" */ +#define MY_TALK "/usr/sbin/ttylinkd" + +/* + * ttylinkd specific + */ +#define CONF_TTYLINKD_FILE "/etc/ax25/ttylinkd.conf" + +/* + * Location of serial port lock files + */ +#define LOCK_SERIAL_DIR "/var/lock" + +#endif diff -urN clussed-19981221/lib/daemon.h clussed-19981224/lib/daemon.h --- clussed-19981221/lib/daemon.h Thu Jan 1 02:00:00 1970 +++ clussed-19981224/lib/daemon.h Tue Dec 22 03:09:39 1998 @@ -0,0 +1,30 @@ +/* + * Function to convert a running process into a "proper" daemon. + */ + +#ifndef _DAEMON_H +#define _DAEMON_H + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The argument is whether to ignore the death of child processes. The function + * return non-zero if all was OK, else zero if there was a problem. + */ +extern int daemon_start(int); + +#ifdef __cplusplus +} +#endif + +#endif Binary files clussed-19981221/lib/libax25.a and clussed-19981224/lib/libax25.a differ diff -urN clussed-19981221/lib/mheard.h clussed-19981224/lib/mheard.h --- clussed-19981221/lib/mheard.h Thu Jan 1 02:00:00 1970 +++ clussed-19981224/lib/mheard.h Tue Dec 22 03:09:39 1998 @@ -0,0 +1,52 @@ +/* + * This file documents the layout of the mheard file. Since this file is + * common to at least two of the AX25 utilities, it is documented here. + */ +#ifndef MHEARD_H +#define MHEARD_H + +struct mheard_struct { + ax25_address from_call; + ax25_address to_call; + char portname[20]; + unsigned int count; + unsigned int sframes; + unsigned int uframes; + unsigned int iframes; + unsigned int ndigis; + ax25_address digis[8]; + time_t first_heard; + time_t last_heard; + +#define MHEARD_TYPE_SABM 0 +#define MHEARD_TYPE_SABME 1 +#define MHEARD_TYPE_DISC 2 +#define MHEARD_TYPE_UA 3 +#define MHEARD_TYPE_DM 4 +#define MHEARD_TYPE_RR 5 +#define MHEARD_TYPE_RNR 6 +#define MHEARD_TYPE_REJ 7 +#define MHEARD_TYPE_FRMR 8 +#define MHEARD_TYPE_I 9 +#define MHEARD_TYPE_UI 10 +#define MHEARD_TYPE_UNKNOWN 11 + unsigned int type; + +#define MHEARD_MODE_TEXT 0x0001 +#define MHEARD_MODE_ARP 0x0002 +#define MHEARD_MODE_IP_DG 0x0004 +#define MHEARD_MODE_IP_VC 0x0008 +#define MHEARD_MODE_NETROM 0x0010 +#define MHEARD_MODE_ROSE 0x0020 +#define MHEARD_MODE_FLEXNET 0x0040 +#define MHEARD_MODE_TEXNET 0x0080 +#define MHEARD_MODE_PSATPB 0x0100 +#define MHEARD_MODE_PSATFT 0x0200 +#define MHEARD_MODE_SEGMENT 0x4000 +#define MHEARD_MODE_UNKNOWN 0x8000 + unsigned int mode; + + char spare[128]; +}; + +#endif diff -urN clussed-19981221/lib/procutils.h clussed-19981224/lib/procutils.h --- clussed-19981221/lib/procutils.h Thu Jan 1 02:00:00 1970 +++ clussed-19981224/lib/procutils.h Tue Dec 22 03:09:39 1998 @@ -0,0 +1,109 @@ +/* + * Support routines to simplify the reading of the /proc/net/ax25* and + * /proc/net/nr* files. + */ + +#ifndef _PROCUTILS_H +#define _PROCUTILS_H + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +struct proc_ax25_route { + char call[10]; + char dev[14]; + int cnt; + long t; + + struct proc_ax25_route *next; +}; + +struct proc_ax25 { + char dest_addr[10], src_addr[10]; + char dev[14]; + unsigned char st; + unsigned short vs, vr, va; + unsigned short t1, t1timer, t2, t2timer, t3, t3timer; + unsigned short idle, idletimer; + unsigned char n2, n2count; + unsigned short rtt; + unsigned char window; + unsigned short paclen; + unsigned long sndq, rcvq; + unsigned long inode; + + struct proc_ax25 *next; +}; + +struct proc_nr { + char user_addr[10], dest_node[10], src_node[10]; + char dev[14]; + char my_circuit[6], your_circuit[6]; + unsigned char st; + unsigned short vs, vr, va; + unsigned short t1, t1timer, t2, t2timer, t4, t4timer; + unsigned short idle, idletimer; + unsigned char n2, n2count; + unsigned char window; + unsigned long sndq, rcvq; + unsigned long inode; + + struct proc_nr *next; +}; + +struct proc_nr_neigh { + int addr; + char call[10]; + char dev[14]; + int qual; + int lock; + int cnt; + + struct proc_nr_neigh *next; +}; + +struct proc_nr_nodes { + char call[10], alias[7]; + unsigned char w, n; + unsigned char qual1, qual2, qual3; + unsigned char obs1, obs2, obs3; + int addr1, addr2, addr3; + + struct proc_nr_nodes *next; +}; + +extern struct proc_ax25 *read_proc_ax25(void); +extern void free_proc_ax25(struct proc_ax25 *ap); + +extern struct proc_ax25_route *read_proc_ax25_route(void); +extern void free_proc_ax25_route(struct proc_ax25_route *rp); + +extern struct proc_nr *read_proc_nr(void); +extern void free_proc_nr(struct proc_nr *np); + +extern struct proc_nr_neigh *read_proc_nr_neigh(void); +extern void free_proc_nr_neigh(struct proc_nr_neigh *np); + +extern struct proc_nr_nodes *read_proc_nr_nodes(void); +extern void free_proc_nr_nodes(struct proc_nr_nodes *np); + +extern char *get_call(int uid); + +extern struct proc_ax25 *find_link(const char *src, const char *dest, const char *dev); +extern struct proc_nr_neigh *find_neigh(int addr, struct proc_nr_neigh *neigh); +extern struct proc_nr_nodes *find_node(char *addr, struct proc_nr_nodes *nodes); + +#ifdef _cplusplus +} +#endif + +#endif diff -urN clussed-19981221/lib/ttyutils.h clussed-19981224/lib/ttyutils.h --- clussed-19981221/lib/ttyutils.h Thu Jan 1 02:00:00 1970 +++ clussed-19981224/lib/ttyutils.h Tue Dec 22 03:09:41 1998 @@ -0,0 +1,53 @@ +/* + * Generic serial port handling functions. + */ + +#ifndef _TTYUTILS_H +#define _TTYUTILS_H + +#ifndef TRUE +#define TRUE 1 +#endif + +#ifndef FALSE +#define FALSE 0 +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Put a given file descriptor into raw mode, if the hwflag is set to TRUE + * then hardware handshaking is enabled. Returns TRUE if successful. + */ +extern int tty_raw(int fd, int hwflag); + +/* + * Set the speed of the given file descriptor. Returns TRUE is it was + * successful. + */ +extern int tty_speed(int fd, int speed); + +/* + * Determines whether a given tty is already open by another process. Returns + * TRUE if is already locked, or FALSE if it is free. + */ +extern int tty_is_locked(char *tty); + +/* + * Creates a lock file for the given tty. It writes the process ID to the + * file so take care if doing a fork. Returns TRUE if everything was OK. + */ +extern int tty_lock(char *tty); + +/* + * Removes the lock file for a given tty. Returns TRUE if successful. + */ +extern int tty_unlock(char *tty); + +#ifdef __cplusplus +} +#endif + +#endif diff -urN clussed-19981221/lib/version.h clussed-19981224/lib/version.h --- clussed-19981221/lib/version.h Thu Jan 1 02:00:00 1970 +++ clussed-19981224/lib/version.h Tue Dec 22 03:09:41 1998 @@ -0,0 +1,10 @@ +/* + * The version of the ax25-utils that the utility belongs to. + */ + +#ifndef _VERSION_H +#define _VERSION_H + +extern char version[]; + +#endif diff -urN clussed-19981221/linker.c clussed-19981224/linker.c --- clussed-19981221/linker.c Sun Dec 20 18:08:27 1998 +++ clussed-19981224/linker.c Tue Dec 22 03:19:32 1998 @@ -36,6 +36,7 @@ lj->f = NULL; lj->s = NULL; + lj->rxfailure = 0; return lj; } @@ -93,13 +94,8 @@ * Close a job */ -void end_connect(struct csock_t *s, int res) +void end_connect(struct linkjob_t *lj, int res) { - struct linkjob_t *lj; - - if (!(lj = lj_find(s))) - return; - if ((res) && (lj->endfunc)) (*lj->endfunc)(lj->ptr, res); @@ -112,7 +108,14 @@ void done_connect(struct csock_t *s) { - end_connect(s, 0); + struct linkjob_t *lj; + + if (!(lj = lj_find(s))) { + log(L_ERR, "done_connect(): no job for the stream!"); + return; + } + + end_connect(lj, 0); } /* @@ -133,19 +136,29 @@ if (read_scriptline(lj)) { log(L_LINK, "Linker: Script %s succeeded.", lj->script); - end_connect(lj->s, LJ_SUCCESS); + end_connect(lj, LJ_SUCCESS); return; } if (!strcmp(lj->argv[0], "s")) { + if (lj->argc != 2) { + log(L_ERR, "Linker: Script %s:%d: \"%s\" wants one parameter", + lj->script, lj->linec, lj->argv[0]); + end_connect(lj, LJ_ERROR); + } linker_send(lj); linker_advance(lj); } else if (!strcmp(lj->argv[0], "r")) { + if (lj->argc < 2) { + log(L_ERR, "Linker: Script %s:%d: \"%s\" wants at least one parameter", + lj->script, lj->linec, lj->argv[0]); + end_connect(lj, LJ_ERROR); + } return; } else { - log(L_LINK, "Linker: Script %s:%d: Unknown command \"%s\"", + log(L_ERR, "Linker: Script %s:%d: Unknown command \"%s\"", lj->script, lj->linec, lj->argv[0]); - end_connect(lj->s, LJ_ERROR); + end_connect(lj, LJ_ERROR); return; } @@ -160,9 +173,10 @@ { struct linkjob_t *lj; char *p = (char *)data; + int i; if (!(lj = lj_find(s))) { - log(L_ERR, "linker_handler(): no job for the stream!"); + log(L_ERR, "Linker: linker_handler(): no job for the stream!"); return 0; } @@ -172,6 +186,16 @@ linker_advance(lj); return 0; } + + for (i = 2; i < lj->argc; i++) { + if (strstr(p, lj->argv[i])) { + log(L_LINK, "Linker: Script %s failed: Received \"%s\"", lj->script, lj->argv[i]); + lj->rxfailure = 1; + sock_disconnect(lj->s); + return -2; + } + } + return 1; } @@ -206,8 +230,10 @@ return; } - log(L_LINK, "Linker: Script %s failed: Disconnected (%s)", lj->script, strerror(s->cs_errno)); - end_connect(s, LJ_FAILURE); + if (!lj->rxfailure) + log(L_LINK, "Linker: Script %s failed: Disconnected (%s)", lj->script, strerror(s->cs_errno)); + + end_connect(lj, LJ_FAILURE); return; } @@ -229,26 +255,32 @@ lj->ptr = ptr; if (!(lj->f = fopen(lj->script, "r"))) { - log(L_ERR, "Could not open script %s for reading: %s", + log(L_ERR, "Linker: Could not open script %s for reading: %s", lj->script, strerror(errno)); lj_free(lj); return 0; } if (read_scriptline(lj)) { - log(L_ERR, "Empty script file %s, no connection command found.", + log(L_ERR, "Linker: Empty script file %s, no connection command found.", lj->script); lj_free(lj); return 0; } if ((af_type = strtoaf(lj->argv[0])) == -1) { - log(L_ERR, "Unknown AF type %s, confusing.", lj->argv[0]); + log(L_ERR, "Linker: Unknown AF type %s, confusing.", lj->argv[0]); lj_free(lj); return 0; } lj->s = sock_connect(af_type, lj->argc-1, &lj->argv[1]); + + if (!lj->s) { + log(L_ERR, "Linker: sock_connect() failed"); + lj_free(lj); + return 0; + } lj->s->conn_handler = &linker_conn_handler; lj->s->disc_handler = &linker_disc_handler; diff -urN clussed-19981221/linker.h clussed-19981224/linker.h --- clussed-19981221/linker.h Sun Dec 20 18:08:27 1998 +++ clussed-19981224/linker.h Tue Dec 22 02:25:06 1998 @@ -24,6 +24,8 @@ int argc; char *argv[256]; + int rxfailure; /* have we found a "failure" string in the rx stream */ + /* Stuff to call after the script is done */ void (*endfunc)(void *ptr, int res); void *ptr; diff -urN clussed-19981221/log.c clussed-19981224/log.c --- clussed-19981221/log.c Sun Dec 20 18:08:27 1998 +++ clussed-19981224/log.c Thu Dec 24 15:59:47 1998 @@ -16,7 +16,9 @@ int open_log(void) { - openlog("clussed", LOG_NDELAY|LOG_PID, LOG_LOCAL6); + if (log_dest & L_SYSLOG) + openlog("clussed", LOG_NDELAY|LOG_PID, LOG_LOCAL6); + return 0; } @@ -29,10 +31,10 @@ vsnprintf(s, LOG_LEN, fmt, args); va_end(args); - if ((log_level & level)) { - if ((log_dest & L_STDERR)) + if (log_level & level) { + if (log_dest & L_STDERR) fprintf(stderr, "%s\n", s); - if ((log_dest & L_SYSLOG)) + if (log_dest & L_SYSLOG) syslog(LOG_ERR, "%s", s); } diff -urN clussed-19981221/luser.c clussed-19981224/luser.c --- clussed-19981221/luser.c Sun Dec 20 18:08:27 1998 +++ clussed-19981224/luser.c Thu Dec 24 15:55:26 1998 @@ -8,6 +8,7 @@ #include #include +#include #include "config.h" #include "csock.h" @@ -83,8 +84,10 @@ lu->next->prevp = lu->prevp; hfree(lu->f); - hfree(lu->fl); - hfree(lu->str); + if (lu->fl) + hfree(lu->fl); + if (lu->str) + hfree(lu->str); lu->sock->lu = NULL; hfree(lu); luser_count--; @@ -136,9 +139,12 @@ struct luserf_t *f; f = hmalloc(sizeof(struct luserf_t)); + memset(f, '\0', sizeof(struct luserf_t)); strcpy(f->call, call); truncssid(&f->call); + f->name[0] = '\0'; + f->qth[0] = '\0'; f->personal[0] = '\0'; f->locator[0] = '\0'; f->loc.latitude = 0; @@ -193,7 +199,7 @@ log(L_LUSER, "User: %s@%s:%s logged in", s->call, s->node, s->port); lu = luser_alloc(s); - lu->f = read_luserf(s->call); + lu->f = read_luserf((call_t *)s->call); if (!lu->f) { newuser = 1; log(L_LUSER, "User: %s is a new user, creating", s->call); diff -urN clussed-19981221/luser.h clussed-19981224/luser.h --- clussed-19981221/luser.h Sun Dec 20 18:08:27 1998 +++ clussed-19981224/luser.h Mon Dec 21 20:16:05 1998 @@ -35,6 +35,8 @@ struct luserf_t { call_t call; /* Callsign */ + char name[41]; /* Name */ + char qth[41]; /* QTH */ char personal[41]; /* Some personal description */ loc_t locator; /* Mainhead locator */ diff -urN clussed-19981221/main.c clussed-19981224/main.c --- clussed-19981221/main.c Sun Dec 20 18:08:27 1998 +++ clussed-19981224/main.c Thu Dec 24 16:07:47 1998 @@ -40,11 +40,12 @@ * Main */ -void main(void) +void main(int argc, char **argv) { ctime_init(); /* Time library init */ cstring_init(); /* Strings library init */ open_log(); /* Open logging */ + parse_cmdl(argc, argv); /* Parse arguments */ read_config(); /* Read configuration */ timer_init(); /* Initialize timer */ net_init(); /* Cluster networking init */ diff -urN clussed-19981221/network.c clussed-19981224/network.c --- clussed-19981221/network.c Sun Dec 20 18:08:27 1998 +++ clussed-19981224/network.c Thu Dec 24 16:09:07 1998 @@ -357,7 +357,7 @@ while (l) { if (l->state == ls_init || l->state == ls_linked) { l->dreason = dr_sysop; - if (method == rude || l->state == ls_init || l->mode == lm_listen) + if (method == cl_rude || l->state == ls_init || l->mode == lm_listen) sock_disconnect(l->sock); else { csprintf(l->sock, "PC39^%s^%s^\n", l->mycall, reason); diff -urN clussed-19981221/network.h clussed-19981224/network.h --- clussed-19981221/network.h Sun Dec 20 18:08:27 1998 +++ clussed-19981224/network.h Thu Dec 24 16:08:44 1998 @@ -180,7 +180,7 @@ }; enum cutlink_t { - nice, rude + cl_nice, cl_rude }; int pc_hops; diff -urN clussed-19981221/scripts/oh1rbi.con clussed-19981224/scripts/oh1rbi.con --- clussed-19981221/scripts/oh1rbi.con Sun Dec 20 18:08:29 1998 +++ clussed-19981224/scripts/oh1rbi.con Thu Jan 1 02:00:00 1970 @@ -1,21 +0,0 @@ - -# -# Connection script for Clusse 0.40 -# - -telnet localhost 3694 -# ax25 lo0 oh7lzb-2 -# netrom nrclu oh7lzb-2 - -#s "c lo0 oh7lzb-2" -#r "connected" "disc" "fail" "err" - -r "login:" -s "oh7lzb-1" - -r "Welcome" -s "i" - -r "LinuxNode" -s "b" -