Rebuild for configurable nodelists handling

This commit is contained in:
Michiel Broek
2002-12-30 22:13:33 +00:00
parent fbe81bfa68
commit 3dfe32df94
20 changed files with 1143 additions and 736 deletions

View File

@@ -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)

View File

@@ -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;

View File

@@ -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] == '-')

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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();
}

View File

@@ -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 */