summaryrefslogtreecommitdiff
path: root/VARA.c
diff options
context:
space:
mode:
Diffstat (limited to 'VARA.c')
-rw-r--r--VARA.c43
1 files changed, 27 insertions, 16 deletions
diff --git a/VARA.c b/VARA.c
index d9fc67e..4d46984 100644
--- a/VARA.c
+++ b/VARA.c
@@ -1163,6 +1163,7 @@ void * VARAExtInit(EXTPORTDATA * PortEntry)
}
TNC->Port = port;
+ TNC->PortRecord = PortEntry;
TNC->ARDOPBuffer = malloc(8192);
TNC->ARDOPDataBuffer = malloc(8192);
@@ -1170,7 +1171,7 @@ void * VARAExtInit(EXTPORTDATA * PortEntry)
if (TNC->ProgramPath)
TNC->WeStartedTNC = 1;
- TNC->Hardware = H_VARA;
+ TNC->PortRecord->PORTCONTROL.HWType = TNC->Hardware = H_VARA;
if (TNC->BusyWait == 0)
TNC->BusyWait = 10;
@@ -1178,8 +1179,6 @@ void * VARAExtInit(EXTPORTDATA * PortEntry)
if (TNC->BusyHold == 0)
TNC->BusyHold = 1;
- TNC->PortRecord = PortEntry;
-
if (PortEntry->PORTCONTROL.PORTCALL[0] == 0)
memcpy(TNC->NodeCall, MYNODECALL, 10);
else
@@ -1446,9 +1445,6 @@ VOID VARAThread(void * portptr)
return;
}
-
-// printf("Starting VARA Thread\n");
-
// if on Windows and Localhost see if TNC is running
#ifdef WIN32
@@ -1564,14 +1560,11 @@ TNCRunning:
sinx.sin_addr.s_addr = INADDR_ANY;
sinx.sin_port = 0;
-// printf("Trying to connect to VARA TNC\n");
-
if (connect(TNC->TCPSock,(LPSOCKADDR) &TNC->destaddr,sizeof(TNC->destaddr)) == 0)
{
// Connected successful
goto VConnected;
-
}
if (TNC->Alerted == FALSE)
@@ -1727,6 +1720,7 @@ VConnected:
GetSemaphore(&Semaphore, 52);
VARAProcessReceivedControl(TNC);
FreeSemaphore(&Semaphore);
+ Debugprintf("VARA Returned from processing control packet");
}
if (FD_ISSET(TNC->TCPDataSock, &readfs))
@@ -2115,7 +2109,7 @@ VOID VARAProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
// Only allow VarAC mode for incomming sessions
ProcessIncommingConnectEx(TNC, Call, 0, (TNC->NetRomMode == 0), TRUE);
-
+
SESS = TNC->PortRecord->ATTACHEDSESSIONS[0];
if (Speed)
@@ -2230,6 +2224,7 @@ VOID VARAProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
if (App < 32)
{
char AppName[13];
+ char AppBuffer[64];
memcpy(AppName, &ApplPtr[App * sizeof(struct CMDX)], 12);
AppName[12] = 0;
@@ -2244,7 +2239,7 @@ VOID VARAProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
if (CheckAppl(TNC, AppName))
{
- MsgLen = sprintf(Buffer, "%s\r", AppName);
+ MsgLen = sprintf(AppBuffer, "%s\r", AppName);
buffptr = GetBuff();
@@ -2254,7 +2249,9 @@ VOID VARAProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
}
buffptr->Len = MsgLen;
- memcpy(buffptr->Data, Buffer, MsgLen);
+ memcpy(buffptr->Data, AppBuffer, MsgLen);
+
+ Debugprintf("Calling Application %s", AppBuffer);
C_Q_ADD(&TNC->WINMORtoBPQ_Q, buffptr);
@@ -2429,7 +2426,7 @@ VOID VARAProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
// return;
}
- if (_memicmp(Buffer, "REGISTERED", 9) == 0)
+ if (_memicmp(Buffer, "LINK REGISTERED", 9) == 0)
{
strcat(Buffer, "\r");
WritetoTrace(TNC, Buffer, (int)strlen(Buffer));
@@ -2443,6 +2440,13 @@ VOID VARAProcessResponse(struct TNCINFO * TNC, UCHAR * Buffer, int MsgLen)
return;
}
+ if (_memicmp(Buffer, "UNENCRYPTED LINK ", 11) == 0)
+ {
+ strcat(Buffer, "\r");
+ WritetoTrace(TNC, Buffer, (int)strlen(Buffer));
+ return;
+ }
+
if (_memicmp(Buffer, "MISSING SOUNDCARD", 17) == 0)
{
strcat(Buffer, "\r");
@@ -2668,7 +2672,7 @@ VOID VARAProcessReceivedControl(struct TNCINFO * TNC)
{
int InputLen, MsgLen;
char * ptr, * ptr2;
- char Buffer[4096];
+ char Buffer[8192];
// shouldn't get several messages per packet, as each should need an ack
// May get message split over packets
@@ -2676,7 +2680,7 @@ VOID VARAProcessReceivedControl(struct TNCINFO * TNC)
if (TNC->InputLen > 8000) // Shouldnt have packets longer than this
TNC->InputLen=0;
- InputLen=recv(TNC->TCPSock, &TNC->ARDOPBuffer[TNC->InputLen], 8192 - TNC->InputLen, 0);
+ InputLen=recv(TNC->TCPSock, &TNC->ARDOPBuffer[TNC->InputLen], 8191 - TNC->InputLen, 0);
if (InputLen == 0 || InputLen == SOCKET_ERROR)
{
@@ -2699,12 +2703,18 @@ VOID VARAProcessReceivedControl(struct TNCINFO * TNC)
TNC->InputLen += InputLen;
+ TNC->ARDOPBuffer[TNC->InputLen] = 0;
+ Debugprintf("VARA Processing buffer - %s", TNC->ARDOPBuffer);
+
loop:
ptr = memchr(TNC->ARDOPBuffer, '\r', TNC->InputLen);
if (ptr == 0) // CR in buffer
+ {
+ Debugprintf("VARA Part Packet Received - Waiting for rest");
return; // Wait for it
+ }
ptr2 = &TNC->ARDOPBuffer[TNC->InputLen];
@@ -2727,9 +2737,10 @@ loop:
if (TNC->InputLen < MsgLen)
{
TNC->InputLen = 0;
+ Debugprintf("VARA Corrupt multi command input");
return;
}
- memmove(TNC->ARDOPBuffer, ptr + 1, TNC->InputLen-MsgLen);
+ memmove(TNC->ARDOPBuffer, ptr + 1, TNC->InputLen - MsgLen);
TNC->InputLen -= MsgLen;
goto loop;