2001-08-17 05:46:24 +00:00
|
|
|
/*****************************************************************************
|
2001-12-27 16:59:29 +00:00
|
|
|
*
|
|
|
|
* $Id$
|
2001-08-17 05:46:24 +00:00
|
|
|
* Purpose ...............: Read nodelists information
|
|
|
|
*
|
|
|
|
*****************************************************************************
|
2002-01-07 19:16:03 +00:00
|
|
|
* Copyright (C) 1997-2002
|
2001-08-17 05:46:24 +00:00
|
|
|
*
|
|
|
|
* Michiel Broek FIDO: 2:280/2802
|
|
|
|
* Beekmansbos 10
|
|
|
|
* 1971 BV IJmuiden
|
|
|
|
* the Netherlands
|
|
|
|
*
|
|
|
|
* This file is part of MBSE BBS.
|
|
|
|
*
|
|
|
|
* This BBS is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2, or (at your option) any
|
|
|
|
* later version.
|
|
|
|
*
|
|
|
|
* MBSE BBS is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with MBSE BBS; see the file COPYING. If not, write to the Free
|
2003-08-15 20:05:34 +00:00
|
|
|
* Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
2001-08-17 05:46:24 +00:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2002-06-30 12:48:44 +00:00
|
|
|
#include "../config.h"
|
2004-02-21 14:24:03 +00:00
|
|
|
#include "mbselib.h"
|
2002-12-28 17:29:06 +00:00
|
|
|
#include "nodelist.h"
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
|
|
|
|
#define NULLDOMAIN "nulldomain"
|
|
|
|
|
|
|
|
|
2002-12-30 22:13:33 +00:00
|
|
|
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**);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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},
|
2004-07-11 11:49:51 +00:00
|
|
|
{(char *)"ipprefix", getarr, (char **)&nl_ipprefix},
|
2002-12-30 22:13:33 +00:00
|
|
|
{(char *)"domsuffix", getdom, (char **)&nl_domsuffix},
|
|
|
|
{(char *)"service", getsrv, (char **)&nl_service},
|
|
|
|
{NULL, NULL, NULL}
|
2001-08-17 05:46:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-12-30 22:13:33 +00:00
|
|
|
/*
|
|
|
|
* 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;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-12-30 22:13:33 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-12-30 22:13:33 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
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);
|
|
|
|
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);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-12-30 22:13:33 +00:00
|
|
|
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;
|
|
|
|
return 0;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-12-30 22:13:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
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);
|
2004-07-11 11:49:51 +00:00
|
|
|
tidy_nl_array(&nl_ipprefix);
|
2002-12-30 22:13:33 +00:00
|
|
|
tidy_nl_domsuf(&nl_domsuffix);
|
|
|
|
tidy_nl_service(&nl_service);
|
|
|
|
|
2003-08-24 12:26:34 +00:00
|
|
|
Syslog('n', "De-init nodelists done");
|
2002-12-30 22:13:33 +00:00
|
|
|
nlinitdone = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Init nodelists.
|
|
|
|
*/
|
2001-08-17 05:46:24 +00:00
|
|
|
int initnl(void)
|
|
|
|
{
|
2002-12-30 22:13:33 +00:00
|
|
|
int i, rc = 0, Found;
|
|
|
|
FILE *dbf, *fp;
|
|
|
|
char *filexnm, buf[256], *p, *q;
|
|
|
|
struct _nlfil fdx;
|
|
|
|
struct taskrec TCFG;
|
|
|
|
nodelist_modem **tmpm;
|
|
|
|
|
|
|
|
if (nlinitdone == TRUE)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
nl_online = NULL;
|
|
|
|
nl_pots = NULL;
|
|
|
|
nl_request = NULL;
|
|
|
|
nl_reqbits = NULL;
|
|
|
|
nl_isdn = NULL;
|
|
|
|
nl_tcpip = NULL;
|
|
|
|
nl_search = NULL;
|
|
|
|
nl_domsuffix = NULL;
|
2004-07-11 11:49:51 +00:00
|
|
|
nl_ipprefix = NULL;
|
2002-12-30 22:13:33 +00:00
|
|
|
nl_dialer = NULL;
|
|
|
|
nl_service = NULL;
|
|
|
|
|
|
|
|
filexnm = xstrcpy(CFG.nodelists);
|
|
|
|
filexnm = xstrcat(filexnm,(char *)"/node.files");
|
|
|
|
nlpath = calloc(PATH_MAX, sizeof(char));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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);
|
|
|
|
}
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-12-30 22:13:33 +00:00
|
|
|
fclose(dbf);
|
|
|
|
}
|
|
|
|
free(filexnm);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-12-30 22:13:33 +00:00
|
|
|
/*
|
|
|
|
* 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 == '#')) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-12-30 22:13:33 +00:00
|
|
|
/*
|
|
|
|
* Read all our TCP/IP capabilities and set the global flag.
|
|
|
|
*/
|
|
|
|
if (TCFG.max_tcp) {
|
2004-07-22 20:30:58 +00:00
|
|
|
sprintf(buf, "%s", CFG.IP_Flags);
|
2002-12-30 22:13:33 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-12-30 22:13:33 +00:00
|
|
|
fclose(fp);
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-12-30 22:13:33 +00:00
|
|
|
free(nlpath);
|
|
|
|
nlinitdone = TRUE;
|
|
|
|
return rc;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int comp_node(struct _nlidx, struct _ixentry);
|
|
|
|
int comp_node(struct _nlidx fap1, struct _ixentry fap2)
|
|
|
|
{
|
2002-12-30 22:13:33 +00:00
|
|
|
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);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
node *getnlent(faddr *addr)
|
|
|
|
{
|
2002-12-16 20:58:14 +00:00
|
|
|
FILE *fp, *np;
|
2002-07-13 12:58:35 +00:00
|
|
|
static node nodebuf;
|
2004-07-10 11:25:49 +00:00
|
|
|
static char buf[MAXNLLINELEN], ebuf[MAXNLLINELEN], *p, *q, tbuf[256];
|
2002-07-13 12:58:35 +00:00
|
|
|
struct _ixentry xaddr;
|
2002-12-30 22:13:33 +00:00
|
|
|
int i, Found = FALSE, ixflag, stdflag, ndrecord = FALSE;
|
2002-12-31 15:27:18 +00:00
|
|
|
char *mydomain, *path, *r;
|
2002-07-13 12:58:35 +00:00
|
|
|
struct _nlfil fdx;
|
|
|
|
struct _nlidx ndx;
|
|
|
|
long lowest, highest, current;
|
|
|
|
struct _nodeshdr ndhdr;
|
|
|
|
static struct _nodes nd;
|
2002-12-30 22:13:33 +00:00
|
|
|
nodelist_modem **tmpm;
|
|
|
|
nodelist_flag **tmpf;
|
|
|
|
nodelist_service **tmps;
|
2004-07-11 11:49:51 +00:00
|
|
|
nodelist_array **tmpa, **tmpaa;
|
2002-12-31 15:27:18 +00:00
|
|
|
nodelist_domsuf **tmpd;
|
2002-12-30 22:13:33 +00:00
|
|
|
unsigned long tport = 0;
|
|
|
|
|
2002-12-31 15:27:18 +00:00
|
|
|
Syslog('n', "getnlent: %s", ascfnode(addr,0xff));
|
2002-07-13 12:58:35 +00:00
|
|
|
|
|
|
|
mydomain = xstrcpy(CFG.aka[0].domain);
|
|
|
|
if (mydomain == NULL)
|
|
|
|
mydomain = (char *)NULLDOMAIN;
|
|
|
|
|
|
|
|
nodebuf.addr.domain = NULL;
|
|
|
|
nodebuf.addr.zone = 0;
|
|
|
|
nodebuf.addr.net = 0;
|
|
|
|
nodebuf.addr.node = 0;
|
|
|
|
nodebuf.addr.point = 0;
|
|
|
|
nodebuf.addr.name = NULL;
|
|
|
|
nodebuf.upnet = 0;
|
|
|
|
nodebuf.upnode = 0;
|
|
|
|
nodebuf.region = 0;
|
|
|
|
nodebuf.type = 0;
|
|
|
|
nodebuf.pflag = 0;
|
|
|
|
nodebuf.name = NULL;
|
|
|
|
nodebuf.location = NULL;
|
|
|
|
nodebuf.sysop = NULL;
|
|
|
|
nodebuf.phone = NULL;
|
|
|
|
nodebuf.speed = 0;
|
|
|
|
nodebuf.mflags = 0L;
|
|
|
|
nodebuf.oflags = 0L;
|
|
|
|
nodebuf.xflags = 0L;
|
|
|
|
nodebuf.iflags = 0L;
|
|
|
|
nodebuf.dflags = 0L;
|
|
|
|
nodebuf.uflags[0] = NULL;
|
2002-12-30 22:13:33 +00:00
|
|
|
nodebuf.t1 = '\0';
|
|
|
|
nodebuf.t2 = '\0';
|
|
|
|
nodebuf.url = NULL;
|
|
|
|
|
2002-07-13 12:58:35 +00:00
|
|
|
if (addr == NULL)
|
|
|
|
goto retdummy;
|
|
|
|
|
|
|
|
if (addr->zone == 0)
|
|
|
|
addr->zone = CFG.aka[0].zone;
|
|
|
|
xaddr.zone = addr->zone;
|
|
|
|
nodebuf.addr.zone = addr->zone;
|
|
|
|
xaddr.net = addr->net;
|
|
|
|
nodebuf.addr.net = addr->net;
|
|
|
|
xaddr.node = addr->node;
|
|
|
|
nodebuf.addr.node = addr->node;
|
|
|
|
xaddr.point = addr->point;
|
|
|
|
nodebuf.addr.point = addr->point;
|
|
|
|
|
|
|
|
if (initnl())
|
|
|
|
goto retdummy;
|
|
|
|
|
|
|
|
/*
|
2003-02-06 20:06:07 +00:00
|
|
|
* Search domainname for the requested aka, should not fail.
|
2002-07-13 12:58:35 +00:00
|
|
|
*/
|
|
|
|
path = calloc(PATH_MAX, sizeof(char));
|
2003-02-06 20:06:07 +00:00
|
|
|
sprintf(path, "%s/etc/fidonet.data", getenv("MBSE_ROOT"));
|
|
|
|
if ((fp = fopen(path, "r"))) {
|
|
|
|
fread(&fidonethdr, sizeof(fidonethdr), 1, fp);
|
|
|
|
while (fread(&fidonet, fidonethdr.recsize, 1, fp) == 1) {
|
|
|
|
for (i = 0; i < 6; i++) {
|
2003-02-08 14:21:33 +00:00
|
|
|
if (addr->zone == fidonet.zone[i]) {
|
2003-02-06 20:06:07 +00:00
|
|
|
nodebuf.addr.domain = xstrcpy(fidonet.domain);
|
2003-02-08 14:21:33 +00:00
|
|
|
Found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2003-02-06 20:06:07 +00:00
|
|
|
}
|
2003-02-08 14:21:33 +00:00
|
|
|
if (Found)
|
|
|
|
break;
|
2003-02-06 20:06:07 +00:00
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
}
|
2003-02-08 14:21:33 +00:00
|
|
|
Found = FALSE;
|
2003-02-06 20:06:07 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* First, lookup node in index. NOTE -- NOT 5D YET
|
|
|
|
*/
|
2002-07-13 12:58:35 +00:00
|
|
|
sprintf(path, "%s/%s", CFG.nodelists, "node.index");
|
|
|
|
if ((fp = fopen(path, "r")) == NULL) {
|
|
|
|
WriteError("$Can't open %s", path);
|
|
|
|
free(path);
|
|
|
|
goto retdummy;
|
|
|
|
}
|
|
|
|
|
|
|
|
fseek(fp, 0, SEEK_END);
|
|
|
|
highest = ftell(fp) / sizeof(ndx);
|
|
|
|
lowest = 0;
|
|
|
|
|
|
|
|
while (TRUE) {
|
|
|
|
current = ((highest - lowest) / 2) + lowest;
|
|
|
|
fseek(fp, current * sizeof(ndx), SEEK_SET);
|
|
|
|
if (fread(&ndx, sizeof(ndx), 1, fp) != 1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (comp_node(ndx, xaddr) == 0) {
|
|
|
|
Found = TRUE;
|
|
|
|
break;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-07-13 12:58:35 +00:00
|
|
|
if (comp_node(ndx, xaddr) < 0)
|
|
|
|
lowest = current;
|
|
|
|
else
|
|
|
|
highest = current;
|
|
|
|
if ((highest - lowest) <= 1)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fclose(fp);
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-07-13 12:58:35 +00:00
|
|
|
if (!Found) {
|
|
|
|
free(path);
|
|
|
|
goto retdummy;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-07-13 12:58:35 +00:00
|
|
|
sprintf(path, "%s/%s", CFG.nodelists, "node.files");
|
|
|
|
if ((fp = fopen(path, "r")) == NULL) {
|
|
|
|
WriteError("$Can't open %s", path);
|
|
|
|
free(path);
|
|
|
|
goto retdummy;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get filename from node.files
|
|
|
|
*/
|
|
|
|
for (i = 0; i < (ndx.fileno +1); i++)
|
|
|
|
fread(&fdx, sizeof(fdx), 1, fp);
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
/* CHECK DOMAIN HERE */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Open and read in real nodelist
|
|
|
|
*/
|
|
|
|
sprintf(path, "%s/%s", CFG.nodelists, fdx.filename);
|
|
|
|
if ((fp = fopen(path, "r")) == NULL) {
|
|
|
|
WriteError("$Can't open %s", path);
|
|
|
|
free(path);
|
|
|
|
goto retdummy;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-07-13 12:58:35 +00:00
|
|
|
if (fseek(fp, ndx.offset, SEEK_SET) != 0) {
|
|
|
|
WriteError("$Seek failed for nodelist entry");
|
2001-08-17 05:46:24 +00:00
|
|
|
fclose(fp);
|
2002-07-13 12:58:35 +00:00
|
|
|
goto retdummy;
|
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
|
2002-07-13 12:58:35 +00:00
|
|
|
if (fgets(buf, sizeof(buf)-1, fp) == NULL) {
|
|
|
|
WriteError("$fgets failed for nodelist entry");
|
2001-08-17 05:46:24 +00:00
|
|
|
fclose(fp);
|
2002-07-13 12:58:35 +00:00
|
|
|
goto retdummy;
|
|
|
|
}
|
2002-12-31 15:27:18 +00:00
|
|
|
Syslog('n', "getnlent: %s", buf);
|
2002-07-13 12:58:35 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Load noderecord if this node has one, if there is one then
|
|
|
|
* nodelist overrides in this record will be used instead of
|
|
|
|
* the nodelist entries.
|
|
|
|
*/
|
|
|
|
sprintf(path, "%s/etc/nodes.data", getenv("MBSE_ROOT"));
|
2002-12-16 20:58:14 +00:00
|
|
|
if ((np = fopen(path, "r")) != NULL) {
|
|
|
|
fread(&ndhdr, sizeof(nodeshdr), 1, np);
|
2002-07-13 12:58:35 +00:00
|
|
|
|
2002-12-16 20:58:14 +00:00
|
|
|
while (fread(&nd, ndhdr.recsize, 1, np) == 1) {
|
|
|
|
fseek(np, ndhdr.filegrp + ndhdr.mailgrp, SEEK_CUR);
|
2002-07-13 12:58:35 +00:00
|
|
|
for (i = 0; i < 20; i++) {
|
|
|
|
if ((addr->zone == nd.Aka[i].zone) && (addr->net == nd.Aka[i].net) &&
|
|
|
|
(addr->node == nd.Aka[i].node) && (addr->point == nd.Aka[i].point)) {
|
|
|
|
ndrecord = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (ndrecord)
|
|
|
|
break;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
2002-12-16 20:58:14 +00:00
|
|
|
fclose(np);
|
2002-07-13 12:58:35 +00:00
|
|
|
}
|
|
|
|
free(path);
|
|
|
|
|
|
|
|
nodebuf.type = ndx.type;
|
|
|
|
nodebuf.pflag = ndx.pflag;
|
|
|
|
|
|
|
|
if (*(p = buf + strlen(buf) -1) == '\n')
|
|
|
|
*p = '\0';
|
|
|
|
if (*(p = buf + strlen(buf) -1) == '\r')
|
|
|
|
*p = '\0';
|
|
|
|
for (p = buf; *p; p++)
|
|
|
|
if (*p == '_')
|
|
|
|
*p = ' ';
|
|
|
|
|
|
|
|
p = buf;
|
|
|
|
|
|
|
|
if ((q = strchr(p,',')))
|
|
|
|
*q++ = '\0';
|
|
|
|
|
|
|
|
p = q;
|
2002-12-16 20:58:14 +00:00
|
|
|
if (p == NULL) {
|
|
|
|
fclose(fp);
|
2002-07-13 12:58:35 +00:00
|
|
|
goto badsyntax;
|
2002-12-16 20:58:14 +00:00
|
|
|
}
|
|
|
|
|
2002-07-13 12:58:35 +00:00
|
|
|
if ((q=strchr(p,',')))
|
|
|
|
*q++ = '\0';
|
|
|
|
p = q;
|
2002-12-16 20:58:14 +00:00
|
|
|
if (p == NULL) {
|
|
|
|
fclose(fp);
|
2002-07-13 12:58:35 +00:00
|
|
|
goto badsyntax;
|
2002-12-16 20:58:14 +00:00
|
|
|
}
|
|
|
|
|
2002-07-13 12:58:35 +00:00
|
|
|
/*
|
|
|
|
* Get system name
|
|
|
|
*/
|
|
|
|
if ((q=strchr(p,',')))
|
|
|
|
*q++ = '\0';
|
|
|
|
if (ndrecord && strlen(nd.Nl_hostname)) {
|
2003-02-08 14:21:33 +00:00
|
|
|
Syslog('+', "getnlent: %s system name override with %s", ascfnode(addr,0xff), nd.Nl_hostname);
|
2002-07-13 12:58:35 +00:00
|
|
|
nodebuf.name = nd.Nl_hostname;
|
|
|
|
} else
|
2001-08-17 05:46:24 +00:00
|
|
|
nodebuf.name = p;
|
2002-07-13 12:58:35 +00:00
|
|
|
p = q;
|
2002-12-16 20:58:14 +00:00
|
|
|
if (p == NULL) {
|
|
|
|
fclose(fp);
|
2002-07-13 12:58:35 +00:00
|
|
|
goto badsyntax;
|
2002-12-16 20:58:14 +00:00
|
|
|
}
|
|
|
|
|
2002-07-13 12:58:35 +00:00
|
|
|
/*
|
|
|
|
* Get location
|
|
|
|
*/
|
|
|
|
if ((q=strchr(p,',')))
|
|
|
|
*q++ = '\0';
|
|
|
|
nodebuf.location = p;
|
|
|
|
p = q;
|
2002-12-16 20:58:14 +00:00
|
|
|
if (p == NULL) {
|
|
|
|
fclose(fp);
|
2002-07-13 12:58:35 +00:00
|
|
|
goto badsyntax;
|
2002-12-16 20:58:14 +00:00
|
|
|
}
|
|
|
|
|
2002-07-13 12:58:35 +00:00
|
|
|
/*
|
|
|
|
* Get sysop name
|
|
|
|
*/
|
|
|
|
if ((q=strchr(p,',')))
|
|
|
|
*q++ = '\0';
|
|
|
|
nodebuf.sysop = p;
|
|
|
|
p = q;
|
2002-12-16 20:58:14 +00:00
|
|
|
if (p == NULL) {
|
|
|
|
fclose(fp);
|
2002-07-13 12:58:35 +00:00
|
|
|
goto badsyntax;
|
2002-12-16 20:58:14 +00:00
|
|
|
}
|
|
|
|
|
2002-07-13 12:58:35 +00:00
|
|
|
/*
|
|
|
|
* Get phone number
|
|
|
|
*/
|
|
|
|
if ((q=strchr(p,',')))
|
|
|
|
*q++ = '\0';
|
|
|
|
if (strcasecmp(p, "-Unpublished-") == 0)
|
|
|
|
nodebuf.phone = NULL;
|
|
|
|
else
|
|
|
|
nodebuf.phone = p;
|
|
|
|
p = q;
|
2002-12-16 20:58:14 +00:00
|
|
|
if (p == NULL) {
|
|
|
|
fclose(fp);
|
2002-07-13 12:58:35 +00:00
|
|
|
goto badsyntax;
|
2002-12-16 20:58:14 +00:00
|
|
|
}
|
|
|
|
|
2002-07-13 12:58:35 +00:00
|
|
|
/*
|
|
|
|
* Get modem speed
|
|
|
|
*/
|
|
|
|
if ((q=strchr(p,',')))
|
|
|
|
*q++ = '\0';
|
|
|
|
nodebuf.speed = atoi(p);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Process the nodelist flags.
|
|
|
|
*/
|
|
|
|
if (ndrecord && strlen(nd.Nl_flags)) {
|
2003-02-08 14:21:33 +00:00
|
|
|
Syslog('+', "getnlent: %s flags override %s", ascfnode(addr,0xff), nd.Nl_flags);
|
2002-07-13 12:58:35 +00:00
|
|
|
q = nd.Nl_flags;
|
|
|
|
}
|
|
|
|
ixflag = 0;
|
|
|
|
stdflag = TRUE;
|
|
|
|
for (p = q; p; p = q) {
|
|
|
|
if ((q = strchr(p, ',')))
|
|
|
|
*q++ = '\0';
|
|
|
|
if ((strncasecmp(p, "U", 1) == 0) && (strlen(p) == 1)) {
|
|
|
|
stdflag = FALSE;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Process authorized flags and user flags both as authorized.
|
|
|
|
*/
|
2002-12-30 22:13:33 +00:00
|
|
|
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;
|
2002-07-13 12:58:35 +00:00
|
|
|
if ((p[0] == 'T') && (strlen(p) == 3)) {
|
|
|
|
/*
|
|
|
|
* System open hours flag
|
|
|
|
*/
|
|
|
|
nodebuf.t1 = p[1];
|
|
|
|
nodebuf.t2 = p[2];
|
|
|
|
}
|
|
|
|
if (!stdflag) {
|
|
|
|
if (ixflag < MAXUFLAGS) {
|
|
|
|
nodebuf.uflags[ixflag++] = p;
|
|
|
|
if (ixflag < MAXUFLAGS)
|
|
|
|
nodebuf.uflags[ixflag] = NULL;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-07-13 12:58:35 +00:00
|
|
|
}
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
2002-07-13 12:58:35 +00:00
|
|
|
}
|
|
|
|
|
2002-12-16 20:58:14 +00:00
|
|
|
/*
|
|
|
|
* Now we read the next line from the nodelist and see if this
|
|
|
|
* is a ESLF (Extended St. Louis Format) line. This is for test
|
|
|
|
* and nothing is defined yet. For now, debug logging only.
|
|
|
|
*/
|
|
|
|
while (TRUE) {
|
|
|
|
if (fgets(ebuf, sizeof(ebuf)-1, fp) == NULL) {
|
|
|
|
WriteError("$fgets failed for nodelist entry");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/*
|
2003-02-08 14:21:33 +00:00
|
|
|
* Lines starting with ;E space are real errors.
|
2002-12-16 20:58:14 +00:00
|
|
|
*/
|
|
|
|
if (strncmp(ebuf, (char *)";E ", 3) == 0)
|
|
|
|
break;
|
|
|
|
if (strncmp(ebuf, (char *)";E", 2))
|
|
|
|
break;
|
2002-12-31 15:27:18 +00:00
|
|
|
Syslog('n', "ESLF: \"%s\"", printable(ebuf, 0));
|
2002-12-16 20:58:14 +00:00
|
|
|
}
|
|
|
|
|
2002-12-30 22:13:33 +00:00
|
|
|
/*
|
|
|
|
* Build the connection URL
|
|
|
|
*
|
|
|
|
* If the node has some IP flags and we allow TCP, then search the best protocol.
|
|
|
|
*/
|
|
|
|
if (nodebuf.iflags & mytcpip) {
|
2002-12-31 15:27:18 +00:00
|
|
|
memset(&tbuf, 0, sizeof(tbuf));
|
2003-08-24 12:26:34 +00:00
|
|
|
Syslog('n', "getnlent: node iflags %08x, mytcpip %08x", nodebuf.iflags, mytcpip);
|
2002-12-30 22:13:33 +00:00
|
|
|
for (tmpm = &nl_tcpip; *tmpm; tmpm=&((*tmpm)->next)) {
|
|
|
|
if ((*tmpm)->mask & nodebuf.iflags) {
|
2003-08-24 12:26:34 +00:00
|
|
|
Syslog('n', "getnlent: best flag is %s", (*tmpm)->name);
|
2002-12-30 22:13:33 +00:00
|
|
|
for (tmps = &nl_service; *tmps; tmps=&((*tmps)->next)) {
|
|
|
|
if (strcmp((*tmps)->flag, (*tmpm)->name) == 0) {
|
|
|
|
sprintf(tbuf, "%s", (*tmps)->service);
|
|
|
|
tport = (*tmps)->port;
|
2003-08-24 12:26:34 +00:00
|
|
|
Syslog('n', "getnlent: protocol %s at port %d", (*tmps)->service, (*tmps)->port);
|
2002-12-30 22:13:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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)) {
|
2003-08-24 12:26:34 +00:00
|
|
|
Syslog('n', "getnlent: using override %s for FQDN", nd.Nl_hostname);
|
2002-12-30 22:13:33 +00:00
|
|
|
sprintf(tbuf, nodebuf.name);
|
|
|
|
nodebuf.url = xstrcat(nodebuf.url, tbuf);
|
|
|
|
} else {
|
|
|
|
for (tmpa = &nl_search; *tmpa; tmpa=&((*tmpa)->next)) {
|
2003-08-24 12:26:34 +00:00
|
|
|
Syslog('n', "getnlent: search FQDN method %s", (*tmpa)->name);
|
2002-12-30 22:13:33 +00:00
|
|
|
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.
|
|
|
|
*/
|
2003-08-24 12:26:34 +00:00
|
|
|
Syslog('n', "getnlent: using field3 \"%s\"", tbuf);
|
2002-12-30 22:13:33 +00:00
|
|
|
nodebuf.url = xstrcat(nodebuf.url, tbuf);
|
|
|
|
break;
|
2002-12-31 15:27:18 +00:00
|
|
|
} else {
|
|
|
|
memset(&tbuf, 0, sizeof(tbuf));
|
2002-12-30 22:13:33 +00:00
|
|
|
}
|
|
|
|
} else if (strcasecmp((*tmpa)->name, "field6") == 0) {
|
2004-07-11 11:49:51 +00:00
|
|
|
memset(&tbuf, 0, sizeof(tbuf));
|
|
|
|
for (tmpaa = &nl_ipprefix; *tmpaa; tmpaa=&((*tmpaa)->next)) {
|
|
|
|
if (nodebuf.phone && strncmp(nodebuf.phone, (*tmpaa)->name, strlen((*tmpaa)->name)) == 0) {
|
|
|
|
Syslog('n', "getnlent: found %s prefix", (*tmpaa)->name);
|
|
|
|
sprintf(tbuf, "%s", nodebuf.phone+strlen((*tmpaa)->name));
|
|
|
|
for (i = 0; i < strlen(tbuf); i++)
|
|
|
|
if (tbuf[i] == '-')
|
|
|
|
tbuf[i] = '.';
|
|
|
|
Syslog('n', "getnlent: using field6 \"%s\"", tbuf);
|
|
|
|
nodebuf.url = xstrcat(nodebuf.url, tbuf);
|
|
|
|
break;
|
|
|
|
}
|
2002-12-31 15:27:18 +00:00
|
|
|
}
|
2004-07-11 11:49:51 +00:00
|
|
|
if (strlen(tbuf))
|
|
|
|
break;
|
2002-12-31 15:27:18 +00:00
|
|
|
} else if (strcasecmp((*tmpa)->name, "field8") == 0) {
|
|
|
|
/*
|
|
|
|
* Read nodelist line again in another buffer, the original
|
|
|
|
* buffer is divided into pieces by all previous actions.
|
|
|
|
*/
|
|
|
|
memset(&tbuf, 0, sizeof(tbuf));
|
|
|
|
if (fseek(fp, ndx.offset, SEEK_SET) != 0) {
|
|
|
|
WriteError("$Seek failed for nodelist entry");
|
|
|
|
fclose(fp);
|
|
|
|
goto retdummy;
|
|
|
|
}
|
|
|
|
if (fgets(ebuf, sizeof(ebuf)-1, fp) == NULL) {
|
|
|
|
WriteError("$fgets failed for nodelist entry");
|
|
|
|
fclose(fp);
|
|
|
|
goto retdummy;
|
2002-12-30 22:13:33 +00:00
|
|
|
}
|
2002-12-31 15:27:18 +00:00
|
|
|
if (*(p = ebuf + strlen(ebuf) -1) == '\n')
|
|
|
|
*p = '\0';
|
|
|
|
if (*(p = ebuf + strlen(ebuf) -1) == '\r')
|
|
|
|
*p = '\0';
|
|
|
|
p = ebuf;
|
|
|
|
/*
|
|
|
|
* Shift to field 8
|
|
|
|
*/
|
|
|
|
for (i = 0; i < 7; i++) {
|
|
|
|
if ((q = strchr(p,',')))
|
|
|
|
*q++ = '\0';
|
|
|
|
p = q;
|
|
|
|
if (p == NULL) {
|
|
|
|
fclose(fp);
|
|
|
|
goto badsyntax;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (p = q; p; p = q) {
|
|
|
|
if ((q = strchr(p, ',')))
|
|
|
|
*q++ = '\0';
|
|
|
|
if ((r = strchr(p, ':'))) {
|
|
|
|
r++;
|
|
|
|
/*
|
|
|
|
* If there is a user@domain then strip the userpart.
|
|
|
|
*/
|
|
|
|
if (strchr(r, '@')) {
|
|
|
|
r = strchr(r, '@');
|
|
|
|
r++;
|
|
|
|
}
|
|
|
|
if (*r == '*') {
|
2003-08-24 12:26:34 +00:00
|
|
|
Syslog('n', "getnlent: possible default domain marking \"%s\"", MBSE_SS(r));
|
2002-12-31 15:27:18 +00:00
|
|
|
for (tmpd = &nl_domsuffix; *tmpd; tmpd=&((*tmpd)->next)) {
|
|
|
|
if ((*tmpd)->zone == nodebuf.addr.zone) {
|
|
|
|
if (*r++ == '\0')
|
2003-01-25 14:20:12 +00:00
|
|
|
sprintf(tbuf, "f%d.n%d.z%d.%s.%s", nodebuf.addr.node, nodebuf.addr.net,
|
|
|
|
nodebuf.addr.zone, nodebuf.addr.domain, (*tmpd)->name);
|
2002-12-31 15:27:18 +00:00
|
|
|
else
|
2003-01-25 14:20:12 +00:00
|
|
|
sprintf(tbuf, "f%d.n%d.z%d.%s.%s%s", nodebuf.addr.node, nodebuf.addr.net,
|
|
|
|
nodebuf.addr.zone, nodebuf.addr.domain, (*tmpd)->name, r);
|
2003-08-24 12:26:34 +00:00
|
|
|
Syslog('n', "getnlent: will try default domain \"%s\"", tbuf);
|
2002-12-31 15:27:18 +00:00
|
|
|
nodebuf.url = xstrcat(nodebuf.url, tbuf);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (strlen(tbuf))
|
|
|
|
break;
|
2003-08-24 12:26:34 +00:00
|
|
|
Syslog('n', "getnlent: no matching default domain found for zone %d", nodebuf.addr.zone);
|
2002-12-31 15:27:18 +00:00
|
|
|
}
|
|
|
|
if (strchr(r, '.')) {
|
2003-08-24 12:26:34 +00:00
|
|
|
Syslog('n', "getnlent: found a FQDN \"%s\"", MBSE_SS(r));
|
2002-12-31 15:27:18 +00:00
|
|
|
sprintf(tbuf, "%s", r);
|
|
|
|
nodebuf.url = xstrcat(nodebuf.url, tbuf);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (strlen(tbuf))
|
|
|
|
break;
|
2003-01-25 14:20:12 +00:00
|
|
|
memset(&tbuf, 0, sizeof(tbuf));
|
|
|
|
} else if (strcasecmp((*tmpa)->name, "defdomain") == 0) {
|
2003-08-24 12:26:34 +00:00
|
|
|
Syslog('n', "getnlent: trying default domain");
|
2003-02-06 20:06:07 +00:00
|
|
|
if (nodebuf.addr.domain) {
|
|
|
|
for (tmpd = &nl_domsuffix; *tmpd; tmpd=&((*tmpd)->next)) {
|
|
|
|
if ((*tmpd)->zone == nodebuf.addr.zone) {
|
|
|
|
sprintf(tbuf, "f%d.n%d.z%d.%s.%s", nodebuf.addr.node, nodebuf.addr.net,
|
|
|
|
nodebuf.addr.zone, nodebuf.addr.domain, (*tmpd)->name);
|
2003-08-24 12:26:34 +00:00
|
|
|
Syslog('n', "getnlent: will try default domain \"%s\"", tbuf);
|
2003-02-06 20:06:07 +00:00
|
|
|
nodebuf.url = xstrcat(nodebuf.url, tbuf);
|
|
|
|
break;
|
|
|
|
}
|
2003-01-25 14:20:12 +00:00
|
|
|
}
|
2003-02-06 20:06:07 +00:00
|
|
|
} else {
|
|
|
|
Syslog('+', "getnlent: no domain name for zone %d, check setup", nodebuf.addr.zone);
|
2003-01-25 14:20:12 +00:00
|
|
|
}
|
|
|
|
if (strlen(tbuf))
|
|
|
|
break;
|
2003-08-24 12:26:34 +00:00
|
|
|
Syslog('n', "getnlent: no matching default domain found for zone %d", nodebuf.addr.zone);
|
2003-01-25 14:20:12 +00:00
|
|
|
memset(&tbuf, 0, sizeof(tbuf));
|
2002-12-30 22:13:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-12-31 15:27:18 +00:00
|
|
|
if (strlen(tbuf) == 0) {
|
2003-08-24 12:26:34 +00:00
|
|
|
Syslog('+', "getnlent: no FQDN found, cannot call");
|
2002-12-31 15:27:18 +00:00
|
|
|
if (nodebuf.url)
|
|
|
|
free(nodebuf.url);
|
|
|
|
nodebuf.url = NULL;
|
|
|
|
} else if (strchr(tbuf, ':') == NULL) {
|
2002-12-30 22:13:33 +00:00
|
|
|
/*
|
|
|
|
* No optional port number, add one from the default
|
|
|
|
* for this protocol.
|
|
|
|
*/
|
|
|
|
sprintf(tbuf, ":%lu", tport);
|
2003-08-24 12:26:34 +00:00
|
|
|
Syslog('n', "getnlent: adding default port %s", tbuf);
|
2002-12-30 22:13:33 +00:00
|
|
|
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);
|
|
|
|
}
|
2003-01-25 14:20:12 +00:00
|
|
|
fclose(fp);
|
|
|
|
|
2002-07-13 12:58:35 +00:00
|
|
|
nodebuf.addr.name = nodebuf.sysop;
|
2003-12-08 18:01:25 +00:00
|
|
|
if (nodebuf.addr.domain)
|
|
|
|
free(nodebuf.addr.domain);
|
2002-07-13 12:58:35 +00:00
|
|
|
nodebuf.addr.domain = xstrcpy(fdx.domain);
|
|
|
|
nodebuf.upnet = ndx.upnet;
|
|
|
|
nodebuf.upnode = ndx.upnode;
|
|
|
|
nodebuf.region = ndx.region;
|
|
|
|
if (addr->domain == NULL)
|
|
|
|
addr->domain = xstrcpy(nodebuf.addr.domain);
|
|
|
|
|
2004-06-19 12:14:12 +00:00
|
|
|
/*
|
|
|
|
* FSP-1033, the ICM (IP Continuous Mail) flag.
|
|
|
|
*/
|
2004-06-18 19:54:13 +00:00
|
|
|
nodebuf.can_pots = (nodebuf.mflags || nodebuf.dflags) ? TRUE : FALSE;
|
|
|
|
nodebuf.can_ip = (nodebuf.iflags) ? TRUE : FALSE;
|
|
|
|
nodebuf.is_cm = (nodebuf.oflags & 0x00000001) ? TRUE : FALSE;
|
|
|
|
nodebuf.is_icm = (nodebuf.oflags & 0x00000002) ? TRUE : FALSE;
|
2004-06-19 12:14:12 +00:00
|
|
|
/*
|
|
|
|
* Now correct if node is ION with a CM flag instead of ICM flag.
|
|
|
|
* This is the case the first months after approval of the ICM flag
|
|
|
|
* and with nodes who won't change flags.
|
|
|
|
*/
|
|
|
|
if (!nodebuf.can_pots && nodebuf.can_ip && nodebuf.is_cm && !nodebuf.is_icm) {
|
|
|
|
Syslog('n', "getnlent: correct CM into ICM flag");
|
|
|
|
nodebuf.is_cm = FALSE;
|
|
|
|
nodebuf.is_icm = TRUE;
|
|
|
|
}
|
2004-06-18 19:54:13 +00:00
|
|
|
|
2002-12-31 15:27:18 +00:00
|
|
|
Syslog('n', "getnlent: system %s, %s", nodebuf.name, nodebuf.location);
|
|
|
|
Syslog('n', "getnlent: sysop %s, %s", nodebuf.sysop, nodebuf.phone);
|
|
|
|
Syslog('n', "getnlent: URL %s", printable(nodebuf.url, 0));
|
2004-06-18 19:54:13 +00:00
|
|
|
Syslog('n', "getnlent: online POTS %s CM %s, IP %s ICM %s", nodebuf.can_pots ?"Yes":"No",
|
|
|
|
nodebuf.is_cm ?"Yes":"No", nodebuf.can_ip ?"Yes":"No", nodebuf.is_icm ?"Yes":"No");
|
2003-08-24 12:26:34 +00:00
|
|
|
// moflags(nodebuf.mflags);
|
|
|
|
// diflags(nodebuf.dflags);
|
|
|
|
// ipflags(nodebuf.iflags);
|
2004-06-18 19:54:13 +00:00
|
|
|
// olflags(nodebuf.oflags);
|
2003-08-24 12:26:34 +00:00
|
|
|
// rqflags(nodebuf.xflags);
|
2002-07-13 12:58:35 +00:00
|
|
|
free(mydomain);
|
|
|
|
|
|
|
|
return &nodebuf;
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
badsyntax:
|
2002-07-13 12:58:35 +00:00
|
|
|
WriteError("nodelist %d offset +%lu: bad syntax in line \"%s\"", ndx.fileno, (unsigned long)ndx.offset, buf);
|
|
|
|
/* fallthrough */
|
2001-08-17 05:46:24 +00:00
|
|
|
|
|
|
|
retdummy:
|
2002-07-13 12:58:35 +00:00
|
|
|
memset(&nodebuf, 0, sizeof(nodebuf));
|
|
|
|
nodebuf.pflag = NL_DUMMY;
|
|
|
|
nodebuf.name = (char *)"Unknown";
|
|
|
|
nodebuf.location = (char *)"Nowhere";
|
|
|
|
nodebuf.sysop = (char *)"Sysop";
|
|
|
|
nodebuf.phone = NULL;
|
|
|
|
nodebuf.speed = 2400;
|
2002-12-30 22:13:33 +00:00
|
|
|
nodebuf.url = NULL;
|
2002-07-13 12:58:35 +00:00
|
|
|
free(mydomain);
|
|
|
|
|
|
|
|
return &nodebuf;
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void olflags(unsigned long flags)
|
|
|
|
{
|
2002-12-30 22:13:33 +00:00
|
|
|
char *t;
|
|
|
|
nodelist_flag **tmpm;
|
2002-07-13 12:58:35 +00:00
|
|
|
|
|
|
|
t = xstrcpy((char *)"Mailer flags :");
|
2002-12-30 22:13:33 +00:00
|
|
|
for (tmpm = &nl_online; *tmpm; tmpm=&((*tmpm)->next)) {
|
|
|
|
if ((*tmpm)->value & flags) {
|
|
|
|
t = xstrcat(t, (char *)" ");
|
|
|
|
t = xstrcat(t, (*tmpm)->name);
|
|
|
|
}
|
|
|
|
}
|
2002-12-31 15:27:18 +00:00
|
|
|
Syslog('n', "%s", t);
|
2002-07-13 12:58:35 +00:00
|
|
|
free(t);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void rqflags(unsigned long flags)
|
|
|
|
{
|
2002-12-30 22:13:33 +00:00
|
|
|
char *t;
|
|
|
|
nodelist_flag **tmpm;
|
|
|
|
|
2002-07-13 12:58:35 +00:00
|
|
|
t = xstrcpy((char *)"Request flags:");
|
2002-12-30 22:13:33 +00:00
|
|
|
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 *)")");
|
|
|
|
}
|
|
|
|
}
|
2002-12-31 15:27:18 +00:00
|
|
|
Syslog('n', "%s", t);
|
2002-07-13 12:58:35 +00:00
|
|
|
free(t);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void moflags(unsigned long flags)
|
|
|
|
{
|
2002-12-30 22:13:33 +00:00
|
|
|
char *t;
|
|
|
|
nodelist_modem **tmpm;
|
2002-07-13 12:58:35 +00:00
|
|
|
|
|
|
|
if (!flags)
|
|
|
|
return;
|
|
|
|
t = xstrcpy((char *)"Modem flags :");
|
2002-12-30 22:13:33 +00:00
|
|
|
for (tmpm = &nl_pots; *tmpm; tmpm=&((*tmpm)->next)) {
|
|
|
|
if ((*tmpm)->mask & flags) {
|
|
|
|
t = xstrcat(t, (char *)" ");
|
|
|
|
t = xstrcat(t, (*tmpm)->name);
|
|
|
|
}
|
|
|
|
}
|
2002-12-31 15:27:18 +00:00
|
|
|
Syslog('n', "%s", t);
|
2002-07-13 12:58:35 +00:00
|
|
|
free(t);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void diflags(unsigned long flags)
|
|
|
|
{
|
2002-12-30 22:13:33 +00:00
|
|
|
char *t;
|
|
|
|
nodelist_modem **tmpm;
|
|
|
|
|
2002-07-13 12:58:35 +00:00
|
|
|
if (!flags)
|
|
|
|
return;
|
|
|
|
t = xstrcpy((char *)"ISDN flags :");
|
2002-12-30 22:13:33 +00:00
|
|
|
for (tmpm = &nl_isdn; *tmpm; tmpm=&((*tmpm)->next)) {
|
|
|
|
if ((*tmpm)->mask & flags) {
|
|
|
|
t = xstrcat(t, (char *)" ");
|
|
|
|
t = xstrcat(t, (*tmpm)->name);
|
|
|
|
}
|
|
|
|
}
|
2002-12-31 15:27:18 +00:00
|
|
|
Syslog('n', "%s", t);
|
2002-07-13 12:58:35 +00:00
|
|
|
free(t);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ipflags(unsigned long flags)
|
|
|
|
{
|
2002-12-30 22:13:33 +00:00
|
|
|
char *t;
|
|
|
|
nodelist_modem **tmpm;
|
|
|
|
|
2002-07-13 12:58:35 +00:00
|
|
|
if (!flags)
|
|
|
|
return;
|
|
|
|
t = xstrcpy((char *)"TCP/IP flags :");
|
2002-12-30 22:13:33 +00:00
|
|
|
for (tmpm = &nl_tcpip; *tmpm; tmpm=&((*tmpm)->next)) {
|
|
|
|
if ((*tmpm)->mask & flags) {
|
|
|
|
t = xstrcat(t, (char *)" ");
|
|
|
|
t = xstrcat(t, (*tmpm)->name);
|
|
|
|
}
|
|
|
|
}
|
2002-12-31 15:27:18 +00:00
|
|
|
Syslog('n', "%s", t);
|
2002-07-13 12:58:35 +00:00
|
|
|
free(t);
|
2001-08-17 05:46:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|