Lost of changes

This commit is contained in:
Michiel Broek
2004-01-25 10:57:35 +00:00
parent 1382701bd8
commit 5a0e317f23
41 changed files with 762 additions and 604 deletions

View File

@@ -306,7 +306,7 @@ SM_NAMES
SM_EDECL
faddr *primary;
char *p, *q, *pwd;
int i, rc = 0, bufl, cmd, dupe, SendPass = FALSE;
int i, rc = 0, bufl, cmd, dupe, SendPass = FALSE, akas = 0;
fa_list **tmp, *tmpa;
faddr *fa, ra;
@@ -409,22 +409,35 @@ SM_STATE(WaitAddr)
}
}
free(p);
for (tmpa = remote; tmpa; tmpa = tmpa->next) {
Syslog('+', "Address : %s", ascfnode(tmpa->addr, 0x1f));
if (nodelock(tmpa->addr, mypid)) {
binkp_send_command(MM_BSY, "Address %s locked", ascfnode(tmpa->addr, 0x1f));
SM_ERROR;
}
/*
* With the loaded flag we prevent removing the noderecord
* when the remote presents us an address we don't know about.
*/
if (!Loaded) {
if (noderecord(tmpa->addr))
Loaded = TRUE;
tmp = &remote;
while (*tmp) {
if (nodelock((*tmp)->addr, mypid)) {
Syslog('+', "address : %s is locked, removed from aka list",ascfnode((*tmp)->addr,0x1f));
tmpa=*tmp;
*tmp=(*tmp)->next;
free(tmpa);
} else {
/*
* With the loaded flag we prevent removing the noderecord
* when the remote presents us an address we don't know about.
*/
akas++;
Syslog('+', "address : %s",ascfnode((*tmp)->addr,0x1f));
if (!Loaded) {
if (noderecord((*tmp)->addr))
Loaded = TRUE;
}
tmp = &((*tmp)->next);
}
}
if (akas == 0) {
binkp_send_command(MM_BSY, "All aka's busy");
Syslog('+', "Binkp: abort, all aka's are busy");
SM_ERROR;
}
history.aka.zone = remote->addr->zone;
history.aka.net = remote->addr->net;
history.aka.node = remote->addr->node;
@@ -578,7 +591,7 @@ SM_NAMES
(char *)"Opts"
SM_EDECL
char *p, *q, *pw;
int i, rc, bufl, cmd, dupe, we_have_pwd = FALSE;
int i, rc, bufl, cmd, dupe, we_have_pwd = FALSE, akas = 0;
fa_list **tmp, *tmpa;
faddr *fa;
@@ -666,23 +679,35 @@ SM_STATE(WaitAddr)
SM_ERROR;
}
}
for (tmpa = remote; tmpa; tmpa = tmpa->next) {
Syslog('+', "Address : %s", ascfnode(tmpa->addr, 0x1f));
if (nodelock(tmpa->addr, mypid)) {
binkp_send_command(MM_BSY, "Address %s locked", ascfnode(tmpa->addr, 0x1f));
SM_ERROR;
}
/*
* With the loaded flag we prevent removing the noderecord
* when the remote presents us an address we don't know about.
*/
if (!Loaded) {
if (noderecord(tmpa->addr))
Loaded = TRUE;
tmp = &remote;
while (*tmp) {
if (nodelock((*tmp)->addr, mypid)) {
Syslog('+', "address : %s is locked, removed from aka list",ascfnode((*tmp)->addr,0x1f));
tmpa=*tmp;
*tmp=(*tmp)->next;
free(tmpa);
} else {
/*
* With the loaded flag we prevent removing the noderecord
* when the remote presents us an address we don't know about.
*/
akas++;
Syslog('+', "address : %s",ascfnode((*tmp)->addr,0x1f));
if (!Loaded) {
if (noderecord((*tmp)->addr))
Loaded = TRUE;
}
tmp = &((*tmp)->next);
}
}
if (akas == 0) {
binkp_send_command(MM_BSY, "All aka's busy");
Syslog('+', "Binkp: abort, all aka's are busy");
SM_ERROR;
}
for (tmpa = remote; tmpa; tmpa = tmpa->next) {
if (((nlent = getnlent(tmpa->addr))) && (nlent->pflag != NL_DUMMY)) {
Syslog('+', "Binkp: remote is a listed system");
@@ -874,7 +899,7 @@ int file_transfer(void)
* Nothing done, release
*/
Syslog('b', "Binkp: NOTHING DONE");
usleep(1);
msleep(1);
break;
case Receive: Trc = binkp_receiver();
@@ -1626,7 +1651,7 @@ int binkp_recv_command(char *buf, int *len, int *cmd)
if (b0 & 0x80)
*cmd = 1;
b1 = GETCHAR(1);
b1 = GETCHAR(BINKP_TIMEOUT / 2);
if (tty_status)
goto to;
@@ -1725,7 +1750,7 @@ int binkp_poll_frame(void)
if (c < 0) {
c = -c;
if (c == STAT_TIMEOUT) {
usleep(1);
msleep(1);
rc = 0;
break;
}

View File

@@ -4,7 +4,7 @@
* Purpose ...............: Fidonet mailer - modem chat
*
*****************************************************************************
* Copyright (C) 1997-2002
* Copyright (C) 1997-2004
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@@ -104,7 +104,7 @@ int send_str(char *str, char *Phone)
case 's': PUTCHAR(' '); *q++ = ' '; break;
case ' ': PUTCHAR(' '); *q++ = ' '; break;
case 'd': sleep(1); *q++ = '\\'; *q++ = 'd'; break;
case 'p': usleep(250000L); *q++ = '\\'; *q++ = 'p'; break;
case 'p': msleep(250); *q++ = '\\'; *q++ = 'p'; break;
case 'D': if (Phone) {
PUTSTR(Phone);
sprintf(q, "%s", Phone);

View File

@@ -4,7 +4,7 @@
* Purpose ...............: Fidonet mailer
*
*****************************************************************************
* Copyright (C) 1997-2003
* Copyright (C) 1997-2004
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@@ -70,7 +70,7 @@ int emsi_remote_opts;
char *emsi_local_password = NULL;
char *emsi_remote_password = NULL;
char emsi_remote_comm[4]="8N1";
int emsi_akas = 0;
int rx_emsi(char *data)
@@ -448,6 +448,10 @@ SM_STATE(checkdat)
Syslog('+', "Got EMSI_DAT packet \"%s\" with bad crc: %04x/%04x", printable(databuf, 0), lcrc, rcrc);
SM_PROCEED(sendnak);
} if (scanemsidat(databuf + 12) == 0) {
if (emsi_akas == 0) {
Syslog('+', "All akas busy, abort");
SM_ERROR;
}
SM_PROCEED(sendack);
} else {
Syslog('+', "Could not parse EMSI_DAT packet \"%s\"",databuf);

View File

@@ -47,6 +47,7 @@
extern int Loaded;
extern int mypid;
extern int emsi_akas;
@@ -334,7 +335,7 @@ exit:
int scanemsidat(char *buf)
{
fa_list **tmp,*tmpa;
fa_list **tmp, *tmpa;
faddr *fa;
char *p, *q, *mailer_prod, *mailer_name, *mailer_version, *mailer_serial;
int dupe;
@@ -375,24 +376,35 @@ int scanemsidat(char *buf)
}
}
for (tmpa = remote; tmpa; tmpa = tmpa->next) {
Syslog('+', "address : %s",ascfnode(tmpa->addr,0x1f));
(void)nodelock(tmpa->addr, mypid);
/*
* With the loaded flag we prevent removing the noderecord
* when the remote presents us an address we don't know about.
*/
if (!Loaded) {
if (noderecord(tmpa->addr))
Loaded = TRUE;
tmp = &remote;
while (*tmp) {
if (nodelock((*tmp)->addr, mypid)) {
Syslog('+', "address : %s is locked, removed from aka list",ascfnode((*tmp)->addr,0x1f));
tmpa=*tmp;
*tmp=(*tmp)->next;
free(tmpa);
} else {
/*
* With the loaded flag we prevent removing the noderecord
* when the remote presents us an address we don't know about.
*/
emsi_akas++;
Syslog('+', "address : %s",ascfnode((*tmp)->addr,0x1f));
if (!Loaded) {
if (noderecord((*tmp)->addr))
Loaded = TRUE;
}
tmp = &((*tmp)->next);
}
}
history.aka.zone = remote->addr->zone;
history.aka.net = remote->addr->net;
history.aka.node = remote->addr->node;
history.aka.point = remote->addr->point;
sprintf(history.aka.domain, "%s", remote->addr->domain);
if (emsi_akas) { /* Only if any aka's left */
history.aka.zone = remote->addr->zone;
history.aka.net = remote->addr->net;
history.aka.node = remote->addr->node;
history.aka.point = remote->addr->point;
sprintf(history.aka.domain, "%s", remote->addr->domain);
}
if (emsi_remote_password)
free(emsi_remote_password);

View File

@@ -4,7 +4,7 @@
* Purpose ...............: Fidonet mailer
*
*****************************************************************************
* Copyright (C) 1997-2003
* Copyright (C) 1997-2004
*
* Michiel Broek FIDO: 2:280/2802
* Beekmansbos 10
@@ -116,95 +116,89 @@ int tx_ftsc(void)
SM_DECL(txftsc,(char *)"txftsc")
SM_STATES
wait_command,
recv_mail,
send_req,
recv_req
wait_command,
recv_mail,
send_req,
recv_req
SM_NAMES
(char *)"wait_command",
(char *)"recv_mail",
(char *)"send_req",
(char *)"recv_req"
(char *)"wait_command",
(char *)"recv_mail",
(char *)"send_req",
(char *)"recv_req"
SM_EDECL
int c,rc;
char *nonhold_mail;
int mailsent = FALSE, mailrcvd = FALSE;
int c,rc, mailsent = FALSE, mailrcvd = FALSE;
char *nonhold_mail;
nonhold_mail = (char *)ALL_MAIL;
tosend = create_filelist(remote,nonhold_mail,2);
nonhold_mail = (char *)ALL_MAIL;
tosend = create_filelist(remote,nonhold_mail,2);
Syslog('s', "txftsc SEND_MAIL");
if ((rc = xmsndfiles(tosend)))
return rc;
mailsent = TRUE;
if ((rc = xmsndfiles(tosend)))
return rc;
mailsent = TRUE;
SM_START(wait_command)
SM_STATE(wait_command)
Syslog('s', "txftsc WAIT_COMMAND");
c = GETCHAR(30);
if (c == TIMEOUT) {
Syslog('+', "timeout waiting for remote action, try receive");
SM_PROCEED(recv_mail);
} else if (c < 0) {
if (mailrcvd && mailsent) {
/*
* Some systems hangup after sending mail, so if we did
* send and receive mail we consider the session OK.
*/
Syslog('+', "Lost carrier, FTS-0001 session looks complete");
SM_SUCCESS;
} else {
Syslog('+', "got error waiting for TSYNC: received %d",c);
SM_ERROR;
}
} else switch (c) {
case TSYNC: SM_PROCEED(recv_mail);
break;
case SYN: SM_PROCEED(recv_req);
break;
case ENQ: SM_PROCEED(send_req);
break;
case 'C':
case NAK: PUTCHAR(EOT);
SM_PROCEED(wait_command);
break;
case CAN: SM_SUCCESS; /* this is not in BT */
break;
default: Syslog('s', "got '%s' waiting command", printablec(c));
PUTCHAR(SUB);
SM_PROCEED(wait_command);
break;
c = GETCHAR(30);
if (c == TIMEOUT) {
Syslog('+', "timeout waiting for remote action, try receive");
SM_PROCEED(recv_mail);
} else if (c < 0) {
if (mailrcvd && mailsent) {
/*
* Some systems hangup after sending mail, so if we did
* send and receive mail we consider the session OK.
*/
Syslog('+', "Lost carrier, FTS-0001 session looks complete");
SM_SUCCESS;
} else {
Syslog('+', "got error waiting for TSYNC: received %d",c);
SM_ERROR;
}
} else switch (c) {
case TSYNC: SM_PROCEED(recv_mail);
break;
case SYN: SM_PROCEED(recv_req);
break;
case ENQ: SM_PROCEED(send_req);
break;
case 'C':
case NAK: PUTCHAR(EOT);
SM_PROCEED(wait_command);
break;
case CAN: SM_SUCCESS; /* this is not in BT */
break;
default: Syslog('s', "got '%s' waiting command", printablec(c));
PUTCHAR(SUB);
SM_PROCEED(wait_command);
break;
}
SM_STATE(recv_mail)
Syslog('s', "txftsc RECV_MAIL");
if (recvfiles()) {
SM_ERROR;
} else {
mailrcvd = TRUE;
SM_PROCEED(wait_command);
}
if (recvfiles()) {
SM_ERROR;
} else {
mailrcvd = TRUE;
SM_PROCEED(wait_command);
}
SM_STATE(send_req)
Syslog('s', "txftsc SEND_BARK");
if (sendbark()) {
SM_ERROR;
} else {
SM_SUCCESS;
}
if (sendbark()) {
SM_ERROR;
} else {
SM_SUCCESS;
}
SM_STATE(recv_req)
Syslog('s', "txftsc RECV_BARK");
if (recvbark()) {
SM_ERROR;
} else {
SM_PROCEED(wait_command);
}
if (recvbark()) {
SM_ERROR;
} else {
SM_PROCEED(wait_command);
}
SM_END
SM_RETURN
@@ -213,148 +207,145 @@ SM_RETURN
SM_DECL(rxftsc,(char *)"rxftsc")
SM_STATES
recv_mail,
send_mail,
send_req,
recv_req
recv_mail,
send_mail,
send_req,
recv_req
SM_NAMES
(char *)"recv_mail",
(char *)"send_mail",
(char *)"send_req",
(char *)"recv_req"
(char *)"recv_mail",
(char *)"send_mail",
(char *)"send_req",
(char *)"recv_req"
SM_EDECL
int c, count = 0, didwazoo = FALSE;
int sentmail = FALSE, rcvdmail = FALSE;
file_list *request = NULL, *tmpfl;
int c, count = 0, didwazoo = FALSE, sentmail = FALSE, rcvdmail = FALSE;
file_list *request = NULL, *tmpfl;
SM_START(recv_mail)
SM_STATE(recv_mail)
Syslog('s', "rxftsc RECV_MAIL");
if (recvfiles()) {
SM_ERROR;
} else {
rcvdmail = TRUE;
SM_PROCEED(send_mail);
}
if (recvfiles()) {
SM_ERROR;
} else {
rcvdmail = TRUE;
SM_PROCEED(send_mail);
}
SM_STATE(send_mail)
Syslog('s', "rxftsc SEND_MAIL count=%d", count);
if (count++ > 45) {
SM_ERROR;
}
Syslog('x', "rxftsc SEND_MAIL count=%d", count);
if (count++ > 45) {
SM_ERROR;
}
/*
* If we got a wazoo request, add files now.
*/
request = respond_wazoo();
if (request != NULL) {
didwazoo = TRUE;
tmpfl = tosend;
tosend = request;
for (; request->next; request = request->next);
request->next = tmpfl;
/*
* If we got a wazoo request, add files now.
*/
request = respond_wazoo();
if (request != NULL) {
didwazoo = TRUE;
tmpfl = tosend;
tosend = request;
for (; request->next; request = request->next);
request->next = tmpfl;
request = NULL;
}
request = NULL;
}
if (tosend == NULL) {
count = 0;
SM_PROCEED(send_req);
}
if (tosend == NULL) {
count = 0;
SM_PROCEED(send_req);
}
PUTCHAR(TSYNC);
c = GETCHAR(1);
Syslog('x', "Got char 0x%02x", c);
if (c == TIMEOUT) {
Syslog('x', " timeout");
SM_PROCEED(send_mail);
} else if (c < 0) {
Syslog('+', "got error waiting for NAK: received %d",c);
SM_ERROR;
} else switch (c) {
case 'C':
case NAK: if (xmsndfiles(tosend)) {
SM_ERROR;
} else {
sentmail = TRUE;
count = 0;
SM_PROCEED(send_req);
}
break;
case CAN: Syslog('+', "Remote refused to pickup mail");
SM_SUCCESS;
break;
case EOT: PUTCHAR(ACK);
SM_PROCEED(send_mail);
break;
default: Syslog('s', "Got '%s' waiting NAK", printablec(c));
SM_PROCEED(send_mail);
break;
}
PUTCHAR(TSYNC);
c = GETCHAR(1);
Syslog('x', "Got char 0x%02x", c);
if (c == TIMEOUT) {
Syslog('x', " timeout");
SM_PROCEED(send_mail);
} else if (c < 0) {
Syslog('+', "got error waiting for NAK: received %d",c);
SM_ERROR;
} else switch (c) {
case 'C':
case NAK: if (xmsndfiles(tosend)) {
SM_ERROR;
} else {
sentmail = TRUE;
count = 0;
SM_PROCEED(send_req);
}
break;
case CAN: Syslog('+', "Remote refused to pickup mail");
SM_SUCCESS;
break;
case EOT: PUTCHAR(ACK);
SM_PROCEED(send_mail);
break;
default: Syslog('s', "Got '%s' waiting NAK", printablec(c));
SM_PROCEED(send_mail);
break;
}
SM_STATE(send_req)
Syslog('s', "rxftsc SEND_REQ count=%d", count);
Syslog('x', "rxftsc SEND_REQ count=%d", count);
if (didwazoo) {
SM_SUCCESS;
}
if (didwazoo) {
SM_SUCCESS;
}
if (count > 15) {
SM_ERROR;
}
if (count > 15) {
SM_ERROR;
}
if (!made_request) {
SM_PROCEED(recv_req);
}
if (!made_request) {
SM_PROCEED(recv_req);
}
PUTCHAR(SYN);
c = GETCHAR(5);
Syslog('x', "Got char 0x%02x", c);
count++;
if (c == TIMEOUT) {
Syslog('x', " timeout");
SM_PROCEED(send_req);
} else if (c < 0) {
Syslog('+', "got error waiting for ENQ: received %d",c);
SM_ERROR;
} else switch (c) {
case ENQ: if (sendbark()) {
SM_ERROR;
} else {
SM_PROCEED(recv_req);
}
break;
case CAN: Syslog('+', "Remote refused to accept request");
SM_PROCEED(recv_req);
break;
case 'C':
case NAK: PUTCHAR(EOT);
SM_PROCEED(send_req);
break;
case SUB: SM_PROCEED(send_req);
break;
default: Syslog('s', "got '%s' waiting ENQ", printablec(c));
SM_PROCEED(send_req);
break;
}
PUTCHAR(SYN);
c = GETCHAR(5);
Syslog('x', "Got char 0x%02x", c);
count++;
if (c == TIMEOUT) {
Syslog('x', " timeout");
SM_PROCEED(send_req);
} else if (c < 0) {
Syslog('+', "got error waiting for ENQ: received %d",c);
SM_ERROR;
} else switch (c) {
case ENQ: if (sendbark()) {
SM_ERROR;
} else {
SM_PROCEED(recv_req);
}
break;
case CAN: Syslog('+', "Remote refused to accept request");
SM_PROCEED(recv_req);
break;
case 'C':
case NAK: PUTCHAR(EOT);
SM_PROCEED(send_req);
break;
case SUB: SM_PROCEED(send_req);
break;
default: Syslog('s', "got '%s' waiting ENQ", printablec(c));
SM_PROCEED(send_req);
break;
}
SM_STATE(recv_req)
Syslog('s', "rxftsc RECV_REQ");
if (recvbark()) {
if (sentmail && rcvdmail) {
Syslog('+', "Consider session OK");
SM_SUCCESS;
} else {
SM_ERROR;
}
if (recvbark()) {
if (sentmail && rcvdmail) {
Syslog('+', "Consider session OK");
SM_SUCCESS;
} else {
SM_SUCCESS;
SM_ERROR;
}
} else {
SM_SUCCESS;
}
SM_END
SM_RETURN
@@ -420,8 +411,18 @@ SM_STATE(scan_packet)
free(fpath);
SM_ERROR;
case 0:
case 5: Syslog('+', "accepting session");
fclose(fp);
case 5: fclose(fp);
if (nodelock(&f, mypid)) {
/*
* Lock failed, FTSC-0001 allowes only one aka, so abort session.
*/
Syslog('+', "address : %s is locked, abort", ascfnode(&f, 0x1f));
Syslog('s', "Unlink %s rc=%d", fpath, unlink(fpath));
free(fpath);
SM_ERROR;
}
Syslog('+', "accepting session");
for (tmpl = &remote; *tmpl; tmpl = &((*tmpl)->next));
(*tmpl)=(fa_list*)malloc(sizeof(fa_list));
(*tmpl)->next=NULL;
@@ -432,12 +433,15 @@ SM_STATE(scan_packet)
(*tmpl)->addr->point=f.point;
(*tmpl)->addr->name=NULL;
(*tmpl)->addr->domain=NULL;
for (tmpl=&remote;*tmpl;tmpl=&((*tmpl)->next)) {
(void)nodelock((*tmpl)->addr, mypid);
/* try lock all remotes, ignore locking result */
if (!Loaded)
if (noderecord((*tmpl)->addr))
Loaded = TRUE;
Syslog('+', "address : %s",ascfnode((*tmpl)->addr,0x1f));
/*
* With the loaded flag we prevent removing the noderecord
* when the remote presents us an address we don't know about.
*/
if (!Loaded) {
if (noderecord((*tmpl)->addr))
Loaded = TRUE;
}
history.aka.zone = remote->addr->zone;

View File

@@ -126,8 +126,8 @@ void die(int onsig)
}
if (sentbytes || rcvdbytes) {
total = (int)(c_end - c_start);
if (!total)
total = (int)(c_end - c_start -2);
if (total < 1)
total = 1;
Syslog('+', "Sent %lu bytes, received %lu bytes, avg %d cps", sentbytes, rcvdbytes, (sentbytes + rcvdbytes) / total);
}

View File

@@ -19,7 +19,7 @@ int proc(void)\
#define SM_START(x) \
sm_state=x;\
Syslog('S', "SM (%s): Start => %s", sm_name, sm_sname[sm_state]); \
Syslog('s', "SM (%s): Start => %s", sm_name, sm_sname[sm_state]); \
while (!sm_success) switch (sm_state)\
{\
default: WriteError("Statemachine %s error: state=%d",sm_name,sm_state);\
@@ -38,16 +38,16 @@ int proc(void)\
#define SM_PROCEED(x) \
if (x != sm_state) {\
Syslog('S', "SM (%s): %s => %s", sm_name, sm_sname[sm_state], sm_sname[x]);\
Syslog('s', "SM (%s): %s => %s", sm_name, sm_sname[sm_state], sm_sname[x]);\
}\
sm_state=x; break;
#define SM_SUCCESS \
Syslog('S', "SM (%s): %s => Success", sm_name, sm_sname[sm_state]);\
Syslog('s', "SM (%s): %s => Success", sm_name, sm_sname[sm_state]);\
sm_success=1; break;
#define SM_ERROR \
Syslog('S', "SM (%s): %s => Error", sm_name, sm_sname[sm_state]);\
Syslog('s', "SM (%s): %s => Error", sm_name, sm_sname[sm_state]);\
sm_success=-1; break;
#endif

View File

@@ -87,7 +87,9 @@ static int txyoohoo(void);
static void fillhello(unsigned short,char*);
static int checkhello(void);
static int iscaller;
static int y_akas;
static int iscaller;
static struct _hello {
unsigned char data[128];
unsigned char crc[2];
@@ -129,6 +131,7 @@ int rx_yoohoo(void)
char *pwd = NULL;
pwd = NULL;
y_akas = 0;
localcaps = LOCALCAPS;
if (localoptions & NOZMODEM) localcaps &= ~(ZED_ZAPPER|ZED_ZIPPER);
if (localoptions & NOZEDZAP) localcaps &= ~ZED_ZAPPER;
@@ -139,6 +142,12 @@ int rx_yoohoo(void)
if ((rc = rxyoohoo()) == 0) {
Loaded = checkhello();
if (y_akas == 0) {
Syslog('+', "All akas busy, abort");
return MBERR_SESSION_ERROR;
}
capabilities = hello2.capabilities;
if (capabilities & WZ_FREQ)
session_flags |= SESSION_WAZOO;
@@ -226,6 +235,7 @@ int tx_yoohoo(void)
unsigned short capabilities;
char *pwd;
y_akas = 0;
if (strlen(nodes.Spasswd))
pwd = xstrcpy(nodes.Spasswd);
else
@@ -256,6 +266,10 @@ int tx_yoohoo(void)
session_flags &= ~SESSION_WAZOO;
}
if (y_akas == 0) {
Syslog('+', "All akas busy, abort");
return MBERR_SESSION_ERROR;
}
if ((rc == 0) && ((capabilities & LOCALCAPS) == 0)) {
Syslog('+', "No common protocols");
return MBERR_SESSION_ERROR;
@@ -286,84 +300,78 @@ int tx_yoohoo(void)
SM_DECL(rxyoohoo,(char *)"rxyoohoo")
SM_STATES
sendenq,
waitchar,
getpacket,
sendnak,
sendack
sendenq,
waitchar,
getpacket,
sendnak,
sendack
SM_NAMES
(char *)"sendenq",
(char *)"waitchar",
(char *)"getpacket",
(char *)"sendnak",
(char *)"sendack"
(char *)"sendenq",
(char *)"waitchar",
(char *)"getpacket",
(char *)"sendnak",
(char *)"sendack"
SM_EDECL
int c;
int count=0;
unsigned short lcrc,rcrc;
int c, count=0;
unsigned short lcrc, rcrc;
SM_START(sendenq)
SM_STATE(sendenq)
Syslog('S', "rxyoohoo SENDENQ");
if (count++ > 12) {
Syslog('+', "Too many tries to get hello packet");
SM_ERROR;
}
PUTCHAR(ENQ);
SM_PROCEED(waitchar)
if (count++ > 12) {
Syslog('+', "Too many tries to get YooHoo hello packet");
SM_ERROR;
}
PUTCHAR(ENQ);
SM_PROCEED(waitchar)
SM_STATE(waitchar)
Syslog('S', "rxyoohoo WAITCHAR");
c=GETCHAR(10);
if (c == TIMEOUT) {
SM_PROCEED(sendenq);
} else if (c < 0) {
SM_ERROR;
} else switch (c) {
case 0x1f: SM_PROCEED(getpacket);
break;
case YOOHOO: SM_PROCEED(sendenq);
break;
default: SM_PROCEED(waitchar);
break;
}
c=GETCHAR(10);
if (c == TIMEOUT) {
SM_PROCEED(sendenq);
} else if (c < 0) {
SM_ERROR;
} else switch (c) {
case 0x1f: SM_PROCEED(getpacket);
break;
case YOOHOO: SM_PROCEED(sendenq);
break;
default: SM_PROCEED(waitchar);
break;
}
SM_STATE(getpacket)
Syslog('S', "rxyoohoo GETPACKET");
GET((char*)&hello, sizeof(hello), 30);
if (STATUS) {
SM_ERROR;
}
GET((char*)&hello, sizeof(hello), 30);
if (STATUS) {
SM_ERROR;
}
lcrc = crc16xmodem((char*)hello.data, sizeof(hello.data));
rcrc = (hello.crc[0] << 8) + hello.crc[1];
if (lcrc != rcrc) {
Syslog('+',"crc does not match in hello packet: %04xh/%04xh", rcrc,lcrc);
SM_PROCEED(sendnak);
} else {
SM_PROCEED(sendack);
}
lcrc = crc16xmodem((char*)hello.data, sizeof(hello.data));
rcrc = (hello.crc[0] << 8) + hello.crc[1];
if (lcrc != rcrc) {
Syslog('+',"crc does not match in YooHoo hello packet: %04xh/%04xh", rcrc,lcrc);
SM_PROCEED(sendnak);
} else {
SM_PROCEED(sendack);
}
SM_STATE(sendnak)
Syslog('S', "rxyoohoo SENDNAK");
if (count++ > 9) {
Syslog('+', "Too many tries to get hello packet");
SM_ERROR;
}
PUTCHAR('?');
SM_PROCEED(waitchar);
if (count++ > 9) {
Syslog('+', "Too many tries to get YooHoo hello packet");
SM_ERROR;
}
PUTCHAR('?');
SM_PROCEED(waitchar);
SM_STATE(sendack)
Syslog('S', "rxyoohoo SENDACK");
PUTCHAR(ACK);
SM_SUCCESS;
PUTCHAR(ACK);
SM_SUCCESS;
SM_END
SM_RETURN
@@ -372,268 +380,269 @@ SM_RETURN
SM_DECL(txyoohoo,(char *)"txyoohoo")
SM_STATES
sendyoohoo,
waitenq,
sendpkt,
waitchar
sendyoohoo,
waitenq,
sendpkt,
waitchar
SM_NAMES
(char *)"sendyoohoo",
(char *)"waitenq",
(char *)"sendpkt",
(char *)"waitchar"
(char *)"sendyoohoo",
(char *)"waitenq",
(char *)"sendpkt",
(char *)"waitchar"
SM_EDECL
int c;
int count=0;
int startstate;
unsigned short lcrc;
int c, count = 0, startstate;
unsigned short lcrc;
if (iscaller)
startstate = sendpkt;
else
startstate = sendyoohoo;
if (iscaller)
startstate = sendpkt;
else
startstate = sendyoohoo;
lcrc = crc16xmodem((char*)hello.data, sizeof(hello.data));
hello.crc[0] = lcrc >> 8;
hello.crc[1] = lcrc & 0xff;
Syslog('S', "txyoohoo INIT");
lcrc = crc16xmodem((char*)hello.data, sizeof(hello.data));
hello.crc[0] = lcrc >> 8;
hello.crc[1] = lcrc & 0xff;
SM_START(startstate)
SM_STATE(sendyoohoo)
Syslog('S', "txyoohoo SENDYOOHOO");
PUTCHAR(YOOHOO);
SM_PROCEED(waitenq);
PUTCHAR(YOOHOO);
SM_PROCEED(waitenq);
SM_STATE(waitenq)
Syslog('S', "txyoohoo WAITENQ");
c=GETCHAR(10);
if (c == TIMEOUT) {
if (count++ > 9) {
Syslog('+', "Timeout waiting ENQ");
SM_ERROR;
} else {
SM_PROCEED(sendyoohoo);
}
} else if (c < 0) {
SM_ERROR;
} else switch (c) {
case ENQ: SM_PROCEED(sendpkt);
case YOOHOO: SM_PROCEED(waitenq);
default: Syslog('+',"Got '%s' waiting hello ACK", printablec(c));
SM_PROCEED(waitchar);
break;
c=GETCHAR(10);
if (c == TIMEOUT) {
if (count++ > 9) {
Syslog('+', "Timeout waiting ENQ");
SM_ERROR;
} else {
SM_PROCEED(sendyoohoo);
}
} else if (c < 0) {
SM_ERROR;
} else switch (c) {
case ENQ: SM_PROCEED(sendpkt);
case YOOHOO: SM_PROCEED(waitenq);
default: Syslog('+',"Got '%s' waiting hello ACK", printablec(c));
SM_PROCEED(waitchar);
break;
}
SM_STATE(sendpkt)
Syslog('S', "txyoohoo SENDPKT");
if (count++ > 9) {
Syslog('+', "Too many tries to send hello packet");
SM_ERROR;
}
if (count++ > 9) {
Syslog('+', "Too many tries to send YooHoo hello packet");
SM_ERROR;
}
PUTCHAR(0x1f);
PUT((char*)&hello, sizeof(hello));
if (STATUS) {
SM_ERROR;
}
SM_PROCEED(waitchar);
PUTCHAR(0x1f);
PUT((char*)&hello, sizeof(hello));
if (STATUS) {
SM_ERROR;
}
SM_PROCEED(waitchar);
SM_STATE(waitchar)
Syslog('S', "txyoohoo WAITCHAR");
c=GETCHAR(30);
if (c == TIMEOUT) {
Syslog('+', "Timeout waiting hello ACK");
SM_ERROR;
} else if (c < 0) {
SM_ERROR;
} else switch (c) {
case ACK: Syslog('S', "Handshake successfull");
SM_SUCCESS;
break;
case '?': SM_PROCEED(sendpkt);
break;
case ENQ: SM_PROCEED(sendpkt);
break;
default: SM_PROCEED(waitchar);
break;
}
c=GETCHAR(30);
if (c == TIMEOUT) {
Syslog('+', "Timeout waiting hello ACK");
SM_ERROR;
} else if (c < 0) {
SM_ERROR;
} else switch (c) {
case ACK: SM_SUCCESS;
break;
case '?': SM_PROCEED(sendpkt);
break;
case ENQ: SM_PROCEED(sendpkt);
break;
default: SM_PROCEED(waitchar);
break;
}
SM_END
SM_RETURN
void fillhello(unsigned short capabilities, char *password)
{
faddr *best;
unsigned short majver, minver;
faddr *best;
unsigned short majver, minver;
Syslog('S',"fillhello(0x%04hx)",capabilities);
best = bestaka_s(remote->addr);
sscanf(VERSION,"%hd.%hd", &majver, &minver);
memset(&hello, 0, sizeof(hello));
best = bestaka_s(remote->addr);
hello.data[0] = 'o'; /* signal */
hello.data[2] = 1; /* hello-version */
hello.data[4] = (PRODCODE & 0x00ff); /* product code */
hello.data[5] = (PRODCODE & 0xff00) >> 8; /* product code */
hello.data[6] = (VERSION_MAJOR & 0x00ff); /* prod-ver-major */
hello.data[7] = (VERSION_MAJOR & 0xff00) >> 8; /* prod-ver-major */
hello.data[8] = (VERSION_MINOR & 0x00ff); /* prod-ver-minor */
hello.data[9] = (VERSION_MINOR & 0xff00) >> 8; /* prod-ver-minor */
strncpy((char*)hello.data+10, name?name:"Unavailable",59); /* name */
if (name) {
hello.data[10+strlen(name)] = '\0';
strncpy((char*)hello.data+11 + strlen(name),
best->domain, 58-strlen(name)); /* domain */
} else
strncpy((char*)hello.data + 22, best->domain, 47); /* domain */
strncpy((char*)hello.data+70, CFG.sysop_name,19); /* sysop */
hello.data[90] = best->zone&0xff; /* zone */
hello.data[91] = best->zone>>8; /* zone */
hello.data[92] = best->net&0xff; /* net */
hello.data[93] = best->net>>8; /* net */
hello.data[94] = best->node&0xff; /* node */
hello.data[95] = best->node>>8; /* node */
hello.data[96] = best->point&0xff; /* point */
hello.data[97] = best->point>>8; /* point */
sscanf(VERSION,"%hd.%hd", &majver, &minver);
memset(&hello, 0, sizeof(hello));
hello.data[0] = 'o'; /* signal */
hello.data[2] = 1; /* hello-version */
hello.data[4] = (PRODCODE & 0x00ff); /* product code */
hello.data[5] = (PRODCODE & 0xff00) >> 8; /* product code */
hello.data[6] = (VERSION_MAJOR & 0x00ff); /* prod-ver-major */
hello.data[7] = (VERSION_MAJOR & 0xff00) >> 8; /* prod-ver-major */
hello.data[8] = (VERSION_MINOR & 0x00ff); /* prod-ver-minor */
hello.data[9] = (VERSION_MINOR & 0xff00) >> 8; /* prod-ver-minor */
strncpy((char*)hello.data+10, name?name:"Unavailable",59); /* name */
if (name) {
hello.data[10+strlen(name)] = '\0';
strncpy((char*)hello.data+11 + strlen(name),
best->domain, 58-strlen(name)); /* domain */
} else
strncpy((char*)hello.data + 22, best->domain, 47); /* domain */
strncpy((char*)hello.data+70, CFG.sysop_name,19); /* sysop */
hello.data[90] = best->zone&0xff; /* zone */
hello.data[91] = best->zone>>8; /* zone */
hello.data[92] = best->net&0xff; /* net */
hello.data[93] = best->net>>8; /* net */
hello.data[94] = best->node&0xff; /* node */
hello.data[95] = best->node>>8; /* node */
hello.data[96] = best->point&0xff; /* point */
hello.data[97] = best->point>>8; /* point */
if (password)
strncpy((char*)hello.data + 98, password, 8);
if (password)
strncpy((char*)hello.data + 98, password, 8);
hello.data[114] = capabilities & 0xff; /* capabilities */
hello.data[115] = capabilities >> 8; /* capabilities */
tidy_faddr(best);
Syslog('S',"filled hello \"%s\"",printable((char*)hello.data,128));
hello.data[114] = capabilities & 0xff; /* capabilities */
hello.data[115] = capabilities >> 8; /* capabilities */
tidy_faddr(best);
}
int checkhello(void)
{
unsigned short i, majver = 0, minver = 0;
fa_list **tmpl,*tmpn;
faddr remaddr;
char *prodnm, *q;
int loaded = FALSE;
unsigned short i, majver = 0, minver = 0;
fa_list **tmpl, *tmpa;
faddr remaddr;
char *prodnm, *q;
int loaded = FALSE;
Syslog('S',"check hello \"%s\"",printable((char*)hello.data,128));
Syslog('s',"check hello \"%s\"",printable((char*)hello.data,128));
hello2 = gethello2(hello.data);
hello2 = gethello2(hello.data);
if ((hello2.signal != 0x6f) || (hello2.hello_version != 0x01)) {
Syslog('+', "Got \"%s\" instead of \"o\\000\\001\000\"", printable((char*)hello.data,3));
}
if ((hello2.signal != 0x6f) ||
(hello2.hello_version != 0x01)) {
Syslog('+', "Got \"%s\" instead of \"o\\000\\001\000\"", printable((char*)hello.data,3));
prodnm = xstrcpy((char *)"<unknown program>");
for (i = 0; ftscprod[i].name; i++) {
if (ftscprod[i].code == hello2.product) {
free(prodnm);
prodnm = xstrcpy(ftscprod[i].name);
majver = hello2.product_maj;
minver = hello2.product_min;
break;
}
}
prodnm = xstrcpy((char *)"<unknown program>");
for (i = 0; ftscprod[i].name; i++)
if (ftscprod[i].code == hello2.product) {
free(prodnm);
prodnm = xstrcpy(ftscprod[i].name);
majver = hello2.product_maj;
minver = hello2.product_min;
break;
}
remaddr.zone = hello2.my_zone;
remaddr.net = hello2.my_net;
remaddr.node = hello2.my_node;
remaddr.point = hello2.my_point;
remaddr.name = NULL;
remaddr.zone = hello2.my_zone;
remaddr.net = hello2.my_net;
remaddr.node = hello2.my_node;
remaddr.point = hello2.my_point;
remaddr.name = NULL;
remaddr.domain = NULL;
if (hello2.my_name[0])
remaddr.domain = hello2.my_name + (strlen(hello2.my_name)) + 1;
if (remaddr.domain[0]) {
if ((q = strchr(remaddr.domain, '.')))
*q = '\0';
} else {
remaddr.domain = NULL;
if (hello2.my_name[0])
remaddr.domain = hello2.my_name + (strlen(hello2.my_name)) + 1;
if (remaddr.domain[0]) {
if ((q = strchr(remaddr.domain, '.')))
*q = '\0';
}
if (remote)
Syslog('s',"Remote known address: %s",ascfnode(remote->addr,0x1f));
for (tmpl = &remote; *tmpl; tmpl = &((*tmpl)->next));
if ((remote == NULL) || (metric(remote->addr, &remaddr) != 0)) {
(*tmpl) = (fa_list*)malloc(sizeof(fa_list));
(*tmpl)->next = NULL;
(*tmpl)->addr = (faddr*)malloc(sizeof(faddr));
(*tmpl)->addr->zone = remaddr.zone;
(*tmpl)->addr->net = remaddr.net;
(*tmpl)->addr->node = remaddr.node;
(*tmpl)->addr->point = remaddr.point;
(*tmpl)->addr->domain = xstrcpy(remaddr.domain);
(*tmpl)->addr->name = NULL; /* Added 15-Dec-1998 */
} else {
tmpl=&remote;
Syslog('s',"Using single remote address");
}
tmpl = &remote;
while (*tmpl) {
if (nodelock((*tmpl)->addr, mypid)) {
Syslog('+', " address: %s is locked, removed from aka list",ascfnode((*tmpl)->addr,0x1f));
tmpa = *tmpl;
*tmpl = (*tmpl)->next;
tidy_faddr(tmpa->addr);
free(tmpa);
} else {
remaddr.domain = NULL;
Syslog('+', " address: %s",ascfnode((*tmpl)->addr,0x1f));
y_akas++;
/*
* With the loaded flag we prevent removing the noderecord
* when the remote presents us an address we don't know about.
*/
if (!Loaded) {
if (noderecord((*tmpl)->addr))
Loaded = TRUE;
}
tmpl = &((*tmpl)->next);
}
if (remote)
Syslog('S',"Remote known address: %s",ascfnode(remote->addr,0x1f));
}
for (tmpl = &remote; *tmpl; tmpl = &((*tmpl)->next));
if ((remote == NULL) || (metric(remote->addr, &remaddr) != 0)) {
(*tmpl) = (fa_list*)malloc(sizeof(fa_list));
(*tmpl)->next = NULL;
(*tmpl)->addr = (faddr*)malloc(sizeof(faddr));
(*tmpl)->addr->zone = remaddr.zone;
(*tmpl)->addr->net = remaddr.net;
(*tmpl)->addr->node = remaddr.node;
(*tmpl)->addr->point = remaddr.point;
(*tmpl)->addr->domain = xstrcpy(remaddr.domain);
(*tmpl)->addr->name = NULL; /* Added 15-Dec-1998 */
} else {
tmpl=&remote;
Syslog('S',"Using single remote address");
}
for (tmpn = remote; tmpn; tmpn = tmpn->next) {
(void)nodelock(tmpn->addr, mypid);
/*
* lock all remotes, ignore locking result
*/
if (!loaded)
if (noderecord(tmpn->addr))
loaded = TRUE;
}
Syslog('+', " address: %s",ascfnode(remote->addr,0x1f));
if (y_akas) { /* Only set if we have aka's left */
history.aka.zone = remote->addr->zone;
history.aka.net = remote->addr->net;
history.aka.node = remote->addr->node;
history.aka.point = remote->addr->point;
Syslog('S', "password: %s",(char*)hello2.my_password);
if (hello2.product < 0x0100)
Syslog('+', " uses: %s [%02X] version %d.%d", prodnm, hello2.product, majver, minver);
else
Syslog('+', " uses: %s [%04X] version %d.%d", prodnm, hello2.product, majver, minver);
Syslog('+', " system: %s",(char*)hello2.my_name);
strncpy(history.system_name, hello2.my_name, 35);
Syslog('+', " sysop: %s",(char*)hello2.sysop);
strncpy(history.sysop, hello2.sysop, 35);
sprintf(history.location, "Somewhere");
}
free(prodnm);
return loaded;
if (hello2.product < 0x0100)
Syslog('+', " uses: %s [%02X] version %d.%d", prodnm, hello2.product, majver, minver);
else
Syslog('+', " uses: %s [%04X] version %d.%d", prodnm, hello2.product, majver, minver);
Syslog('+', " system: %s",(char*)hello2.my_name);
strncpy(history.system_name, hello2.my_name, 35);
Syslog('+', " sysop: %s",(char*)hello2.sysop);
strncpy(history.sysop, hello2.sysop, 35);
sprintf(history.location, "Somewhere");
free(prodnm);
return loaded;
}
Hello gethello2(unsigned char Hellop[])
{
int i;
Hello p;
int i;
Hello p;
p.signal=Hellop[0]+(Hellop[1]<<8);
p.hello_version=Hellop[2]+(Hellop[3]<<8);
p.product=Hellop[4]+(Hellop[5]<<8);
p.product_maj=Hellop[6]+(Hellop[7]<<8);
p.product_min=Hellop[8]+(Hellop[9]<<8);
for (i=0;i<60;i++)
p.my_name[i]=Hellop[10+i];
for (i=0;i<20;i++)
p.sysop[i]=Hellop[70+i];
p.my_zone=Hellop[90]+(Hellop[91]<<8);
p.my_net=Hellop[92]+(Hellop[93]<<8);
p.my_node=Hellop[94]+(Hellop[95]<<8);
p.my_point=Hellop[96]+(Hellop[97]<<8);
for (i=0;i<8;i++)
p.my_password[i]=Hellop[98+i];
for (i=0;i<8;i++)
p.reserved2[i]=Hellop[106+i];
p.capabilities=Hellop[114]+(Hellop[115]<<8);
for (i=0;i<12;i++)
p.reserved3[i]=Hellop[116+i];
p.signal=Hellop[0]+(Hellop[1]<<8);
p.hello_version=Hellop[2]+(Hellop[3]<<8);
p.product=Hellop[4]+(Hellop[5]<<8);
p.product_maj=Hellop[6]+(Hellop[7]<<8);
p.product_min=Hellop[8]+(Hellop[9]<<8);
for (i=0;i<60;i++)
p.my_name[i]=Hellop[10+i];
for (i=0;i<20;i++)
p.sysop[i]=Hellop[70+i];
p.my_zone=Hellop[90]+(Hellop[91]<<8);
p.my_net=Hellop[92]+(Hellop[93]<<8);
p.my_node=Hellop[94]+(Hellop[95]<<8);
p.my_point=Hellop[96]+(Hellop[97]<<8);
for (i=0;i<8;i++)
p.my_password[i]=Hellop[98+i];
for (i=0;i<8;i++)
p.reserved2[i]=Hellop[106+i];
p.capabilities=Hellop[114]+(Hellop[115]<<8);
for (i=0;i<12;i++)
p.reserved3[i]=Hellop[116+i];
return p;
return p;
}