Merge pull request #2 from fidoman/master

обновления
master
Max N. Boyarov 12 years ago
commit 9383985bf9

@ -1,3 +1,14 @@
=== 2012-03 ===
$DEBUGLEVEL, $DEBUGFILE removed - please use configuration options
DNS zone support
=== 2012-02 ===
Netspool support
24554 protocol remake
=== 2011-12-25 ===
Cmdline processing code is partially rewritten.

@ -24,9 +24,6 @@
## Config reader directives:
##
## $INCLUDE <filename> Include this file
## $LOGFILE <filename> Log to this file
## $DEBUGFILE <filename> Write debug information to this file
## $DEBUGLEVEL <debug_levels> Change debug level
##
## $IFEXP <expression> All data between ``$IFEXP'' and ``$ENDIF''
## <config_keyword> <value> directives will be used with the specified
@ -35,8 +32,6 @@
##
## Examples:
##
## $DEBUGLEVEL Outbound hShake
##
## $IFEXP ((2:*/*.* | !protected) & Time 23:00-01:00)
## options NoFreqs
## min_speed_in 14400
@ -81,7 +76,13 @@ options NoDirZap NoJanus NoChat
#
#log_file_daemon /var/log/bforce/bf-daemon
#log_file /var/log/bforce/bf-log
# Debugging information completness level. Debugging is disabled by
# default. Allowed debug levels: config, nodelist, outbound, info, hshake,
# ttyio, modem, prot, freq, daemon, full
#debug_file /var/log/bforce/bf-debug
#debug_level info hshake prot
#
# Existing of this file forbid any outgoing modem calls. Existing of
@ -90,16 +91,6 @@ options NoDirZap NoJanus NoChat
#
nodial_flag /etc/nodial
#
# Debugging information completness level. Debugging is disabled by
# default. Allowed debug levels: config, nodelist, outbound, info, hshake,
# ttyio, modem, prot, freq, daemon, full
#
# It seems to be broken now, use "$DEBUGLEVEL" instead
#
#debug_level info hshake prot
#
#
# Inbound directories
#

@ -31,11 +31,13 @@ SPOOLDIR = @SPOOLDIR@
DAEMON_LOGFILE = $(LOGDIR)/bf-daemon
BFORCE_LOGFILE = $(LOGDIR)/bf-log
BFORCE_DEBFILE = $(LOGDIR)/bf-debug
BFORCE_DEBLEVEL = 0L
BFORCE_CFGFILE = $(CONFDIR)/bforce.conf
DEFINES = -DDAEMON_LOGFILE=\"$(DAEMON_LOGFILE)\" \
-DBFORCE_LOGFILE=\"$(BFORCE_LOGFILE)\" \
-DBFORCE_DEBFILE=\"$(BFORCE_DEBFILE)\" \
-DBFORCE_DEBLEVEL=$(BFORCE_DEBLEVEL) \
-DBFORCE_CFGFILE=\"$(BFORCE_CFGFILE)\" \
-DBF_OS=\"@build_os@\" @DEFS@
@ -101,7 +103,7 @@ BFORCE_OBJS = bforce/bforce.o \
bforce/u_misc.o bforce/u_string.o \
bforce/u_time.o bforce/u_file.o \
bforce/u_pkt.o bforce/u_recode.o \
bforce/u_plock.o
bforce/u_plock.o bforce/netspool.o
.c.o:
@echo Compiling $*.c

@ -422,13 +422,13 @@ int main(int argc, char *argv[], char *envp[])
}
}
}
/* if( (rc = log_open(log_getfilename(LOG_FILE_SESSION), NULL, NULL)) )
/* if( (rc = log_open(BFORCE_LOGFILE, NULL, NULL)) ) //compiled in
{
log("can't continue without logging");
gotoexit(BFERR_FATALERROR);
}
*/
}*/
/* Process primary config file */
if( opts.confname && *opts.confname )
rc = conf_readconf(opts.confname, 0);
@ -442,17 +442,12 @@ int main(int argc, char *argv[], char *envp[])
(void)conf_readconf(opts.incname, 1);
/* Reopen log file if it was defined in config */
if( log_open(log_getfilename(LOG_FILE_SESSION), NULL, NULL) )
if( log_reopen(log_getfilename(LOG_FILE_SESSION), NULL, NULL) )
{
log("can't continue without logging");
gotoexit(BFERR_FATALERROR);
}
#ifdef DEBUG
/* Same for the debug file */
(void)debug_setfilename(log_getfilename(LOG_FILE_DEBUG));
#endif
//char runmode_str[21];
//snprintf(runmode_str, 20, "Run mode: %d", opts.runmode);
//log(runmode_str);
@ -485,10 +480,10 @@ exit:
/* Shutdown logging services */
if( log_isopened() ) log_close();
DEB((D_FREE, "good exit"));
#ifdef DEBUG
if( debug_isopened() ) debug_close();
#endif
exit(rc);
}

@ -163,19 +163,25 @@ s_conf_entry bforce_config[BFORCE_NUMBER_OF_KEYWORDS+1] = {
CONF_KEY(zmodem_mincps_send, CT_CONNLIST),
CONF_KEY(zmodem_send_dummy_pkt, CT_BOOLEAN),
CONF_KEY(zmodem_skip_by_pos, CT_BOOLEAN),
CONF_KEY(zmodem_start_block_size, CT_NUMBER),
CONF_KEY(zmodem_tx_window, CT_NUMBER),
CONF_KEY(nomail_flag, CT_STRING),
CONF_KEY(bind_ip, CT_STRING),
CONF_KEY(recieved_to_lower, CT_BOOLEAN),
CONF_KEY(zmodem_start_block_size, CT_NUMBER),
CONF_KEY(zmodem_tx_window, CT_NUMBER),
CONF_KEY(nomail_flag, CT_STRING),
CONF_KEY(bind_ip, CT_STRING),
CONF_KEY(recieved_to_lower, CT_BOOLEAN),
#ifdef USE_SYSLOG
CONF_KEY(syslog_facility, CT_NUMBER),
CONF_KEY(syslog_facility, CT_NUMBER),
#endif
#ifdef DEBUG
CONF_KEY(debug_file, CT_STRING),
CONF_KEY(debug_level, CT_DEBLEVEL),
CONF_KEY(debug_file, CT_STRING),
CONF_KEY(debug_level, CT_STRING),
#endif
CONF_KEY(split_inbound, CT_BOOLEAN),
CONF_KEY(split_inbound, CT_BOOLEAN),
#ifdef NETSPOOL
CONF_KEY(netspool_host, CT_STRING),
CONF_KEY(netspool_port, CT_STRING),
#endif
CONF_KEY(fidodnszone, CT_STRING),
CONF_END()
};
@ -195,9 +201,9 @@ static int proc_dialresp(s_dialresp *dest, char *value);
static int proc_translate(s_translate *dest, char *value);
static int proc_speeddep(s_connlist *dest, char *value);
static int proc_tries(s_tries *dest, char *value);
#ifdef DEBUG
static int proc_debuglevel(s_number *dest, char *value);
#endif
//#ifdef DEBUG
//static int proc_debuglevel(s_number *dest, char *value); move to reader
//#endif
static int proc_filebox(s_filebox *dest, char *value);
static int append_config_entry(s_conf_entry *conf_ent, s_cval_entry *cval_entry)
@ -286,11 +292,11 @@ int proc_configline(const char *k, const char *e, const char *v)
case CT_TRIES:
rc = proc_tries(&temp_value.d.tries, copy);
break;
#ifdef DEBUG
case CT_DEBLEVEL:
rc = proc_debuglevel(&temp_value.d.number, copy);
break;
#endif
//#ifdef DEBUG
// case CT_DEBLEVEL:
// rc = proc_debuglevel(&temp_value.d.number, copy);
// break;
//#endif
case CT_FILEBOX:
rc = proc_filebox(&temp_value.d.filebox, copy);
break;
@ -927,7 +933,7 @@ static int proc_tries(s_tries *dest, char *value)
* Line format: DebugLevel <Level> [<Level>]..
*/
#ifdef DEBUG
static int proc_debuglevel(s_number *dest, char *value)
/*static int proc_debuglevel(s_number *dest, char *value)
{
int rc = PROC_RC_OK;
long deblevel = 0L;
@ -939,7 +945,7 @@ static int proc_debuglevel(s_number *dest, char *value)
dest->num = deblevel;
return(rc);
}
} */
#endif
/*

@ -32,10 +32,10 @@ const char *conf_getconfname(void)
return(name);
}
int conf_readpasswdlist(s_falist **pwdlist, char *fname)
/*int conf_readpasswdlist(s_falist **pwdlist, char *fname)
{
return(0);
}
} */
/*
* Prepare config string for parsing, check for comments
@ -131,6 +131,7 @@ static void conf_parsestr(char *str, char **key, char **expr, char **value)
int conf_readconf(const char *confname, int inclevel)
{
// printf("%s %d\n", confname, inclevel);
FILE *fp = NULL;
char tmp[BF_MAXCFGLINE + 1];
int rc, maxrc = 0;
@ -300,7 +301,7 @@ int conf_readconf(const char *confname, int inclevel)
isifexpr = FALSE;
}
}
else if( strcasecmp(p_key+1, "logfile") == 0 )
/* else if( strcasecmp(p_key+1, "logfile") == 0 )
{
if( value == NULL || expr )
{
@ -359,7 +360,7 @@ int conf_readconf(const char *confname, int inclevel)
rc = PROC_RC_IGNORE;
}
#endif
}
}*/
else
{
log("unknown directive `%s'", p_key);
@ -426,11 +427,24 @@ int conf_readconf(const char *confname, int inclevel)
DEB((D_CONFIG, "readconfig: exit with maxrc = %d", maxrc));
/* update subsystems */
if (inclevel==0) { // end of main config
if( log_reopen(log_getfilename(LOG_FILE_SESSION), NULL, NULL) )
{
log("can't continue without logging");
exit(-1);
}
#ifdef DEBUG
debug_configure();
#endif
}
return maxrc;
}
#ifdef DEBUG
void debug_override(void)
/*void debug_override(void)
{
s_cval_entry *ptrl;
char abuf[BF_MAXADDRSTR+1];
@ -452,6 +466,6 @@ void debug_override(void)
}
DEB((D_CONFIG, "debug_override: END"));
}
}*/
#endif /* DEBUG */

@ -914,10 +914,6 @@ int daemon_run(const char *confname, const char *incname, bool quit)
return BFERR_FATALERROR;
}
#ifdef DEBUG
(void)debug_setfilename(log_getfilename(LOG_FILE_DEBUG));
#endif
log("%sstarting daemon (%s)",
started ? "re" : "", BF_VERSION);

@ -68,8 +68,7 @@ int req_createsrif(char *sname, char *req, char *rsp)
else
fprintf(fp, "Sysop SysOp\n");
if( state.handshake && state.handshake->remote_address
&& (aptr = state.handshake->remote_address(state.handshake)) )
if( aptr = session_1remote_address() )
fprintf(fp, "AKA %s\n", ftn_addrstr(abuf, *aptr));
else
return -1;

@ -32,7 +32,7 @@ static char log_ttyname[32] = "";
* Local variables needed to make debug work
*/
static FILE *debug_fp = NULL;
static long debug_current_debuglevel = 0L;
static long debug_current_debuglevel = BFORCE_DEBLEVEL;
static char debug_name[BF_MAXPATH+1] = BFORCE_DEBFILE;
static bool debug_invalid_name = FALSE;
@ -56,6 +56,9 @@ struct debuglevel {
{ "Freq", D_FREQ },
{ "Statem", D_STATEM },
{ "Daemon", D_DAEMON },
{ "Free", D_FREE },
{ "24554", D_24554 },
// { "Daemon", D_DAEMON },
{ "Full", D_FULL },
{ NULL, 0 }
};
@ -103,11 +106,6 @@ int log_open(const char *logname, const char *ext, const char *tty)
if( logname )
{
/* Reset previous settings */
*log_name = '\0';
*log_extension = '\0';
*log_ttyname = '\0';
strnxcpy(log_name, logname, sizeof(log_name));
if( tty && *tty )
@ -119,14 +117,9 @@ int log_open(const char *logname, const char *ext, const char *tty)
strnxcat(log_name, ".", sizeof(log_name));
strnxcat(log_name, ext, sizeof(log_name));
}
if( (log_fp = fopen(log_name, "a")) == NULL )
{
logerr("can't open log file \"%s\"", log_name);
return -1;
}
}
else if( log_name )
if( log_name )
{
/* Open previously set log file */
@ -385,28 +378,16 @@ int logerr(const char *s, ...)
#ifdef DEBUG
void debug_setlevel(long newlevel, bool logit)
{
if( logit && newlevel != debug_current_debuglevel )
{
log("changing debug level from 0x%07x to 0x%07x",
debug_current_debuglevel, newlevel);
debug_current_debuglevel = newlevel;
}
}
bool debug_isopened(void)
{
return debug_fp ? TRUE : FALSE;
}
int debug_parsestring(char *str, unsigned long *deblevel)
int _debug_parsestring(char *str, unsigned long *deblevel)
{
int i, rc = 0;
char *n;
char *p_str = NULL;
ASSERT(str != NULL);
if (str==NULL) {
puts("DEBUG level string is empty, please configure");
exit(-1);
}
*deblevel = 0L;
@ -427,42 +408,73 @@ int debug_parsestring(char *str, unsigned long *deblevel)
rc = 1;
}
}
return rc;
return rc;
}
void debug_setfilename(const char *debugname)
void debug_configure() // this function should be called after configuration is settled
{
ASSERT(debugname != NULL);
if( !strcmp(debug_name, debugname) ) return;
char *debugfile = conf_string(cf_debug_file);
char *debuglevel = conf_string(cf_debug_level);
unsigned long n_debuglevel;
if (debugfile!=NULL) {
if( strcmp(debug_name, debugfile)!=0 ) {
if( debug_isopened() ) debug_close();
if( debug_isopened() ) debug_close();
/* Reset ignore flag */
if( debug_invalid_name )
if( debug_invalid_name )
debug_invalid_name = FALSE;
strnxcpy(debug_name, debugname, sizeof(debug_name));
strncpy(debug_name, debugfile, sizeof(debug_name));
}
}
_debug_parsestring(debuglevel, &n_debuglevel);
if( n_debuglevel != debug_current_debuglevel ) {
log("changing debug level from 0x%08x to 0x%08x",
debug_current_debuglevel, n_debuglevel);
debug_current_debuglevel = n_debuglevel;
}
}
int debug_open(const char *debugname)
bool debug_isopened(void)
{
return debug_fp ? TRUE : FALSE;
}
int debug_open()
{
char buf[40];
ASSERT(debug_fp == NULL);
if( debugname )
if( debug_name )
{
if( (debug_fp = fopen(debugname, "a")) == NULL )
{
logerr("can't open debug file \"%s\"", debugname);
return -1;
char log_name[PATH_MAX];
char *marker;
/* Reset previous settings */
*log_name = '\0';
*log_extension = '\0';
*log_ttyname = '\0';
if (marker = strchr(debug_name, '!')) {
struct timespec xtm;
struct tm btm;
clock_gettime(CLOCK_REALTIME, &xtm);
gmtime_r(&xtm.tv_sec, &btm);
// hope sysop will not DoS his own node
memcpy(log_name, debug_name, marker-debug_name);
sprintf( log_name + (marker-debug_name) + strftime(log_name + (marker-debug_name), 100, ".%Y-%m-%d.%H.%M.%S.", &btm), "%09ld.%s", xtm.tv_nsec, marker+1);
// I'm too lazy to add variable
}
else {
strcpy(log_name, debug_name);
}
strnxcpy(debug_name, debugname, sizeof(debug_name));
}
else if( debug_name )
{
if( (debug_fp = fopen(debug_name, "a")) == NULL )
if( (debug_fp = fopen(log_name, "a")) == NULL )
{
/* Don't try to open it next time */
debug_invalid_name = TRUE;
@ -502,7 +514,7 @@ int debug_close(void)
rc = fclose(debug_fp) ? 0 : -1; debug_fp = NULL;
}
return rc;
return rc;
}
int debug(unsigned long what, const char *str, ...)
@ -515,7 +527,7 @@ int debug(unsigned long what, const char *str, ...)
{
if( debug_fp == NULL && debug_invalid_name == FALSE )
{
debug_open(NULL);
debug_open();
}
if( debug_fp )

@ -0,0 +1,274 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <errno.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netdb.h>
#include "includes.h"
#include "netspool.h"
#ifdef NETSPOOL
int readstr(int s, char *buf, int len) {
char c=0;
int r;
while(1) {
r=recv(s, &c, 1, 0);
if(r==0){
//puts("remote socket shutdown");
return -3;
}
if(r==-1){
//puts("error reading string");
//printf("%d %s\n", errno, strerror(errno));
return -3;
}
if(c=='\n') {
*buf=0;
break;
}
*buf++=c;
len--;
if(!len) {
//puts("string buffer overflow");
return -3;
}
}
return 0;
}
int sendstr(int s, const char *buf) {
int l = strlen(buf);
int c;
char nl='\n';
while(l>0) {
c=send(s, buf, l, 0);
if(c==-1){
//puts("error sending string");
//printf("%d %s\n", errno, strerror(errno));
return -3;
}
if(c==0){
//puts("zero send: may loop infinitely");
return -3;
}
l-=c;
}
c=send(s, &nl, 1, 0);
if(c==-1){
//puts("error sending string");
//printf("%d %s\n", errno, strerror(errno));
return -3;
}
if(c==0){
//puts("zero send: may loop infinitely");
return -3;
}
return 0;
}
void netspool_start(s_netspool_state *state, const char *host, const char *port, const char *addresses, const char *password)
{
int s, r;
struct addrinfo hint;
struct addrinfo *addrs, *a;
char strbuf[STRBUF];
s = socket(AF_INET6, SOCK_STREAM, 0);
state->socket = s;
if( s==-1 )
{
state->state = NS_ERROR;
state->error = "socket error";
return;
}
memset(&hint, 0, sizeof(struct addrinfo));
hint.ai_socktype = SOCK_STREAM;
hint.ai_family = PF_INET6;
hint.ai_flags = AI_V4MAPPED;
r = getaddrinfo(host, port!=NULL? port: "24555", &hint, &addrs);
if( r ) {
state->state = NS_ERROR;
state->error = gai_strerror(r);
return;
}
a=addrs;
r=-1;
while(a) {
r = connect(s, a->ai_addr, a->ai_addrlen);
if(r==-1) {
//printf("%d %s\n", errno, strerror(errno));
;
} else {
break;
}
a=a->ai_next;
}
freeaddrinfo(addrs);
if(r==-1) {
state->state = NS_ERROR;
state->error = "could not connect";
return;
}
r = readstr(s, strbuf, STRBUF);
if( r ) { state->state = NS_ERROR; state->error = "IO error"; return; }
//puts(strbuf); -- hello from remote
while (*addresses) { // stop when zero length string under pointer
snprintf(strbuf, STRBUF, "ADDRESS %s", addresses);
r = sendstr(s, strbuf);
if( r ) { state->state = NS_ERROR; state->error = "IO error"; return; }
addresses += strlen(addresses)+1; // go to next string
}
snprintf(strbuf, STRBUF, "PASSWORD %s", password);
r = sendstr(s, strbuf);
if( r ) { state->state = NS_ERROR; state->error = "IO error"; return; }
state->state = NS_READY;
}
void netspool_query(s_netspool_state *state, const char *what)
{
char strbuf[STRBUF];
int r;
snprintf(strbuf, STRBUF, "GET %s", what); /* ALL or comma separated NETMAIL, ECHOMAIL... */
r = sendstr(state->socket, strbuf);
if( r ) {
state->state = NS_ERROR;
state->error = "IO error";
return;
}
state->state = NS_RECEIVING;
}
void netspool_receive(s_netspool_state *state)
{
char strbuf[STRBUF];
int r;
r = readstr(state->socket, strbuf, STRBUF);
if( r ) { state->state = NS_ERROR; state->error = "IO error"; return; }
//puts(strbuf);
if(strcmp(strbuf, "QUEUE EMPTY")==0) {
state->state = NS_READY;
return;
}
if(strncmp(strbuf, "FILENAME ", 9)==0) {
strcpy(state->filename, strbuf+9);
//puts(state->filename);
} else {
state->state = NS_ERROR;
state->error = "expected filename or queue empty";
return;
}
r = readstr(state->socket, strbuf, STRBUF);
if( r ) { state->state = NS_ERROR; state->error = "IO error"; return; }
if(strncmp(strbuf, "BINARY ", 7)==0) {
/*if(filename[0]==0) {
puts("no filename");
exit(-5);
} */
sscanf(strbuf+7, "%Lu", &state->length);
//printf("length=%Lu\n", state->length);
state->state = NS_RECVFILE;
} else {
state->state = NS_ERROR;
state->error = "expected binary";
return;
}
}
int netspool_read(s_netspool_state *state, void *buf, int buflen)
{
int n;
if( state->length == 0 ) {
//puts("everithing is read");
return 0;
}
n = recv(state->socket, buf, state->length>buflen? buflen: state->length, 0);
if(n==0) {
state->state = NS_ERROR;
state->error = "remote socket shutdown";
return -1;
}
if(n==-1) {
//puts("error reading data");
//printf("%d %s\n", errno, strerror(errno));
state->state = NS_ERROR;
state->error = "IO error";
return -1;
}
state->length -= n;
return n;
}
void netspool_acknowledge(s_netspool_state *state)
{
char strbuf[STRBUF];
int r;
if( state->length > 0 ) {
state->state = NS_ERROR;
state->error = "Too early acknowledgement";
return;
}
snprintf(strbuf, STRBUF, "DONE %s", state->filename);
r = sendstr(state->socket, strbuf);
if( r ) { state->state = NS_ERROR; state->error = "IO error"; return; }
state->state = NS_RECEIVING;
state->filename[0] = 0;
}
void netspool_end(s_netspool_state *state)
{
sendstr(state->socket, "END satisfied");
close(state->socket);
state->state = NS_NOTINIT;
}
/*
void savefile(const char *fn, unsigned long long l, int s)
{
char BUF[STRBUF];
int n, n1;
int f;
f=open(fn, O_CREAT|O_EXCL|O_WRONLY, 0664);
if(f==-1) {
puts("error open file");
printf("%d %s\n", errno, strerror(errno));
exit(-3);
}
while(l) {
n1 = write(f, BUF, n);
if(n1!=n) {
puts("error writing file");
printf("%d %s\n", errno, strerror(errno));
exit(-3);
}
}
close(f);
}
*/
#endif

File diff suppressed because it is too large Load Diff

@ -48,7 +48,7 @@ s_handshake_protocol handshake_protocol_binkp = {
binkp_incoming2,
binkp_outgoing2,
/* Section 2 */
binkp_remote_address,
// binkp_remote_address,
binkp_remote_password,
binkp_remote_sysop_name,
binkp_remote_system_name,
@ -56,9 +56,9 @@ s_handshake_protocol handshake_protocol_binkp = {
binkp_remote_phone,
binkp_remote_flags,
binkp_remote_mailer,
NULL,
binkp_remote_traffic,
/* Section 3 */
binkp_local_address,
// binkp_local_address,
binkp_local_password
};
@ -78,21 +78,27 @@ void binkp_init(s_handshake_protocol *THIS)
void binkp_deinit(s_handshake_protocol *THIS)
{
ASSERT(THIS);
ASSERT(THIS->remote_data);
ASSERT(THIS->local_data);
DEB((D_FREE, "binkp_deinit"));
if (THIS==NULL) {
log("THIS==NULL");
return;
}
if( THIS->remote_data )
{
memset(THIS->remote_data, '\0', sizeof(s_binkp_sysinfo));
free(THIS->remote_data);
THIS->remote_data = NULL;
}
if( THIS->local_data )
{
memset(THIS->local_data, '\0', sizeof(s_binkp_sysinfo));
free(THIS->local_data);
THIS->local_data = NULL;
}
DEB((D_FREE, "binkp_deinit end"));
}
int binkp_incoming2(s_handshake_protocol *THIS)
@ -113,9 +119,9 @@ int binkp_incoming2(s_handshake_protocol *THIS)
rc = binkp_incoming(local_data, remote_data);
binkp_log_sysinfo(remote_data);
if( remote_data->anum > 0 )
if( state.n_remoteaddr > 0 )
{
session_remote_lookup(remote_data->addrs, remote_data->anum);
session_remote_lookup(state.remoteaddrs, state.n_remoteaddr);
session_remote_log_status();
binkp_log_options(remote_data);
}
@ -125,8 +131,8 @@ int binkp_incoming2(s_handshake_protocol *THIS)
/*
* Create mail/files queue
*/
session_create_files_queue(remote_data->addrs,
remote_data->anum);
session_create_files_queue(state.remoteaddrs,
state.n_remoteaddr);
session_set_send_options();
session_set_inbound();
session_set_freqs_status();
@ -155,9 +161,9 @@ int binkp_outgoing2(s_handshake_protocol *THIS)
rc = binkp_outgoing(local_data, remote_data);
binkp_log_sysinfo(remote_data);
if( remote_data->anum > 0 )
if( state.n_remoteaddr > 0 )
{
session_remote_lookup(remote_data->addrs, remote_data->anum);
session_remote_lookup(state.remoteaddrs, state.n_remoteaddr);
session_remote_log_status();
binkp_log_options(remote_data);
}
@ -167,8 +173,7 @@ int binkp_outgoing2(s_handshake_protocol *THIS)
/*
* Create mail/files queue
*/
session_create_files_queue(remote_data->addrs,
remote_data->anum);
session_create_files_queue(state.remoteaddrs, state.n_remoteaddr);
session_set_send_options();
session_set_inbound();
}
@ -176,7 +181,7 @@ int binkp_outgoing2(s_handshake_protocol *THIS)
return rc;
}
s_faddr *binkp_remote_address(s_handshake_protocol *THIS)
/*s_faddr *binkp_remote_address(s_handshake_protocol *THIS)
{
ASSERT(THIS);
ASSERT(THIS->remote_data);
@ -185,7 +190,7 @@ s_faddr *binkp_remote_address(s_handshake_protocol *THIS)
return &((s_binkp_sysinfo *)THIS->remote_data)->addrs[0].addr;
return NULL;
}
} */
char *binkp_remote_password(s_handshake_protocol *THIS)
{
@ -264,7 +269,7 @@ char *binkp_remote_mailer(s_handshake_protocol *THIS)
return NULL;
}
s_faddr *binkp_local_address(s_handshake_protocol *THIS)
/*s_faddr *binkp_local_address(s_handshake_protocol *THIS)
{
ASSERT(THIS);
ASSERT(THIS->local_data);
@ -273,7 +278,7 @@ s_faddr *binkp_local_address(s_handshake_protocol *THIS)
return &((s_binkp_sysinfo *)THIS->local_data)->addrs[0].addr;
return NULL;
}
} */
char *binkp_local_password(s_handshake_protocol *THIS)
{
@ -286,3 +291,19 @@ char *binkp_local_password(s_handshake_protocol *THIS)
return NULL;
}
int binkp_remote_traffic(s_handshake_protocol *THIS, s_traffic *dest)
{
ASSERT(THIS);
ASSERT(THIS->remote_data);
ASSERT(dest);
memset(dest, '\0', sizeof(s_traffic));
if (((s_binkp_sysinfo *)THIS->remote_data)->has_TRF) {
dest->netmail_size = ((s_binkp_sysinfo *)THIS->remote_data)->TRF_PKT;
dest->arcmail_size = 0;
dest->files_size = ((s_binkp_sysinfo *)THIS->remote_data)->TRF_other;
return 0;
}
return -1;
}

@ -21,198 +21,12 @@
#include "prot_common.h"
#include "prot_binkp.h"
/*****************************************************************************
* Initialise binkp state structure, allocate memory for buffers, etc.
*
* Arguments:
* bpi pointer to the binkp state structure (s_bpinfo)
*
* Return value:
* None
*/
void binkp_init_bpinfo(s_bpinfo *bpi)
{
memset(bpi, '\0', sizeof(s_bpinfo));
bpi->obuf = (char*)xmalloc(BINKP_MAX_BLKSIZE + BINKP_BLK_HDRSIZE + 1);
bpi->opos = 0;
bpi->optr = bpi->obuf;
bpi->inew = TRUE;
bpi->isize = -1;
bpi->ibuf = (char*)xmalloc(BINKP_MAX_BLKSIZE + BINKP_BLK_HDRSIZE + 1);
bpi->timeout = conf_number(cf_binkp_timeout);
if( !bpi->timeout )
bpi->timeout = 300;
}
/*****************************************************************************
* DeInitialise binkp state structure, release allocated memory, etc.
*
* Arguments:
* bpi pointer to the binkp state structure (s_bpinfo)
*
* Return value:
* None
*/
void binkp_deinit_bpinfo(s_bpinfo *bpi)
{
if( bpi->obuf )
free(bpi->obuf);
if( bpi->ibuf )
free(bpi->ibuf);
if( bpi->msgqueue )
free(bpi->msgqueue);
memset(bpi, '\0', sizeof(s_bpinfo));
}
/*****************************************************************************
* Fills s[0] and s[1] with binkp frame header using value of u
*
* Arguments:
* s pointer to the binkp's frame header (2 bytes)
* val value to put
*
* Return value:
* None
*/
void binkp_puthdr(char *s, unsigned int val)
{
s[0] = ( (unsigned long) val >> 8 ) & 0xff;
s[1] = ( (unsigned long) val ) & 0xff;
}
/*****************************************************************************
* Fills s[0] with binkp message type value
*
* Arguments:
* s pointer to the destination buffer
* msg message type
*
* Return value:
* None
*/
void binkp_putmsgtype(char *s, e_bpmsg msg)
{
s[0] = ( (unsigned int) msg ) & 0xff;
}
/*****************************************************************************
* Extract size from binkp frame header
*
* Arguments:
* s pointer to the source buffer
*
* Return value:
* Value, extracted from binkp header
*/
int binkp_gethdr(const char *s)
{
return ( (unsigned int) (((unsigned char) s[0]) & 0x7f) << 8 )
| ( (unsigned int) (((unsigned char) s[1]) & 0xff) );
}
/*****************************************************************************
* Extract message type from s[0]
*
* Arguments:
* s pointer to the source buffer (1 byte)
*
* Return value:
* Value, extracted from binkp header, or -1 if extracted message type is
* out of range
*/
int binkp_getmsgtype(char ch)
{
int val = ( ((unsigned char)ch) & 0x7f );
if( BPMSG_MIN > val || val > BPMSG_MAX )
return -1;
else
return val;
}
/*****************************************************************************
* Puts a message to the output messages queue. These msgs will be send
* right after the current data block
*
* Arguments:
* bpi binkp state structure
* msg message type
* s1 message text
* s2 message text (will be concatenated with s1)
*
* Return value:
* None
*/
void binkp_queuemsg(s_bpinfo *bpi, e_bpmsg msg, const char *s1, const char *s2)
{
bpi->msgqueue = xrealloc(bpi->msgqueue, sizeof(s_bpmsg)*(bpi->n_msgs + 1));
memset(&bpi->msgqueue[bpi->n_msgs], '\0', sizeof(s_bpmsg));
/* Set message type */
bpi->msgqueue[bpi->n_msgs].type = msg;
/* Set message data size (without frame header) */
bpi->msgqueue[bpi->n_msgs].size = 1;
if( s1 ) bpi->msgqueue[bpi->n_msgs].size += strlen(s1);
if( s2 ) bpi->msgqueue[bpi->n_msgs].size += strlen(s2);
/* Set message data */
bpi->msgqueue[bpi->n_msgs].data = xmalloc(bpi->msgqueue[bpi->n_msgs].size+3);
binkp_puthdr(bpi->msgqueue[bpi->n_msgs].data,
(unsigned)(bpi->msgqueue[bpi->n_msgs].size | 0x8000));
binkp_putmsgtype(bpi->msgqueue[bpi->n_msgs].data + 2, msg);
bpi->msgqueue[bpi->n_msgs].data[3] = '\0';
if( s1 ) strcat(bpi->msgqueue[bpi->n_msgs].data + 3, s1);
if( s2 ) strcat(bpi->msgqueue[bpi->n_msgs].data + 3, s2);
DEB((D_PROT, "binkp_queuemsg: queued message #%d, %ld bytes, \"%s\"",
(int)bpi->msgqueue[bpi->n_msgs].type,
(long)bpi->msgqueue[bpi->n_msgs].size,
(char*)bpi->msgqueue[bpi->n_msgs].data+3));
++bpi->n_msgs;
++bpi->msgs_in_batch;
}
/*****************************************************************************
* Sends a message using format string
*
* Arguments:
* bpi binkp state structure
* msg message type
* fmt pointer to the format string, (man printf)
*
* Return value:
* None
*/
void binkp_queuemsgf(s_bpinfo *bpi, e_bpmsg msg, const char *fmt, ...)
{
char msg_text[2048];
va_list ap;
va_start(ap, fmt);
#ifdef HAVE_SNPRINTF
vsnprintf(msg_text, sizeof(msg_text), fmt, ap);
#else
vsprintf(msg_text, fmt, ap);
#endif
va_end(ap);
binkp_queuemsg(bpi, msg, msg_text, NULL);
}
/*****************************************************************************
* Parse most common message arguments, send error message to remote
* if needed.
*
* Arguments:
* s pointer to the string to parse
* str pointer to the string to parse
* fn pointer to the pointer for extracted file name
* sz pointer to the extracted file size
* tm pointer to the extracted file modification time
@ -221,272 +35,33 @@ void binkp_queuemsgf(s_bpinfo *bpi, e_bpmsg msg, const char *fmt, ...)
* Return value:
* non-zero value on error, zero on success
*/
int binkp_parsfinfo(char *str,char **fn,size_t *sz,time_t *tm,size_t *offs){
char *n;
char *p_fname = NULL;
char *p_size = NULL;
char *p_time = NULL;
char *p_offs = NULL;
static char *s = NULL;
/* Attention, offs may be NULL! */
ASSERT(str != NULL && fn != NULL && sz != NULL && tm != NULL);
DEB((D_PROT, "binkp_parsemsg: want parse \"%s\"", s));
if (s) free (s);
s = xstrcpy (str);
p_fname = string_token(s, &n, NULL, 0);
p_size = string_token(NULL, &n, NULL, 0);
p_time = string_token(NULL, &n, NULL, 0);
if( offs ) p_offs = string_token(NULL, &n, NULL, 0);
if( p_fname && p_size && p_time && (!offs || p_offs) )
{
if( ISDEC(p_size) && ISDEC(p_time) &&
(!offs || ISDEC(p_offs) || !strcmp (p_offs, "-1")) )
{
(*fn) = p_fname;
(*sz) = atol(p_size);
(*tm) = atol(p_time);
if( offs ) *offs = atol(p_offs);
DEB((D_PROT, "binkp_parsemsg: file = \"%s\", size = %d, time = %d",
*fn, *sz, *tm));
return 0;
}
}
return 1;
}
/*****************************************************************************
* Put message to a buffer
*
* Arguments:
* bpi binkp state structure
* msg message
*
* Return value:
* Zero on success, and non-zero value if no more free space left
* in the buffer
*/
int binkp_buffer_message(s_bpinfo *bpi, s_bpmsg *msg)
{
DEB((D_PROT, "binkp_buffer_message: buffer message #%d, %ld byte(s)",
(int)msg->type, (long)msg->size));
/* Check for possible internal error */
if( msg->size > BINKP_MAX_BLKSIZE )
{
log("size of msg we want to send is too big (%db)", msg->size);
return 1;
}
/* Is there space for the new msg? */
if( bpi->opos + msg->size > BINKP_MAX_BLKSIZE ) return 1;
if( msg->data )
{
memcpy(bpi->obuf + bpi->opos, msg->data, msg->size + BINKP_BLK_HDRSIZE);
bpi->opos += msg->size + BINKP_BLK_HDRSIZE;
free(msg->data);
msg->data = NULL;
}
return 0;
}
/*****************************************************************************
* Send as much buffered data as possible (non-blocking)
*
* Arguments:
* bpi binkp state structure
*
* Return value:
* Zero on success, and non-zero value on errors
*/
int binkp_send_buffer(s_bpinfo *bpi)
int binkp_parsfinfo(const char *str, s_bpfinfo *fi, bool with_offset)
{
int n;
DEB((D_PROT, "binkp_send_buffer: sending %ld byte(s)", (long)bpi->opos));
n = tty_write(bpi->optr, bpi->opos);
if( n >= bpi->opos )
{ bpi->optr = bpi->obuf; bpi->opos = 0; }
else if( n > 0 )
{ bpi->optr += n; bpi->opos -= n; }
else
return -1;
return 0;
}
/*****************************************************************************
* Send as much buffered data or messages from the queue as possible
*
* Arguments:
* bpi binkp state structure
*
* Return value:
* Zero on success, and non-zero value on errors
*/
int binkp_send(s_bpinfo *bpi)
{
int i;
if( bpi->opos == 0 && bpi->msgqueue )
{
/*
* Buffer is empty and there are unsent msgs
*/
for( i = 0; i < bpi->n_msgs; i++ )
{
if( bpi->msgqueue[i].sent == FALSE )
{
if( binkp_buffer_message(bpi, &bpi->msgqueue[i]) )
break;
else
bpi->msgqueue[i].sent = TRUE;
}
}
/* If the message queue is empty, free it */
if( i >= bpi->n_msgs )
{
if( bpi->msgqueue )
{ free(bpi->msgqueue); bpi->msgqueue = NULL; }
bpi->n_msgs = 0;
}
}
return bpi->opos ? binkp_send_buffer(bpi) : 0;
}
/*****************************************************************************
* Flush all buffers and queues that can contain unsent data
*
* Arguments:
* bpi binkp state structure
* timeout abort flushing if this time will be exceeded
*
* Return value:
* Zero on success, and non-zero value on errors
*/
int binkp_flush_queue(s_bpinfo *bpi, int timeout)
{
bool send_ready = FALSE;
time_t flush_timer;
timer_set(&flush_timer, timeout);
while( bpi->opos > 0 || bpi->n_msgs > 0 )
{
if( timer_expired(flush_timer)
|| tty_select(NULL, &send_ready, 10) < 0 )
return -1;
if( send_ready && binkp_send(bpi) < 0 )
return -1;
}
return 0;
}
/*****************************************************************************
* Try to receive next message or data block in non-blocking mode
*
* Arguments:
* bpi binkp state structure
*
* Return value:
* One of the BPMSG_* values
*/
int binkp_recv(s_bpinfo *bpi)
{
int n = 0;
int size;
if( bpi->inew || bpi->isize == -1 )
{
bpi->inew = FALSE;
bpi->isize = -1;
size = BINKP_BLK_HDRSIZE;
}
else
size = bpi->isize;
if( size > 0 )
{
n = tty_read(bpi->ibuf + bpi->ipos, size - bpi->ipos);
if( n <= 0 ) return BPMSG_EXIT;
}
bpi->ipos += n;
if( bpi->ipos == size )
{
if( bpi->isize == -1 )
{
/* We got block header */
bpi->ipos = 0;
bpi->imsg = ((bpi->ibuf[0] >> 7) & 0377) ? TRUE : FALSE;
bpi->isize = binkp_gethdr(bpi->ibuf);
DEB((D_PROT, "binkp_recv: received header: %ld byte(s) (%s)",
(long)bpi->isize, bpi->imsg ? "msg" : "data"));
if( bpi->isize > BINKP_MAX_BLKSIZE )
{
log("internal error: got %ld bytes block size", bpi->isize);
return BPMSG_EXIT;
}
else if( bpi->isize == 0 )
{
bpi->ipos = 0;
bpi->inew = TRUE;
bpi->isize = -1;
if( bpi->imsg == TRUE )
log("zero length message from remote");
}
}
else /* We got whole data block/message */
{
if( bpi->imsg == TRUE ) /* Is it message? */
{
bpi->ipos = 0;
bpi->inew = TRUE;
bpi->ibuf[size] = '\0';
bpi->imsgtype = binkp_getmsgtype(bpi->ibuf[0]);
DEB((D_PROT, "binkp_recv: got message #%d, %ld byte(s), \"%s\"",
(int)bpi->imsgtype, bpi->isize, bpi->ibuf+1));
++bpi->msgs_in_batch;
if( bpi->imsgtype < 0 )
{
bpi->isize = -1;
log("got incorrect message type");
if( ++bpi->junkcount >= 5 )
{
log("junk count exceeded");
return BPMSG_EXIT;
}
return BPMSG_NONE;
}
return bpi->imsgtype;
}
else /* It is data */
{
bpi->ipos = 0;
bpi->inew = TRUE;
bpi->ibuf[size] = '\0';
DEB((D_PROT, "binkp_recv: got data block, %ld byte(s)",
(long)bpi->isize));
return BPMSG_DATA;
}
}
}
return BPMSG_NONE;
int r;
char *chkslash;
if( strlen(str)>PATH_MAX ) {
log("too long string, overflow may occur");
return -1;
}
DEB((D_24554, "info to parse: %s", str));
r = sscanf(str, with_offset? "%s %d %d %d": "%s %d %d", &fi->fn, &fi->sz, &fi->tm, &fi->offs);
chkslash = fi->fn;
while (1) {
chkslash = strchr(chkslash, '/');
if (chkslash) {
*chkslash = '_';
}
else {
break;
}
}
if (r==(with_offset? 4: 3)) {
return 0;
}
else {
return -1;
}
}
/*****************************************************************************
@ -499,6 +74,7 @@ int binkp_recv(s_bpinfo *bpi)
* Return value:
* None
*/
/*
void binkp_queue_sysinfo(s_bpinfo *bpi, s_binkp_sysinfo *binkp)
{
int i;
@ -538,8 +114,10 @@ void binkp_queue_sysinfo(s_bpinfo *bpi, s_binkp_sysinfo *binkp)
if (state.caller)
{
char *szOpt = xstrcpy (" MB");
#ifndef NETSPOOL
if (!nodelist_checkflag (state.node.flags, "NR"))
szOpt = xstrcat (szOpt, " NR");
#endif
if (!nodelist_checkflag (state.node.flags, "ND"))
szOpt = xstrcat (szOpt, " ND");
if (*szOpt)
@ -547,6 +125,7 @@ void binkp_queue_sysinfo(s_bpinfo *bpi, s_binkp_sysinfo *binkp)
free (szOpt);
}
}
*/
/*****************************************************************************
* Write options to the log
@ -572,16 +151,15 @@ void binkp_log_options(s_binkp_sysinfo *remote)
* Return value:
* None
*/
void binkp_log_sysinfo(s_binkp_sysinfo *binkp)
{
int i;
char abuf[BF_MAXADDRSTR+1];
if( binkp->anum )
for( i = 0; i < binkp->anum; i++ )
{
log(" Address : %s", ftn_addrstr(abuf, binkp->addrs[i].addr));
}
for( i = 0; i < state.n_remoteaddr; i++ ) {
log(" Address : %s", ftn_addrstr(abuf, state.remoteaddrs[i].addr));
}
if( *binkp->systname && *binkp->phone )
log(" System : %s (%s)",
@ -626,6 +204,7 @@ void binkp_log_sysinfo(s_binkp_sysinfo *binkp)
log(" Time : %s", string_printable(binkp->timestr));
}
/*****************************************************************************
* Set our local system information
*
@ -650,25 +229,21 @@ void binkp_set_sysinfo(s_binkp_sysinfo *binkp, s_faddr *remote_addr, bool caller
const char *p_flags = conf_string(cf_flags);
/* free previously allocated memory */
if( binkp->addrs )
free(binkp->addrs);
// if( binkp->addrs )
// free(binkp->addrs);
memset(binkp, '\0', sizeof(s_binkp_sysinfo));
/* Set best primary address */
if( remote_addr )
{
if(remote_addr) {
primary = session_get_bestaka(*remote_addr);
/* Add primary address */
if( primary )
session_addrs_add(&binkp->addrs, &binkp->anum, *primary);
if (primary) session_addrs_add(&state.localaddrs, &state.n_localaddr, *primary);
}
/* Add other AKAs */
for( addr_ptr = conf_first(cf_address); addr_ptr;
addr_ptr = conf_next(addr_ptr) )
{
for( addr_ptr = conf_first(cf_address); addr_ptr; addr_ptr = conf_next(addr_ptr) ) {
for( hide_ptr = conf_first(cf_hide_our_aka); hide_ptr;
hide_ptr = conf_next(hide_ptr) )
{
@ -677,12 +252,11 @@ void binkp_set_sysinfo(s_binkp_sysinfo *binkp, s_faddr *remote_addr, bool caller
}
if( !hide_ptr && primary != &addr_ptr->d.falist.addr )
session_addrs_add(&binkp->addrs, &binkp->anum,
session_addrs_add(&state.localaddrs, &state.n_localaddr,
addr_ptr->d.falist.addr);
}
if( binkp->anum == 0 )
log("warning: no addresses will be presented to remote");
if (state.n_localaddr == 0) log("warning: no addresses will be presented to remote");
/* session password */
if( caller )
@ -725,6 +299,7 @@ void binkp_set_sysinfo(s_binkp_sysinfo *binkp, s_faddr *remote_addr, bool caller
}
}
void binkp_parse_options(s_binkp_sysinfo *binkp, char *options)
{
char *p, *n;
@ -732,9 +307,10 @@ void binkp_parse_options(s_binkp_sysinfo *binkp, char *options)
for( p = string_token(options, &n, NULL, 0); p;
p = string_token(NULL, &n, NULL, 0) )
{
if( !strcmp(p, "NR") )
if( !strcmp(p, "NR") ) {
binkp->options |= BINKP_OPT_NR;
else if( !strcmp(p, "MB") )
} else
if( !strcmp(p, "MB") )
binkp->options |= BINKP_OPT_MB;
else if( !strcmp(p, "MPWD") )
binkp->options |= BINKP_OPT_MPWD;
@ -771,3 +347,4 @@ void binkp_parse_options(s_binkp_sysinfo *binkp, char *options)
}
}

@ -40,14 +40,21 @@ const char *Protocols[] =
* Return value:
* Zero value on success and non-zero if nothing to send
*/
static int prot_get_next_file(s_filelist **dest, s_protinfo *pi, s_fsqueue *q)
static int prot_get_next_file(s_filelist **dest, s_protinfo *pi)
{
DEB((D_OUTBOUND, "prot_get_next_file")); // %s %d", hint->fn, hint->sz);
s_filelist *ptrl = NULL;
s_filelist *best = NULL;
s_fsqueue *q = &state.queue;
s_filehint *hint = NULL; // M_GET hinting does not work good here as it spec net_name and it is unknown here (especially for PKTs)
*dest = NULL;
for( ptrl = q->fslist; ptrl; ptrl = ptrl->next )
/* local queue */
for( ptrl = q->fslist; ptrl; ptrl = ptrl->next ) {
//DEB((D_OUTBOUND, "scan %s", ptrl->fname));
if (hint) if (strcmp(hint->fn, ptrl->fname) !=0 || hint->sz != ptrl->size) continue;
if( ptrl->status == STATUS_WILLSEND )
{
if( pi->reqs_only )
@ -83,6 +90,8 @@ static int prot_get_next_file(s_filelist **dest, s_protinfo *pi, s_fsqueue *q)
else
best = ptrl;
}
}
//DEB((D_OUTBOUND, log("scan1 done");
if( best )
{
@ -90,13 +99,99 @@ static int prot_get_next_file(s_filelist **dest, s_protinfo *pi, s_fsqueue *q)
return 0;
}
for( ptrl = pi->filelist; ptrl; ptrl = ptrl->next )
for( ptrl = pi->filelist; ptrl; ptrl = ptrl->next ) {
if (hint) if (strcmp(hint->fn, ptrl->fname) !=0 || hint->sz != ptrl->size) continue;
if( ptrl->status == STATUS_WILLSEND )
{
*dest = ptrl;
return 0;
}
}
//DEB((D_OUTBOUND, log("scan2 done");
/* network queue */
#ifdef NETSPOOL
if (hint) return 1; // cannot choose
/*DEB((D_OUTBOUND, log("netspool next file");*/
if(state.netspool.state == NS_NOTINIT) {
/*DEB((D_OUTBOUND, log("new netspool connection");*/
#define ADDRBUF 3000
#define SMALLBUF 128
char password[SMALLBUF];
char address[SMALLBUF];
char addresses[ADDRBUF];
int i, pos, alen;
char *host = conf_string(cf_netspool_host);
char *port = conf_string(cf_netspool_port);
if(host==NULL) {
//DEB((D_OUTBOUND, log("netspool is not configured");
state.netspool.state = NS_UNCONF;
} else {
if (state.n_remoteaddr==0) {
log("cannot start netspool: list of remote addresses has zero length");
return -1;
}
for(i=0, pos=0; i<state.n_remoteaddr; i++) {
alen=snprintf(address, SMALLBUF, state.remoteaddrs[i].addr.point? "%d:%d/%d.%d": "%d:%d/%d",
state.remoteaddrs[i].addr.zone, state.remoteaddrs[i].addr.net,
state.remoteaddrs[i].addr.node, state.remoteaddrs[i].addr.point);
if (!state.remoteaddrs[i].good) {
log("ignoring addr %s", address);
continue;
}
if (pos+alen+1 > ADDRBUF-1) { // space for zero length string as end marker
log("no buffer space for address %s", address);
break;
}
DEB((D_OUTBOUND, "add address %s", address));
memcpy (addresses+pos, address, alen);
pos += alen;
addresses[pos++] = 0;
}
addresses[pos++] = 0;
if(state.protected) {
session_get_password(state.remoteaddrs[0].addr, password, SMALLBUF);
} else {
password[0] = 0;
}
log("netspool start %s %s", host, port);
netspool_start(&state.netspool, host, port, addresses, password);
}
}
if(state.netspool.state == NS_READY) {
/*DEB((D_OUTBOUND, log("netspool request");*/
netspool_query(&state.netspool, "ALL");
}
if(state.netspool.state == NS_RECEIVING) {
//DEB((D_OUTBOUND, log("netspool begin receive");
netspool_receive(&state.netspool);
} else {
//DEB((D_OUTBOUND, log("netspool could not start receive");
return 1;
}
if(state.netspool.state == NS_RECVFILE) {
/*DEB((D_OUTBOUND, log("netspool start file");*/
*dest = NULL;
return 0;
}
if(state.netspool.state == NS_READY) {
//DEB((D_OUTBOUND, log("netspool queue empty");
netspool_end(&state.netspool);
}
if(state.netspool.state==NS_ERROR) {
log("netspool error %s", state.netspool.error);
}
#endif
return 1;
}
@ -149,7 +244,7 @@ void prot_update_traffic(s_protinfo *pi, const s_fsqueue *q)
* Return value:
* Zero value on success and non-zero if have nothing to send
*/
int p_tx_fopen(s_protinfo *pi)
int p_tx_fopen(s_protinfo *pi, s_filehint *hint)
{
FILE *fp;
struct stat st;
@ -157,50 +252,90 @@ int p_tx_fopen(s_protinfo *pi)
if( state.sopts.holdall )
return 1;
if (hint) {
DEB((D_OUTBOUND, "trying to reopen file %s size %d time %d", hint->fn, hint->sz, hint->tm));
int i;
for (i=0; i++; i<pi->n_sentfiles) {
DEB((D_OUTBOUND, "check %s %d %d", pi->sentfiles[i].net_name, pi->sentfiles[i].bytes_total, pi->sentfiles[i].mod_time));
if (strcmp(pi->sentfiles[i].net_name, hint->fn)==0) {
DEB((D_OUTBOUND, "name match"));
if (pi->sentfiles[i].bytes_total == hint->sz) {
DEB((D_OUTBOUND, "size match"));
if (pi->sentfiles[i].mod_time == hint->tm) {
DEB((D_OUTBOUND, "time match"));
if (!pi->sentfiles[i].fp) {
DEB((D_OUTBOUND, "already closed"));
return -1;
}
pi->send = pi->sentfiles + i;
pi->send->eofseen = FALSE;
pi->send->status = FSTAT_PROCESS;
DEB((D_OUTBOUND, "reopened %s", pi->send->fname));
return 0;
}
}
}
}
DEB((D_OUTBOUND, "no file for this hint"));
return -1;
}
get_next_file:
if( prot_get_next_file(&ptrl, pi, &state.queue) || !ptrl )
return 1;
if( prot_get_next_file(&ptrl, pi) ) {
DEB((D_OUTBOUND, "no next file"));
return 1;
}
if( ptrl ) {
/* Mark this file as "processed" */
ptrl->status = STATUS_SENDING;
DEB((D_OUTBOUND, "sending local file"));
/* Mark this file as "processed" */
ptrl->status = STATUS_SENDING;
pi->send_left_num -= 1;
pi->send_left_size -= ptrl->size;
pi->send_left_num -= 1;
pi->send_left_size -= ptrl->size;
if( pi->send_left_size < 0 )
if( pi->send_left_size < 0 )
pi->send_left_size = 0;
if( pi->send_left_num < 0 )
if( pi->send_left_num < 0 )
pi->send_left_num = 0;
DEB((D_PROT, "p_tx_fopen: now opening \"%s\"", ptrl->fname));
/* Reset MinCPS time counter */
pi->tx_low_cps_time = 0;
DEB((D_PROT, "p_tx_fopen: now opening \"%s\"", ptrl->fname));
if( stat(ptrl->fname, &st) )
{
if( stat(ptrl->fname, &st) ) {
logerr("send: cannot stat file \"%s\"", ptrl->fname);
goto get_next_file;
}
}
if( (fp = file_open(ptrl->fname, "r")) == NULL )
{
if( (fp = file_open(ptrl->fname, "r")) == NULL ) {
logerr("send: cannot open file \"%s\"", ptrl->fname);
goto get_next_file;
}
}
#ifndef NETSPOOL
else {
return 1;
}
#endif
/* Reset MinCPS time counter */
pi->tx_low_cps_time = 0;
/*
* Add new entry to the send files queue
*/
if( pi->sentfiles && pi->n_sentfiles > 0 )
{
DEB((D_OUTBOUND, "adding file to sentfile"));
pi->sentfiles = (s_finfo *)xrealloc(pi->sentfiles, sizeof(s_finfo)*(pi->n_sentfiles+1));
memset(&pi->sentfiles[pi->n_sentfiles], '\0', sizeof(s_finfo));
pi->send = &pi->sentfiles[pi->n_sentfiles++];
}
else
{
DEB((D_OUTBOUND, "adding file to new sentfile"));
pi->sentfiles = (s_finfo *)xmalloc(sizeof(s_finfo));
memset(pi->sentfiles, '\0', sizeof(s_finfo));
pi->send = pi->sentfiles;
@ -210,6 +345,27 @@ get_next_file:
/*
* Set file information
*/
#ifdef NETSPOOL
if( !ptrl ) {
/* send file received through netspool */
pi->send->fp = 0;
pi->send->local_name = (char*)xstrcpy("NETSPOOL");
pi->send->type = out_filetype(state.netspool.filename);
pi->send->net_name = recode_file_out(p_convfilename(state.netspool.filename, pi->send->type));
pi->send->fname = NULL;
pi->send->mod_time = time(NULL);
pi->send->mode = 0664;
pi->send->bytes_total = state.netspool.length;
pi->send->start_time = time(NULL);
pi->send->eofseen = FALSE;
pi->send->status = FSTAT_PROCESS;
pi->send->action = ACTION_ACKNOWLEDGE;
pi->send->flodsc = -1;
pi->send->waitack = true;
pi->send->netspool = true;
} else {
#endif
pi->send->fp = fp;
pi->send->local_name = (char*)xstrcpy(file_getname(ptrl->fname));
pi->send->net_name = recode_file_out(p_convfilename(pi->send->local_name, ptrl->type));
@ -225,7 +381,12 @@ get_next_file:
pi->send->type = ptrl->type;
pi->send->action = ptrl->action;
pi->send->flodsc = ptrl->flodsc;
pi->send->waitack = false;
pi->send->netspool = false;
#ifdef NETSPOOL
}
#endif
if( strcmp(pi->send->local_name, pi->send->net_name) == 0 )
{
log("send: \"%s\" %d bytes",
@ -243,6 +404,15 @@ get_next_file:
return 0;
}
int p_tx_rewind(s_protinfo *pi, size_t pos)
{
if( !pi || !pi->send || !pi->send->fp) {
DEB((D_OUTBOUND, "cannot rewind"));
return -1;
}
return fseek(pi->send->fp, pos, SEEK_SET);
}
void prot_traffic_update(s_traffic *traf, size_t size, int xtime, int type)
{
if( type & TYPE_REQANSW )
@ -298,6 +468,11 @@ int p_tx_fclose(s_protinfo *pi)
long trans_time = 0;
long cps = 0;
if (!pi->send) {
DEB((D_OUTBOUND, "already closed"));
return -1;
}
if( pi->send->fp )
{
(void)file_close(pi->send->fp);
@ -364,9 +539,17 @@ int p_tx_fclose(s_protinfo *pi)
else if( errno != ENOENT )
logerr("send: cannot truncate file \"%s\"", pi->send->fname);
break;
#ifdef NETSPOOL
case ACTION_ACKNOWLEDGE:
DEB((D_OUTBOUND, "netspool commit %s", state.netspool.filename));
netspool_acknowledge(&state.netspool);
break;
#endif
}
}
pi->send = NULL;
return 0;
}
@ -383,12 +566,33 @@ int p_tx_fclose(s_protinfo *pi)
* -1 - error reading file (must try to send file later)
* -2 - file must be skipped (send never)
*/
int p_tx_readfile(char *buffer, size_t buflen, s_protinfo *pi)
long int p_tx_readfile(char *buffer, size_t buflen, s_protinfo *pi)
{
int n;
struct stat st;
long ftell_pos;
#ifdef NETSPOOL
if (pi->send->netspool) {
/*DEB((D_OUTBOUND, log("reading netspool file");*/
if( state.netspool.state != NS_RECVFILE ) {
log("send: wrong netspool state");
pi->send->status = FSTAT_SKIPPED;
return -2;
}
n = netspool_read(&state.netspool, buffer, buflen);
pi->send->eofseen = state.netspool.length == 0;
if( n==-1 ) {
log("send: netspool error %s", state.netspool.error);
pi->send->status = FSTAT_SKIPPED;
return -2;
}
/*DEB((D_OUTBOUND, log("got %d bytes from netspool", n);*/
return n;
} else {
/*DEB((D_OUTBOUND, log("reading local file");*/
}
#endif
/*
* Sanity check: read from closed file.
*/
@ -459,7 +663,7 @@ int p_tx_readfile(char *buffer, size_t buflen, s_protinfo *pi)
* -1 - error writing file (receive later)
* -2 - file must be skipped (receive never)
*/
int p_rx_writefile(const char *buffer, size_t buflen, s_protinfo *pi)
long int p_rx_writefile(const char *buffer, size_t buflen, s_protinfo *pi)
{
struct stat st;
long ftell_pos = ftell(pi->recv->fp);
@ -545,7 +749,9 @@ static int p_move2inbound(s_protinfo *pi)
{
log("recv: cannot get unique name for \"%s\"",
pi->recv->local_name);
DEB((D_FREE, "free realname"));
free(realname);
DEB((D_FREE, "freed"));
return 1;
}
@ -592,10 +798,16 @@ static int p_move2inbound(s_protinfo *pi)
destname);
}
if( realname )
if( realname ) {
DEB((D_FREE, "free realname"));
free(realname);
if( uniqname )
DEB((D_FREE, "freed"));
}
if( uniqname ) {
DEB((D_FREE, "free uniqname"));
free(uniqname);
DEB((D_FREE, "freed"));
}
return rc ? 1 : 0;
}
@ -776,12 +988,13 @@ int p_rx_fopen(s_protinfo *pi, char *fn, size_t sz, time_t tm, mode_t mode)
if( pi->recv->mod_time == localtogmt(st.st_mtime)
&& pi->recv->bytes_total == st.st_size )
{
log("recv: allready have \"%s\"", fname);
log("recv: already have \"%s\"", fname);
pi->recv->status = FSTAT_SKIPPED;
}
}
DEB((D_FREE, "free fname"));
free(fname); fname = NULL;
DEB((D_FREE, "freed"));
if( pi->recv->status == FSTAT_SKIPPED )
return 2;
@ -802,15 +1015,17 @@ int p_rx_fopen(s_protinfo *pi, char *fn, size_t sz, time_t tm, mode_t mode)
* directory, do you know who could left it here ? :)
*/
log("recv: allready have \"%s\"", pi->recv->fname);
log("recv: already have \"%s\"", pi->recv->fname);
if( p_move2inbound(pi) == 0 )
pi->recv->status = FSTAT_SKIPPED;
else
pi->recv->status = FSTAT_REFUSED;
DEB((D_FREE, "free pi->recv->fname"));
free(pi->recv->fname);
pi->recv->fname = NULL;
DEB((D_FREE, "freed"));
return pi->recv->status == FSTAT_SKIPPED ? 2 : 1;
}
@ -849,8 +1064,10 @@ int p_rx_fopen(s_protinfo *pi, char *fn, size_t sz, time_t tm, mode_t mode)
logerr("recv: cannot open \"%s\" -> refuse", pi->recv->fname);
pi->recv->status = FSTAT_REFUSED;
DEB((D_FREE, "p_rx_open free"));
free(pi->recv->fname);
pi->recv->fname = NULL;
DEB((D_FREE, "p_rx_open ok"));
return 1;
}
@ -1183,6 +1400,13 @@ void p_session_cleanup(s_protinfo *pi, bool success)
logerr("cannot unlink temporary file \"%s\"", ptrl->fname);
}
}
#ifdef NETSPOOL
if(state.netspool.state==NS_ERROR) {
log("end session: netspool error %s", state.netspool.error);
}
/*netspool_end(&state.netspool);*/
#endif
}
/*****************************************************************************
@ -1373,8 +1597,10 @@ char *prot_unique_name(char *dirname, char *fname, int type)
*p = 'A';
else if( --p < result || *p == '.' || *p == '/' )
{
DEB((D_FREE, "free result"));
free(result);
result = NULL;
DEB((D_FREE, "result ok"));
break;
}
}
@ -1405,8 +1631,11 @@ char *prot_unique_name(char *dirname, char *fname, int type)
if( try >= MAX_TRIES )
{
if( result )
if( result ) {
DEB((D_FREE, "free result"));
free(result);
DEB((D_FREE, "result ok"));
}
return NULL;
}
@ -1425,6 +1654,7 @@ char *prot_unique_name(char *dirname, char *fname, int type)
*/
void deinit_finfo(s_finfo *fi)
{
DEB((D_FREE, "deinit_finfo"));
if( fi->fp )
fclose(fi->fp);
@ -1436,6 +1666,7 @@ void deinit_finfo(s_finfo *fi)
free(fi->fname);
memset(fi, '\0', sizeof(s_finfo));
DEB((D_FREE, "deinit_finfo end"));
}
/*****************************************************************************
@ -1553,6 +1784,7 @@ void init_protinfo(s_protinfo *pi, bool caller)
void deinit_protinfo(s_protinfo *pi)
{
int i;
DEB((D_FREE, "deinit_protinfo"));
for( i = 0; i < pi->n_sentfiles; i++ )
deinit_finfo(&pi->sentfiles[i]);
@ -1568,4 +1800,5 @@ void deinit_protinfo(s_protinfo *pi)
free(pi->rcvdfiles);
memset(pi, '\0', sizeof(s_protinfo));
DEB((D_FREE, "deinit_protinfo end"));
}

@ -610,7 +610,7 @@ void emsi_set_sysinfo(s_emsi *emsi, s_emsi *remote_emsi, int hrc,
const char *p_emsifr = conf_string(cf_emsi_FR_time);
/* free previously allocated memory */
if( emsi->addrs ) free(emsi->addrs);
// if( emsi->addrs ) free(emsi->addrs);
memset(emsi, '\0', sizeof(s_emsi));
@ -624,7 +624,7 @@ void emsi_set_sysinfo(s_emsi *emsi, s_emsi *remote_emsi, int hrc,
/* Add primary address */
if( primary )
session_addrs_add(&emsi->addrs, &emsi->anum, *primary);
session_addrs_add(&state.localaddrs, &state.n_localaddr, *primary);
/* Add other AKAs */
for( addr_ptr = conf_first(cf_address); addr_ptr;
@ -638,11 +638,11 @@ void emsi_set_sysinfo(s_emsi *emsi, s_emsi *remote_emsi, int hrc,
}
if( !hide_ptr && primary != &addr_ptr->d.falist.addr )
session_addrs_add(&emsi->addrs, &emsi->anum,
session_addrs_add(&state.localaddrs, &state.n_localaddr,
addr_ptr->d.falist.addr);
}
if( emsi->anum == 0 )
if( state.localaddrs == 0 )
log("warning: no addresses will be presented to remote");
/* session password */

@ -24,7 +24,7 @@ void emsi_init(s_handshake_protocol *THIS);
void emsi_deinit(s_handshake_protocol *THIS);
int emsi_incoming(s_handshake_protocol *THIS);
int emsi_outgoing(s_handshake_protocol *THIS);
s_faddr *emsi_remote_address(s_handshake_protocol *THIS);
//s_faddr *emsi_remote_address(s_handshake_protocol *THIS);
char *emsi_remote_password(s_handshake_protocol *THIS);
char *emsi_remote_sysop_name(s_handshake_protocol *THIS);
char *emsi_remote_system_name(s_handshake_protocol *THIS);
@ -33,7 +33,7 @@ char *emsi_remote_phone(s_handshake_protocol *THIS);
char *emsi_remote_flags(s_handshake_protocol *THIS);
char *emsi_remote_mailer(s_handshake_protocol *THIS);
int emsi_remote_traffic(s_handshake_protocol *THIS, s_traffic *dest);
s_faddr *emsi_local_address(s_handshake_protocol *THIS);
//s_faddr *emsi_local_address(s_handshake_protocol *THIS);
char *emsi_local_password(s_handshake_protocol *THIS);
s_handshake_protocol handshake_protocol_emsi = {
@ -49,7 +49,7 @@ s_handshake_protocol handshake_protocol_emsi = {
emsi_incoming,
emsi_outgoing,
/* Section 2 */
emsi_remote_address,
// emsi_remote_address,
emsi_remote_password,
emsi_remote_sysop_name,
emsi_remote_system_name,
@ -59,7 +59,7 @@ s_handshake_protocol handshake_protocol_emsi = {
emsi_remote_mailer,
emsi_remote_traffic,
/* Section 3 */
emsi_local_address,
// emsi_local_address,
emsi_local_password
};
@ -151,7 +151,7 @@ int emsi_incoming(s_handshake_protocol *THIS)
/*
* Check password(s)
*/
if( session_addrs_check(remote_emsi->addrs, remote_emsi->anum,
if( session_addrs_check(state.remoteaddrs, state.n_remoteaddr,
remote_emsi->passwd, NULL, 0) )
{
rc = HRC_BAD_PASSWD;
@ -161,7 +161,7 @@ int emsi_incoming(s_handshake_protocol *THIS)
else
{
/* Lock (create BSY) remote addresses */
if( session_addrs_lock(remote_emsi->addrs, remote_emsi->anum) )
if( session_addrs_lock(state.remoteaddrs, state.n_remoteaddr) )
{
log("all remote addresses are busy");
rc = HRC_BUSY;
@ -172,7 +172,7 @@ int emsi_incoming(s_handshake_protocol *THIS)
* We know caller's address so we can process
* more expressions and fill state.node structure..
*/
session_remote_lookup(remote_emsi->addrs, remote_emsi->anum);
session_remote_lookup(state.remoteaddrs, state.n_remoteaddr);
if( session_check_speed() )
rc = HRC_LOW_SPEED;
@ -219,8 +219,8 @@ int emsi_incoming(s_handshake_protocol *THIS)
/*
* Create mail/files queue
*/
session_create_files_queue(remote_emsi->addrs,
remote_emsi->anum);
session_create_files_queue(state.remoteaddrs,
state.n_remoteaddr);
/*
* Set FREQ processor status
@ -290,21 +290,21 @@ int emsi_outgoing(s_handshake_protocol *THIS)
/*
* Make sure expected address was presented
*/
if( session_addrs_check_genuine(remote_emsi->addrs,
remote_emsi->anum, state.node.addr) )
if( session_addrs_check_genuine(state.remoteaddrs,
state.n_remoteaddr, state.node.addr) )
return HRC_NO_ADDRESS;
/*
* Check password(s)
*/
if( session_addrs_check(remote_emsi->addrs, remote_emsi->anum,
if( session_addrs_check(state.remoteaddrs, state.n_remoteaddr,
remote_emsi->passwd, NULL, 0) )
return HRC_BAD_PASSWD;
/*
* Lock (create BSY) remote addresses
*/
(void)session_addrs_lock(remote_emsi->addrs, remote_emsi->anum);
(void)session_addrs_lock(state.remoteaddrs, state.n_remoteaddr);
/*
* Set protocol we will use ("options" ignored)
@ -341,13 +341,12 @@ int emsi_outgoing(s_handshake_protocol *THIS)
/*
* Create mail/files queue
*/
session_create_files_queue(remote_emsi->addrs,
remote_emsi->anum);
session_create_files_queue(state.remoteaddrs, state.n_remoteaddr);
return HRC_OK;
}
s_faddr *emsi_remote_address(s_handshake_protocol *THIS)
/*s_faddr *emsi_remote_address(s_handshake_protocol *THIS)
{
ASSERT(THIS);
ASSERT(THIS->remote_data);
@ -356,7 +355,7 @@ s_faddr *emsi_remote_address(s_handshake_protocol *THIS)
return &((s_emsi *)THIS->remote_data)->addrs[0].addr;
return NULL;
}
} */
char *emsi_remote_password(s_handshake_protocol *THIS)
{
@ -456,7 +455,7 @@ int emsi_remote_traffic(s_handshake_protocol *THIS, s_traffic *dest)
return -1;
}
s_faddr *emsi_local_address(s_handshake_protocol *THIS)
/*s_faddr *emsi_local_address(s_handshake_protocol *THIS)
{
ASSERT(THIS);
ASSERT(THIS->local_data);
@ -465,7 +464,7 @@ s_faddr *emsi_local_address(s_handshake_protocol *THIS)
return &((s_emsi *)THIS->local_data)->addrs[0].addr;
return NULL;
}
} */
char *emsi_local_password(s_handshake_protocol *THIS)
{

@ -116,10 +116,10 @@ char *emsi_createdat(s_emsi *emsi)
/* our addresses, akas, etc :) */
tmp = add_char(tmp, '{');
for( i = 0; i < emsi->anum; i++ )
for( i = 0; i < state.n_localaddr; i++ )
{
if( i ) tmp = add_char(tmp, ' ');
tmp = add_str(tmp, ftn_addrstr(abuf, emsi->addrs[i].addr));
tmp = add_str(tmp, ftn_addrstr(abuf, state.localaddrs[i].addr));
}
tmp = add_char(tmp, '}');
@ -146,27 +146,27 @@ char *emsi_createdat(s_emsi *emsi)
if( emsi->linkcodes.FNC ) tmp = add_str(tmp, "FNC,");
if( emsi->linkcodes.RMA ) tmp = add_str(tmp, "RMA,");
if( emsi->linkcodes.RH1 ) tmp = add_str(tmp, "RH1,");
for( i = 0; i < emsi->anum; i++ )
for( i = 0; i < state.n_localaddr; i++ )
{
if( emsi->addrs[i].flags & EMSI_FLAG_PU )
if( state.localaddrs[i].flags & EMSI_FLAG_PU )
tmp = add_nflag(tmp, "PU", i);
if( emsi->addrs[i].flags & EMSI_FLAG_HA )
if( state.localaddrs[i].flags & EMSI_FLAG_HA )
tmp = add_nflag(tmp, "HA", i);
if( emsi->addrs[i].flags & EMSI_FLAG_PM )
if( state.localaddrs[i].flags & EMSI_FLAG_PM )
tmp = add_nflag(tmp, "PM", i);
if( emsi->addrs[i].flags & EMSI_FLAG_NF )
if( state.localaddrs[i].flags & EMSI_FLAG_NF )
tmp = add_nflag(tmp, "NF", i);
if( emsi->addrs[i].flags & EMSI_FLAG_NX )
if( state.localaddrs[i].flags & EMSI_FLAG_NX )
tmp = add_nflag(tmp, "NX", i);
if( emsi->addrs[i].flags & EMSI_FLAG_NR )
if( state.localaddrs[i].flags & EMSI_FLAG_NR )
tmp = add_nflag(tmp, "NR", i);
if( emsi->addrs[i].flags & EMSI_FLAG_HN )
if( state.localaddrs[i].flags & EMSI_FLAG_HN )
tmp = add_nflag(tmp, "HN", i);
if( emsi->addrs[i].flags & EMSI_FLAG_HX )
if( state.localaddrs[i].flags & EMSI_FLAG_HX )
tmp = add_nflag(tmp, "HX", i);
if( emsi->addrs[i].flags & EMSI_FLAG_HF )
if( state.localaddrs[i].flags & EMSI_FLAG_HF )
tmp = add_nflag(tmp, "HF", i);
if( emsi->addrs[i].flags & EMSI_FLAG_HR )
if( state.localaddrs[i].flags & EMSI_FLAG_HR )
tmp = add_nflag(tmp, "HR", i);
}
if( tmp[strlen(tmp+1)] == ',' )
@ -468,10 +468,10 @@ int emsi_parsedat(char *emsi_dat, s_emsi *emsi)
if( ftn_addrparse(&addr, p, FALSE) )
log("unparsable address \"%s\" skipped", p);
else
session_addrs_add(&emsi->addrs, &emsi->anum, addr);
session_addrs_add(&state.remoteaddrs, &state.n_remoteaddr, addr);
}
if( emsi->anum == 0 )
if( state.n_remoteaddr == 0 )
{
log("parsable addresses not found");
return(1);
@ -502,24 +502,24 @@ int emsi_parsedat(char *emsi_dat, s_emsi *emsi)
else if( !strcmp(p, "RMA") ) emsi->linkcodes.RMA = 1;
else if( !strcmp(p, "RH1") ) emsi->linkcodes.RH1 = 1;
/* check EMSI-II address dependend flags */
else if( ((i=nflgcmp(p, "HA")) >= 0) && (i < emsi->anum) )
emsi->addrs[i].flags |= EMSI_FLAG_HA;
else if( ((i=nflgcmp(p, "PM")) >= 0) && (i < emsi->anum) )
emsi->addrs[i].flags |= EMSI_FLAG_PM;
else if( ((i=nflgcmp(p, "NF")) >= 0) && (i < emsi->anum) )
emsi->addrs[i].flags |= EMSI_FLAG_NF;
else if( ((i=nflgcmp(p, "NX")) >= 0) && (i < emsi->anum) )
emsi->addrs[i].flags |= EMSI_FLAG_NX;
else if( ((i=nflgcmp(p, "NR")) >= 0) && (i < emsi->anum) )
emsi->addrs[i].flags |= EMSI_FLAG_NR;
else if( ((i=nflgcmp(p, "HN")) >= 0) && (i < emsi->anum) )
emsi->addrs[i].flags |= EMSI_FLAG_HN;
else if( ((i=nflgcmp(p, "HX")) >= 0) && (i < emsi->anum) )
emsi->addrs[i].flags |= EMSI_FLAG_HX;
else if( ((i=nflgcmp(p, "HF")) >= 0) && (i < emsi->anum) )
emsi->addrs[i].flags |= EMSI_FLAG_HF;
else if( ((i=nflgcmp(p, "HR")) >= 0) && (i < emsi->anum) )
emsi->addrs[i].flags |= EMSI_FLAG_HR;
else if( ((i=nflgcmp(p, "HA")) >= 0) && (i < state.n_remoteaddr) )
state.remoteaddrs[i].flags |= EMSI_FLAG_HA;
else if( ((i=nflgcmp(p, "PM")) >= 0) && (i < state.n_remoteaddr) )
state.remoteaddrs[i].flags |= EMSI_FLAG_PM;
else if( ((i=nflgcmp(p, "NF")) >= 0) && (i < state.n_remoteaddr) )
state.remoteaddrs[i].flags |= EMSI_FLAG_NF;
else if( ((i=nflgcmp(p, "NX")) >= 0) && (i < state.n_remoteaddr) )
state.remoteaddrs[i].flags |= EMSI_FLAG_NX;
else if( ((i=nflgcmp(p, "NR")) >= 0) && (i < state.n_remoteaddr) )
state.remoteaddrs[i].flags |= EMSI_FLAG_NR;
else if( ((i=nflgcmp(p, "HN")) >= 0) && (i < state.n_remoteaddr) )
state.remoteaddrs[i].flags |= EMSI_FLAG_HN;
else if( ((i=nflgcmp(p, "HX")) >= 0) && (i < state.n_remoteaddr) )
state.remoteaddrs[i].flags |= EMSI_FLAG_HX;
else if( ((i=nflgcmp(p, "HF")) >= 0) && (i < state.n_remoteaddr) )
state.remoteaddrs[i].flags |= EMSI_FLAG_HF;
else if( ((i=nflgcmp(p, "HR")) >= 0) && (i < state.n_remoteaddr) )
state.remoteaddrs[i].flags |= EMSI_FLAG_HR;
}
/* compatibility codes */
@ -670,14 +670,14 @@ void emsi_logdat(s_emsi *emsi)
if( emsi->have_emsi )
{
if( emsi->anum )
if( state.n_remoteaddr )
{
for( i = 0; i < emsi->anum; i++ )
for( i = 0; i < state.n_remoteaddr; i++ )
{
if( emsi->addrs[i].busy )
log(" Address : %s (Busy)", ftn_addrstr(abuf, emsi->addrs[i].addr));
if( state.remoteaddrs[i].busy )
log(" Address : %s (Busy)", ftn_addrstr(abuf, state.remoteaddrs[i].addr));
else
log(" Address : %s", ftn_addrstr(abuf, emsi->addrs[i].addr));
log(" Address : %s", ftn_addrstr(abuf, state.remoteaddrs[i].addr));
}
}
else

@ -1327,7 +1327,7 @@ int hydra_batch(s_hydrainfo *hi, s_protinfo *pi)
if( pi->send && pi->send->fp )
p_tx_fclose(pi);
send_EOB = p_tx_fopen(pi) ? TRUE : FALSE;
send_EOB = p_tx_fopen(pi, NULL) ? TRUE : FALSE;
txtries = 0;
txstate = HTX_FINFO;

@ -64,35 +64,35 @@ static int yoohoo_getword(const char *buf)
* Return value:
* None
*/
static void yoohoo_put_hello(char *buffer, s_yoohoo_sysinfo *hello)
static void yoohoo_put_hello(char *buffer, s_yoohoo_sysinfo *myhello)
{
char *p, *q;
ASSERT(buffer && hello);
ASSERT(buffer && myhello);
memset(buffer, '\0', YOOHOO_HELLOLEN);
p = buffer;
p = yoohoo_putword(p, 0x6f);
p = yoohoo_putword(p, 0x01); /* Hello version */
p = yoohoo_putword(p, hello->product_code); /* Product code */
p = yoohoo_putword(p, hello->version_maj); /* Major version */
p = yoohoo_putword(p, hello->version_min); /* Minor version */
p = yoohoo_putword(p, myhello->product_code); /* Product code */
p = yoohoo_putword(p, myhello->version_maj); /* Major version */
p = yoohoo_putword(p, myhello->version_min); /* Minor version */
strnxcpy(p, hello->system, 60); /* Node name */
strnxcpy(p, myhello->system, 60); /* Node name */
/*
* Add domain after the end of 'Node name'
* TODO: check it for buffer overflows %-I
*/
if( hello->anum > 0 && hello->addrs[0].addr.domain
&& *hello->addrs[0].addr.domain )
if( state.n_localaddr > 0 && state.localaddrs[0].addr.domain
&& *state.localaddrs[0].addr.domain )
{
char *q;
if( strlen(hello->system) + strlen(hello->addrs[0].addr.domain) > 57 )
if( strlen(myhello->system) + strlen(state.localaddrs[0].addr.domain) > 57 )
{
if( strlen(hello->addrs[0].addr.domain) < 60 )
q = p + (60 - strlen(hello->addrs[0].addr.domain));
if( strlen(state.localaddrs[0].addr.domain) < 60 )
q = p + (60 - strlen(state.localaddrs[0].addr.domain));
else
q = p;
@ -100,29 +100,29 @@ static void yoohoo_put_hello(char *buffer, s_yoohoo_sysinfo *hello)
}
else
{
q = p + strlen(hello->system) + 1;
q = p + strlen(myhello->system) + 1;
}
strnxcpy(q, hello->addrs[0].addr.domain, 60-(q-p));
strnxcpy(q, state.localaddrs[0].addr.domain, 60-(q-p));
}
p += 60;
strnxcpy(p, hello->sysop, 20); /* SysOp name */
strnxcpy(p, myhello->sysop, 20); /* SysOp name */
p += 20;
if( hello->anum > 0 )
if( state.n_localaddr > 0 )
{
p = yoohoo_putword(p, hello->addrs[0].addr.zone);
p = yoohoo_putword(p, hello->addrs[0].addr.net);
p = yoohoo_putword(p, hello->addrs[0].addr.node);
p = yoohoo_putword(p, hello->addrs[0].addr.point);
p = yoohoo_putword(p, state.localaddrs[0].addr.zone);
p = yoohoo_putword(p, state.localaddrs[0].addr.net);
p = yoohoo_putword(p, state.localaddrs[0].addr.node);
p = yoohoo_putword(p, state.localaddrs[0].addr.point);
}
else
p += 8;
strncpy(p, hello->passwd, 8); /* Session password */
strncpy(p, myhello->passwd, 8); /* Session password */
p += 8;
p += 8; /* Reserved 8 bytes */
p = yoohoo_putword(p, hello->capabilities); /* Capabilities */
p = yoohoo_putword(p, myhello->capabilities); /* Capabilities */
p += 12; /* Reserved 12 bytes */
#ifdef DEBUG
@ -145,11 +145,11 @@ static void yoohoo_put_hello(char *buffer, s_yoohoo_sysinfo *hello)
* Return value:
* None
*/
static int yoohoo_get_hello(s_yoohoo_sysinfo *hello, const char *buffer)
static int yoohoo_get_hello(s_yoohoo_sysinfo *remhello, const char *buffer)
{
s_faddr addr;
ASSERT(buffer && hello);
ASSERT(buffer && remhello);
#ifdef DEBUG
{
@ -159,16 +159,16 @@ static int yoohoo_get_hello(s_yoohoo_sysinfo *hello, const char *buffer)
}
#endif
memset(hello, '\0', sizeof(s_yoohoo_sysinfo));
memset(remhello, '\0', sizeof(s_yoohoo_sysinfo));
if( yoohoo_getword(buffer+2) != 0x01 )
log("YooHoo hello version is %d!", yoohoo_getword(buffer+2));
hello->product_code = yoohoo_getword(buffer+4);
hello->version_maj = yoohoo_getword(buffer+6);
hello->version_min = yoohoo_getword(buffer+8);
strnxcpy(hello->system, buffer+10, MIN(sizeof(hello->system),60+1));
strnxcpy(hello->sysop, buffer+70, MIN(sizeof(hello->sysop),20+1));
remhello->product_code = yoohoo_getword(buffer+4);
remhello->version_maj = yoohoo_getword(buffer+6);
remhello->version_min = yoohoo_getword(buffer+8);
strnxcpy(remhello->system, buffer+10, MIN(sizeof(remhello->system),60+1));
strnxcpy(remhello->sysop, buffer+70, MIN(sizeof(remhello->sysop),20+1));
/*
* Extract address
@ -178,11 +178,11 @@ static int yoohoo_get_hello(s_yoohoo_sysinfo *hello, const char *buffer)
addr.net = yoohoo_getword(buffer+92);
addr.node = yoohoo_getword(buffer+94);
addr.point = yoohoo_getword(buffer+96);
session_addrs_add(&hello->addrs, &hello->anum, addr);
session_addrs_add(&state.remoteaddrs, &state.n_remoteaddr, addr);
strnxcpy(hello->passwd, buffer+98, MIN(sizeof(hello->passwd),8+1));
strnxcpy(remhello->passwd, buffer+98, MIN(sizeof(remhello->passwd),8+1));
/* Reserved 8 bytes */
hello->capabilities = yoohoo_getword(buffer+114);
remhello->capabilities = yoohoo_getword(buffer+114);
/* Reserved 12 bytes */
return 0;
@ -466,11 +466,11 @@ void yoohoo_set_sysinfo(s_yoohoo_sysinfo *local_data, int hrc,
* Set our local address
*/
if( primary )
session_addrs_add(&local_data->addrs, &local_data->anum, *primary);
session_addrs_add(&state.localaddrs, &state.n_localaddr, *primary);
else if( (addr_ptr = conf_first(cf_address)) )
session_addrs_add(&local_data->addrs, &local_data->anum, addr_ptr->d.falist.addr);
session_addrs_add(&state.localaddrs, &state.n_localaddr, addr_ptr->d.falist.addr);
if( !local_data->anum )
if( !state.n_localaddr )
log("warning: no addresses will be presented to remote");
/*
@ -557,35 +557,35 @@ void yoohoo_set_sysinfo(s_yoohoo_sysinfo *local_data, int hrc,
* Return value:
* None
*/
void yoohoo_log_sysinfo(s_yoohoo_sysinfo *yoohoo)
void yoohoo_log_sysinfo(s_yoohoo_sysinfo *remyoohoo)
{
int i;
char abuf[BF_MAXADDRSTR+1];
if( yoohoo->anum )
for( i = 0; i < yoohoo->anum; i++ )
if( state.n_remoteaddr )
for( i = 0; i < state.n_remoteaddr; i++ )
{
log(" Address : %s", ftn_addrstr(abuf, yoohoo->addrs[i].addr));
log(" Address : %s", ftn_addrstr(abuf, state.remoteaddrs[i].addr));
}
else
log(" Address : <none>");
if( yoohoo->system[0] )
log(" System : %s", string_printable(yoohoo->system));
if( remyoohoo->system[0] )
log(" System : %s", string_printable(remyoohoo->system));
#ifdef BFORCE_LOG_PASSWD
if( yoohoo->passwd[0] )
log(" Password : %s", string_printable(yoohoo->passwd));
if( remyoohoo->passwd[0] )
log(" Password : %s", string_printable(remyoohoo->passwd));
#endif
if( yoohoo->sysop[0] )
log(" SysOp : %s", string_printable(yoohoo->sysop));
if( remyoohoo->sysop[0] )
log(" SysOp : %s", string_printable(remyoohoo->sysop));
if( yoohoo->product_code || yoohoo->version_maj || yoohoo->version_min )
if( remyoohoo->product_code || remyoohoo->version_maj || remyoohoo->version_min )
{
log(" Mailer : %s [%02x] %d.%d",
"?", yoohoo->product_code,
yoohoo->version_maj, yoohoo->version_min);
"?", remyoohoo->product_code,
remyoohoo->version_maj, remyoohoo->version_min);
}
}

@ -24,7 +24,7 @@ void yoohoo_init(s_handshake_protocol *THIS);
void yoohoo_deinit(s_handshake_protocol *THIS);
int yoohoo_incoming(s_handshake_protocol *THIS);
int yoohoo_outgoing(s_handshake_protocol *THIS);
s_faddr *yoohoo_remote_address(s_handshake_protocol *THIS);
//s_faddr *yoohoo_remote_address(s_handshake_protocol *THIS);
char *yoohoo_remote_password(s_handshake_protocol *THIS);
char *yoohoo_remote_sysop_name(s_handshake_protocol *THIS);
char *yoohoo_remote_system_name(s_handshake_protocol *THIS);
@ -32,7 +32,7 @@ char *yoohoo_remote_location(s_handshake_protocol *THIS);
char *yoohoo_remote_phone(s_handshake_protocol *THIS);
char *yoohoo_remote_flags(s_handshake_protocol *THIS);
char *yoohoo_remote_mailer(s_handshake_protocol *THIS);
s_faddr *yoohoo_local_address(s_handshake_protocol *THIS);
//s_faddr *yoohoo_local_address(s_handshake_protocol *THIS);
char *yoohoo_local_password(s_handshake_protocol *THIS);
s_handshake_protocol handshake_protocol_yoohoo = {
@ -48,7 +48,7 @@ s_handshake_protocol handshake_protocol_yoohoo = {
yoohoo_incoming,
yoohoo_outgoing,
/* Section 2 */
yoohoo_remote_address,
// yoohoo_remote_address,
yoohoo_remote_password,
yoohoo_remote_sysop_name,
yoohoo_remote_system_name,
@ -58,7 +58,7 @@ s_handshake_protocol handshake_protocol_yoohoo = {
NULL,
NULL,
/* Section 3 */
yoohoo_local_address,
// yoohoo_local_address,
yoohoo_local_password
};
@ -113,7 +113,7 @@ int yoohoo_incoming(s_handshake_protocol *THIS)
/*
* Check password(s)
*/
if( session_addrs_check(remote_data->addrs, remote_data->anum,
if( session_addrs_check(state.remoteaddrs, state.n_remoteaddr,
remote_data->passwd, NULL, 0) )
{
rc = HRC_BAD_PASSWD;
@ -123,8 +123,8 @@ int yoohoo_incoming(s_handshake_protocol *THIS)
else
{
/* Lock (create BSY) remote addresses */
if( session_addrs_lock(remote_data->addrs,
remote_data->anum) )
if( session_addrs_lock(state.remoteaddrs,
state.n_remoteaddr) )
{
log("all remote addresses are busy");
rc = HRC_BUSY;
@ -135,7 +135,7 @@ int yoohoo_incoming(s_handshake_protocol *THIS)
* Fill state.node with a first valid
* address, try to lookup it in nodelist
*/
session_remote_lookup(remote_data->addrs, remote_data->anum);
session_remote_lookup(state.remoteaddrs, state.n_remoteaddr);
if( session_check_speed() )
rc = HRC_LOW_SPEED;
@ -180,7 +180,7 @@ int yoohoo_incoming(s_handshake_protocol *THIS)
/*
* Create mail/files queue
*/
session_create_files_queue(remote_data->addrs, remote_data->anum);
session_create_files_queue(state.remoteaddrs, state.n_remoteaddr);
/*
* Set FREQ processor status
@ -238,23 +238,23 @@ int yoohoo_outgoing(s_handshake_protocol *THIS)
/*
* Make sure expected address was presented
*/
if( session_addrs_check_genuine(remote_data->addrs,
remote_data->anum,
if( session_addrs_check_genuine(state.remoteaddrs,
state.n_remoteaddr,
state.node.addr) )
return HRC_NO_ADDRESS;
/*
* Check password(s)
*/
if( session_addrs_check(remote_data->addrs, remote_data->anum,
if( session_addrs_check(state.remoteaddrs, state.n_remoteaddr,
remote_data->passwd, NULL, 0) )
return HRC_BAD_PASSWD;
/*
* Lock (create BSY) remote addresses
*/
(void)session_addrs_lock(remote_data->addrs,
remote_data->anum);
(void)session_addrs_lock(state.remoteaddrs,
state.n_remoteaddr);
/*
* Set protocol we will use ("options" ignored)
@ -289,13 +289,12 @@ int yoohoo_outgoing(s_handshake_protocol *THIS)
/*
* Create mail/files queue
*/
session_create_files_queue(remote_data->addrs,
remote_data->anum);
session_create_files_queue(state.remoteaddrs, state.n_remoteaddr);
return HRC_OK;
}
s_faddr *yoohoo_remote_address(s_handshake_protocol *THIS)
/*s_faddr *yoohoo_remote_address(s_handshake_protocol *THIS)
{
ASSERT(THIS);
ASSERT(THIS->remote_data);
@ -304,7 +303,7 @@ s_faddr *yoohoo_remote_address(s_handshake_protocol *THIS)
return &((s_yoohoo_sysinfo *)THIS->remote_data)->addrs[0].addr;
return NULL;
}
} */
char *yoohoo_remote_password(s_handshake_protocol *THIS)
{
@ -339,7 +338,7 @@ char *yoohoo_remote_system_name(s_handshake_protocol *THIS)
return NULL;
}
s_faddr *yoohoo_local_address(s_handshake_protocol *THIS)
/*s_faddr *yoohoo_local_address(s_handshake_protocol *THIS)
{
ASSERT(THIS);
ASSERT(THIS->local_data);
@ -348,7 +347,7 @@ s_faddr *yoohoo_local_address(s_handshake_protocol *THIS)
return &((s_yoohoo_sysinfo *)THIS->local_data)->addrs[0].addr;
return NULL;
}
} */
char *yoohoo_local_password(s_handshake_protocol *THIS)
{

@ -58,7 +58,7 @@ static void zmodem_add_empty_packet(s_protinfo *pi)
memset(&pkt, '\0', sizeof(s_packet));
pkt.dest = state.node.addr;
pkt.orig = *state.handshake->remote_address(state.handshake);
if (session_1remote_address()) pkt.orig = *session_1remote_address();
if( pkt_createpacket(p_tmpname, &pkt) )
{
@ -210,10 +210,10 @@ int tx_zmodem(s_protinfo *pi, bool caller)
case ZTX_NEXTFILE:
DEB((D_PROT, "tx_zmodem: entering state ZTX_NEXTFILE"));
if( pi->send && pi->send->fp )
p_tx_fclose(pi);
if (pi->send) p_tx_fclose(pi);
txtries = 0;
txstate = p_tx_fopen(pi) ? ZTX_FIN : ZTX_FINFO;
txstate = p_tx_fopen(pi, NULL) ? ZTX_FIN : ZTX_FINFO;
log("nextfile next state: %d", txstate);
break;
case ZTX_FINFO:
@ -556,7 +556,7 @@ int tx_zmodem(s_protinfo *pi, bool caller)
case ZFIN:
/* BUG!BUG!BUG!BUG!BUG!BUG!BUG!BUG!BUG! */
/* BUG!BUG!BUG!BUG!BUG!BUG!BUG!BUG!BUG! */
/* BUG!BUG!BUG!BUG!BUG!BUG!BUG!BUG!BUG! */
log(" BUG!BUG!BUG!BUG!BUG!BUG!BUG!BUG!BUG! ");
if( txstate == ZTX_FINACK )
{
if( PUTSTR("OO") == 0 )
@ -590,7 +590,7 @@ int tx_zmodem(s_protinfo *pi, bool caller)
/* Check pos */
if( (Z_Rxpos || txstate != ZTX_FINFOACK)
&& fseek(pi->send->fp, Z_Rxpos, 0) )
&& p_tx_rewind(pi, Z_Rxpos) )
{
logerr("can't send file from requested position");
/* Open next file for send */
@ -641,7 +641,7 @@ int tx_zmodem(s_protinfo *pi, bool caller)
case ZCRC:
if( txstate == ZTX_FINFOACK )
{
/* Send file's CRC-32 */
log(" Send file's CRC-32 ");
crc32 = 0xFFFFFFFFL;
while( ((c = getc(pi->send->fp)) != EOF) && --Z_Rxpos )
@ -717,11 +717,13 @@ exit:
setalarm(0);
if( pi->send && pi->send->fp )
p_tx_fclose(pi);
if (pi->send) p_tx_fclose(pi);
if( txbuf )
if( txbuf ) {
free(txbuf);
txbuf = NULL;
}
return(rc);
}

@ -41,7 +41,7 @@ int answ_system(e_session type, char *connstr, int inetd)
state.inet = TRUE;
}
else
state.linename = isatty(0) ? port_get_name(ttyname(0)) : "tcpip";
state.linename = isatty(0) ? port_get_name(ttyname(0)) : xstrcpy("tcpip");
if( !inetd )
{
@ -69,10 +69,6 @@ int answ_system(e_session type, char *connstr, int inetd)
gotoexit(BFERR_FATALERROR);
}
#ifdef DEBUG
(void)debug_setfilename(log_getfilename(LOG_FILE_DEBUG));
#endif
if( inetd )
{
if( connstr && *connstr )

@ -249,10 +249,6 @@ int call_system_quiet(const char *connstr, bool inet)
return BFERR_FATALERROR;
}
#ifdef DEBUG
(void)debug_setfilename(log_getfilename(LOG_FILE_DEBUG));
#endif
if( inet )
{
if( connstr && *connstr )
@ -350,10 +346,6 @@ int call_system_modem(void)
log("can't continue without logging");
return BFERR_FATALERROR;
}
#ifdef DEBUG
(void)debug_setfilename(log_getfilename(LOG_FILE_DEBUG));
#endif
if( (rc = port_open(state.modemport, 1, &oldtio)) == 0 )
{
@ -505,10 +497,6 @@ int call_system_tcpip(int callwith) // only TCPIP values
log("can't continue without logging");
return BFERR_FATALERROR;
}
#ifdef DEBUG
(void)debug_setfilename(log_getfilename(LOG_FILE_DEBUG));
#endif
switch( callwith ) {
case CALL_TCPIP_BINKP:
@ -758,6 +746,21 @@ 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) ) {
char *fidodnszone = conf_string(cf_fidodnszone);
if (fidodnszone) {
if (addr.point) {
snprintf(state.node.host, BNI_MAXHOST, "p%d.f%d.n%d.z%d.%s",
addr.point, addr.node, addr.net, addr.zone, fidodnszone);
}
else {
snprintf(state.node.host, BNI_MAXHOST, "f%d.n%d.z%d.%s",
addr.node, addr.net, addr.zone, fidodnszone);
}
log("use fido DNS zone: %s", state.node.host);
}
}
if( call_mayuse & CALL_TCPIP_ANY && !tcpip_isgood_host(state.node.host) )
{
call_mayuse &= ~CALL_TCPIP_ANY;

@ -52,8 +52,7 @@ int session_run_command(const char *execstr)
if( state.handshake )
{
if( state.handshake->remote_address
&& (addr = state.handshake->remote_address(state.handshake)) )
if( addr = session_1remote_address() )
{
exec_env_add(&eopts, "REM_ADDR_FTN",
ftn_addrstr_fido(abuf, *addr));
@ -61,8 +60,7 @@ int session_run_command(const char *execstr)
ftn_addrstr_inet(abuf, *addr));
}
if( state.handshake->local_address
&& (addr = state.handshake->local_address(state.handshake)) )
if( addr = session_1local_address() )
{
exec_env_add(&eopts, "LOC_ADDR_FTN",
ftn_addrstr_fido(abuf, *addr));
@ -166,27 +164,52 @@ void init_state(s_state *pstate)
void deinit_state(s_state *pstate)
{
if( pstate->linename )
free(pstate->linename);
if( pstate->cidstr )
free(pstate->cidstr);
if( pstate->peername )
free(pstate->peername);
if( pstate->connstr )
free(pstate->connstr);
if( pstate->inbound )
free(pstate->inbound);
if( pstate->tinbound )
free(pstate->tinbound);
if( pstate->mailfor )
deinit_falist(pstate->mailfor);
DEB((D_FREE, "deinit_state begin"));
DEB((D_FREE, "deinit_state linename"));
if (pstate->linename) free(pstate->linename);
DEB((D_FREE, "deinit_state cidstr"));
if (pstate->cidstr) free(pstate->cidstr);
DEB((D_FREE, "deinit_state peername"));
if (pstate->peername) free(pstate->peername);
DEB((D_FREE, "deinit_state connstr"));
if (pstate->connstr) free(pstate->connstr);
DEB((D_FREE, "deinit_state inbound"));
if (pstate->inbound) free(pstate->inbound);
DEB((D_FREE, "deinit_state tinbound"));
if (pstate->tinbound) free(pstate->tinbound);
DEB((D_FREE, "deinit_state mailfor"));
if (pstate->mailfor) deinit_falist(pstate->mailfor);
DEB((D_FREE, "deinit_state fsqueue"));
deinit_fsqueue(&pstate->queue);
if( state.handshake && state.handshake->deinit )
DEB((D_FREE, "deinit_state handshake"));
if (state.handshake && state.handshake->deinit) {
state.handshake->deinit(state.handshake);
}
DEB((D_FREE, "deinit_state remotedata"));
if (pstate->remoteaddrs) free (pstate->remoteaddrs);
DEB((D_FREE, "deinit_state localdata"));
if (pstate->localaddrs) free (pstate->localaddrs);
memset(pstate, '\0', sizeof(s_state));
pstate->session_rc = -1;
DEB((D_FREE, "deinit_state end"));
}
s_faddr *session_1remote_address()
{
if (state.n_remoteaddr > 0) return &state.remoteaddrs[0].addr;
return NULL;
}
s_faddr *session_1local_address()
{
if (state.n_localaddr > 0) return &state.localaddrs[0].addr;
return NULL;
}

@ -132,7 +132,7 @@ int session_addrs_check(s_sysaddr *addrs, int anum, const char *passwd,
char pbuf[32];
bool failure = FALSE;
bool success = FALSE;
bool cram = (challenge && *challenge);
bool cram = challenge;
if( !anum )
return -1;
@ -156,11 +156,12 @@ int session_addrs_check(s_sysaddr *addrs, int anum, const char *passwd,
{
char digest_bin[16];
char digest_hex[33];
md5_cram_get(pbuf, challenge, challenge_length, digest_bin);
/* Encode digest to the hex string */
string_bin_to_hex(digest_hex, digest_bin, 16);
//log("good password is %s", digest_hex);
if( strcasecmp(passwd, digest_hex) == 0 )
good_passwd = TRUE;
@ -185,7 +186,7 @@ int session_addrs_check(s_sysaddr *addrs, int anum, const char *passwd,
}
}
else
/* not password protected address */
log("not password protected address");
addrs[i].good = TRUE;
}
@ -620,7 +621,7 @@ void session_traffic(void)
rc = session_traffic_set_incoming(&state.traff_recv);
session_traffic_log(TRUE, rc ? NULL : &state.traff_recv);
/* Outgoing traffic must be allread calculated */
/* Outgoing traffic must be already calculated */
session_traffic_log(FALSE, &state.traff_send);
}
@ -813,7 +814,7 @@ int session(void)
switch(state.handshake->protocol) {
case PROT_BINKP:
rc = binkp_transfer(&pi);
rc = binkp_transfer((s_binkp_sysinfo *)state.handshake->local_data, (s_binkp_sysinfo *)state.handshake->remote_data, &pi);
break;
case PROT_ZMODEM:
case PROT_ZEDZAP:

@ -161,7 +161,9 @@ int plock_create(const char *lockname)
*++p = '\0';
else
{
DEB((D_FREE, "plock free"));
free(tmpname);
DEB((D_FREE, "plock freed"));
return PLOCK_ERROR;
}
tmpname = xstrcat(tmpname, "bforce-XXXXXX");
@ -169,7 +171,9 @@ int plock_create(const char *lockname)
if( (p = mktemp(tmpname)) == NULL )
{
logerr("can't generate unique file name from \"%s\"", tmpname);
DEB((D_FREE, "plock free"));
free(tmpname);
DEB((D_FREE, "plock freed"));
return PLOCK_ERROR;
}
@ -179,7 +183,9 @@ int plock_create(const char *lockname)
DEB((D_OUTBOUND, "out_bsy_createfile: createlink(\"%s\", \"%s\"), rc = %d",
lockname, p, rc));
DEB((D_FREE, "plock free"));
free(tmpname);
DEB((D_FREE, "plock freed"));
return rc;
}

9520
source/configure vendored

File diff suppressed because it is too large Load Diff

@ -3,7 +3,7 @@ dnl
dnl $Id$
dnl
#AC_INIT(bforce/bforce.c)
AC_INIT([bforce],[0.22.9],[e.kozhuhovskiy@gmail.com])
AC_INIT([bforce],[0.24],[sergey@fidoman.ru])
AC_CONFIG_HEADER(include/config.h)
AC_CANONICAL_SYSTEM
dnl # Minimum Autoconf version required.
@ -82,6 +82,11 @@ AC_ARG_ENABLE(syslog, [ --enable-syslog use syslog for logging [experimen
AC_DEFINE([USE_SYSLOG], [1], [Use syslog for logging])
fi], [AC_DEFINE([USE_SYSLOG], [1], [Use syslog for logging])])
AC_ARG_ENABLE(netspool, [ --enable-netspool network attached inbound/outbound],
[if test $enableval = yes; then
AC_DEFINE([NETSPOOL], [1], [Use netspool])
fi], [AC_DEFINE([NETSPOOL], [1], [Use netspool])])
AC_ARG_ENABLE(buggy_emsi, [ --disable-buggy-emsi disable buggy emsi support (default)],
[if test $enableval = yes; then
AC_DEFINE([BUGGY_EMSI], [1], [Disable buggy emsi])

@ -1,22 +0,0 @@
/* Do you want debug code to be compiled? */
#undef DEBUG
/* Do you want use DCD line control? */
#undef MODEM_WATCH_CARRIER
/* Do you want hangup to watch for modem DCD line? */
#undef MODEM_HANGUP_WATCH_CARRIER
/* Version string */
#undef RELEASE_VERSION
/* Disable passwords logging? */
#undef BFORCE_LOG_PASSWD
/* Path to the UUCP lock files directory */
#undef BFORCE_LOCK_DIR
/* Do you want use .csy locks? */
#undef BFORCE_USE_CSY

@ -14,22 +14,6 @@
#ifndef _BFORCE_H_
#define _BFORCE_H_
#ifndef DAEMON_LOGFILE
#define DAEMON_LOGFILE "/var/log/bforce/bf-daemon"
#endif
#ifndef BFORCE_LOGFILE
#define BFORCE_LOGFILE "/var/log/bforce/bf-log"
#endif
#ifndef BFORCE_DEBFILE
#define BFORCE_DEBFILE "/var/log/bforce/bf-debug"
#endif
#ifndef BFORCE_CFGFILE
#define BFORCE_CFGFILE "/etc/bforce/bforce.conf"
#endif
/*
* BinkleyForce limits
*/
@ -39,9 +23,6 @@
#define BF_MAXDOMAIN 40
#define BF_MAXADDRSTR 80
/* IP-only nodes phone */
#define NO_PSTN_PHONE "00-00-000000"
/*
* Maximum length of file name (without path)
*/
@ -154,7 +135,6 @@
/*
* Definition of new pretty types
*/
typedef char bool;
typedef unsigned long UINT32;
typedef unsigned short UINT16;
typedef unsigned char UINT8;

@ -62,6 +62,9 @@
/* Do you want to use syslog? */
#undef USE_SYSLOG
/* Netspool */
#undef NETSPOOL
/* Do you want use .csy locks? */
#undef BFORCE_USE_CSY

@ -271,6 +271,11 @@ typedef enum {
cf_debug_level,
#endif
cf_split_inbound,
#ifdef NETSPOOL
cf_netspool_host,
cf_netspool_port,
#endif
cf_fidodnszone,
BFORCE_NUMBER_OF_KEYWORDS
} bforce_config_keyword;
@ -314,7 +319,7 @@ typedef struct conf_entry {
CT_STRING,
CT_TRANSLATE,
CT_TRIES,
CT_DEBLEVEL,
// CT_DEBLEVEL,
CT_FILEBOX
} type;
s_cval_entry *data;

@ -16,6 +16,7 @@
#include "config.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>

@ -46,6 +46,8 @@ enum { LOG_FILE_DAEMON, LOG_FILE_SESSION, LOG_FILE_DEBUG, LOG_FILE_HISTORY };
# define D_FREQ 0x0000400L
# define D_STATEM 0x0000800L
# define D_DAEMON 0x0001000L
# define D_24554 0x0002000L
# define D_FREE 0x0004000L
# define D_FULL 0xfffffffL
#endif
@ -67,13 +69,14 @@ int log(const char *s, ...);
int logerr(const char *s, ...);
#ifdef DEBUG
void debug_setlevel(long newlevel, bool logit);
//void debug_setlevel(long newlevel, bool logit);
bool debug_isopened(void);
void debug_setfilename(const char *debugname);
int debug_parsestring(char *str, unsigned long *deblevel);
int debug_open(const char *debugname);
int debug_close(void);
int debug(unsigned long what, const char *str, ...);
//void debug_setfilename(const char *debugname);
//int debug_parsestring(char *str, unsigned long *deblevel);
int debug_open();
int debug_close();
int debug(unsigned long what, const char *str, ...);
void debug_configure();
#endif
#endif

@ -0,0 +1,47 @@
/*
* binkleyforce -- unix FTN mailer project
*
* Copyright (c) 1998-2000 Alexander Belkin, 2:5020/1398.11
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* $Id$
*/
#ifndef _NETSPOOL_H_
#define _NETSPOOL_H_
#define NS_NOTINIT (0)
#define NS_UNCONF (1)
#define NS_ERROR (2)
#define NS_READY (3)
#define NS_RECEIVING (4)
#define NS_RECVFILE (5)
#define STRBUF (1024)
typedef struct {
int state;
const char *error;
int socket;
char filename[STRBUF];
unsigned long long length;
} s_netspool_state;
/* create socket and start session */
void netspool_start(s_netspool_state *state, const char *host, const char *port, const char *address, const char *password);
/* request for outbound */
void netspool_query(s_netspool_state *state, const char *what);
/* receive next file */
void netspool_receive(s_netspool_state *state);
/* read data */
int netspool_read(s_netspool_state *state, void *buf, int buflen);
/* acknowledge successful file transmission */
void netspool_acknowledge(s_netspool_state *state);
/* end session */
void netspool_end(s_netspool_state *state);
#endif

@ -27,6 +27,7 @@
#define ACTION_UNLINK 0x001 /* Unlink file if send successful */
#define ACTION_TRUNCATE 0x002 /* Truncate file if send successful */
#define ACTION_FORCEUNLINK 0x004 /* Unlink file in any case after ses.*/
#define ACTION_ACKNOWLEDGE 0x008 /* Report success to netspool server */
#define TYPE_UNKNOWN 0x000
#define TYPE_NETMAIL 0x001

@ -54,9 +54,19 @@
#define BINKP_OPT_SHA1 0x10 /* CRAM-SHA1 authentication */
#define BINKP_OPT_DES 0x20 /* CRAM-DES authentication */
typedef enum binkp_mode {
bmode_failoff,
bmode_incoming_handshake,
bmode_outgoing_handshake,
bmode_transfer,
bmode_complete
} e_binkp_mode;
typedef struct {
s_sysaddr *addrs;
int anum;
// s_sysaddr *addrs;
// int anum;
char passwd[BINKP_MAXPASSWD+1];
char systname[BINKP_MAXSYSTNAME+1];
char location[BINKP_MAXLOCATION+1];
@ -72,6 +82,9 @@ typedef struct {
int options;
char challenge[BINKP_MAXCHALLENGE+1];
int challenge_length;
bool has_TRF;
int TRF_PKT;
int TRF_other;
} s_binkp_sysinfo;
@ -79,9 +92,9 @@ typedef enum {
/*
* Pseudo message types, returned by binkp_recv()
*/
BPMSG_EXIT = -3, /* Terminate session */
BPMSG_NONE = -2, /* Got nothing intresting */
BPMSG_DATA = -1, /* Got data block */
// BPMSG_EXIT = -3, /* Terminate session */
// BPMSG_NONE = -2, /* Got nothing intresting */
// BPMSG_DATA = -1, /* Got data block */
/*
* Real BinkP message types
*/
@ -101,62 +114,71 @@ typedef enum {
} e_bpmsg;
typedef struct {
bool sent; /* Sent message (queued) */
e_bpmsg type; /* Message type */
int size; /* Message size (length of text) */
char *data; /* Message text */
} s_bpmsg;
//typedef struct {
// bool sent; /* Sent message (queued) */
// e_bpmsg type; /* Message type */
// int size; /* Message size (length of text) */
// char *data; /* Message text */
//} s_bpmsg;
//typedef struct {
// char *obuf; /* Output buffer */
// int opos; /* Unsent bytes left in buffer */
// char *optr; /* Send data from this position */
//
// char *ibuf; /* Our input buffer */
// int ipos;
// int isize;
//// bool imsg; /* Is it message? */
/// bool inew;
// e_bpmsg imsgtype; /* Message type */
//
// int junkcount;
// s_bpmsg *msgqueue; /* Outgoing messages queue */
// int n_msgs; /* Number of messages in queue */
// int msgs_in_batch; /* Number of messages in batch */
// int timeout;
//} s_bpinfo;
typedef struct {
char *obuf; /* Output buffer */
int opos; /* Unsent bytes left in buffer */
char *optr; /* Send data from this position */
char *ibuf; /* Our input buffer */
int ipos;
int isize;
bool imsg; /* Is it message? */
bool inew;
e_bpmsg imsgtype; /* Message type */
int junkcount;
s_bpmsg *msgqueue; /* Outgoing messages queue */
int n_msgs; /* Number of messages in queue */
int msgs_in_batch; /* Number of messages in batch */
int timeout;
} s_bpinfo;
char fn[PATH_MAX];
size_t sz;
time_t tm;
size_t offs;
} s_bpfinfo;
/* prot_binkp.c */
int binkp_outgoing(s_binkp_sysinfo *local_data, s_binkp_sysinfo *remote_data);
int binkp_incoming(s_binkp_sysinfo *local_data, s_binkp_sysinfo *remote_data);
int binkp_transfer(s_protinfo *pi);
int binkp_transfer(s_binkp_sysinfo *local_data, s_binkp_sysinfo *remote_data, s_protinfo *pi);
/* prot_binkp_misc.c */
void binkp_init_bpinfo(s_bpinfo *bpi);
void binkp_deinit_bpinfo(s_bpinfo *bpi);
//void binkp_init_bpinfo(s_bpinfo *bpi);
//void binkp_deinit_bpinfo(s_bpinfo *bpi);
int binkp_gethdr(const char *s);
int binkp_getmsgtype(char ch);
void binkp_puthdr(char *s, unsigned int u);
void binkp_putmsgtype(char *s, e_bpmsg msg);
void binkp_queuemsg(s_bpinfo *bpi, e_bpmsg msg, const char *s1, const char *s2);
void binkp_queuemsgf(s_bpinfo *bpi, e_bpmsg msg, const char *fmt, ...);
int binkp_parsfinfo(char *s, char **fn, size_t *sz, time_t *tm, size_t *offs);
int binkp_buffer_message(s_bpinfo *bpi, s_bpmsg *msg);
int binkp_send_buffer(s_bpinfo *bpi);
int binkp_send(s_bpinfo *bpi);
int binkp_flush_queue(s_bpinfo *bpi, int timeout);
int binkp_recv(s_bpinfo *bpi);
//void binkp_queuemsg(s_bpinfo *bpi, e_bpmsg msg, const char *s1, const char *s2);
//void binkp_queuemsgf(s_bpinfo *bpi, e_bpmsg msg, const char *fmt, ...);
int binkp_parsfinfo(const char *s, s_bpfinfo *fi, bool with_offset);
//int binkp_buffer_message(s_bpinfo *bpi, s_bpmsg *msg);
//int binkp_send_buffer(s_bpinfo *bpi);
//int binkp_send(s_bpinfo *bpi);
//int binkp_flush_queue(s_bpinfo *bpi, int timeout);
//int binkp_recv(s_bpinfo *bpi);
void binkp_update_sysinfo(s_binkp_sysinfo *binkp);
void binkp_log_options(s_binkp_sysinfo *remote);
void binkp_log_sysinfo(s_binkp_sysinfo *binkp);
void binkp_queue_sysinfo(s_bpinfo *bpi, s_binkp_sysinfo *binkp);
//void binkp_queue_sysinfo(s_bpinfo *bpi, s_binkp_sysinfo *binkp);
void binkp_set_sysinfo(s_binkp_sysinfo *binkp, s_faddr *remote_addr, bool caller);
void binkp_parse_options(s_binkp_sysinfo *binkp, char *options);
int binkp_remote_traffic(s_handshake_protocol *THIS, s_traffic *dest);
/* prot_binkp_api.c */
extern s_handshake_protocol handshake_protocol_binkp;
#endif /* _P_BINKP_H_ */

@ -17,12 +17,12 @@
#include "outbound.h"
/* File transfer protocols return codes */
#define PRC_NOERROR 0 /* No comments :) */
#define PRC_ERROR 1 /* I/O error occured while snd./rcv. */
#define PRC_REMOTEABORTED 2 /* "ABORT" initiated by remote */
#define PRC_LOCALABORTED 3 /* We got SIGINT/SIGTERM? */
#define PRC_CPSTOOLOW 4 /* Cps was so low.. :( */
#define PRC_STOPTIME 5 /* Aborted due to the time limits */
#define PRC_NOERROR 0 /* Successful session */
#define PRC_ERROR 20 /* I/O error occured while snd./rcv. */
#define PRC_REMOTEABORTED 21 /* "ABORT" initiated by remote */
#define PRC_LOCALABORTED 22 /* We got SIGINT/SIGTERM? */
#define PRC_CPSTOOLOW 23 /* Cps was so low.. :( */
#define PRC_STOPTIME 24 /* Aborted due to the time limits */
/* Send/Recv file status values */
#define FSTAT_PROCESS 1
@ -50,22 +50,24 @@ typedef struct traffic {
* Information on currently receiveing/transmitting file
*/
typedef struct finfo {
FILE *fp; /* File descriptor of current file */
char *local_name; /* Local file name that is used at our side */
char *net_name; /* File name as it known to the remote side */
char *fname; /* Local file name with full path */
time_t start_time; /* Start of current file rx/tx transactions */
time_t mod_time; /* File last modification time */
mode_t mode;
size_t bytes_total; /* File size */
size_t bytes_sent;
size_t bytes_received;
size_t bytes_skipped; /* crash recovery */
int eofseen; /* end of file seen */
int status;
int action;
int type;
int flodsc; /* Index number in flo files table */
FILE *fp; /* File descriptor of current file */
char *local_name; /* Local file name that is used at our side */
char *net_name; /* File name as it known to the remote side */
char *fname; /* Local file name with full path */
time_t start_time; /* Start of current file rx/tx transactions */
time_t mod_time; /* File last modification time */
mode_t mode;
size_t bytes_total; /* File size */
size_t bytes_sent;
size_t bytes_received;
size_t bytes_skipped; /* crash recovery */
int eofseen; /* end of file seen */
int status;
int action;
int type;
int flodsc; /* Index number in flo files table */
bool waitack;
bool netspool;
} s_finfo;
/*
@ -113,10 +115,17 @@ typedef struct protinfo {
extern const char *Protocols[]; /* Protocol names */
int p_tx_fopen(s_protinfo *pi);
typedef struct {
char *fn;
size_t sz;
time_t tm;
} s_filehint;
int p_tx_fopen(s_protinfo *pi, s_filehint *hint);
int p_tx_fclose(s_protinfo *pi);
int p_tx_readfile(char *buf, size_t sz, s_protinfo *pi);
int p_rx_writefile(const char *buf, size_t sz, s_protinfo *pi);
int p_tx_rewind(s_protinfo *pi, size_t pos);
long int p_tx_readfile(char *buf, size_t sz, s_protinfo *pi);
long int p_rx_writefile(const char *buf, size_t sz, s_protinfo *pi);
int p_compfinfo(s_finfo *finf, const char *fn, size_t sz, time_t tm);
int p_rx_fopen(s_protinfo *pi, char *f_name, size_t f_size, time_t f_modtime, mode_t f_mode);
int p_rx_fclose(s_protinfo *pi);

@ -143,8 +143,8 @@ struct emsi
* {EMSI_DAT} (main handshake information)
*/
bool have_emsi;
s_sysaddr *addrs; /* dynamicaly allocated array */
int anum; /* number of used entries in it */
// s_sysaddr *addrs; /* dynamicaly allocated array */
// int anum; /* number of used entries in it */
char passwd[EMSI_MAXPASSWD+1];
s_linkcodes linkcodes; /* XXn linkcodes contained in eaddr */
s_compcodes compcodes;

@ -22,8 +22,8 @@
*/
typedef struct
{
s_sysaddr *addrs; /* FTN address */
int anum;
// s_sysaddr *addrs; /* FTN address */
// int anum;
int product_code; /* product code */
int version_maj; /* major revision of the product */
int version_min; /* minor revision of the product */

@ -20,8 +20,20 @@
#include "io.h"
#include "nodelist.h"
#include "outbound.h"
typedef struct sysaddr {
s_faddr addr;
bool busy;
bool good;
int flags;
} s_sysaddr;
#include "prot_common.h"
#ifdef NETSPOOL
#include "netspool.h"
#endif
typedef enum session {
SESSION_UNKNOWN,
SESSION_FTSC,
@ -58,13 +70,6 @@ typedef enum reqstat {
#define HRC_TEMP_ERR 7 /* Any other temporary handshake error */
#define HRC_OTHER_ERR 8 /* Any other error (e.g. timeout, NO CARRIER) */
typedef struct sysaddr {
s_faddr addr;
bool busy;
bool good;
int flags;
} s_sysaddr;
typedef struct {
char passwd[128];
char challenge[128];
@ -105,7 +110,7 @@ typedef struct handshake_protocol
/*
* 2. Remote system information extract methods
*/
s_faddr* (*remote_address)(struct handshake_protocol *THIS);
// s_faddr* (*remote_address)(struct handshake_protocol *THIS);
char* (*remote_password)(struct handshake_protocol *THIS);
char* (*remote_sysop_name)(struct handshake_protocol *THIS);
char* (*remote_system_name)(struct handshake_protocol *THIS);
@ -118,7 +123,7 @@ typedef struct handshake_protocol
/*
* 3. Local system information extract methods
*/
s_faddr* (*local_address)(struct handshake_protocol *THIS);
// s_faddr* (*local_address)(struct handshake_protocol *THIS);
char* (*local_password)(struct handshake_protocol *THIS);
} s_handshake_protocol;
@ -155,6 +160,13 @@ const s_modemport *modemport;
s_falist *mailfor; /* Remote valid addresses */
s_fsqueue queue; /* Send files queue */
#ifdef NETSPOOL
s_netspool_state netspool;
#endif
s_sysaddr *remoteaddrs;
int n_remoteaddr;
s_sysaddr *localaddrs;
int n_localaddr;
};
typedef struct state s_state;
@ -180,7 +192,8 @@ int session_init_outgoing();
int session_init_incoming();
/* s_main.c */
extern s_state state;
extern s_state state; // IF YOU WANT MAKE THIS PROGRAM MULTITHREAD, MAKE THIS VARIBLE LOCAL TO THE THREADS AND PASS IT TO SUBROUTINES
// YOU SHOULD ADD IT TO ALL FUNCTIONS: IT IS MANY OF HANDWORK BUT EASY TO DO
s_faddr *session_get_bestaka(s_faddr addr);
int session_addrs_lock(s_sysaddr *addrs, int anum);
@ -194,7 +207,7 @@ int session_check_addr(s_faddr addr);
int session_get_password(s_faddr addr, char *buffer, size_t buflen);
int session_remote_lookup(s_sysaddr *addrs, int anum);
void session_remote_log_status(void);
int session_check_password(s_faddr addr, const char *passwd);
/*int session_check_password(s_faddr addr, const char *passwd); seems not used*/
int session_set_inbound(void);
void session_set_freqs_status(void);
void session_set_send_options(void);
@ -206,6 +219,9 @@ void session_traffic(void);
void session_update_history(s_traffic *send, s_traffic *recv, int rc);
int session(void);
s_faddr* session_1remote_address();
s_faddr* session_1local_address();
/* sess_call.c */
int call_system(s_faddr addr, const s_bforce_opts *opts);
int call_system_modem(void);

@ -11,4 +11,8 @@ CC=$PREFIX-gcc
export PATH CC CPP
#./configure --prefix=/opt/bforce --host=mips-openwrt-linux --disable-syslog
#make clean
#./configure --prefix=/opt/bforce --host=mips-openwrt-linux --disable-syslog --enable-netspool
#--with-logdir=/home/fido/log --with-spooldir=/home/fido/bforce
#make && scp bin/bforce root@gw-home:/opt/bforce/bin/bforce-new
make && scp bin/bforce root@gw-home:/opt/bforce/bin/bforce
Loading…
Cancel
Save