Changed daemon mode tcpip priority (to be first in outbound calls), fixed daemon_call creating opts record, fixed working time for tcp nodes

zx
Alexey Khromov 3 days ago
parent bba77edecd
commit 5a7bac039a

@ -178,7 +178,7 @@ static int daemon_sysentry_deinit(s_sysentry *sysent)
return 0;
}
static bool daemon_node_cancall_line(const s_node *node, const s_override *ovrd)
static int daemon_node_cancall_line(const s_node *node, const s_override *ovrd)
{
bool good_phone = FALSE;
bool good_host = FALSE;
@ -208,6 +208,11 @@ static bool daemon_node_cancall_line(const s_node *node, const s_override *ovrd)
if( tcpip_isgood_host(ovrd->sIpaddr) )
good_host = TRUE;
}
else if ( node && *node->host )
{
if( tcpip_isgood_host(node->host) )
good_host = TRUE;
}
/*
* Check work time
@ -231,6 +236,16 @@ static bool daemon_node_cancall_line(const s_node *node, const s_override *ovrd)
good_time = TRUE;
}
// Must be more complicated, i.e. call to IP even if modem is not good time
if ( good_host )
{
good_time = TRUE;
}
DEB((D_DAEMON, "daemon: node_cancall_line good_phone: %d, good_time:%d, good_host:%d",
good_phone, good_time, good_host));
if( good_time )
{
if( good_host )
@ -323,9 +338,23 @@ static bool daemon_node_cancall(s_sysentry *syst, bool ign_wtime, bool tcpip)
return FALSE;
}
/* Make check for tcpip out */
if ( tcpip )
{
rc = daemon_node_cancall_line(&syst->node, NULL);
DEB((D_DAEMON, "daemon tcpip: node_cancall rc=%d", rc));
if ( rc == 2 )
{
syst->tcpip = TRUE;
return TRUE;
}
}
/* Make checks for all lines */
if( syst->overrides )
{
DEB((D_DAEMON, "daemon: node_cancall OVR-IN"));
if( syst->lineptr && syst->lineptr->hidden )
{
line = syst->line + 1;
@ -363,11 +392,18 @@ static bool daemon_node_cancall(s_sysentry *syst, bool ign_wtime, bool tcpip)
}
line++;
}
}
else /* Node without overriden parameters */
{
syst->line = line = 0;
return daemon_node_cancall_line(&syst->node, NULL);
rc = daemon_node_cancall_line(&syst->node, NULL);
DEB((D_DAEMON, "daemon: node_cancall rc=%d", rc));
if ( rc )
{
syst->tcpip = (rc == 2) ? TRUE : FALSE;
return TRUE;
}
}
return FALSE;
@ -687,6 +723,8 @@ int daemon_rescan_sysqueue(s_sysqueue *q, s_daemon_queue dqs[])
#ifdef DEBUG
log_sysqueue(q);
DEB((D_DAEMON, "daemon rescan_sysqueue daemon queue: MODEM: %d, %d; TCPIP: %d, %d",
dqs[MODEM_QUEUE].circle, dqs[MODEM_QUEUE].current, dqs[TCPIP_QUEUE].circle, dqs[TCPIP_QUEUE].current));
#endif
return 0;
@ -1010,16 +1048,16 @@ int daemon_run(const char *confname, const char *incname, bool quit)
timer_set(&timer_alive, DAEMON_ALIVE_TIMER);
}
if( max_modem > 0 )
if( max_tcpip > 0 )
{
DEB((D_INFO,"daemon: daemon_modem_queue"));
daemon_queue_do(&daemon_queues[MODEM_QUEUE]);
DEB((D_INFO,"daemon: daemon_tcpip_queue"));
daemon_queue_do(&daemon_queues[TCPIP_QUEUE]);
}
if( max_tcpip > 0 )
if( max_modem > 0 )
{
DEB((D_INFO,"daemon: daemon_modem_queue"));
daemon_queue_do(&daemon_queues[TCPIP_QUEUE]);
daemon_queue_do(&daemon_queues[MODEM_QUEUE]);
}
(void)sleep(DAEMON_IDLE_SLEEP);

@ -54,8 +54,13 @@ static int daemon_call_branch(s_sysentry *syst, const char *lockdir, s_modemport
s_bforce_opts opts;
// TODO: add hiddenline round-robin
memset(&opts, '\0', sizeof(s_bforce_opts));
opts.hiddline = 0;
opts.runmode = MODE_CALL_DEFAULT;
if ( syst->tcpip )
opts.runmode = MODE_CALL_IP;
else
opts.runmode = MODE_CALL_DEFAULT;
opts.ipproto = NULL;
opts.phone = NULL;
opts.force = 0;

@ -294,7 +294,7 @@ int nodelist_parsestring(s_node *node, char *str)
//TODO: Add more INA flags to array
nodelist_flagvalue(node->flags, "INA", node->host);
DEB((D_NODELIST, "nodelist: Parsed inet values IBN: %d, IFC: %d, ITN: %d, INA: %d", node->do_binkp, node->do_ifcico, node->do_telnet, node->host));
DEB((D_NODELIST, "nodelist: Parsed inet values IBN: %d, IFC: %d, ITN: %d, INA: %s", node->do_binkp, node->do_ifcico, node->do_telnet, node->host));
return 0;
}

@ -543,7 +543,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 +568,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 +582,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 +594,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,31 +613,29 @@ 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;
}
call_mayuse |= call_mustuse; // it simplifies logics: all required is allowed
//char s[300];
//snprintf(s, 299, "initial: may use %d must use %d", call_mayuse, call_mustuse);
//log(s);
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
@ -693,9 +699,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
*/
@ -746,6 +752,8 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
state.override.sIpaddr, sizeof(state.node.host));
}
DEB((D_EVENT, "Calling init, IPHOST", state.node.host));
if( call_mayuse & CALL_TCPIP_ANY && !tcpip_isgood_host(state.node.host) ) {
char *fidodnszone = conf_string(cf_fidodnszone);
if (fidodnszone) {
@ -765,6 +773,7 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
{
call_mayuse &= ~CALL_TCPIP_ANY;
log("bad host, exclude IP");
DEB((D_EVENT, "bad host %s, exclude IP", state.node.host));
if( call_mustuse & CALL_TCPIP_ANY )
{
errmsg = "don't know host name";

Loading…
Cancel
Save