diff --git a/ChangeLog b/ChangeLog index cad628e0..89ca3023 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,10 +1,20 @@ $Id$ +WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING + +Nodelist processing is under construction, it may be possible that you system +won't call if you use this version or if it does not accept calls, cannot +route mail or breaks your system. + +DO NOT USE THIS VERSION ON PRODUCTION SYSTEMS, ONLY FOR TESTING. v0.37.00 26-Dec-2002. general: A new developer joined the team, David Gonzalez. + The settings to suppres some IP protocols (global and nodes) + are removed, this behaviour can be set using nodelist flags + configuration. libs: The nodelist lookup functions are now in a separate library. @@ -17,10 +27,18 @@ v0.37.00 26-Dec-2002. With binkp and EMSI sessions double received remote aka's are filtered. + mbout: + When a poll was removed, the outbound was not rescanned. + examples: Prepared for more example translations. + Added German template files made by Joachim Kuwan. + mbsetup: + Removed global flags No-IBN, IFC and ITN from the setup. + Removed nodes flags No-IBN, IFC and ITN from the setup. + v0.36.00 26-Dec-2002 - stable release diff --git a/examples/Makefile b/examples/Makefile index 59a4e11a..2ccfc80e 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -7,7 +7,7 @@ SRCS = endian.c HDRS = endian.h OBJS = endian.o OTHER = Makefile header.txt footer.txt menus-le.tar menus-be.tar \ - txtfiles-en.tar templates-en.tar templates-es.tar + txtfiles-en.tar templates-en.tar templates-es.tar templates-de.tar ##################################################################################### @@ -36,11 +36,15 @@ install: all fi @if [ ! -f ${PREFIX}/english/txtfiles/main.ans ]; then \ tar xfC txtfiles-en.tar ${PREFIX}/english/txtfiles ; \ - echo "Installed default english txtfiles" ; \ + echo "Installed default English txtfiles" ; \ fi @if [ ! -f ${PREFIX}/english/macro/html.tic ]; then \ tar xfC templates-en.tar ${PREFIX}/english/macro ; \ - echo "Installed default english macro files" ; \ + echo "Installed default English macro files" ; \ + fi + @if [ ! -f ${PREFIX}/german/macro/html.tic ]; then \ + tar xfC templates-de.tar ${PREFIX}/german/macro ; \ + echo "Installed default German macro files" ; \ fi clean: diff --git a/lib/Makefile b/lib/Makefile index 8614d318..e8fe077b 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -179,6 +179,6 @@ smtp.o: ../config.h libs.h memwatch.h structs.h users.h records.h clcomm.h mbine diesel.o: ../config.h libs.h memwatch.h diesel.h mbdiesel.o: ../config.h libs.h memwatch.h structs.h users.h records.h common.h clcomm.h diesel.h memwatch.o: ../config.h libs.h memwatch.h -nodelist.o: ../config.h libs.h memwatch.h structs.h users.h records.h clcomm.h common.h nodelist.h +nodelist.o: ../config.h libs.h memwatch.h structs.h users.h records.h clcomm.h common.h mberrors.h nodelist.h ftscprod.o: ../config.h libs.h memwatch.h structs.h common.h # End of generated dependencies diff --git a/lib/nodelist.c b/lib/nodelist.c index 9a02834d..4b31e8cc 100644 --- a/lib/nodelist.c +++ b/lib/nodelist.c @@ -36,12 +36,28 @@ #include "records.h" #include "clcomm.h" #include "common.h" +#include "mberrors.h" #include "nodelist.h" #define NULLDOMAIN "nulldomain" +static char *k, *v; +static char *nlpath = NULL; +static int nlinitdone = FALSE; +static int linecnt = 0; +static unsigned long mypots = 0, myisdn = 0, mytcpip =0; + + +static int getkwd(char**); +static int getmdm(char**); +static int getarr(char**); +static int getdom(char**); +static int getsrv(char**); + + + struct _pkey pkey[] = { {(char *)"Down", NL_NODE, NL_DOWN}, {(char *)"Hold", NL_NODE, NL_HOLD}, @@ -54,106 +70,477 @@ struct _pkey pkey[] = { }; - -struct _okey okey[] = { - {(char *)"CM", OL_CM}, - {(char *)"MO", OL_MO}, - {(char *)"LO", OL_LO}, - {(char *)"MN", OL_MN}, - {NULL, 0} -}; - -struct _fkey fkey[] = { - {(char *)"V22", NL_V22}, - {(char *)"V29", NL_V29}, - {(char *)"V32", NL_V32}, - {(char *)"V32B",NL_V32B | NL_V32}, - {(char *)"V34", NL_V34}, - {(char *)"V42", NL_V42 | NL_MNP}, - {(char *)"V42B",NL_V42B | NL_V42 | NL_MNP}, - {(char *)"MNP", NL_MNP}, - {(char *)"H96", NL_H96}, - {(char *)"HST", NL_HST | NL_MNP}, - {(char *)"H14", NL_H14 | NL_HST | NL_MNP}, - {(char *)"H16", NL_H16 | NL_H14 | NL_HST | NL_MNP | NL_V42 | NL_V42B}, - {(char *)"MAX", NL_MAX}, - {(char *)"PEP", NL_PEP}, - {(char *)"CSP", NL_CSP}, - {(char *)"V32T",NL_V32T | NL_V32B | NL_V32}, - {(char *)"VFC", NL_VFC}, - {(char *)"ZYX", NL_ZYX | NL_V32B | NL_V32 | NL_V42B | NL_V42 | NL_MNP}, - {(char *)"X2C", NL_X2C | NL_X2S | NL_V34}, - {(char *)"X2S", NL_X2S | NL_V34}, - {(char *)"V90C",NL_V90C | NL_V90S | NL_V34}, - {(char *)"V90S",NL_V90S | NL_V34}, - {(char *)"Z19", NL_Z19 | NL_V32B | NL_V32 | NL_V42B | NL_V42 | NL_MNP | NL_ZYX}, - {NULL, 0} -}; - -struct _xkey xkey [] = { - {(char *)"XA", RQ_XA}, - {(char *)"XB", RQ_XB}, - {(char *)"XC", RQ_XC}, - {(char *)"XP", RQ_XP}, - {(char *)"XR", RQ_XR}, - {(char *)"XW", RQ_XW}, - {(char *)"XX", RQ_XX}, - {NULL, 0} -}; - -struct _dkey dkey [] = { - {(char *)"V110L", ND_V110L}, - {(char *)"V110H", ND_V110H}, - {(char *)"V120L", ND_V120L}, - {(char *)"V120H", ND_V120H}, - {(char *)"X75", ND_X75}, - {NULL, 0} -}; - -struct _ikey ikey [] = { - {(char *)"IBN", IP_IBN}, - {(char *)"IFC", IP_IFC}, - {(char *)"ITN", IP_ITN}, - {(char *)"IVM", IP_IVM}, - {(char *)"IP", IP_IP}, - {(char *)"IFT", IP_IFT}, - {NULL, 0} +/* + * Table to parse the ~/etc/nodelist.conf file + */ +static struct _keytab { + char *key; + int (*prc)(char **); + char** dest; +} keytab[] = { + {(char *)"online", getkwd, (char **)&nl_online}, + {(char *)"request", getkwd, (char **)&nl_request}, + {(char *)"reqbits", getkwd, (char **)&nl_reqbits}, + {(char *)"pots", getmdm, (char **)&nl_pots}, + {(char *)"isdn", getmdm, (char **)&nl_isdn}, + {(char *)"tcpip", getmdm, (char **)&nl_tcpip}, + {(char *)"search", getarr, (char **)&nl_search}, + {(char *)"dialer", getarr, (char **)&nl_dialer}, + {(char *)"domsuffix", getdom, (char **)&nl_domsuffix}, + {(char *)"service", getsrv, (char **)&nl_service}, + {NULL, NULL, NULL} }; +/* + * Get a keyword, string, unsigned long + */ +static int getkwd(char **dest) +{ + char *p; + unsigned long tmp; + nodelist_flag **tmpm; + + for (p = v; *p && !isspace(*p); p++); + if (*p) + *p++ = '\0'; + while (*p && isspace(*p)) + p++; + if (*p == '\0') { + WriteError("%s(%s): less then two tokens", nlpath, linecnt); + return MBERR_INIT_ERROR; + } + + for (tmpm = (nodelist_flag**)dest; *tmpm; tmpm=&((*tmpm)->next)); + (*tmpm) = (nodelist_flag *) xmalloc(sizeof(nodelist_flag)); + (*tmpm)->next = NULL; + (*tmpm)->name = xstrcpy(v); + tmp = strtoul(p, NULL, 0); + (*tmpm)->value = tmp; +// Syslog('s', "getkwd: %s(%d): \"%s\" \"%s\" \"%08x\"", nlpath, linecnt, MBSE_SS(k), (*tmpm)->name, (*tmpm)->value); + + return 0; +} + + + +/* + * Get a keyword, string, unsigned long, unsigned long + */ +static int getmdm(char **dest) +{ + char *p, *q; + unsigned long tmp1, tmp2; + nodelist_modem **tmpm; + + for (p = v; *p && !isspace(*p); p++); + if (*p) + *p++ = '\0'; + while (*p && isspace(*p)) + p++; + if (*p == '\0') { + WriteError("%s(%s): less then two tokens", nlpath, linecnt); + return MBERR_INIT_ERROR; + } + + for (q = p; *q && !isspace(*q); q++); + if (*q) + *q++ = '\0'; + while (*q && isspace(*q)) + q++; + if (*q == '\0') { + WriteError("%s(%s): less then three tokens", nlpath, linecnt); + return MBERR_INIT_ERROR; + } + + for (tmpm = (nodelist_modem**)dest; *tmpm; tmpm=&((*tmpm)->next)); + (*tmpm) = (nodelist_modem *) xmalloc(sizeof(nodelist_modem)); + (*tmpm)->next = NULL; + (*tmpm)->name = xstrcpy(v); + tmp1 = strtoul(p, NULL, 0); + tmp2 = strtoul(q, NULL, 0); + (*tmpm)->mask = tmp1; + (*tmpm)->value = tmp2; +// Syslog('s', "getmdm: %s(%d): \"%s\" \"%s\" \"%08x\" \"%08x\"", nlpath, linecnt, MBSE_SS(k), +// (*tmpm)->name, (*tmpm)->mask, (*tmpm)->value); + + return 0; +} + + + +/* + * Get a keyword, string array + */ +static int getarr(char **dest) +{ + char *p; + nodelist_array **tmpm; + + for (p = v; *p && !isspace(*p); p++); + if (*p) + *p++ = '\0'; + + for (tmpm = (nodelist_array**)dest; *tmpm; tmpm=&((*tmpm)->next)); + (*tmpm) = (nodelist_array *) xmalloc(sizeof(nodelist_array)); + (*tmpm)->next = NULL; + (*tmpm)->name = xstrcpy(v); +// Syslog('s', "getarr: %s(%d): \"%s\" \"%s\"", nlpath, linecnt, MBSE_SS(k), (*tmpm)->name); + return 0; +} + + + +/* + * Get a keyword, unsigned short, string + */ +static int getdom(char **dest) +{ + char *p; + unsigned short tmp; + nodelist_domsuf **tmpm; + + for (p = v; *p && !isspace(*p); p++); + if (*p) + *p++ = '\0'; + while (*p && isspace(*p)) + p++; + if (*p == '\0') { + WriteError("%s(%s): less then two tokens", nlpath, linecnt); + return MBERR_INIT_ERROR; + } + + for (tmpm = (nodelist_domsuf**)dest; *tmpm; tmpm=&((*tmpm)->next)); + (*tmpm) = (nodelist_domsuf *) xmalloc(sizeof(nodelist_domsuf)); + (*tmpm)->next = NULL; + tmp = strtod(v, NULL); + (*tmpm)->zone = tmp; + (*tmpm)->name = xstrcpy(p); +// Syslog('s', "getdom: %s(%d): \"%s\" \"%d\" \"%s\"", nlpath, linecnt, MBSE_SS(k), (*tmpm)->zone, (*tmpm)->name); + + return 0; +} + + + +/* + * Get a keyword, string, string, unsigned long + */ +static int getsrv(char **dest) +{ + char *p, *q; + unsigned long tmp; + nodelist_service **tmpm; + + for (p = v; *p && !isspace(*p); p++); + if (*p) + *p++ = '\0'; + while (*p && isspace(*p)) + p++; + if (*p == '\0') { + WriteError("%s(%s): less then two tokens", nlpath, linecnt); + return MBERR_INIT_ERROR; + } + + for (q = p; *q && !isspace(*q); q++); + if (*q) + *q++ = '\0'; + while (*q && isspace(*q)) + q++; + if (*q == '\0') { + WriteError("%s(%s): less then three tokens", nlpath, linecnt); + return MBERR_INIT_ERROR; + } + + for (tmpm = (nodelist_service**)dest; *tmpm; tmpm=&((*tmpm)->next)); + (*tmpm) = (nodelist_service *) xmalloc(sizeof(nodelist_service)); + (*tmpm)->next = NULL; + (*tmpm)->flag = xstrcpy(v); + (*tmpm)->service = xstrcpy(p); + tmp = strtoul(q, NULL, 0); + (*tmpm)->port = tmp; +// Syslog('s', "getsrv: %s(%d): \"%s\" \"%s\" \"%s\" \"%d\"", nlpath, linecnt, MBSE_SS(k), +// (*tmpm)->flag, (*tmpm)->service, (*tmpm)->port); + return 0; +} + + + +void tidy_nl_flag(nodelist_flag **); +void tidy_nl_flag(nodelist_flag **fap) +{ + nodelist_flag *tmp, *old; + + for (tmp = *fap; tmp; tmp = old) { + old = tmp->next; + if (tmp->name) + free(tmp->name); + free(tmp); + } + *fap = NULL; +} + + + +void tidy_nl_modem(nodelist_modem **); +void tidy_nl_modem(nodelist_modem **fap) +{ + nodelist_modem *tmp, *old; + + for (tmp = *fap; tmp; tmp = old) { + old = tmp->next; + if (tmp->name) + free(tmp->name); + free(tmp); + } + *fap = NULL; +} + + + +void tidy_nl_array(nodelist_array **); +void tidy_nl_array(nodelist_array **fap) +{ + nodelist_array *tmp, *old; + + for (tmp = *fap; tmp; tmp = old) { + old = tmp->next; + if (tmp->name) + free(tmp->name); + free(tmp); + } + *fap = NULL; +} + + + +void tidy_nl_domsuf(nodelist_domsuf **); +void tidy_nl_domsuf(nodelist_domsuf **fap) +{ + nodelist_domsuf *tmp, *old; + + for (tmp = *fap; tmp; tmp = old) { + old = tmp->next; + if (tmp->name) + free(tmp->name); + free(tmp); + } + *fap = NULL; +} + + + +void tidy_nl_service(nodelist_service **); +void tidy_nl_service(nodelist_service **fap) +{ + nodelist_service *tmp, *old; + + for (tmp = *fap; tmp; tmp = old) { + old = tmp->next; + if (tmp->flag) + free(tmp->flag); + if (tmp->service) + free(tmp->service); + free(tmp); + } + *fap = NULL; +} + + + +/* + * De-init nodelists, free all allocated memory + */ +void deinitnl(void) +{ + if (!nlinitdone) + return; + + Syslog('s', "De-init nodelists"); + + tidy_nl_flag(&nl_online); + tidy_nl_flag(&nl_request); + tidy_nl_flag(&nl_reqbits); + tidy_nl_modem(&nl_pots); + tidy_nl_modem(&nl_isdn); + tidy_nl_modem(&nl_tcpip); + tidy_nl_array(&nl_search); + tidy_nl_array(&nl_dialer); + tidy_nl_domsuf(&nl_domsuffix); + tidy_nl_service(&nl_service); + + Syslog('s', "De-init done"); + nlinitdone = FALSE; +} + + + +/* + * Init nodelists. + */ int initnl(void) { - int rc = 0; - FILE *dbf, *fp; - char *filexnm, *path; - struct _nlfil fdx; + int i, rc = 0, Found; + FILE *dbf, *fp; + char *filexnm, buf[256], *p, *q; + struct _nlfil fdx; + struct taskrec TCFG; + nodelist_modem **tmpm; - filexnm = xstrcpy(CFG.nodelists); - filexnm = xstrcat(filexnm,(char *)"/node.files"); + if (nlinitdone == TRUE) + return 0; - if ((dbf = fopen(filexnm, "r")) == NULL) { - WriteError("$Can't open %s", filexnm); - rc = 101; - } else { - path = calloc(128, sizeof(char)); + nl_online = NULL; + nl_pots = NULL; + nl_request = NULL; + nl_reqbits = NULL; + nl_isdn = NULL; + nl_tcpip = NULL; + nl_search = NULL; + nl_domsuffix = NULL; + nl_dialer = NULL; + nl_service = NULL; - while (fread(&fdx, sizeof(fdx), 1, dbf) == 1) { - sprintf(path, "%s/%s", CFG.nodelists, fdx.filename); - if ((fp = fopen(path, "r")) == NULL) { - WriteError("$Can't open %s", path); - rc = 101; - } else { - fclose(fp); - } - } + filexnm = xstrcpy(CFG.nodelists); + filexnm = xstrcat(filexnm,(char *)"/node.files"); + nlpath = calloc(PATH_MAX, sizeof(char)); - fclose(dbf); - free(path); + /* + * Check if all installed nodelists are present. + */ + if ((dbf = fopen(filexnm, "r")) == NULL) { + WriteError("$Can't open %s", filexnm); + rc = MBERR_INIT_ERROR; + } else { + while (fread(&fdx, sizeof(fdx), 1, dbf) == 1) { + sprintf(nlpath, "%s/%s", CFG.nodelists, fdx.filename); + if ((fp = fopen(nlpath, "r")) == NULL) { + WriteError("$Can't open %s", nlpath); + rc = MBERR_INIT_ERROR; + } else { + fclose(fp); + } } - free(filexnm); - return rc; + fclose(dbf); + } + free(filexnm); + + /* + * Read and parse ~/etc/nodelist.conf + */ + sprintf(nlpath, "%s/etc/nodelist.conf", getenv("MBSE_ROOT")); + if ((dbf = fopen(nlpath, "r")) == NULL) { + WriteError("$Can't open %s", nlpath); + rc = MBERR_INIT_ERROR; + } else { + while (fgets(buf, sizeof(buf) -1, dbf)) { + linecnt++; + if (*(p = buf + strlen(buf) -1) != '\n') { + WriteError("%s(%d): \"%s\" - line too long", nlpath, linecnt, buf); + rc = MBERR_INIT_ERROR; + break; + } + *p-- = '\0'; + while ((p >= buf) && isspace(*p)) + *p-- = '\0'; + k = buf; + while (*k && isspace(*k)) + k++; + p = k; + while (*p && !isspace(*p)) + p++; + *p++='\0'; + v = p; + while (*v && isspace(*v)) + v++; + + if ((*k == '\0') || (*k == '#')) { +// Syslog('n', "\"%s\" \"%s\" - ignore", MBSE_SS(k), MBSE_SS(v)); + continue; + } + +// Syslog('n', "\"%s\" \"%s\" - parsed", MBSE_SS(k), MBSE_SS(v)); + + for (i = 0; keytab[i].key; i++) + if (strcasecmp(k,keytab[i].key) == 0) + break; + + if (keytab[i].key == NULL) { + WriteError("%s(%d): %s %s - unknown keyword", nlpath, linecnt, MBSE_SS(k), MBSE_SS(v)); + rc = MBERR_INIT_ERROR; + break; + } else if ((keytab[i].prc(keytab[i].dest))) { + rc = MBERR_INIT_ERROR; + break; + } + } + fclose(dbf); + } + + Found = FALSE; + + /* + * Howmany TCP sessions are allowd + */ + sprintf(nlpath, "%s/etc/task.data", getenv("MBSE_ROOT")); + if ((fp = fopen(nlpath, "r"))) { + fread(&TCFG, sizeof(TCFG), 1, fp); + fclose(fp); + } else { + TCFG.max_tcp = 0; + } + + /* + * Read all our TCP/IP capabilities and set the global flag. + */ + if (TCFG.max_tcp) { + sprintf(buf, "%s", CFG.Flags); + q = buf; + for (p = q; p; p = q) { + if ((q = strchr(p, ','))) + *q++ = '\0'; + for (tmpm = &nl_tcpip; *tmpm; tmpm=&((*tmpm)->next)) + if (strncasecmp((*tmpm)->name, p, strlen((*tmpm)->name)) == 0) + mytcpip |= (*tmpm)->value; + } + } + + /* + * Read the ports configuration for all pots and isdn lines. + * All lines are ORed so we have a global and total lines + * capability. + */ + sprintf(nlpath, "%s/etc/ttyinfo.data", getenv("MBSE_ROOT")); + if ((fp = fopen(nlpath, "r"))) { + fread(&ttyinfohdr, sizeof(ttyinfohdr), 1, fp); + + while (fread(&ttyinfo, ttyinfohdr.recsize, 1, fp) == 1) { + if (((ttyinfo.type == POTS) || (ttyinfo.type == ISDN)) && (ttyinfo.available) && (ttyinfo.callout)) { + + sprintf(buf, "%s", ttyinfo.flags); + q = buf; + for (p = q; p; p = q) { + if ((q = strchr(p, ','))) + *q++ = '\0'; + for (tmpm = &nl_pots; *tmpm; tmpm=&((*tmpm)->next)) + if (strcasecmp((*tmpm)->name, p) == 0) + mypots |= (*tmpm)->value; + for (tmpm = &nl_isdn; *tmpm; tmpm=&((*tmpm)->next)) + if (strcasecmp((*tmpm)->name, p) == 0) + myisdn |= (*tmpm)->value; + } + } + } + fclose(fp); + } + + free(nlpath); + Syslog('s', "mypots %08x myisdn %08x mytcpip %08x", mypots, myisdn, mytcpip); + Syslog('s', "Nodelists initialize complete, rc=%d", rc); + nlinitdone = TRUE; + return rc; } @@ -161,14 +548,14 @@ int initnl(void) int comp_node(struct _nlidx, struct _ixentry); int comp_node(struct _nlidx fap1, struct _ixentry fap2) { - if (fap1.zone != fap2.zone) - return (fap1.zone - fap2.zone); - else if (fap1.net != fap2.net) - return (fap1.net - fap2.net); - else if (fap1.node != fap2.node) - return (fap1.node - fap2.node); - else - return (fap1.point - fap2.point); + if (fap1.zone != fap2.zone) + return (fap1.zone - fap2.zone); + else if (fap1.net != fap2.net) + return (fap1.net - fap2.net); + else if (fap1.node != fap2.node) + return (fap1.node - fap2.node); + else + return (fap1.point - fap2.point); } @@ -177,16 +564,21 @@ node *getnlent(faddr *addr) { FILE *fp, *np; static node nodebuf; - static char buf[2048], ebuf[2048], *p, *q; + static char buf[2048], ebuf[2048], *p, *q, tbuf[256]; struct _ixentry xaddr; - int i, j, Found = FALSE, ixflag, stdflag, ndrecord = FALSE; + int i, Found = FALSE, ixflag, stdflag, ndrecord = FALSE; char *mydomain, *path; struct _nlfil fdx; struct _nlidx ndx; long lowest, highest, current; struct _nodeshdr ndhdr; static struct _nodes nd; - + nodelist_modem **tmpm; + nodelist_flag **tmpf; + nodelist_service **tmps; + nodelist_array **tmpa; + unsigned long tport = 0; + Syslog('s', "getnlent: %s", ascfnode(addr,0xff)); mydomain = xstrcpy(CFG.aka[0].domain); @@ -215,9 +607,10 @@ node *getnlent(faddr *addr) nodebuf.iflags = 0L; nodebuf.dflags = 0L; nodebuf.uflags[0] = NULL; - nodebuf.t1 = '\0'; - nodebuf.t2 = '\0'; - + nodebuf.t1 = '\0'; + nodebuf.t2 = '\0'; + nodebuf.url = NULL; + if (addr == NULL) goto retdummy; @@ -312,6 +705,7 @@ node *getnlent(faddr *addr) fclose(fp); goto retdummy; } + Syslog('s', "getnlent: %s", buf); /* * Load noderecord if this node has one, if there is one then @@ -450,21 +844,21 @@ node *getnlent(faddr *addr) /* * Process authorized flags and user flags both as authorized. */ - for (j = 0; fkey[j].key; j++) - if (strcasecmp(p, fkey[j].key) == 0) - nodebuf.mflags |= fkey[j].flag; - for (j = 0; okey[j].key; j++) - if (strcasecmp(p, okey[j].key) == 0) - nodebuf.oflags |= okey[j].flag; - for (j = 0; dkey[j].key; j++) - if (strcasecmp(p, dkey[j].key) == 0) - nodebuf.dflags |= dkey[j].flag; - for (j = 0; ikey[j].key; j++) - if (strncasecmp(p, ikey[j].key, strlen(ikey[j].key)) == 0) - nodebuf.iflags |= ikey[j].flag; - for (j = 0; xkey[j].key; j++) - if (strcasecmp(p, xkey[j].key) == 0) - nodebuf.xflags |= xkey[j].flag; + for (tmpf = &nl_online; *tmpf; tmpf=&((*tmpf)->next)) + if (strcasecmp(p, (*tmpf)->name) == 0) + nodebuf.oflags |= (*tmpf)->value; + for (tmpm = &nl_pots; *tmpm; tmpm=&((*tmpm)->next)) + if (strcasecmp(p, (*tmpm)->name) == 0) + nodebuf.mflags |= (*tmpm)->value; + for (tmpm = &nl_isdn; *tmpm; tmpm=&((*tmpm)->next)) + if (strcasecmp(p, (*tmpm)->name) == 0) + nodebuf.dflags |= (*tmpm)->value; + for (tmpm = &nl_tcpip; *tmpm; tmpm=&((*tmpm)->next)) + if (strncasecmp(p, (*tmpm)->name, strlen((*tmpm)->name)) == 0) + nodebuf.iflags |= (*tmpm)->value; + for (tmpf = &nl_request; *tmpf; tmpf=&((*tmpf)->next)) + if (strcasecmp(p, (*tmpf)->name) == 0) + nodebuf.xflags = (*tmpf)->value; if ((p[0] == 'T') && (strlen(p) == 3)) { /* * System open hours flag @@ -503,6 +897,87 @@ node *getnlent(faddr *addr) } fclose(fp); + /* + * Build the connection URL + * + * If the node has some IP flags and we allow TCP, then search the best protocol. + */ + if (nodebuf.iflags & mytcpip) { + Syslog('s', "node iflags %08x, mytcpip %08x", nodebuf.iflags, mytcpip); + for (tmpm = &nl_tcpip; *tmpm; tmpm=&((*tmpm)->next)) { + if ((*tmpm)->mask & nodebuf.iflags) { + Syslog('s', "Setting %s", (*tmpm)->name); + for (tmps = &nl_service; *tmps; tmps=&((*tmps)->next)) { + if (strcmp((*tmps)->flag, (*tmpm)->name) == 0) { + sprintf(tbuf, "%s", (*tmps)->service); + tport = (*tmps)->port; + Syslog('s', "Setting %s %d", (*tmps)->service, (*tmps)->port); + } + } + } + } + + /* + * The last setting is the best + */ + nodebuf.url = xstrcpy(tbuf); + nodebuf.url = xstrcat(nodebuf.url, (char *)"://"); + + /* + * Next, try to find out the FQDN for this node, we have a search + * preference list in the nodelist.conf file. + */ + memset(&tbuf, 0, sizeof(tbuf)); + if (ndrecord && strlen(nd.Nl_hostname)) { + Syslog('s', "Using override %s for FQDN", nd.Nl_hostname); + sprintf(tbuf, nodebuf.name); + nodebuf.url = xstrcat(nodebuf.url, tbuf); + } else { + for (tmpa = &nl_search; *tmpa; tmpa=&((*tmpa)->next)) { + Syslog('s', "Search FQDN method %s", (*tmpa)->name); + if (strcasecmp((*tmpa)->name, "field3") == 0) { + sprintf(tbuf, nodebuf.name); + if (strchr(tbuf, '.')) { + /* + * Okay, there are dots, this can be a FQDN or IP address. + */ + Syslog('s', "Using field3 \"%s\"", tbuf); + nodebuf.url = xstrcat(nodebuf.url, tbuf); + break; + } + } else if (strcasecmp((*tmpa)->name, "field6") == 0) { + if (nodebuf.phone && strncmp(nodebuf.phone, "000-", 4) == 0) { + Syslog('s', "Found 000- prefix"); + sprintf(tbuf, "%s", nodebuf.phone+4); + for (i = 0; i < strlen(tbuf); i++) + if (tbuf[i] == '-') + tbuf[i] = '.'; + Syslog('s', "Using field6 \"%s\"", tbuf); + nodebuf.url = xstrcat(nodebuf.url, tbuf); + break; + } + } + } + } + + if (strchr(tbuf, ':') == NULL) { + /* + * No optional port number, add one from the default + * for this protocol. + */ + sprintf(tbuf, ":%lu", tport); + Syslog('s', "Adding default port %s", tbuf); + nodebuf.url = xstrcat(nodebuf.url, tbuf); + } + + } else if (nodebuf.dflags & myisdn) { + nodebuf.url = xstrcpy((char *)"isdn://"); + nodebuf.url = xstrcat(nodebuf.url, nodebuf.phone); + } else if (nodebuf.mflags & mypots) { + nodebuf.url = xstrcpy((char *)"pots://"); + nodebuf.url = xstrcat(nodebuf.url, nodebuf.phone); + } + nodebuf.addr.name = nodebuf.sysop; nodebuf.addr.domain = xstrcpy(fdx.domain); nodebuf.upnet = ndx.upnet; @@ -511,8 +986,9 @@ node *getnlent(faddr *addr) if (addr->domain == NULL) addr->domain = xstrcpy(nodebuf.addr.domain); - Syslog('s', "getnlent: system %s, %s", nodebuf.name, nodebuf.location); - Syslog('s', "getnlent: sysop %s, %s", nodebuf.sysop, nodebuf.phone); + Syslog('s', "getnlent: system %s, %s", nodebuf.name, nodebuf.location); + Syslog('s', "getnlent: sysop %s, %s", nodebuf.sysop, nodebuf.phone); + Syslog('s', "getnlent: URL %s", printable(nodebuf.url, 0)); moflags(nodebuf.mflags); diflags(nodebuf.dflags); ipflags(nodebuf.iflags); @@ -534,6 +1010,7 @@ retdummy: nodebuf.sysop = (char *)"Sysop"; nodebuf.phone = NULL; nodebuf.speed = 2400; + nodebuf.url = NULL; free(mydomain); return &nodebuf; @@ -543,17 +1020,16 @@ retdummy: void olflags(unsigned long flags) { - char *t; + char *t; + nodelist_flag **tmpm; t = xstrcpy((char *)"Mailer flags :"); - if (flags & OL_CM) - t = xstrcat(t, (char *)" CM"); - if (flags & OL_MO) - t = xstrcat(t, (char *)" MO"); - if (flags & OL_LO) - t = xstrcat(t, (char *)" LO"); - if (flags & OL_MN) - t = xstrcat(t, (char *)" MN"); + for (tmpm = &nl_online; *tmpm; tmpm=&((*tmpm)->next)) { + if ((*tmpm)->value & flags) { + t = xstrcat(t, (char *)" "); + t = xstrcat(t, (*tmpm)->name); + } + } Syslog('s', "%s", t); free(t); } @@ -562,17 +1038,23 @@ void olflags(unsigned long flags) void rqflags(unsigned long flags) { - char *t; - + char *t; + nodelist_flag **tmpm; + t = xstrcpy((char *)"Request flags:"); - if (flags & RQ_RQ_BR) - t = xstrcat(t, (char *)" RQ_BR"); - if (flags & RQ_RQ_BU) - t = xstrcat(t, (char *)" RQ_BU"); - if (flags & RQ_RQ_WR) - t = xstrcat(t, (char *)" RQ_WR"); - if (flags & RQ_RQ_WU) - t = xstrcat(t, (char *)" RQ_WU"); + for (tmpm = &nl_reqbits; *tmpm; tmpm=&((*tmpm)->next)) { + if ((*tmpm)->value & flags) { + t = xstrcat(t, (char *)" "); + t = xstrcat(t, (*tmpm)->name); + } + } + for (tmpm = &nl_request; *tmpm; tmpm=&((*tmpm)->next)) { + if ((*tmpm)->value == flags) { + t = xstrcat(t, (char *)" ("); + t = xstrcat(t, (*tmpm)->name); + t = xstrcat(t, (char *)")"); + } + } Syslog('s', "%s", t); free(t); } @@ -581,55 +1063,18 @@ void rqflags(unsigned long flags) void moflags(unsigned long flags) { - char *t; + char *t; + nodelist_modem **tmpm; if (!flags) return; t = xstrcpy((char *)"Modem flags :"); - if (flags & NL_V22) - t = xstrcat(t, (char *)" V22"); - if (flags & NL_V29) - t = xstrcat(t, (char *)" V29"); - if (flags & NL_V32) - t = xstrcat(t, (char *)" V32"); - if (flags & NL_V32B) - t = xstrcat(t, (char *)" V32B"); - if (flags & NL_V34) - t = xstrcat(t, (char *)" V34"); - if (flags & NL_V42) - t = xstrcat(t, (char *)" V42"); - if (flags & NL_V42B) - t = xstrcat(t, (char *)" V42B"); - if (flags & NL_MNP) - t = xstrcat(t, (char *)" MNP"); - if (flags & NL_H96) - t = xstrcat(t, (char *)" H96"); - if (flags & NL_HST) - t = xstrcat(t, (char *)" HST"); - if (flags & NL_H14) - t = xstrcat(t, (char *)" H14"); - if (flags & NL_H16) - t = xstrcat(t, (char *)" H16"); - if (flags & NL_MAX) - t = xstrcat(t, (char *)" MAX"); - if (flags & NL_PEP) - t = xstrcat(t, (char *)" PEP"); - if (flags & NL_CSP) - t = xstrcat(t, (char *)" CSP"); - if (flags & NL_V32T) - t = xstrcat(t, (char *)" V32T"); - if (flags & NL_VFC) - t = xstrcat(t, (char *)" VFC"); - if (flags & NL_ZYX) - t = xstrcat(t, (char *)" ZYX"); - if (flags & NL_X2C) - t = xstrcat(t, (char *)" X2C"); - if (flags & NL_X2S) - t = xstrcat(t, (char *)" X2S"); - if (flags & NL_V90C) - t = xstrcat(t, (char *)" V90C"); - if (flags & NL_V90S) - t = xstrcat(t, (char *)" V90S"); + for (tmpm = &nl_pots; *tmpm; tmpm=&((*tmpm)->next)) { + if ((*tmpm)->mask & flags) { + t = xstrcat(t, (char *)" "); + t = xstrcat(t, (*tmpm)->name); + } + } Syslog('s', "%s", t); free(t); } @@ -638,22 +1083,18 @@ void moflags(unsigned long flags) void diflags(unsigned long flags) { - char *t; - + char *t; + nodelist_modem **tmpm; + if (!flags) return; - t = xstrcpy((char *)"ISDN flags :"); - if (flags & ND_V110L) - t = xstrcat(t, (char *)" V110L"); - if (flags & ND_V110H) - t = xstrcat(t, (char *)" V110H"); - if (flags & ND_V120L) - t = xstrcat(t, (char *)" V120L"); - if (flags & ND_V120H) - t = xstrcat(t, (char *)" V120H"); - if (flags & ND_X75) - t = xstrcat(t, (char *)" X75"); + for (tmpm = &nl_isdn; *tmpm; tmpm=&((*tmpm)->next)) { + if ((*tmpm)->mask & flags) { + t = xstrcat(t, (char *)" "); + t = xstrcat(t, (*tmpm)->name); + } + } Syslog('s', "%s", t); free(t); } @@ -662,27 +1103,36 @@ void diflags(unsigned long flags) void ipflags(unsigned long flags) { - char *t; - + char *t; + nodelist_modem **tmpm; + if (!flags) return; - t = xstrcpy((char *)"TCP/IP flags :"); - if (flags & IP_IBN) - t = xstrcat(t, (char *)" IBN"); - if (flags & IP_IFC) - t = xstrcat(t, (char *)" IFC"); - if (flags & IP_ITN) - t = xstrcat(t, (char *)" ITN"); - if (flags & IP_IVM) - t = xstrcat(t, (char *)" IVM"); - if (flags & IP_IP) - t = xstrcat(t, (char *)" IP"); - if (flags & IP_IFT) - t = xstrcat(t, (char *)" IFT"); + for (tmpm = &nl_tcpip; *tmpm; tmpm=&((*tmpm)->next)) { + if ((*tmpm)->mask & flags) { + t = xstrcat(t, (char *)" "); + t = xstrcat(t, (*tmpm)->name); + } + } Syslog('s', "%s", t); free(t); } +unsigned long getCMmask(void) +{ + nodelist_flag **tmpm; + + for (tmpm = &nl_online; *tmpm; tmpm=&((*tmpm)->next)) { + if (strcmp("CM", (*tmpm)->name) == 0) { + return (*tmpm)->value; + } + } + + WriteError("CM mask not found in %s/etc/nodelist.conf", getenv("MBSE_ROOT")); + return 0; +} + + diff --git a/lib/nodelist.conf b/lib/nodelist.conf index 4ccc48eb..56babd16 100644 --- a/lib/nodelist.conf +++ b/lib/nodelist.conf @@ -41,26 +41,6 @@ # WARNING: This file will replace hardcoded behaviour of several parts of # the MBSE BBS package, tampering with this file is at your own risk. -# The following are the valid keywords in field 1 of the nodelist. -# They also represent the order of the nodes. -keyword Zone 1 -keyword Region 2 -keyword Host 3 -keyword Hub 4 -keyword "" 5 -keyword Point 6 - - -# The next flags are ORed to get a call possible value. A value of zero -# means that the node is reachable analogue with a FTS-0001 session. -# The rest is treated special. -# -callflag Down 0x01 # Node is Down -callflag Hold 0x02 # Node is Hold -callflag Pvt 0x04 # Pvt nodelist entry, no analogue call possible -callflag Dummy 0x08 # Dummy, no nodelist entry -callflag ISDN 0x10 # ISDN only node -callflag TCPIP 0x20 # ION (Internet Only Node) # Online special flags. @@ -71,49 +51,71 @@ online LO 0x00000004 online MN 0x00000008 +# Request flags, masks: +# 0x00000001 Bark request +# 0x00000002 Bark update +# 0x00000004 Wazoo request +# 0x00000008 Wazoo update +# +request XA 0x0000000F # Bark request, Bark update, Wazoo request, Wazoo update +request XB 0x00000007 # Bark request, Bark update, Wazoo request +request XC 0x0000000D # Bark request, Wazoo request, Wazoo update +request XP 0x00000003 # Bark request, Bark update +request XR 0x00000005 # Bark request, Wazoo request +request XW 0x00000004 # Wazoo request +request XX 0x0000000C # Wazoo request, Wazoo update + +# Request flags bits +# +reqbits RQ_BR 0x00000001 # Bark request +reqbits RQ_BU 0x00000002 # Bark update +reqbits RQ_WR 0x00000004 # Wazoo request +reqbits RQ_WU 0x00000008 # Wazoo update + + + +# Network services, the valid IP flags translated to the internet service +# names and their default ports. +# +service IBN binkp 24554 +service IFC fido 60179 +service ITN telnet 23 + + +# Switched network service names, they are used to build the +# URLs for modem and ISDN lines. +# +dialer pots +dialer isdn + # Modem flags, order is important to check the fastest possible connection # method. This also masks implied modes. # # flag entry implied mask -modem MNP 0x00000001 0x00000001 -modem V42 0x00000002 0x00000003 # implies MNP -modem V42B 0x00000004 0x00000007 # implies MNP and V42 -modem V22 0x00000008 0x00000008 -modem V29 0x00000010 0x00000010 -modem V32 0x00000020 0x00000020 -modem H96 0x00000040 0x00000040 -modem HST 0x00000080 0x00000081 # implies MNP -modem MAX 0x00000100 0x00000100 -modem PEP 0x00000200 0x00000200 -modem CSP 0x00000400 0x00000400 -modem V32B 0x00000800 0x00000820 # implies V32 -modem H14 0x00001000 0x00001081 # implies HST and MNP -modem V32T 0x00002000 0x00002820 # implies V32B and V32 -modem H16 0x00004000 0x00005087 # implies H14, HST, MNP, V42, V42B -modem ZYX 0x00008000 0x00008827 # implies V32B, V32, V42B, V42, MNP -modem Z19 0x00010000 0x00018827 # implies V32B, V32, V42B, V42, MNP, ZYX -modem VFC 0x00020000 0x00020000 -modem V34 0x00040000 0x00040000 -modem X2C 0x00080000 0x001B0000 # implies X2S, V34 -modem X2S 0x00100000 0x00140000 # implies V34 -modem V90C 0x00200000 0x00640000 # implies V90S, V34 -modem V90S 0x00400000 0x00440000 # implies V34 - - -# Request flags, masks: -# 0x00000001 Bark request -# 0x00000002 Bark update -# 0x00000004 Wazoo request -# 0x00000008 Wazoo update -# -request XA 0x0000000F # Bark request, Bark update, Wazoo request, Wazoo update -request XB 0x00000007 # Bark request, Bark update, Wazoo request -request XC 0x0000000D # Bark request, Wazoo request, Wazoo update -request XP 0x00000003 # Bark request, Bark update -request XR 0x00000005 # Bark request, Wazoo request -request XW 0x00000004 # Wazoo request -request XX 0x0000000B # Wazoo request, Wazoo update +pots MNP 0x00000001 0x00000001 +pots V42 0x00000002 0x00000003 # implies MNP +pots V42B 0x00000004 0x00000007 # implies MNP and V42 +pots V22 0x00000008 0x00000008 +pots V29 0x00000010 0x00000010 +pots V32 0x00000020 0x00000020 +pots H96 0x00000040 0x00000040 +pots HST 0x00000080 0x00000081 # implies MNP +pots MAX 0x00000100 0x00000100 +pots PEP 0x00000200 0x00000200 +pots CSP 0x00000400 0x00000400 +pots V32B 0x00000800 0x00000820 # implies V32 +pots H14 0x00001000 0x00001081 # implies HST and MNP +pots V32T 0x00002000 0x00002820 # implies V32B and V32 +pots H16 0x00004000 0x00005087 # implies H14, HST, MNP, V42, V42B +pots ZYX 0x00008000 0x00008827 # implies V32B, V32, V42B, V42, MNP +pots Z19 0x00010000 0x00018827 # implies V32B, V32, V42B, V42, MNP, ZYX +pots VFC 0x00020000 0x00020000 +pots V34 0x00040000 0x00040000 +pots X2C 0x00080000 0x001B0000 # implies X2S, V34 +pots X2S 0x00100000 0x00140000 # implies V34 +pots V90C 0x00200000 0x00640000 # implies V90S, V34 +pots V90S 0x00400000 0x00440000 # implies V34 # ISDN flags in order of best speed. @@ -127,30 +129,31 @@ isdn X75 0x00000010 0x00000010 -# Note that the IP flags do not represent the order of preference. -# That need to be changed. +# Supported IP protocols by the mailer in order of preference. +# The names must match the service names. # -tcpip IBN 0x00000001 0x00000001 +tcpip ITN 0x00000001 0x00000001 tcpip IFC 0x00000002 0x00000002 -tcpip ITN 0x00000004 0x00000004 -tcpip IVM 0x00000008 0x00000008 -tcpip IP 0x00000010 0x00000010 -tcpip IFT 0x00000020 0x00000020 +tcpip IBN 0x00000004 0x00000004 # The following gives the order to search for the # FQDN or IP address of the node. Valid values are: -# system - Search in the system name field -# phone - Search the phone field for 000- prefix +# field3 - Search in the system name field, may have :port suffix. +# 192.168.1.40:1234 or ntbox.mbse.ym:5678 are valid. +# field6 - Search the phone field for 000- prefix, may be a IP +# or a FQDN with or without a :port suffix. +# 000-192-168-1-40:1234 or 000-ntbox.mbse.ym:5678 are valid. +# ina - Search INA:fqdn (NOT YET AVAILABLE) # firstflag - First IP flag (NOT YET AVAILABLE) # eslf - Extended St. Louis Format fields (NOT YET AVAILABLE) # defdomain - Asume default domain (NOT YET AVAILABLE) # # In all cases, the nodes setup overrides everything. -# Order is important +# Order is important, defdomain must be the last if used. # -search system -search phone +search field3 +search field6 # The default searchdomain, will be prefixed with f1.n2 (NOT YET AVAILABLE) # diff --git a/lib/nodelist.h b/lib/nodelist.h index 2b247455..3789262f 100644 --- a/lib/nodelist.h +++ b/lib/nodelist.h @@ -5,95 +5,11 @@ #include "../config.h" - #define MAXNAME 35 #define MAXUFLAGS 16 -/* - * Analogue Modem flag values, order is important, first the - * compresion capabilities, then the linespeeds. This is late - * tested by portsel to find the fastest common connection - * speed for a given line if you have multiple dialout modems. - */ -#define NL_MNP 0x00000001L -#define NL_V42 0x00000002L -#define NL_V42B 0x00000004L -#define NL_V22 0x00000008L -#define NL_V29 0x00000010L -#define NL_V32 0x00000020L -#define NL_H96 0x00000040L -#define NL_HST 0x00000080L -#define NL_MAX 0x00000100L -#define NL_PEP 0x00000200L -#define NL_CSP 0x00000400L -#define NL_V32B 0x00000800L -#define NL_H14 0x00001000L -#define NL_V32T 0x00002000L -#define NL_H16 0x00004000L -#define NL_ZYX 0x00008000L -#define NL_Z19 0x00010000L -#define NL_VFC 0x00020000L -#define NL_V34 0x00040000L -#define NL_X2C 0x00080000L -#define NL_X2S 0x00100000L -#define NL_V90C 0x00200000L -#define NL_V90S 0x00400000L - - - -/* - * ISDN Flags - */ -#define ND_V110L 0x00000001L -#define ND_V110H 0x00000002L -#define ND_V120L 0x00000004L -#define ND_V120H 0x00000008L -#define ND_X75 0x00000010L - - - -/* - * TCP/IP flags - */ -#define IP_IBN 0x00000001L -#define IP_IFC 0x00000002L -#define IP_ITN 0x00000004L -#define IP_IVM 0x00000008L -#define IP_IP 0x00000010L -#define IP_IFT 0x00000020L - - - -/* - * Online special flags - */ -#define OL_CM 0x00000001L -#define OL_MO 0x00000002L -#define OL_LO 0x00000004L -#define OL_MN 0x00000008L - - - -/* - * Request flags - */ -#define RQ_RQMODE 0x0000000fL -#define RQ_RQ_BR 0x00000001L -#define RQ_RQ_BU 0x00000002L -#define RQ_RQ_WR 0x00000004L -#define RQ_RQ_WU 0x00000008L -#define RQ_XA (RQ_RQ_BR | RQ_RQ_BU | RQ_RQ_WR | RQ_RQ_WU) -#define RQ_XB (RQ_RQ_BR | RQ_RQ_BU | RQ_RQ_WR ) -#define RQ_XC (RQ_RQ_BR | RQ_RQ_WR | RQ_RQ_WU) -#define RQ_XP (RQ_RQ_BR | RQ_RQ_BU ) -#define RQ_XR (RQ_RQ_BR | RQ_RQ_WR ) -#define RQ_XW ( RQ_RQ_WR ) -#define RQ_XX ( RQ_RQ_WR | RQ_RQ_WU) - - - /* * Nodelist entry */ @@ -117,43 +33,48 @@ typedef struct _node { char *uflags[MAXUFLAGS]; /* User flags */ int t1; /* T flag, first char */ int t2; /* T flag, second char */ + char *url; /* URL for connection */ } node; -extern struct _fkey { - char *key; - unsigned long flag; -} fkey[]; +/* + * Memory array structures read from nodelist.conf + */ +typedef struct _nodelist_flag { + struct _nodelist_flag *next; + char *name; + unsigned long value; +} nodelist_flag; - -extern struct _dkey { - char *key; - unsigned long flag; -} dkey[]; +typedef struct _nodelist_modem { + struct _nodelist_modem *next; + char *name; + unsigned long mask; + unsigned long value; +} nodelist_modem; - -extern struct _ikey { - char *key; - unsigned long flag; -} ikey[]; +typedef struct _nodelist_array { + struct _nodelist_array *next; + char *name; +} nodelist_array; - -extern struct _okey { - char *key; - unsigned long flag; -} okey[]; +typedef struct _nodelist_domsuf { + struct _nodelist_domsuf *next; + unsigned short zone; + char *name; +} nodelist_domsuf; - -extern struct _xkey { - char *key; - unsigned long flag; -} xkey[]; - +typedef struct _nodelist_service { + struct _nodelist_service *next; + char *flag; + char *service; + unsigned long port; +} nodelist_service; extern struct _nodelist { @@ -162,7 +83,6 @@ extern struct _nodelist { } *nodevector; - struct _ixentry { unsigned short zone; unsigned short net; @@ -171,7 +91,6 @@ struct _ixentry { }; - extern struct _pkey { char *key; unsigned char type; @@ -180,16 +99,30 @@ extern struct _pkey { +nodelist_flag *nl_online; +nodelist_flag *nl_request; +nodelist_flag *nl_reqbits; +nodelist_modem *nl_pots; +nodelist_modem *nl_isdn; +nodelist_modem *nl_tcpip; +nodelist_array *nl_search; +nodelist_array *nl_dialer; +nodelist_domsuf *nl_domsuffix; +nodelist_service *nl_service; + + /* * From nodelist.c */ int initnl(void); +void deinitnl(void); node *getnlent(faddr *); void olflags(unsigned long); void rqflags(unsigned long); void moflags(unsigned long); void diflags(unsigned long); void ipflags(unsigned long); +unsigned long getCMmask(void); #endif diff --git a/lib/structs.h b/lib/structs.h index 7825b8f2..d373e7ed 100644 --- a/lib/structs.h +++ b/lib/structs.h @@ -729,9 +729,9 @@ struct sysconfig { unsigned xNoJanus : 1; unsigned NoHydra : 1; /* Don't do Hydra */ - unsigned NoIBN : 1; /* No TCP-IP binkp */ - unsigned NoITN : 1; /* No TCP-IP telnet */ - unsigned NoIFC : 1; /* No TCP-IP ifcico */ + unsigned xNoIBN : 1; + unsigned xNoITN : 1; + unsigned xNoIFC : 1; char Phone[21]; /* Default phonenumber */ unsigned long Speed; /* Default linespeed */ @@ -1221,13 +1221,13 @@ struct _nodes { unsigned xNoJanus : 1; /* Don't use Janus */ unsigned NoHydra : 1; /* Don't use Hydra */ - unsigned NoIBN : 1; /* Don't use TCP-IP binkp */ + unsigned xNoIBN : 1; unsigned PackNetmail : 1; /* Pack netmail */ unsigned ARCmailCompat : 1; /* ARCmail Compatibility */ unsigned ARCmailAlpha : 1; /* Allow a..z ARCmail name */ unsigned FNC : 1; /* Node needs 8.3 filenames */ - unsigned NoITN : 1; /* Don't use TCP-IP telnet */ - unsigned NoIFC : 1; /* Don't use TCP-IP ifcico */ + unsigned xNoITN : 1; + unsigned xNoIFC : 1; char xExtra[94]; time_t StartDate; /* Node start date */ diff --git a/mbcico/call.c b/mbcico/call.c index dfb848d3..f4f26fbb 100644 --- a/mbcico/call.c +++ b/mbcico/call.c @@ -104,8 +104,10 @@ int portopen(faddr *addr) int call(faddr *addr) { - int i, rc = 1; + int i, rc = 1, proto = FALSE; struct hostent *he; + unsigned long cmmask, ipmask; + nodelist_modem **tmpm; /* * Don't call points, call their boss instead. @@ -134,6 +136,7 @@ int call(faddr *addr) */ noderecord(addr); rdoptions(TRUE); + cmmask = getCMmask(); /* * Fill default history info in case we get a FTS0001 session @@ -152,39 +155,31 @@ int call(faddr *addr) * First see if this node can be reached over the internet and * that internet calls are allowed. */ - if (nlent->iflags && ((localoptions & (NOIBN & NOITN & NOIFC)) == 0)) { + if (nlent->iflags) { if (!inetaddr) { Syslog('d', "Trying to find IP address..."); /* * There is no fdn or IP address at the commandline. * First check nodesetup for an override in the phone field. + * Try to find the fdn in several places in the nodelist fields. */ -// if (strlen(nodes.phone[0])) { -// inetaddr = xstrcpy(nodes.phone[0]); -// } else if (strlen(nodes.phone[1])) { -// inetaddr = xstrcpy(nodes.phone[1]); -// } else { + if ((nlent->phone != NULL) && (strncmp(nlent->phone, (char *)"000-", 4) == 0)) { + inetaddr = xstrcpy(nlent->phone+4); + for (i = 0; i < strlen(inetaddr); i++) + if (inetaddr[i] == '-') + inetaddr[i] = '.'; + Syslog('d', "Got IP address from phone field"); + } else if ((he = gethostbyname(nlent->name))) { + inetaddr = xstrcpy(nlent->name); + Syslog('d', "Got hostname from nodelist system name"); + } else if ((he = gethostbyname(nlent->location))) { /* - * Try to find the fdn in several places in the nodelist fields. + * A fdn at the nodelist location field is not in the specs + * but the real world differs from the specs. */ - if ((nlent->phone != NULL) && (strncmp(nlent->phone, (char *)"000-", 4) == 0)) { - inetaddr = xstrcpy(nlent->phone+4); - for (i = 0; i < strlen(inetaddr); i++) - if (inetaddr[i] == '-') - inetaddr[i] = '.'; - Syslog('d', "Got IP address from phone field"); - } else if ((he = gethostbyname(nlent->name))) { - inetaddr = xstrcpy(nlent->name); - Syslog('d', "Got hostname from nodelist system name"); - } else if ((he = gethostbyname(nlent->location))) { - /* - * A fdn at the nodelist location field is not in the specs - * but the real world differs from the specs. - */ - inetaddr = xstrcpy(nlent->location); - Syslog('d', "Got hostname from nodelist location"); - } -// } + inetaddr = xstrcpy(nlent->location); + Syslog('d', "Got hostname from nodelist location"); + } } /* @@ -200,16 +195,36 @@ int call(faddr *addr) * from the nodelist. If it fails, fallback to dial. * Priority IBN, IFC, ITN. */ - if ((nlent->iflags & IP_IBN) && ((localoptions & NOIBN) == 0)) { + ipmask = 0; + for (tmpm = &nl_tcpip; *tmpm; tmpm=&((*tmpm)->next)) + if (strcmp("IBN", (*tmpm)->name) == 0) + ipmask = (*tmpm)->mask; + if (nlent->iflags & ipmask) { tcp_mode = TCPMODE_IBN; Syslog('d', "TCP/IP mode set to IBN"); - } else if ((nlent->iflags & IP_IFC) && ((localoptions & NOIFC) == 0)) { - tcp_mode = TCPMODE_IFC; - Syslog('d', "TCP/IP mode set to IFC"); - } else if ((nlent->iflags & IP_ITN) && ((localoptions & NOITN) == 0)) { - tcp_mode = TCPMODE_ITN; - Syslog('d', "TCP/IP mode seto to ITN"); - } else { + proto = TRUE; + } + if (!proto) { + for (tmpm = &nl_tcpip; *tmpm; tmpm=&((*tmpm)->next)) + if (strcmp("IFC", (*tmpm)->name) == 0) + ipmask = (*tmpm)->mask; + if (nlent->iflags & ipmask) { + tcp_mode = TCPMODE_IFC; + Syslog('d', "TCP/IP mode set to IFC"); + proto = TRUE; + } + } + if (!proto) { + for (tmpm = &nl_tcpip; *tmpm; tmpm=&((*tmpm)->next)) + if (strcmp("ITN", (*tmpm)->name) == 0) + ipmask = (*tmpm)->mask; + if (nlent->iflags & ipmask) { + tcp_mode = TCPMODE_ITN; + Syslog('d', "TCP/IP mode seto to ITN"); + proto = TRUE; + } + } + if (!proto) { Syslog('+', "No common TCP/IP protocols for node %s", nlent->name); free(inetaddr); inetaddr = NULL; @@ -224,8 +239,8 @@ int call(faddr *addr) } } - if (((nlent->oflags & OL_CM) == 0) && (!IsZMH())) { - Syslog('?', "Warning: calling MO system outside ZMH"); + if (((nlent->oflags & cmmask) == 0) && (!IsZMH())) { + Syslog('?', "Warning: calling non-CM system outside ZMH"); } if (inbound) diff --git a/mbcico/emsi.c b/mbcico/emsi.c index 004b2fd2..620fd53a 100644 --- a/mbcico/emsi.c +++ b/mbcico/emsi.c @@ -93,7 +93,7 @@ int rx_emsi(char *data) emsi_local_protos &= ~PROT_JAN; if (localoptions & NOHYDRA) emsi_local_protos &= ~PROT_HYD; - if ((localoptions & NOITN) || (localoptions & NOIFC) || ((session_flags & SESSION_TCP) == 0)) { + if ((session_flags & SESSION_TCP) == 0) { emsi_local_protos &= ~PROT_TCP; } @@ -224,7 +224,7 @@ int tx_emsi(char *data) emsi_local_protos &= ~PROT_JAN; if (localoptions & NOHYDRA) emsi_local_protos &= ~PROT_HYD; - if ((localoptions & NOIFC) || (localoptions & NOITN) || ((session_flags & SESSION_TCP) == 0)) { + if ((session_flags & SESSION_TCP) == 0) { emsi_local_protos &= ~PROT_TCP; } emsi_remote_protos=0; diff --git a/mbcico/mbout.c b/mbcico/mbout.c index 30bbc44d..63ee9949 100644 --- a/mbcico/mbout.c +++ b/mbcico/mbout.c @@ -77,48 +77,50 @@ void ProgName() void die(int); void die(int onsig) { + deinitnl(); + + /* + * First check if a child is running, if so, kill it. + */ + if (e_pid) { + if ((kill(e_pid, SIGTERM)) == 0) + Syslog('+', "SIGTERM to pid %d succeeded", e_pid); + else { + if ((kill(e_pid, SIGKILL)) == 0) + Syslog('+', "SIGKILL to pid %d succeded", e_pid); + else + WriteError("$Failed to kill pid %d", e_pid); + } + /* - * First check if a child is running, if so, kill it. + * In case the child had the tty in raw mode... */ - if (e_pid) { - if ((kill(e_pid, SIGTERM)) == 0) - Syslog('+', "SIGTERM to pid %d succeeded", e_pid); - else { - if ((kill(e_pid, SIGKILL)) == 0) - Syslog('+', "SIGKILL to pid %d succeded", e_pid); - else - WriteError("$Failed to kill pid %d", e_pid); - } + system("stty sane"); + } - /* - * In case the child had the tty in raw mode... - */ - system("stty sane"); - } + signal(onsig, SIG_IGN); - signal(onsig, SIG_IGN); + if (show_log) + do_quiet = FALSE; - if (show_log) - do_quiet = FALSE; + if (!do_quiet) + colour(3, 0); - if (!do_quiet) - colour(3, 0); + if (onsig) { + if (onsig <= NSIG) + WriteError("Terminated on signal %d (%s)", onsig, SigName[onsig]); + else + WriteError("Terminated with error %d", onsig); + } - if (onsig) { - if (onsig <= NSIG) - WriteError("Terminated on signal %d (%s)", onsig, SigName[onsig]); - else - WriteError("Terminated with error %d", onsig); - } + t_end = time(NULL); + Syslog(' ', "MBOUT finished in %s", t_elapsed(t_start, t_end)); - t_end = time(NULL); - Syslog(' ', "MBOUT finished in %s", t_elapsed(t_start, t_end)); - - if (!do_quiet) { - colour(7, 0); - printf("\n"); - } - ExitClient(onsig); + if (!do_quiet) { + colour(7, 0); + printf("\n"); + } + ExitClient(onsig); } @@ -176,7 +178,8 @@ int main(int argc, char *argv[]) faddr *addr = NULL; node *nlent; FILE *fl; - + unsigned long cmmask; + #ifdef MEMWATCH mwInit(); #endif @@ -312,13 +315,14 @@ int main(int argc, char *argv[]) } nlent = getnlent(addr); + cmmask = getCMmask(); if (nlent->pflag == NL_DUMMY) Fatal((char *)"Node is not in nodelist", MBERR_NODE_NOT_IN_LIST); if (nlent->pflag == NL_DOWN) Fatal((char *)"Node has status Down", MBERR_NODE_MAY_NOT_CALL); if (nlent->pflag == NL_HOLD) Fatal((char *)"Node has status Hold", MBERR_NODE_MAY_NOT_CALL); - if (((nlent->oflags & OL_CM) == 0) && (flavor == 'c')) + if (((nlent->oflags & cmmask) == 0) && (flavor == 'c')) Fatal((char *)"Node is not CM, must use Immediate, Normal or Hold flavor", MBERR_NODE_MAY_NOT_CALL); if (argv[4][0] == '-') diff --git a/mbcico/nlinfo.c b/mbcico/nlinfo.c index 68c17071..02fd7e93 100644 --- a/mbcico/nlinfo.c +++ b/mbcico/nlinfo.c @@ -41,107 +41,103 @@ int nlinfo(faddr *addr) { - node *nlent; - int i, t; - char flagbuf[256]; + node *nlent; + int i, t; + char flagbuf[256]; + nodelist_modem **tmpm; + nodelist_flag **tmpf; + + if (addr == NULL) + return 0; - if (addr == NULL) - return 0; + Syslog('s', "Search nodelist info for %s", ascfnode(addr, 0x1f)); + nlent = getnlent(addr); - Syslog('s', "Search nodelist info for %s", ascfnode(addr, 0x1f)); - nlent = getnlent(addr); + if (nlent->pflag != NL_DUMMY) { + colour(3, 0); + printf("System : %s\n", nlent->name); + printf("Sysop : %s@%s\n", nlent->sysop, ascinode(addr, 0x3f)); + printf("Location : %s\n", nlent->location); + if (nlent->phone) + printf("Phone : %s\n", nlent->phone); + else + printf("Phone : -Unpublished-\n"); + printf("Speed : %d\n", nlent->speed); - if (nlent->pflag != NL_DUMMY) { - colour(3, 0); - printf("System : %s\n", nlent->name); - printf("Sysop : %s@%s\n", nlent->sysop, ascinode(addr, 0x3f)); - printf("Location : %s\n", nlent->location); - if (nlent->phone) - printf("Phone : %s\n", nlent->phone); - else - printf("Phone : -Unpublished-\n"); - printf("Speed : %d\n", nlent->speed); + flagbuf[0] = 0; - flagbuf[0] = 0; + /* + * Get all normal nodelist flags + */ + for (tmpf = &nl_online; *tmpf; tmpf = &((*tmpf)->next)) + if ((nlent->oflags & (*tmpf)->value) == (*tmpf)->value) + sprintf(flagbuf + strlen(flagbuf), "%s,", (*tmpf)->name); + for (tmpf = &nl_request; *tmpf; tmpf = &((*tmpf)->next)) + if (nlent->xflags == (*tmpf)->value) + sprintf(flagbuf + strlen(flagbuf), "%s,", (*tmpf)->name); + for (tmpm = &nl_pots; *tmpm; tmpm=&((*tmpm)->next)) + if ((nlent->mflags & (*tmpm)->mask) == (*tmpm)->mask) + sprintf(flagbuf + strlen(flagbuf), "%s,", (*tmpm)->name); + for (tmpm = &nl_isdn; *tmpm; tmpm=&((*tmpm)->next)) + if ((nlent->dflags & (*tmpm)->mask) == (*tmpm)->mask) + sprintf(flagbuf + strlen(flagbuf), "%s,", (*tmpm)->name); + for (tmpm = &nl_tcpip; *tmpm; tmpm=&((*tmpm)->next)) + if ((nlent->iflags & (*tmpm)->mask) == (*tmpm)->mask) + sprintf(flagbuf + strlen(flagbuf), "%s,", (*tmpm)->name); + flagbuf[strlen(flagbuf)-1] = '\0'; + printf("Flags : %s\n", flagbuf); - /* - * Get all normal nodelist flags - */ - for (i = 0; fkey[i].flag != 0; i++) - if ((nlent->mflags & fkey[i].flag) == fkey[i].flag) - sprintf(flagbuf + strlen(flagbuf), "%s,", fkey[i].key); - for (i = 0; dkey[i].flag != 0; i++) - if ((nlent->dflags & dkey[i].flag) == dkey[i].flag) - sprintf(flagbuf + strlen(flagbuf), "%s,", dkey[i].key); - for (i = 0; ikey[i].flag != 0; i++) - if ((nlent->iflags & ikey[i].flag) == ikey[i].flag) - sprintf(flagbuf + strlen(flagbuf), "%s,", ikey[i].key); - for (i = 0; okey[i].flag != 0; i++) - if ((nlent->oflags & okey[i].flag) == okey[i].flag) - sprintf(flagbuf + strlen(flagbuf), "%s,", okey[i].key); - - switch (nlent->xflags) { - case RQ_XA: sprintf(flagbuf + strlen(flagbuf), "XA"); break; - case RQ_XB: sprintf(flagbuf + strlen(flagbuf), "XB"); break; - case RQ_XC: sprintf(flagbuf + strlen(flagbuf), "XC"); break; - case RQ_XP: sprintf(flagbuf + strlen(flagbuf), "XP"); break; - case RQ_XR: sprintf(flagbuf + strlen(flagbuf), "XR"); break; - case RQ_XW: sprintf(flagbuf + strlen(flagbuf), "XW"); break; - case RQ_XX: sprintf(flagbuf + strlen(flagbuf), "XX"); break; - } - - printf("Flags : %s\n", flagbuf); - - /* - * Show User flags - */ - flagbuf[0] = 0; - for (i = 0; nlent->uflags[i]; i++) { - sprintf(flagbuf + strlen(flagbuf), "%s,", nlent->uflags[i]); - } - if (strlen(flagbuf)) { - flagbuf[strlen(flagbuf) - 1] = 0; - printf("U-Flags : %s\n", flagbuf); - } - - /* - * Show P flags - */ - printf("P Flag :"); - if (nlent->pflag & 0x01) - printf(" Down"); - if (nlent->pflag & 0x02) - printf(" Hold"); - if (nlent->pflag & 0x04) - printf(" Pvt"); - if (nlent->pflag & 0x10) - printf(" ISDN"); - if (nlent->pflag & 0x20) - printf(" TCP/IP"); - printf("\n"); - if (nlent->t1) { - printf("System open : "); - t = toupper(nlent->t1); - printf("%02d:", t - 65); - if (isupper(nlent->t1)) - printf("00 - "); - else - printf("30 - "); - t = toupper(nlent->t2); - printf("%02d:", t - 65); - if (isupper(nlent->t2)) - printf("00\n"); - else - printf("30\n"); - } - printf("Uplink : %u/%u\n", nlent->upnet, nlent->upnode); - printf("Region : %u\n", nlent->region); + /* + * Show User flags + */ + flagbuf[0] = 0; + for (i = 0; nlent->uflags[i]; i++) { + sprintf(flagbuf + strlen(flagbuf), "%s,", nlent->uflags[i]); + } + if (strlen(flagbuf)) { + flagbuf[strlen(flagbuf) - 1] = 0; + printf("U-Flags : %s\n", flagbuf); } - if (nlent->addr.domain) - free(nlent->addr.domain); + /* + * Show P flags + */ + printf("P Flag :"); + if (nlent->pflag & 0x01) + printf(" Down"); + if (nlent->pflag & 0x02) + printf(" Hold"); + if (nlent->pflag & 0x04) + printf(" Pvt"); + if (nlent->pflag & 0x10) + printf(" ISDN"); + if (nlent->pflag & 0x20) + printf(" TCP/IP"); + printf("\n"); + if (nlent->t1) { + printf("System open : "); + t = toupper(nlent->t1); + printf("%02d:", t - 65); + if (isupper(nlent->t1)) + printf("00 - "); + else + printf("30 - "); + t = toupper(nlent->t2); + printf("%02d:", t - 65); + if (isupper(nlent->t2)) + printf("00\n"); + else + printf("30\n"); + } + printf("Uplink : %u/%u\n", nlent->upnet, nlent->upnode); + printf("Region : %u\n", nlent->region); + printf("URL : %s\n", printable(nlent->url, 0)); + } - return 0; + if (nlent->addr.domain) + free(nlent->addr.domain); + + return 0; } diff --git a/mbcico/outstat.c b/mbcico/outstat.c index ef61dca8..f034862b 100644 --- a/mbcico/outstat.c +++ b/mbcico/outstat.c @@ -364,78 +364,82 @@ int IsZMH() int poll(faddr *addr, int stop) { - char *pol; - int rc = 0; - FILE *fp; - callstat *cst; - node *nlent; - - if (addr == NULL) - return 0; - - pol = polname(addr); - - if (stop) { - if (access(pol, R_OK) == 0) { - rc = unlink(pol); - if (rc == 0) { - Syslog('+', "Removed poll for %s", ascfnode(addr, 0x1f)); - if (!do_quiet) - printf("Removed poll for %s\n", ascfnode(addr, 0x1f)); - } - } else { - Syslog('+', "No poll found for %s", ascfnode(addr, 0x1f)); - } - } else { - nlent = getnlent(addr); - if (nlent->pflag == NL_DUMMY) { - Syslog('+', "Node %s not in nodelist", ascfnode(addr, 0x1f)); - if (!do_quiet) - printf("Node %s not in nodelist", ascfnode(addr, 0x1f)); - return MBERR_NODE_NOT_IN_LIST; - } - if (nlent->pflag == NL_DOWN) { - Syslog('+', "Node %s has status Down", ascfnode(addr, 0x1f)); - if (!do_quiet) - printf("Node %s has status Down", ascfnode(addr, 0x1f)); - return MBERR_NODE_MAY_NOT_CALL; - } - if (nlent->pflag == NL_HOLD) { - Syslog('+', "Node %s has status Hold", ascfnode(addr, 0x1f)); - if (!do_quiet) - printf("Node %s has status Hold", ascfnode(addr, 0x1f)); - return MBERR_NODE_MAY_NOT_CALL; - } - - if ((fp = fopen(pol, "w+")) == NULL) { - WriteError("$Can't create poll for %s", ascfnode(addr, 0x1f)); - rc = MBERR_CANNOT_MAKE_POLL; - } else { - fclose(fp); - if (((nlent->oflags & OL_CM) == 0) && (!IsZMH())) { - Syslog('+', "Created poll for %s, non-CM node outside ZMH", ascfnode(addr, 0x1f)); - if (!do_quiet) - printf("Created poll for %s, non-CM node outside ZMH\n", ascfnode(addr, 0x1f)); - } else { - Syslog('+', "Created poll for %s", ascfnode(addr, 0x1f)); - if (!do_quiet) - printf("Created poll for %s\n", ascfnode(addr, 0x1f)); - } - cst = getstatus(addr); - if ((cst->trystat == MBERR_NODE_LOCKED) || - (cst->trystat == MBERR_NOT_ZMH) || - (cst->trystat == MBERR_NO_CONNECTION) || - (cst->trystat == MBERR_SESSION_ERROR) || - (cst->trystat == MBERR_UNKNOWN_SESSION) || - (cst->trystat == MBERR_NO_PORT_AVAILABLE) || - (cst->trystat == MBERR_MODEM_ERROR)) { - putstatus(addr, 0, 0); - } - CreateSema((char *)"scanout"); - } - } - + char *pol; + int rc = 0; + unsigned long cmmask; + FILE *fp; + callstat *cst; + node *nlent; + + if (addr == NULL) return 0; + + pol = polname(addr); + + if (stop) { + if (access(pol, R_OK) == 0) { + rc = unlink(pol); + if (rc == 0) { + Syslog('+', "Removed poll for %s", ascfnode(addr, 0x1f)); + if (!do_quiet) + printf("Removed poll for %s\n", ascfnode(addr, 0x1f)); + } + CreateSema((char *)"scanout"); + } else { + Syslog('+', "No poll found for %s", ascfnode(addr, 0x1f)); + } + } else { + nlent = getnlent(addr); + if (nlent->pflag == NL_DUMMY) { + Syslog('+', "Node %s not in nodelist", ascfnode(addr, 0x1f)); + if (!do_quiet) + printf("Node %s not in nodelist", ascfnode(addr, 0x1f)); + return MBERR_NODE_NOT_IN_LIST; + } + if (nlent->pflag == NL_DOWN) { + Syslog('+', "Node %s has status Down", ascfnode(addr, 0x1f)); + if (!do_quiet) + printf("Node %s has status Down", ascfnode(addr, 0x1f)); + return MBERR_NODE_MAY_NOT_CALL; + } + if (nlent->pflag == NL_HOLD) { + Syslog('+', "Node %s has status Hold", ascfnode(addr, 0x1f)); + if (!do_quiet) + printf("Node %s has status Hold", ascfnode(addr, 0x1f)); + return MBERR_NODE_MAY_NOT_CALL; + } + + if ((fp = fopen(pol, "w+")) == NULL) { + WriteError("$Can't create poll for %s", ascfnode(addr, 0x1f)); + rc = MBERR_CANNOT_MAKE_POLL; + } else { + fclose(fp); + cmmask = getCMmask(); + Syslog('s', "oflags %08x cmmask %08x", nlent->oflags, cmmask); + if (((nlent->oflags & cmmask) == 0) && (!IsZMH())) { + Syslog('+', "Created poll for %s, non-CM node outside ZMH", ascfnode(addr, 0x1f)); + if (!do_quiet) + printf("Created poll for %s, non-CM node outside ZMH\n", ascfnode(addr, 0x1f)); + } else { + Syslog('+', "Created poll for %s", ascfnode(addr, 0x1f)); + if (!do_quiet) + printf("Created poll for %s\n", ascfnode(addr, 0x1f)); + } + cst = getstatus(addr); + if ((cst->trystat == MBERR_NODE_LOCKED) || + (cst->trystat == MBERR_NOT_ZMH) || + (cst->trystat == MBERR_NO_CONNECTION) || + (cst->trystat == MBERR_SESSION_ERROR) || + (cst->trystat == MBERR_UNKNOWN_SESSION) || + (cst->trystat == MBERR_NO_PORT_AVAILABLE) || + (cst->trystat == MBERR_MODEM_ERROR)) { + putstatus(addr, 0, 0); + } + CreateSema((char *)"scanout"); + } + } + + return 0; } diff --git a/mbcico/rdoptions.c b/mbcico/rdoptions.c index 76ba8c06..a40b7ced 100644 --- a/mbcico/rdoptions.c +++ b/mbcico/rdoptions.c @@ -55,9 +55,6 @@ static struct _ktab { {(char *)"Zmodem", NOZMODEM}, {(char *)"ZedZap", NOZEDZAP}, {(char *)"Hydra", NOHYDRA}, - {(char *)"IBN", NOIBN}, - {(char *)"ITN", NOITN}, - {(char *)"IFC", NOIFC}, {NULL, 0} }; @@ -98,12 +95,6 @@ void rdoptions(int Loaded) localoptions |= NOZEDZAP; if (CFG.NoHydra) localoptions |= NOHYDRA; - if (CFG.NoIBN) - localoptions |= NOIBN; - if (CFG.NoITN) - localoptions |= NOITN; - if (CFG.NoIFC) - localoptions |= NOIFC; if (nodes.Aka[0].zone == 0) { if (Loaded) @@ -128,13 +119,6 @@ void rdoptions(int Loaded) localoptions |= NOZEDZAP; if (nodes.NoHydra) localoptions |= NOHYDRA; - if (nodes.NoIBN) - localoptions |= NOIBN; - if (nodes.NoITN) - localoptions |= NOITN; - if (nodes.NoIFC) - localoptions |= NOIFC; - logoptions(); } diff --git a/mbcico/session.h b/mbcico/session.h index e4b24031..20d30df7 100644 --- a/mbcico/session.h +++ b/mbcico/session.h @@ -60,9 +60,6 @@ extern int localoptions; #define NOZEDZAP 0x0080 #define NOJANUS 0x0100 #define NOHYDRA 0x0200 -#define NOIBN 0x0400 -#define NOITN 0x0800 -#define NOIFC 0x1000 struct _history history; /* History record for sessions */ diff --git a/mbsebbs/mail.c b/mbsebbs/mail.c index 68d1e498..dd67dc65 100644 --- a/mbsebbs/mail.c +++ b/mbsebbs/mail.c @@ -188,45 +188,47 @@ int Alias_Option(void) int Crash_Option(faddr *); int Crash_Option(faddr *Dest) { - node *Nlent; - int rc = 0; - unsigned short point; + node *Nlent; + int rc = 0; + unsigned short point; + unsigned long cmmask; - if (exitinfo.Security.level < CFG.iCrashLevel) - return 0; + if (exitinfo.Security.level < CFG.iCrashLevel) + return 0; - point = Dest->point; - Dest->point = 0; + cmmask = getCMmask(); + point = Dest->point; + Dest->point = 0; - if (((Nlent = getnlent(Dest)) != NULL) && (Nlent->addr.zone)) { - if (Nlent->oflags & OL_CM) { - /* Crash [y/N]: */ - pout(CYAN, BLACK, (char *)Language(461)); - colour(CFG.MsgInputColourF, CFG.MsgInputColourB); - fflush(stdout); - alarm_on(); - if (toupper(Getone()) == Keystroke(461, 0)) { - rc = 1; - printf("%c", Keystroke(461, 0)); - } else - printf("%c", Keystroke(461, 1)); - } else { - /* Warning: node is not CM, send Immediate [y/N]: */ - pout(CYAN, BLACK, (char *)Language(462)); - colour(CFG.MsgInputColourF, CFG.MsgInputColourB); - fflush(stdout); - alarm_on(); - if (toupper(Getone()) == Keystroke(462, 0)) { - rc = 2; - printf("%c", Keystroke(462, 0)); - } else - printf("%c", Keystroke(462, 1)); - } - fflush(stdout); + if (((Nlent = getnlent(Dest)) != NULL) && (Nlent->addr.zone)) { + if (Nlent->oflags & cmmask) { + /* Crash [y/N]: */ + pout(CYAN, BLACK, (char *)Language(461)); + colour(CFG.MsgInputColourF, CFG.MsgInputColourB); + fflush(stdout); + alarm_on(); + if (toupper(Getone()) == Keystroke(461, 0)) { + rc = 1; + printf("%c", Keystroke(461, 0)); + } else + printf("%c", Keystroke(461, 1)); + } else { + /* Warning: node is not CM, send Immediate [y/N]: */ + pout(CYAN, BLACK, (char *)Language(462)); + colour(CFG.MsgInputColourF, CFG.MsgInputColourB); + fflush(stdout); + alarm_on(); + if (toupper(Getone()) == Keystroke(462, 0)) { + rc = 2; + printf("%c", Keystroke(462, 0)); + } else + printf("%c", Keystroke(462, 1)); } + fflush(stdout); + } - Dest->point = point; - return rc; + Dest->point = point; + return rc; } diff --git a/mbsetup/m_global.c b/mbsetup/m_global.c index 470920df..0f0ac9d8 100644 --- a/mbsetup/m_global.c +++ b/mbsetup/m_global.c @@ -1351,9 +1351,6 @@ void s_mailer(void) mvprintw(12,31, "12. No Zmodem"); mvprintw(13,31, "13. No Zedzap"); mvprintw(14,31, "14. No Hydra"); - mvprintw(15,31, "15. No IBN binkp"); - mvprintw(16,31, "16. No IFC ifcico"); - mvprintw(17,31, "17. No ITN telnet"); mvprintw(12,59, "18. Phonetrans 1-10"); mvprintw(13,59, "19. Phonetrans 11-20"); @@ -1418,9 +1415,6 @@ void e_mailer(void) show_bool(12,52, CFG.NoZmodem); show_bool(13,52, CFG.NoZedzap); show_bool(14,52, CFG.NoHydra); - show_bool(15,52, CFG.NoIBN); - show_bool(16,52, CFG.NoIFC); - show_bool(17,52, CFG.NoITN); show_int( 16,75, CFG.Req_Files); show_int( 17,75, CFG.Req_MBytes); @@ -1442,9 +1436,6 @@ void e_mailer(void) case 12:E_BOOL(12,52, CFG.NoZmodem, "If set then the ^Zmodem^ protocol is disabled") case 13:E_BOOL(13,52, CFG.NoZedzap, "If set then the ^Zedzap^ protocol is disabled") case 14:E_BOOL(14,52, CFG.NoHydra, "If set then the ^Hydra^ protocol is disabled") - case 15:E_BOOL(15,52, CFG.NoIBN, "If set then the ^TCP/IP IBN binkp^ protocol is disabled") - case 16:E_BOOL(16,52, CFG.NoIFC, "If set then the ^TCP/IP IFC ifcico^ protocol is disabled") - case 17:E_BOOL(17,52, CFG.NoITN, "If set then the ^TCP/IP ITN telnet^ protocol is disabled") case 18:e_trans(0); break; @@ -2106,9 +2097,6 @@ int global_doc(FILE *fp, FILE *toc, int page) fprintf(fp, " No Zmodem %s\n", getboolean(CFG.NoZmodem)); fprintf(fp, " No Zedzap %s\n", getboolean(CFG.NoZedzap)); fprintf(fp, " No Hydra %s\n", getboolean(CFG.NoHydra)); - fprintf(fp, " No TCP/IP IBN %s\n", getboolean(CFG.NoIBN)); - fprintf(fp, " No TCP/IP IFC %s\n", getboolean(CFG.NoIFC)); - fprintf(fp, " No TCP/IP ITN %s\n", getboolean(CFG.NoITN)); fprintf(fp, " Max request files %d\n", CFG.Req_Files); fprintf(fp, " Max request MBytes %d\n", CFG.Req_MBytes); diff --git a/mbsetup/m_node.c b/mbsetup/m_node.c index 715dcd0d..ab4d563c 100644 --- a/mbsetup/m_node.c +++ b/mbsetup/m_node.c @@ -802,9 +802,6 @@ void SessionScreen(void) mvprintw(14,41, "14. No Zmodem"); mvprintw(15,41, "15. No Zedzap"); mvprintw(16,41, "16. No Hydra"); - mvprintw(17,41, "17. No TCP/IP IBN"); - mvprintw(18,41, "18. No TCP/IP IFC"); - mvprintw(19,41, "19. No TCP/IP ITN"); } @@ -833,11 +830,8 @@ void SessionEdit(void) show_bool(14,61, nodes.NoZmodem); show_bool(15,61, nodes.NoZedzap); show_bool(16,61, nodes.NoHydra); - show_bool(17,61, nodes.NoIBN); - show_bool(18,61, nodes.NoIFC); - show_bool(19,61, nodes.NoITN); - switch(select_menu(19)) { + switch(select_menu(16)) { case 0: return; case 1: E_STR( 7,26,15, nodes.Spasswd, "The ^Session password^ for this node") case 2: E_STR( 8,26,40, nodes.dial, "If needed, give a special modem ^dial command^ for this node") @@ -858,9 +852,6 @@ void SessionEdit(void) case 14:E_BOOL(14,61, nodes.NoZmodem, "Disable ^Zmodem^ protocol with this node") case 15:E_BOOL(15,61, nodes.NoZedzap, "Disable ^Zedzap^ protocol with this node") case 16:E_BOOL(16,61, nodes.NoHydra, "Disable ^Hydra^ protocol with this node") - case 17:E_BOOL(17,61, nodes.NoIBN, "Disable ^TCP/IP IBN binkp^ protocol with this node") - case 18:E_BOOL(18,61, nodes.NoIFC, "Disable ^TCP/IP IFC ifcico^ protocol with this node") - case 19:E_BOOL(19,61, nodes.NoITN, "Disable ^TCP/IP ITN telnet^ protocol with this node") } } } @@ -1483,9 +1474,6 @@ int node_doc(FILE *fp, FILE *toc, int page) fprintf(fp, " No Zmodem %s\n", getboolean(nodes.NoZmodem)); fprintf(fp, " No Zedzap %s", getboolean(nodes.NoZedzap)); fprintf(fp, " No Hydra %s", getboolean(nodes.NoHydra)); - fprintf(fp, " No TCP/IP IBN %s\n", getboolean(nodes.NoIBN)); - fprintf(fp, " No TCP/IP IFC %s", getboolean(nodes.NoIFC)); - fprintf(fp, " No TCP/IP ITN %s", getboolean(nodes.NoITN)); fprintf(fp, " Mail forward %s\n", getboolean(nodes.MailFwd)); fprintf(fp, " Check mailpwd %s", getboolean(nodes.MailPwdCheck)); fprintf(fp, " ARCmail comp. %s", getboolean(nodes.ARCmailCompat)); diff --git a/mbtask/mbtask.c b/mbtask/mbtask.c index d3a31cec..53b9f22d 100644 --- a/mbtask/mbtask.c +++ b/mbtask/mbtask.c @@ -591,6 +591,13 @@ int checktasks(int onsig) if (task[i].tasktype == CM_POTS || task[i].tasktype == CM_ISDN || task[i].tasktype == CM_INET) rescan = TRUE; ptimer = PAUSETIME; + /* + * If a nodelist compiler is ready, reload the nodelists configuration + */ + if (task[i].tasktype == MBINDEX) { + deinitnl(); + initnl(); + } } if (first && task[i].rc) { @@ -699,6 +706,7 @@ void die(int onsig) else Syslog('+', "Good, no more tasks running"); + deinitnl(); ulocktask(); if (sock != -1) close(sock); @@ -1034,6 +1042,8 @@ void scheduler(void) Syslog('+', "Ports configuration changed, reloading"); load_ports(); check_ports(); + deinitnl(); + initnl(); sem_set((char *)"scanout", TRUE); } @@ -1305,8 +1315,8 @@ int main(int argc, char **argv) memset(®info, 0, sizeof(reginfo)); memset(&calllist, 0, sizeof(calllist)); sprintf(spath, "%s/tmp/mbtask", getenv("MBSE_ROOT")); - sprintf(ttyfn, "%s/etc/ttyinfo.data", getenv("MBSE_ROOT")); + initnl(); load_ports(); check_ports(); diff --git a/mbtask/outstat.c b/mbtask/outstat.c index 509d456d..73894e7d 100644 --- a/mbtask/outstat.c +++ b/mbtask/outstat.c @@ -202,7 +202,18 @@ int outstat() struct dirent *de; struct stat sb; struct passwd *pw; + unsigned long cmmask, ibnmask = 0, ifcmask = 0, itnmask = 0; + nodelist_modem **tmpm; + cmmask = getCMmask(); + for (tmpm = &nl_tcpip; *tmpm; tmpm=&((*tmpm)->next)) { + if (strcmp((*tmpm)->name, "IBN") == 0) + ibnmask = (*tmpm)->mask; + if (strcmp((*tmpm)->name, "IFC") == 0) + ifcmask = (*tmpm)->mask; + if (strcmp((*tmpm)->name, "ITN") == 0) + itnmask = (*tmpm)->mask; + } now = time(NULL); tm = gmtime(&now); /* UTC time */ uhour = tm->tm_hour; @@ -406,9 +417,9 @@ int outstat() * If the node has internet and we have internet configured, * check if we can send immediatly. */ - if (TCFG.max_tcp && (tmp->olflags & OL_CM) && + if (TCFG.max_tcp && (tmp->olflags & cmmask) && (((tmp->flavors) & F_IMM) || ((tmp->flavors) & F_CRASH) || ((tmp->flavors) & F_NORMAL)) && - ((tmp->ipflags & IP_IBN) || (tmp->ipflags & IP_IFC) || (tmp->ipflags & IP_ITN))) { + ((tmp->ipflags & ibnmask) || (tmp->ipflags & ifcmask) || (tmp->ipflags & itnmask))) { tmp->flavors |= F_CALL; } @@ -417,7 +428,7 @@ int outstat() /* * Immediate mail, send if node is CM or is in a Txx window or is in ZMH. */ - if ((tmp->olflags & OL_CM) || T_window || iszmh) { + if ((tmp->olflags & cmmask) || T_window || iszmh) { tmp->flavors |= F_CALL; } } @@ -427,7 +438,7 @@ int outstat() /* * Crash mail, send if node is CM or is in a Txx window or is in ZMH. */ - if ((tmp->olflags & OL_CM) || T_window || iszmh) { + if ((tmp->olflags & cmmask) || T_window || iszmh) { tmp->flavors |= F_CALL; } } @@ -480,8 +491,7 @@ int outstat() if ((tmp->flavors) & F_CALL) { tmp->callmode = CM_NONE; - if (TCFG.max_tcp && !(nodes.NoIBN && nodes.NoIFC && nodes.NoITN) && - ((tmp->ipflags & IP_IBN) || (tmp->ipflags & IP_IFC) || (tmp->ipflags & IP_ITN))) { + if (TCFG.max_tcp && ((tmp->ipflags & ibnmask) || (tmp->ipflags & ifcmask) || (tmp->ipflags & itnmask))) { inet_calls++; tmp->callmode = CM_INET; } diff --git a/mbtask/ports.c b/mbtask/ports.c index b3f03ae4..0fec3b39 100644 --- a/mbtask/ports.c +++ b/mbtask/ports.c @@ -109,11 +109,12 @@ void fill_portlist(pp_list **fdp, pp_list *new) */ void load_ports() { - FILE *fp; - pp_list new; - int j, stdflag; - char *p, *q; - + FILE *fp; + pp_list new; + int stdflag; + char *p, *q; + nodelist_modem **tmpm; + tidy_portlist(&pl); if ((fp = fopen(ttyfn, "r")) == NULL) { Syslog('?', "$Can't open %s", ttyfn); @@ -142,12 +143,12 @@ void load_ports() if ((strncasecmp(p, "U", 1) == 0) && (strlen(p) == 1)) { stdflag = FALSE; } else { - for (j = 0; fkey[j].key; j++) - if (strcasecmp(p, fkey[j].key) == 0) - new.mflags |= fkey[j].flag; - for (j = 0; dkey[j].key; j++) - if (strcasecmp(p, dkey[j].key) == 0) - new.dflags |= dkey[j].flag; + for (tmpm = &nl_pots; *tmpm; tmpm=&((*tmpm)->next)) + if (strcasecmp(p, (*tmpm)->name) == 0) + new.mflags |= (*tmpm)->value; + for (tmpm = &nl_isdn; *tmpm; tmpm=&((*tmpm)->next)) + if (strcasecmp(p, (*tmpm)->name) == 0) + new.dflags |= (*tmpm)->value; } }