New nodelist features test
This commit is contained in:
parent
92e96084b5
commit
79d31bda0a
@ -30,6 +30,8 @@ v0.37.00 26-Dec-2002.
|
||||
mbcico:
|
||||
With binkp and EMSI sessions double received remote aka's are
|
||||
filtered.
|
||||
When calling ITN nodes, the default port is now 23.
|
||||
Call setup changed and uses now the nodelist lookup URL.
|
||||
|
||||
mbout:
|
||||
When a poll was removed, the outbound was not rescanned.
|
||||
|
118
mbcico/call.c
118
mbcico/call.c
@ -4,7 +4,7 @@
|
||||
* Purpose ...............: Fidonet mailer
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2002
|
||||
* Copyright (C) 1997-2003
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@ -52,11 +52,11 @@
|
||||
|
||||
|
||||
extern int tcp_mode;
|
||||
extern int forcedcalls;
|
||||
extern int immediatecall;
|
||||
extern char *forcedphone;
|
||||
extern char *forcedline;
|
||||
extern char *inetaddr;
|
||||
extern char *protocol;
|
||||
|
||||
|
||||
|
||||
@ -70,7 +70,6 @@ int portopen(faddr *addr)
|
||||
if ((rc = opentcp(inetaddr))) {
|
||||
Syslog('+', "Cannot connect %s", inetaddr);
|
||||
nodeulock(addr);
|
||||
// putstatus(addr,1,MBERR_NO_CONNECTION);
|
||||
return MBERR_NO_CONNECTION;
|
||||
}
|
||||
return MBERR_OK;
|
||||
@ -104,10 +103,9 @@ int portopen(faddr *addr)
|
||||
|
||||
int call(faddr *addr)
|
||||
{
|
||||
int i, rc = 1, proto = FALSE;
|
||||
struct hostent *he;
|
||||
unsigned long cmmask, ipmask;
|
||||
nodelist_modem **tmpm;
|
||||
int rc = 1;
|
||||
char *p, temp[81];
|
||||
unsigned long cmmask;
|
||||
|
||||
/*
|
||||
* Don't call points, call their boss instead.
|
||||
@ -152,91 +150,56 @@ int call(faddr *addr)
|
||||
sprintf(history.aka.domain, "%s", addr->domain);
|
||||
|
||||
/*
|
||||
* First see if this node can be reached over the internet and
|
||||
* that internet calls are allowed.
|
||||
* Extract the protocol from the URL.
|
||||
*/
|
||||
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 ((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");
|
||||
}
|
||||
}
|
||||
strncpy(temp, nlent->url, 80);
|
||||
p = strchr(temp, ':');
|
||||
*p = '\0';
|
||||
protocol = xstrcpy(temp);
|
||||
|
||||
if (strcasecmp(protocol, "pots") && strcasecmp(protocol, "isdn")) {
|
||||
if (!inetaddr) {
|
||||
/*
|
||||
* If we have an internet address, set protocol
|
||||
* Get the internet address from the URL.
|
||||
*/
|
||||
if (inetaddr) {
|
||||
p = strchr(nlent->url, '/');
|
||||
p++;
|
||||
p++;
|
||||
inetaddr = xstrcpy(p);
|
||||
}
|
||||
RegTCP();
|
||||
Syslog('d', "TCP/IP node \"%s\"", MBSE_SS(inetaddr));
|
||||
|
||||
if (tcp_mode == TCPMODE_NONE) {
|
||||
/*
|
||||
* If protocol not forced at the commandline, get it
|
||||
* from the nodelist. If it fails, fallback to dial.
|
||||
* Priority IBN, IFC, ITN.
|
||||
*/
|
||||
ipmask = 0;
|
||||
for (tmpm = &nl_tcpip; *tmpm; tmpm=&((*tmpm)->next))
|
||||
if (strcmp("IBN", (*tmpm)->name) == 0)
|
||||
ipmask = (*tmpm)->mask;
|
||||
if (nlent->iflags & ipmask) {
|
||||
if (strcmp(protocol, "binkp") == 0) {
|
||||
tcp_mode = TCPMODE_IBN;
|
||||
Syslog('d', "TCP/IP mode set to IBN");
|
||||
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) {
|
||||
} else if (strcmp(protocol, "fido") == 0) {
|
||||
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) {
|
||||
} else if (strcmp(protocol, "telnet") == 0) {
|
||||
tcp_mode = TCPMODE_ITN;
|
||||
Syslog('d', "TCP/IP mode seto to ITN");
|
||||
proto = TRUE;
|
||||
}
|
||||
}
|
||||
if (!proto) {
|
||||
} else {
|
||||
Syslog('+', "No common TCP/IP protocols for node %s", nlent->name);
|
||||
free(inetaddr);
|
||||
inetaddr = NULL;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
if (inetaddr == NULL) {
|
||||
WriteError("No IP address, abort call");
|
||||
rc = MBERR_NO_IP_ADDRESS;
|
||||
putstatus(addr, 10, rc);
|
||||
nodeulock(addr);
|
||||
return rc;
|
||||
}
|
||||
} else {
|
||||
if (!forcedphone) {
|
||||
/*
|
||||
* Get the phone number from the URL.
|
||||
*/
|
||||
p = strchr(nlent->url, '/');
|
||||
p++;
|
||||
p++;
|
||||
forcedphone = xstrcpy(p);
|
||||
}
|
||||
}
|
||||
|
||||
if (((nlent->oflags & cmmask) == 0) && (!IsZMH())) {
|
||||
@ -249,20 +212,19 @@ int call(faddr *addr)
|
||||
|
||||
/*
|
||||
* Call when:
|
||||
* the nodelist has a phone, or phone on commandline, or TCP address given
|
||||
* there is a phone number or fqdn/ip-address
|
||||
* and
|
||||
* nodenumber on commandline, or node is CM and not down, hold, pvt
|
||||
* and
|
||||
* nocall is false
|
||||
*/
|
||||
if ((nlent->phone || forcedphone || inetaddr ) &&
|
||||
(forcedcalls || (((nlent->pflag & (NL_DUMMY|NL_DOWN|NL_HOLD|NL_PVT)) == 0) && ((localoptions & NOCALL) == 0)))) {
|
||||
Syslog('+', "Calling %s (%s, phone %s)",ascfnode(addr,0x1f), nlent->name,nlent->phone?nlent->phone:forcedphone);
|
||||
if ((forcedphone||inetaddr) && (((nlent->pflag & (NL_DUMMY|NL_DOWN|NL_HOLD|NL_PVT))==0) && ((localoptions & NOCALL)==0))) {
|
||||
Syslog('+', "Calling %s (%s, phone %s)", ascfnode(addr,0x1f), nlent->name, forcedphone);
|
||||
IsDoing("Call %s", ascfnode(addr, 0x0f));
|
||||
rc = portopen(addr);
|
||||
|
||||
if ((rc == MBERR_OK) && (!inetaddr)) {
|
||||
if ((rc = dialphone(forcedphone?forcedphone:nlent->phone))) {
|
||||
if ((rc == MBERR_OK) && (forcedphone)) {
|
||||
if ((rc = dialphone(forcedphone))) {
|
||||
Syslog('+', "Dial failed");
|
||||
nodeulock(addr);
|
||||
}
|
||||
@ -297,7 +259,7 @@ int call(faddr *addr)
|
||||
}
|
||||
} else {
|
||||
IsDoing("NoCall");
|
||||
Syslog('+', "Cannot call %s (%s, phone %s)", ascfnode(addr,0x1f),MBSE_SS(nlent->name), MBSE_SS(nlent->phone));
|
||||
Syslog('+', "Cannot call %s (%s)", ascfnode(addr,0x1f), MBSE_SS(nlent->name));
|
||||
rc = MBERR_NO_CONNECTION;
|
||||
putstatus(addr, 10, rc);
|
||||
nodeulock(addr);
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Purpose: Fidonet mailer
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2002
|
||||
* Copyright (C) 1997-2003
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@ -51,11 +51,11 @@
|
||||
|
||||
|
||||
int master = 0;
|
||||
int forcedcalls = 0;
|
||||
int immediatecall = FALSE;
|
||||
char *forcedphone = NULL;
|
||||
char *forcedline = NULL;
|
||||
char *inetaddr = NULL;
|
||||
char *protocol = NULL;
|
||||
char *envptr = NULL;
|
||||
time_t t_start;
|
||||
time_t t_end;
|
||||
@ -82,7 +82,7 @@ void usage(void)
|
||||
{
|
||||
fprintf(stderr,"ifcico; (c) Eugene G. Crosser, 1993-1997\n");
|
||||
fprintf(stderr,"mbcico ver. %s; (c) %s\n\n", VERSION, SHORTRIGHT);
|
||||
fprintf(stderr,"-r<role> -a<inetaddr> <node> ...\n");
|
||||
fprintf(stderr,"-a<inetaddr> <node>\n");
|
||||
fprintf(stderr,"-n<phone> forced phone number\n");
|
||||
fprintf(stderr,"-l<ttydevice> forced tty device\n");
|
||||
fprintf(stderr,"-t<tcpmode> must be one of ifc|itn|ibn, forces TCP/IP\n");
|
||||
@ -127,8 +127,7 @@ void die(int onsig)
|
||||
total = (int)(c_end - c_start);
|
||||
if (!total)
|
||||
total = 1;
|
||||
Syslog('+', "Sent %lu bytes, received %lu bytes, avg %d cps",
|
||||
sentbytes, rcvdbytes, (sentbytes + rcvdbytes) / total);
|
||||
Syslog('+', "Sent %lu bytes, received %lu bytes, avg %d cps", sentbytes, rcvdbytes, (sentbytes + rcvdbytes) / total);
|
||||
}
|
||||
|
||||
if (online)
|
||||
@ -149,15 +148,13 @@ void die(int onsig)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int i, c, uid;
|
||||
fa_list *callist = NULL, **tmpl;
|
||||
faddr *tmp;
|
||||
int rc, maxrc, callno = 0, succno = 0;
|
||||
faddr *addr = NULL;
|
||||
int i, c, uid, rc, maxrc;
|
||||
char *answermode = NULL, *p = NULL, *cmd = NULL;
|
||||
struct passwd *pw;
|
||||
FILE *fp;
|
||||
#ifdef IEMSI
|
||||
char temp[81];
|
||||
char temp[PATH_MAX];
|
||||
#endif
|
||||
|
||||
#ifdef MEMWATCH
|
||||
@ -203,14 +200,15 @@ int main(int argc, char *argv[])
|
||||
for (i = 0; i < NSIG; i++) {
|
||||
if ((i == SIGINT) || (i == SIGBUS) || (i == SIGFPE) || (i == SIGSEGV)) {
|
||||
signal(i, (void (*))die);
|
||||
} else
|
||||
} else {
|
||||
signal(i, SIG_DFL);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if history file exists, if not create a new one.
|
||||
*/
|
||||
cmd = calloc(128, sizeof(char));
|
||||
cmd = calloc(PATH_MAX, sizeof(char));
|
||||
sprintf(cmd, "%s/var/mailer.hist", getenv("MBSE_ROOT"));
|
||||
if ((fp = fopen(cmd, "r")) == NULL) {
|
||||
if ((fp = fopen(cmd, "a")) == NULL) {
|
||||
@ -239,7 +237,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
setmyname(argv[0]);
|
||||
|
||||
while ((c=getopt(argc,argv,"r:n:l:t:a:I:h")) != -1)
|
||||
while ((c = getopt(argc,argv,"r:n:l:t:a:I:h")) != -1) {
|
||||
switch (c) {
|
||||
case 'r': WriteError("commandline option -r is obsolete");
|
||||
break;
|
||||
@ -248,13 +246,16 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
|
||||
case 't': p = xstrcpy(optarg);
|
||||
if (strncmp(p, "ifc", 3) == 0)
|
||||
if (strncmp(p, "ifc", 3) == 0) {
|
||||
tcp_mode = TCPMODE_IFC;
|
||||
else if (strncmp(p, "itn", 3) == 0)
|
||||
protocol = xstrcpy((char *)"fido");
|
||||
} else if (strncmp(p, "itn", 3) == 0) {
|
||||
tcp_mode = TCPMODE_ITN;
|
||||
else if (strncmp(p, "ibn", 3) == 0)
|
||||
protocol = xstrcpy((char *)"telnet");
|
||||
} else if (strncmp(p, "ibn", 3) == 0) {
|
||||
tcp_mode = TCPMODE_IBN;
|
||||
else {
|
||||
protocol = xstrcpy((char *)"binkp");
|
||||
} else {
|
||||
usage();
|
||||
die(MBERR_COMMANDLINE);
|
||||
}
|
||||
@ -271,6 +272,7 @@ int main(int argc, char *argv[])
|
||||
default: usage();
|
||||
die(MBERR_COMMANDLINE);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Load rest of the configuration
|
||||
@ -281,8 +283,6 @@ int main(int argc, char *argv[])
|
||||
phone = xstrcpy(CFG.Phone);
|
||||
flags = xstrcpy(CFG.Flags);
|
||||
|
||||
tmpl = &callist;
|
||||
|
||||
while (argv[optind]) {
|
||||
|
||||
for (p = argv[optind]; (*p) && (*p == '*'); p++);
|
||||
@ -318,22 +318,14 @@ int main(int argc, char *argv[])
|
||||
answermode = argv[optind];
|
||||
Syslog('S', "Inbound \"%s\" mode", MBSE_SS(answermode));
|
||||
} else {
|
||||
Syslog('-', "Callist entry \"%s\"", argv[optind]);
|
||||
if ((tmp = parsefaddr(argv[optind]))) {
|
||||
*tmpl = (fa_list *)malloc(sizeof(fa_list));
|
||||
(*tmpl)->next = NULL;
|
||||
(*tmpl)->addr = tmp;
|
||||
tmpl = &((*tmpl)->next);
|
||||
if ((addr = parsefaddr(argv[optind]))) {
|
||||
immediatecall = TRUE;
|
||||
} else
|
||||
master = 1;
|
||||
} else {
|
||||
WriteError("Unrecognizable address \"%s\"", argv[optind]);
|
||||
}
|
||||
optind++;
|
||||
}
|
||||
|
||||
if (callist) {
|
||||
master = 1;
|
||||
forcedcalls = 1;
|
||||
optind++;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -368,40 +360,24 @@ int main(int argc, char *argv[])
|
||||
if (!diskfree(CFG.freespace))
|
||||
die(MBERR_DISK_FULL);
|
||||
|
||||
if (callist == NULL) {
|
||||
if (addr == NULL) {
|
||||
WriteError("Calling mbcico without node address not supported anymore");
|
||||
die(MBERR_COMMANDLINE);
|
||||
}
|
||||
|
||||
for (tmpl = &callist; *tmpl; tmpl = &((*tmpl)->next)) {
|
||||
callno++;
|
||||
forcedcalls = (*tmpl)->force;
|
||||
rc = call((*tmpl)->addr);
|
||||
Syslog('+', "Call to %s %s (rc=%d)", ascfnode((*tmpl)->addr,0x1f), rc?"failed":"successful",rc);
|
||||
rc = call(addr);
|
||||
Syslog('+', "Call to %s %s (rc=%d)", ascfnode(addr, 0x1f), rc?"failed":"successful", rc);
|
||||
if (rc > maxrc)
|
||||
maxrc=rc;
|
||||
if (rc == 0) {
|
||||
succno++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if (callist == NULL)
|
||||
// if (IsSema((char *)"scanout"))
|
||||
// RemoveSema((char *)"scanout");
|
||||
} else {
|
||||
/* slave */
|
||||
if (!answermode && tcp_mode == TCPMODE_IBN)
|
||||
answermode = xstrcpy((char *)"ibn");
|
||||
maxrc = answer(answermode);
|
||||
callno = 1;
|
||||
succno = (maxrc == 0);
|
||||
rc = maxrc = answer(answermode);
|
||||
Syslog('+', "Incoming call %s (rc=%d)", rc?"failed":"successful", rc);
|
||||
}
|
||||
|
||||
if (callno)
|
||||
Syslog('+', "%d of %d calls, maxrc=%d",succno,callno,maxrc);
|
||||
|
||||
tidy_falist(&callist);
|
||||
|
||||
tidy_faddr(addr);
|
||||
if (maxrc)
|
||||
die(maxrc);
|
||||
else
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Purpose ...............: Fidonet mailer
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2002
|
||||
* Copyright (C) 1997-2003
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@ -118,7 +118,7 @@ int opentcp(char *name)
|
||||
else
|
||||
server.sin_port = htons(FIDOPORT);
|
||||
break;
|
||||
case TCPMODE_ITN: if ((se = getservbyname("tfido", "tcp")))
|
||||
case TCPMODE_ITN: if ((se = getservbyname("telnet", "tcp")))
|
||||
server.sin_port = se->s_port;
|
||||
else
|
||||
server.sin_port = htons(TELNPORT);
|
||||
|
Reference in New Issue
Block a user