|
|
|
@ -480,10 +480,15 @@ int call_system_tcpip(int callwith) // only TCPIP values
|
|
|
|
|
{
|
|
|
|
|
char abuf[BF_MAXADDRSTR+1];
|
|
|
|
|
int rc = BFERR_NOERROR;
|
|
|
|
|
|
|
|
|
|
char * pbuf;
|
|
|
|
|
char * target;
|
|
|
|
|
int resflg;
|
|
|
|
|
/*
|
|
|
|
|
* Set verbal line name to "tcpip" value
|
|
|
|
|
*/
|
|
|
|
|
memset(abuf, '\0', BF_MAXADDRSTR+1);
|
|
|
|
|
target = xmalloc(1024);
|
|
|
|
|
memset(target, '\0', 1024);
|
|
|
|
|
|
|
|
|
|
state.linename = xstrcpy("tcpip");
|
|
|
|
|
state.inet = TRUE;
|
|
|
|
@ -502,14 +507,17 @@ int call_system_tcpip(int callwith) // only TCPIP values
|
|
|
|
|
case CALL_TCPIP_BINKP:
|
|
|
|
|
state.tcpmode = TCPMODE_BINKP;
|
|
|
|
|
state.session = SESSION_BINKP;
|
|
|
|
|
target = xstrcpy("IBN");
|
|
|
|
|
break;
|
|
|
|
|
case CALL_TCPIP_IFCICO:
|
|
|
|
|
state.tcpmode = TCPMODE_RAW;
|
|
|
|
|
state.session = SESSION_UNKNOWN;
|
|
|
|
|
target = xstrcpy("IFC");
|
|
|
|
|
break;
|
|
|
|
|
case CALL_TCPIP_TELNET:
|
|
|
|
|
state.tcpmode = TCPMODE_TELNET;
|
|
|
|
|
state.session = SESSION_UNKNOWN;
|
|
|
|
|
target = xstrcpy("ITN");
|
|
|
|
|
break;
|
|
|
|
|
defalt:
|
|
|
|
|
log("invalid protocol for TCP/IP module");
|
|
|
|
@ -520,8 +528,45 @@ defalt:
|
|
|
|
|
ftn_addrstr(abuf, state.node.addr),
|
|
|
|
|
(state.node.name && *state.node.name ) ? state.node.name : "<none>",
|
|
|
|
|
(state.node.host && *state.node.host) ? state.node.host : "<none>");
|
|
|
|
|
|
|
|
|
|
memset(abuf, '\0', BF_MAXADDRSTR+1);
|
|
|
|
|
pbuf = xmalloc(1024);
|
|
|
|
|
|
|
|
|
|
resflg = nodelist_lookup_string(pbuf, 1024, state.node.addr);
|
|
|
|
|
if ( ! resflg )
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
char *p = strcasestr(pbuf, target);
|
|
|
|
|
|
|
|
|
|
if( (rc = tcpip_connect(state.node.host, state.tcpmode)) == 0
|
|
|
|
|
if ( p )
|
|
|
|
|
{
|
|
|
|
|
target = strchr(p, ',');
|
|
|
|
|
if ( target ) target[0] = '\0';
|
|
|
|
|
target = strrchr(p, ':');
|
|
|
|
|
if ( target ) {
|
|
|
|
|
target++;
|
|
|
|
|
strcpy(abuf,target);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free(pbuf);
|
|
|
|
|
pbuf = xstrcpy(state.node.host);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( ! resflg )
|
|
|
|
|
{
|
|
|
|
|
if ( abuf[0] != '\0' )
|
|
|
|
|
{
|
|
|
|
|
// port not empty
|
|
|
|
|
DEB((D_EVENT, "Modifying host address %s with port %s", pbuf, abuf));
|
|
|
|
|
pbuf = xstrcat(pbuf, ":");
|
|
|
|
|
pbuf = xstrcat(pbuf, abuf);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( (rc = tcpip_connect(pbuf, state.tcpmode)) == 0
|
|
|
|
|
&& (rc = tcpip_init() == 0) )
|
|
|
|
|
{
|
|
|
|
|
TTYSTATUS(1);
|
|
|
|
@ -532,7 +577,7 @@ defalt:
|
|
|
|
|
{
|
|
|
|
|
rc = BFERR_CANT_CONNECT10;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
free(pbuf);
|
|
|
|
|
return rc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -543,7 +588,7 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
|
|
|
|
|
char s[300];
|
|
|
|
|
snprintf(s, 299, "bforce calling system %d:%d/%d.%d", addr.zone, addr.net, addr.node, addr.point );
|
|
|
|
|
log(s);
|
|
|
|
|
|
|
|
|
|
DEB((D_EVENT, s));
|
|
|
|
|
// find suitable way of connection and try to make session
|
|
|
|
|
|
|
|
|
|
int rc = 0;
|
|
|
|
@ -568,12 +613,13 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
state.listed = state.node.listed;
|
|
|
|
|
//DEB((D_EVENT, "Calling init, listed=%d", state.listed));
|
|
|
|
|
state.node.addr.domain[0] = '\0'; /* Discard domain for node address */
|
|
|
|
|
|
|
|
|
|
// 1. If call method specified in cmdline, do use it
|
|
|
|
|
// 2. If not, use nodelist data and overrides and call all available methods
|
|
|
|
|
// If override contains Phone or IP flags, ignore nodelist connect methods (but save INA if not overrided)
|
|
|
|
|
|
|
|
|
|
DEB((D_EVENT, "Calling init, runmode=%d", opts->runmode));
|
|
|
|
|
// 1st - get all allowed call ways
|
|
|
|
|
// 2nd - gather information reqired to call and remove unavailable ways (no info, node does not support)
|
|
|
|
|
|
|
|
|
@ -581,7 +627,7 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
|
|
|
|
|
|
|
|
|
|
if( opts->runmode == MODE_CALL_DEFAULT )
|
|
|
|
|
{
|
|
|
|
|
call_mayuse = CALL_MODEM | CALL_TCPIP_ANY;
|
|
|
|
|
call_mustuse = CALL_MODEM | CALL_TCPIP_ANY;
|
|
|
|
|
}
|
|
|
|
|
else if( opts->runmode == MODE_CALL_STDIO )
|
|
|
|
|
{
|
|
|
|
@ -593,7 +639,14 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
|
|
|
|
|
}
|
|
|
|
|
else if( opts->runmode == MODE_CALL_IP )
|
|
|
|
|
{
|
|
|
|
|
if( strcasecmp(opts->ipproto, "binkp") == 0 )
|
|
|
|
|
DEB((D_EVENT, "Calling init, MODE_CALL_IP"));
|
|
|
|
|
if( !(opts->ipproto) ) // determine from nodelist/override
|
|
|
|
|
{
|
|
|
|
|
DEB((D_EVENT, "ipproto not set"));
|
|
|
|
|
call_mayuse = CALL_TCPIP_ANY;
|
|
|
|
|
call_mustuse = 0;
|
|
|
|
|
}
|
|
|
|
|
else if( strcasecmp(opts->ipproto, "binkp") == 0 )
|
|
|
|
|
{
|
|
|
|
|
call_mustuse = CALL_TCPIP_BINKP;
|
|
|
|
|
}
|
|
|
|
@ -605,20 +658,17 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
|
|
|
|
|
{
|
|
|
|
|
call_mustuse = CALL_TCPIP_TELNET;
|
|
|
|
|
}
|
|
|
|
|
else if( opts->ipproto == NULL ) // determine from nodelist/override
|
|
|
|
|
{
|
|
|
|
|
call_mayuse = CALL_TCPIP_ANY;
|
|
|
|
|
call_mustuse = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DEB((D_EVENT, "Unknown protocol %s", opts->ipproto));
|
|
|
|
|
log("Unknown protocol");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
log("Unknown protocol");
|
|
|
|
|
DEB((D_EVENT, "Unknown runmode %d", opts->runmode));
|
|
|
|
|
log("Unknown runmode");
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -627,9 +677,10 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
|
|
|
|
|
//char s[300];
|
|
|
|
|
//snprintf(s, 299, "initial: may use %d must use %d", call_mayuse, call_mustuse);
|
|
|
|
|
//log(s);
|
|
|
|
|
//DEB((D_EVENT, s));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( call_mayuse & CALL_MODEM )
|
|
|
|
|
if( (call_mayuse & CALL_MODEM) )
|
|
|
|
|
{
|
|
|
|
|
// 1. use phone from opts
|
|
|
|
|
// 2. use overrides
|
|
|
|
@ -650,7 +701,7 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
|
|
|
|
|
{
|
|
|
|
|
log("bad phone, excluding modem");
|
|
|
|
|
call_mayuse &= ~CALL_MODEM;
|
|
|
|
|
if( call_mustuse & CALL_MODEM )
|
|
|
|
|
if( !(call_mayuse) )
|
|
|
|
|
{
|
|
|
|
|
errmsg = "don't know phone number";
|
|
|
|
|
gotoexit(BFERR_PHONE_UNKNOWN);
|
|
|
|
@ -684,7 +735,7 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
|
|
|
|
|
{
|
|
|
|
|
call_mayuse &= ~CALL_MODEM;
|
|
|
|
|
log("bad worktime, excluding modem");
|
|
|
|
|
if( call_mustuse & CALL_MODEM )
|
|
|
|
|
if( !(call_mayuse) )
|
|
|
|
|
{
|
|
|
|
|
errmsg = "not works now, try later";
|
|
|
|
|
gotoexit(BFERR_NOTWORKING);
|
|
|
|
@ -693,9 +744,9 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// snprintf(s, 299, "after phone check: may use %d must use %d", call_mayuse, call_mustuse);
|
|
|
|
|
// log(s);
|
|
|
|
|
|
|
|
|
|
//snprintf(s, 299, "after phone check: may use %d must use %d", call_mayuse, call_mustuse);
|
|
|
|
|
//log(s);
|
|
|
|
|
//DEB((D_EVENT, s));
|
|
|
|
|
/*
|
|
|
|
|
* Apply overrides to the node information
|
|
|
|
|
*/
|
|
|
|
@ -714,7 +765,8 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
|
|
|
|
|
|
|
|
|
|
if( !(call_mustuse & CALL_TCPIP_BINKP) && (call_mayuse & CALL_TCPIP_BINKP) )
|
|
|
|
|
{
|
|
|
|
|
if( nodelist_checkflag(state.node.flags, "BINKP") != 0 && nodelist_checkflag(state.node.flags, "IBN") != 0 )
|
|
|
|
|
//if( nodelist_checkflag(state.node.flags, "BINKP") != 0 && nodelist_checkflag(state.node.flags, "IBN") != 0 )
|
|
|
|
|
if( state.node.do_binkp == 0 )
|
|
|
|
|
{
|
|
|
|
|
call_mayuse &= ~CALL_TCPIP_BINKP;
|
|
|
|
|
}
|
|
|
|
@ -722,7 +774,8 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
|
|
|
|
|
|
|
|
|
|
if( !(call_mustuse & CALL_TCPIP_IFCICO) && (call_mayuse & CALL_TCPIP_IFCICO) )
|
|
|
|
|
{
|
|
|
|
|
if( nodelist_checkflag(state.node.flags, "IFC") != 0 && nodelist_checkflag(state.node.flags, "IFC") != 0 )
|
|
|
|
|
//if( nodelist_checkflag(state.node.flags, "IFC") != 0 && nodelist_checkflag(state.node.flags, "IFC") != 0 )
|
|
|
|
|
if( state.node.do_ifcico == 0 )
|
|
|
|
|
{
|
|
|
|
|
call_mayuse &= ~CALL_TCPIP_IFCICO;
|
|
|
|
|
}
|
|
|
|
@ -730,7 +783,8 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
|
|
|
|
|
|
|
|
|
|
if( !(call_mustuse & CALL_TCPIP_TELNET) && (call_mayuse & CALL_TCPIP_TELNET) )
|
|
|
|
|
{
|
|
|
|
|
if( nodelist_checkflag(state.node.flags, "TELN") != 0 && nodelist_checkflag(state.node.flags, "TLN") != 0 )
|
|
|
|
|
//if( nodelist_checkflag(state.node.flags, "TELN") != 0 && nodelist_checkflag(state.node.flags, "TLN") != 0 )
|
|
|
|
|
if( state.node.do_telnet == 0 )
|
|
|
|
|
{
|
|
|
|
|
call_mayuse &= ~CALL_TCPIP_TELNET;
|
|
|
|
|
}
|
|
|
|
@ -746,7 +800,12 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
|
|
|
|
|
state.override.sIpaddr, sizeof(state.node.host));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( call_mayuse & CALL_TCPIP_ANY && !tcpip_isgood_host(state.node.host) ) {
|
|
|
|
|
//DEB((D_EVENT, "Calling init, IPHOST", state.node.host));
|
|
|
|
|
|
|
|
|
|
// We have at least one protocol and not valid address - try to
|
|
|
|
|
// find INA with through Fidonet DNS
|
|
|
|
|
if( (call_mayuse & CALL_TCPIP_ANY) && !tcpip_isgood_host(state.node.host) )
|
|
|
|
|
{
|
|
|
|
|
char *fidodnszone = conf_string(cf_fidodnszone);
|
|
|
|
|
if (fidodnszone) {
|
|
|
|
|
if (addr.point) {
|
|
|
|
@ -761,17 +820,21 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( call_mayuse & CALL_TCPIP_ANY && !tcpip_isgood_host(state.node.host) )
|
|
|
|
|
// We have no valid tcpip protocols OR not valid address
|
|
|
|
|
if( !(call_mayuse & CALL_TCPIP_ANY) || !tcpip_isgood_host(state.node.host) )
|
|
|
|
|
{
|
|
|
|
|
call_mayuse &= ~CALL_TCPIP_ANY;
|
|
|
|
|
log("bad host, exclude IP");
|
|
|
|
|
if( call_mustuse & CALL_TCPIP_ANY )
|
|
|
|
|
DEB((D_EVENT, "bad host or proto -> exclude IP, mayuse=%d", call_mayuse));
|
|
|
|
|
|
|
|
|
|
// If we had ONLY tcpip command - go out with error
|
|
|
|
|
if( !(call_mayuse) )
|
|
|
|
|
{
|
|
|
|
|
errmsg = "don't know host name";
|
|
|
|
|
errmsg = "Aborting, don't know host name";
|
|
|
|
|
gotoexit(BFERR_PHONE_UNKNOWN);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
DEB((D_EVENT,"sess_call: may use %d must use %d", call_mayuse, call_mustuse));
|
|
|
|
|
// snprintf(s, 299, "after IP check: may use %d must use %d", call_mayuse, call_mustuse);
|
|
|
|
|
// log(s);
|
|
|
|
|
|
|
|
|
@ -807,29 +870,34 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
|
|
|
|
|
|
|
|
|
|
// try allowed methods and break if rc == 0
|
|
|
|
|
rc = -1;
|
|
|
|
|
|
|
|
|
|
if( rc && call_mayuse & CALL_STDIO )
|
|
|
|
|
|
|
|
|
|
if( rc && (call_mayuse & CALL_STDIO) )
|
|
|
|
|
{
|
|
|
|
|
DEB((D_EVENT,"sess_call: calling stdio"));
|
|
|
|
|
rc = call_system_quiet(opts->connect, opts->inetd);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( rc && call_mayuse & CALL_TCPIP_BINKP )
|
|
|
|
|
if( rc && (call_mayuse & CALL_TCPIP_BINKP) )
|
|
|
|
|
{
|
|
|
|
|
DEB((D_EVENT,"sess_call: calling binkp"));
|
|
|
|
|
rc = call_system_tcpip(CALL_TCPIP_BINKP);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( rc && call_mayuse & CALL_TCPIP_IFCICO )
|
|
|
|
|
if( rc && (call_mayuse & CALL_TCPIP_IFCICO) )
|
|
|
|
|
{
|
|
|
|
|
DEB((D_EVENT,"sess_call: calling ifcico"));
|
|
|
|
|
rc = call_system_tcpip(CALL_TCPIP_IFCICO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( rc && call_mayuse & CALL_TCPIP_TELNET )
|
|
|
|
|
if( rc && (call_mayuse & CALL_TCPIP_TELNET) )
|
|
|
|
|
{
|
|
|
|
|
DEB((D_EVENT,"sess_call: calling telnet"));
|
|
|
|
|
rc = call_system_tcpip(CALL_TCPIP_TELNET);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if( rc && call_mayuse & CALL_MODEM )
|
|
|
|
|
if( rc && (call_mayuse & CALL_MODEM) )
|
|
|
|
|
{
|
|
|
|
|
DEB((D_EVENT,"sess_call: calling MODEM"));
|
|
|
|
|
setproctitle("bforce calling %.32s, %.32s",
|
|
|
|
|
ftn_addrstr(abuf, state.node.addr), state.node.phone);
|
|
|
|
|
rc = -1;
|
|
|
|
@ -850,6 +918,7 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
|
|
|
|
|
|
|
|
|
|
if( port_lock(p_lockdir, state.modemport) == 0 ) /* Successfuly locked port */
|
|
|
|
|
{
|
|
|
|
|
DEB((D_EVENT,"sess_call: call_system_modem running"));
|
|
|
|
|
rc = call_system_modem();
|
|
|
|
|
port_unlock(p_lockdir, state.modemport);
|
|
|
|
|
}
|
|
|
|
|