diff --git a/gtests/net/packetdrill/sctp_chunk_to_string.c b/gtests/net/packetdrill/sctp_chunk_to_string.c index 2cb43820a0a4669f20cfe448500ee3c3dfbdcf61..16b0af4d394077cb7f28b3688de2bd1667f65732 100644 --- a/gtests/net/packetdrill/sctp_chunk_to_string.c +++ b/gtests/net/packetdrill/sctp_chunk_to_string.c @@ -1654,6 +1654,45 @@ static int sctp_reconfig_chunk_to_string( return result; } +static u16 get_num_sid_blocks (u16 packet_length) { + return (packet_length - sizeof(struct sctp_forward_tsn_chunk)) / sizeof(struct sctp_stream_identifier_block); +} + +static int sctp_forward_tsn_chunk_to_string( + FILE *s, + struct sctp_forward_tsn_chunk *chunk, + char **error) +{ + u16 length, i; + length = ntohs(chunk->length); + u16 num_sid_blocks = get_num_sid_blocks(length); + + if (length < sizeof(struct sctp_forward_tsn_chunk)) { + asprintf(error, "FORWARD_TSN chunk too short (length=%u)", length); + return STATUS_ERR; + } + + fputs("FORWARD_TSN[", s); + fprintf(s, "flgs=0x%02x, ", chunk->flags); + fprintf(s, "len=%u, ", length); + fprintf(s, "cum_tsn=%d, ", ntohl(chunk->cum_tsn)); + + fprintf(s, "sids=["); + + for (i = 0; i < num_sid_blocks; i++) { + fprintf(s, "%u:%u", + ntohs(chunk->stream_identifier_blocks[i].stream), + ntohs(chunk->stream_identifier_blocks[i].stream_sequence)); + if (i != num_sid_blocks-1) { + fprintf(s, ", "); + } + } + + fprintf(s, "]"); + + return STATUS_OK; +} + static int sctp_unknown_chunk_to_string(FILE *s, struct sctp_chunk *chunk, char **error) @@ -1750,6 +1789,10 @@ int sctp_chunk_to_string(FILE *s, struct sctp_chunk *chunk, char **error) result = sctp_reconfig_chunk_to_string(s, (struct sctp_reconfig_chunk *)chunk, error); break; + case SCTP_FORWARD_TSN_CHUNK_TYPE: + result = sctp_forward_tsn_chunk_to_string(s, + (struct sctp_forward_tsn_chunk *)chunk, error); + break; default: result = sctp_unknown_chunk_to_string(s, chunk, error); break;