summaryrefslogtreecommitdiff
path: root/L2Code.c
diff options
context:
space:
mode:
authorDave Hibberd <hibby@debian.org>2025-11-09 22:34:20 +0000
committerDave Hibberd <hibby@debian.org>2025-11-09 22:34:20 +0000
commit367ab8fb01191ec54c91810b1896c41fdf7de911 (patch)
tree8f9ac2b818ebb923b47fce00b28eb127556d96fb /L2Code.c
parent7c796758d1b65d4d7585c90ba71b1fb339a4d283 (diff)
New upstream version 6.0.25.9+repack
Diffstat (limited to 'L2Code.c')
-rw-r--r--L2Code.c330
1 files changed, 258 insertions, 72 deletions
diff --git a/L2Code.c b/L2Code.c
index 0fd8ecd..44015e1 100644
--- a/L2Code.c
+++ b/L2Code.c
@@ -64,7 +64,7 @@ VOID L2SENDRESPONSE(struct _LINKTABLE * LINK, int CMD);
VOID L2SENDCOMMAND(struct _LINKTABLE * LINK, int CMD);
VOID ACKMSG(struct _LINKTABLE * LINK);
VOID InformPartner(struct _LINKTABLE * LINK, int Reason);
-UINT RR_OR_RNR(struct _LINKTABLE * LINK);
+UINT RR_OR_RNR(struct _LINKTABLE * LINK, int CMD);
VOID L2TIMEOUT(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT);
VOID CLEAROUTLINK(struct _LINKTABLE * LINK);
VOID SENDFRMR(struct _LINKTABLE * LINK);
@@ -99,6 +99,7 @@ VOID L2SENDXID(struct _LINKTABLE * LINK);
VOID __cdecl Debugprintf(const char * format, ...);
VOID Q_IP_MSG(MESSAGE * Buffer);
VOID PROCESSNODEMESSAGE(MESSAGE * Msg, struct PORTCONTROL * PORT);
+VOID PROCESSNODESPOLL(struct PORTCONTROL * PORT);
VOID L2LINKACTIVE(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE * Buffer, MESSAGE * ADJBUFFER, UCHAR CTL, UCHAR MSGFLAG);
BOOL CompareAliases(UCHAR * c1, UCHAR * c2);
VOID L2FORUS(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE * Buffer, MESSAGE * ADJBUFFER, UCHAR CTL, UCHAR MSGFLAG);
@@ -120,11 +121,18 @@ int CheckKissInterlock(struct PORTCONTROL * MYPORT, int Exclusive);
void hookL2SessionAccepted(int Port, char * fromCall, char * toCall, struct _LINKTABLE * LINK);
void hookL2SessionDeleted(struct _LINKTABLE * LINK);
void hookL2SessionAttempt(int Port, char * fromCall, char * toCall, struct _LINKTABLE * LINK);
+void hookL2SessionConnected(struct _LINKTABLE * LINK);
int L2Compressit(unsigned char * Out, int OutSize, unsigned char * In, int Len);
VOID DeleteINP3Routes(struct ROUTE * Route);
+VOID SendRTTMsg(struct ROUTE * Route);
+void hookL2SessionStatus(struct _LINKTABLE * LINK);
+void hookL2SessionClosed(struct _LINKTABLE * LINK, char * Reason, char * Direction);
+int NETROMOpenConnection(struct ROUTE * Route);
extern int REALTIMETICKS;
+int linkStatusInterval = 300; // 5 mins
+
// MSGFLAG contains CMD/RESPONSE BITS
#define CMDBIT 4 // CURRENT MESSAGE IS A COMMAND
@@ -139,6 +147,7 @@ extern int REALTIMETICKS;
extern int L2Compress;
extern int L2CompMaxframe;
extern int L2CompPaclen;
+extern BOOL CLOSING;
UCHAR NO_CTEXT = 0;
UCHAR ALIASMSG = 0;
@@ -445,6 +454,8 @@ TRYBBS:
if ((PORT->PERMITTEDAPPLS & APPLMASK) != 0)
{
ALIASMSG = 0;
+
+ strcpy(LINK->ApplName, APPL->APPLCMD);
if (CompareCalls(Buffer->DEST, APPL->APPLCALL))
goto FORUS;
@@ -479,9 +490,9 @@ NOWTRY_NODES:
if (CompareCalls(Buffer->DEST, NODECALL))
{
if (Buffer->L2DATA[0] == 0xff) // Valid NODES Broadcast
- {
PROCESSNODEMESSAGE(Buffer, PORT);
- }
+ else if (Buffer->L2DATA[0] == 0xfe) // Paula's NODES Poll (request Nodes broadcast on port)
+ PROCESSNODESPOLL(PORT);
}
ReleaseBuffer(Buffer);
@@ -808,7 +819,15 @@ VOID L2FORUS(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE * Buff
if (CTLlessPF == XID)
{
- ProcessXIDCommand(LINK, PORT, Buffer, ADJBUFFER, CTL, MSGFLAG);
+ // We could possibly get an XID response if packet is badly delayed and we had timed out
+
+ if ((MSGFLAG & CMDBIT)) // Command
+ ProcessXIDCommand(LINK, PORT, Buffer, ADJBUFFER, CTL, MSGFLAG);
+ else
+ {
+ Debugprintf("Unexpected XID response with no session");
+ ReleaseBuffer(Buffer); // Ignore if not
+ }
return;
}
@@ -929,6 +948,7 @@ VOID ProcessXIDCommand(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESS
LINK->L2STATE = 1; // XID received
LINK->Ver2point2 = TRUE; // Must support 2.2 if sent XID
LINK->L2TIME = PORT->PORTT1;
+ LINK->LINKWINDOW = PORT->PORTWINDOW; // Just in case!
LINK->LINKPORT = PORT;
@@ -1067,6 +1087,7 @@ VOID L2LINKACTIVE(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE *
if (CTLlessPF == DISC)
{
InformPartner(LINK, NORMALCLOSE); // SEND DISC TO OTHER END
+ hookL2SessionClosed(LINK, "Normal", "In");
CLEAROUTLINK(LINK);
L2SENDUA(PORT, Buffer, ADJBUFFER);
@@ -1076,87 +1097,128 @@ VOID L2LINKACTIVE(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE *
return;
}
-
- if (LINK->L2STATE == 1)
+ if (CTLlessPF == XID)
{
- // XID State. Should be XID response if 2.2 ok or DM/FRMR if not
+ // XID command or response on active session.
+
+ // if Command and state = 2 then other end missed XID Response. Process command again
- if (MSGFLAG & RESP)
+ if ((MSGFLAG & CMDBIT))
{
- if (CTLlessPF == DM || CTLlessPF == FRMR)
+ if (LINK->L2STATE == 2)
{
- // Doesn't support XID - Send SABM
+ // I think we can just process as normal.
- LINK->L2STATE = 2;
- LINK->Ver2point2 = FALSE;
- LINK->L2TIMER = 1; // Use retry to send SABM
+ ProcessXIDCommand(LINK, PORT, Buffer, ADJBUFFER, CTL, MSGFLAG);
+ return;
}
- else if (CTLlessPF == XID)
+
+ if (LINK->L2STATE == 1) // We've just sent XID so is probably XID Collision
{
- // Process response to make sure ok, Send SABM or DISC
+ // I think we can just process as normal. If we don't send a response the other end may not switch to 2.2
+
+ ProcessXIDCommand(LINK, PORT, Buffer, ADJBUFFER, CTL, MSGFLAG);
+ return;
+ }
- LINK->L2STATE = 2;
- LINK->Ver2point2 = TRUE;// Must support 2.2 if responded to XID
+ // XID Command on active session. Other end may be restarting. Reset session
- // if Compress enabled set it
+ InformPartner(LINK, NORMALCLOSE); // SEND DISC TO OTHER END
+ LINK->CIRCUITPOINTER = 0;
- ptr = &ADJBUFFER->PID;
+ // I think it is safer to ignore it. The retry will be processed normally as XID command with no session
- if (*ptr++ == 0x82 && *ptr++ == 0x80)
- {
- int Type;
- int Len;
- unsigned int value;
- int xidlen = *(ptr++) << 8;
- xidlen += *ptr++;
+ ReleaseBuffer(Buffer);
+ return;
+ }
- // XID is set of Type, Len, Value n-tuples
+ // XID Response
- while (xidlen > 0)
- {
- Type = *ptr++;
- Len = *ptr++;
+ // if Link State = 1 this is a normal response. Check it then send SABM
- value = 0;
- xidlen -= (Len + 2);
+ if (LINK->L2STATE == 1)
+ {
+ LINK->L2STATE = 2;
+ LINK->Ver2point2 = TRUE;// Must support 2.2 if responded to XID
- while (Len--)
- {
- value <<=8;
- value += *ptr++;
- }
- switch(Type)
- {
- case 17:
+ // if Compress enabled set it
+
+ ptr = &ADJBUFFER->PID;
- // Compression
+ if (*ptr++ == 0x82 && *ptr++ == 0x80)
+ {
+ int Type;
+ int Len;
+ unsigned int value;
+ int xidlen = *(ptr++) << 8;
+ xidlen += *ptr++;
- if (L2Compress)
- LINK->AllowCompress = 1;
+ // XID is set of Type, Len, Value n-tuples
- }
+ while (xidlen > 0)
+ {
+ Type = *ptr++;
+ Len = *ptr++;
+
+ value = 0;
+ xidlen -= (Len + 2);
+
+ while (Len--)
+ {
+ value <<=8;
+ value += *ptr++;
}
+ switch(Type)
+ {
+ case 17:
+
+ // Compression
+
+ if (L2Compress)
+ LINK->AllowCompress = 1;
+ }
}
- LINK->L2TIMER = 1; // Use retry to send SABM
}
+ LINK->LINKWINDOW = PORT->PORTWINDOW; // Just in case!
+ LINK->L2TIMER = 1; // Use retry to send SABM
+
ReleaseBuffer(Buffer);
return;
}
-
- // Command on existing session. Could be due to other end missing
- // the XID response, so if XID just resend response
+ // XID response, not in state 1.
+
+ // This "shouldn't happen"
+
+ Debugprintf("Unexpected XID response, State = %d", LINK->L2STATE);
+
+ // Discard
+
+ ReleaseBuffer(Buffer);
+ return;
}
- if (CTLlessPF == XID && (MSGFLAG & CMDBIT))
+
+ // Not XID
+
+ // if state = 1 then unexpected response to XID
+
+ if (LINK->L2STATE == 1)
{
- // XID Command on active session. Other end may be restarting. Send Response
+ if (CTLlessPF == DM || CTLlessPF == FRMR)
+ {
+ // Doesn't support XID - Send SABM
- ProcessXIDCommand(LINK, PORT, Buffer, ADJBUFFER, CTL, MSGFLAG);
- return;
+ LINK->L2STATE = 2;
+ LINK->Ver2point2 = FALSE;
+ LINK->L2TIMER = 1; // Use retry to send SABM
+
+ ReleaseBuffer(Buffer);
+ return;
+ }
}
@@ -1221,9 +1283,13 @@ VOID L2SABM(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE * Buffe
int CONERROR;
struct ROUTE * ROUTE = NULL;
-
char toCall[12], fromCall[12];
+ if (CLOSING)
+ {
+ L2SENDDM(PORT, Buffer, ADJBUFFER);
+ return;
+ }
if (LINK == 0) // NO LINK ENTRIES - SEND DM RESPONSE
{
@@ -1288,6 +1354,16 @@ VOID L2SABM(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE * Buffe
Debugprintf("INP3 Incoming connect from %s", fromCall);
DeleteINP3Routes(ROUTE);
}
+ else
+ {
+ if (PORT->ENABLEINP3)
+ {
+ // We will offer INP3 by sending an RTT probe.
+
+ SendRTTMsg(ROUTE);
+
+ }
+ }
}
if (NO_CTEXT == 1)
@@ -1388,6 +1464,8 @@ VOID L2SABM(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE * Buffe
return;
}
+ strcpy(Session->APPL, LINK->ApplName);
+
// NOW TRY A BBS CONNECT
// IF APPL CONNECT, SEE IF APPL HAS AN ALIAS
@@ -1772,6 +1850,16 @@ BOOL InternalL2SETUPCROSSLINK(PROUTE ROUTE, int Retries)
struct PORTCONTROL * PORT;
int FRACK;
+ // If it is NETROM Over TCP then check for existing connection
+
+ if (ROUTE->TCPPort)
+ {
+ if (strcmp(ROUTE->TCPHost, "0.0.0.0") == 0) // listening connection so wait for other end to connect
+ return FALSE;
+
+ return NETROMOpenConnection(ROUTE);
+ }
+
if (FindLink(ROUTE->NEIGHBOUR_CALL, NETROMCALL, ROUTE->NEIGHBOUR_PORT, &LINK))
{
// SESSION ALREADY EXISTS
@@ -1983,19 +2071,32 @@ VOID L2_PROCESS(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE * B
if (FindNeighbour(Buffer->ORIGIN, PORT->PORTNUMBER, &ROUTE))
{
+ ROUTE->ConnectionAttempts = 0; // Reset counter
+
if (ROUTE->INP3Node)
{
Debugprintf("INP3 Route to %s connected", fromCall);
}
+ else
+ {
+ if (PORT->ENABLEINP3)
+ {
+ // We will offer INP3 by sending an RTT probe.
+
+ SendRTTMsg(ROUTE);
+
+ }
+ }
}
+ hookL2SessionConnected(LINK);
SendL2ToMonMap(PORT, fromCall, '+', 'O');
LINK->L2STATE = 5;
LINK->L2TIMER = 0; // CANCEL TIMER
LINK->L2RETRIES = 0;
- LINK->L2SLOTIM, T3; // SET FRAME SENT RECENTLY
+ LINK->L2SLOTIM = T3; // SET FRAME SENT RECENTLY
// IF VERSION 1 MSG, SET FLAG
@@ -2015,6 +2116,8 @@ VOID L2_PROCESS(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE * B
if (LINK->L2STATE == 4) // DISCONNECTING?
{
InformPartner(LINK, NORMALCLOSE); // SEND DISC TO OTHER END
+ hookL2SessionClosed(LINK, "Normal", "Out");
+
CLEAROUTLINK(LINK);
if (PORT->TNC && PORT->TNC->Hardware == H_KISSHF)
@@ -2177,6 +2280,13 @@ VOID SFRAME(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, UCHAR CTL, UCHA
MESSAGE * Msg;
MESSAGE * Buffer;
+ // it shouldn't be possible to get srej when all are acked (NS = Link->NS) but just in case...
+
+ if (NS == LINK->LINKNS)
+ {
+ Debugprintf ("SREJ for our NS");
+ goto treatasRR;
+ }
LINK->L2FLAGS &= ~POLLSENT; // CLEAR I(P) or RR(P) SET
Msg = LINK->FRAMES[NS]; // is frame available?
@@ -2236,6 +2346,9 @@ VOID SFRAME(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, UCHAR CTL, UCHA
LINK->L2TIMER = ONEMINUTE; // (RE)SET TIMER
+
+ LINK->framesResent++;
+
PORT = LINK->LINKPORT;
if (PORT)
@@ -2254,6 +2367,9 @@ VOID SFRAME(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, UCHAR CTL, UCHA
return;
}
+treatasRR:
+
+
// VALID RR/RNR RECEIVED
LINK->L2FLAGS &= ~RNRSET; //CLEAR RNR
@@ -2274,7 +2390,7 @@ VOID SFRAME(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, UCHAR CTL, UCHA
if (LINK->LAST_F_TIME + 15 > REALTIMETICKS)
return; // DISCARD
- CTL = RR_OR_RNR(LINK);
+ CTL = RR_OR_RNR(LINK, FALSE); // Sending response
CTL |= LINK->LINKNR << 5; // SHIFT N(R) TO TOP 3 BITS
CTL |= PFBIT;
@@ -2339,6 +2455,20 @@ VOID SFRAME(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, UCHAR CTL, UCHA
LINK->L2FLAGS &= ~POLLSENT; // CLEAR I(P) or RR(P) SET
+ // ?? is this the place to do RTT?
+
+ if (LINK->lastPSent)
+ {
+ int RTT = GetTickCount() - LINK->lastPSent;
+
+ if (LINK->RTT)
+ LINK->RTT = ((LINK->RTT * 90) / 100) + RTT /10; // Smooth - 90% of old + 10% of new
+ else
+ LINK->RTT = RTT;
+
+ LINK->lastPSent = 0;
+ }
+
if ((CTL & 0xf) == RNR)
{
// Dont Clear timer on receipt of RNR(F), spec says should poll for clearing of busy,
@@ -2586,6 +2716,7 @@ VOID PROC_I_FRAME(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT, MESSAGE *
LINK->bytesRXed += Length;
LINK->Received += Length - 1; // Exclude PID
+ LINK->framesRXed++;
// Adjust for DIGIS
@@ -2813,6 +2944,8 @@ VOID RESETNS(struct _LINKTABLE * LINK, UCHAR NS)
{
int Resent = (LINK->LINKNS - NS) & 7; // FRAMES TO RESEND
+ LINK->framesResent += Resent;
+
LINK->LINKNS = NS; // RESET N(S)
if (LINK->LINKTYPE == 3) // mode-Node
@@ -2981,9 +3114,9 @@ VOID SDETX(struct _LINKTABLE * LINK)
// **** Debug code **** look for stuck links
- if (LINK->LASTFRAMESENT && (time(NULL) - LINK->LASTFRAMESENT) > 60) // No send for 60 secs
+ if (LINK->LINKWINDOW == 0 || LINK->LASTFRAMESENT == 0 || (time(NULL) - LINK->LASTFRAMESENT) > 60) // No send for 60 secs
{
- if (COUNT_AT_L2(LINK) > 16)
+ if (COUNT_AT_L2(LINK) > 16 || LINK->LINKWINDOW == 0)
{
// Dump Link State
@@ -3036,6 +3169,11 @@ VOID SDETX(struct _LINKTABLE * LINK)
LINK->LASTFRAMESENT = time(NULL);
LINK->LASTSENTQCOUNT = COUNT_AT_L2(LINK);
+ if (LINK->LASTSENTQCOUNT > LINK->maxQueued)
+ LINK->maxQueued = LINK->LASTSENTQCOUNT;
+
+ if (LINK->LASTSENTQCOUNT > LINK->intervalMaxQueued)
+ LINK->intervalMaxQueued = LINK->LASTSENTQCOUNT;
if (LINK->AllowCompress && Msg->LENGTH > 20 && LINK->TX_Q && Msg->PID == 240) // if short and no more not worth trying compression
{
@@ -3161,6 +3299,10 @@ VOID SDETX(struct _LINKTABLE * LINK)
LINK->FRAMES[LINK->SDTSLOT] = Msg;
LINK->SDTSLOT ++;
LINK->SDTSLOT &= 7;
+
+ LINK->framesTXed++;
+ LINK->bytesTXed += sendLen;
+
compdata += sendLen;
complen -= sendLen;
@@ -3174,6 +3316,9 @@ VOID SDETX(struct _LINKTABLE * LINK)
LINK->FRAMES[LINK->SDTSLOT] = Msg;
LINK->SDTSLOT ++;
LINK->SDTSLOT &= 7;
+
+ LINK->framesTXed++;
+ LINK->bytesTXed += (Msg->LENGTH - (MSGHDDRLEN + 1));
}
}
@@ -3231,6 +3376,7 @@ VOID SDETX(struct _LINKTABLE * LINK)
// FLAG BUFFER TO CAUSE TIMER TO BE RESET AFTER SEND (or ACK if ACKMODE)
Buffer->Linkptr = LINK;
+ LINK->lastPSent = GetTickCount();
}
}
@@ -3272,6 +3418,7 @@ VOID L2TimerProc()
int i = MAXLINKS;
struct _LINKTABLE * LINK = LINKS;
struct PORTCONTROL * PORT = PORTTABLE;
+ time_t Now = time(NULL);
while (i--)
{
@@ -3279,8 +3426,14 @@ VOID L2TimerProc()
{
LINK++;
continue;
- }
+ }
+
+ // Check for Status report time
+ if (LINK->lastStatusSentTime && (Now - LINK->lastStatusSentTime) > linkStatusInterval)
+ hookL2SessionStatus(LINK);
+
+
// CHECK FOR TIMER EXPIRY OR BUSY CLEARED
PORT = LINK->LINKPORT;
@@ -3316,7 +3469,7 @@ VOID L2TimerProc()
{
// Was busy
- if (RR_OR_RNR(LINK) != RNR) // SEE IF STILL BUSY
+ if (RR_OR_RNR(LINK, 0) != RNR) // SEE IF STILL BUSY
{
// Not still busy - tell other end
@@ -3375,7 +3528,7 @@ VOID L2TimerProc()
{
SendSupervisCmd(LINK);
LINK++;
- continue;
+ continue;
}
}
@@ -3432,7 +3585,7 @@ VOID SendSupervisCmd(struct _LINKTABLE * LINK)
LINK->L2ACKREQ = 0; // CLEAR ACK NEEDED
- CTL = RR_OR_RNR(LINK);
+ CTL = RR_OR_RNR(LINK, TRUE);
// MOV L2STATE[EBX],5 ; CANCEL REJ - ACTUALLY GOING TO 'PENDING ACK'
@@ -3450,7 +3603,7 @@ void SEND_RR_RESP(struct _LINKTABLE * LINK, UCHAR PF)
{
UCHAR CTL;
- CTL = RR_OR_RNR(LINK);
+ CTL = RR_OR_RNR(LINK, FALSE);
// MOV L2STATE[EBX],5 ; CANCEL REJ - ACTUALLY GOING TO 'PENDING ACK'
@@ -3643,6 +3796,8 @@ VOID L2TIMEOUT(struct _LINKTABLE * LINK, struct PORTCONTROL * PORT)
{
// RETRIED N TIMES SEND A COUPLE OF DISCS AND THEN CLOSE
+ hookL2SessionClosed(LINK, "Retried Out", "Out");
+
InformPartner(LINK, RETRIEDOUT); // TELL OTHER END ITS GONE
LINK->L2RETRIES -= 1; // Just send one DISC
@@ -3801,6 +3956,7 @@ VOID L2SENDXID(struct _LINKTABLE * LINK)
if (PORT)
{
+ LINK->LINKWINDOW = PORT->PORTWINDOW; // Just in case!
Buffer->PORT = PORT->PORTNUMBER;
PUT_ON_PORT_Q(PORT, Buffer);
}
@@ -3944,7 +4100,7 @@ VOID InformPartner(struct _LINKTABLE * LINK, int Reason)
}
-UINT RR_OR_RNR(struct _LINKTABLE * LINK)
+UINT RR_OR_RNR(struct _LINKTABLE * LINK, int CMD)
{
UCHAR Temp;
TRANSPORTENTRY * Session;
@@ -4021,18 +4177,21 @@ stayinREJ2:
goto CheckNSLoop2; // See if OK or we have another saved frame
}
if (LINK->L2STATE == 6)
+ {
+ // if we support SREJ send that instesd or REJ
- // if we support SREJ send that instesd or REJ
+ // Dont send SREJ if clearing RNR - causes FRMR
- // Dont send SREJ if clearing RNR - causes FRMR
+ // Latest Spec says shouldn't send SREJ as Command
- if (SaveRNRSent)
- return REJ;
+ if (SaveRNRSent || CMD == 1)
+ return REJ;
- if (LINK->Ver2point2) // We only allow 2.2 with SREJ Multi
- return SREJ;
- else
- return REJ;
+ if (LINK->Ver2point2) // We only allow 2.2 with SREJ Multi
+ return SREJ;
+ else
+ return REJ;
+ }
}
return RR;
@@ -4627,5 +4786,32 @@ int L2Compressit(unsigned char * Out, int OutSize, unsigned char * In, int Len)
}
+int CloseAllLinks()
+{
+ struct _LINKTABLE * LINK = LINKS;
+ int i = MAXLINKS;
+ int Closed = 0;
+
+ while (i--)
+ {
+ if (LINK->LINKCALL[0] == 0 || LINK->L2STATE !=5 )
+ {
+ LINK++;
+ continue;
+ }
+
+ // Close Link
+
+ InformPartner(LINK, NORMALCLOSE); // TELL OTHER END ITS GONE
+
+ LINK->L2RETRIES -= 1; // Just send one DISC
+ LINK->L2STATE = 4; // CLOSING
+
+ L2SENDCOMMAND(LINK, DISC | PFBIT);
+
+ Closed++;
+ }
+ return Closed;
+}