Skip to content

Commit

Permalink
LCS: Handle oversized outbound SNA messages correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcisho committed Jan 7, 2022
1 parent 47f9d14 commit 261bb51
Showing 1 changed file with 50 additions and 6 deletions.
56 changes: 50 additions & 6 deletions ctc_lcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -4682,10 +4682,29 @@ void Process_0D10 (PLCSDEV pLCSDEV, PLCSHDR pLCSHDR, PLCSBAF1 pLCSBAF1, PLCSBAF2
// 0100000000 xxxxxxxx...........
// 0 1 2 3 4 5 6 7 8 9 A B C ...

#define INBOUND_4C0B_SIZE 32
static const BYTE Inbound_4C0B[INBOUND_4C0B_SIZE] =
{
0x00, 0x20, 0x04, 0x00, /* LCSHDR */
0x00, 0x18, 0x4C, 0x0B, 0x00, 0x03, 0x60, 0x01, /* LCSBAF1 */
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x76, 0x56, 0x00, 0x00, 0x00, 0x00,
0x01, 0x40, 0x00, /* LCSBAF2 */
0x00 /* Filler */
};
// 00200400 00184C0B 00036001 00000101 00000000 00007656 00000000 014000 00
// 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 0 1 2 3

DEVBLK* pDEVBLK;
PLCSPORT pLCSPORT;
PLCSCONN pLCSCONN;
PETHFRM pEthFrame;
PLCSIBH pLCSIBH;
PLCSHDR pInHDR;
PLCSBAF1 pInBAF1;
// PLCSBAF2 pInBAF2;
// U16 hwLenInBaf1;
// U16 hwLenInBaf2;
int iEthLen;
int iLPDULen;
LLC llc;
Expand Down Expand Up @@ -4736,9 +4755,7 @@ void Process_0D10 (PLCSDEV pLCSDEV, PLCSHDR pLCSHDR, PLCSBAF1 pLCSBAF1, PLCSBAF2
{
if ( iTHetcLen > 1493 ) // 1493 = 0x5D5
{
snprintf( llcmsg, sizeof(llcmsg), "LCS: Truncating %d bytes to 1493 bytes!!!", iTHetcLen );
WRMSG(HHC03984, "W", llcmsg ); /* FixMe! Proper message number! */
iTHetcLen = 1493;
goto Process_0D10_too_large;
}
STORE_HW( pEthFrame->hwEthernetType, (U16)(iLPDULen + iTHetcLen) ); // Set LLC and TH etc length
memcpy( &pEthFrame->bData[iLPDULen], &pLCSBAF2->bByte05, iTHetcLen ); // Copy TH etc
Expand Down Expand Up @@ -4785,6 +4802,31 @@ void Process_0D10 (PLCSDEV pLCSDEV, PLCSHDR pLCSHDR, PLCSBAF1 pLCSBAF1, PLCSBAF2
}

return;


Process_0D10_too_large:

// Obtain a buffer in which to construct the data to be passed to VTAM.
pLCSIBH = alloc_lcs_buffer( pLCSDEV, ( INBOUND_4C0B_SIZE * 2 ) );

memcpy( &pLCSIBH->bData, Inbound_4C0B, INBOUND_4C0B_SIZE );
pLCSIBH->iDataLen = INBOUND_4C0B_SIZE;

pInHDR = (PLCSHDR)&pLCSIBH->bData;
pInBAF1 = (PLCSBAF1)( (BYTE*)pInHDR + sizeof(LCSHDR) );
// FETCH_HW( hwLenInBaf1, pInBAF1->hwLenBaf1 );
// FETCH_HW( hwLenInBaf2, pInBAF1->hwLenBaf2 );
// pInBAF2 = (PLCSBAF2)( (BYTE*)pInBAF1 + hwLenInBaf1 );

//
memcpy( pInBAF1->bTokenA, &pLCSCONN->bInToken, sizeof(pLCSCONN->bInToken) ); // Set Inbound token

// Add the buffer containing the bad news response to the chain.
add_lcs_buffer_to_chain( pLCSDEV, pLCSIBH );

pLCSDEV->fAttnRequired = TRUE;

return;
}


Expand Down Expand Up @@ -6030,7 +6072,8 @@ static const BYTE Inbound_4C25[INBOUND_4C25_SIZE] =
0x01, 0xff, 0xff, 0xC0, 0x00, 0x00, 0x00, 0x00, /* LCSBAF2 */
0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0x04, 0x00
0xff, 0xff, 0xff, 0x04,
0x00 /* Filler */
};
// 002E0400 000D4C25 001C6003 00000001 00 01 0001 C0000000 00000000 00 400074700001 000CCE4B4740 0401F3 04 00
// 0 1 2 3 4 5 6 7 8 9 A B C 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 8 9 A B C
Expand Down Expand Up @@ -6065,9 +6108,10 @@ static const BYTE Inbound_4C0B[INBOUND_4C0B_SIZE] =
0x00, 0x18, 0x4C, 0x0B, 0x00, 0x03, 0x60, 0x01, /* LCSBAF1 */
0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x76, 0x56, 0x00, 0x00, 0x00, 0x00,
0x01, 0x40, 0x00, 0x00 /* LCSBAF2 */
0x01, 0x40, 0x00, /* LCSBAF2 */
0x00 /* Filler */
};
// 00200400 00184C0B 00036001 00000101 00000000 00007656 00000000 01 4000 00
// 00200400 00184C0B 00036001 00000101 00000000 00007656 00000000 014000 00
// 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 0 1 2 3

#define INBOUND_CD00_SIZE 32
Expand Down

0 comments on commit 261bb51

Please sign in to comment.