Updated calling methods in mbtask and mbcico

This commit is contained in:
Michiel Broek 2002-03-03 20:40:03 +00:00
parent 4a7252d7b5
commit 5fc848598c
6 changed files with 100 additions and 74 deletions

View File

@ -4664,17 +4664,20 @@ v0.33.20 10-Feb-2002
Creates the semafore is_inet when the internet connections is
available, and removes it when it is down.
Added test for ISDN/modem lines in use.
Lost of code cleanup.
Lots of code cleanup.
No setup setting anymore for maximum POTS and ISDN lines, this
is now automatic.
mbtask will now update internal counters how many ISDN and POTS
lines are free to use for dialout.
For ISDN and POTS calls, mbtask now decides which tty to use,
mbcico gets the tty to use as option on the commandline.
mbcico:
Fixed binkp driver to accept incoming unprotected sessions.
Temporary added extra password handling logs.
If a binkp session comes in and there already is a session
with that node, mbcico stopts the binkp session with an error.
Remove some obsolete code that is handled by mbtask.
mbout:
The status display has now 9 digits for the outbound size.

View File

@ -4,7 +4,7 @@
* Purpose ...............: Fidonet mailer
*
*****************************************************************************
* Copyright (C) 1997-2001
* Copyright (C) 1997-2002
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@ -69,8 +69,8 @@ int checkretry(callstat *st)
int portopen(faddr *addr)
{
char *p, *q;
int rc, speed;
char *p;
int rc;
pp_list *pl = NULL, *tmp;
if (inetaddr) {
@ -87,27 +87,15 @@ int portopen(faddr *addr)
if (forcedline) {
Syslog('d', "portopen forcedline %s", forcedline);
p = forcedline;
if ((q = strchr(p, ':'))) { /* Note: DIT KAN WEG ! */
*q++ = '\0';
if ((*q == 'l') || (*q == 'L'))
speed=atoi(++q);
else {
speed = atoi(q);
if (nlent->speed < speed)
speed = nlent->speed;
}
}
if (load_port(p)) {
speed = ttyinfo.portspeed;
rc = openport(p,speed);
if (rc) {
if ((rc = openport(p, ttyinfo.portspeed))) {
Syslog('+', "Cannot open port %s",p);
nodeulock(addr);
putstatus(addr, 10, ST_PORTERR);
return ST_PORTERR;
}
return 0;
return ST_PORTOK;
} else {
nodeulock(addr);
putstatus(addr, 0, ST_PORTERR);
@ -115,6 +103,8 @@ int portopen(faddr *addr)
}
}
WriteError("call.c portopen(): should not be here");
if (make_portlist(nlent, &pl) == 0) {
WriteError("No matching ports defined");
nodeulock(addr);
@ -126,8 +116,7 @@ int portopen(faddr *addr)
if (load_port(tmp->tty)) {
Syslog('+', "Port %s at %ld, modem %s", ttyinfo.tty, ttyinfo.portspeed, modem.modem);
p = xstrcpy(tmp->tty);
speed = ttyinfo.portspeed;
rc = openport(p, speed);
rc = openport(p, ttyinfo.portspeed);
free(p);
if (rc == 0) {
tidy_pplist(&pl);
@ -146,7 +135,7 @@ int portopen(faddr *addr)
int call(faddr *addr)
{
int i, j, rc = 1;
int i, rc = 1;
callstat *st;
struct hostent *he;
@ -261,12 +250,12 @@ int call(faddr *addr)
}
if (((nlent->oflags & OL_CM) == 0) && (!IsZMH())) {
if (!forcedcalls) {
Syslog('d', "Node is ZMH only and it is not ZMH");
nodeulock(addr);
putstatus(addr,0,ST_NOTZMH);
return ST_NOTZMH;
}
// if (!forcedcalls) {
// Syslog('d', "Node is ZMH only and it is not ZMH");
// nodeulock(addr);
// putstatus(addr,0,ST_NOTZMH);
// return ST_NOTZMH;
// }
Syslog('?', "Warning: calling MO system outside ZMH");
}
@ -280,26 +269,26 @@ int call(faddr *addr)
* Over TCP/IP we don't do a delay because the node we are
* connecting can't be busy. Also forced calls don't delay.
*/
Syslog('d', "delay=%d inetaddr=%s immediatecall=%s",
CFG.dialdelay, inetaddr?"true":"false", immediatecall?"true":"false");
if ((CFG.dialdelay > 10) && (!inetaddr) && (!immediatecall)) {
/*
* Generate a random number between CFG.dialdelay and
* CFG.dialdelay / 10, minimum value is 10.
*/
srand(getpid());
while (TRUE) {
j = 1+(int) (1.0 * CFG.dialdelay * rand() / (RAND_MAX + 1.0));
if ((j > (CFG.dialdelay / 10)) && (j > 9))
break;
}
Syslog('d', "Dial delay %d seconds", j);
for (i = j; i > 0; i--) {
IsDoing("Delay %d seconds", i);
sleep(1);
}
}
// Syslog('d', "delay=%d inetaddr=%s immediatecall=%s",
// CFG.dialdelay, inetaddr?"true":"false", immediatecall?"true":"false");
// if ((CFG.dialdelay > 10) && (!inetaddr) && (!immediatecall)) {
// /*
// * Generate a random number between CFG.dialdelay and
// * CFG.dialdelay / 10, minimum value is 10.
// */
// srand(getpid());
// while (TRUE) {
// j = 1+(int) (1.0 * CFG.dialdelay * rand() / (RAND_MAX + 1.0));
// if ((j > (CFG.dialdelay / 10)) && (j > 9))
// break;
// }
// Syslog('d', "Dial delay %d seconds", j);
//
// for (i = j; i > 0; i--) {
// IsDoing("Delay %d seconds", i);
// sleep(1);
// }
// }
if (nodelock(addr)) {
Syslog('+', "System %s is locked", ascfnode(addr, 0x1f));

View File

@ -1,7 +1,10 @@
/* $Id$ */
#ifndef CALLSTAT_H
#define CALLSTAT_H
#define ST_PORTOK 0
#define ST_PORTERR 1
#define ST_NOCONN 2
#define ST_MDMERR 3

View File

@ -247,6 +247,7 @@ int main(int argc, char *argv[])
usage();
die(101);
}
WriteError("commandline option -r is obsolete");
break;
case 'l': forcedline = optarg;
@ -372,8 +373,11 @@ int main(int argc, char *argv[])
if (!diskfree(CFG.freespace))
die(101);
if (callist == NULL)
callist = callall();
if (callist == NULL) {
WriteError("Calling mbcico without node address not supported anymore");
die(101);
}
// callist = callall();
for (tmpl = &callist; *tmpl; tmpl = &((*tmpl)->next)) {
callno++;
@ -387,9 +391,9 @@ int main(int argc, char *argv[])
break;
}
}
if (callist == NULL)
if (IsSema((char *)"scanout"))
RemoveSema((char *)"scanout");
// if (callist == NULL)
// if (IsSema((char *)"scanout"))
// RemoveSema((char *)"scanout");
} else {
/* slave */
if (!answermode && tcp_mode == TCPMODE_IBN)

View File

@ -100,6 +100,7 @@ extern int pots_lines; /* POTS lines available */
extern int isdn_lines; /* ISDN lines available */
extern int pots_free; /* POTS lines free */
extern int isdn_free; /* ISDN lines free */
extern pp_list *pl; /* List of tty ports */
@ -836,7 +837,7 @@ void scheduler(void)
struct passwd *pw;
int running = 0, rc, i, rlen, found;
static int LOADhi = FALSE, oldmin = 70, olddo = 70, oldsec = 70;
char *cmd = NULL, opts[41];
char *cmd = NULL, opts[41], port[21];
static char doing[32], buf[2048];
time_t now;
struct tm *tm, *utm;
@ -847,6 +848,7 @@ void scheduler(void)
int call_work = 0;
static int call_entry = MAXTASKS;
double loadavg[3];
pp_list *tpl;
InitFidonet();
@ -1147,17 +1149,14 @@ void scheduler(void)
call_entry = 0;
else
call_entry++;
// tasklog('c', "Call entry rotaded to %d", call_entry);
/*
* If a valid entry, and not yet calling, and the retry time is reached,
* then launch a callprocess for this node.
*/
// if (calllist[call_entry].addr.zone && !calllist[call_entry].calling) {
// tasklog('o', "trytime %lu, now %lu", calllist[call_entry].cst.trytime, now);
// }
if (calllist[call_entry].addr.zone && !calllist[call_entry].calling &&
(calllist[call_entry].cst.trytime < now)) {
if ((calllist[call_entry].callmode == CM_INET) && (runtasktype(CM_INET) < TCFG.max_tcp)) {
if ((calllist[call_entry].callmode == CM_INET) && (runtasktype(CM_INET) < TCFG.max_tcp) && internet) {
found = TRUE;
break;
}
@ -1170,6 +1169,7 @@ void scheduler(void)
break;
}
}
/*
* Safety counter, if all systems are already calling, we should
* never break out of this loop anymore.
@ -1179,15 +1179,30 @@ void scheduler(void)
break;
}
if (found) {
// tasklog('c', "Should launch slot %d node %s", call_entry, ascfnode(calllist[call_entry].addr, 0x1f));
/*
* FIXME: here we should check if there are multiple ISDN or POTS lines which of the
* lines matches the flags to call that node and use the most simple device.
* The mbcico should be called with the instruction which line to use.
*/
cmd = xstrcpy(pw->pw_dir);
cmd = xstrcat(cmd, (char *)"/bin/mbcico");
sprintf(opts, "f%u.n%u.z%u", calllist[call_entry].addr.node, calllist[call_entry].addr.net,
/*
* For ISDN or POTS, select a free tty device.
*/
switch (calllist[call_entry].callmode) {
case CM_ISDN: for (tpl = pl; tpl; tpl = tpl->next) {
if (!tpl->locked && (tpl->dflags & calllist[call_entry].diflags)) {
sprintf(port, "-l %s ", tpl->tty);
break;
}
}
break;
case CM_POTS: for (tpl = pl; tpl; tpl = tpl->next) {
if (!tpl->locked && (tpl->mflags & calllist[call_entry].moflags)) {
sprintf(port, "-l %s ", tpl->tty);
break;
}
}
break;
default: port[0] = '\0';
break;
}
sprintf(opts, "%sf%u.n%u.z%u", port, calllist[call_entry].addr.node, calllist[call_entry].addr.net,
calllist[call_entry].addr.zone);
calllist[call_entry].taskpid = launch(cmd, opts, (char *)"mbcico", calllist[call_entry].callmode);
if (calllist[call_entry].taskpid)

View File

@ -35,6 +35,7 @@
#include "scanout.h"
#include "nodelist.h"
#include "callstat.h"
#include "ports.h"
#include "outstat.h"
@ -50,6 +51,7 @@ _alist_l *alist = NULL; /* Nodes to call list */
extern int s_do_inet; /* Internet wanted */
extern int pots_lines; /* POTS lines available */
extern int isdn_lines; /* ISDN lines available */
extern pp_list *pl; /* Available ports */
@ -192,6 +194,7 @@ int outstat()
time_t now;
struct tm *tm;
int uhour, umin, thour, tmin;
pp_list *tpl;
now = time(NULL);
tm = gmtime(&now); /* UTC time */
@ -393,27 +396,36 @@ int outstat()
if ((tmp->callmode == CM_NONE) && isdn_lines) {
/*
* ISDN node
* If any matching port found, mark node ISDN
*/
isdn_calls++;
tmp->callmode = CM_ISDN;
break;
for (tpl = pl; tpl; tpl = tpl->next) {
if (tmp->diflags & tpl->dflags) {
isdn_calls++;
tmp->callmode = CM_ISDN;
break;
}
}
}
if ((tmp->callmode == CM_NONE) && pots_lines) {
/*
* POTS node
* If any matching ports found, mark node POTS
*/
pots_calls++;
tmp->callmode = CM_POTS;
break;
for (tpl = pl; tpl; tpl = tpl->next) {
if (tmp->moflags & tpl->mflags) {
pots_calls++;
tmp->callmode = CM_POTS;
break;
}
}
}
/*
* Here we are out of options.
* Here we are out of options, clear callflag.
*/
if (tmp->callmode == CM_NONE) {
tasklog('!', "No method to call %s available", ascfnode(tmp->addr, 0x0f));
tmp->flavors &= ~F_CALL;
}
}