3 Commits
14 changed files with 79 additions and 241 deletions
-4
View File
@@ -253,7 +253,3 @@ Alexey Khromov (zx@zxalexis.ru)
0.25.1 0.25.1
+ Added testing script for PSTN comms (tests folder). + Added testing script for PSTN comms (tests folder).
0.25.2
+ Adopted for outgoing IPv6 communication
+1 -1
View File
@@ -1 +1 @@
0.25.3 0.25.1
+4 -49
View File
@@ -178,7 +178,7 @@ static int daemon_sysentry_deinit(s_sysentry *sysent)
return 0; return 0;
} }
static int daemon_node_cancall_line(const s_node *node, const s_override *ovrd) static bool daemon_node_cancall_line(const s_node *node, const s_override *ovrd)
{ {
bool good_phone = FALSE; bool good_phone = FALSE;
bool good_host = FALSE; bool good_host = FALSE;
@@ -208,11 +208,6 @@ static int daemon_node_cancall_line(const s_node *node, const s_override *ovrd)
if( tcpip_isgood_host(ovrd->sIpaddr) ) if( tcpip_isgood_host(ovrd->sIpaddr) )
good_host = TRUE; good_host = TRUE;
} }
else if ( node && *node->host )
{
if( tcpip_isgood_host(node->host) )
good_host = TRUE;
}
/* /*
* Check work time * Check work time
@@ -236,16 +231,6 @@ static int daemon_node_cancall_line(const s_node *node, const s_override *ovrd)
good_time = TRUE; 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_time )
{ {
if( good_host ) if( good_host )
@@ -338,23 +323,9 @@ static bool daemon_node_cancall(s_sysentry *syst, bool ign_wtime, bool tcpip)
return FALSE; 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 */ /* Make checks for all lines */
if( syst->overrides ) if( syst->overrides )
{ {
DEB((D_DAEMON, "daemon: node_cancall OVR-IN"));
if( syst->lineptr && syst->lineptr->hidden ) if( syst->lineptr && syst->lineptr->hidden )
{ {
line = syst->line + 1; line = syst->line + 1;
@@ -392,18 +363,11 @@ static bool daemon_node_cancall(s_sysentry *syst, bool ign_wtime, bool tcpip)
} }
line++; line++;
} }
} }
else /* Node without overriden parameters */ else /* Node without overriden parameters */
{ {
syst->line = line = 0; syst->line = line = 0;
rc = daemon_node_cancall_line(&syst->node, NULL); return 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; return FALSE;
@@ -723,8 +687,6 @@ int daemon_rescan_sysqueue(s_sysqueue *q, s_daemon_queue dqs[])
#ifdef DEBUG #ifdef DEBUG
log_sysqueue(q); 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 #endif
return 0; return 0;
@@ -1048,17 +1010,10 @@ int daemon_run(const char *confname, const char *incname, bool quit)
timer_set(&timer_alive, DAEMON_ALIVE_TIMER); timer_set(&timer_alive, DAEMON_ALIVE_TIMER);
} }
if( max_tcpip > 0 )
{
DEB((D_INFO,"daemon: daemon_tcpip_queue"));
daemon_queue_do(&daemon_queues[TCPIP_QUEUE]);
}
if( max_modem > 0 ) if( max_modem > 0 )
{
DEB((D_INFO,"daemon: daemon_modem_queue"));
daemon_queue_do(&daemon_queues[MODEM_QUEUE]); daemon_queue_do(&daemon_queues[MODEM_QUEUE]);
} if( max_tcpip > 0 )
daemon_queue_do(&daemon_queues[TCPIP_QUEUE]);
(void)sleep(DAEMON_IDLE_SLEEP); (void)sleep(DAEMON_IDLE_SLEEP);
break; break;
+2 -14
View File
@@ -54,12 +54,7 @@ static int daemon_call_branch(s_sysentry *syst, const char *lockdir, s_modemport
s_bforce_opts opts; s_bforce_opts opts;
// TODO: add hiddenline round-robin // TODO: add hiddenline round-robin
memset(&opts, '\0', sizeof(s_bforce_opts));
opts.hiddline=0; opts.hiddline=0;
if ( syst->tcpip )
opts.runmode = MODE_CALL_IP;
else
opts.runmode = MODE_CALL_DEFAULT; opts.runmode = MODE_CALL_DEFAULT;
opts.ipproto = NULL; opts.ipproto = NULL;
opts.phone = NULL; opts.phone = NULL;
@@ -67,7 +62,7 @@ static int daemon_call_branch(s_sysentry *syst, const char *lockdir, s_modemport
opts.inetd = 0; opts.inetd = 0;
opts.connect = NULL; opts.connect = NULL;
opts.device = NULL; opts.device = NULL;
DEB((D_DAEMON, "daemon_call: calling call_system from branch"));
// log("doing call_system"); // log("doing call_system");
return call_system(syst->node.addr, &opts); return call_system(syst->node.addr, &opts);
} }
@@ -93,10 +88,7 @@ int daemon_call(s_sysentry *syst)
* Check whether this node is allready locked * Check whether this node is allready locked
*/ */
if( out_bsy_check(syst->node.addr) ) if( out_bsy_check(syst->node.addr) )
{
DEB((D_DAEMON, "daemon_call: node locked by .bsy file"));
return 0; return 0;
}
/* /*
* Set state structure to make expressions works properly now * Set state structure to make expressions works properly now
@@ -109,7 +101,6 @@ int daemon_call(s_sysentry *syst)
if( syst->tcpip == FALSE ) if( syst->tcpip == FALSE )
{ {
DEB((D_DAEMON, "daemon_call: tcpip false - prep modem line"));
if( (p_lockdir = conf_string(cf_uucp_lock_directory)) == NULL ) if( (p_lockdir = conf_string(cf_uucp_lock_directory)) == NULL )
p_lockdir = BFORCE_LOCK_DIR; p_lockdir = BFORCE_LOCK_DIR;
@@ -119,9 +110,6 @@ int daemon_call(s_sysentry *syst)
return 1; return 1;
} }
} }
DEB((D_DAEMON, "call %s line %d via %s",
ftn_addrstr(abuf, syst->node.addr), syst->line,
syst->tcpip ? "TCP/IP" : modemport->name));
log("call %s line %d via %s", log("call %s line %d via %s",
ftn_addrstr(abuf, syst->node.addr), syst->line, ftn_addrstr(abuf, syst->node.addr), syst->line,
@@ -150,7 +138,7 @@ int daemon_call(s_sysentry *syst)
} }
/* Now we are in child process */ /* Now we are in child process */
DEB((D_DAEMON, "daemon_call: fork success - calling..."));
exit(daemon_call_branch(syst, p_lockdir, modemport)); exit(daemon_call_branch(syst, p_lockdir, modemport));
} }
+20 -71
View File
@@ -19,49 +19,29 @@
#define DEFAULT_PORT 60179 /* Birthday .. mother fucker :) */ #define DEFAULT_PORT 60179 /* Birthday .. mother fucker :) */
struct addrinfo *ai = NULL;
static RETSIGTYPE tcpip_interrupt(int sig) static RETSIGTYPE tcpip_interrupt(int sig)
{ {
tty_abort = TRUE; tty_abort = TRUE;
(void)log("terminating on signal %d", sig); log("terminating on signal %d", sig);
} }
static RETSIGTYPE tcpip_brokenpipe(int sig) static RETSIGTYPE tcpip_brokenpipe(int sig)
{ {
tty_abort = TRUE; tty_abort = TRUE;
if( tty_online ) if( tty_online )
(void)log("connection closed"); log("connection closed");
else else
(void)log("terminating on signal %d", sig); log("terminating on signal %d", sig);
} }
static int tcpip_connect2(struct addrinfo *ai) static int tcpip_connect2(struct sockaddr_in server)
{ {
int fd = -1; int fd;
char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
struct addrinfo *rai; DEB((D_INFO, "tcpip_connect2: trying \"%s\" at port %d",
inet_ntoa(server.sin_addr), (int)ntohs(server.sin_port)));
for (rai = ai; rai != NULL; rai = rai->ai_next) if( (fd = socket(AF_INET, SOCK_STREAM, 0)) < 0 )
{
if (getnameinfo(rai->ai_addr, rai->ai_addrlen, hbuf, sizeof(hbuf), sbuf,
sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV) == 0)
DEB((D_INFO, "tcpip_connect2: trying host=%s, serv=%s", hbuf, sbuf));
fd = socket (rai->ai_family, rai->ai_socktype, rai->ai_protocol);
if ( fd == -1 )
{
DEB((D_INFO, "tcpip_connect2: socket error"));
}
else break;
hbuf[0]='\0';
sbuf[0]='\0';
}
DEB((D_INFO, "tcpip_connect2: socket success: %d", fd));
if (fd < 0 )
{ {
logerr("can't create socket"); logerr("can't create socket");
return(1); return(1);
@@ -104,9 +84,9 @@ static int tcpip_connect2(struct addrinfo *ai)
clearerr(stdout); clearerr(stdout);
clearerr(stderr); clearerr(stderr);
if( connect(0, rai->ai_addr, rai->ai_addrlen) == -1 ) if( connect(0, (struct sockaddr*)&server, sizeof(server)) == -1 )
{ {
logerr("can't connect to %s", hbuf); logerr("can't connect to %s", inet_ntoa(server.sin_addr));
close(0); close(0);
close(1); close(1);
close(2); close(2);
@@ -119,7 +99,8 @@ static int tcpip_connect2(struct addrinfo *ai)
return 1; return 1;
} }
(void)log("TCP/IP connect success to %s on service %s", hbuf, sbuf); log("TCP/IP connect to %s on port %d",
inet_ntoa(server.sin_addr), (int)ntohs(server.sin_port));
return(0); return(0);
} }
@@ -127,23 +108,14 @@ static int tcpip_connect2(struct addrinfo *ai)
int tcpip_connect(const char *hostname, e_tcpmode tcpmode) int tcpip_connect(const char *hostname, e_tcpmode tcpmode)
{ {
int rc = 0; int rc = 0;
//struct hostent *he = NULL; struct hostent *he = NULL;
//struct servent *se = NULL; struct servent *se = NULL;
//struct sockaddr_in server; struct sockaddr_in server;
//struct sockaddr_storage server;
struct addrinfo *aisave = NULL;
struct addrinfo aihints;
int nameres = 0;
char *host = xstrcpy(hostname); char *host = xstrcpy(hostname);
char *p = strrchr(host, ':'); char *p = strrchr(host, ':');
const char *port = NULL; const char *port = NULL;
server.sin_family = AF_INET;
// AF_INET - only IPv4
//server.sin_family = AF_INET;
if( p ) if( p )
{ *p++ = '\0'; port = p; } { *p++ = '\0'; port = p; }
@@ -154,31 +126,15 @@ int tcpip_connect(const char *hostname, e_tcpmode tcpmode)
else /* Can not rely on /etc/services - it is not well-known port */ else /* Can not rely on /etc/services - it is not well-known port */
port = "60179"; port = "60179";
// Do not need it
/*
if( ISDEC(port) ) if( ISDEC(port) )
server.sin_port = htons(atoi(port)); server.sin_port = htons(atoi(port));
else if( (se = getservbyname(port, "tcp")) ) else if( (se = getservbyname(port, "tcp")) )
server.sin_port = se->s_port; server.sin_port = se->s_port;
else else
{ log("invalid port or service name \"%s\"", port); rc = 1; } { log("invalid port or service name \"%s\"", port); rc = 1; }
*/
//if( rc == 0 )
//{
DEB((D_INFO, "tcpip_connect: port is %s", port));
memset( &aihints, 0, sizeof( aihints) );
aihints.ai_family = AF_UNSPEC;
//aihints.ai_socktype = SOCK_STREAM;
aihints.ai_protocol = IPPROTO_TCP;
nameres = getaddrinfo ( host, port, &aihints, &ai ); if( rc == 0 )
if ( nameres != 0 )
{ {
rc = 1;
log("Resolver error for host %s, port %s: \"%s\".", host, port, gai_strerror(nameres));
}
// GetHostByName works with IPv4 only and *deprecated*
/*
if( (he = gethostbyname(host)) ) if( (he = gethostbyname(host)) )
{ {
memcpy(&server.sin_addr, he->h_addr, he->h_length); memcpy(&server.sin_addr, he->h_addr, he->h_length);
@@ -203,19 +159,12 @@ int tcpip_connect(const char *hostname, e_tcpmode tcpmode)
log("unknown error while resolving host \"%s\"", host); log("unknown error while resolving host \"%s\"", host);
break; break;
} }
} */ }
//} }
if( host ) { free(host); host = NULL; } if( host ) { free(host); host = NULL; }
DEB((D_INFO, "tcpip_connect: resolver got result!"));
aisave = ai;
if (rc == 0 ) return rc ? rc : tcpip_connect2(server);
rc = tcpip_connect2(ai);
freeaddrinfo( aisave );
return rc;
} }
int tcpip_init(void) int tcpip_init(void)
-6
View File
@@ -118,9 +118,6 @@ int tio_get(int fd, TIO *tio)
{ {
#ifdef HAVE_TERMIOS_H #ifdef HAVE_TERMIOS_H
return tcgetattr(fd, tio); return tcgetattr(fd, tio);
#else
DEB(("io_unix_tio: TERMIOS not supported!"));
return -1;
#endif #endif
} }
@@ -130,9 +127,6 @@ int tio_set(int fd, TIO *tio)
{ {
#ifdef HAVE_TERMIOS_H #ifdef HAVE_TERMIOS_H
return tcsetattr(fd, TCSANOW, tio); return tcsetattr(fd, TCSANOW, tio);
#else
DEB(("io_unix_tio: TERMIOS not supported!"));
return -1;
#endif #endif
} }
+1 -7
View File
@@ -106,15 +106,11 @@ int log_open(const char *logname, const char *ext, const char *tty)
if( logname ) if( logname )
{ {
DEB((D_INFO,"log_open: Opening log file %s", logname));
strnxcpy(log_name, logname, sizeof(log_name)); strnxcpy(log_name, logname, sizeof(log_name));
// May be NULL, so check both
if( tty && *tty ) if( tty && *tty )
strnxcpy(log_ttyname, tty, sizeof(log_ttyname)); strnxcpy(log_ttyname, tty, sizeof(log_ttyname));
// May be NULL, so check both
if( ext && *ext ) if( ext && *ext )
{ {
strnxcpy(log_extension, ext, sizeof(log_extension)); strnxcpy(log_extension, ext, sizeof(log_extension));
@@ -146,9 +142,7 @@ int log_close(void)
if( log_fp ) if( log_fp )
{ {
rc = fclose(log_fp); rc = fclose(log_fp); log_fp = NULL;
DEB((D_INFO,"Closing log file."));
log_fp = NULL;
} }
return rc; return rc;
+1 -4
View File
@@ -243,7 +243,7 @@ int nodelist_parsestring(s_node *node, char *str)
strnxcpy(node->phone, argv[NODELIST_POSPHONE], sizeof(node->phone)); strnxcpy(node->phone, argv[NODELIST_POSPHONE], sizeof(node->phone));
strnxcpy(node->flags, argv[NODELIST_POSFLAGS], sizeof(node->flags)); strnxcpy(node->flags, argv[NODELIST_POSFLAGS], sizeof(node->flags));
node->speed = atoi(argv[NODELIST_POSSPEED]); node->speed = atoi(argv[NODELIST_POSSPEED]);
DEB((D_NODELIST, "nodelist: Parsed common values SYS: %s, ZYZ: %s, LOC: %s, PHONE: %s", node->name, node->sysop, node->location, node->phone));
/* /*
* Replace all '_' by space character * Replace all '_' by space character
*/ */
@@ -291,11 +291,8 @@ int nodelist_parsestring(s_node *node, char *str)
node->do_ifcico = nodelist_checkflag(node->flags, "IFC") == 0; node->do_ifcico = nodelist_checkflag(node->flags, "IFC") == 0;
node->do_telnet = nodelist_checkflag(node->flags, "ITN") == 0; node->do_telnet = nodelist_checkflag(node->flags, "ITN") == 0;
//TODO: Add more INA flags to array
nodelist_flagvalue(node->flags, "INA", node->host); nodelist_flagvalue(node->flags, "INA", 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; return 0;
} }
+8 -8
View File
@@ -124,7 +124,7 @@ int binkp_loop(s_binkp_state *bstate) {
bstate->continuesend = false; bstate->continuesend = false;
} }
if (have_to_write==0 && (!no_more_to_send || bstate->extracmd[0]!=(char)-1)) { if (have_to_write==0 && (!no_more_to_send || bstate->extracmd[0]!=-1)) {
m = binkp_getforsend(bstate, writebuf+BINKP_HEADER, &block_type, &block_length); m = binkp_getforsend(bstate, writebuf+BINKP_HEADER, &block_type, &block_length);
if(m==1 || m==3) { if(m==1 || m==3) {
//DEB((D_24554, "got block for sending %d %hu", block_type, block_length)); //DEB((D_24554, "got block for sending %d %hu", block_type, block_length));
@@ -340,7 +340,7 @@ int binkp_getforsend(s_binkp_state *bstate, char *buf, int *block_type, unsigned
{ {
int my_sf, wr_pos; int my_sf, wr_pos;
int n; // read file int n; // read file
if (bstate->extracmd[0]!=(char)-1) { if (bstate->extracmd[0]!=-1) {
DEB((D_24554, "Send cmd to remote %d %s", bstate->extracmd[0], bstate->extracmd+1)); DEB((D_24554, "Send cmd to remote %d %s", bstate->extracmd[0], bstate->extracmd+1));
buf[0] = bstate->extracmd[0]; buf[0] = bstate->extracmd[0];
strcpy(buf+1, bstate->extracmd+1); strcpy(buf+1, bstate->extracmd+1);
@@ -668,12 +668,12 @@ case BPMSG_ADR: /* List of addresses */
if (bstate->address_established) { if (bstate->address_established) {
PROTO_ERROR("remote tries to change address"); PROTO_ERROR("remote tries to change address");
} }
if( bstate->extracmd[0] != (char)-1 ) return 0; // suspend !!! if( bstate->extracmd[0] !=-1 ) return 0; // suspend !!!
binkp_process_ADR(buf+1); binkp_process_ADR(buf+1);
if( !state.n_remoteaddr ) { if( !state.n_remoteaddr ) {
log("error: remote did not supplied any addresses"); log("error: remote did not supplied any addresses");
if( bstate->extracmd[0] != (char)-1 ) return 0; // suspend if( bstate->extracmd[0] !=-1 ) return 0; // suspend
bstate->extracmd[0] = BPMSG_BSY; bstate->extracmd[0] = BPMSG_BSY;
strcpy(bstate->extracmd+1, "No addresses was presented"); strcpy(bstate->extracmd+1, "No addresses was presented");
bstate->extraislast = true; bstate->extraislast = true;
@@ -788,7 +788,7 @@ case BPMSG_FILE: /* File information */
DEB((D_24554, "no, skipping; TODO: accept it")); DEB((D_24554, "no, skipping; TODO: accept it"));
if( bstate->extracmd[0] != -1 ) return 0; if( bstate->extracmd[0] != -1 ) return 0;
bstate->extracmd[0] = BPMSG_SKIP; bstate->extracmd[0] = BPMSG_SKIP;
sprintf(bstate->extracmd+1, "%s %ld %ld %ld", recvfi.fn, recvfi.sz, recvfi.tm, recvfi.offs); sprintf(bstate->extracmd+1, "%s %ld %ld %ld", recvfi.fn, recvfi.sz, recvfi.tm);
bstate->extraislast = false; bstate->extraislast = false;
return 1; return 1;
} }
@@ -844,7 +844,7 @@ case BPMSG_OK: /* Password was acknowleged (data ignored) */
} }
if (session_addrs_lock(state.remoteaddrs, state.n_remoteaddr)) { if (session_addrs_lock(state.remoteaddrs, state.n_remoteaddr)) {
log("error: unable to lock"); log("error: unable to lock");
if (bstate->extracmd[0]!= (char)-1) return 0; if (bstate->extracmd[0]!=-1) return 0;
bstate->extracmd[0] = BPMSG_BSY; bstate->extracmd[0] = BPMSG_BSY;
strcpy(bstate->extracmd+1, "All addresses are busy"); strcpy(bstate->extracmd+1, "All addresses are busy");
bstate->extraislast = true; bstate->extraislast = true;
@@ -954,7 +954,7 @@ case BPMSG_GET: /* Get a file from offset */
} }
DEB((D_24554, "M_GET file %s size %d time %d offset %d", getfi.fn, getfi.sz, getfi.tm, getfi.offs)); DEB((D_24554, "M_GET file %s size %d time %d offset %d", getfi.fn, getfi.sz, getfi.tm, getfi.offs));
if (bstate->extracmd[0] != (char)-1) return 0; if (bstate->extracmd[0] != -1) return 0;
if (bstate->pi->send) if (p_compfinfo(bstate->pi->send, getfi.fn, getfi.sz, getfi.tm)==0) { if (bstate->pi->send) if (p_compfinfo(bstate->pi->send, getfi.fn, getfi.sz, getfi.tm)==0) {
DEB((D_24554, "M_GET for currently transmitted file")); DEB((D_24554, "M_GET for currently transmitted file"));
@@ -1044,7 +1044,7 @@ case BINKP_BLK_DATA:
return 1; return 1;
} }
if (bstate->extracmd[0] != (char)-1) return 0; if (bstate->extracmd[0] != -1) return 0;
long int n; long int n;
n = p_rx_writefile(buf, block_length, bstate->pi); n = p_rx_writefile(buf, block_length, bstate->pi);
+11 -21
View File
@@ -22,16 +22,8 @@
int answ_system(e_session type, char *connstr, int inetd) int answ_system(e_session type, char *connstr, int inetd)
{ {
TIO oldtio; TIO oldtio;
union { struct sockaddr_in client;
struct sockaddr a;
struct sockaddr_in in;
struct sockaddr_in6 in6;
} client;
//struct sockaddr_storage client;
int clientlen = sizeof(client); int clientlen = sizeof(client);
char clienthost[NI_MAXHOST];
char clientport[NI_MAXSERV];
int clientres = 0;
int rc = 0; int rc = 0;
char *p; char *p;
@@ -82,20 +74,18 @@ int answ_system(e_session type, char *connstr, int inetd)
log("Answering TCPIP call..."); log("Answering TCPIP call...");
if( connstr && *connstr ) if( connstr && *connstr )
state.connstr = (char*)xstrcpy(connstr); state.connstr = (char*)xstrcpy(connstr);
else if( getpeername(0, (struct sockaddr*)&client, &clientlen) == -1 )
logerr("can't get client address");
else else
{ {
if(getpeername(0, &client.a, &clientlen)) #ifdef IPV6
log("sess_answ: can't detrmine socket client"); >char addr_str[INET6_ADDRSTRLEN+1];
clientres = getnameinfo( &client.a, clientlen, state.peername = (char*)xstrcpy(inet_ntop(AF_INET6, client.sin6_addr, addr_str, INET6_ADDRSTRLEN));
clienthost, sizeof(clienthost), clientport, state.peerport = (long)ntohs(client.sin6_port);
sizeof(clientport), NI_NUMERICHOST | NI_NUMERICSERV); #else
if ( clientres == 0 ) state.peername = (char*)xstrcpy(inet_ntoa(client.sin_addr));
{ state.peerport = (long)ntohs(client.sin_port);
state.peername = (char*)xstrcpy(clienthost); #endif
state.peerport = (long)atol(clientport);
}
else
log("sess_answ: can't get client address: ", gai_strerror(clientres));
} }
} }
+17 -32
View File
@@ -543,7 +543,7 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
char s[300]; char s[300];
snprintf(s, 299, "bforce calling system %d:%d/%d.%d", addr.zone, addr.net, addr.node, addr.point ); snprintf(s, 299, "bforce calling system %d:%d/%d.%d", addr.zone, addr.net, addr.node, addr.point );
log(s); log(s);
DEB((D_EVENT, s));
// find suitable way of connection and try to make session // find suitable way of connection and try to make session
int rc = 0; int rc = 0;
@@ -568,13 +568,12 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
} }
state.listed = state.node.listed; 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 */ state.node.addr.domain[0] = '\0'; /* Discard domain for node address */
// 1. If call method specified in cmdline, do use it // 1. If call method specified in cmdline, do use it
// 2. If not, use nodelist data and overrides and call all available methods // 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) // 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 // 1st - get all allowed call ways
// 2nd - gather information reqired to call and remove unavailable ways (no info, node does not support) // 2nd - gather information reqired to call and remove unavailable ways (no info, node does not support)
@@ -582,7 +581,7 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
if( opts->runmode == MODE_CALL_DEFAULT ) if( opts->runmode == MODE_CALL_DEFAULT )
{ {
call_mustuse = CALL_MODEM | CALL_TCPIP_ANY; call_mayuse = CALL_MODEM | CALL_TCPIP_ANY;
} }
else if( opts->runmode == MODE_CALL_STDIO ) else if( opts->runmode == MODE_CALL_STDIO )
{ {
@@ -594,14 +593,7 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
} }
else if( opts->runmode == MODE_CALL_IP ) else if( opts->runmode == MODE_CALL_IP )
{ {
DEB((D_EVENT, "Calling init, MODE_CALL_IP")); if( strcasecmp(opts->ipproto, "binkp") == 0 )
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; call_mustuse = CALL_TCPIP_BINKP;
} }
@@ -613,29 +605,31 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
{ {
call_mustuse = CALL_TCPIP_TELNET; call_mustuse = CALL_TCPIP_TELNET;
} }
else if( opts->ipproto == NULL ) // determine from nodelist/override
{
call_mayuse = CALL_TCPIP_ANY;
call_mustuse = 0;
}
else else
{ {
DEB((D_EVENT, "Unknown protocol %s", opts->ipproto));
log("Unknown protocol"); log("Unknown protocol");
return -1; return -1;
} }
} }
else else
{ {
DEB((D_EVENT, "Unknown runmode %d", opts->runmode)); log("Unknown protocol");
log("Unknown runmode");
return -1; return -1;
} }
call_mayuse |= call_mustuse; // it simplifies logics: all required is allowed call_mayuse |= call_mustuse; // it simplifies logics: all required is allowed
//char s[300]; //char s[300];
snprintf(s, 299, "initial: may use %d must use %d", call_mayuse, call_mustuse); //snprintf(s, 299, "initial: may use %d must use %d", call_mayuse, call_mustuse);
log(s); //log(s);
DEB((D_EVENT, s));
if( (call_mayuse & CALL_MODEM) ) if( call_mayuse & CALL_MODEM )
{ {
// 1. use phone from opts // 1. use phone from opts
// 2. use overrides // 2. use overrides
@@ -699,9 +693,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); // snprintf(s, 299, "after phone check: may use %d must use %d", call_mayuse, call_mustuse);
log(s); // log(s);
DEB((D_EVENT, s));
/* /*
* Apply overrides to the node information * Apply overrides to the node information
*/ */
@@ -752,8 +746,6 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
state.override.sIpaddr, sizeof(state.node.host)); 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) ) { if( call_mayuse & CALL_TCPIP_ANY && !tcpip_isgood_host(state.node.host) ) {
char *fidodnszone = conf_string(cf_fidodnszone); char *fidodnszone = conf_string(cf_fidodnszone);
if (fidodnszone) { if (fidodnszone) {
@@ -773,14 +765,13 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
{ {
call_mayuse &= ~CALL_TCPIP_ANY; call_mayuse &= ~CALL_TCPIP_ANY;
log("bad host, exclude IP"); log("bad host, exclude IP");
DEB((D_EVENT, "bad host %s, exclude IP", state.node.host));
if( call_mustuse & CALL_TCPIP_ANY ) if( call_mustuse & CALL_TCPIP_ANY )
{ {
errmsg = "don't know host name"; errmsg = "don't know host name";
gotoexit(BFERR_PHONE_UNKNOWN); 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); // snprintf(s, 299, "after IP check: may use %d must use %d", call_mayuse, call_mustuse);
// log(s); // log(s);
@@ -819,31 +810,26 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
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); 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); 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); 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); 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", setproctitle("bforce calling %.32s, %.32s",
ftn_addrstr(abuf, state.node.addr), state.node.phone); ftn_addrstr(abuf, state.node.addr), state.node.phone);
rc = -1; rc = -1;
@@ -864,7 +850,6 @@ int call_system(s_faddr addr, const s_bforce_opts *opts)
if( port_lock(p_lockdir, state.modemport) == 0 ) /* Successfuly locked port */ if( port_lock(p_lockdir, state.modemport) == 0 ) /* Successfuly locked port */
{ {
DEB((D_EVENT,"sess_call: call_system_modem running"));
rc = call_system_modem(); rc = call_system_modem();
port_unlock(p_lockdir, state.modemport); port_unlock(p_lockdir, state.modemport);
} }
+1 -3
View File
@@ -189,8 +189,7 @@ static int ftn_addrparse_fido(s_faddr *addr, const char *s, bool wildcard)
{ {
strnxcpy(addr->domain, string_printable(p), sizeof(addr->domain)); strnxcpy(addr->domain, string_printable(p), sizeof(addr->domain));
} }
DEB((D_INFO,"u_ftn: Parsed ftn address z:%d, net:%d, node:%d, point:%d",
addr->zone, addr->net, addr->node, addr->point));
return badaddr; return badaddr;
} }
@@ -327,7 +326,6 @@ int ftn_addrparse(s_faddr *addr, const char *s, bool wildcard)
addr->node = DEFAULT_NODE; addr->node = DEFAULT_NODE;
addr->point = 0; addr->point = 0;
DEB((D_INFO, "u_ftn: parsing ftnaddr %s", s));
if( addr->inetform ) if( addr->inetform )
badaddr = ftn_addrparse_inet(addr, s, wildcard); badaddr = ftn_addrparse_inet(addr, s, wildcard);
else else
-1
View File
@@ -81,7 +81,6 @@ void *xrealloc(void *buf, size_t size)
else if( (tmp = (char*)(buf ? realloc(buf, size) : malloc(size))) == NULL ) else if( (tmp = (char*)(buf ? realloc(buf, size) : malloc(size))) == NULL )
{ {
log("failed to reallocate %ld bytes -> abort", size); log("failed to reallocate %ld bytes -> abort", size);
if( buf ) free(buf);
abort(); abort();
} }
-7
View File
@@ -28,8 +28,6 @@ function testcomm() {
BFCFGA=${CURDIR}/etc/bforceA.conf BFCFGA=${CURDIR}/etc/bforceA.conf
BFCFGB=${CURDIR}/etc/bforceB.conf BFCFGB=${CURDIR}/etc/bforceB.conf
# Works for Linux
BFCONFIG=${BFCFGA} BFCONFIG=${BFCFGA}
BFCONFIG=${BFCFGA} ${BFBIN} -o 99:1/2 > ${CURDIR}/bforceAtoB < ${CURDIR}/bforceBtoA & BFCONFIG=${BFCFGA} ${BFBIN} -o 99:1/2 > ${CURDIR}/bforceAtoB < ${CURDIR}/bforceBtoA &
# #
@@ -37,9 +35,6 @@ function testcomm() {
BFCONFIG=${BFCFGB} BFCONFIG=${BFCFGB}
BFCONFIG=${BFCFGB} ${BFBIN} -S"CONNECT 9600" auto < ${CURDIR}/bforceAtoB > ${CURDIR}/bforceBtoA BFCONFIG=${BFCFGB} ${BFBIN} -S"CONNECT 9600" auto < ${CURDIR}/bforceAtoB > ${CURDIR}/bforceBtoA
# For [Free]BSD it need to be replaced - pipes are bidirectional:
# ./ping <&1 | ./pong >&0
rm ${CURDIR}/{bforceAtoB,bforceBtoA} rm ${CURDIR}/{bforceAtoB,bforceBtoA}
## WE MUST CHECK THAT INBOUND ARE FULL!!! ## ## WE MUST CHECK THAT INBOUND ARE FULL!!! ##
@@ -93,8 +88,6 @@ else
echo -n "--> Running Hydra test..." echo -n "--> Running Hydra test..."
testcomm testcomm
# TODO: make binkd test over netcat possibly
fi fi