typedef enum _eNWCState {
- eeGreating,
+ eGreating,
eAuth,
eNDOP,
eREAD,
eQUIT
}eNWCState;
+typedef enum _eNWCVState {
+ eNWCVSLookup,
+ eNWCVSConnecting,
+ eNWCVSConnFail,
+ eNWCVSGreating,
+ eNWCVSAuth,
+ eNWCVSAuthFailNTT,
+ eNWCVSAuthFail,
+ eNWCVSNDOP,
+ eNWCVSNDOPDone,
+ eNWCVSNUOP,
+ eNWCVSNUOPDone,
+ eNWCVSFail
+}eNWCVState;
+
+ConstStr NWCStateStr[] = {
+ {HKEY("Looking up Host")},
+ {HKEY("Connecting host")},
+ {HKEY("Failed to connect")},
+ {HKEY("Rread Greeting")},
+ {HKEY("Authenticating")},
+ {HKEY("Auth failed by NTT")},
+ {HKEY("Auth failed")},
+ {HKEY("Downloading")},
+ {HKEY("Downloading Success")},
+ {HKEY("Uploading Spoolfile")},
+ {HKEY("Uploading done")},
+ {HKEY("failed")}
+};
+
+void SetNWCState(AsyncIO *IO, eNWCVState State)
+{
+ CitContext* CCC = IO->CitContext;
+ memcpy(CCC->cs_clientname, NWCStateStr[State].Key, NWCStateStr[State].len + 1);
+}
typedef struct _async_networker {
AsyncIO IO;
{
char connected_to[SIZ];
AsyncIO *IO = &NW->IO;
+ SetNWCState(IO, eNWCVSGreating);
NWC_DBG_READ();
/* Read the server greeting */
/* Check that the remote is who we think it is and warn the Aide if not */
eNextState NWC_SendAuth(AsyncNetworker *NW)
{
AsyncIO *IO = &NW->IO;
+ SetNWCState(IO, eNWCVSAuth);
/* We're talking to the correct node. Now identify ourselves. */
StrBufPrintf(NW->IO.SendBuf.Buf, "NETP %s|%s\n",
config.c_nodename,
"Connected to node \"%s\" but my secret wasn't accurate.\nReason was:%s\n",
ChrPtr(NW->node), ChrPtr(NW->IO.IOBuf) + 4);
if (Error == 552) {
+ SetNWCState(IO, eNWCVSAuthFailNTT);
EVN_syslog(LOG_INFO,
"Already talking to %s; skipping this time.\n",
ChrPtr(NW->node));
}
else {
+ SetNWCState(IO, eNWCVSAuthFailNTT);
EVN_syslog(LOG_ERR, "%s\n", ChrPtr(NW->IO.ErrMsg));
StopClientWatchers(IO, 1);
return QueueDBOperation(IO, SendFailureMessage);
eNextState NWC_SendNDOP(AsyncNetworker *NW)
{
AsyncIO *IO = &NW->IO;
+ SetNWCState(IO, eNWCVSNDOP);
NW->tempFileName = NewStrBuf();
NW->SpoolFileName = NewStrBuf();
StrBufPrintf(NW->SpoolFileName,
S_IRUSR|S_IWUSR);
if (fd < 0)
{
+ SetNWCState(IO, eNWCVSFail);
EVN_syslog(LOG_CRIT,
"cannot open %s: %s\n",
ChrPtr(NW->tempFileName),
}
else
{
+ SetNWCState(IO, eNWCVSFail);
return eAbort;
}
}
FDIOBufferDelete(&NW->IO.IOB);
unlink(ChrPtr(NW->tempFileName));
FDIOBufferDelete(&IO->IOB);
+ SetNWCState(IO, eNWCVSFail);
return eAbort;
}
StrBufPrintf(NW->IO.SendBuf.Buf, "READ %ld|%ld\n",
eNextState NWC_SendCLOS(AsyncNetworker *NW)
{
AsyncIO *IO = &NW->IO;
+ SetNWCState(IO, eNWCVSNDOPDone);
StrBufPlain(NW->IO.SendBuf.Buf, HKEY("CLOS\n"));
NWC_DBG_SEND();
return eSendReply;
struct stat statbuf;
int fd;
+ SetNWCState(IO, eNWCVSNUOP);
StrBufPrintf(NW->SpoolFileName,
"%s/%s",
ctdl_netout_dir,
unlink(ChrPtr(NW->SpoolFileName));
}
FDIOBufferDelete(&IO->IOB);
+ SetNWCState(IO, eNWCVSNUOPDone);
return eSendReply;
}
eNextState NWC_FailNetworkConnection(AsyncIO *IO)
{
+ SetNWCState(IO, eNWCVSConnFail);
StopClientWatchers(IO, 1);
return QueueDBOperation(IO, SendFailureMessage);
}
{
AsyncNetworker *NW = IO->Data;
+ SetNWCState(&NW->IO, eNWCVSConnecting);
EVN_syslog(LOG_DEBUG, "%s\n", __FUNCTION__);
EVN_syslog(LOG_NOTICE, "Connecting to <%s> at %s:%s\n",
ChrPtr(NW->node),
sizeof(((CitContext *)NW->IO.CitContext)->cs_host));
if (NW->IO.ConnectMe->IsIP) {
+ SetNWCState(&NW->IO, eNWCVSLookup);
QueueEventContext(&NW->IO,
nwc_connect_ip);
}
else { /* uneducated admin has chosen to add DNS to the equation... */
+ SetNWCState(&NW->IO, eNWCVSConnecting);
QueueEventContext(&NW->IO,
nwc_get_one_host_ip);
}