Skip to content

Commit 08b3357

Browse files
author
Yuxuan Luo
committed
SCTP: Support I-FORWARD chunk
Add support for printing I-FORWARD chunk based on RFC8260 section 2.3. Remove REL_CTL (RFC3758) since it is obsolete and it uses the value '0xc2' of I-FORWARD for CNTL_ACK. Print stream IDs and message IDs with `-vv` set. Example: `-v`: [I-FORWARD-FSN] [TSN: 1584188225] `-vv`: [I-FORWARD-FSN] [TSN: 2195717635] [SID: 0] [MID: 2]
1 parent f13fabd commit 08b3357

File tree

1 file changed

+49
-2
lines changed

1 file changed

+49
-2
lines changed

print-sctp.c

+49-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
#define SCTP_I_DATA 0x40
115115
#define SCTP_FORWARD_CUM_TSN 0xc0
116116
#define SCTP_RELIABLE_CNTL 0xc1
117-
#define SCTP_RELIABLE_CNTL_ACK 0xc2
117+
#define SCTP_I_FORWARD_TSN 0xc2
118118

119119
static const struct tok sctp_chunkid_str[] = {
120120
{ SCTP_DATA, "DATA" },
@@ -135,7 +135,7 @@ static const struct tok sctp_chunkid_str[] = {
135135
{ SCTP_I_DATA, "I-DATA" },
136136
{ SCTP_FORWARD_CUM_TSN, "FOR CUM TSN" },
137137
{ SCTP_RELIABLE_CNTL, "REL CTRL" },
138-
{ SCTP_RELIABLE_CNTL_ACK, "REL CTRL ACK" },
138+
{ SCTP_I_FORWARD_TSN, "I-FORWARD-FSN" },
139139
{ 0, NULL }
140140
};
141141

@@ -148,6 +148,9 @@ static const struct tok sctp_chunkid_str[] = {
148148
#define SCTP_DATA_UNORDERED 0x04
149149
#define SCTP_DATA_SACK_IMM 0x08
150150

151+
/* I-Forward-TSN Specific Flag */
152+
#define SCTP_I_FORWARD_UNORDERED 0x01
153+
151154
#define SCTP_ADDRMAX 60
152155

153156
#define CHAN_HP 6704
@@ -361,6 +364,16 @@ struct sctpIData{
361364
nd_uint32_t PPID_FSN;
362365
};
363366

367+
struct sctpIForward{
368+
nd_uint32_t new_cum_TSN;
369+
};
370+
371+
struct sctpIForwardEntry{
372+
nd_uint16_t streamId;
373+
nd_uint16_t flag;
374+
nd_uint32_t MID;
375+
};
376+
364377
struct sctpUnifiedDatagram{
365378
struct sctpChunkDesc uh;
366379
struct sctpDataPart dp;
@@ -729,6 +742,40 @@ sctp_print(netdissect_options *ndo,
729742
chunkLengthRemaining -= payload_size;
730743
break;
731744
}
745+
case SCTP_I_FORWARD_TSN:
746+
{
747+
const struct sctpIForward *dataHdrPtr;
748+
const struct sctpIForwardEntry *entry;
749+
const size_t entry_len = sizeof(struct sctpIForwardEntry);
750+
751+
ND_ICHECKMSG_ZU("chunk length", chunkLengthRemaining, <, sizeof(*dataHdrPtr));
752+
dataHdrPtr=(const struct sctpIForward*)bp;
753+
ND_PRINT("[TSN: %u] ", GET_BE_U_4(dataHdrPtr->new_cum_TSN));
754+
755+
bp += sizeof(*dataHdrPtr);
756+
sctpPacketLengthRemaining -= sizeof(*dataHdrPtr);
757+
chunkLengthRemaining -= sizeof(*dataHdrPtr);
758+
759+
if (ndo->ndo_vflag >= 2) {
760+
while (entry_len <= chunkLengthRemaining) {
761+
entry = (const struct sctpIForwardEntry*)bp;
762+
763+
ND_PRINT("[SID: %u] ", GET_BE_U_2(entry->streamId));
764+
if ((GET_BE_U_2(entry->flag) & SCTP_I_FORWARD_UNORDERED))
765+
ND_PRINT("(U)"); /* if U bit is set */
766+
ND_PRINT("[MID: %u] ", GET_BE_U_4(entry->MID));
767+
768+
chunkLengthRemaining -= entry_len;
769+
sctpPacketLengthRemaining -= entry_len;
770+
bp += entry_len;
771+
}
772+
}
773+
774+
bp += chunkLengthRemaining;
775+
sctpPacketLengthRemaining -= chunkLengthRemaining;
776+
chunkLengthRemaining = 0;
777+
break;
778+
}
732779
case SCTP_INITIATION :
733780
{
734781
const struct sctpInitiation *init;

0 commit comments

Comments
 (0)