Changed all error return codes

This commit is contained in:
Michiel Broek
2002-10-20 20:58:55 +00:00
parent 1d819c9201
commit 02a1621f62
73 changed files with 2103 additions and 2022 deletions

View File

@@ -90,15 +90,15 @@ zmmisc.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/co
zmrle.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/clcomm.h ../lib/common.h ttyio.h session.h zmodem.h
zmrecv.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/clcomm.h ../lib/common.h lutil.h ttyio.h session.h zmodem.h config.h emsi.h openfile.h filelist.h openport.h
zmsend.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ttyio.h session.h zmodem.h lutil.h emsi.h filelist.h
binkp.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/dbnode.h ../lib/clcomm.h ttyio.h session.h statetbl.h config.h emsi.h openfile.h respfreq.h filelist.h opentcp.h rdoptions.h lutil.h binkp.h config.h
binkp.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/dbnode.h ../lib/clcomm.h ../lib/mberrors.h ttyio.h session.h statetbl.h config.h emsi.h openfile.h respfreq.h filelist.h opentcp.h rdoptions.h lutil.h binkp.h config.h
xmsend.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h session.h ttyio.h statetbl.h xmsend.h m7send.h filelist.h filetime.h
xmrecv.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h session.h ttyio.h statetbl.h config.h lutil.h openfile.h m7recv.h xmrecv.h filelist.h filetime.h
m7recv.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h statetbl.h ttyio.h m7recv.h
m7send.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h statetbl.h ttyio.h m7send.h
hydra.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h session.h filelist.h filetime.h ttyio.h statetbl.h config.h emsi.h openfile.h lutil.h respfreq.h mbcico.h hydra.h
answer.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h lutil.h session.h config.h answer.h openport.h portsel.h dial.h rdoptions.h mbcico.h
hydra.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ../lib/mberrors.h session.h filelist.h filetime.h ttyio.h statetbl.h config.h emsi.h openfile.h lutil.h respfreq.h mbcico.h hydra.h
answer.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h ../lib/mberrors.h lutil.h session.h config.h answer.h openport.h portsel.h dial.h rdoptions.h mbcico.h
chat.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h config.h chat.h ttyio.h
dial.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h config.h chat.h ttyio.h session.h dial.h
dial.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h ../lib/mberrors.h config.h chat.h ttyio.h session.h dial.h
dietifna.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ttyio.h session.h emsi.h dietifna.h respfreq.h filelist.h xmrecv.h xmsend.h
emsidat.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h emsi.h session.h lutil.h config.h emsidat.h filetime.h
filelist.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h config.h session.h filelist.h
@@ -106,27 +106,27 @@ openfile.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/
openport.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ulock.h ttyio.h openport.h
opentcp.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h session.h ttyio.h openport.h opentcp.h
rdoptions.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h session.h config.h
yoohoo.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/dbnode.h statetbl.h ttyio.h session.h config.h emsi.h hydra.h rdoptions.h wazoo.h dietifna.h yoohoo.h
yoohoo.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h ../lib/dbnode.h ../lib/mberrors.h statetbl.h ttyio.h session.h config.h emsi.h hydra.h rdoptions.h wazoo.h dietifna.h yoohoo.h
recvbark.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ttyio.h session.h statetbl.h recvbark.h respfreq.h filelist.h
respfreq.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h session.h lutil.h config.h atoul.h respfreq.h filelist.h
sendbark.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ttyio.h session.h statetbl.h sendbark.h xmrecv.h
tcp.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ttyio.h session.h statetbl.h config.h emsi.h respfreq.h filelist.h tcpproto.h tcp.h
tcpproto.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ttyio.h session.h config.h emsi.h lutil.h openfile.h filelist.h tcpproto.h
wazoo.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ttyio.h session.h statetbl.h config.h emsi.h respfreq.h filelist.h wazoo.h zmodem.h
tcpproto.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ../lib/mberrors.h ttyio.h session.h config.h emsi.h lutil.h openfile.h filelist.h tcpproto.h
wazoo.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h ../lib/mberrors.h ttyio.h session.h statetbl.h config.h emsi.h respfreq.h filelist.h wazoo.h zmodem.h
filetime.o: ../config.h ../lib/libs.h ../lib/memwatch.h filetime.h
ftsc.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h session.h ttyio.h statetbl.h config.h ftsc.h rdoptions.h recvbark.h filelist.h sendbark.h respfreq.h xmrecv.h xmsend.h
ftsc.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mberrors.h session.h ttyio.h statetbl.h config.h ftsc.h rdoptions.h recvbark.h filelist.h sendbark.h respfreq.h xmrecv.h xmsend.h
atoul.o: ../config.h ../lib/libs.h ../lib/memwatch.h atoul.h
portsel.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h portsel.h
ttyio.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ttyio.h lutil.h
lutil.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h lutil.h
scanout.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbftn.h config.h scanout.h lutil.h
emsi.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/dbnode.h ../lib/clcomm.h ttyio.h session.h statetbl.h config.h emsi.h emsidat.h hydra.h rdoptions.h tcp.h wazoo.h
emsi.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/dbnode.h ../lib/clcomm.h ../lib/mberrors.h ttyio.h session.h statetbl.h config.h emsi.h emsidat.h hydra.h rdoptions.h tcp.h wazoo.h
ulock.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/clcomm.h
callstat.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/clcomm.h ../lib/common.h callstat.h
session.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ttyio.h statetbl.h emsi.h ftsc.h session.h yoohoo.h mbcico.h binkp.h callstat.h
call.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h session.h callstat.h call.h config.h dial.h lutil.h portsel.h openport.h opentcp.h rdoptions.h
mbcico.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbftn.h config.h answer.h call.h lutil.h mbcico.h session.h
outstat.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbftn.h scanout.h callstat.h outstat.h
session.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/mberrors.h ttyio.h statetbl.h emsi.h ftsc.h session.h yoohoo.h mbcico.h binkp.h callstat.h
call.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbnode.h ../lib/mberrors.h session.h callstat.h call.h config.h dial.h lutil.h portsel.h openport.h opentcp.h rdoptions.h
mbcico.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbftn.h ../lib/mberrors.h config.h answer.h call.h lutil.h mbcico.h session.h
outstat.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbftn.h ../lib/mberrors.h scanout.h callstat.h outstat.h
nlinfo.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h nlinfo.h
mbout.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbftn.h outstat.h nlinfo.h
mbout.o: ../config.h ../lib/libs.h ../lib/memwatch.h ../lib/structs.h ../lib/users.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/dbcfg.h ../lib/dbnode.h ../lib/dbftn.h ../lib/mberrors.h outstat.h nlinfo.h
# End of generated dependencies

View File

@@ -37,6 +37,7 @@
#include "../lib/common.h"
#include "../lib/clcomm.h"
#include "../lib/dbnode.h"
#include "../lib/mberrors.h"
#include "lutil.h"
#include "session.h"
#include "config.h"
@@ -56,109 +57,110 @@ extern int Loaded;
int answer(char *stype)
{
int st, rc;
char *p, *q;
FILE *fp;
int st, rc;
char *p, *q;
FILE *fp;
/*
* mgetty set's the environment variable CONNECT and CALLER_ID,
* so if they are present, we might as well make log entries.
*/
if ((q = getenv("CONNECT")) != NULL)
Syslog('+', "CONNECT %s", q);
if ((q = getenv("CALLER_ID")) != NULL)
if (strncmp(q, "none", 4))
Syslog('+', "CALLER %s", q);
/*
* Incoming calls from modem/ISDN lines do have a tty.
* Network calls don't have a tty attached.
*/
carrier = TRUE;
p = ttyname(0);
if (p) {
q = strrchr(ttyname(0), '/');
if (q)
p = q + 1;
strncpy(history.tty, p, 6);
if (load_port(p))
Syslog('d', "Port %s, modem %s", ttyinfo.tty, modem.modem);
else
Syslog('d', "Port and modem not loaded!");
}
if ((nlent = getnlent(NULL)) == NULL) {
WriteError("could not get dummy nodelist entry");
return MBERR_NODE_NOT_IN_LIST;
}
c_start = time(NULL);
rdoptions(FALSE);
if (inbound)
free(inbound);
inbound = xstrcpy(CFG.inbound); /* slave session is unsecure by default */
if (stype == NULL) {
st=SESSION_UNKNOWN;
} else if (strcmp(stype,"tsync") == 0) {
st=SESSION_FTSC;
IsDoing("Answer ftsc");
} else if (strcmp(stype,"yoohoo") == 0) {
st=SESSION_YOOHOO;
IsDoing("Answer yoohoo");
} else if (strncmp(stype,"**EMSI_",7) == 0) {
st=SESSION_EMSI;
IsDoing("Answer EMSI");
} else if (strncmp(stype,"ibn",3) == 0) {
st=SESSION_BINKP;
IsDoing("Answer binkp");
} else {
st=SESSION_UNKNOWN;
IsDoing("Answer unknown");
}
if ((rc = rawport()) != 0)
WriteError("Unable to set raw mode");
else {
nolocalport();
rc = session(NULL,NULL,SESSION_SLAVE,st,stype);
}
cookedport();
if (p) {
/*
* mgetty set's the environment variable CONNECT and CALLER_ID,
* so if they are present, we might as well make log entries.
* Hangup will write the history record.
*/
if ((q = getenv("CONNECT")) != NULL)
Syslog('+', "CONNECT %s", q);
if ((q = getenv("CALLER_ID")) != NULL)
if (strncmp(q, "none", 4))
Syslog('+', "CALLER %s", q);
hangup();
} else {
/*
* Incoming calls from modem/ISDN lines do have a tty.
* Network calls don't have a tty attached.
* Network call, write history record.
*/
carrier = TRUE;
p = ttyname(0);
if (p) {
q = strrchr(ttyname(0), '/');
if (q)
p = q + 1;
strncpy(history.tty, p, 6);
if (load_port(p))
Syslog('d', "Port %s, modem %s", ttyinfo.tty, modem.modem);
else
Syslog('d', "Port and modem not loaded!");
}
c_end = time(NULL);
online += (c_end - c_start);
if ((nlent = getnlent(NULL)) == NULL) {
WriteError("could not get dummy nodelist entry");
return 1;
}
history.online = c_start;
history.offline = c_end;
history.sent_bytes = sentbytes;
history.rcvd_bytes = rcvdbytes;
history.inbound = TRUE;
c_start = time(NULL);
rdoptions(FALSE);
if (inbound)
free(inbound);
inbound = xstrcpy(CFG.inbound); /* slave session is unsecure by default */
if (stype == NULL) {
st=SESSION_UNKNOWN;
} else if (strcmp(stype,"tsync") == 0) {
st=SESSION_FTSC;
IsDoing("Answer ftsc");
} else if (strcmp(stype,"yoohoo") == 0) {
st=SESSION_YOOHOO;
IsDoing("Answer yoohoo");
} else if (strncmp(stype,"**EMSI_",7) == 0) {
st=SESSION_EMSI;
IsDoing("Answer EMSI");
} else if (strncmp(stype,"ibn",3) == 0) {
st=SESSION_BINKP;
IsDoing("Answer binkp");
} else {
st=SESSION_UNKNOWN;
IsDoing("Answer unknown");
}
if ((rc = rawport()) != 0)
WriteError("Unable to set raw mode");
p = calloc(PATH_MAX, sizeof(char));
sprintf(p, "%s/var/mailer.hist", getenv("MBSE_ROOT"));
if ((fp = fopen(p, "a")) == NULL)
WriteError("$Can't open %s", p);
else {
nolocalport();
rc=session(NULL,NULL,SESSION_SLAVE,st,stype);
fwrite(&history, sizeof(history), 1, fp);
fclose(fp);
}
cookedport();
if (p) {
/*
* Hangup will write the history record.
*/
hangup();
} else {
/*
* Network call, write history record.
*/
c_end = time(NULL);
online += (c_end - c_start);
history.online = c_start;
history.offline = c_end;
history.sent_bytes = sentbytes;
history.rcvd_bytes = rcvdbytes;
history.inbound = TRUE;
p = calloc(PATH_MAX, sizeof(char));
sprintf(p, "%s/var/mailer.hist", getenv("MBSE_ROOT"));
if ((fp = fopen(p, "a")) == NULL)
WriteError("$Can't open %s", p);
else {
fwrite(&history, sizeof(history), 1, fp);
fclose(fp);
}
free(p);
if (Loaded) {
nodes.LastDate = time(NULL);
UpdateNode();
}
free(p);
if (Loaded) {
nodes.LastDate = time(NULL);
UpdateNode();
}
return rc;
}
return rc;
}

View File

@@ -38,6 +38,7 @@
#include "../lib/common.h"
#include "../lib/dbnode.h"
#include "../lib/clcomm.h"
#include "../lib/mberrors.h"
#include "ttyio.h"
#include "session.h"
#include "statetbl.h"
@@ -95,96 +96,96 @@ int batchnr = 0, crc_errors = 0;
int binkp(int role)
{
int rc = 0;
fa_list *eff_remote;
file_list *tosend = NULL, *request = NULL, *respond = NULL, *tmpfl;
char *nonhold_mail;
int rc = MBERR_OK;
fa_list *eff_remote;
file_list *tosend = NULL, *request = NULL, *respond = NULL, *tmpfl;
char *nonhold_mail;
if (role == 1) {
Syslog('+', "BINKP start outbound session");
if (orgbinkp()) {
rc = 5;
}
} else {
Syslog('+', "BINKP start inbound session");
if (ansbinkp()) {
rc = 5;
}
if (role == 1) {
Syslog('+', "BINKP start outbound session");
if (orgbinkp()) {
rc = MBERR_FTRANSFER;
}
} else {
Syslog('+', "BINKP start inbound session");
if (ansbinkp()) {
rc = MBERR_FTRANSFER;
}
}
if (rc) {
Syslog('!', "BINKP session failed");
return rc;
}
nonhold_mail = (char *)ALL_MAIL;
eff_remote = remote;
/*
* If remote doesn't have the 8.3 flag set, allow long filenames.
*/
if (!nodes.FNC)
remote_flags &= ~SESSION_FNC;
tosend = create_filelist(eff_remote, nonhold_mail, 0);
request = create_freqlist(remote);
if (request != NULL) {
Syslog('b', "Inserting request list");
tmpfl = tosend;
tosend = request;
for (; request->next; request = request->next);
request->next = tmpfl;
request = NULL;
}
rc = binkp_batch(tosend, role);
tidy_filelist(tosend, (rc == 0));
tosend = NULL;
if ((rc == 0) && transferred && MBflag) {
/*
* Running Multiple Batch, only if last batch actually
* did transfer some data.
*/
respond = respond_wazoo();
/*
* Just create the tosend list again, there may be something
* ready again for this node.
*/
tosend = create_filelist(eff_remote, nonhold_mail, 0);
for (tmpfl = tosend; tmpfl->next; tmpfl = tmpfl->next);
tmpfl->next = respond;
rc = binkp_batch(tosend, role);
tmpfl->next = NULL;
}
Syslog('+', "BINKP end transfer rc=%d", rc);
closetcp();
if (!MBflag) {
/*
* In singe batch mode we process filerequests after the batch.
* The results will be put on hold for the calling node.
*/
respond = respond_wazoo();
for (tmpfl = respond; tmpfl; tmpfl = tmpfl->next) {
if (strncmp(tmpfl->local, "/tmp", 4)) {
attach(*remote->addr, tmpfl->local, LEAVE, 'h');
Syslog('+', "Put on hold: %s", MBSE_SS(tmpfl->local));
} else {
file_mv(tmpfl->local, pktname(remote->addr, 'h'));
Syslog('+', "New netmail: %s", pktname(remote->addr, 'h'));
}
}
}
tidy_filelist(request, (rc == 0));
tidy_filelist(tosend, (rc == 0));
tidy_filelist(respond, 0);
rc = abs(rc);
if (rc) {
Syslog('!', "BINKP session failed");
return rc;
}
nonhold_mail = (char *)ALL_MAIL;
eff_remote = remote;
/*
* If remote doesn't have the 8.3 flag set, allow long filenames.
*/
if (!nodes.FNC)
remote_flags &= ~SESSION_FNC;
tosend = create_filelist(eff_remote, nonhold_mail, 0);
request = create_freqlist(remote);
if (request != NULL) {
Syslog('b', "Inserting request list");
tmpfl = tosend;
tosend = request;
for (; request->next; request = request->next);
request->next = tmpfl;
request = NULL;
}
rc = binkp_batch(tosend, role);
tidy_filelist(tosend, (rc == 0));
tosend = NULL;
if ((rc == 0) && transferred && MBflag) {
/*
* Running Multiple Batch, only if last batch actually
* did transfer some data.
*/
respond = respond_wazoo();
/*
* Just create the tosend list again, there may be something
* ready again for this node.
*/
tosend = create_filelist(eff_remote, nonhold_mail, 0);
for (tmpfl = tosend; tmpfl->next; tmpfl = tmpfl->next);
tmpfl->next = respond;
rc = binkp_batch(tosend, role);
tmpfl->next = NULL;
}
Syslog('+', "BINKP end transfer rc=%d", rc);
closetcp();
if (!MBflag) {
/*
* In singe batch mode we process filerequests after the batch.
* The results will be put on hold for the calling node.
*/
respond = respond_wazoo();
for (tmpfl = respond; tmpfl; tmpfl = tmpfl->next) {
if (strncmp(tmpfl->local, "/tmp", 4)) {
attach(*remote->addr, tmpfl->local, LEAVE, 'h');
Syslog('+', "Put on hold: %s", MBSE_SS(tmpfl->local));
} else {
file_mv(tmpfl->local, pktname(remote->addr, 'h'));
Syslog('+', "New netmail: %s", pktname(remote->addr, 'h'));
}
}
}
tidy_filelist(request, (rc == 0));
tidy_filelist(tosend, (rc == 0));
tidy_filelist(respond, 0);
rc = abs(rc);
return rc;
}
@@ -854,7 +855,7 @@ int binkp_batch(file_list *to_send, int role)
RxState = RxDone;
TxState = TxDone;
binkp_send_control(MM_ERR, "Transfer timeout");
rc = -2;
rc = MBERR_FTRANSFER;
break;
}
@@ -876,7 +877,7 @@ int binkp_batch(file_list *to_send, int role)
Syslog('?', "Binkp: receiver status %s", ttystat[c]);
TxState = TxDone;
RxState = RxDone;
rc = -c;
rc = (MBERR_TTYIO + (-c));
break;
} else {
switch (rxlen) {
@@ -1056,13 +1057,13 @@ int binkp_batch(file_list *to_send, int role)
case MM_ERR: Syslog('+', "Binkp: got ERR: %s", rxbuf+1);
RxState = RxDone;
TxState = TxDone;
rc = -10;
rc = MBERR_FTRANSFER;
break;
case MM_BSY: Syslog('+', "Binkp: got BSY: %s", rxbuf+1);
RxState = RxDone;
TxState = TxDone;
rc = -11;
rc = MBERR_FTRANSFER;
break;
case MM_SKIP: Syslog('+', "Binkp: got SKIP: %s", rxbuf+1);
@@ -1151,7 +1152,7 @@ int binkp_batch(file_list *to_send, int role)
WriteError("File CRC error nr %d, aborting session", crc_errors);
binkp_send_control(MM_ERR, "Too much CRC errors, aborting session");
RxState = RxDone;
rc = -12;
rc = MBERR_FTRANSFER;
}
closefile(FALSE);
}
@@ -1205,7 +1206,7 @@ int binkp_batch(file_list *to_send, int role)
binkp_send_control(MM_BSY, "Low diskspace, try again later");
RxState = RxDone;
TxState = TxDone;
rc = -13;
rc = MBERR_FTRANSFER;
break;
}

View File

@@ -37,6 +37,7 @@
#include "../lib/common.h"
#include "../lib/clcomm.h"
#include "../lib/dbnode.h"
#include "../lib/mberrors.h"
#include "session.h"
#include "callstat.h"
#include "call.h"
@@ -68,10 +69,10 @@ int portopen(faddr *addr)
if ((rc = opentcp(inetaddr))) {
Syslog('+', "Cannot connect %s", inetaddr);
nodeulock(addr);
putstatus(addr,1,ST_NOCONN);
return ST_NOCONN;
putstatus(addr,1,MBERR_NO_CONNECTION);
return MBERR_NO_CONNECTION;
}
return 0;
return MBERR_OK;
}
if (forcedline) {
@@ -83,19 +84,19 @@ int portopen(faddr *addr)
if ((rc = openport(p, ttyinfo.portspeed))) {
Syslog('+', "Cannot open port %s",p);
nodeulock(addr);
putstatus(addr, 10, ST_PORTERR);
return ST_PORTERR;
putstatus(addr, 10, MBERR_PORTERROR);
return MBERR_PORTERROR;
}
return ST_PORTOK;
return MBERR_OK;
} else {
nodeulock(addr);
putstatus(addr, 0, ST_PORTERR);
return ST_PORTERR;
putstatus(addr, 0, MBERR_PORTERROR);
return MBERR_PORTERROR;
}
}
WriteError("No call method available, maybe missing parameters");
return ST_PORTERR;
return MBERR_NO_CONNECTION;
}
@@ -116,15 +117,15 @@ int call(faddr *addr)
*/
if (nodelock(addr)) {
Syslog('+', "System %s is locked", ascfnode(addr, 0x1f));
putstatus(addr, 0, ST_LOCKED);
return ST_LOCKED;
putstatus(addr, 0, MBERR_NODE_LOCKED);
return MBERR_NODE_LOCKED;
}
if ((nlent = getnlent(addr)) == NULL) {
WriteError("Cannot call %s: fatal in nodelist lookup", ascfnode(addr, 0x1f));
putstatus(addr,0,ST_LOOKUP);
putstatus(addr,0,MBERR_NODE_NOT_IN_LIST);
nodeulock(addr);
return ST_LOOKUP;
return MBERR_NODE_NOT_IN_LIST;
}
/*
@@ -215,7 +216,7 @@ int call(faddr *addr)
}
} else {
WriteError("No IP address, abort call");
rc = ST_NOCALL8;
rc = MBERR_NO_IP_ADDRESS;
putstatus(addr, 10, rc);
nodeulock(addr);
return rc;
@@ -244,15 +245,14 @@ int call(faddr *addr)
IsDoing("Call %s", ascfnode(addr, 0x0f));
rc = portopen(addr);
if ((rc == 0) && (!inetaddr)) {
if ((rc == MBERR_OK) && (!inetaddr)) {
if ((rc = dialphone(forcedphone?forcedphone:nlent->phone))) {
Syslog('+', "Dial failed");
nodeulock(addr);
rc+=1; /* rc=2 - dial fail, rc=3 - could not reset */
}
}
if (rc == 0) {
if (rc == MBERR_OK) {
if (!inetaddr)
nolocalport();
@@ -260,9 +260,6 @@ int call(faddr *addr)
rc = session(addr,nlent,SESSION_MASTER,SESSION_BINKP,NULL);
else
rc = session(addr,nlent,SESSION_MASTER,SESSION_UNKNOWN,NULL);
if (rc)
rc=abs(rc)+10;
}
IsDoing("Disconnect");
@@ -285,18 +282,15 @@ int call(faddr *addr)
} else {
IsDoing("NoCall");
Syslog('+', "Cannot call %s (%s, phone %s)", ascfnode(addr,0x1f),MBSE_SS(nlent->name), MBSE_SS(nlent->phone));
if ((nlent->phone || forcedphone || inetaddr ))
rc=ST_NOCALL8;
else
rc=ST_NOCALL7;
rc = MBERR_NO_CONNECTION;
putstatus(addr, 10, rc);
nodeulock(addr);
return rc;
}
if ((rc > 10) && (rc < 20)) /* Session error */
if ((rc == MBERR_NOT_ZMH) || (rc == MBERR_UNKNOWN_SESSION)) /* Session error */
putstatus(addr, 5, rc);
else if ((rc == 2) || (rc == 30))
else if ((rc == MBERR_NO_CONNECTION) || (rc == MBERR_SESSION_ERROR))
putstatus(addr,1,rc);
else
putstatus(addr,0,rc);

View File

@@ -72,6 +72,7 @@ void putstatus(faddr *addr, int incr, int sts)
} else {
cst->tryno += incr;
srand(getpid());
Syslog('d', "putstatus %s, incr=%d, tryno=%d, status=%d", ascfnode(addr, 0xf), incr, cst->tryno, sts);
while (TRUE) {
j = 1+(int) (1.0 * CFG.dialdelay * rand() / (RAND_MAX + 1.0));
if ((j > (CFG.dialdelay / 10)) && (j > 9))

View File

@@ -37,6 +37,7 @@
#include "../lib/common.h"
#include "../lib/clcomm.h"
#include "../lib/dbnode.h"
#include "../lib/mberrors.h"
#include "config.h"
#include "chat.h"
#include "ttyio.h"
@@ -62,9 +63,9 @@ int initmodem(void)
if (strlen(modem.init[i]))
if (chat(modem.init[i], CFG.timeoutreset, FALSE, NULL)) {
WriteError("dial: could not reset the modem");
return 1;
return MBERR_MODEM_ERROR;
}
return 0;
return MBERR_OK;
}
@@ -77,7 +78,7 @@ int dialphone(char *Phone)
carrier = FALSE;
if (initmodem())
return 2;
return MBERR_MODEM_ERROR;
rc = 0;
if (strlen(nodes.phone[0])) {
@@ -100,11 +101,11 @@ int dialphone(char *Phone)
if (rc) {
Syslog('+', "Could not connect to the remote");
return 1;
return MBERR_NO_CONNECTION;
} else {
c_start = time(NULL);
carrier = TRUE;
return 0;
return MBERR_OK;
}
}
@@ -147,7 +148,7 @@ int hangup()
}
FLUSHIN();
FLUSHOUT();
return 0;
return MBERR_OK;
}

View File

@@ -37,6 +37,7 @@
#include "../lib/common.h"
#include "../lib/dbnode.h"
#include "../lib/clcomm.h"
#include "../lib/mberrors.h"
#include "ttyio.h"
#include "session.h"
#include "statetbl.h"
@@ -105,7 +106,7 @@ int rx_emsi(char *data)
caller=0;
if ((rc=rxemsi()))
return rc;
return MBERR_EMSI;
Syslog('i', "local lcodes 0x%04x, protos 0x%04x, opts 0x%04x", emsi_local_lcodes,emsi_local_protos,emsi_local_opts);
Syslog('i', "remote lcodes 0x%04x, protos 0x%04x, opts 0x%04x", emsi_remote_lcodes,emsi_remote_protos,emsi_remote_opts);
@@ -179,7 +180,7 @@ int rx_emsi(char *data)
Syslog('i', "local lcodes 0x%04x, protos 0x%04x, opts 0x%04x", emsi_local_lcodes,emsi_local_protos,emsi_local_opts);
if ((rc=txemsi()))
return rc;
return MBERR_EMSI;
if (denypw || (emsi_local_protos == 0)) {
Syslog('+', "Refusing remote: %s", emsi_local_protos?"bad password presented": "no common protocols");
@@ -243,10 +244,10 @@ int tx_emsi(char *data)
Syslog('i', "local lcodes 0x%04x, protos 0x%04x, opts 0x%04x", emsi_local_lcodes,emsi_local_protos,emsi_local_opts);
if ((rc=txemsi()))
return rc;
return MBERR_EMSI;
else {
if ((rc=rxemsi()))
return rc;
return MBERR_EMSI;
}
if ((emsi_remote_opts & OPT_EII) == 0) {

View File

@@ -36,6 +36,7 @@
#include "../lib/records.h"
#include "../lib/common.h"
#include "../lib/clcomm.h"
#include "../lib/mberrors.h"
#include "session.h"
#include "ttyio.h"
#include "statetbl.h"
@@ -62,23 +63,26 @@ extern int Loaded;
int rx_ftsc(void)
{
int rc;
int rc;
Syslog('+', "Start inbound FTS-0001 session");
IsDoing("FTS-0001 inbound");
Syslog('+', "Start inbound FTS-0001 session");
IsDoing("FTS-0001 inbound");
session_flags |= SESSION_BARK;
if ((rc = rxftsc())) {
WriteError("Session failed: rc=%d",rc);
PUTCHAR(CAN);
PUTCHAR(CAN);
PUTCHAR(CAN);
} else
Syslog('+', "FTS-0001 session completed");
session_flags |= SESSION_BARK;
if ((rc = rxftsc())) {
WriteError("Session failed: rc=%d",rc);
PUTCHAR(CAN);
PUTCHAR(CAN);
PUTCHAR(CAN);
} else
Syslog('+', "FTS-0001 session completed");
tidy_filelist(tosend, (rc == 0));
tosend = NULL;
return rc;
tidy_filelist(tosend, (rc == 0));
tosend = NULL;
if (rc)
return MBERR_FTSC;
else
return 0;
}
@@ -86,22 +90,25 @@ int rx_ftsc(void)
int tx_ftsc(void)
{
int rc;
int rc;
Syslog('+', "Start outbound FTS-0001 session with %s", ascfnode(remote->addr,0x1f));
IsDoing("FTS-0001 to %s", ascfnode(remote->addr, 0x0f));
Syslog('+', "Start outbound FTS-0001 session with %s", ascfnode(remote->addr,0x1f));
IsDoing("FTS-0001 to %s", ascfnode(remote->addr, 0x0f));
if ((rc = txftsc())) {
WriteError("Session failed: rc=%d",rc);
PUTCHAR(CAN);
PUTCHAR(CAN);
PUTCHAR(CAN);
} else
Syslog('+', "FTS-0001 session completed");
if ((rc = txftsc())) {
WriteError("Session failed: rc=%d",rc);
PUTCHAR(CAN);
PUTCHAR(CAN);
PUTCHAR(CAN);
} else
Syslog('+', "FTS-0001 session completed");
tidy_filelist(tosend, (rc == 0));
tosend = NULL;
return rc;
tidy_filelist(tosend, (rc == 0));
tosend = NULL;
if (rc)
return MBERR_FTSC;
else
return 0;
}

View File

@@ -47,6 +47,7 @@
#include "../lib/structs.h"
#include "../lib/common.h"
#include "../lib/clcomm.h"
#include "../lib/mberrors.h"
#include "session.h"
#include "filelist.h"
#include "filetime.h"
@@ -278,7 +279,7 @@ enum HyPktTypes hyrxpkt(char *rxbuf, int *rxlen, int tot)
if ((i & ~0x0f) || (n & ~ 0x0f)) {
Syslog('+', "Hydra: RXPKT assert");
die(1);
die(MBERR_FTRANSFER);
break;
}
@@ -295,7 +296,7 @@ enum HyPktTypes hyrxpkt(char *rxbuf, int *rxlen, int tot)
case HCHR_UUEPKT:
default:
Syslog('+', "Hydra: RXPKT assert");
die(1);
die(MBERR_FTRANSFER);
}
if ((format != HCHR_HEXPKT) && (rxoptions & HOPT_CRC32)) {
@@ -449,7 +450,7 @@ void hytxpkt(enum HyPktTypes pkttype, char *txbuf, int txlen)
case HCHR_UUEPKT:
default:
Syslog('+', "Hydra: TXPKT assert");
die(1);
die(MBERR_FTRANSFER);
}
*outbuf++ = H_DLE;
@@ -1196,7 +1197,7 @@ int hydra_batch(int role, file_list *to_send)
break;
default:
die(1);
die(MBERR_FTRANSFER);
} /* switch (txstate) */
switch (rxstate) {
@@ -1586,10 +1587,10 @@ int hydra_batch(int role, file_list *to_send)
sleep(4); /* wait a few seconds... */
FLUSHIN();
return 2;
return MBERR_FTRANSFER;
}
return 0;
return MBERR_OK;
}

View File

@@ -39,6 +39,7 @@
#include "../lib/dbcfg.h"
#include "../lib/dbnode.h"
#include "../lib/dbftn.h"
#include "../lib/mberrors.h"
#include "config.h"
#include "answer.h"
#include "call.h"
@@ -182,7 +183,7 @@ int main(int argc, char *argv[])
#ifdef MEMWATCH
mwTerm();
#endif
exit(101);
exit(MBERR_COMMANDLINE);
}
InitConfig();
@@ -254,7 +255,7 @@ int main(int argc, char *argv[])
tcp_mode = TCPMODE_IBN;
else {
usage();
die(101);
die(MBERR_COMMANDLINE);
}
free(p);
RegTCP();
@@ -267,7 +268,7 @@ int main(int argc, char *argv[])
break;
default: usage();
die(101);
die(MBERR_COMMANDLINE);
}
/*
@@ -305,7 +306,7 @@ int main(int argc, char *argv[])
#ifdef MEMWATCH
mwTerm();
#endif
exit(100);
exit(MBERROR_EXEC_FAILED);
}
#endif
if ((strcasecmp(argv[optind],"tsync") == 0) ||
@@ -364,11 +365,11 @@ int main(int argc, char *argv[])
* Don't do outbound calls if low diskspace
*/
if (!diskfree(CFG.freespace))
die(101);
die(MBERR_DISK_FULL);
if (callist == NULL) {
WriteError("Calling mbcico without node address not supported anymore");
die(101);
die(MBERR_COMMANDLINE);
}
for (tmpl = &callist; *tmpl; tmpl = &((*tmpl)->next)) {
@@ -401,9 +402,9 @@ int main(int argc, char *argv[])
tidy_falist(&callist);
if (maxrc)
die(maxrc+100);
die(maxrc);
else
die(0);
die(MBERR_OK);
return 0;
}

View File

@@ -39,6 +39,7 @@
#include "../lib/dbcfg.h"
#include "../lib/dbnode.h"
#include "../lib/dbftn.h"
#include "../lib/mberrors.h"
#include "outstat.h"
#include "nlinfo.h"
@@ -147,21 +148,21 @@ void Help()
colour(3, 0);
printf(" -quiet Quiet mode\n");
colour(7, 0);
die(0);
die(MBERR_OK);
}
void Fatal(char *);
void Fatal(char *msg)
void Fatal(char *, int);
void Fatal(char *msg, int error)
{
show_log = TRUE;
if (!do_quiet) {
colour(12, 0);
printf("%s\n", msg);
}
WriteError(msg);
die(100);
show_log = TRUE;
if (!do_quiet) {
colour(12, 0);
printf("%s\n", msg);
}
WriteError(msg);
die(error);
}
@@ -243,12 +244,10 @@ int main(int argc, char *argv[])
}
if (strcmp(pw->pw_name, "mbse"))
Fatal((char *)"You are not user 'mbse'");
Fatal((char *)"You are not user 'mbse'", MBERR_COMMANDLINE);
if (do_stat) {
rc = outstat();
if (rc)
rc += 100;
die(rc);
}
@@ -257,19 +256,17 @@ int main(int argc, char *argv[])
*/
if (do_attach || do_node || do_poll || do_stop || do_req || do_reset) {
if (argc < 3)
Fatal((char *)"Not enough parameters");
Fatal((char *)"Not enough parameters", MBERR_COMMANDLINE);
}
if (do_attach || do_node || do_req || do_reset) {
if ((addr = parsefaddr(argv[2])) == NULL)
Fatal((char *)"Unrecognizable address");
Fatal((char *)"Unrecognizable address", MBERR_COMMANDLINE);
}
if (do_node) {
rc = nlinfo(addr);
tidy_faddr(addr);
if (rc)
rc += 100;
die(rc);
}
@@ -277,15 +274,13 @@ int main(int argc, char *argv[])
for (i = 3; i <= argc; i++) {
if (strncasecmp(argv[i-1], "-q", 2)) {
if ((addr = parsefaddr(argv[i-1])) == NULL)
Fatal((char *)"Unrecognizable address");
Fatal((char *)"Unrecognizable address", MBERR_COMMANDLINE);
j = poll(addr, do_stop);
tidy_faddr(addr);
if (j > rc)
if (j)
rc = j;
}
}
if (rc)
rc = 100;
die(rc);
}
@@ -293,50 +288,48 @@ int main(int argc, char *argv[])
for (i = 3; i <= argc; i++) {
if (strncasecmp(argv[i-1], "-q", 2)) {
if ((addr = parsefaddr(argv[i-1])) == NULL)
Fatal((char *)"Unrecognizable address");
Fatal((char *)"Unrecognizable address", MBERR_COMMANDLINE);
j = reset(addr);
tidy_faddr(addr);
if (j > rc)
if (j)
rc = j;
}
}
if (rc)
rc = 100;
die(rc);
}
if (do_attach) {
if (argc < 5)
Fatal((char *)"Not enough parameters");
Fatal((char *)"Not enough parameters", MBERR_COMMANDLINE);
flavor = tolower(argv[3][0]);
switch (flavor) {
case 'n' : flavor = 'f'; break;
case 'i' : flavor = 'i'; break;
case 'c' : flavor = 'c'; break;
case 'h' : flavor = 'h'; break;
default : Fatal((char *)"Invalid flavor, must be: immediate, crash, normal or hold");
default : Fatal((char *)"Invalid flavor, must be: immediate, crash, normal or hold", MBERR_COMMANDLINE);
}
nlent = getnlent(addr);
if (nlent->pflag == NL_DUMMY)
Fatal((char *)"Node is not in nodelist");
Fatal((char *)"Node is not in nodelist", MBERR_NODE_NOT_IN_LIST);
if (nlent->pflag == NL_DOWN)
Fatal((char *)"Node has status Down");
Fatal((char *)"Node has status Down", MBERR_NODE_MAY_NOT_CALL);
if (nlent->pflag == NL_HOLD)
Fatal((char *)"Node has status Hold");
Fatal((char *)"Node has status Hold", MBERR_NODE_MAY_NOT_CALL);
if (((nlent->oflags & OL_CM) == 0) && (flavor == 'c'))
Fatal((char *)"Node is not CM, must use Immediate, Normal or Hold flavor");
Fatal((char *)"Node is not CM, must use Immediate, Normal or Hold flavor", MBERR_NODE_MAY_NOT_CALL);
if (argv[4][0] == '-')
Fatal((char *)"Invalid filename given");
Fatal((char *)"Invalid filename given", MBERR_COMMANDLINE);
if (file_exist(argv[4], R_OK) != 0)
Fatal((char *)"File doesn't exist");
Fatal((char *)"File doesn't exist", MBERR_COMMANDLINE);
cmd = calloc(PATH_MAX, sizeof(char));
sprintf(cmd, "%s/%d.%d.%d.%d/.filelist", CFG.out_queue, addr->zone, addr->net, addr->node, addr->point);
mkdirs(cmd, 0750);
if ((fl = fopen(cmd, "a+")) == NULL) {
Fatal((char *)"File attach failed");
Fatal((char *)"File attach failed", MBERR_ATTACH_FAILED);
} else {
fprintf(fl, "%c LEAVE %s\n", flavor, argv[4]);
Syslog('+', "File attach %s is successfull", argv[4]);
@@ -347,14 +340,14 @@ int main(int argc, char *argv[])
fsync(fileno(fl));
fclose(fl);
free(cmd);
die(0);
die(MBERR_OK);
}
free(cmd);
}
if (do_req) {
if (argc < 4)
Fatal((char *)"Not enough parameters");
Fatal((char *)"Not enough parameters", MBERR_COMMANDLINE);
for (i = 4; i <= argc; i++) {
if (strncasecmp(argv[i-1], "-q", 2)) {
rc = freq(addr, argv[i-1]);
@@ -362,8 +355,6 @@ int main(int argc, char *argv[])
break;
}
}
if (rc)
rc += 100;
die(rc);
}
@@ -371,7 +362,7 @@ int main(int argc, char *argv[])
#ifdef MEMWATCH
mwTerm();
#endif
return 0;
return MBERR_OK;
}

View File

@@ -39,6 +39,7 @@
#include "../lib/dbcfg.h"
#include "../lib/dbnode.h"
#include "../lib/dbftn.h"
#include "../lib/mberrors.h"
#include "scanout.h"
#include "callstat.h"
#include "outstat.h"
@@ -82,7 +83,7 @@ int outstat()
if ((rc = scanout(each))) {
WriteError("Error scanning outbound, aborting");
return rc;
return MBERR_OUTBOUND_SCAN;
}
/*
@@ -93,7 +94,7 @@ int outstat()
if ((fp = fopen(temp, "r")) == NULL) {
WriteError("Error open %s, aborting", temp);
free(temp);
return 1;
return MBERR_OUTBOUND_SCAN;
}
fread(&nodeshdr, sizeof(nodeshdr), 1, fp);
fseek(fp, 0, SEEK_SET);
@@ -364,24 +365,24 @@ int poll(faddr *addr, int stop)
Syslog('+', "Node %s not in nodelist", ascfnode(addr, 0x1f));
if (!do_quiet)
printf("Node %s not in nodelist", ascfnode(addr, 0x1f));
return 1;
return MBERR_NODE_NOT_IN_LIST;
}
if (nlent->pflag == NL_DOWN) {
Syslog('+', "Node %s has status Down", ascfnode(addr, 0x1f));
if (!do_quiet)
printf("Node %s has status Down", ascfnode(addr, 0x1f));
return 1;
return MBERR_NODE_MAY_NOT_CALL;
}
if (nlent->pflag == NL_HOLD) {
Syslog('+', "Node %s has status Hold", ascfnode(addr, 0x1f));
if (!do_quiet)
printf("Node %s has status Hold", ascfnode(addr, 0x1f));
return 1;
return MBERR_NODE_MAY_NOT_CALL;
}
if ((fp = fopen(pol, "w+")) == NULL) {
WriteError("$Can't create poll for %s", ascfnode(addr, 0x1f));
rc = 1;
rc = MBERR_CANNOT_MAKE_POLL;
} else {
fclose(fp);
if (((nlent->oflags & OL_CM) == 0) && (!IsZMH())) {
@@ -394,12 +395,13 @@ int poll(faddr *addr, int stop)
printf("Created poll for %s\n", ascfnode(addr, 0x1f));
}
cst = getstatus(addr);
if ((cst->trystat == 5) ||
(cst->trystat == ST_NOTZMH) ||
(cst->trystat == ST_NOCONN) ||
(cst->trystat == ST_NOCALL7) ||
(cst->trystat == ST_NOCALL8) ||
(cst->trystat > 10)) {
if ((cst->trystat == MBERR_NODE_LOCKED) ||
(cst->trystat == MBERR_NOT_ZMH) ||
(cst->trystat == MBERR_NO_CONNECTION) ||
(cst->trystat == MBERR_SESSION_ERROR) ||
(cst->trystat == MBERR_UNKNOWN_SESSION) ||
(cst->trystat == MBERR_NO_PORT_AVAILABLE) ||
(cst->trystat == MBERR_MODEM_ERROR)) {
putstatus(addr, 0, 0);
}
CreateSema((char *)"scanout");
@@ -443,7 +445,7 @@ int freq(faddr *addr, char *fname)
if (!do_quiet)
printf("File request failed\n");
free(req);
return 1;
return MBERR_REQUEST;
}
fprintf(fp, "%s\r\n", fname);
fclose(fp);

View File

@@ -36,6 +36,7 @@
#include "../lib/records.h"
#include "../lib/common.h"
#include "../lib/clcomm.h"
#include "../lib/mberrors.h"
#include "ttyio.h"
#include "statetbl.h"
#include "emsi.h"
@@ -79,7 +80,7 @@ char *typestr(int tp)
int session(faddr *a, node *nl, int role, int tp, char *dt)
{
int rc = 1;
int rc = MBERR_OK;
fa_list *tmpl;
struct sockaddr_in peeraddr;
int addrlen = sizeof(struct sockaddr_in);
@@ -108,7 +109,7 @@ int session(faddr *a, node *nl, int role, int tp, char *dt)
IsDoing("Incoming IFC/TCP");
} else if (tcp_mode == TCPMODE_NONE) {
WriteError("Unknown TCP connection, parameter missing");
die(101);
die(MBERR_COMMANDLINE);
}
}
session_flags |= SESSION_TCP;
@@ -147,11 +148,11 @@ int session(faddr *a, node *nl, int role, int tp, char *dt)
if (type == SESSION_UNKNOWN)
(void)tx_define_type();
switch(type) {
case SESSION_UNKNOWN: rc=20; break;
case SESSION_FTSC: rc=tx_ftsc(); break;
case SESSION_YOOHOO: rc=tx_yoohoo(); break;
case SESSION_EMSI: rc=tx_emsi(data); break;
case SESSION_BINKP: rc=binkp(role); break;
case SESSION_UNKNOWN: rc = MBERR_UNKNOWN_SESSION; break;
case SESSION_FTSC: rc = tx_ftsc(); break;
case SESSION_YOOHOO: rc = tx_yoohoo(); break;
case SESSION_EMSI: rc = tx_emsi(data); break;
case SESSION_BINKP: rc = binkp(role); break;
}
} else {
if (type == SESSION_FTSC)
@@ -159,11 +160,11 @@ int session(faddr *a, node *nl, int role, int tp, char *dt)
if (type == SESSION_UNKNOWN)
(void)rx_define_type();
switch(type) {
case SESSION_UNKNOWN: rc=20; break;
case SESSION_FTSC: rc=rx_ftsc(); break;
case SESSION_YOOHOO: rc=rx_yoohoo(); break;
case SESSION_EMSI: rc=rx_emsi(data); break;
case SESSION_BINKP: rc=binkp(role); break;
case SESSION_UNKNOWN: rc = MBERR_UNKNOWN_SESSION; break;
case SESSION_FTSC: rc = rx_ftsc(); break;
case SESSION_YOOHOO: rc = rx_yoohoo(); break;
case SESSION_EMSI: rc = rx_emsi(data); break;
case SESSION_BINKP: rc = binkp(role); break;
}
}
sleep(2);

View File

@@ -38,6 +38,7 @@
#include "../lib/structs.h"
#include "../lib/common.h"
#include "../lib/clcomm.h"
#include "../lib/mberrors.h"
#include "ttyio.h"
#include "session.h"
#include "config.h"
@@ -84,7 +85,7 @@ int tcpsndfiles(file_list *lst)
if (getsync()) {
WriteError("Can't get synchronization");
return 1;
return MBERR_FTRANSFER;
}
for (tmpf = lst; tmpf && (maxrc == 0); tmpf = tmpf->next) {
@@ -108,9 +109,11 @@ int tcpsndfiles(file_list *lst)
if (rc > maxrc)
maxrc=rc;
if (rc)
WriteError("TCP send error: rc=%d",maxrc);
return maxrc;
if (rc) {
WriteError("TCP send error: rc=%d",maxrc);
return MBERR_FTRANSFER;
} else
return 0;
}
@@ -124,7 +127,7 @@ int tcprcvfiles(void)
Syslog('+', "Start TCP receive");
if (getsync()) {
WriteError("Can't get synchronization");
return 1;
return MBERR_FTRANSFER;
}
next:
if ((rc = tcp_rblk(rxbuf, &bufl)) == 0) {
@@ -155,9 +158,11 @@ next:
goto next;
}
if (rc)
WriteError("TCP receive error: rc=%d", rc);
return abs(rc);
if (rc) {
WriteError("TCP receive error: rc=%d", rc);
return MBERR_FTRANSFER;
} else
return 0;
}

View File

@@ -34,6 +34,7 @@
#include "../lib/structs.h"
#include "../lib/common.h"
#include "../lib/clcomm.h"
#include "../lib/mberrors.h"
#include "ttyio.h"
#include "session.h"
#include "statetbl.h"
@@ -50,80 +51,85 @@ extern int made_request;
int rxwazoo(void)
{
int rc = 0;
fa_list *eff_remote, tmpl;
file_list *tosend = NULL, **tmpfl;
int rc = 0;
fa_list *eff_remote, tmpl;
file_list *tosend = NULL, **tmpfl;
Syslog('+', "Start WaZOO session");
Syslog('+', "Start WaZOO session");
if (emsi_remote_lcodes & LCODE_NPU) {
Syslog('+', "Remote requested \"no pickup\", no send");
eff_remote=NULL;
} else if (emsi_remote_lcodes & LCODE_PUP) {
Syslog('+', "Remote requested \"pickup primary\"");
tmpl.addr = remote->addr;
tmpl.next = NULL;
eff_remote = &tmpl;
} else eff_remote=remote;
if (emsi_remote_lcodes & LCODE_NPU) {
Syslog('+', "Remote requested \"no pickup\", no send");
eff_remote=NULL;
} else if (emsi_remote_lcodes & LCODE_PUP) {
Syslog('+', "Remote requested \"pickup primary\"");
tmpl.addr = remote->addr;
tmpl.next = NULL;
eff_remote = &tmpl;
} else eff_remote=remote;
tosend = create_filelist(eff_remote,(char *)ALL_MAIL,0);
tosend = create_filelist(eff_remote,(char *)ALL_MAIL,0);
if ((rc = zmrcvfiles()) == 0) {
if ((emsi_local_opts & OPT_NRQ) == 0) {
for (tmpfl = &tosend; *tmpfl; tmpfl = &((*tmpfl)->next));
*tmpfl = respond_wazoo();
}
if ((tosend != NULL) || ((emsi_remote_lcodes & LCODE_NPU) == 0))
rc = zmsndfiles(tosend);
if ((rc == 0) && (made_request)) {
Syslog('+', "Freq was made, trying to receive files");
rc = zmrcvfiles();
}
if ((rc = zmrcvfiles()) == 0) {
if ((emsi_local_opts & OPT_NRQ) == 0) {
for (tmpfl = &tosend; *tmpfl; tmpfl = &((*tmpfl)->next));
*tmpfl = respond_wazoo();
}
tidy_filelist(tosend, (rc == 0));
if ((tosend != NULL) || ((emsi_remote_lcodes & LCODE_NPU) == 0))
rc = zmsndfiles(tosend);
if (rc)
WriteError("WaZOO session failed: rc=%d", rc);
else
Syslog('+', "WaZOO session completed");
return rc;
if ((rc == 0) && (made_request)) {
Syslog('+', "Freq was made, trying to receive files");
rc = zmrcvfiles();
}
}
tidy_filelist(tosend, (rc == 0));
if (rc) {
WriteError("WaZOO session failed: rc=%d", rc);
return MBERR_WAZOO;
}
Syslog('+', "WaZOO session completed");
return MBERR_OK;
}
int txwazoo(void)
{
int rc = 0;
file_list *tosend = NULL, *respond = NULL;
char *nonhold_mail;
int rc = 0;
file_list *tosend = NULL, *respond = NULL;
char *nonhold_mail;
Syslog('+', "Start WaZOO session");
// 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;
} else tosend = create_filelist(remote, nonhold_mail, 0);
Syslog('+', "Start WaZOO session");
// 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;
} else tosend = create_filelist(remote, nonhold_mail, 0);
if ((tosend != NULL) || ((emsi_remote_lcodes & LCODE_NPU) == 0))
rc = zmsndfiles(tosend);
if (rc == 0)
if ((rc = zmrcvfiles()) == 0)
if ((emsi_local_opts & OPT_NRQ) == 0)
if ((respond = respond_wazoo()))
rc = zmsndfiles(respond);
if ((tosend != NULL) || ((emsi_remote_lcodes & LCODE_NPU) == 0))
rc = zmsndfiles(tosend);
if (rc == 0)
if ((rc = zmrcvfiles()) == 0)
if ((emsi_local_opts & OPT_NRQ) == 0)
if ((respond = respond_wazoo()))
rc = zmsndfiles(respond);
tidy_filelist(tosend,(rc == 0));
tidy_filelist(respond,0);
if (rc)
WriteError("WaZOO session failed: rc=%d", rc);
else
Syslog('+', "WaZOO session completed");
return rc;
tidy_filelist(tosend,(rc == 0));
tidy_filelist(respond,0);
if (rc) {
WriteError("WaZOO session failed: rc=%d", rc);
return MBERR_WAZOO;
}
Syslog('+', "WaZOO session completed");
return MBERR_OK;
}

View File

@@ -45,6 +45,7 @@
#include "../lib/clcomm.h"
#include "../lib/common.h"
#include "../lib/dbnode.h"
#include "../lib/mberrors.h"
#include "statetbl.h"
#include "ttyio.h"
#include "session.h"
@@ -121,165 +122,166 @@ Hello gethello2(unsigned char[]);
int rx_yoohoo(void)
{
int rc;
unsigned short capabilities,localcaps;
char *pwd = NULL;
int rc;
unsigned short capabilities,localcaps;
char *pwd = NULL;
Syslog('+', "Start inbound YooHoo session");
Syslog('+', "Start inbound YooHoo session");
pwd = NULL;
localcaps = LOCALCAPS;
if (localoptions & NOZMODEM) localcaps &= ~(ZED_ZAPPER|ZED_ZIPPER);
if (localoptions & NOZEDZAP) localcaps &= ~ZED_ZAPPER;
if (localoptions & NOHYDRA) localcaps &= ~DOES_HYDRA;
emsi_local_opts = 0;
emsi_remote_opts = 0;
iscaller = 0;
pwd = NULL;
localcaps = LOCALCAPS;
if (localoptions & NOZMODEM) localcaps &= ~(ZED_ZAPPER|ZED_ZIPPER);
if (localoptions & NOZEDZAP) localcaps &= ~ZED_ZAPPER;
if (localoptions & NOHYDRA) localcaps &= ~DOES_HYDRA;
emsi_local_opts = 0;
emsi_remote_opts = 0;
iscaller = 0;
if ((rc = rxyoohoo()) == 0) {
Loaded = checkhello();
capabilities = hello2.capabilities;
if (capabilities & WZ_FREQ)
session_flags |= SESSION_WAZOO;
else
session_flags &= ~SESSION_WAZOO;
localcaps &= capabilities;
if (localcaps & DOES_HYDRA)
localcaps &= DOES_HYDRA;
else if (localcaps & ZED_ZAPPER)
localcaps &= ZED_ZAPPER;
else if (localcaps & ZED_ZIPPER)
localcaps &= ZED_ZIPPER;
else if (localcaps & FTB_USER)
localcaps &= FTB_USER;
else if (localcaps & Y_DIETIFNA)
localcaps &= Y_DIETIFNA;
if ((localoptions & NOFREQS) == 0)
localcaps |= WZ_FREQ;
else
emsi_local_opts |= OPT_NRQ;
if (((nlent=getnlent(remote->addr))) && (nlent->pflag != NL_DUMMY)) {
Syslog('+', "Remote is a listed system");
if (inbound)
free(inbound);
inbound = xstrcpy(CFG.inbound);
strncpy(history.location, nlent->location, 35);
}
if (nlent)
rdoptions(Loaded);
if (strlen(nodes.Spasswd)) {
if ((strncasecmp((char*)hello2.my_password, nodes.Spasswd, strlen(nodes.Spasswd)) == 0) &&
(strlen((char*)hello2.my_password) == strlen(nodes.Spasswd))) {
Syslog('+', "Password correct, protected mail session");
if (inbound)
free(inbound);
inbound = xstrcpy(CFG.pinbound);
pwd = xstrcpy(nodes.Spasswd);
} else {
pwd = (char *)"BAD_PASS";
Syslog('?', "Remote password \"%s\", expected \"%s\"", (char*)hello2.my_password, nodes.Spasswd);
localcaps = 0;
}
} else
Syslog('s', "No YooHoo password check");
fillhello(localcaps,pwd);
rc = txyoohoo();
if (pwd)
free(pwd);
}
if ((rc == 0) && ((localcaps & LOCALCAPS) == 0)) {
Syslog('+', "No common protocols or bad password");
return 0;
}
if (rc)
return rc;
IsDoing("Inbound %s", ascfnode(remote->addr, 0x0f));
session_flags |= SESSION_WAZOO;
if (localcaps & DOES_HYDRA)
return hydra(0);
else if ((localcaps & ZED_ZAPPER) || (localcaps & ZED_ZIPPER)) {
if (localcaps & ZED_ZAPPER)
emsi_local_protos = PROT_ZAP;
else
emsi_local_protos = PROT_ZMO;
return rxwazoo();
} else if (localcaps & Y_DIETIFNA)
return rxdietifna();
if ((rc = rxyoohoo()) == 0) {
Loaded = checkhello();
capabilities = hello2.capabilities;
if (capabilities & WZ_FREQ)
session_flags |= SESSION_WAZOO;
else
WriteError("YooHoo internal error - no proto for 0x%04xh",localcaps);
return 1;
session_flags &= ~SESSION_WAZOO;
localcaps &= capabilities;
if (localcaps & DOES_HYDRA)
localcaps &= DOES_HYDRA;
else if (localcaps & ZED_ZAPPER)
localcaps &= ZED_ZAPPER;
else if (localcaps & ZED_ZIPPER)
localcaps &= ZED_ZIPPER;
else if (localcaps & FTB_USER)
localcaps &= FTB_USER;
else if (localcaps & Y_DIETIFNA)
localcaps &= Y_DIETIFNA;
if ((localoptions & NOFREQS) == 0)
localcaps |= WZ_FREQ;
else
emsi_local_opts |= OPT_NRQ;
if (((nlent=getnlent(remote->addr))) && (nlent->pflag != NL_DUMMY)) {
Syslog('+', "Remote is a listed system");
if (inbound)
free(inbound);
inbound = xstrcpy(CFG.inbound);
strncpy(history.location, nlent->location, 35);
}
if (nlent)
rdoptions(Loaded);
if (strlen(nodes.Spasswd)) {
if ((strncasecmp((char*)hello2.my_password, nodes.Spasswd, strlen(nodes.Spasswd)) == 0) &&
(strlen((char*)hello2.my_password) == strlen(nodes.Spasswd))) {
Syslog('+', "Password correct, protected mail session");
if (inbound)
free(inbound);
inbound = xstrcpy(CFG.pinbound);
pwd = xstrcpy(nodes.Spasswd);
} else {
pwd = (char *)"BAD_PASS";
Syslog('?', "Remote password \"%s\", expected \"%s\"", (char*)hello2.my_password, nodes.Spasswd);
localcaps = 0;
}
} else
Syslog('s', "No YooHoo password check");
fillhello(localcaps,pwd);
rc = txyoohoo();
if (pwd)
free(pwd);
}
if ((rc == 0) && ((localcaps & LOCALCAPS) == 0)) {
Syslog('+', "No common protocols or bad password");
return 0;
}
if (rc)
return MBERR_YOOHOO;
IsDoing("Inbound %s", ascfnode(remote->addr, 0x0f));
session_flags |= SESSION_WAZOO;
if (localcaps & DOES_HYDRA)
return hydra(0);
else if ((localcaps & ZED_ZAPPER) || (localcaps & ZED_ZIPPER)) {
if (localcaps & ZED_ZAPPER)
emsi_local_protos = PROT_ZAP;
else
emsi_local_protos = PROT_ZMO;
return rxwazoo();
} else if (localcaps & Y_DIETIFNA)
return rxdietifna();
WriteError("YooHoo internal error - no proto for 0x%04xh",localcaps);
return MBERR_YOOHOO;
}
int tx_yoohoo(void)
{
int rc;
unsigned short capabilities;
char *pwd;
int rc;
unsigned short capabilities;
char *pwd;
Syslog('+', "Start outbound YooHoo session");
Syslog('+', "Start outbound YooHoo session");
if (strlen(nodes.Spasswd))
pwd = xstrcpy(nodes.Spasswd);
else
pwd = NULL;
if (strlen(nodes.Spasswd))
pwd = xstrcpy(nodes.Spasswd);
else
pwd = NULL;
capabilities = LOCALCAPS;
if (localoptions & NOZMODEM)
capabilities &= ~(ZED_ZAPPER|ZED_ZIPPER);
if (localoptions & NOZEDZAP)
capabilities &= ~ZED_ZAPPER;
if (localoptions & NOHYDRA)
capabilities &= ~DOES_HYDRA;
if ((localoptions & NOFREQS) == 0)
capabilities |= WZ_FREQ;
capabilities = LOCALCAPS;
if (localoptions & NOZMODEM)
capabilities &= ~(ZED_ZAPPER|ZED_ZIPPER);
if (localoptions & NOZEDZAP)
capabilities &= ~ZED_ZAPPER;
if (localoptions & NOHYDRA)
capabilities &= ~DOES_HYDRA;
if ((localoptions & NOFREQS) == 0)
capabilities |= WZ_FREQ;
else
emsi_local_opts |= OPT_NRQ;
fillhello(capabilities,pwd);
iscaller=1;
if ((rc = txyoohoo()) == 0) {
rc = rxyoohoo();
checkhello();
capabilities = hello2.capabilities;
if (capabilities & WZ_FREQ)
session_flags |= SESSION_WAZOO;
else
emsi_local_opts |= OPT_NRQ;
session_flags &= ~SESSION_WAZOO;
}
fillhello(capabilities,pwd);
iscaller=1;
if ((rc == 0) && ((capabilities & LOCALCAPS) == 0)) {
Syslog('+', "No common protocols");
return 0;
}
if ((rc = txyoohoo()) == 0) {
rc = rxyoohoo();
checkhello();
capabilities = hello2.capabilities;
if (capabilities & WZ_FREQ)
session_flags |= SESSION_WAZOO;
else
session_flags &= ~SESSION_WAZOO;
}
if (rc)
return MBERR_YOOHOO;
if ((rc == 0) && ((capabilities & LOCALCAPS) == 0)) {
Syslog('+', "No common protocols");
return 0;
}
IsDoing("Outbound %s", ascfnode(remote->addr, 0x0f));
if (rc)
return rc;
IsDoing("Outbound %s", ascfnode(remote->addr, 0x0f));
session_flags |= SESSION_WAZOO;
if (capabilities & DOES_HYDRA)
return hydra(1);
else if ((capabilities & ZED_ZAPPER) || (capabilities & ZED_ZIPPER)) {
if (capabilities & ZED_ZAPPER)
emsi_local_protos = PROT_ZAP;
else
emsi_local_protos = PROT_ZMO;
return txwazoo();
} else if (capabilities & Y_DIETIFNA)
return txdietifna();
session_flags |= SESSION_WAZOO;
if (capabilities & DOES_HYDRA)
return hydra(1);
else if ((capabilities & ZED_ZAPPER) || (capabilities & ZED_ZIPPER)) {
if (capabilities & ZED_ZAPPER)
emsi_local_protos = PROT_ZAP;
else
WriteError("YooHoo internal error - no proto for 0x%04xh",capabilities);
return 1;
emsi_local_protos = PROT_ZMO;
return txwazoo();
} else if (capabilities & Y_DIETIFNA)
return txdietifna();
WriteError("YooHoo internal error - no proto for 0x%04xh",capabilities);
return MBERR_YOOHOO;
}