Skip to content

Commit 549bd84

Browse files
committed
Added INIT ACK parsing.
1 parent 34dee35 commit 549bd84

5 files changed

+33
-2
lines changed

src/spindump_analyze_sctp.c

+8-1
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,15 @@ spindump_analyze_process_sctp(struct spindump_analyze* state,
178178
//
179179

180180
if (connection != 0) {
181+
182+
struct spindump_sctp_chunk_init_ack sctp_chunk_init_ack;
183+
spindump_protocols_sctp_chunk_init_ack_parse(
184+
packet->contents + sctpHeaderPosition + spindump_sctp_packet_header_length,
185+
&sctp_chunk_init_ack);
181186

182-
spindump_analyze_process_pakstats(state,connection,1,packet,ipPacketLength,ecnFlags);
187+
connection->u.sctp.side2Vtag = sctp_chunk_init_ack.initiateTag;
188+
189+
spindump_analyze_process_pakstats(state,connection,1,packet,ipPacketLength,ecnFlags);
183190
*p_connection = connection;
184191

185192
} else {

src/spindump_analyze_sctp_parser.c

+19
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@
4444
// | Chunk Value |
4545
// | |
4646
// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47+
//
48+
// TODO: Maksim Proshin: add checks on params length
4749
void
4850
spindump_protocols_sctp_chunk_header_parse(const unsigned char* header,
4951
struct spindump_sctp_chunk_header* decoded){
@@ -54,6 +56,7 @@ spindump_protocols_sctp_chunk_header_parse(const unsigned char* header,
5456
}
5557

5658
// TODO: Maksim Proshin: add INIT chunk description and function description
59+
// TODO: Maksim Proshin: add checks on params length
5760
void
5861
spindump_protocols_sctp_chunk_init_parse(const unsigned char* header,
5962
struct spindump_sctp_chunk_init* decoded){
@@ -67,3 +70,19 @@ spindump_protocols_sctp_chunk_init_parse(const unsigned char* header,
6770
spindump_decode2byteint(decoded->inStreams,header,pos); // Num of Inbound Streams
6871
spindump_decode4byteint(decoded->initTsn,header,pos); // Initial TSN
6972
}
73+
74+
// TODO: Maksim Proshin: add INIT ACK chunk description and function description
75+
// TODO: Maksim Proshin: add checks on params length
76+
void
77+
spindump_protocols_sctp_chunk_init_ack_parse(const unsigned char* header,
78+
struct spindump_sctp_chunk_init_ack* decoded){
79+
unsigned int pos = 0;
80+
spindump_decodebyte(decoded->header.ch_type,header,pos); // Chunk Type
81+
spindump_decodebyte(decoded->header.ch_flags,header,pos); // Chunk Flags
82+
spindump_decode2byteint(decoded->header.ch_length,header,pos); // Chunk Length
83+
spindump_decode4byteint(decoded->initiateTag,header,pos); // Initiate Tag
84+
spindump_decode4byteint(decoded->arwnd,header,pos); // Advertised Receiver Window
85+
spindump_decode2byteint(decoded->outStreams,header,pos); // Num of Outbound Streams
86+
spindump_decode2byteint(decoded->inStreams,header,pos); // Num of Inbound Streams
87+
spindump_decode4byteint(decoded->initTsn,header,pos); // Initial TSN
88+
}

src/spindump_analyze_sctp_parser.h

+4
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,8 @@ void
3838
spindump_protocols_sctp_chunk_init_parse(const unsigned char* header,
3939
struct spindump_sctp_chunk_init* decoded);
4040

41+
void
42+
spindump_protocols_sctp_chunk_init_ack_parse(const unsigned char* header,
43+
struct spindump_sctp_chunk_init_ack* decoded);
44+
4145
#endif // SPINDUMP_ANALYZE_SCTP_PARSER_H

src/spindump_connections_new.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ spindump_connections_newconnection_sctp(const spindump_address* side1address,
429429
connection->u.sctp.side1peerPort = side1port;
430430
connection->u.sctp.side2peerPort = side2port;
431431
connection->u.sctp.side1Vtag = side1Vtag; // VTag from INIT chunk
432-
connection->u.sctp.side2Vtag = 0; // VTag from INIT ACK chunk
432+
connection->u.sctp.side2Vtag = 0; // VTag from INIT ACK chunk will be stored here
433433
spindump_connections_newconnection_addtoaggregates(connection,table);
434434

435435
spindump_debugf("created a new SCTP connection %u", connection->id);

src/spindump_protocols.h

+1
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,7 @@ struct spindump_sctp_chunk_header {
730730
uint8_t ch_type; // Chunk Type
731731
uint8_t ch_flags; // Chunk Flags
732732
uint16_t ch_length; // Chunk Length
733+
// Chunk Value follows
733734
};
734735

735736

0 commit comments

Comments
 (0)