Changed mbcico raw ifcico protocol logging
This commit is contained in:
parent
821e1dc5b6
commit
4e6faee53c
@ -23,6 +23,7 @@ v0.37.3 09-Apr-2003.
|
||||
mbcico:
|
||||
Removed some heavy debug code from ttyio functions to increase
|
||||
throughput.
|
||||
Standarized raw ifcico protocol logging.
|
||||
|
||||
lang:
|
||||
New language prompt number 17.
|
||||
|
19
mbcico/tcp.c
19
mbcico/tcp.c
@ -4,7 +4,7 @@
|
||||
* Purpose ...............: Fidonet mailer
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2002
|
||||
* Copyright (C) 1997-2003
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@ -59,7 +59,7 @@ int rxtcp(void)
|
||||
fa_list *eff_remote, tmpl;
|
||||
file_list *tosend = NULL, **tmpfl;
|
||||
|
||||
Syslog('+', "Start TCP session");
|
||||
Syslog('+', "TCP: inbound session start");
|
||||
|
||||
if (emsi_remote_lcodes & LCODE_NPU) {
|
||||
Syslog('+', "Remote requested \"no pickup\", no send");
|
||||
@ -84,7 +84,7 @@ int rxtcp(void)
|
||||
rc = tcpsndfiles(tosend);
|
||||
|
||||
if ((rc == 0) && (made_request)) {
|
||||
Syslog('+', "Freq was made, trying to receive files");
|
||||
Syslog('+', "TCP: freq was made, trying to receive files");
|
||||
rc = tcprcvfiles();
|
||||
}
|
||||
}
|
||||
@ -92,9 +92,9 @@ int rxtcp(void)
|
||||
tidy_filelist(tosend,(rc == 0));
|
||||
|
||||
if (rc)
|
||||
WriteError("TCP session failed: rc=%d", rc);
|
||||
WriteError("TCP: session failed: rc=%d", rc);
|
||||
else
|
||||
Syslog('+', "TCP session completed");
|
||||
Syslog('+', "TCP: session completed");
|
||||
return rc;
|
||||
}
|
||||
|
||||
@ -106,12 +106,9 @@ int txtcp(void)
|
||||
file_list *tosend = NULL, *respond = NULL;
|
||||
char *nonhold_mail;
|
||||
|
||||
Syslog('+', "Start TCP session");
|
||||
Syslog('+', "TCP: outbound session start");
|
||||
|
||||
// if (localoptions & NOHOLD)
|
||||
nonhold_mail = (char *)ALL_MAIL;
|
||||
// else
|
||||
// nonhold_mail = (char *)NONHOLD_MAIL;
|
||||
if (emsi_remote_lcodes & LCODE_HAT) {
|
||||
Syslog('+', "Remote asked to \"hold all traffic\", no send");
|
||||
tosend=NULL;
|
||||
@ -130,9 +127,9 @@ int txtcp(void)
|
||||
tidy_filelist(respond,0);
|
||||
|
||||
if (rc)
|
||||
WriteError("TCP session failed: rc=%d", rc);
|
||||
WriteError("TCP: session failed: rc=%d", rc);
|
||||
else
|
||||
Syslog('+', "TCP session completed");
|
||||
Syslog('+', "TCP: session completed");
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* Purpose ...............: Fidonet mailer
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2001
|
||||
* Copyright (C) 1997-2003
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
@ -82,10 +82,10 @@ int tcpsndfiles(file_list *lst)
|
||||
int rc = 0, maxrc = 0;
|
||||
file_list *tmpf;
|
||||
|
||||
Syslog('+', "Start TCP send%s",lst?"":" (dummy)");
|
||||
Syslog('+', "TCP: start send files");
|
||||
|
||||
if (getsync()) {
|
||||
WriteError("Can't get synchronization");
|
||||
WriteError("TCP: can't get synchronization");
|
||||
return MBERR_FTRANSFER;
|
||||
}
|
||||
|
||||
@ -111,9 +111,11 @@ int tcpsndfiles(file_list *lst)
|
||||
maxrc=rc;
|
||||
|
||||
if (rc) {
|
||||
WriteError("TCP send error: rc=%d",maxrc);
|
||||
WriteError("TCP: send error: rc=%d",maxrc);
|
||||
return MBERR_FTRANSFER;
|
||||
} else
|
||||
}
|
||||
|
||||
Syslog('+', "TCP: send files completed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -125,11 +127,12 @@ int tcprcvfiles(void)
|
||||
long filesize, filetime;
|
||||
char *filename, *p;
|
||||
|
||||
Syslog('+', "Start TCP receive");
|
||||
Syslog('+', "TCP: start receive files");
|
||||
if (getsync()) {
|
||||
WriteError("Can't get synchronization");
|
||||
WriteError("TCP: can't get synchronization");
|
||||
return MBERR_FTRANSFER;
|
||||
}
|
||||
|
||||
next:
|
||||
if ((rc = tcp_rblk(rxbuf, &bufl)) == 0) {
|
||||
if (strncmp(rxbuf, "SN", 2) == 0) {
|
||||
@ -153,16 +156,18 @@ next:
|
||||
|
||||
if (fout) {
|
||||
if (closeit(0))
|
||||
WriteError("Error closing file");
|
||||
WriteError("TCP: error closing file");
|
||||
(void)tcp_sblk((char *)"FERROR",6,TCP_CMD);
|
||||
} else
|
||||
goto next;
|
||||
}
|
||||
|
||||
if (rc) {
|
||||
WriteError("TCP receive error: rc=%d", rc);
|
||||
WriteError("TCP: receive error: rc=%d", rc);
|
||||
return MBERR_FTRANSFER;
|
||||
} else
|
||||
}
|
||||
|
||||
Syslog('+', "TCP: receive files completed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -184,32 +189,32 @@ static int sendtfile(char *ln, char *rn)
|
||||
if ((in = fopen(ln,"r")) == NULL) {
|
||||
sverr = errno;
|
||||
if ((sverr == ENOENT) || (sverr == EINVAL)) {
|
||||
Syslog('+', "File %s doesn't exist, removing", MBSE_SS(ln));
|
||||
Syslog('+', "TCP: file %s doesn't exist, removing", MBSE_SS(ln));
|
||||
return 0;
|
||||
} else {
|
||||
WriteError("$tcpsend: cannot open file %s, skipping", MBSE_SS(ln));
|
||||
WriteError("$TCP: can't open file %s, skipping", MBSE_SS(ln));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (fcntl(fileno(in), F_SETLK, &fl) != 0) {
|
||||
Syslog('+', "$tcpsend: cannot lock file %s, skipping", MBSE_SS(ln));
|
||||
WriteError("$TCP: can't lock file %s, skipping", MBSE_SS(ln));
|
||||
fclose(in);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (stat(ln, &st) != 0) {
|
||||
Syslog('+', "$tcpsend: cannot access \"%s\", skipping", MBSE_SS(ln));
|
||||
WriteError("$TCP: can't access \"%s\", skipping", MBSE_SS(ln));
|
||||
fclose(in);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (st.st_size > 0) {
|
||||
Syslog('+', "TCP send \"%s\" as \"%s\"", MBSE_SS(ln), MBSE_SS(rn));
|
||||
Syslog('+', "TCP size %lu bytes, dated %s", (unsigned long)st.st_size, date(st.st_mtime));
|
||||
Syslog('+', "TCP: send \"%s\" as \"%s\"", MBSE_SS(ln), MBSE_SS(rn));
|
||||
Syslog('+', "TCP: size %lu bytes, dated %s", (unsigned long)st.st_size, date(st.st_mtime));
|
||||
gettimeofday(&starttime, &tz);
|
||||
} else {
|
||||
Syslog('+', "File \"%s\" has 0 size, skiped",ln);
|
||||
Syslog('+', "TCP: file \"%s\" has 0 size, skiped",ln);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -219,16 +224,16 @@ static int sendtfile(char *ln, char *rn)
|
||||
rc = tcp_rblk(rxbuf, &bufl);
|
||||
|
||||
if (strncmp(rxbuf,"RS",2) == 0) {
|
||||
Syslog('+', "File %s already received, skipping",rn);
|
||||
Syslog('+', "TCP: file %s already received, skipping",rn);
|
||||
return 0;
|
||||
} else if (strncmp(rxbuf,"RN",2) == 0) {
|
||||
Syslog('+', "Remote refused file, aborting",rn);
|
||||
Syslog('+', "TCP: remote refused file, aborting",rn);
|
||||
return 2;
|
||||
} else if (strncmp(rxbuf,"ROK",3) == 0) {
|
||||
if (bufl > 3 && rxbuf[3]==' ') {
|
||||
offset = strtol(rxbuf+4,(char **)NULL,10);
|
||||
if (fseek(in,offset,SEEK_SET) != 0) {
|
||||
WriteError("$tcpsend cannot seek in file %s",ln);
|
||||
WriteError("$TCP: can't seek offset %ld in file %s", offset, ln);
|
||||
return 1;
|
||||
}
|
||||
} else
|
||||
@ -255,7 +260,7 @@ static int sendtfile(char *ln, char *rn)
|
||||
sentbytes += (unsigned long)st.st_size - offset;
|
||||
return 0;
|
||||
} else if(strncmp(rxbuf,"FERROR",6) == 0){
|
||||
WriteError("$tcpsend remote file error",ln);
|
||||
WriteError("TCP: remote file error",ln);
|
||||
return rc==0?1:rc;
|
||||
} else
|
||||
return rc==0?1:rc;
|
||||
@ -311,14 +316,14 @@ static int receivefile(char *fn, time_t ft, off_t fs)
|
||||
{
|
||||
int rc, bufl;
|
||||
|
||||
Syslog('+', "TCP receive \"%s\" (%lu bytes) dated %s",fn,fs,date(ft));
|
||||
Syslog('+', "TCP: receive \"%s\" (%lu bytes) dated %s",fn,fs,date(ft));
|
||||
strcpy(txbuf,"ROK");
|
||||
fout = openfile(fn, ft, fs, &rxbytes, resync);
|
||||
gettimeofday(&starttime, &tz);
|
||||
sbytes = rxbytes;
|
||||
|
||||
if (fs == rxbytes) {
|
||||
Syslog('+', "Skipping %s", fn);
|
||||
Syslog('+', "TCP: skipping %s", fn);
|
||||
fout = NULL;
|
||||
rc = tcp_sblk((char *)"RS",2,TCP_CMD);
|
||||
return rc;
|
||||
@ -369,10 +374,9 @@ static int tcp_sblk(char *buf, int len, int typ)
|
||||
PUT(buf, len);
|
||||
PUTCHAR(0x6c);
|
||||
FLUSHOUT();
|
||||
|
||||
if (tty_status)
|
||||
WriteError("TCP send error: %s", ttystat[tty_status]);
|
||||
else
|
||||
Syslog('A', "tcp_sblk: complete");
|
||||
WriteError("TCP: send error: %s", ttystat[tty_status]);
|
||||
return tty_status;
|
||||
}
|
||||
|
||||
@ -382,7 +386,6 @@ static int tcp_rblk(char *buf, int *len)
|
||||
{
|
||||
int c;
|
||||
|
||||
Syslog('A', "tcp_rblk: start");
|
||||
*len = 0;
|
||||
|
||||
/*
|
||||
@ -419,7 +422,11 @@ static int tcp_rblk(char *buf, int *len)
|
||||
if (tty_status)
|
||||
goto to;
|
||||
*len += c;
|
||||
Syslog('A', "tcp_rblk: expecting %d bytes", *len);
|
||||
|
||||
if (*len > 2048) {
|
||||
WriteError("TCP: remote sends too large block: %d bytes", len);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get actual data block
|
||||
@ -445,7 +452,7 @@ static int tcp_rblk(char *buf, int *len)
|
||||
|
||||
to:
|
||||
if (tty_status)
|
||||
WriteError("TCP receive error: %s", ttystat[tty_status]);
|
||||
WriteError("TCP: receive error: %s", ttystat[tty_status]);
|
||||
return tty_status;
|
||||
}
|
||||
|
||||
@ -462,12 +469,12 @@ static int getsync(void)
|
||||
|
||||
gs:
|
||||
if (tty_status) {
|
||||
WriteError("TCP getsync failed %s", ttystat[tty_status]);
|
||||
WriteError("TCP: getsync failed %s", ttystat[tty_status]);
|
||||
return 1;
|
||||
}
|
||||
while ((c = GETCHAR(180)) != 0xaa)
|
||||
while ((c = GETCHAR(120)) != 0xaa)
|
||||
if (tty_status) {
|
||||
WriteError("TCP getsync failed: %s", ttystat[tty_status]);
|
||||
WriteError("TCP: getsync failed: %s", ttystat[tty_status]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user