logging, binkp TRF

master
Sergey Dorofeev 12 years ago
parent f2d9c6e4a7
commit 441f4021c2

@ -1,3 +1,9 @@
=== 2012-03 ===
$DEBUGLEVEL, $DEBUGFILE removed - please use configuration options
DNS zone support
=== 2012-02 ===
Netspool support

@ -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
#

@ -1 +1 @@
0.22.9
0.24

@ -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@

@ -1,8 +0,0 @@
tx_zmodem
rx_zmodem
hydra
binkp_transfer
all of then do use p_tx_readfile

@ -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);

@ -173,7 +173,7 @@ s_conf_entry bforce_config[BFORCE_NUMBER_OF_KEYWORDS+1] = {
#endif
#ifdef DEBUG
CONF_KEY(debug_file, CT_STRING),
CONF_KEY(debug_level, CT_DEBLEVEL),
CONF_KEY(debug_level, CT_STRING),
#endif
CONF_KEY(split_inbound, CT_BOOLEAN),
#ifdef NETSPOOL
@ -201,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)
@ -292,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;
@ -933,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;
@ -945,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);

@ -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 }
};
@ -385,28 +388,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,40 +418,49 @@ 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;
}
}
bool debug_isopened(void)
{
return debug_fp ? TRUE : FALSE;
}
int debug_open(const char *debugname)
int debug_open()
{
char buf[40];
ASSERT(debug_fp == NULL);
if( debugname )
{
if( (debug_fp = fopen(debugname, "a")) == NULL )
{
logerr("can't open debug file \"%s\"", debugname);
return -1;
}
strnxcpy(debug_name, debugname, sizeof(debug_name));
}
else if( debug_name )
if( debug_name )
{
if( (debug_fp = fopen(debug_name, "a")) == NULL )
{
@ -502,7 +502,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 +515,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 )

@ -115,7 +115,8 @@ int binkp_loop(s_binkp_state *bstate) {
// session criterium handshake criterium
while (!bstate->complete || bstate->waiting_got) {
log("loop s: %d r: %d", bstate->batchsendcomplete, bstate->batchreceivecomplete);
DEB((D_24554, "loop s: %d r: %d p: %d sp: %d", bstate->batchsendcomplete, bstate->batchreceivecomplete,
bstate->phase, bstate->subphase));
if (bstate->continuesend) {
no_more_to_send = false;
bstate->continuesend = false;
@ -123,7 +124,7 @@ int binkp_loop(s_binkp_state *bstate) {
if (have_to_write==0 && (!no_more_to_send || bstate->extracmd[0]!=-1)) {
m = binkp_getforsend(bstate, writebuf+BINKP_HEADER, &block_type, &block_length);
if(m==1 || m==3) {
//log("got block for sending %d %hu", block_type, block_length);
//DEB((D_24554, "got block for sending %d %hu", block_type, block_length));
write_pos = 0;
have_to_write = block_length+BINKP_HEADER;
if( block_type == BINKP_BLK_CMD ) {
@ -132,28 +133,28 @@ int binkp_loop(s_binkp_state *bstate) {
else if( block_type == BINKP_BLK_DATA ) {
writebuf[0] = (block_length>>8)&0x7f;
} else {
log("block for sending has invalid type, aborting");
DEB((D_24554, "block for sending has invalid type, aborting"));
return PRC_ERROR;
}
writebuf[1] = block_length&0xff;
}
if (m==2 || m==3) {
log("no more to send");
DEB((D_24554, "no more to send"));
no_more_to_send = true;
}
if (m==0) {
log("binkp: nothing to write");
DEB((D_24554, "binkp: nothing to write"));
}
if (m<0 || m>3) {
log("getforsend error");
DEB((D_24554, "getforsend error"));
return PRC_ERROR;
}
}
if (bstate->batchsendcomplete && bstate->batchreceivecomplete) {
log("batch is complete");
DEB((D_24554, "batch is complete"));
if (bstate->MB && (bstate->batch_send_count || bstate->batch_recv_count)) {
log("starting one more batch");
DEB((D_24554, "starting one more batch"));
bstate->batchsendcomplete -= 1;
bstate->batchreceivecomplete -= 1;
//bstate->firstbatch = false;
@ -167,17 +168,17 @@ int binkp_loop(s_binkp_state *bstate) {
}
else {
if (bstate->waiting_got) {
log("waiting for all files have being confirmed");
DEB((D_24554, "waiting for all files have being confirmed"));
}
else {
log("finishing session");
DEB((D_24554, "finishing session"));
bstate->complete = true;
want_read = 0;
}
}
}
log("select read: %d write %d", want_read, have_to_write);
DEB((D_24554, "select read: %d write: %d", want_read, have_to_write));
if (want_read || have_to_write) {
n = tty_select(want_read?&canread:NULL, have_to_write?&canwrite:NULL, timeout);
if( n<0 ) {
@ -186,8 +187,9 @@ int binkp_loop(s_binkp_state *bstate) {
}
}
else {
log("empty loop %d", ++bstate->emptyloop);
DEB((D_24554, "empty loop %d", ++bstate->emptyloop));
if (bstate->emptyloop==10) {
log("eternal loop");
return PRC_ERROR;
}
}
@ -202,13 +204,14 @@ int binkp_loop(s_binkp_state *bstate) {
log("read: remote socket shutdown");
return PRC_REMOTEABORTED;
}
DEB((D_24554, "got %d bytes", n));
want_read -= n;
read_pos += n;
if (read_pos == BINKP_HEADER) {
// have read header, want read body
log("it should be 0: %d", want_read);
DEB((D_24554, "it should be 0: %d", want_read));
want_read = ((unsigned short)(readbuf[0]&0x7F)<<8) | readbuf[1];
log("pending block, length %u", want_read);
DEB((D_24554, "got block header, block length %u", want_read));
} // no else here: if want_read may be zero here for zero length block
}
@ -216,23 +219,23 @@ int binkp_loop(s_binkp_state *bstate) {
if (want_read==0 && read_pos) { // check every loop, not only just after read as accepting may be deferred
block_type = readbuf[0]&0x80? BINKP_BLK_CMD: BINKP_BLK_DATA;
block_length = read_pos - BINKP_HEADER;
log("binkp: complete block is received %d %hu", block_type, block_length);
DEB((D_24554, "binkp: complete block is received %d %hu", block_type, block_length));
m = binkp_doreceiveblock(bstate, readbuf+BINKP_HEADER, block_type, block_length);
if(m==1) {
log("block is successfully accepted");
DEB((D_24554, "block is successfully accepted"));
read_pos = 0;
want_read = BINKP_HEADER;
} else if (m==2) {
log("block accepted and no more is needed in this mode");
DEB((D_24554, "block accepted and no more is needed in this mode"));
no_more_read = true;
read_pos = 0;
want_read = 0; //BINKP_HEADER;
}
else if (m==0) {
log("binkp: keeping buffer");
DEB((D_24554, "binkp: keeping buffer"));
}
else if (m==3) {
log("aborting session");
DEB((D_24554, "aborting session"));
bstate->complete = true;
//rc = HRC_OTHER_ERR;
}
@ -243,7 +246,7 @@ int binkp_loop(s_binkp_state *bstate) {
}
if (have_to_write && canwrite) {
log("writing %d pos %d", have_to_write, write_pos);
DEB((D_24554, "writing %d pos %d", have_to_write, write_pos));
n = tty_write(writebuf+write_pos, have_to_write);
if( n<0 ) {
log("binkp: tty write error");
@ -253,7 +256,7 @@ int binkp_loop(s_binkp_state *bstate) {
log("write: remote socket shutdown");
return PRC_REMOTEABORTED;
}
//log("%d bytes sent", n);
DEB((D_24554, "%d bytes sent", n));
write_pos += n;
have_to_write -= n;
}
@ -285,7 +288,7 @@ int binkp_incoming(s_binkp_sysinfo *local_data, s_binkp_sysinfo *remote_data)
int binkp_transfer(s_binkp_sysinfo *local_data, s_binkp_sysinfo *remote_data, s_protinfo *pi)
{
log("start transfer");
DEB((D_24554, "start transfer"));
s_binkp_state s;
s.mode = bmode_transfer;
s.local_data = local_data;
@ -325,7 +328,7 @@ int binkp_getforsend(s_binkp_state *bstate, char *buf, int *block_type, unsigned
int my_sf, wr_pos;
int n; // read file
if (bstate->extracmd[0]!=-1) {
log("extra command from receiver %d %s", bstate->extracmd[0], bstate->extracmd+1);
DEB((D_24554, "send command from receiver %d %s", bstate->extracmd[0], bstate->extracmd+1));
buf[0] = bstate->extracmd[0];
strcpy(buf+1, bstate->extracmd+1);
*block_type = BINKP_BLK_CMD;
@ -333,7 +336,7 @@ int binkp_getforsend(s_binkp_state *bstate, char *buf, int *block_type, unsigned
bstate->extracmd[0] = -1;
if (bstate->extraislast) {
bstate->phase = 100;
log("extracmd is last");
DEB((D_24554, "extracmd is last"));
bstate->complete = true;
}
return 1;
@ -345,12 +348,12 @@ case 0: // MD5 challenge
bstate->subphase=0;
if( bstate->mode==bmode_incoming_handshake && bstate->local_data->challenge_length > 0 )
{
log("send challenge");
DEB((D_24554, "send challenge"));
char challenge[128];
string_bin_to_hex(challenge, bstate->local_data->challenge, bstate->local_data->challenge_length);
buf[0] = BPMSG_NUL;
sprintf(buf+1, "OPT CRAM-MD5-%s", challenge);
log("sent %s", buf+1);
DEB((D_24554, "send M_NUL %s", buf+1));
*block_type = BINKP_BLK_CMD;
*block_length = strlen(buf+1)+1;
return 1;
@ -390,6 +393,7 @@ case 6:
*block_length = 1 + sprintf(buf+1, "VER %s %s/%d.%d",
bstate->local_data->progname, bstate->local_data->protname,
bstate->local_data->majorver, bstate->local_data->minorver);
DEB((D_24554, "send M_NUL %s", buf+1));
return 1;
case 7:
if (bstate->mode==bmode_outgoing_handshake) {
@ -402,6 +406,7 @@ case 7:
// if (!nodelist_checkflag (state.node.flags, "ND"))
// strcat(buf+1, " ND");
*block_length = 1 + strlen(buf+1);
DEB((D_24554, "send M_NUL %s", buf+1));
return 1;
}
// else skip subphase
@ -415,7 +420,7 @@ case 7:
// p
case 2:
log("send address");
DEB((D_24554, "send address"));
bstate->phase += 1;
buf[0] = BPMSG_ADR;
wr_pos = 1;
@ -438,29 +443,29 @@ case 2:
}
*block_type = BINKP_BLK_CMD;
*block_length = wr_pos;
log("address: %s", buf+1);
DEB((D_24554, "send address: %s", buf+1));
return 1;
case 3: // send password on outgoing or pw confirmation on incoming
// special empty password is sent if there is no password for the remote addr
if (bstate->mode==bmode_incoming_handshake) {
if (bstate->password_received) {
log("password verified");
DEB((D_24554, "password verified"));
buf[0] = BPMSG_OK;
*block_type = BINKP_BLK_CMD;
*block_length = 1;
bstate->phase += 1;
return 1;
}
log("waiting for password from remote");
DEB((D_24554, "waiting for password from remote"));
return 0; // nothing to send
}
else if (bstate->mode==bmode_outgoing_handshake) {
if (!bstate->address_established) {
log("address not received still");
DEB((D_24554, "address not received still"));
return 0;
}
log("sending password");
DEB((D_24554, "sending password"));
buf[0] = BPMSG_PWD;
*block_type = BINKP_BLK_CMD;
@ -473,7 +478,7 @@ case 3: // send password on outgoing or pw confirmation on incoming
char digest_hex[33];
if(bstate->remote_data->challenge_length==0) {
log("waiting for challenge");
DEB((D_24554, "waiting for challenge"));
return 0;
}
md5_cram_get(bstate->local_data->passwd, bstate->remote_data->challenge,
@ -498,11 +503,11 @@ case 3: // send password on outgoing or pw confirmation on incoming
case 4:
if (bstate->mode==bmode_incoming_handshake) {
log("incoming handshake is complete");
DEB((D_24554, "incoming handshake is complete"));
bstate->complete = true;
}
else {
log("outgoing handshake: everything is sent");
DEB((D_24554, "outgoing handshake: everything is sent"));
}
return 2;
}
@ -513,9 +518,9 @@ case 4:
switch (bstate->phase) {
send_next_file:
case 0:
log("fetch file from queue");
DEB((D_24554, "fetch file from queue"));
if (p_tx_fopen(bstate->pi, NULL)) {
log("queue empty");
DEB((D_24554, "queue empty"));
bstate->phase = 4;
goto send_EOB;
}
@ -524,7 +529,7 @@ case 4:
//send M_FILE -1
if (bstate->NR) {
log("send M_FILE with -1");
DEB((D_24554, "send M_FILE with -1"));
buf[0] = BPMSG_FILE;
*block_length = 1+sprintf(buf+1, "%s %ld %ld -1", bstate->pi->send->net_name,
(long)bstate->pi->send->bytes_total, (long)bstate->pi->send->mod_time);
@ -534,7 +539,7 @@ case 4:
bstate->phase += 1;
case 1: //send M_FILE - M_GET forcibly sets this phase. M_GET must open needed file
log("send M_FILE");
DEB((D_24554, "send M_FILE"));
buf[0] = BPMSG_FILE;
*block_length = 1+sprintf(buf+1, "%s %ld %ld 0", bstate->pi->send->net_name,
bstate->pi->send->bytes_total, bstate->pi->send->mod_time);
@ -554,7 +559,7 @@ case 4:
log("p_tx_readfile error");
return -1;
}
log("file is sent");
DEB((D_24554, "file is sent"));
bstate->pi->send->status = FSTAT_WAITACK;
bstate->phase += 1;
@ -562,32 +567,32 @@ case 4:
case 3: //wait for acknowlede
if (bstate->pi->send->waitack) {
log("file must be acknowledged with M_GOT");
DEB((D_24554, "file must be acknowledged with M_GOT"));
int i;
bool ack = false;
for(i = 0; i < bstate->pi->n_sentfiles; i++ ) {
if (p_compfinfo(&bstate->pi->sentfiles[i], bstate->pi->send->net_name, bstate->pi->send->bytes_total, bstate->pi->send->mod_time) == 0) {
if (bstate->pi->sentfiles[i].status == FSTAT_SUCCESS) {
ack = true;
log("acknowledged");
DEB((D_24554, "acknowledged"));
break;
}
}
}
if (!ack) {
log("wait for M_GOT");
DEB((D_24554, "wait for M_GOT"));
return 0;
}
log("M_GOT received, going to next file");
DEB((D_24554, "M_GOT received, going to next file"));
} else {
log("do not wait M_GOT");
DEB((D_24554, "do not wait M_GOT"));
}
bstate->phase = 0;
goto send_next_file;
send_EOB:
case 4:
log("send EOB n_sentfile=%d", bstate->pi->n_sentfiles);
DEB((D_24554, "send EOB n_sentfile=%d", bstate->pi->n_sentfiles));
buf[0] = BPMSG_EOB;
*block_type = BINKP_BLK_CMD;
*block_length = 1;
@ -596,7 +601,7 @@ case 4:
return 1;
case 5:
log("nothing to send");
DEB((D_24554, "nothing to send"));
return 2;
@ -628,11 +633,12 @@ case BINKP_BLK_CMD:
buf[block_length] = 0; // fencing for easy processing
switch (buf[0]) {
case BPMSG_NUL: /* Site information, just logging */
log("received M_NUL len=%d", block_length);
DEB((D_24554, "received M_NUL len=%d", block_length));
DEB((D_24554, "M_NUL %s", buf+1));
binkp_process_NUL(bstate->remote_data, buf+1);
return 1;
case BPMSG_ADR: /* List of addresses */
log("received M_ADR len=%d", block_length);
DEB((D_24554, "received M_ADR len=%d", block_length));
if (bstate->address_established) {
PROTO_ERROR("remote tries to change address");
}
@ -650,7 +656,7 @@ case BPMSG_ADR: /* List of addresses */
if (bstate->mode == bmode_incoming_handshake) {
int i;
log("sending options");
DEB((D_24554, "sending options"));
bstate->extracmd[0] = BPMSG_NUL;
bstate->extraislast = false;
sprintf(bstate->extracmd+1,"OPT MB");
@ -693,7 +699,7 @@ case BPMSG_ADR: /* List of addresses */
bstate->address_established = true;
return 1;
case BPMSG_PWD: /* Session password */
log("received M_PWD len=%d", block_length);
DEB((D_24554, "received M_PWD len=%d", block_length));
if (bstate->mode != bmode_incoming_handshake) {
PROTO_ERROR("unexpected M_PWD");
}
@ -724,14 +730,14 @@ case BPMSG_PWD: /* Session password */
return 1;
}
else {
log("flag password received");
DEB((D_24554, "flag password received"));
bstate->password_received = true;
return 2;
}
break;
case BPMSG_FILE: /* File information */
log("received M_FILE len=%d", block_length);
DEB((D_24554, "received M_FILE len=%d", block_length));
if (bstate->mode != bmode_transfer) {
PROTO_ERROR("unexpected M_FILE");
}
@ -746,14 +752,14 @@ case BPMSG_FILE: /* File information */
}
if (bstate->frs == frs_didget) {
log("is it what we want?");
DEB((D_24554, "is it what we want?"));
if( bstate->pi->recv && p_compfinfo(bstate->pi->recv, recvfi.fn, recvfi.sz, recvfi.tm) == 0
&& bstate->pi->recv->bytes_skipped == recvfi.offs && bstate->pi->recv->fp ) {
log("resuming %s from offset %d", recvfi.fn, recvfi.offs);
bstate->frs = frs_data;
return 1;
}
log("no, skipping (TODO: accept it)");
DEB((D_24554, "no, skipping; TODO: accept it"));
if( bstate->extracmd[0] != -1 ) return 0;
bstate->extracmd[0] = BPMSG_SKIP;
sprintf(bstate->extracmd+1, "%s %ld %ld %ld", recvfi.fn, recvfi.sz, recvfi.tm);
@ -762,7 +768,7 @@ case BPMSG_FILE: /* File information */
}
if (bstate->frs!=frs_nothing && bstate->frs!=frs_skipping) {
log("strange receiving mode %d", bstate->frs);
DEB((D_24554, "strange receiving mode %d", bstate->frs));
PROTO_ERROR("invalid mode for M_FILE");
}
@ -774,7 +780,7 @@ case 0:
bstate->frs = frs_data;
return 1;
}
log("making M_GET to skip downloaded part");
DEB((D_24554, "making M_GET to skip downloaded part"));
bstate->extracmd[0] = BPMSG_GET;
sprintf(bstate->extracmd+1, "%s %ld %ld %ld",
bstate->pi->recv->net_name, (long)bstate->pi->recv->bytes_total,
@ -784,7 +790,7 @@ case 0:
bstate->frs = frs_didget;
return 1;
case 1:
log("SKIP (non-destructive)");
DEB((D_24554, "SKIP, non-destructive"));
bstate->extracmd[0] = BPMSG_SKIP;
sprintf(bstate->extracmd+1, "%s %ld %ld", bstate->pi->recv->net_name, (long)bstate->pi->recv->bytes_total,
(long)bstate->pi->recv->mod_time);
@ -792,7 +798,7 @@ case 1:
bstate->frs = frs_skipping;
return 1;
case 2:
log("SKIP (destructive)");
DEB((D_24554, "SKIP, destructive"));
bstate->extracmd[0] = BPMSG_GOT;
sprintf(bstate->extracmd+1, "%s %ld %ld",
bstate->pi->recv->net_name, (long)bstate->pi->recv->bytes_total,
@ -806,7 +812,7 @@ default:
PROTO_ERROR("never should get here");
case BPMSG_OK: /* Password was acknowleged (data ignored) */
log("received M_OK len=%d", block_length);
DEB((D_24554, "received M_OK len=%d", block_length));
if (bstate->mode != bmode_outgoing_handshake) {
PROTO_ERROR("unexpected M_OK");
}
@ -818,12 +824,12 @@ case BPMSG_OK: /* Password was acknowleged (data ignored) */
bstate->extraislast = true;
return 2;
}
log("outoing handshake successfully complete");
DEB((D_24554, "outoing handshake successfully complete"));
bstate->complete = true;
return 2;
case BPMSG_EOB: /* End Of Batch (data ignored) */
log("received M_EOB len=%d", block_length);
DEB((D_24554, "received M_EOB len=%d", block_length));
if (bstate->mode != bmode_transfer) {
PROTO_ERROR("unexpected M_EOB");
}
@ -832,7 +838,7 @@ case BPMSG_EOB: /* End Of Batch (data ignored) */
case BPMSG_GOT: /* File received */
case BPMSG_SKIP:
log("received GOT/SKIP len=%d", block_length);
DEB((D_24554, "received GOT/SKIP len=%d", block_length));
if (bstate->mode != bmode_transfer) {
PROTO_ERROR("unexpected M_GOT/M_SKIP");
}
@ -843,7 +849,7 @@ case BPMSG_SKIP:
}
if (strcmp (bstate->pi->send->net_name, fi.fn) == 0 && bstate->pi->send->status != FSTAT_WAITACK) {
log("aborting current file");
DEB((D_24554, "aborting current file"));
if (bstate->pi->send->netspool) {
PROTO_ERROR("cannot SKIP or REFUSE netspool");
}
@ -863,7 +869,7 @@ case BPMSG_SKIP:
bstate->pi->send->status = FSTAT_REFUSED;
} else {
if (bstate->pi->send->status == FSTAT_WAITACK) {
log("confirmed %s", fi.fn);
DEB((D_24554, "confirmed %s", fi.fn));
bstate->pi->send->status = FSTAT_SUCCESS;
} else {
log("confirmed not sent file - skipped %s", fi.fn);
@ -873,7 +879,7 @@ case BPMSG_SKIP:
bstate->pi->send->status = FSTAT_SKIPPED;
}
}
log("closing file");
DEB((D_24554, "closing file"));
p_tx_fclose(bstate->pi);
bstate->pi->send = tmp;
goto check_that_all_files_are_confirmed;
@ -886,12 +892,12 @@ check_that_all_files_are_confirmed:
int i;
for (i = 0; i < bstate->pi->n_sentfiles; i++) {
if (bstate->pi->sentfiles[i].status == FSTAT_WAITACK) {
log("sent file %d waits for acknowlede", i);
DEB((D_24554, "sent file %d waits for acknowlede", i));
return 1;
}
}
}
log("all files are confirmed");
DEB((D_24554, "all files are confirmed"));
bstate->waiting_got = false;
return 1;
@ -906,23 +912,23 @@ case BPMSG_BSY: /* All AKAs are busy */
return 3;
case BPMSG_GET: /* Get a file from offset */
log("received M_GET len=%d", block_length);
DEB((D_24554, "received M_GET len=%d", block_length));
if (bstate->mode != bmode_transfer) {
PROTO_ERROR("unexpected M_GET");
}
s_bpfinfo getfi;
if (binkp_parsfinfo(buf+1, &getfi, true) != 0) {
log("error parsing M_GET %s", buf+1);
DEB((D_24554, "error parsing M_GET %s", buf+1));
PROTO_ERROR("invalid M_GET");
}
log("M_GET file %s size %d time %d offset %d", getfi.fn, getfi.sz, getfi.tm, getfi.offs);
DEB((D_24554, "M_GET file %s size %d time %d offset %d", getfi.fn, getfi.sz, getfi.tm, getfi.offs));
if (bstate->extracmd[0] != -1) return 0;
if (bstate->pi->send) if (p_compfinfo(bstate->pi->send, getfi.fn, getfi.sz, getfi.tm)==0) {
log("M_GET for currently transmitted file");
DEB((D_24554, "M_GET for currently transmitted file"));
if (getfi.offs==bstate->pi->send->bytes_sent) {
log("M_GET offset match current (seems NR mode)");
DEB((D_24554, "M_GET offset match current, seems NR mode"));
// go to sending M_FILE
bstate->phase = 2;
bstate->extracmd[0] = BPMSG_FILE;
@ -937,7 +943,7 @@ case BPMSG_GET: /* Get a file from offset */
}
if (bstate->pi->send) if (bstate->pi->send->netspool) {
log("ignore differing M_GET for netspool");
DEB((D_24554, "ignore differing M_GET for netspool"));
bstate->continuesend = true;
return 1;
}
@ -945,7 +951,7 @@ case BPMSG_GET: /* Get a file from offset */
if (bstate->pi->send) if (p_compfinfo(bstate->pi->send, getfi.fn, getfi.sz, getfi.tm)==0) {
log("resending \"%s\" from %ld offset", bstate->pi->send->net_name, (long)getfi.offs);
if( p_tx_rewind(bstate->pi, getfi.offs) != 0 ) {
log("failed to rewind");
DEB((D_24554, "failed to rewind"));
p_tx_fclose(bstate->pi);
PROTO_ERROR("seek error")
}
@ -961,7 +967,7 @@ case BPMSG_GET: /* Get a file from offset */
}
if( bstate->pi->send ) {
log("aborting current file");
DEB((D_24554, "aborting current file"));
p_tx_fclose(bstate->pi);
}
@ -973,7 +979,7 @@ case BPMSG_GET: /* Get a file from offset */
PROTO_ERROR("could not satisfy M_GET");
}
if( p_tx_rewind(bstate->pi, getfi.offs) != 0 ) {
log("failed to rewind");
DEB((D_24554, "failed to rewind"));
p_tx_fclose(bstate->pi);
PROTO_ERROR("seek error 2");
}
@ -989,21 +995,21 @@ case BPMSG_GET: /* Get a file from offset */
bstate->continuesend = true;
return 1;
}
log("unknown command %d received", buf[0]);
DEB((D_24554, "unknown command %d received", buf[0]));
PROTO_ERROR("invalid command")
case BINKP_BLK_DATA:
//if there is file in progress
log("data block received length=%d", block_length);
DEB((D_24554, "data block received length=%d", block_length));
if (block_length==0) {
log("ignore zero length data block, argus workaround");
log("warning: remote have sent zero length data block");
return 1;
}
if (bstate->frs == frs_nothing) {
PROTO_ERROR("unexpected data block");
}
if (bstate->frs == frs_didget || bstate->frs == frs_skipping) {
log("did M_GET or M_GOT or M_SKIP, skipping data");
DEB((D_24554, "did M_GET or M_GOT or M_SKIP, skipping data"));
return 1;
}
@ -1044,7 +1050,7 @@ case BINKP_BLK_DATA:
PROTO_ERROR("extra data for file")
}
else if( bstate->pi->recv->bytes_received == bstate->pi->recv->bytes_total ) {
log("receive completed");
DEB((D_24554, "receive completed"));
bstate->frs = frs_nothing;
bstate->pi->recv->status = FSTAT_SUCCESS;
if( !p_rx_fclose(bstate->pi) ) {
@ -1056,7 +1062,7 @@ case BINKP_BLK_DATA:
return 1;
}
else {
log("some error committing file");
DEB((D_24554, "some error committing file"));
bstate->extracmd[0] = BPMSG_SKIP;
sprintf(bstate->extracmd+1, "%s %ld %ld",
bstate->pi->recv->net_name, (long)bstate->pi->recv->bytes_total,
@ -1065,7 +1071,7 @@ case BINKP_BLK_DATA:
return 1;
}
} else {
log("data block accepted");
DEB((D_24554, "data block accepted"));
return 1;
}
}
@ -1129,6 +1135,13 @@ void binkp_process_NUL(s_binkp_sysinfo *remote_data, char *buffer)
else
strnxcpy(remote_data->progname, buffer+4, sizeof(remote_data->progname));
}
else if( strncmp(buffer, "TRF ", 4) == 0 ) {
// usually 24554 protocol mailers send only netmail size and arcmail+files size
DEB((D_24554, "process TRF"));
if( sscanf(buffer, "TRF %d %d", &remote_data->TRF_PKT, &remote_data->TRF_other)==2 ) {
remote_data->has_TRF = true;
}
}
else
log("BinkP NUL: \"%s\"", string_printable(buffer)); // NUL cannot be invalid as it is optional info
}
@ -1152,11 +1165,11 @@ int binkp_auth_incoming(s_binkp_sysinfo *remote_data)
if( remote_data->challenge_length > 0
&& strncmp(remote_data->passwd, "CRAM-MD5-", 9) == 0 )
{
//log("md5 auth addrs %s", remote_data->addrs);
//log("md5 auth anum %d", remote_data->anum);
//log("md5 auth passwd %s", remote_data->passwd + 9);
//log("md5 auth challenge %s", remote_data->challenge);
//log("md5 auth challenge len %d", remote_data->challenge_length);
//DEB((D_24554, "md5 auth addrs %s", remote_data->addrs));
//DEB((D_24554, "md5 auth anum %d", remote_data->anum));
//DEB((D_24554, "md5 auth passwd %s", remote_data->passwd + 9));
//DEB((D_24554, "md5 auth challenge %s", remote_data->challenge));
//DEB((D_24554, "md5 auth challenge len %d", remote_data->challenge_length));
return session_addrs_check(state.remoteaddrs,
state.n_remoteaddr,
remote_data->passwd + 9,
@ -1164,7 +1177,7 @@ int binkp_auth_incoming(s_binkp_sysinfo *remote_data)
remote_data->challenge_length);
}
log("plain-text auth");
DEB((D_24554, "plain-text auth"));
return session_addrs_check(state.remoteaddrs, state.n_remoteaddr,
remote_data->passwd, NULL, 0);
}

@ -56,7 +56,7 @@ 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_password
@ -78,7 +78,7 @@ void binkp_init(s_handshake_protocol *THIS)
void binkp_deinit(s_handshake_protocol *THIS)
{
log("binkp_deinit");
DEB((D_FREE, "binkp_deinit"));
if (THIS==NULL) {
log("THIS==NULL");
return;
@ -97,7 +97,7 @@ void binkp_deinit(s_handshake_protocol *THIS)
free(THIS->local_data);
THIS->local_data = NULL;
}
log("binkp_deinit end");
DEB((D_FREE, "binkp_deinit end"));
}
@ -291,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;
}

@ -44,7 +44,7 @@ int binkp_parsfinfo(const char *str, s_bpfinfo *fi, bool with_offset)
log("too long string, overflow may occur");
return -1;
}
log("info to parse: %s", str);
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) {

@ -43,7 +43,7 @@ const char *Protocols[] =
static int prot_get_next_file(s_filelist **dest, s_protinfo *pi)
{
log("prot_get_next_file"); // %s %d", hint->fn, hint->sz);
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;
@ -53,7 +53,7 @@ static int prot_get_next_file(s_filelist **dest, s_protinfo *pi)
/* local queue */
for( ptrl = q->fslist; ptrl; ptrl = ptrl->next ) {
//log("scan %s", ptrl->fname);
//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 )
{
@ -91,7 +91,7 @@ static int prot_get_next_file(s_filelist **dest, s_protinfo *pi)
best = ptrl;
}
}
//log("scan1 done");
//DEB((D_OUTBOUND, log("scan1 done");
if( best )
{
@ -107,16 +107,16 @@ static int prot_get_next_file(s_filelist **dest, s_protinfo *pi)
return 0;
}
}
//log("scan2 done");
//DEB((D_OUTBOUND, log("scan2 done");
/* network queue */
#ifdef NETSPOOL
if (hint) return 1; // cannot choose
/*log("netspool next file");*/
/*DEB((D_OUTBOUND, log("netspool next file");*/
if(state.netspool.state == NS_NOTINIT) {
/*log("new netspool connection");*/
/*DEB((D_OUTBOUND, log("new netspool connection");*/
#define ADDRBUF 3000
#define SMALLBUF 128
char password[SMALLBUF];
@ -126,7 +126,7 @@ static int prot_get_next_file(s_filelist **dest, s_protinfo *pi)
char *host = conf_string(cf_netspool_host);
char *port = conf_string(cf_netspool_port);
if(host==NULL) {
//log("netspool is not configured");
//DEB((D_OUTBOUND, log("netspool is not configured");
state.netspool.state = NS_UNCONF;
} else {
if (state.n_remoteaddr==0) {
@ -145,7 +145,7 @@ static int prot_get_next_file(s_filelist **dest, s_protinfo *pi)
log("no buffer space for address %s", address);
break;
}
log("add address %s", address);
DEB((D_OUTBOUND, "add address %s", address));
memcpy (addresses+pos, address, alen);
pos += alen;
addresses[pos++] = 0;
@ -163,26 +163,26 @@ static int prot_get_next_file(s_filelist **dest, s_protinfo *pi)
}
if(state.netspool.state == NS_READY) {
/*log("netspool request");*/
/*DEB((D_OUTBOUND, log("netspool request");*/
netspool_query(&state.netspool, "ALL");
}
if(state.netspool.state == NS_RECEIVING) {
//log("netspool begin receive");
//DEB((D_OUTBOUND, log("netspool begin receive");
netspool_receive(&state.netspool);
} else {
//log("netspool could not start receive");
//DEB((D_OUTBOUND, log("netspool could not start receive");
return 1;
}
if(state.netspool.state == NS_RECVFILE) {
/*log("netspool start file");*/
/*DEB((D_OUTBOUND, log("netspool start file");*/
*dest = NULL;
return 0;
}
if(state.netspool.state == NS_READY) {
//log("netspool queue empty");
//DEB((D_OUTBOUND, log("netspool queue empty");
netspool_end(&state.netspool);
}
@ -254,42 +254,42 @@ int p_tx_fopen(s_protinfo *pi, s_filehint *hint)
return 1;
if (hint) {
log("trying to reopen file %s size %d time %d", hint->fn, hint->sz, hint->tm);
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) {
log("check %s %d %d", pi->sentfiles[i].net_name, pi->sentfiles[i].bytes_total, pi->sentfiles[i].mod_time);
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) {
log("name match");
DEB((D_OUTBOUND, "name match"));
if (pi->sentfiles[i].bytes_total == hint->sz) {
log("size match");
DEB((D_OUTBOUND, "size match"));
if (pi->sentfiles[i].mod_time == hint->tm) {
log("time match");
DEB((D_OUTBOUND, "time match"));
if (!pi->sentfiles[i].fp) {
log("already closed");
DEB((D_OUTBOUND, "already closed"));
return -1;
}
pi->send = pi->sentfiles + i;
pi->send->eofseen = FALSE;
pi->send->status = FSTAT_PROCESS;
log("reopened %s", pi->send->fname);
DEB((D_OUTBOUND, "reopened %s", pi->send->fname));
return 0;
}
}
}
}
log("no file for this hint");
DEB((D_OUTBOUND, "no file for this hint"));
return -1;
}
get_next_file:
if( prot_get_next_file(&ptrl, pi) ) {
log("no next file");
DEB((D_OUTBOUND, "no next file"));
return 1;
}
if( ptrl ) {
log("sending local file");
DEB((D_OUTBOUND, "sending local file"));
/* Mark this file as "processed" */
ptrl->status = STATUS_SENDING;
@ -328,14 +328,14 @@ get_next_file:
*/
if( pi->sentfiles && pi->n_sentfiles > 0 )
{
log("adding file to sentfile");
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
{
log("adding file to new sentfile");
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;
@ -407,7 +407,7 @@ get_next_file:
int p_tx_rewind(s_protinfo *pi, size_t pos)
{
if( !pi || !pi->send || !pi->send->fp) {
log("cannot rewind");
DEB((D_OUTBOUND, "cannot rewind"));
return -1;
}
return fseek(pi->send->fp, pos, SEEK_SET);
@ -469,7 +469,7 @@ int p_tx_fclose(s_protinfo *pi)
long cps = 0;
if (!pi->send) {
log("already closed");
DEB((D_OUTBOUND, "already closed"));
return -1;
}
@ -541,7 +541,7 @@ int p_tx_fclose(s_protinfo *pi)
break;
#ifdef NETSPOOL
case ACTION_ACKNOWLEDGE:
log("netspool commit %s", state.netspool.filename);
DEB((D_OUTBOUND, "netspool commit %s", state.netspool.filename));
netspool_acknowledge(&state.netspool);
break;
#endif
@ -574,7 +574,7 @@ long int p_tx_readfile(char *buffer, size_t buflen, s_protinfo *pi)
#ifdef NETSPOOL
if (pi->send->netspool) {
/*log("reading netspool file");*/
/*DEB((D_OUTBOUND, log("reading netspool file");*/
if( state.netspool.state != NS_RECVFILE ) {
log("send: wrong netspool state");
pi->send->status = FSTAT_SKIPPED;
@ -587,10 +587,10 @@ long int p_tx_readfile(char *buffer, size_t buflen, s_protinfo *pi)
pi->send->status = FSTAT_SKIPPED;
return -2;
}
/*log("got %d bytes from netspool", n);*/
/*DEB((D_OUTBOUND, log("got %d bytes from netspool", n);*/
return n;
} else {
/*log("reading local file");*/
/*DEB((D_OUTBOUND, log("reading local file");*/
}
#endif
/*
@ -749,9 +749,9 @@ static int p_move2inbound(s_protinfo *pi)
{
log("recv: cannot get unique name for \"%s\"",
pi->recv->local_name);
log("free realname");
DEB((D_FREE, "free realname"));
free(realname);
log("freed");
DEB((D_FREE, "freed"));
return 1;
}
@ -799,14 +799,14 @@ static int p_move2inbound(s_protinfo *pi)
}
if( realname ) {
log("free realname");
DEB((D_FREE, "free realname"));
free(realname);
log("freed");
DEB((D_FREE, "freed"));
}
if( uniqname ) {
log("free uniqname");
DEB((D_FREE, "free uniqname"));
free(uniqname);
log("freed");
DEB((D_FREE, "freed"));
}
return rc ? 1 : 0;
@ -988,13 +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;
}
}
log("free fname");
DEB((D_FREE, "free fname"));
free(fname); fname = NULL;
log("freed");
DEB((D_FREE, "freed"));
if( pi->recv->status == FSTAT_SKIPPED )
return 2;
@ -1022,10 +1022,10 @@ int p_rx_fopen(s_protinfo *pi, char *fn, size_t sz, time_t tm, mode_t mode)
else
pi->recv->status = FSTAT_REFUSED;
log("free pi->recv->fname");
DEB((D_FREE, "free pi->recv->fname"));
free(pi->recv->fname);
pi->recv->fname = NULL;
log("freed");
DEB((D_FREE, "freed"));
return pi->recv->status == FSTAT_SKIPPED ? 2 : 1;
}
@ -1064,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;
}
@ -1595,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;
}
}
@ -1627,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;
}
@ -1647,7 +1654,7 @@ char *prot_unique_name(char *dirname, char *fname, int type)
*/
void deinit_finfo(s_finfo *fi)
{
log("deinit_finfo");
DEB((D_FREE, "deinit_finfo"));
if( fi->fp )
fclose(fi->fp);
@ -1659,7 +1666,7 @@ void deinit_finfo(s_finfo *fi)
free(fi->fname);
memset(fi, '\0', sizeof(s_finfo));
log("deinit_finfo end");
DEB((D_FREE, "deinit_finfo end"));
}
/*****************************************************************************
@ -1777,7 +1784,7 @@ void init_protinfo(s_protinfo *pi, bool caller)
void deinit_protinfo(s_protinfo *pi)
{
int i;
log("deinit_protinfo");
DEB((D_FREE, "deinit_protinfo"));
for( i = 0; i < pi->n_sentfiles; i++ )
deinit_finfo(&pi->sentfiles[i]);
@ -1793,5 +1800,5 @@ void deinit_protinfo(s_protinfo *pi)
free(pi->rcvdfiles);
memset(pi, '\0', sizeof(s_protinfo));
log("deinit_protinfo end");
DEB((D_FREE, "deinit_protinfo end"));
}

@ -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:

@ -164,7 +164,7 @@ void init_state(s_state *pstate)
void deinit_state(s_state *pstate)
{
log("deinit_state begin");
DEB((D_FREE, "deinit_state begin"));
if (pstate->linename) free(pstate->linename);
if (pstate->cidstr) free(pstate->cidstr);
if (pstate->peername) free(pstate->peername);
@ -185,7 +185,7 @@ void deinit_state(s_state *pstate)
memset(pstate, '\0', sizeof(s_state));
pstate->session_rc = -1;
log("deinit_state end");
DEB((D_FREE, "deinit_state end"));
}
s_faddr *session_1remote_address()

@ -161,7 +161,7 @@ int session_addrs_check(s_sysaddr *addrs, int anum, const char *passwd,
/* Encode digest to the hex string */
string_bin_to_hex(digest_hex, digest_bin, 16);
log("good password is %s", digest_hex);
//log("good password is %s", digest_hex);
if( strcasecmp(passwd, digest_hex) == 0 )
good_passwd = TRUE;
@ -621,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);
}

@ -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;
}

48
source/configure vendored

@ -1,8 +1,8 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.68 for bforce 0.22.9.
# Generated by GNU Autoconf 2.68 for bforce 0.24.
#
# Report bugs to <e.kozhuhovskiy@gmail.com>.
# Report bugs to <sergey@fidoman.ru>.
#
#
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@ -238,11 +238,11 @@ fi
$as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
$as_echo "$0: be upgraded to zsh 4.3.4 or later."
else
$as_echo "$0: Please tell bug-autoconf@gnu.org and
$0: e.kozhuhovskiy@gmail.com about your system, including
$0: any error possibly output before this message. Then
$0: install a modern shell, or manually run the script
$0: under such a shell if you do have one."
$as_echo "$0: Please tell bug-autoconf@gnu.org and sergey@fidoman.ru
$0: about your system, including any error possibly output
$0: before this message. Then install a modern shell, or
$0: manually run the script under such a shell if you do
$0: have one."
fi
exit 1
fi
@ -560,9 +560,9 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='bforce'
PACKAGE_TARNAME='bforce'
PACKAGE_VERSION='0.22.9'
PACKAGE_STRING='bforce 0.22.9'
PACKAGE_BUGREPORT='e.kozhuhovskiy@gmail.com'
PACKAGE_VERSION='0.24'
PACKAGE_STRING='bforce 0.24'
PACKAGE_BUGREPORT='sergey@fidoman.ru'
PACKAGE_URL=''
ac_default_prefix=/usr/local/fido
@ -1243,7 +1243,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures bforce 0.22.9 to adapt to many kinds of systems.
\`configure' configures bforce 0.24 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1309,7 +1309,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of bforce 0.22.9:";;
short | recursive ) echo "Configuration of bforce 0.24:";;
esac
cat <<\_ACEOF
@ -1354,7 +1354,7 @@ Some influential environment variables:
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Report bugs to <e.kozhuhovskiy@gmail.com>.
Report bugs to <sergey@fidoman.ru>.
_ACEOF
ac_status=$?
fi
@ -1417,7 +1417,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
bforce configure 0.22.9
bforce configure 0.24
generated by GNU Autoconf 2.68
Copyright (C) 2010 Free Software Foundation, Inc.
@ -1664,9 +1664,9 @@ $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
( $as_echo "## --------------------------------------- ##
## Report this to e.kozhuhovskiy@gmail.com ##
## --------------------------------------- ##"
( $as_echo "## -------------------------------- ##
## Report this to sergey@fidoman.ru ##
## -------------------------------- ##"
) | sed "s/^/$as_me: WARNING: /" >&2
;;
esac
@ -1840,7 +1840,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by bforce $as_me 0.22.9, which was
It was created by bforce $as_me 0.24, which was
generated by GNU Autoconf 2.68. Invocation command line was
$ $0 $@
@ -4961,7 +4961,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by bforce $as_me 0.22.9, which was
This file was extended by bforce $as_me 0.24, which was
generated by GNU Autoconf 2.68. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -5017,13 +5017,13 @@ $config_files
Configuration headers:
$config_headers
Report bugs to <e.kozhuhovskiy@gmail.com>."
Report bugs to <sergey@fidoman.ru>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
bforce config.status 0.22.9
bforce config.status 0.24
configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\"
@ -6253,7 +6253,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by bforce $as_me 0.22.9, which was
This file was extended by bforce $as_me 0.24, which was
generated by GNU Autoconf 2.68. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@ -6309,13 +6309,13 @@ $config_files
Configuration headers:
$config_headers
Report bugs to <e.kozhuhovskiy@gmail.com>."
Report bugs to <sergey@fidoman.ru>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
bforce config.status 0.22.9
bforce config.status 0.24
configured by $0, generated by GNU Autoconf 2.68,
with options \\"\$ac_cs_config\\"

@ -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.

@ -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)
*/

@ -319,7 +319,7 @@ typedef struct conf_entry {
CT_STRING,
CT_TRANSLATE,
CT_TRIES,
CT_DEBLEVEL,
// CT_DEBLEVEL,
CT_FILEBOX
} type;
s_cval_entry *data;

@ -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

@ -82,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;
@ -172,6 +175,7 @@ void binkp_log_sysinfo(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;

@ -12,5 +12,7 @@ CC=$PREFIX-gcc
export PATH CC CPP
#make clean
#./configure --prefix=/opt/bforce --host=mips-openwrt-linux --disable-syslog --enable-netspool
make && scp bin/bforce root@gw-home:/opt/bforce/bin
#./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