summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-sctp.c
diff options
context:
space:
mode:
Diffstat (limited to 'epan/dissectors/packet-sctp.c')
-rw-r--r--epan/dissectors/packet-sctp.c1662
1 files changed, 876 insertions, 786 deletions
diff --git a/epan/dissectors/packet-sctp.c b/epan/dissectors/packet-sctp.c
index 76348743..ea3132cf 100644
--- a/epan/dissectors/packet-sctp.c
+++ b/epan/dissectors/packet-sctp.c
@@ -39,6 +39,8 @@
#include "config.h"
+#define WS_LOG_DOMAIN "sctp"
+
#include "ws_symbol_export.h"
#include <epan/packet.h>
@@ -64,7 +66,7 @@
#include "packet-sctp.h"
-#define LT(x, y) ((gint32)((x) - (y)) < 0)
+#define LT(x, y) ((int32_t)((x) - (y)) < 0)
#define UDP_TUNNELING_PORT 9899
@@ -76,240 +78,241 @@ void proto_register_sctp(void);
void proto_reg_handoff_sctp(void);
/* Initialize the protocol and registered fields */
-static int proto_sctp = -1;
-static int hf_port = -1;
-static int hf_source_port = -1;
-static int hf_destination_port = -1;
-static int hf_verification_tag = -1;
-static int hf_checksum = -1;
-static int hf_checksum_adler = -1;
-static int hf_checksum_crc32c = -1;
-static int hf_checksum_status = -1;
-
-static int hf_chunk_type = -1;
-static int hf_chunk_flags = -1;
-static int hf_chunk_bit_1 = -1;
-static int hf_chunk_bit_2 = -1;
-static int hf_chunk_length = -1;
-static int hf_chunk_padding = -1;
-static int hf_chunk_value = -1;
-
-static int hf_initiate_tag = -1;
-static int hf_init_chunk_initiate_tag = -1;
-static int hf_init_chunk_adv_rec_window_credit = -1;
-static int hf_init_chunk_number_of_outbound_streams = -1;
-static int hf_init_chunk_number_of_inbound_streams = -1;
-static int hf_init_chunk_initial_tsn = -1;
-
-static int hf_initack_chunk_initiate_tag = -1;
-static int hf_initack_chunk_adv_rec_window_credit = -1;
-static int hf_initack_chunk_number_of_outbound_streams = -1;
-static int hf_initack_chunk_number_of_inbound_streams = -1;
-static int hf_initack_chunk_initial_tsn = -1;
-
-static int hf_data_chunk_tsn = -1;
-static int hf_data_chunk_tsn_raw = -1;
-static int hf_data_chunk_stream_id = -1;
-static int hf_data_chunk_stream_seq_number = -1;
-static int hf_data_chunk_payload_proto_id = -1;
-static int hf_idata_chunk_reserved = -1;
-static int hf_idata_chunk_mid = -1;
-static int hf_idata_chunk_fsn = -1;
-
-static int hf_data_chunk_e_bit = -1;
-static int hf_data_chunk_b_bit = -1;
-static int hf_data_chunk_u_bit = -1;
-static int hf_data_chunk_i_bit = -1;
-
-static int hf_sack_chunk_ns = -1;
-static int hf_sack_chunk_cumulative_tsn_ack = -1;
-static int hf_sack_chunk_cumulative_tsn_ack_raw = -1;
-static int hf_sack_chunk_adv_rec_window_credit = -1;
-static int hf_sack_chunk_number_of_gap_blocks = -1;
-static int hf_sack_chunk_number_of_dup_tsns = -1;
-static int hf_sack_chunk_gap_block_start = -1;
-static int hf_sack_chunk_gap_block_end = -1;
-static int hf_sack_chunk_gap_block_start_tsn = -1;
-static int hf_sack_chunk_gap_block_end_tsn = -1;
-static int hf_sack_chunk_number_tsns_gap_acked = -1;
-static int hf_sack_chunk_duplicate_tsn = -1;
-
-static int hf_nr_sack_chunk_ns = -1;
-static int hf_nr_sack_chunk_cumulative_tsn_ack = -1;
-static int hf_nr_sack_chunk_adv_rec_window_credit = -1;
-static int hf_nr_sack_chunk_number_of_gap_blocks = -1;
-static int hf_nr_sack_chunk_number_of_nr_gap_blocks = -1;
-static int hf_nr_sack_chunk_number_of_dup_tsns = -1;
-static int hf_nr_sack_chunk_reserved = -1;
-static int hf_nr_sack_chunk_gap_block_start = -1;
-static int hf_nr_sack_chunk_gap_block_end = -1;
-static int hf_nr_sack_chunk_gap_block_start_tsn = -1;
-static int hf_nr_sack_chunk_gap_block_end_tsn = -1;
-static int hf_nr_sack_chunk_number_tsns_gap_acked = -1;
-static int hf_nr_sack_chunk_nr_gap_block_start = -1;
-static int hf_nr_sack_chunk_nr_gap_block_end = -1;
-static int hf_nr_sack_chunk_nr_gap_block_start_tsn = -1;
-static int hf_nr_sack_chunk_nr_gap_block_end_tsn = -1;
-static int hf_nr_sack_chunk_number_tsns_nr_gap_acked = -1;
-static int hf_nr_sack_chunk_duplicate_tsn = -1;
-
-static int hf_shutdown_chunk_cumulative_tsn_ack = -1;
-static int hf_cookie = -1;
-static int hf_cwr_chunk_lowest_tsn = -1;
-
-static int hf_ecne_chunk_lowest_tsn = -1;
-static int hf_abort_chunk_t_bit = -1;
-static int hf_shutdown_complete_chunk_t_bit = -1;
-
-static int hf_parameter_type = -1;
-static int hf_parameter_length = -1;
-static int hf_parameter_value = -1;
-static int hf_parameter_padding = -1;
-static int hf_parameter_bit_1 = -1;
-static int hf_parameter_bit_2 = -1;
-static int hf_ipv4_address = -1;
-static int hf_ipv6_address = -1;
-static int hf_heartbeat_info = -1;
-static int hf_state_cookie = -1;
-static int hf_cookie_preservative_increment = -1;
-static int hf_hostname = -1;
-static int hf_supported_address_type = -1;
-static int hf_stream_reset_req_seq_nr = -1;
-static int hf_stream_reset_rsp_seq_nr = -1;
-static int hf_senders_last_assigned_tsn = -1;
-static int hf_senders_next_tsn = -1;
-static int hf_receivers_next_tsn = -1;
-static int hf_stream_reset_rsp_result = -1;
-static int hf_stream_reset_sid = -1;
-static int hf_add_outgoing_streams_number_streams = -1;
-static int hf_add_outgoing_streams_reserved = -1;
-static int hf_add_incoming_streams_number_streams = -1;
-static int hf_add_incoming_streams_reserved = -1;
-
-static int hf_zero_checksum_edmid = -1;
-
-static int hf_random_number = -1;
-static int hf_chunks_to_auth = -1;
-static int hf_hmac_id = -1;
-static int hf_hmac = -1;
-static int hf_shared_key_id = -1;
-static int hf_supported_chunk_type = -1;
-
-static int hf_cause_code = -1;
-static int hf_cause_length = -1;
-static int hf_cause_padding = -1;
-static int hf_cause_info = -1;
-
-static int hf_cause_stream_identifier = -1;
-static int hf_cause_reserved = -1;
-
-static int hf_cause_number_of_missing_parameters = -1;
-static int hf_cause_missing_parameter_type = -1;
-
-static int hf_cause_measure_of_staleness = -1;
-
-static int hf_cause_tsn = -1;
-
-static int hf_forward_tsn_chunk_tsn = -1;
-static int hf_forward_tsn_chunk_sid = -1;
-static int hf_forward_tsn_chunk_ssn = -1;
-
-static int hf_i_forward_tsn_chunk_tsn = -1;
-static int hf_i_forward_tsn_chunk_sid = -1;
-static int hf_i_forward_tsn_chunk_flags = -1;
-static int hf_i_forward_tsn_chunk_res = -1;
-static int hf_i_forward_tsn_chunk_u_bit = -1;
-static int hf_i_forward_tsn_chunk_mid = -1;
-
-static int hf_asconf_ack_seq_nr = -1;
-static int hf_asconf_seq_nr = -1;
-static int hf_correlation_id = -1;
-
-static int hf_adap_indication = -1;
-
-static int hf_pktdrop_chunk_m_bit = -1;
-static int hf_pktdrop_chunk_b_bit = -1;
-static int hf_pktdrop_chunk_t_bit = -1;
-static int hf_pktdrop_chunk_bandwidth = -1;
-static int hf_pktdrop_chunk_queuesize = -1;
-static int hf_pktdrop_chunk_truncated_length = -1;
-static int hf_pktdrop_chunk_reserved = -1;
-static int hf_pktdrop_chunk_data_field = -1;
-
-static int hf_pad_chunk_padding_data = -1;
-
-static int hf_sctp_reassembled_in = -1;
-static int hf_sctp_duplicate = -1;
-static int hf_sctp_fragments = -1;
-static int hf_sctp_fragment = -1;
-
-static int hf_sctp_retransmission = -1;
-static int hf_sctp_retransmitted = -1;
-static int hf_sctp_retransmitted_count = -1;
-static int hf_sctp_data_rtt = -1;
-static int hf_sctp_sack_rtt = -1;
-static int hf_sctp_rto = -1;
-static int hf_sctp_ack_tsn = -1;
-static int hf_sctp_ack_frame = -1;
-static int hf_sctp_acked = -1;
-static int hf_sctp_retransmitted_after_ack = -1;
-
-static int hf_sctp_assoc_index = -1;
+static int proto_sctp;
+static int hf_port;
+static int hf_source_port;
+static int hf_destination_port;
+static int hf_verification_tag;
+static int hf_checksum;
+static int hf_checksum_adler;
+static int hf_checksum_crc32c;
+static int hf_checksum_status;
+
+static int hf_chunk;
+static int hf_chunk_type;
+static int hf_chunk_flags;
+static int hf_chunk_bit_1;
+static int hf_chunk_bit_2;
+static int hf_chunk_length;
+static int hf_chunk_padding;
+static int hf_chunk_value;
+
+static int hf_initiate_tag;
+static int hf_init_chunk_initiate_tag;
+static int hf_init_chunk_adv_rec_window_credit;
+static int hf_init_chunk_number_of_outbound_streams;
+static int hf_init_chunk_number_of_inbound_streams;
+static int hf_init_chunk_initial_tsn;
+
+static int hf_initack_chunk_initiate_tag;
+static int hf_initack_chunk_adv_rec_window_credit;
+static int hf_initack_chunk_number_of_outbound_streams;
+static int hf_initack_chunk_number_of_inbound_streams;
+static int hf_initack_chunk_initial_tsn;
+
+static int hf_data_chunk_tsn;
+static int hf_data_chunk_tsn_raw;
+static int hf_data_chunk_stream_id;
+static int hf_data_chunk_stream_seq_number;
+static int hf_data_chunk_payload_proto_id;
+static int hf_idata_chunk_reserved;
+static int hf_idata_chunk_mid;
+static int hf_idata_chunk_fsn;
+
+static int hf_data_chunk_e_bit;
+static int hf_data_chunk_b_bit;
+static int hf_data_chunk_u_bit;
+static int hf_data_chunk_i_bit;
+
+static int hf_sack_chunk_ns;
+static int hf_sack_chunk_cumulative_tsn_ack;
+static int hf_sack_chunk_cumulative_tsn_ack_raw;
+static int hf_sack_chunk_adv_rec_window_credit;
+static int hf_sack_chunk_number_of_gap_blocks;
+static int hf_sack_chunk_number_of_dup_tsns;
+static int hf_sack_chunk_gap_block_start;
+static int hf_sack_chunk_gap_block_end;
+static int hf_sack_chunk_gap_block_start_tsn;
+static int hf_sack_chunk_gap_block_end_tsn;
+static int hf_sack_chunk_number_tsns_gap_acked;
+static int hf_sack_chunk_duplicate_tsn;
+
+static int hf_nr_sack_chunk_ns;
+static int hf_nr_sack_chunk_cumulative_tsn_ack;
+static int hf_nr_sack_chunk_adv_rec_window_credit;
+static int hf_nr_sack_chunk_number_of_gap_blocks;
+static int hf_nr_sack_chunk_number_of_nr_gap_blocks;
+static int hf_nr_sack_chunk_number_of_dup_tsns;
+static int hf_nr_sack_chunk_reserved;
+static int hf_nr_sack_chunk_gap_block_start;
+static int hf_nr_sack_chunk_gap_block_end;
+static int hf_nr_sack_chunk_gap_block_start_tsn;
+static int hf_nr_sack_chunk_gap_block_end_tsn;
+static int hf_nr_sack_chunk_number_tsns_gap_acked;
+static int hf_nr_sack_chunk_nr_gap_block_start;
+static int hf_nr_sack_chunk_nr_gap_block_end;
+static int hf_nr_sack_chunk_nr_gap_block_start_tsn;
+static int hf_nr_sack_chunk_nr_gap_block_end_tsn;
+static int hf_nr_sack_chunk_number_tsns_nr_gap_acked;
+static int hf_nr_sack_chunk_duplicate_tsn;
+
+static int hf_shutdown_chunk_cumulative_tsn_ack;
+static int hf_cookie;
+static int hf_cwr_chunk_lowest_tsn;
+
+static int hf_ecne_chunk_lowest_tsn;
+static int hf_abort_chunk_t_bit;
+static int hf_shutdown_complete_chunk_t_bit;
+
+static int hf_parameter_type;
+static int hf_parameter_length;
+static int hf_parameter_value;
+static int hf_parameter_padding;
+static int hf_parameter_bit_1;
+static int hf_parameter_bit_2;
+static int hf_ipv4_address;
+static int hf_ipv6_address;
+static int hf_heartbeat_info;
+static int hf_state_cookie;
+static int hf_cookie_preservative_increment;
+static int hf_hostname;
+static int hf_supported_address_type;
+static int hf_stream_reset_req_seq_nr;
+static int hf_stream_reset_rsp_seq_nr;
+static int hf_senders_last_assigned_tsn;
+static int hf_senders_next_tsn;
+static int hf_receivers_next_tsn;
+static int hf_stream_reset_rsp_result;
+static int hf_stream_reset_sid;
+static int hf_add_outgoing_streams_number_streams;
+static int hf_add_outgoing_streams_reserved;
+static int hf_add_incoming_streams_number_streams;
+static int hf_add_incoming_streams_reserved;
+
+static int hf_zero_checksum_edmid;
+
+static int hf_random_number;
+static int hf_chunks_to_auth;
+static int hf_hmac_id;
+static int hf_hmac;
+static int hf_shared_key_id;
+static int hf_supported_chunk_type;
+
+static int hf_cause_code;
+static int hf_cause_length;
+static int hf_cause_padding;
+static int hf_cause_info;
+
+static int hf_cause_stream_identifier;
+static int hf_cause_reserved;
+
+static int hf_cause_number_of_missing_parameters;
+static int hf_cause_missing_parameter_type;
+
+static int hf_cause_measure_of_staleness;
+
+static int hf_cause_tsn;
+
+static int hf_forward_tsn_chunk_tsn;
+static int hf_forward_tsn_chunk_sid;
+static int hf_forward_tsn_chunk_ssn;
+
+static int hf_i_forward_tsn_chunk_tsn;
+static int hf_i_forward_tsn_chunk_sid;
+static int hf_i_forward_tsn_chunk_flags;
+static int hf_i_forward_tsn_chunk_res;
+static int hf_i_forward_tsn_chunk_u_bit;
+static int hf_i_forward_tsn_chunk_mid;
+
+static int hf_asconf_ack_seq_nr;
+static int hf_asconf_seq_nr;
+static int hf_correlation_id;
+
+static int hf_adap_indication;
+
+static int hf_pktdrop_chunk_m_bit;
+static int hf_pktdrop_chunk_b_bit;
+static int hf_pktdrop_chunk_t_bit;
+static int hf_pktdrop_chunk_bandwidth;
+static int hf_pktdrop_chunk_queuesize;
+static int hf_pktdrop_chunk_truncated_length;
+static int hf_pktdrop_chunk_reserved;
+static int hf_pktdrop_chunk_data_field;
+
+static int hf_pad_chunk_padding_data;
+
+static int hf_sctp_reassembled_in;
+static int hf_sctp_duplicate;
+static int hf_sctp_fragments;
+static int hf_sctp_fragment;
+
+static int hf_sctp_retransmission;
+static int hf_sctp_retransmitted;
+static int hf_sctp_retransmitted_count;
+static int hf_sctp_data_rtt;
+static int hf_sctp_sack_rtt;
+static int hf_sctp_rto;
+static int hf_sctp_ack_tsn;
+static int hf_sctp_ack_frame;
+static int hf_sctp_acked;
+static int hf_sctp_retransmitted_after_ack;
+
+static int hf_sctp_assoc_index;
static dissector_table_t sctp_port_dissector_table;
static dissector_table_t sctp_ppi_dissector_table;
static heur_dissector_list_t sctp_heur_subdissector_list;
-static int sctp_tap = -1;
-static int exported_pdu_tap = -1;
+static int sctp_tap;
+static int exported_pdu_tap;
/* Initialize the subtree pointers */
-static gint ett_sctp = -1;
-static gint ett_sctp_chunk = -1;
-static gint ett_sctp_chunk_parameter = -1;
-static gint ett_sctp_chunk_cause = -1;
-static gint ett_sctp_chunk_type = -1;
-static gint ett_sctp_data_chunk_flags = -1;
-static gint ett_sctp_sack_chunk_flags = -1;
-static gint ett_sctp_nr_sack_chunk_flags = -1;
-static gint ett_sctp_abort_chunk_flags = -1;
-static gint ett_sctp_shutdown_complete_chunk_flags = -1;
-static gint ett_sctp_pktdrop_chunk_flags = -1;
-static gint ett_sctp_parameter_type= -1;
-static gint ett_sctp_sack_chunk_gap_block = -1;
-static gint ett_sctp_sack_chunk_gap_block_start = -1;
-static gint ett_sctp_sack_chunk_gap_block_end = -1;
-static gint ett_sctp_nr_sack_chunk_gap_block = -1;
-static gint ett_sctp_nr_sack_chunk_gap_block_start = -1;
-static gint ett_sctp_nr_sack_chunk_gap_block_end = -1;
-static gint ett_sctp_nr_sack_chunk_nr_gap_block = -1;
-static gint ett_sctp_nr_sack_chunk_nr_gap_block_start = -1;
-static gint ett_sctp_nr_sack_chunk_nr_gap_block_end = -1;
-static gint ett_sctp_unrecognized_parameter_parameter = -1;
-static gint ett_sctp_i_forward_tsn_chunk_flags = -1;
-
-static gint ett_sctp_fragments = -1;
-static gint ett_sctp_fragment = -1;
-
-static gint ett_sctp_tsn = -1;
-static gint ett_sctp_ack = -1;
-static gint ett_sctp_acked = -1;
-static gint ett_sctp_tsn_retransmission = -1;
-static gint ett_sctp_tsn_retransmitted_count = -1;
-static gint ett_sctp_tsn_retransmitted = -1;
-
-static expert_field ei_sctp_sack_chunk_adv_rec_window_credit = EI_INIT;
-static expert_field ei_sctp_nr_sack_chunk_number_tsns_gap_acked_100 = EI_INIT;
-static expert_field ei_sctp_parameter_length = EI_INIT;
-static expert_field ei_sctp_bad_sctp_checksum = EI_INIT;
-static expert_field ei_sctp_tsn_retransmitted_more_than_twice = EI_INIT;
-static expert_field ei_sctp_parameter_padding = EI_INIT;
-static expert_field ei_sctp_retransmitted_after_ack = EI_INIT;
-static expert_field ei_sctp_nr_sack_chunk_number_tsns_nr_gap_acked_100 = EI_INIT;
-static expert_field ei_sctp_sack_chunk_gap_block_out_of_order = EI_INIT;
-static expert_field ei_sctp_chunk_length_bad = EI_INIT;
-static expert_field ei_sctp_tsn_retransmitted = EI_INIT;
-static expert_field ei_sctp_sack_chunk_gap_block_malformed = EI_INIT;
-static expert_field ei_sctp_sack_chunk_number_tsns_gap_acked_100 = EI_INIT;
+static int ett_sctp;
+static int ett_sctp_chunk;
+static int ett_sctp_chunk_parameter;
+static int ett_sctp_chunk_cause;
+static int ett_sctp_chunk_type;
+static int ett_sctp_data_chunk_flags;
+static int ett_sctp_sack_chunk_flags;
+static int ett_sctp_nr_sack_chunk_flags;
+static int ett_sctp_abort_chunk_flags;
+static int ett_sctp_shutdown_complete_chunk_flags;
+static int ett_sctp_pktdrop_chunk_flags;
+static int ett_sctp_parameter_type;
+static int ett_sctp_sack_chunk_gap_block;
+static int ett_sctp_sack_chunk_gap_block_start;
+static int ett_sctp_sack_chunk_gap_block_end;
+static int ett_sctp_nr_sack_chunk_gap_block;
+static int ett_sctp_nr_sack_chunk_gap_block_start;
+static int ett_sctp_nr_sack_chunk_gap_block_end;
+static int ett_sctp_nr_sack_chunk_nr_gap_block;
+static int ett_sctp_nr_sack_chunk_nr_gap_block_start;
+static int ett_sctp_nr_sack_chunk_nr_gap_block_end;
+static int ett_sctp_unrecognized_parameter_parameter;
+static int ett_sctp_i_forward_tsn_chunk_flags;
+
+static int ett_sctp_fragments;
+static int ett_sctp_fragment;
+
+static int ett_sctp_tsn;
+static int ett_sctp_ack;
+static int ett_sctp_acked;
+static int ett_sctp_tsn_retransmission;
+static int ett_sctp_tsn_retransmitted_count;
+static int ett_sctp_tsn_retransmitted;
+
+static expert_field ei_sctp_sack_chunk_adv_rec_window_credit;
+static expert_field ei_sctp_nr_sack_chunk_number_tsns_gap_acked_100;
+static expert_field ei_sctp_parameter_length;
+static expert_field ei_sctp_bad_sctp_checksum;
+static expert_field ei_sctp_tsn_retransmitted_more_than_twice;
+static expert_field ei_sctp_parameter_padding;
+static expert_field ei_sctp_retransmitted_after_ack;
+static expert_field ei_sctp_nr_sack_chunk_number_tsns_nr_gap_acked_100;
+static expert_field ei_sctp_sack_chunk_gap_block_out_of_order;
+static expert_field ei_sctp_chunk_length_bad;
+static expert_field ei_sctp_tsn_retransmitted;
+static expert_field ei_sctp_sack_chunk_gap_block_malformed;
+static expert_field ei_sctp_sack_chunk_number_tsns_gap_acked_100;
WS_DLL_PUBLIC_DEF const value_string chunk_type_values[] = {
{ SCTP_DATA_CHUNK_ID, "DATA" },
@@ -388,14 +391,14 @@ WS_DLL_PUBLIC_DEF const value_string chunk_type_values[] = {
#define ASSOC_NOT_FOUND 5
/* Default values for preferences */
-static gboolean show_port_numbers = TRUE;
-static gint sctp_checksum = SCTP_CHECKSUM_NONE;
-static gboolean enable_tsn_analysis = TRUE;
-static gboolean enable_association_indexing = FALSE;
-static gboolean enable_ulp_dissection = TRUE;
-static gboolean use_reassembly = TRUE;
-static gboolean show_always_control_chunks = TRUE;
-static gboolean show_relative_tsns = TRUE;
+static bool show_port_numbers = true;
+static int sctp_checksum = SCTP_CHECKSUM_NONE;
+static bool enable_tsn_analysis = true;
+static bool enable_association_indexing;
+static bool enable_ulp_dissection = true;
+static bool use_reassembly = true;
+static bool show_always_control_chunks = true;
+static bool show_relative_tsns = true;
/* Data types and functions for generation/handling of chunk types for chunk statistics */
@@ -405,35 +408,36 @@ static const value_string chunk_enabled[] = {
{0, NULL}
};
typedef struct _type_field_t {
- guint type_id;
- gchar* type_name;
- guint type_enable;
+ unsigned type_id;
+ char* type_name;
+ unsigned type_enable;
} type_field_t;
-static type_field_t* type_fields = NULL;
-static guint num_type_fields = 0;
+static type_field_t* type_fields;
+static unsigned num_type_fields;
typedef struct _assoc_info_t {
- guint16 assoc_index;
- guint16 direction;
- gboolean vtag_reflected;
- guint16 sport;
- guint16 dport;
- guint32 verification_tag1;
- guint32 verification_tag2;
- guint32 initiate_tag;
+ uint16_t assoc_index;
+ uint16_t direction;
+ address saddr;
+ address daddr;
+ uint16_t sport;
+ uint16_t dport;
+ uint32_t verification_tag1;
+ uint32_t verification_tag2;
} assoc_info_t;
typedef struct _infodata_t {
- guint16 assoc_index;
- guint16 direction;
+ uint16_t assoc_index;
+ uint16_t direction;
} infodata_t;
-static wmem_list_t *assoc_info_list = NULL;
-static guint num_assocs = 0;
+static wmem_map_t *assoc_info_half_map;
+static wmem_map_t *assoc_info_map;
+static unsigned num_assocs;
UAT_CSTRING_CB_DEF(type_fields, type_name, type_field_t)
-UAT_VS_DEF(type_fields, type_enable, type_field_t, guint, 0, "Show")
+UAT_VS_DEF(type_fields, type_enable, type_field_t, unsigned, 0, "Show")
UAT_DEC_CB_DEF(type_fields, type_id, type_field_t)
static void *sctp_chunk_type_copy_cb(void* n, const void* o, size_t siz _U_)
@@ -459,13 +463,13 @@ sctp_chunk_type_update_cb(void *r, char **err)
char c;
if (rec->type_name == NULL) {
*err = g_strdup("Header name can't be empty");
- return FALSE;
+ return false;
}
g_strstrip(rec->type_name);
if (rec->type_name[0] == 0) {
*err = g_strdup("Header name can't be empty");
- return FALSE;
+ return false;
}
/* Check for invalid characters (to avoid asserting out when
@@ -474,240 +478,292 @@ sctp_chunk_type_update_cb(void *r, char **err)
c = proto_check_field_name(rec->type_name);
if (c) {
*err = ws_strdup_printf("Header name can't contain '%c'", c);
- return FALSE;
+ return false;
}
*err = NULL;
- return TRUE;
+ return true;
}
static dissector_handle_t sctp_handle;
static struct _sctp_info sctp_info;
-#define RETURN_DIRECTION(direction) \
- do { \
- /*ws_warning("Returning %d at %d: a-itag=0x%x, a-vtag1=0x%x, a-vtag2=0x%x, b-itag=0x%x, b-vtag1=0x%x, b-vtag2=0x%x", \
- direction, __LINE__, a->initiate_tag, a->verification_tag1, a->verification_tag2, b->initiate_tag, b->verification_tag1, b->verification_tag2);*/ \
- return direction; \
- } while (0)
-static gint sctp_assoc_vtag_cmp(const assoc_info_t *a, const assoc_info_t *b)
-{
- if (a == NULL || b == NULL)
- RETURN_DIRECTION(ASSOC_NOT_FOUND);
-
- if ((a->sport == b->sport) &&
- (a->dport == b->dport) &&
- (b->verification_tag2 != 0) &&
- (a->initiate_tag == b->verification_tag2) &&
- (a->initiate_tag == b->initiate_tag))
- RETURN_DIRECTION(FORWARD_STREAM);
-
- if ((a->sport == b->sport) &&
- (a->dport == b->dport) &&
- (a->verification_tag1 == b->verification_tag1) &&
- (a->initiate_tag == b->initiate_tag))
- RETURN_DIRECTION(FORWARD_STREAM);
-
- if ((a->sport == b->sport) &&
- (a->dport == b->dport) &&
- (a->verification_tag1 == b->verification_tag1) &&
- (a->verification_tag1 == 0 && a->initiate_tag != 0) &&
- (a->initiate_tag != b->initiate_tag ))
- RETURN_DIRECTION(ASSOC_NOT_FOUND); /* two INITs that belong to different assocs */
-
- /* assoc known*/
- if ((a->sport == b->sport) &&
- (a->dport == b->dport) &&
- (a->verification_tag1 == b->verification_tag1) &&
- ((a->verification_tag1 != 0 ||
- (b->verification_tag2 != 0))))
- RETURN_DIRECTION(FORWARD_STREAM);
-
- /* ABORT, vtag reflected */
- if ((a->sport == b->sport) &&
- (a->dport == b->dport) &&
- (a->verification_tag2 == b->verification_tag2) &&
- (a->verification_tag1 == 0 && b->verification_tag1 != 0))
- RETURN_DIRECTION(FORWARD_STREAM);
-
- if ((a->sport == b->dport) &&
- (a->dport == b->sport) &&
- (a->verification_tag1 == b->verification_tag2) &&
- (a->verification_tag1 != 0))
- RETURN_DIRECTION(BACKWARD_STREAM);
-
- if ((a->sport == b->dport) &&
- (a->dport == b->sport) &&
- (a->verification_tag2 == b->verification_tag1) &&
- (a->verification_tag2 != 0))
- RETURN_DIRECTION(BACKWARD_STREAM);
-
- if ((a->sport == b->dport) &&
- (a->dport == b->sport) &&
- (a->verification_tag1 == b->initiate_tag) &&
- (a->verification_tag2 == 0))
- RETURN_DIRECTION(BACKWARD_ADD_BACKWARD_VTAG);
-
- /* ABORT, vtag reflected */
- if ((a->sport == b->dport) &&
- (a->dport == b->sport) &&
- (a->verification_tag2 == b->verification_tag1) &&
- (a->verification_tag1 == 0 && b->verification_tag2 != 0))
- RETURN_DIRECTION(BACKWARD_STREAM);
-
- /*forward stream verification tag can be added*/
- if ((a->sport == b->sport) &&
- (a->dport == b->dport) &&
- (a->verification_tag1 != 0) &&
- (b->verification_tag1 == 0) &&
- (b->verification_tag2 !=0))
- RETURN_DIRECTION(FORWARD_ADD_FORWARD_VTAG);
-
- if ((a->sport == b->dport) &&
- (a->dport == b->sport) &&
- (a->verification_tag1 == b->verification_tag2) &&
- (b->verification_tag1 == 0))
- RETURN_DIRECTION(BACKWARD_ADD_FORWARD_VTAG);
-
- /*backward stream verification tag can be added */
- if ((a->sport == b->dport) &&
- (a->dport == b->sport) &&
- (a->verification_tag1 != 0) &&
- (b->verification_tag1 != 0) &&
- (b->verification_tag2 == 0))
- RETURN_DIRECTION(BACKWARD_ADD_BACKWARD_VTAG);
-
- RETURN_DIRECTION(ASSOC_NOT_FOUND);
-}
-#undef RETURN_DIRECTION
+static bool
+sctp_vtag_match(uint32_t vtag1, uint32_t vtag2)
+{
+ /* If zero (unknown) tags match anything. Nonzero tags must be the same. */
+ if (vtag1 != 0) {
+ return (vtag1 == vtag2 || vtag2 == 0);
+ }
+ return true;
+}
+
+static assoc_info_t*
+sctp_assoc_reverse(wmem_allocator_t *scope, const assoc_info_t *assoc)
+{
+ assoc_info_t *new_assoc;
+
+ new_assoc = wmem_new(scope, assoc_info_t);
+ new_assoc->assoc_index = assoc->assoc_index;
+ new_assoc->direction = (assoc->direction == 1) ? 2 : 1;
+ copy_address_shallow(&new_assoc->saddr, &assoc->daddr);
+ copy_address_shallow(&new_assoc->daddr, &assoc->saddr);
+ new_assoc->sport = assoc->dport;
+ new_assoc->dport = assoc->sport;
+ new_assoc->verification_tag1 = assoc->verification_tag2;
+ new_assoc->verification_tag2 = assoc->verification_tag1;
+
+ return new_assoc;
+}
+
+static unsigned
+sctp_assoc_half_hash(const void *key)
+{
+ const assoc_info_t *k = (const assoc_info_t *)key;
+
+ /* Add the ports so that the hash is the same regardless of direction */
+ return g_direct_hash(GUINT_TO_POINTER(k->sport + k->dport));
+}
+
+static unsigned
+sctp_assoc_hash(const void *key)
+{
+ const assoc_info_t *k = (const assoc_info_t *)key;
+
+ // When inserting in this map, we know we have both vtags.
+ // Hash via the first one (we expect vtag collisions will be low.)
+ // When looking up with a entry from a packet that only has one vtag,
+ // we'll reverse the temporary key as necessary.
+ return g_int_hash(&k->verification_tag1);
+}
+
+/* Association comparison strategy:
+ * 1. Ports MUST match.
+ * 2. Assume vtag collisions are rare compared to multihoming. Thus:
+ * 3. If we have already discovered the vtags on both sides (e.g., with an
+ * INIT ACK, which contains both sides) and the ports match, don't require
+ * address matches.
+ * 4. If we have two keys each with 1 matching vtag in the same direction (and
+ * the other vtag 0), don't require address matches; if there are new addresses
+ * assume it's multihoming.
+ * 5. However, if we have two keys each with 1 vtag (and the other tag 0)
+ * that are different but could be the two vtags of one association
+ * (e.g., two unmatched DATA chunks in the opposite direction, or an INIT
+ * and a DATA in the same direction) require address matching. Otherwise
+ * we'll make likely spurious matches.
+ * 6. Don't worry about odd possibilities like both sides of an association
+ * chosing the same vtag.
+ * 7. We ought to track additional addresses given in INIT, INIT ACK, ASCONF.
+ * If we do, we could have an option of more strict association matching
+ * that uses the addresses in all cases and is more similar to what SCTP
+ * stacks actually do. We'd have to store a list/map/set of known source
+ * and destinatiion addresses instead of just one each. This would fail in
+ * the case of multihoming and where we missed the configuration messages
+ * setting up multihoming.
+ */
+
+static gboolean
+sctp_assoc_half_equal(const void *key1, const void *key2)
+{
+ const assoc_info_t *a = (const assoc_info_t *)key1;
+ const assoc_info_t *b = (const assoc_info_t *)key2;
+
+ /* Matching for associations where for the entries already in the table
+ * only have one vtag, and have zero for the other direction. (For an
+ * new INIT ACK, we know both directions.)
+ */
+
+ if (a->sport == b->sport && a->dport == b->dport) {
+ // Forward match
+ if ((a->verification_tag1 == 0 || b->verification_tag1 == 0) &&
+ (a->verification_tag2 == 0 || b->verification_tag2 == 0)) {
+ // Possible INIT and DATA in the same direction, where we didn't get
+ // the INIT ACK. Call it a match if the addresses match.
+ if (addresses_equal(&a->saddr, &b->saddr) && addresses_equal(&a->daddr, &b->daddr)) {
+ return TRUE;
+ }
+ } else if (sctp_vtag_match(a->verification_tag1, b->verification_tag1) &&
+ sctp_vtag_match(a->verification_tag2, b->verification_tag2)) {
+ return TRUE;
+ }
+ }
+ if (a->sport == b->dport && a->dport == b->sport) {
+ // Reverse direction (not an else so we can handle identical ports)
+ if ((a->verification_tag1 == 0 || b->verification_tag2 == 0) &&
+ (a->verification_tag2 == 0 || b->verification_tag1 == 0)) {
+ // Possible two DATAs chunks in the opposite direction, where we
+ // didn't get the INIT ACK. Call it a match if the addresses match.
+ if (addresses_equal(&a->saddr, &b->daddr) && addresses_equal(&a->daddr, &b->saddr)) {
+ return TRUE;
+ }
+ } else if (sctp_vtag_match(a->verification_tag1, b->verification_tag2) &&
+ sctp_vtag_match(a->verification_tag2, b->verification_tag1)) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+static gboolean
+sctp_assoc_equal(const void *key1, const void *key2)
+{
+ const assoc_info_t *a = (const assoc_info_t *)key1;
+ const assoc_info_t *b = (const assoc_info_t *)key2;
+
+ /*
+ * Matching for associations where for the entries already in the map
+ * we know the vtags in each direction.
+ * We will not check addresses.
+ */
+
+ if (a->sport == b->sport && a->dport == b->dport) {
+ // Forward match
+ // ASSERTION: at least one of the verification tags must be nonzero.
+ if (sctp_vtag_match(a->verification_tag1, b->verification_tag1) &&
+ sctp_vtag_match(a->verification_tag2, b->verification_tag2)) {
+ return TRUE;
+ }
+ }
+ if (a->sport == b->dport && a->dport == b->sport) {
+ // Reverse direction (not an else so we can handle identical ports)
+ if (sctp_vtag_match(a->verification_tag1, b->verification_tag2) &&
+ sctp_vtag_match(a->verification_tag2, b->verification_tag1)) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
static infodata_t
-find_assoc_index(assoc_info_t* tmpinfo, gboolean visited)
+find_assoc_index(assoc_info_t* tmpinfo, packet_info *pinfo)
{
assoc_info_t *info = NULL;
- wmem_list_frame_t *elem;
- gboolean cmp = FALSE;
infodata_t inf;
inf.assoc_index = -1;
inf.direction = 1;
- if (assoc_info_list == NULL) {
- assoc_info_list = wmem_list_new(wmem_file_scope());
+ /* At least one of tmpinfo's vtag1 must be nonzero (both might be, if
+ * it's an INIT ACK.) Lookup in the proper direction(s).
+ */
+ if (tmpinfo->verification_tag1 != 0) {
+ info = (assoc_info_t*)wmem_map_lookup(assoc_info_map, tmpinfo);
+ if (info) {
+ inf.assoc_index = info->assoc_index;
+ inf.direction = info->direction;
+ return inf;
+ }
}
- for (elem = wmem_list_head(assoc_info_list); elem; elem = wmem_list_frame_next(elem))
- {
- info = (assoc_info_t*) wmem_list_frame_data(elem);
-
- if (!visited) {
- cmp = sctp_assoc_vtag_cmp(tmpinfo, info);
- if (cmp < ASSOC_NOT_FOUND) {
- switch (cmp)
- {
- case FORWARD_ADD_FORWARD_VTAG:
- case BACKWARD_ADD_FORWARD_VTAG:
- info->verification_tag1 = tmpinfo->verification_tag1;
- break;
- case BACKWARD_ADD_BACKWARD_VTAG:
- info->verification_tag2 = tmpinfo->verification_tag1;
- info->direction = 1;
- inf.assoc_index = info->assoc_index;
- inf.direction = 2;
- return inf;
- case BACKWARD_STREAM:
- inf.assoc_index = info->assoc_index;
- inf.direction = 2;
- return inf;
- }
- if (cmp == FORWARD_STREAM || cmp == FORWARD_ADD_FORWARD_VTAG) {
- info->direction = 1;
- } else {
- info->direction = 2;
- }
- inf.assoc_index = info->assoc_index;
- inf.direction = info->direction;
- return inf;
- }
- } else {
- if ((tmpinfo->initiate_tag != 0 && tmpinfo->initiate_tag == info->initiate_tag) ||
- (tmpinfo->verification_tag1 != 0 && tmpinfo->verification_tag1 == info->verification_tag1) ||
- (tmpinfo->verification_tag2 != 0 && tmpinfo->verification_tag2 == info->verification_tag2)) {
- inf.assoc_index = info->assoc_index;
- inf.direction = info->direction;
- return inf;
- } else if ((tmpinfo->verification_tag1 != 0 && tmpinfo->verification_tag1 == info->verification_tag2) ||
- (tmpinfo->verification_tag2 != 0 && tmpinfo->verification_tag2 == info->verification_tag1) ||
- (tmpinfo->verification_tag1 == 0 && tmpinfo->initiate_tag != 0 &&
- tmpinfo->initiate_tag == info->verification_tag1)) {
- inf.assoc_index = info->assoc_index;
- if (info->direction == 1)
- inf.direction = 2;
- else
- inf.direction = 1;
- return inf;
- }
+ if (tmpinfo->verification_tag2 != 0) {
+ info = sctp_assoc_reverse(pinfo->pool, tmpinfo);
+ info = (assoc_info_t*)wmem_map_lookup(assoc_info_map, info);
+ if (info) {
+ inf.assoc_index = info->assoc_index;
+ inf.direction = info->direction == 1 ? 2 : 1;
+ return inf;
}
}
- if (!elem && !visited) {
- info = wmem_new0(wmem_file_scope(), assoc_info_t);
- info->assoc_index = num_assocs;
- info->sport = tmpinfo->sport;
- info->dport = tmpinfo->dport;
- info->verification_tag1 = tmpinfo->verification_tag1;
- info->verification_tag2 = tmpinfo->verification_tag2;
- info->initiate_tag = tmpinfo->initiate_tag;
- num_assocs++;
- wmem_list_prepend(assoc_info_list, info);
+ info = (assoc_info_t*)wmem_map_lookup(assoc_info_half_map, tmpinfo);
+ if (info == NULL) {
+ if (!PINFO_FD_VISITED(pinfo)) {
+ info = wmem_new(wmem_file_scope(), assoc_info_t);
+ *info = *tmpinfo;
+ copy_address_wmem(wmem_file_scope(), &info->saddr, &tmpinfo->saddr);
+ copy_address_wmem(wmem_file_scope(), &info->daddr, &tmpinfo->daddr);
+ info->assoc_index = num_assocs++;
+ info->direction = 1;
+ inf.assoc_index = info->assoc_index;
+ if (info->verification_tag1 == 0 || info->verification_tag2 == 0) {
+ wmem_map_insert(assoc_info_half_map, info, info);
+ } else {
+ info->direction = 1;
+ wmem_map_insert(assoc_info_map, info, info);
+ info = sctp_assoc_reverse(wmem_file_scope(), info);
+ wmem_map_insert(assoc_info_map, info, info);
+ }
+ } else {
+ ws_info("association not found on second pass");
+ }
+ } else {
inf.assoc_index = info->assoc_index;
- inf.direction = 1;
+ /* Now figure out why we matched and fill in new information. */
+ if (info->sport == tmpinfo->dport &&
+ sctp_vtag_match(info->verification_tag1, tmpinfo->verification_tag1) &&
+ sctp_vtag_match(info->verification_tag2, tmpinfo->verification_tag2)) {
+ /* We already checked the addresses if needed when looking up in the map. */
+ if (info->verification_tag1 == 0) {
+ info->verification_tag1 = tmpinfo->verification_tag1;
+ }
+ if (info->verification_tag2 == 0) {
+ info->verification_tag2 = tmpinfo->verification_tag2;
+ }
+ } else if (sctp_vtag_match(info->verification_tag1, tmpinfo->verification_tag2) &&
+ sctp_vtag_match(info->verification_tag2, tmpinfo->verification_tag1)) {
+ /* We already checked the addresses if needed when looking up in the map. */
+ inf.direction = 2;
+ if (info->verification_tag1 == 0) {
+ info->verification_tag1 = tmpinfo->verification_tag2;
+ }
+ if (info->verification_tag2 == 0) {
+ info->verification_tag2 = tmpinfo->verification_tag1;
+ }
+ }
+ if (info->verification_tag1 != 0 && info->verification_tag2 != 0) {
+ DISSECTOR_ASSERT(wmem_map_remove(assoc_info_half_map, info) != NULL);
+ wmem_map_insert(assoc_info_map, info, info);
+ info = sctp_assoc_reverse(wmem_file_scope(), info);
+ wmem_map_insert(assoc_info_map, info, info);
+ }
}
return inf;
}
static void
-sctp_src_prompt(packet_info *pinfo, gchar *result)
+sctp_src_prompt(packet_info *pinfo, char *result)
{
- guint32 port = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hf_source_port, pinfo->curr_layer_num));
+ uint32_t port = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hf_source_port, pinfo->curr_layer_num));
snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "source (%s%u)", UTF8_RIGHTWARDS_ARROW, port);
}
-static gpointer
+static void *
sctp_src_value(packet_info *pinfo)
{
return p_get_proto_data(pinfo->pool, pinfo, hf_source_port, pinfo->curr_layer_num);
}
static void
-sctp_dst_prompt(packet_info *pinfo, gchar *result)
+sctp_dst_prompt(packet_info *pinfo, char *result)
{
- guint32 port = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hf_destination_port, pinfo->curr_layer_num));
+ uint32_t port = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hf_destination_port, pinfo->curr_layer_num));
snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "destination (%s%u)", UTF8_RIGHTWARDS_ARROW, port);
}
-static gpointer
+static void *
sctp_dst_value(packet_info *pinfo)
{
return p_get_proto_data(pinfo->pool, pinfo, hf_destination_port, pinfo->curr_layer_num);
}
static void
-sctp_both_prompt(packet_info *pinfo, gchar *result)
+sctp_both_prompt(packet_info *pinfo, char *result)
{
- guint32 srcport = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hf_source_port, pinfo->curr_layer_num)),
+ uint32_t srcport = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hf_source_port, pinfo->curr_layer_num)),
destport = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, hf_destination_port, pinfo->curr_layer_num));
snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "both (%u%s%u)", srcport, UTF8_LEFT_RIGHT_ARROW, destport);
}
static void
-sctp_ppi_prompt1(packet_info *pinfo _U_, gchar* result)
+sctp_ppi_prompt1(packet_info *pinfo _U_, char* result)
{
- guint32 ppid = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_sctp, 0));
+ uint32_t ppid = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_sctp, 0));
if (ppid == LAST_PPID) {
snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "PPID (none)");
@@ -717,9 +773,9 @@ sctp_ppi_prompt1(packet_info *pinfo _U_, gchar* result)
}
static void
-sctp_ppi_prompt2(packet_info *pinfo _U_, gchar* result)
+sctp_ppi_prompt2(packet_info *pinfo _U_, char* result)
{
- guint32 ppid = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_sctp, 1));
+ uint32_t ppid = GPOINTER_TO_UINT(p_get_proto_data(pinfo->pool, pinfo, proto_sctp, 1));
if (ppid == LAST_PPID) {
snprintf(result, MAX_DECODE_AS_PROMPT_LEN, "PPID (none)");
@@ -728,13 +784,13 @@ sctp_ppi_prompt2(packet_info *pinfo _U_, gchar* result)
}
}
-static gpointer
+static void *
sctp_ppi_value1(packet_info *pinfo)
{
return p_get_proto_data(pinfo->pool, pinfo, proto_sctp, 0);
}
-static gpointer
+static void *
sctp_ppi_value2(packet_info *pinfo)
{
return p_get_proto_data(pinfo->pool, pinfo, proto_sctp, 1);
@@ -848,8 +904,8 @@ sctp_endpoint_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, con
/* Take two "add" passes per packet, adding for each direction, ensures that all
packets are counted properly (even if address is sending to itself)
XXX - this could probably be done more efficiently inside endpoint_table */
- add_endpoint_table_data(hash, &sctphdr->ip_src, sctphdr->sport, TRUE, 1, pinfo->fd->pkt_len, &sctp_endpoint_dissector_info, ENDPOINT_SCTP);
- add_endpoint_table_data(hash, &sctphdr->ip_dst, sctphdr->dport, FALSE, 1, pinfo->fd->pkt_len, &sctp_endpoint_dissector_info, ENDPOINT_SCTP);
+ add_endpoint_table_data(hash, &sctphdr->ip_src, sctphdr->sport, true, 1, pinfo->fd->pkt_len, &sctp_endpoint_dissector_info, ENDPOINT_SCTP);
+ add_endpoint_table_data(hash, &sctphdr->ip_dst, sctphdr->dport, false, 1, pinfo->fd->pkt_len, &sctp_endpoint_dissector_info, ENDPOINT_SCTP);
return TAP_PACKET_REDRAW;
}
@@ -857,8 +913,8 @@ sctp_endpoint_packet(void *pit, packet_info *pinfo, epan_dissect_t *edt _U_, con
static unsigned int
sctp_adler32(tvbuff_t *tvb, unsigned int len)
{
- const guint8 *buf = tvb_get_ptr(tvb, 0, len);
- guint32 result = 1;
+ const uint8_t *buf = tvb_get_ptr(tvb, 0, len);
+ uint32_t result = 1;
result = update_adler32(result, buf, SOURCE_PORT_LENGTH + DESTINATION_PORT_LENGTH + VERIFICATION_TAG_LENGTH);
/* handle four 0 bytes as checksum */
@@ -868,13 +924,13 @@ sctp_adler32(tvbuff_t *tvb, unsigned int len)
return result;
}
-static guint32
+static uint32_t
sctp_crc32c(tvbuff_t *tvb, unsigned int len)
{
- const guint8 *buf = tvb_get_ptr(tvb, 0, len);
- guint32 crc32,
+ const uint8_t *buf = tvb_get_ptr(tvb, 0, len);
+ uint32_t crc32,
zero = 0;
- guint32 result;
+ uint32_t result;
/* CRC for header */
crc32 = crc32c_calculate_no_swap(buf, SOURCE_PORT_LENGTH + DESTINATION_PORT_LENGTH + VERIFICATION_TAG_LENGTH, CRC32C_PRELOAD);
@@ -896,30 +952,30 @@ sctp_crc32c(tvbuff_t *tvb, unsigned int len)
typedef struct _sctp_half_assoc_t sctp_half_assoc_t;
-static void dissect_parameter(tvbuff_t *, packet_info *, proto_tree *, proto_item *, gboolean, gboolean);
+static void dissect_parameter(tvbuff_t *, packet_info *, proto_tree *, proto_item *, bool, bool);
-static void dissect_parameters(tvbuff_t *, packet_info *, proto_tree *, proto_item *, gboolean);
+static void dissect_parameters(tvbuff_t *, packet_info *, proto_tree *, proto_item *, bool);
static void dissect_error_cause(tvbuff_t *, packet_info *, proto_tree *);
static void dissect_error_causes(tvbuff_t *, packet_info *, proto_tree *);
-static gboolean dissect_data_chunk(tvbuff_t*, guint16, packet_info*, proto_tree*, proto_tree*, proto_item*, proto_item*, sctp_half_assoc_t*, gboolean);
+static bool dissect_data_chunk(tvbuff_t*, uint16_t, packet_info*, proto_tree*, proto_tree*, proto_item*, proto_item*, sctp_half_assoc_t*, bool);
-static void dissect_sctp_packet(tvbuff_t *, packet_info *, proto_tree *, gboolean);
+static void dissect_sctp_packet(tvbuff_t *, packet_info *, proto_tree *, bool);
/* TSN ANALYSIS CODE */
struct _sctp_half_assoc_t {
- guint32 spt;
- guint32 dpt;
- guint32 vtag;
+ uint32_t spt;
+ uint32_t dpt;
+ uint32_t vtag;
- gboolean started;
+ bool started;
- guint32 first_tsn; /* start */
- guint32 cumm_ack; /* rel */
+ uint32_t first_tsn; /* start */
+ uint32_t cumm_ack; /* rel */
wmem_tree_t *tsns; /* sctp_tsn_t* by rel_tsn */
wmem_tree_t *tsn_acks; /* sctp_tsn_t* by ctsn_frame */
@@ -928,39 +984,39 @@ struct _sctp_half_assoc_t {
typedef struct _retransmit_t {
- guint32 framenum;
+ uint32_t framenum;
nstime_t ts;
struct _retransmit_t *next;
} retransmit_t;
typedef struct _sctp_tsn_t {
- guint32 tsn;
+ uint32_t tsn;
struct {
- guint32 framenum;
+ uint32_t framenum;
nstime_t ts;
} first_transmit;
struct {
- guint32 framenum;
+ uint32_t framenum;
nstime_t ts;
} ack;
retransmit_t *retransmit;
- guint32 retransmit_count;
+ uint32_t retransmit_count;
struct _sctp_tsn_t *next;
} sctp_tsn_t;
static wmem_tree_key_t*
-make_address_key(wmem_allocator_t *pool, guint32 spt, guint32 dpt, address *addr)
+make_address_key(wmem_allocator_t *pool, uint32_t spt, uint32_t dpt, address *addr)
{
wmem_tree_key_t *k = (wmem_tree_key_t *)wmem_alloc(pool, sizeof(wmem_tree_key_t)*6);
- k[0].length = 1; k[0].key = (guint32*)wmem_memdup(pool, &spt,sizeof(spt));
- k[1].length = 1; k[1].key = (guint32*)wmem_memdup(pool, &dpt,sizeof(dpt));
- k[2].length = 1; k[2].key = (guint32*)(void *)&(addr->type);
- k[3].length = 1; k[3].key = (guint32*)(void *)&(addr->len);
+ k[0].length = 1; k[0].key = (uint32_t*)wmem_memdup(pool, &spt,sizeof(spt));
+ k[1].length = 1; k[1].key = (uint32_t*)wmem_memdup(pool, &dpt,sizeof(dpt));
+ k[2].length = 1; k[2].key = (uint32_t*)(void *)&(addr->type);
+ k[3].length = 1; k[3].key = (uint32_t*)(void *)&(addr->len);
k[4].length = ((addr->len/4)+1);
- k[4].key = (guint32*)wmem_alloc0(pool, ((addr->len/4)+1)*4);
+ k[4].key = (uint32_t*)wmem_alloc0(pool, ((addr->len/4)+1)*4);
if (addr->len) memcpy(k[4].key, addr->data, addr->len);
k[5].length = 0; k[5].key = NULL;
@@ -969,13 +1025,13 @@ make_address_key(wmem_allocator_t *pool, guint32 spt, guint32 dpt, address *addr
}
static wmem_tree_key_t *
-make_dir_key(wmem_allocator_t *pool, guint32 spt, guint32 dpt, guint32 vtag)
+make_dir_key(wmem_allocator_t *pool, uint32_t spt, uint32_t dpt, uint32_t vtag)
{
wmem_tree_key_t *k = (wmem_tree_key_t *)wmem_alloc(pool, sizeof(wmem_tree_key_t)*4);
- k[0].length = 1; k[0].key = (guint32*)wmem_memdup(pool, &spt,sizeof(spt));
- k[1].length = 1; k[1].key = (guint32*)wmem_memdup(pool, &dpt,sizeof(dpt));
- k[2].length = 1; k[2].key = (guint32*)wmem_memdup(pool, &vtag,sizeof(vtag));
+ k[0].length = 1; k[0].key = (uint32_t*)wmem_memdup(pool, &spt,sizeof(spt));
+ k[1].length = 1; k[1].key = (uint32_t*)wmem_memdup(pool, &dpt,sizeof(dpt));
+ k[2].length = 1; k[2].key = (uint32_t*)wmem_memdup(pool, &vtag,sizeof(vtag));
k[3].length = 0; k[3].key = NULL;
return k;
@@ -987,7 +1043,7 @@ static wmem_tree_t *dirs_by_ptvtag; /* sctp_half_assoc_t* */
static wmem_tree_t *dirs_by_ptaddr; /* sctp_half_assoc_t**, it may contain a null pointer */
static sctp_half_assoc_t *
-get_half_assoc(packet_info *pinfo, guint32 spt, guint32 dpt, guint32 vtag)
+get_half_assoc(packet_info *pinfo, uint32_t spt, uint32_t dpt, uint32_t vtag)
{
sctp_half_assoc_t *ha;
sctp_half_assoc_t **hb;
@@ -1010,7 +1066,7 @@ get_half_assoc(packet_info *pinfo, guint32 spt, guint32 dpt, guint32 vtag)
ha->vtag = vtag;
ha->tsns = wmem_tree_new(wmem_file_scope());
ha->tsn_acks = wmem_tree_new(wmem_file_scope());
- ha->started = FALSE;
+ ha->started = false;
ha->first_tsn= 0;
ha->cumm_ack= 0;
@@ -1033,7 +1089,7 @@ get_half_assoc(packet_info *pinfo, guint32 spt, guint32 dpt, guint32 vtag)
*hb = NULL;
}
} else {
- /* we found no entry in the table: add one (using reversed ports and src addresss) so that it can be matched later */
+ /* we found no entry in the table: add one (using reversed ports and src addresses) so that it can be matched later */
*(hb = (sctp_half_assoc_t **)wmem_alloc(wmem_file_scope(), sizeof(void*))) = ha;
k = make_address_key(pinfo->pool, spt, dpt, &(pinfo->src));
wmem_tree_insert32_array(dirs_by_ptaddr, k, hb);
@@ -1049,7 +1105,7 @@ get_half_assoc(packet_info *pinfo, guint32 spt, guint32 dpt, guint32 vtag)
static void
tsn_tree(sctp_tsn_t *t, proto_item *tsn_item, packet_info *pinfo,
- tvbuff_t *tvb, guint32 framenum)
+ tvbuff_t *tvb, uint32_t framenum)
{
proto_item *pi;
proto_tree *pt;
@@ -1131,21 +1187,21 @@ tsn_tree(sctp_tsn_t *t, proto_item *tsn_item, packet_info *pinfo,
#define RELTSN(tsn) (((tsn) < h->first_tsn) ? (tsn + (0xffffffff - (h->first_tsn)) + 1) : (tsn - h->first_tsn))
-/* Returns TRUE if the tsn is a retransmission (we've seen it before), FALSE
+/* Returns true if the tsn is a retransmission (we've seen it before), false
* otherwise.
*/
-static gboolean
+static bool
sctp_tsn(packet_info *pinfo, tvbuff_t *tvb, proto_item *tsn_item,
- sctp_half_assoc_t *h, guint32 tsn)
+ sctp_half_assoc_t *h, uint32_t tsn)
{
sctp_tsn_t *t;
- guint32 framenum;
- guint32 reltsn;
- gboolean is_retransmission = FALSE;
+ uint32_t framenum;
+ uint32_t reltsn;
+ bool is_retransmission = false;
/* no half assoc? nothing to do!*/
if (!h)
- return(is_retransmission);
+ return is_retransmission;
framenum = pinfo->num;
@@ -1160,12 +1216,12 @@ sctp_tsn(packet_info *pinfo, tvbuff_t *tvb, proto_item *tsn_item,
* retransmission of that in frame 0.
*/
if (framenum == 0)
- return(is_retransmission);
+ return is_retransmission;
/* we have not seen any tsn yet in this half assoc set the ground */
if (! h->started) {
h->first_tsn = tsn;
- h->started = TRUE;
+ h->started = true;
}
@@ -1208,7 +1264,7 @@ sctp_tsn(packet_info *pinfo, tvbuff_t *tvb, proto_item *tsn_item,
tsn_tree(t, tsn_item, pinfo, tvb, framenum);
- return(is_retransmission);
+ return is_retransmission;
}
static void
@@ -1218,7 +1274,7 @@ ack_tree(sctp_tsn_t *t, proto_tree *acks_tree,
proto_item *pi;
proto_tree *pt;
nstime_t rtt;
- guint framenum = pinfo->num;
+ unsigned framenum = pinfo->num;
if ( t->ack.framenum == framenum ) {
nstime_delta( &rtt, &(t->ack.ts), &(t->first_transmit.ts) );
@@ -1238,10 +1294,10 @@ ack_tree(sctp_tsn_t *t, proto_tree *acks_tree,
static void
sctp_ack(packet_info *pinfo, tvbuff_t *tvb, proto_tree *acks_tree,
- sctp_half_assoc_t *h, guint32 reltsn)
+ sctp_half_assoc_t *h, uint32_t reltsn)
{
sctp_tsn_t *t;
- guint32 framenum;
+ uint32_t framenum;
if (!h || !h->peer)
@@ -1281,13 +1337,13 @@ sctp_ack(packet_info *pinfo, tvbuff_t *tvb, proto_tree *acks_tree,
#define RELTSNACK(tsn) (((tsn) < h->peer->first_tsn) ? ((tsn) + (0xffffffff - (h->peer->first_tsn)) + 1) : ((tsn) - h->peer->first_tsn))
static void
sctp_ack_block(packet_info *pinfo, sctp_half_assoc_t *h, tvbuff_t *tvb,
- proto_item *acks_tree, const guint32 *tsn_start_ptr,
- guint32 tsn_end)
+ proto_item *acks_tree, const uint32_t *tsn_start_ptr,
+ uint32_t tsn_end)
{
sctp_tsn_t *t;
- guint32 framenum;
- guint32 rel_start;
- guint32 rel_end;
+ uint32_t framenum;
+ uint32_t rel_start;
+ uint32_t rel_end;
if ( !h || !h->peer || ! h->peer->started )
@@ -1307,7 +1363,7 @@ sctp_ack_block(packet_info *pinfo, sctp_half_assoc_t *h, tvbuff_t *tvb,
if ((t = (sctp_tsn_t *)wmem_tree_lookup32(h->peer->tsn_acks, framenum))) {
for(;t;t = t->next) {
- guint32 tsn = t->tsn;
+ uint32_t tsn = t->tsn;
tsn -= h->peer->first_tsn;
@@ -1324,9 +1380,9 @@ sctp_ack_block(packet_info *pinfo, sctp_half_assoc_t *h, tvbuff_t *tvb,
h->peer->cumm_ack = rel_end + 1;
if (rel_start <= rel_end && rel_end - rel_start < 5000 ) {
- guint32 rel_tsn, i;
+ uint32_t rel_tsn, i;
for (i=0; i <= rel_end-rel_start; i++) {
- rel_tsn = (guint32) (i+rel_start);
+ rel_tsn = (uint32_t) (i+rel_start);
sctp_ack(pinfo, tvb, acks_tree, h, rel_tsn);
}
}
@@ -1342,7 +1398,7 @@ sctp_ack_block(packet_info *pinfo, sctp_half_assoc_t *h, tvbuff_t *tvb,
static void
dissect_heartbeat_info_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
- guint16 heartbeat_info_length;
+ uint16_t heartbeat_info_length;
heartbeat_info_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
if (heartbeat_info_length > 0)
@@ -1354,7 +1410,7 @@ dissect_heartbeat_info_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_
#define IPV4_ADDRESS_OFFSET PARAMETER_VALUE_OFFSET
static void
-dissect_ipv4_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item, proto_item *additional_item, gboolean dissecting_init_init_ack_chunk)
+dissect_ipv4_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item, proto_item *additional_item, bool dissecting_init_init_ack_chunk)
{
if (parameter_tree) {
proto_tree_add_item(parameter_tree, hf_ipv4_address, parameter_tvb, IPV4_ADDRESS_OFFSET, IPV4_ADDRESS_LENGTH, ENC_BIG_ENDIAN);
@@ -1366,7 +1422,7 @@ dissect_ipv4_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, prot
if (sctp_info.number_of_tvbs < MAXIMUM_NUMBER_OF_TVBS)
sctp_info.tvb[sctp_info.number_of_tvbs++] = parameter_tvb;
else
- sctp_info.incomplete = TRUE;
+ sctp_info.incomplete = true;
}
}
@@ -1374,7 +1430,7 @@ dissect_ipv4_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, prot
#define IPV6_ADDRESS_OFFSET PARAMETER_VALUE_OFFSET
static void
-dissect_ipv6_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item, proto_item *additional_item, gboolean dissecting_init_init_ack_chunk)
+dissect_ipv6_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item, proto_item *additional_item, bool dissecting_init_init_ack_chunk)
{
if (parameter_tree) {
proto_tree_add_item(parameter_tree, hf_ipv6_address, parameter_tvb, IPV6_ADDRESS_OFFSET, IPV6_ADDRESS_LENGTH, ENC_NA);
@@ -1386,7 +1442,7 @@ dissect_ipv6_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, prot
if (sctp_info.number_of_tvbs < MAXIMUM_NUMBER_OF_TVBS)
sctp_info.tvb[sctp_info.number_of_tvbs++] = parameter_tvb;
else
- sctp_info.incomplete = TRUE;
+ sctp_info.incomplete = true;
}
}
@@ -1395,7 +1451,7 @@ dissect_ipv6_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, prot
static void
dissect_state_cookie_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
- guint16 state_cookie_length;
+ uint16_t state_cookie_length;
state_cookie_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
if (state_cookie_length > 0)
@@ -1408,7 +1464,7 @@ static void
dissect_unrecognized_parameters_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *parameter_tree)
{
/* FIXME: Does it contain one or more parameters? */
- dissect_parameter(tvb_new_subset_remaining(parameter_tvb, PARAMETER_VALUE_OFFSET), pinfo, parameter_tree, NULL, FALSE, FALSE);
+ dissect_parameter(tvb_new_subset_remaining(parameter_tvb, PARAMETER_VALUE_OFFSET), pinfo, parameter_tree, NULL, false, false);
}
#define COOKIE_PRESERVATIVE_PARAMETER_INCR_LENGTH 4
@@ -1426,8 +1482,8 @@ dissect_cookie_preservative_parameter(tvbuff_t *parameter_tvb, proto_tree *param
static void
dissect_hostname_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item, proto_item *additional_item)
{
- gchar *hostname;
- guint16 hostname_length;
+ char *hostname;
+ uint16_t hostname_length;
hostname_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
proto_tree_add_item_ret_display_string(parameter_tree, hf_hostname, parameter_tvb, HOSTNAME_OFFSET, hostname_length, ENC_ASCII, wmem_packet_scope(), &hostname);
@@ -1455,8 +1511,8 @@ static const value_string address_types_values[] = {
static void
dissect_supported_address_types_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
- guint16 addr_type, number_of_addr_types, addr_type_number;
- guint offset;
+ uint16_t addr_type, number_of_addr_types, addr_type_number;
+ unsigned offset;
number_of_addr_types = (tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH)
/ SUPPORTED_ADDRESS_TYPE_PARAMETER_ADDRESS_TYPE_LENGTH;
@@ -1497,7 +1553,7 @@ dissect_supported_address_types_parameter(tvbuff_t *parameter_tvb, proto_tree *p
static void
dissect_outgoing_ssn_reset_request_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item _U_)
{
- guint length, number_of_sids, sid_number, sid_offset;
+ unsigned length, number_of_sids, sid_number, sid_offset;
proto_tree_add_item(parameter_tree, hf_stream_reset_req_seq_nr, parameter_tvb, STREAM_RESET_REQ_SEQ_NR_OFFSET, STREAM_RESET_SEQ_NR_LENGTH, ENC_BIG_ENDIAN);
proto_tree_add_item(parameter_tree, hf_stream_reset_rsp_seq_nr, parameter_tvb, STREAM_RESET_REQ_RSP_SEQ_NR_OFFSET, STREAM_RESET_SEQ_NR_LENGTH, ENC_BIG_ENDIAN);
@@ -1517,7 +1573,7 @@ dissect_outgoing_ssn_reset_request_parameter(tvbuff_t *parameter_tvb, proto_tree
static void
dissect_incoming_ssn_reset_request_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item _U_)
{
- guint length, number_of_sids, sid_number, sid_offset;
+ unsigned length, number_of_sids, sid_number, sid_offset;
proto_tree_add_item(parameter_tree, hf_stream_reset_req_seq_nr, parameter_tvb, STREAM_RESET_REQ_SEQ_NR_OFFSET, STREAM_RESET_SEQ_NR_LENGTH, ENC_BIG_ENDIAN);
@@ -1564,7 +1620,7 @@ static const value_string stream_reset_result_values[] = {
static void
dissect_re_configuration_response_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item _U_)
{
- guint length;
+ unsigned length;
length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET);
@@ -1587,7 +1643,7 @@ dissect_re_configuration_response_parameter(tvbuff_t *parameter_tvb, proto_tree
static void
dissect_add_outgoing_streams_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item _U_)
{
- /* guint length; */
+ /* unsigned length; */
/* length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET); */
@@ -1607,7 +1663,7 @@ dissect_add_outgoing_streams_parameter(tvbuff_t *parameter_tvb, proto_tree *para
static void
dissect_add_incoming_streams_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item _U_)
{
- /* guint length; */
+ /* unsigned length; */
/* length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET); */
@@ -1641,7 +1697,7 @@ dissect_zero_checksum_acceptable_parameter(tvbuff_t *parameter_tvb, proto_tree *
static void
dissect_random_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree)
{
- gint32 number_length;
+ int32_t number_length;
number_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
if (number_length > 0)
@@ -1651,14 +1707,14 @@ dissect_random_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree)
static void
dissect_chunks_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
- guint16 number_of_chunks;
- guint16 chunk_number, offset;
+ uint16_t number_of_chunks;
+ uint16_t chunk_number, offset;
proto_item_append_text(parameter_item, " (Chunk types to be authenticated: ");
number_of_chunks = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
for(chunk_number = 0, offset = PARAMETER_VALUE_OFFSET; chunk_number < number_of_chunks; chunk_number++, offset += CHUNK_TYPE_LENGTH) {
proto_tree_add_item(parameter_tree, hf_chunks_to_auth, parameter_tvb, offset, CHUNK_TYPE_LENGTH, ENC_BIG_ENDIAN);
- proto_item_append_text(parameter_item, "%s", val_to_str_const(tvb_get_guint8(parameter_tvb, offset), chunk_type_values, "Unknown"));
+ proto_item_append_text(parameter_item, "%s", val_to_str_const(tvb_get_uint8(parameter_tvb, offset), chunk_type_values, "Unknown"));
if (chunk_number < (number_of_chunks - 1))
proto_item_append_text(parameter_item, ", ");
}
@@ -1677,8 +1733,8 @@ static const value_string hmac_id_values[] = {
static void
dissect_hmac_algo_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
- guint16 number_of_ids;
- guint16 id_number, offset;
+ uint16_t number_of_ids;
+ uint16_t id_number, offset;
proto_item_append_text(parameter_item, " (Supported HMACs: ");
number_of_ids = (tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH) / HMAC_ID_LENGTH;
@@ -1694,14 +1750,14 @@ dissect_hmac_algo_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree,
static void
dissect_supported_extensions_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
- guint16 number_of_types;
- guint16 type_number, offset;
+ uint16_t number_of_types;
+ uint16_t type_number, offset;
proto_item_append_text(parameter_item, " (Supported types: ");
number_of_types = (tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH) / CHUNK_TYPE_LENGTH;
for(type_number = 0, offset = PARAMETER_VALUE_OFFSET; type_number < number_of_types; type_number++, offset += CHUNK_TYPE_LENGTH) {
proto_tree_add_item(parameter_tree, hf_supported_chunk_type, parameter_tvb, offset, CHUNK_TYPE_LENGTH, ENC_BIG_ENDIAN);
- proto_item_append_text(parameter_item, "%s", val_to_str_const(tvb_get_guint8(parameter_tvb, offset), chunk_type_values, "Unknown"));
+ proto_item_append_text(parameter_item, "%s", val_to_str_const(tvb_get_uint8(parameter_tvb, offset), chunk_type_values, "Unknown"));
if (type_number < (number_of_types - 1))
proto_item_append_text(parameter_item, ", ");
}
@@ -1721,7 +1777,7 @@ static void
// NOLINTNEXTLINE(misc-no-recursion)
dissect_add_ip_address_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *parameter_tree, proto_item *parameter_item)
{
- guint16 address_length;
+ uint16_t address_length;
tvbuff_t *address_tvb;
address_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH - CORRELATION_ID_LENGTH;
@@ -1731,7 +1787,7 @@ dissect_add_ip_address_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, pr
MIN(address_length, tvb_captured_length_remaining(parameter_tvb, ADDRESS_PARAMETER_OFFSET)),
MIN(address_length, tvb_reported_length_remaining(parameter_tvb, ADDRESS_PARAMETER_OFFSET)));
proto_item_append_text(parameter_item, " (Address: ");
- dissect_parameter(address_tvb, pinfo, parameter_tree, parameter_item, FALSE, FALSE);
+ dissect_parameter(address_tvb, pinfo, parameter_tree, parameter_item, false, false);
proto_item_append_text(parameter_item, ", correlation ID: %u)", tvb_get_ntohl(parameter_tvb, CORRELATION_ID_OFFSET));
}
@@ -1739,7 +1795,7 @@ static void
// NOLINTNEXTLINE(misc-no-recursion)
dissect_del_ip_address_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *parameter_tree, proto_item *parameter_item)
{
- guint16 address_length;
+ uint16_t address_length;
tvbuff_t *address_tvb;
address_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH - CORRELATION_ID_LENGTH;
@@ -1749,7 +1805,7 @@ dissect_del_ip_address_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, pr
MIN(address_length, tvb_captured_length_remaining(parameter_tvb, ADDRESS_PARAMETER_OFFSET)),
MIN(address_length, tvb_reported_length_remaining(parameter_tvb, ADDRESS_PARAMETER_OFFSET)));
proto_item_append_text(parameter_item, " (Address: ");
- dissect_parameter(address_tvb, pinfo, parameter_tree, parameter_item, FALSE, FALSE);
+ dissect_parameter(address_tvb, pinfo, parameter_tree, parameter_item, false, false);
proto_item_append_text(parameter_item, ", correlation ID: %u)", tvb_get_ntohl(parameter_tvb, CORRELATION_ID_OFFSET));
}
@@ -1759,7 +1815,7 @@ static void
// NOLINTNEXTLINE(misc-no-recursion)
dissect_error_cause_indication_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *parameter_tree)
{
- guint16 causes_length;
+ uint16_t causes_length;
tvbuff_t *causes_tvb;
proto_tree_add_item(parameter_tree, hf_correlation_id, parameter_tvb, CORRELATION_ID_OFFSET, CORRELATION_ID_LENGTH, ENC_BIG_ENDIAN);
@@ -1774,7 +1830,7 @@ static void
// NOLINTNEXTLINE(misc-no-recursion)
dissect_set_primary_address_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo, proto_tree *parameter_tree, proto_item *parameter_item)
{
- guint16 address_length;
+ uint16_t address_length;
tvbuff_t *address_tvb;
address_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH - CORRELATION_ID_LENGTH;
@@ -1784,7 +1840,7 @@ dissect_set_primary_address_parameter(tvbuff_t *parameter_tvb, packet_info *pinf
MIN(address_length, tvb_captured_length_remaining(parameter_tvb, ADDRESS_PARAMETER_OFFSET)),
MIN(address_length, tvb_reported_length_remaining(parameter_tvb, ADDRESS_PARAMETER_OFFSET)));
proto_item_append_text(parameter_item, " (Address: ");
- dissect_parameter(address_tvb, pinfo, parameter_tree, parameter_item, FALSE, FALSE);
+ dissect_parameter(address_tvb, pinfo, parameter_tree, parameter_item, false, false);
proto_item_append_text(parameter_item, ", correlation ID: %u)", tvb_get_ntohl(parameter_tvb, CORRELATION_ID_OFFSET));
}
@@ -1808,7 +1864,7 @@ dissect_adap_indication_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter
static void
dissect_unknown_parameter(tvbuff_t *parameter_tvb, proto_tree *parameter_tree, proto_item *parameter_item)
{
- guint16 type, parameter_value_length;
+ uint16_t type, parameter_value_length;
type = tvb_get_ntohs(parameter_tvb, PARAMETER_TYPE_OFFSET);
parameter_value_length = tvb_get_ntohs(parameter_tvb, PARAMETER_LENGTH_OFFSET) - PARAMETER_HEADER_LENGTH;
@@ -1894,10 +1950,10 @@ static void
// NOLINTNEXTLINE(misc-no-recursion)
dissect_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo,
proto_tree *chunk_tree, proto_item *additional_item,
- gboolean dissecting_init_init_ack_chunk,
- gboolean final_parameter)
+ bool dissecting_init_init_ack_chunk,
+ bool final_parameter)
{
- guint16 type, length, padding_length, reported_length;
+ uint16_t type, length, padding_length, reported_length;
proto_item *parameter_item, *type_item;
proto_tree *parameter_tree, *type_tree;
@@ -2030,11 +2086,11 @@ dissect_parameter(tvbuff_t *parameter_tvb, packet_info *pinfo,
static void
// NOLINTNEXTLINE(misc-no-recursion)
-dissect_parameters(tvbuff_t *parameters_tvb, packet_info *pinfo, proto_tree *tree, proto_item *additional_item, gboolean dissecting_init_init_ack_chunk)
+dissect_parameters(tvbuff_t *parameters_tvb, packet_info *pinfo, proto_tree *tree, proto_item *additional_item, bool dissecting_init_init_ack_chunk)
{
- gint offset, length, total_length, remaining_length;
+ int offset, length, total_length, remaining_length;
tvbuff_t *parameter_tvb;
- gboolean final_parameter;
+ bool final_parameter;
offset = 0;
remaining_length = tvb_reported_length_remaining(parameters_tvb, offset);
@@ -2056,9 +2112,9 @@ dissect_parameters(tvbuff_t *parameters_tvb, packet_info *pinfo, proto_tree *tre
offset += total_length;
remaining_length = tvb_reported_length_remaining(parameters_tvb, offset);
if (remaining_length > 0) {
- final_parameter = FALSE;
+ final_parameter = false;
} else {
- final_parameter = TRUE;
+ final_parameter = true;
}
dissect_parameter(parameter_tvb, pinfo, tree, additional_item, dissecting_init_init_ack_chunk, final_parameter);
}
@@ -2103,8 +2159,8 @@ dissect_invalid_stream_identifier_cause(tvbuff_t *cause_tvb, proto_tree *cause_t
static void
dissect_missing_mandatory_parameters_cause(tvbuff_t *cause_tvb, proto_tree *cause_tree)
{
- guint32 number_of_missing_parameters, missing_parameter_number;
- guint offset;
+ uint32_t number_of_missing_parameters, missing_parameter_number;
+ unsigned offset;
number_of_missing_parameters = tvb_get_ntohl(cause_tvb, CAUSE_NUMBER_OF_MISSING_PARAMETERS_OFFSET);
proto_tree_add_item(cause_tree, hf_cause_number_of_missing_parameters, cause_tvb, CAUSE_NUMBER_OF_MISSING_PARAMETERS_OFFSET, CAUSE_NUMBER_OF_MISSING_PARAMETERS_LENGTH, ENC_BIG_ENDIAN);
@@ -2134,33 +2190,33 @@ static void
// NOLINTNEXTLINE(misc-no-recursion)
dissect_unresolvable_address_cause(tvbuff_t *cause_tvb, packet_info *pinfo, proto_tree *cause_tree, proto_item *cause_item)
{
- guint16 parameter_length;
+ uint16_t parameter_length;
tvbuff_t *parameter_tvb;
parameter_length = tvb_get_ntohs(cause_tvb, CAUSE_LENGTH_OFFSET) - CAUSE_HEADER_LENGTH;
parameter_tvb = tvb_new_subset_length_caplen(cause_tvb, CAUSE_INFO_OFFSET,
MIN(parameter_length, tvb_captured_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)),
MIN(parameter_length, tvb_reported_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)));
- dissect_parameter(parameter_tvb, pinfo, cause_tree, cause_item, FALSE, TRUE);
+ dissect_parameter(parameter_tvb, pinfo, cause_tree, cause_item, false, true);
}
-static gboolean
-dissect_sctp_chunk(tvbuff_t *chunk_tvb, packet_info *pinfo, proto_tree *tree, proto_tree *sctp_tree, sctp_half_assoc_t *assoc, gboolean useinfo);
+static bool
+dissect_sctp_chunk(tvbuff_t *chunk_tvb, packet_info *pinfo, proto_tree *tree, proto_tree *sctp_tree, sctp_half_assoc_t *assoc, bool useinfo);
static void
// NOLINTNEXTLINE(misc-no-recursion)
dissect_unrecognized_chunk_type_cause(tvbuff_t *cause_tvb, packet_info *pinfo, proto_tree *cause_tree, proto_item *cause_item)
{
- guint16 chunk_length;
- guint8 unrecognized_type;
+ uint16_t chunk_length;
+ uint8_t unrecognized_type;
tvbuff_t *unrecognized_chunk_tvb;
chunk_length = tvb_get_ntohs(cause_tvb, CAUSE_LENGTH_OFFSET) - CAUSE_HEADER_LENGTH;
unrecognized_chunk_tvb = tvb_new_subset_length_caplen(cause_tvb, CAUSE_INFO_OFFSET,
MIN(chunk_length, tvb_captured_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)),
MIN(chunk_length, tvb_reported_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)));
- dissect_sctp_chunk(unrecognized_chunk_tvb, pinfo, cause_tree,cause_tree, NULL, FALSE);
- unrecognized_type = tvb_get_guint8(unrecognized_chunk_tvb, CHUNK_TYPE_OFFSET);
+ dissect_sctp_chunk(unrecognized_chunk_tvb, pinfo, cause_tree,cause_tree, NULL, false);
+ unrecognized_type = tvb_get_uint8(unrecognized_chunk_tvb, CHUNK_TYPE_OFFSET);
proto_item_append_text(cause_item, " (Type: %u (%s))", unrecognized_type, val_to_str_const(unrecognized_type, chunk_type_values, "unknown"));
}
@@ -2173,7 +2229,7 @@ static void
// NOLINTNEXTLINE(misc-no-recursion)
dissect_unrecognized_parameters_cause(tvbuff_t *cause_tvb, packet_info *pinfo, proto_tree *cause_tree)
{
- guint16 cause_info_length;
+ uint16_t cause_info_length;
tvbuff_t *unrecognized_parameters_tvb;
cause_info_length = tvb_get_ntohs(cause_tvb, CAUSE_LENGTH_OFFSET) - CAUSE_HEADER_LENGTH;
@@ -2181,7 +2237,7 @@ dissect_unrecognized_parameters_cause(tvbuff_t *cause_tvb, packet_info *pinfo, p
unrecognized_parameters_tvb = tvb_new_subset_length_caplen(cause_tvb, CAUSE_INFO_OFFSET,
MIN(cause_info_length, tvb_captured_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)),
MIN(cause_info_length, tvb_reported_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)));
- dissect_parameters(unrecognized_parameters_tvb, pinfo, cause_tree, NULL, FALSE);
+ dissect_parameters(unrecognized_parameters_tvb, pinfo, cause_tree, NULL, false);
}
#define CAUSE_TSN_LENGTH 4
@@ -2203,7 +2259,7 @@ static void
// NOLINTNEXTLINE(misc-no-recursion)
dissect_restart_with_new_address_cause(tvbuff_t *cause_tvb, packet_info *pinfo, proto_tree *cause_tree, proto_item *cause_item)
{
- guint16 cause_info_length;
+ uint16_t cause_info_length;
tvbuff_t *parameter_tvb;
cause_info_length = tvb_get_ntohs(cause_tvb, CAUSE_LENGTH_OFFSET) - CAUSE_HEADER_LENGTH;
@@ -2211,14 +2267,14 @@ dissect_restart_with_new_address_cause(tvbuff_t *cause_tvb, packet_info *pinfo,
MIN(cause_info_length, tvb_captured_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)),
MIN(cause_info_length, tvb_reported_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)));
proto_item_append_text(cause_item, " (New addresses: ");
- dissect_parameters(parameter_tvb, pinfo, cause_tree, cause_item, FALSE);
+ dissect_parameters(parameter_tvb, pinfo, cause_tree, cause_item, false);
proto_item_append_text(cause_item, ")");
}
static void
dissect_user_initiated_abort_cause(tvbuff_t *cause_tvb, proto_tree *cause_tree)
{
- guint16 cause_info_length;
+ uint16_t cause_info_length;
cause_info_length = tvb_get_ntohs(cause_tvb, CAUSE_LENGTH_OFFSET) - CAUSE_HEADER_LENGTH;
if (cause_info_length > 0)
@@ -2228,7 +2284,7 @@ dissect_user_initiated_abort_cause(tvbuff_t *cause_tvb, proto_tree *cause_tree)
static void
dissect_protocol_violation_cause(tvbuff_t *cause_tvb, proto_tree *cause_tree)
{
- guint16 cause_info_length;
+ uint16_t cause_info_length;
cause_info_length = tvb_get_ntohs(cause_tvb, CAUSE_LENGTH_OFFSET) - CAUSE_HEADER_LENGTH;
if (cause_info_length > 0)
@@ -2239,7 +2295,7 @@ static void
// NOLINTNEXTLINE(misc-no-recursion)
dissect_delete_last_address_cause(tvbuff_t *cause_tvb, packet_info *pinfo, proto_tree *cause_tree, proto_item *cause_item)
{
- guint16 cause_info_length;
+ uint16_t cause_info_length;
tvbuff_t *parameter_tvb;
cause_info_length = tvb_get_ntohs(cause_tvb, CAUSE_LENGTH_OFFSET) - CAUSE_HEADER_LENGTH;
@@ -2247,7 +2303,7 @@ dissect_delete_last_address_cause(tvbuff_t *cause_tvb, packet_info *pinfo, proto
MIN(cause_info_length, tvb_captured_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)),
MIN(cause_info_length, tvb_reported_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)));
proto_item_append_text(cause_item, " (Last address: ");
- dissect_parameter(parameter_tvb, pinfo, cause_tree, cause_item, FALSE, FALSE);
+ dissect_parameter(parameter_tvb, pinfo, cause_tree, cause_item, false, false);
proto_item_append_text(cause_item, ")");
}
@@ -2255,21 +2311,21 @@ static void
// NOLINTNEXTLINE(misc-no-recursion)
dissect_resource_outage_cause(tvbuff_t *cause_tvb, packet_info *pinfo, proto_tree *cause_tree)
{
- guint16 cause_info_length;
+ uint16_t cause_info_length;
tvbuff_t *parameter_tvb;
cause_info_length = tvb_get_ntohs(cause_tvb, CAUSE_LENGTH_OFFSET) - CAUSE_HEADER_LENGTH;
parameter_tvb = tvb_new_subset_length_caplen(cause_tvb, CAUSE_INFO_OFFSET,
MIN(cause_info_length, tvb_captured_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)),
MIN(cause_info_length, tvb_reported_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)));
- dissect_parameter(parameter_tvb, pinfo, cause_tree, NULL, FALSE, FALSE);
+ dissect_parameter(parameter_tvb, pinfo, cause_tree, NULL, false, false);
}
static void
// NOLINTNEXTLINE(misc-no-recursion)
dissect_delete_source_address_cause(tvbuff_t *cause_tvb, packet_info *pinfo, proto_tree *cause_tree, proto_item *cause_item)
{
- guint16 cause_info_length;
+ uint16_t cause_info_length;
tvbuff_t *parameter_tvb;
cause_info_length = tvb_get_ntohs(cause_tvb, CAUSE_LENGTH_OFFSET) - CAUSE_HEADER_LENGTH;
@@ -2277,7 +2333,7 @@ dissect_delete_source_address_cause(tvbuff_t *cause_tvb, packet_info *pinfo, pro
MIN(cause_info_length, tvb_captured_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)),
MIN(cause_info_length, tvb_reported_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)));
proto_item_append_text(cause_item, " (Deleted address: ");
- dissect_parameter(parameter_tvb, pinfo, cause_tree, cause_item, FALSE, FALSE);
+ dissect_parameter(parameter_tvb, pinfo, cause_tree, cause_item, false, false);
proto_item_append_text(cause_item, ")");
}
@@ -2285,14 +2341,14 @@ static void
// NOLINTNEXTLINE(misc-no-recursion)
dissect_request_refused_cause(tvbuff_t *cause_tvb, packet_info *pinfo, proto_tree *cause_tree)
{
- guint16 cause_info_length;
+ uint16_t cause_info_length;
tvbuff_t *parameter_tvb;
cause_info_length = tvb_get_ntohs(cause_tvb, CAUSE_LENGTH_OFFSET) - CAUSE_HEADER_LENGTH;
parameter_tvb = tvb_new_subset_length_caplen(cause_tvb, CAUSE_INFO_OFFSET,
MIN(cause_info_length, tvb_captured_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)),
MIN(cause_info_length, tvb_reported_length_remaining(cause_tvb, CAUSE_INFO_OFFSET)));
- dissect_parameter(parameter_tvb, pinfo, cause_tree, NULL, FALSE, FALSE);
+ dissect_parameter(parameter_tvb, pinfo, cause_tree, NULL, false, false);
}
static void
@@ -2304,7 +2360,7 @@ dissect_unsupported_hmac_id_cause(tvbuff_t *cause_tvb, packet_info *pinfo _U_, p
static void
dissect_unknown_cause(tvbuff_t *cause_tvb, proto_tree *cause_tree, proto_item *cause_item)
{
- guint16 cause_info_length;
+ uint16_t cause_info_length;
cause_info_length = tvb_get_ntohs(cause_tvb, CAUSE_LENGTH_OFFSET) - CAUSE_HEADER_LENGTH;
if (cause_info_length > 0)
@@ -2359,7 +2415,7 @@ static void
// NOLINTNEXTLINE(misc-no-recursion)
dissect_error_cause(tvbuff_t *cause_tvb, packet_info *pinfo, proto_tree *chunk_tree)
{
- guint16 code, length, padding_length;
+ uint16_t code, length, padding_length;
proto_item *cause_item;
proto_tree *cause_tree;
@@ -2444,7 +2500,7 @@ static void
// NOLINTNEXTLINE(misc-no-recursion)
dissect_error_causes(tvbuff_t *causes_tvb, packet_info *pinfo, proto_tree *tree)
{
- gint offset, length, total_length, remaining_length;
+ int offset, length, total_length, remaining_length;
tvbuff_t *cause_tvb;
offset = 0;
@@ -2472,13 +2528,13 @@ dissect_error_causes(tvbuff_t *causes_tvb, packet_info *pinfo, proto_tree *tree)
* Code to actually dissect the packets
*/
-static gboolean try_heuristic_first = FALSE;
+static bool try_heuristic_first;
-static gboolean
-dissect_payload(tvbuff_t *payload_tvb, packet_info *pinfo, proto_tree *tree, guint32 ppi)
+static bool
+dissect_payload(tvbuff_t *payload_tvb, packet_info *pinfo, proto_tree *tree, uint32_t ppi)
{
- guint32 low_port, high_port;
- gboolean try_ppi, try_low_port, try_high_port;
+ uint32_t low_port, high_port;
+ bool try_ppi, try_low_port, try_high_port;
heur_dtbl_entry_t *hdtbl_entry;
if (enable_ulp_dissection) {
@@ -2493,44 +2549,44 @@ dissect_payload(tvbuff_t *payload_tvb, packet_info *pinfo, proto_tree *tree, gui
high_port = pinfo->destport;
}
- try_ppi = FALSE;
+ try_ppi = false;
if (dissector_is_uint_changed(sctp_ppi_dissector_table, ppi)) {
- if (dissector_try_uint_new(sctp_ppi_dissector_table, ppi, payload_tvb, pinfo, tree, TRUE, GUINT_TO_POINTER(ppi))) {
- return TRUE;
+ if (dissector_try_uint_new(sctp_ppi_dissector_table, ppi, payload_tvb, pinfo, tree, true, GUINT_TO_POINTER(ppi))) {
+ return true;
}
} else {
/* The default; try it later */
- try_ppi = TRUE;
+ try_ppi = true;
}
- try_low_port = FALSE;
+ try_low_port = false;
if (low_port != 0) {
if (dissector_is_uint_changed(sctp_port_dissector_table, low_port)) {
- if (dissector_try_uint_new(sctp_port_dissector_table, low_port, payload_tvb, pinfo, tree, TRUE, GUINT_TO_POINTER(ppi))) {
- return TRUE;
+ if (dissector_try_uint_new(sctp_port_dissector_table, low_port, payload_tvb, pinfo, tree, true, GUINT_TO_POINTER(ppi))) {
+ return true;
}
} else {
/* The default; try it later */
- try_low_port = TRUE;
+ try_low_port = true;
}
}
- try_high_port = FALSE;
+ try_high_port = false;
if (high_port != 0) {
if (dissector_is_uint_changed(sctp_port_dissector_table, high_port)) {
- if (dissector_try_uint_new(sctp_port_dissector_table, high_port, payload_tvb, pinfo, tree, TRUE, GUINT_TO_POINTER(ppi))) {
- return TRUE;
+ if (dissector_try_uint_new(sctp_port_dissector_table, high_port, payload_tvb, pinfo, tree, true, GUINT_TO_POINTER(ppi))) {
+ return true;
}
} else {
/* The default; try it later */
- try_high_port = TRUE;
+ try_high_port = true;
}
}
if (try_heuristic_first) {
/* do lookup with the heuristic subdissector table */
if (dissector_try_heuristic(sctp_heur_subdissector_list, payload_tvb, pinfo, tree, &hdtbl_entry, GUINT_TO_POINTER(ppi)))
- return TRUE;
+ return true;
}
/* Do lookups with the subdissector table.
@@ -2549,25 +2605,25 @@ dissect_payload(tvbuff_t *payload_tvb, packet_info *pinfo, proto_tree *tree, gui
although there is, of course, no guarantee that any such strategy
will always pick the right port number. */
if (try_ppi &&
- dissector_try_uint_new(sctp_ppi_dissector_table, ppi, payload_tvb, pinfo, tree, TRUE, GUINT_TO_POINTER(ppi)))
- return TRUE;
+ dissector_try_uint_new(sctp_ppi_dissector_table, ppi, payload_tvb, pinfo, tree, true, GUINT_TO_POINTER(ppi)))
+ return true;
if (try_low_port &&
- dissector_try_uint_new(sctp_port_dissector_table, low_port, payload_tvb, pinfo, tree, TRUE, GUINT_TO_POINTER(ppi)))
- return TRUE;
+ dissector_try_uint_new(sctp_port_dissector_table, low_port, payload_tvb, pinfo, tree, true, GUINT_TO_POINTER(ppi)))
+ return true;
if (try_high_port &&
- dissector_try_uint_new(sctp_port_dissector_table, high_port, payload_tvb, pinfo, tree, TRUE, GUINT_TO_POINTER(ppi)))
- return TRUE;
+ dissector_try_uint_new(sctp_port_dissector_table, high_port, payload_tvb, pinfo, tree, true, GUINT_TO_POINTER(ppi)))
+ return true;
if (!try_heuristic_first) {
/* do lookup with the heuristic subdissector table */
if (dissector_try_heuristic(sctp_heur_subdissector_list, payload_tvb, pinfo, tree, &hdtbl_entry, GUINT_TO_POINTER(ppi)))
- return TRUE;
+ return true;
}
}
/* Oh, well, we don't know this; dissect it as data. */
call_data_dissector(payload_tvb, pinfo, tree);
- return TRUE;
+ return true;
}
#define DATA_CHUNK_TSN_LENGTH 4
@@ -2616,21 +2672,21 @@ dissect_payload(tvbuff_t *payload_tvb, packet_info *pinfo, proto_tree *tree, gui
#define SCTP_DATA_CHUNK_I_BIT 0x08
/* table to hold fragmented SCTP messages */
-static GHashTable *frag_table = NULL;
+static GHashTable *frag_table;
typedef struct _frag_key {
- guint16 sport;
- guint16 dport;
- guint32 verification_tag;
- guint16 stream_id;
- guint32 stream_seq_num;
- guint8 u_bit;
+ uint16_t sport;
+ uint16_t dport;
+ uint32_t verification_tag;
+ uint16_t stream_id;
+ uint32_t stream_seq_num;
+ uint8_t u_bit;
} frag_key;
-static gint
-frag_equal(gconstpointer k1, gconstpointer k2)
+static int
+frag_equal(const void *k1, const void *k2)
{
const frag_key *key1 = (const frag_key *) k1;
const frag_key *key2 = (const frag_key *) k2;
@@ -2641,12 +2697,12 @@ frag_equal(gconstpointer k1, gconstpointer k2)
(key1->stream_id == key2->stream_id) &&
(key1->stream_seq_num == key2->stream_seq_num) &&
(key1->u_bit == key2->u_bit)
- ? TRUE : FALSE);
+ ? true : false);
}
-static guint
-frag_hash(gconstpointer k)
+static unsigned
+frag_hash(const void *k)
{
const frag_key *key = (const frag_key *) k;
@@ -2694,7 +2750,6 @@ sctp_init(void)
frag_table = g_hash_table_new_full(frag_hash, frag_equal,
(GDestroyNotify)g_free, (GDestroyNotify)frag_free_msgs);
num_assocs = 0;
- assoc_info_list = NULL;
}
static void
@@ -2705,7 +2760,7 @@ sctp_cleanup(void)
static sctp_frag_msg*
-find_message(guint16 stream_id, guint32 stream_seq_num, guint8 u_bit)
+find_message(uint16_t stream_id, uint32_t stream_seq_num, uint8_t u_bit)
{
frag_key key;
@@ -2721,7 +2776,7 @@ find_message(guint16 stream_id, guint32 stream_seq_num, guint8 u_bit)
static sctp_fragment*
-find_fragment(guint32 tsn, guint16 stream_id, guint32 stream_seq_num, guint8 u_bit)
+find_fragment(uint32_t tsn, uint16_t stream_id, uint32_t stream_seq_num, uint8_t u_bit)
{
sctp_frag_msg *msg;
sctp_fragment *next_fragment;
@@ -2742,9 +2797,9 @@ find_fragment(guint32 tsn, guint16 stream_id, guint32 stream_seq_num, guint8 u_b
static sctp_fragment *
-add_fragment(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 tsn,
- guint16 stream_id, guint32 stream_seq_num, guint8 b_bit, guint8 e_bit,
- guint8 u_bit, guint32 ppi, gboolean is_idata)
+add_fragment(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, uint32_t tsn,
+ uint16_t stream_id, uint32_t stream_seq_num, uint8_t b_bit, uint8_t e_bit,
+ uint8_t u_bit, uint32_t ppi, bool is_idata)
{
sctp_frag_msg *msg;
sctp_fragment *fragment, *last_fragment;
@@ -2901,14 +2956,14 @@ add_fragment(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint32 tsn,
static tvbuff_t*
fragment_reassembly(tvbuff_t *tvb, sctp_fragment *fragment,
- packet_info *pinfo, proto_tree *tree, guint16 stream_id,
- guint32 stream_seq_num, guint8 u_bit)
+ packet_info *pinfo, proto_tree *tree, uint16_t stream_id,
+ uint32_t stream_seq_num, uint8_t u_bit)
{
sctp_frag_msg *msg;
sctp_complete_msg *message, *last_message;
sctp_fragment *frag_i, *last_frag, *first_frag;
sctp_frag_be *begin, *end, *beginend;
- guint32 len, offset = 0;
+ uint32_t len, offset = 0;
tvbuff_t *new_tvb = NULL;
proto_item *item;
proto_tree *ptree;
@@ -3220,13 +3275,13 @@ fragment_reassembly(tvbuff_t *tvb, sctp_fragment *fragment,
}
/* it's not fragmented anymore */
- pinfo->fragmented = FALSE;
+ pinfo->fragmented = false;
return new_tvb;
}
static exp_pdu_data_t*
-create_exp_pdu_table(packet_info *pinfo, tvbuff_t *tvb, const char *table_name, guint32 table_value)
+create_exp_pdu_table(packet_info *pinfo, tvbuff_t *tvb, const char *table_name, uint32_t table_value)
{
exp_pdu_data_item_t exp_pdu_data_table_value = {
exp_pdu_data_dissector_table_num_value_size,
@@ -3255,7 +3310,7 @@ create_exp_pdu_table(packet_info *pinfo, tvbuff_t *tvb, const char *table_name,
}
static exp_pdu_data_t*
-create_exp_pdu_proto_name(packet_info *pinfo, tvbuff_t *tvb, const gchar *proto_name)
+create_exp_pdu_proto_name(packet_info *pinfo, tvbuff_t *tvb, const char *proto_name)
{
exp_pdu_data_t *exp_pdu_data = export_pdu_create_common_tags(pinfo, proto_name, EXP_PDU_TAG_DISSECTOR_NAME);
@@ -3267,10 +3322,10 @@ create_exp_pdu_proto_name(packet_info *pinfo, tvbuff_t *tvb, const gchar *proto_
}
static void
-export_sctp_data_chunk(packet_info *pinfo, tvbuff_t *tvb, guint32 payload_proto_id,
+export_sctp_data_chunk(packet_info *pinfo, tvbuff_t *tvb, uint32_t payload_proto_id,
const wmem_list_frame_t *frame)
{
- const gchar *proto_name = NULL;
+ const char *proto_name = NULL;
exp_pdu_data_t *exp_pdu_data = NULL;
if (!have_tap_listener(exported_pdu_tap)) {
@@ -3300,10 +3355,10 @@ export_sctp_data_chunk(packet_info *pinfo, tvbuff_t *tvb, guint32 payload_proto_
tap_queue_packet(exported_pdu_tap, pinfo, exp_pdu_data);
}
-static gboolean
+static bool
dissect_fragmented_payload(tvbuff_t *payload_tvb, packet_info *pinfo, proto_tree *tree,
- proto_tree *chunk_tree, guint32 tsn, guint32 ppi, guint16 stream_id,
- guint32 stream_seq_num, guint8 b_bit, guint8 e_bit, guint8 u_bit, gboolean is_idata)
+ proto_tree *chunk_tree, uint32_t tsn, uint32_t ppi, uint16_t stream_id,
+ uint32_t stream_seq_num, uint8_t b_bit, uint8_t e_bit, uint8_t u_bit, bool is_idata)
{
sctp_fragment *fragment;
tvbuff_t *new_tvb = NULL;
@@ -3313,7 +3368,7 @@ dissect_fragmented_payload(tvbuff_t *payload_tvb, packet_info *pinfo, proto_tree
* reassembly on it. We just give up.
*/
if (tvb_reported_length(payload_tvb) > tvb_captured_length(payload_tvb))
- return TRUE;
+ return true;
/* add fragment to list of known fragments. returns NULL if segment is a duplicate */
fragment = add_fragment(payload_tvb, pinfo, chunk_tree, tsn, stream_id, stream_seq_num, b_bit, e_bit, u_bit, ppi, is_idata);
@@ -3323,7 +3378,7 @@ dissect_fragmented_payload(tvbuff_t *payload_tvb, packet_info *pinfo, proto_tree
/* pass reassembled data to next dissector, if possible */
if (new_tvb){
- gboolean retval;
+ bool retval;
wmem_list_frame_t *cur = wmem_list_tail(pinfo->layers);
retval = dissect_payload(new_tvb, pinfo, tree, ppi);
@@ -3332,7 +3387,7 @@ dissect_fragmented_payload(tvbuff_t *payload_tvb, packet_info *pinfo, proto_tree
}
/* no reassembly done, do nothing */
- return TRUE;
+ return true;
}
static const true_false_string sctp_data_chunk_e_bit_value = {
@@ -3355,29 +3410,29 @@ static const true_false_string sctp_data_chunk_i_bit_value = {
"Possibly delay SACK"
};
-static gboolean
+static bool
dissect_data_chunk(tvbuff_t *chunk_tvb,
- guint16 chunk_length,
+ uint16_t chunk_length,
packet_info *pinfo,
proto_tree *tree,
proto_tree *chunk_tree,
proto_item *chunk_item,
proto_item *flags_item,
sctp_half_assoc_t *ha,
- gboolean is_idata)
+ bool is_idata)
{
- guint number_of_ppid;
- volatile guint32 payload_proto_id;
+ unsigned number_of_ppid;
+ volatile uint32_t payload_proto_id;
tvbuff_t *payload_tvb;
proto_tree *flags_tree;
- guint8 oct, e_bit, b_bit, u_bit;
- guint16 stream_id;
- guint32 tsn, rawtsn, ppid, stream_seq_num = 0;
+ uint8_t oct, e_bit, b_bit, u_bit;
+ uint16_t stream_id;
+ uint32_t tsn, rawtsn, ppid, stream_seq_num = 0;
proto_item *tsn_item = NULL;
- gboolean call_subdissector = FALSE;
- gboolean is_retransmission;
- guint16 header_length;
- guint16 payload_offset;
+ bool call_subdissector = false;
+ bool is_retransmission;
+ uint16_t header_length;
+ uint16_t payload_offset;
static int* const chunk_flags[] = {
&hf_data_chunk_i_bit,
@@ -3390,13 +3445,13 @@ dissect_data_chunk(tvbuff_t *chunk_tvb,
if (is_idata) {
if (chunk_length < I_DATA_CHUNK_HEADER_LENGTH) {
proto_item_append_text(chunk_item, ", bogus chunk length %u < %u)", chunk_length, I_DATA_CHUNK_HEADER_LENGTH);
- return TRUE;
+ return true;
}
payload_proto_id = tvb_get_ntohl(chunk_tvb, I_DATA_CHUNK_PAYLOAD_PROTOCOL_ID_OFFSET);
} else {
if (chunk_length < DATA_CHUNK_HEADER_LENGTH) {
proto_item_append_text(chunk_item, ", bogus chunk length %u < %u)", chunk_length, DATA_CHUNK_HEADER_LENGTH);
- return TRUE;
+ return true;
}
payload_proto_id = tvb_get_ntohl(chunk_tvb, DATA_CHUNK_PAYLOAD_PROTOCOL_ID_OFFSET);
}
@@ -3411,7 +3466,7 @@ dissect_data_chunk(tvbuff_t *chunk_tvb,
if ((number_of_ppid < MAX_NUMBER_OF_PPIDS) && (ppid == LAST_PPID))
p_add_proto_data(pinfo->pool, pinfo, proto_sctp, number_of_ppid, GUINT_TO_POINTER(payload_proto_id));
- oct = tvb_get_guint8(chunk_tvb, CHUNK_FLAGS_OFFSET);
+ oct = tvb_get_uint8(chunk_tvb, CHUNK_FLAGS_OFFSET);
e_bit = oct & SCTP_DATA_CHUNK_E_BIT;
b_bit = oct & SCTP_DATA_CHUNK_B_BIT;
u_bit = oct & SCTP_DATA_CHUNK_U_BIT;
@@ -3420,7 +3475,7 @@ dissect_data_chunk(tvbuff_t *chunk_tvb,
if ((show_relative_tsns) && (ha)) {
if (!ha->started) {
ha->first_tsn = tsn;
- ha->started = TRUE;
+ ha->started = true;
}
tsn -= ha->first_tsn;
}
@@ -3507,10 +3562,10 @@ dissect_data_chunk(tvbuff_t *chunk_tvb,
if (b_bit && e_bit) {
/* No - just call the subdissector. */
if (!is_retransmission)
- call_subdissector = TRUE;
+ call_subdissector = true;
} else {
/* Yes. */
- pinfo->fragmented = TRUE;
+ pinfo->fragmented = true;
/* if reassembly is off just mark as fragment for next dissector and proceed */
if (!use_reassembly)
@@ -3520,9 +3575,9 @@ dissect_data_chunk(tvbuff_t *chunk_tvb,
*/
if (b_bit) {
if (!is_retransmission)
- call_subdissector = TRUE;
+ call_subdissector = true;
} else
- return FALSE;
+ return false;
}
}
@@ -3530,7 +3585,7 @@ dissect_data_chunk(tvbuff_t *chunk_tvb,
if (call_subdissector) {
/* This isn't a fragment or reassembly is off and it's the first fragment */
- volatile gboolean retval = FALSE;
+ volatile bool retval = false;
wmem_list_frame_t *cur = wmem_list_tail(pinfo->layers);
TRY {
@@ -3554,7 +3609,7 @@ dissect_data_chunk(tvbuff_t *chunk_tvb,
} else if (is_retransmission) {
col_append_str(pinfo->cinfo, COL_INFO, "(retransmission) ");
- return FALSE;
+ return false;
} else {
/* The logic above should ensure this... */
@@ -3609,7 +3664,7 @@ dissect_data_chunk(tvbuff_t *chunk_tvb,
static void
// NOLINTNEXTLINE(misc-no-recursion)
-dissect_init_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *pinfo, proto_tree *chunk_tree, proto_item *chunk_item)
+dissect_init_chunk(tvbuff_t *chunk_tvb, uint16_t chunk_length, packet_info *pinfo, proto_tree *chunk_tree, proto_item *chunk_item)
{
tvbuff_t *parameters_tvb;
proto_item *hidden_item;
@@ -3639,12 +3694,12 @@ dissect_init_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *pinfo
parameters_tvb = tvb_new_subset_length_caplen(chunk_tvb, INIT_CHUNK_VARIABLE_LENGTH_PARAMETER_OFFSET,
MIN(chunk_length, tvb_captured_length_remaining(chunk_tvb, INIT_CHUNK_VARIABLE_LENGTH_PARAMETER_OFFSET)),
MIN(chunk_length, tvb_reported_length_remaining(chunk_tvb, INIT_CHUNK_VARIABLE_LENGTH_PARAMETER_OFFSET)));
- dissect_parameters(parameters_tvb, pinfo, chunk_tree, NULL, TRUE);
+ dissect_parameters(parameters_tvb, pinfo, chunk_tree, NULL, true);
}
static void
// NOLINTNEXTLINE(misc-no-recursion)
-dissect_init_ack_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *pinfo, proto_tree *chunk_tree, proto_item *chunk_item)
+dissect_init_ack_chunk(tvbuff_t *chunk_tvb, uint16_t chunk_length, packet_info *pinfo, proto_tree *chunk_tree, proto_item *chunk_item)
{
tvbuff_t *parameters_tvb;
proto_item *hidden_item;
@@ -3669,12 +3724,12 @@ dissect_init_ack_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *p
tvb_get_ntohs(chunk_tvb, INIT_CHUNK_NUMBER_OF_OUTBOUND_STREAMS_OFFSET),
tvb_get_ntohs(chunk_tvb, INIT_CHUNK_NUMBER_OF_INBOUND_STREAMS_OFFSET));
}
- /* handle variable paramters */
+ /* handle variable parameters */
chunk_length -= INIT_CHUNK_FIXED_PARAMTERS_LENGTH;
parameters_tvb = tvb_new_subset_length_caplen(chunk_tvb, INIT_CHUNK_VARIABLE_LENGTH_PARAMETER_OFFSET,
MIN(chunk_length, tvb_captured_length_remaining(chunk_tvb, INIT_CHUNK_VARIABLE_LENGTH_PARAMETER_OFFSET)),
MIN(chunk_length, tvb_reported_length_remaining(chunk_tvb, INIT_CHUNK_VARIABLE_LENGTH_PARAMETER_OFFSET)));
- dissect_parameters(parameters_tvb, pinfo, chunk_tree, NULL, TRUE);
+ dissect_parameters(parameters_tvb, pinfo, chunk_tree, NULL, true);
}
#define SCTP_SACK_CHUNK_NS_BIT 0x01
@@ -3701,18 +3756,18 @@ dissect_init_ack_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *p
static void
dissect_sack_chunk(packet_info *pinfo, tvbuff_t *chunk_tvb, proto_tree *chunk_tree, proto_item *chunk_item, proto_item *flags_item, sctp_half_assoc_t *ha)
{
- guint16 number_of_gap_blocks, number_of_dup_tsns;
- guint16 gap_block_number, dup_tsn_number, start, end;
- gint gap_block_offset, dup_tsn_offset;
- guint32 cum_tsn_ack;
+ uint16_t number_of_gap_blocks, number_of_dup_tsns;
+ uint16_t gap_block_number, dup_tsn_number, start, end;
+ int gap_block_offset, dup_tsn_offset;
+ uint32_t cum_tsn_ack;
proto_tree *block_tree;
proto_tree *flags_tree;
proto_item *ctsa_item;
proto_item *a_rwnd_item;
proto_tree *acks_tree;
- guint32 tsns_gap_acked = 0;
- guint32 a_rwnd;
- guint16 last_end;
+ uint32_t tsns_gap_acked = 0;
+ uint32_t a_rwnd;
+ uint16_t last_end;
cum_tsn_ack = tvb_get_ntohl(chunk_tvb, SACK_CHUNK_CUMULATIVE_TSN_ACK_OFFSET);
if((show_relative_tsns) && (ha) && (ha->peer)) {
@@ -3748,7 +3803,7 @@ dissect_sack_chunk(packet_info *pinfo, tvbuff_t *chunk_tvb, proto_tree *chunk_tr
for(gap_block_number = 0; gap_block_number < number_of_gap_blocks; gap_block_number++) {
proto_item *pi;
proto_tree *pt;
- guint32 tsn_start;
+ uint32_t tsn_start;
start = tvb_get_ntohs(chunk_tvb, gap_block_offset);
end = tvb_get_ntohs(chunk_tvb, gap_block_offset + SACK_CHUNK_GAP_BLOCK_START_LENGTH);
@@ -3859,18 +3914,18 @@ dissect_sack_chunk(packet_info *pinfo, tvbuff_t *chunk_tvb, proto_tree *chunk_tr
static void
dissect_nr_sack_chunk(packet_info *pinfo, tvbuff_t *chunk_tvb, proto_tree *chunk_tree, proto_item *chunk_item, proto_item *flags_item, sctp_half_assoc_t *ha)
{
- guint16 number_of_gap_blocks, number_of_dup_tsns;
- guint16 number_of_nr_gap_blocks;
- guint16 gap_block_number, nr_gap_block_number, dup_tsn_number, start, end;
- gint gap_block_offset, nr_gap_block_offset, dup_tsn_offset;
- guint32 cum_tsn_ack;
+ uint16_t number_of_gap_blocks, number_of_dup_tsns;
+ uint16_t number_of_nr_gap_blocks;
+ uint16_t gap_block_number, nr_gap_block_number, dup_tsn_number, start, end;
+ int gap_block_offset, nr_gap_block_offset, dup_tsn_offset;
+ uint32_t cum_tsn_ack;
proto_tree *block_tree;
proto_tree *flags_tree;
proto_item *ctsa_item;
proto_tree *acks_tree;
- guint32 tsns_gap_acked = 0;
- guint32 tsns_nr_gap_acked = 0;
- guint16 last_end;
+ uint32_t tsns_gap_acked = 0;
+ uint32_t tsns_nr_gap_acked = 0;
+ uint16_t last_end;
flags_tree = proto_item_add_subtree(flags_item, ett_sctp_nr_sack_chunk_flags);
proto_tree_add_item(flags_tree, hf_nr_sack_chunk_ns, chunk_tvb, CHUNK_FLAGS_OFFSET, CHUNK_FLAGS_LENGTH, ENC_BIG_ENDIAN);
@@ -3896,7 +3951,7 @@ dissect_nr_sack_chunk(packet_info *pinfo, tvbuff_t *chunk_tvb, proto_tree *chunk
for(gap_block_number = 0; gap_block_number < number_of_gap_blocks; gap_block_number++) {
proto_item *pi;
proto_tree *pt;
- guint32 tsn_start;
+ uint32_t tsn_start;
start = tvb_get_ntohs(chunk_tvb, gap_block_offset);
end = tvb_get_ntohs(chunk_tvb, gap_block_offset + NR_SACK_CHUNK_GAP_BLOCK_START_LENGTH);
@@ -3953,7 +4008,7 @@ dissect_nr_sack_chunk(packet_info *pinfo, tvbuff_t *chunk_tvb, proto_tree *chunk
for(nr_gap_block_number = 0; nr_gap_block_number < number_of_nr_gap_blocks; nr_gap_block_number++) {
proto_item *pi;
proto_tree *pt;
- /*guint32 tsn_start;*/
+ /*uint32_t tsn_start;*/
start = tvb_get_ntohs(chunk_tvb, nr_gap_block_offset);
end = tvb_get_ntohs(chunk_tvb, nr_gap_block_offset + NR_SACK_CHUNK_NR_GAP_BLOCK_START_LENGTH);
@@ -4022,7 +4077,7 @@ dissect_nr_sack_chunk(packet_info *pinfo, tvbuff_t *chunk_tvb, proto_tree *chunk
static void
// NOLINTNEXTLINE(misc-no-recursion)
-dissect_heartbeat_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *pinfo, proto_tree *chunk_tree, proto_item *chunk_item)
+dissect_heartbeat_chunk(tvbuff_t *chunk_tvb, uint16_t chunk_length, packet_info *pinfo, proto_tree *chunk_tree, proto_item *chunk_item)
{
tvbuff_t *parameter_tvb;
@@ -4032,7 +4087,7 @@ dissect_heartbeat_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *
MIN(chunk_length - CHUNK_HEADER_LENGTH, tvb_captured_length_remaining(chunk_tvb, HEARTBEAT_CHUNK_INFO_OFFSET)),
MIN(chunk_length - CHUNK_HEADER_LENGTH, tvb_reported_length_remaining(chunk_tvb, HEARTBEAT_CHUNK_INFO_OFFSET)));
/* FIXME: Parameters or parameter? */
- dissect_parameter(parameter_tvb, pinfo, chunk_tree, NULL, FALSE, TRUE);
+ dissect_parameter(parameter_tvb, pinfo, chunk_tree, NULL, false, true);
}
}
@@ -4040,7 +4095,7 @@ dissect_heartbeat_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *
static void
// NOLINTNEXTLINE(misc-no-recursion)
-dissect_heartbeat_ack_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *pinfo, proto_tree *chunk_tree, proto_item *chunk_item)
+dissect_heartbeat_ack_chunk(tvbuff_t *chunk_tvb, uint16_t chunk_length, packet_info *pinfo, proto_tree *chunk_tree, proto_item *chunk_item)
{
tvbuff_t *parameter_tvb;
@@ -4050,7 +4105,7 @@ dissect_heartbeat_ack_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_in
MIN(chunk_length - CHUNK_HEADER_LENGTH, tvb_captured_length_remaining(chunk_tvb, HEARTBEAT_ACK_CHUNK_INFO_OFFSET)),
MIN(chunk_length - CHUNK_HEADER_LENGTH, tvb_reported_length_remaining(chunk_tvb, HEARTBEAT_ACK_CHUNK_INFO_OFFSET)));
/* FIXME: Parameters or parameter? */
- dissect_parameter(parameter_tvb, pinfo, chunk_tree, NULL, FALSE, TRUE);
+ dissect_parameter(parameter_tvb, pinfo, chunk_tree, NULL, false, true);
}
}
@@ -4059,13 +4114,13 @@ dissect_heartbeat_ack_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_in
static void
// NOLINTNEXTLINE(misc-no-recursion)
-dissect_abort_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *pinfo, proto_tree *chunk_tree, proto_item *flags_item)
+dissect_abort_chunk(tvbuff_t *chunk_tvb, uint16_t chunk_length, packet_info *pinfo, proto_tree *chunk_tree, proto_item *flags_item)
{
tvbuff_t *causes_tvb;
proto_tree *flags_tree;
sctp_info.vtag_reflected =
- (tvb_get_guint8(chunk_tvb, CHUNK_FLAGS_OFFSET) & SCTP_ABORT_CHUNK_T_BIT) != 0;
+ (tvb_get_uint8(chunk_tvb, CHUNK_FLAGS_OFFSET) & SCTP_ABORT_CHUNK_T_BIT) != 0;
if (chunk_tree) {
flags_tree = proto_item_add_subtree(flags_item, ett_sctp_abort_chunk_flags);
@@ -4098,7 +4153,7 @@ dissect_shutdown_ack_chunk(tvbuff_t *chunk_tvb _U_)
static void
// NOLINTNEXTLINE(misc-no-recursion)
-dissect_error_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *pinfo, proto_tree *chunk_tree)
+dissect_error_chunk(tvbuff_t *chunk_tvb, uint16_t chunk_length, packet_info *pinfo, proto_tree *chunk_tree)
{
tvbuff_t *causes_tvb;
@@ -4113,7 +4168,7 @@ dissect_error_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *pinf
#define COOKIE_OFFSET CHUNK_VALUE_OFFSET
static void
-dissect_cookie_echo_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, proto_tree *chunk_tree, proto_item *chunk_item)
+dissect_cookie_echo_chunk(tvbuff_t *chunk_tvb, uint16_t chunk_length, proto_tree *chunk_tree, proto_item *chunk_item)
{
if (chunk_tree) {
proto_tree_add_item(chunk_tree, hf_cookie, chunk_tvb, COOKIE_OFFSET, chunk_length - CHUNK_HEADER_LENGTH, ENC_NA);
@@ -4161,7 +4216,7 @@ dissect_shutdown_complete_chunk(tvbuff_t *chunk_tvb, proto_tree *chunk_tree, pro
proto_tree *flags_tree;
sctp_info.vtag_reflected =
- (tvb_get_guint8(chunk_tvb, CHUNK_FLAGS_OFFSET) & SCTP_SHUTDOWN_COMPLETE_CHUNK_T_BIT) != 0;
+ (tvb_get_uint8(chunk_tvb, CHUNK_FLAGS_OFFSET) & SCTP_SHUTDOWN_COMPLETE_CHUNK_T_BIT) != 0;
if (chunk_tree) {
flags_tree = proto_item_add_subtree(flags_item, ett_sctp_shutdown_complete_chunk_flags);
@@ -4177,10 +4232,10 @@ dissect_shutdown_complete_chunk(tvbuff_t *chunk_tvb, proto_tree *chunk_tree, pro
#define FORWARD_TSN_CHUNK_SSN_OFFSET (FORWARD_TSN_CHUNK_SID_OFFSET + FORWARD_TSN_CHUNK_SID_LENGTH)
static void
-dissect_forward_tsn_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, proto_tree *chunk_tree, proto_item *chunk_item)
+dissect_forward_tsn_chunk(tvbuff_t *chunk_tvb, uint16_t chunk_length, proto_tree *chunk_tree, proto_item *chunk_item)
{
- guint offset;
- guint16 number_of_affected_streams, affected_stream;
+ unsigned offset;
+ uint16_t number_of_affected_streams, affected_stream;
/* FIXME */
if (chunk_length < CHUNK_HEADER_LENGTH + FORWARD_TSN_CHUNK_TSN_LENGTH) {
@@ -4222,10 +4277,10 @@ static const true_false_string sctp_i_forward_tsn_chunk_u_bit_value = {
};
static void
-dissect_i_forward_tsn_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, proto_tree *chunk_tree, proto_item *chunk_item)
+dissect_i_forward_tsn_chunk(tvbuff_t *chunk_tvb, uint16_t chunk_length, proto_tree *chunk_tree, proto_item *chunk_item)
{
- guint offset;
- guint16 number_of_affected_streams, affected_stream;
+ unsigned offset;
+ uint16_t number_of_affected_streams, affected_stream;
proto_tree *flags_tree;
proto_item *flags_item = NULL;
@@ -4259,14 +4314,14 @@ dissect_i_forward_tsn_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, proto_tre
static void
// NOLINTNEXTLINE(misc-no-recursion)
-dissect_re_config_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *pinfo, proto_tree *chunk_tree, proto_item *chunk_item _U_)
+dissect_re_config_chunk(tvbuff_t *chunk_tvb, uint16_t chunk_length, packet_info *pinfo, proto_tree *chunk_tree, proto_item *chunk_item _U_)
{
tvbuff_t *parameters_tvb;
parameters_tvb = tvb_new_subset_length_caplen(chunk_tvb, RE_CONFIG_PARAMETERS_OFFSET,
MIN(chunk_length - CHUNK_HEADER_LENGTH, tvb_captured_length_remaining(chunk_tvb, RE_CONFIG_PARAMETERS_OFFSET)),
MIN(chunk_length - CHUNK_HEADER_LENGTH, tvb_reported_length_remaining(chunk_tvb, RE_CONFIG_PARAMETERS_OFFSET)));
- dissect_parameters(parameters_tvb, pinfo, chunk_tree, NULL, FALSE);
+ dissect_parameters(parameters_tvb, pinfo, chunk_tree, NULL, false);
}
#define SHARED_KEY_ID_LENGTH 2
@@ -4276,9 +4331,9 @@ dissect_re_config_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *
#define HMAC_OFFSET (HMAC_ID_OFFSET + HMAC_ID_LENGTH)
static void
-dissect_auth_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, proto_tree *chunk_tree, proto_item *chunk_item _U_)
+dissect_auth_chunk(tvbuff_t *chunk_tvb, uint16_t chunk_length, proto_tree *chunk_tree, proto_item *chunk_item _U_)
{
- guint hmac_length;
+ unsigned hmac_length;
hmac_length = chunk_length - CHUNK_HEADER_LENGTH - HMAC_ID_LENGTH - SHARED_KEY_ID_LENGTH;
proto_tree_add_item(chunk_tree, hf_shared_key_id, chunk_tvb, SHARED_KEY_ID_OFFSET, SHARED_KEY_ID_LENGTH, ENC_BIG_ENDIAN);
@@ -4293,7 +4348,7 @@ dissect_auth_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, proto_tree *chunk_
static void
// NOLINTNEXTLINE(misc-no-recursion)
-dissect_asconf_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *pinfo, proto_tree *chunk_tree, proto_item *chunk_item)
+dissect_asconf_chunk(tvbuff_t *chunk_tvb, uint16_t chunk_length, packet_info *pinfo, proto_tree *chunk_tree, proto_item *chunk_item)
{
tvbuff_t *parameters_tvb;
@@ -4310,14 +4365,14 @@ dissect_asconf_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *pin
parameters_tvb = tvb_new_subset_length_caplen(chunk_tvb, ASCONF_CHUNK_PARAMETERS_OFFSET,
MIN(chunk_length, tvb_captured_length_remaining(chunk_tvb, ASCONF_CHUNK_PARAMETERS_OFFSET)),
MIN(chunk_length, tvb_reported_length_remaining(chunk_tvb, ASCONF_CHUNK_PARAMETERS_OFFSET)));
- dissect_parameters(parameters_tvb, pinfo, chunk_tree, NULL, FALSE);
+ dissect_parameters(parameters_tvb, pinfo, chunk_tree, NULL, false);
}
#define ASCONF_ACK_CHUNK_PARAMETERS_OFFSET (SEQUENCE_NUMBER_OFFSET + SCTP_SEQUENCE_NUMBER_LENGTH)
static void
// NOLINTNEXTLINE(misc-no-recursion)
-dissect_asconf_ack_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *pinfo, proto_tree *chunk_tree, proto_item *chunk_item)
+dissect_asconf_ack_chunk(tvbuff_t *chunk_tvb, uint16_t chunk_length, packet_info *pinfo, proto_tree *chunk_tree, proto_item *chunk_item)
{
tvbuff_t *parameters_tvb;
@@ -4334,7 +4389,7 @@ dissect_asconf_ack_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info
parameters_tvb = tvb_new_subset_length_caplen(chunk_tvb, ASCONF_ACK_CHUNK_PARAMETERS_OFFSET,
MIN(chunk_length, tvb_captured_length_remaining(chunk_tvb, ASCONF_ACK_CHUNK_PARAMETERS_OFFSET)),
MIN(chunk_length, tvb_reported_length_remaining(chunk_tvb, ASCONF_ACK_CHUNK_PARAMETERS_OFFSET)));
- dissect_parameters(parameters_tvb, pinfo, chunk_tree, NULL, FALSE);
+ dissect_parameters(parameters_tvb, pinfo, chunk_tree, NULL, false);
}
#define PKTDROP_CHUNK_BANDWIDTH_LENGTH 4
@@ -4375,7 +4430,7 @@ static const true_false_string sctp_pktdropk_t_bit_value = {
static void
// NOLINTNEXTLINE(misc-no-recursion)
-dissect_pktdrop_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *pinfo, proto_tree *chunk_tree, proto_item *chunk_item, proto_item *flags_item)
+dissect_pktdrop_chunk(tvbuff_t *chunk_tvb, uint16_t chunk_length, packet_info *pinfo, proto_tree *chunk_tree, proto_item *chunk_item, proto_item *flags_item)
{
tvbuff_t *data_field_tvb;
proto_tree *flags_tree;
@@ -4404,13 +4459,13 @@ dissect_pktdrop_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *pi
if (chunk_length > 0) {
/* XXX - We should dissect what we can and catch the BoundsError when we run out of bytes */
- if (tvb_get_guint8(chunk_tvb, CHUNK_FLAGS_OFFSET) & SCTP_PKTDROP_CHUNK_T_BIT)
+ if (tvb_get_uint8(chunk_tvb, CHUNK_FLAGS_OFFSET) & SCTP_PKTDROP_CHUNK_T_BIT)
proto_tree_add_item(chunk_tree, hf_pktdrop_chunk_data_field, chunk_tvb, PKTDROP_CHUNK_DATA_FIELD_OFFSET, chunk_length, ENC_NA);
else {
- gboolean save_in_error_pkt = pinfo->flags.in_error_pkt;
- pinfo->flags.in_error_pkt = TRUE;
+ bool save_in_error_pkt = pinfo->flags.in_error_pkt;
+ pinfo->flags.in_error_pkt = true;
- dissect_sctp_packet(data_field_tvb, pinfo, chunk_tree, TRUE);
+ dissect_sctp_packet(data_field_tvb, pinfo, chunk_tree, true);
pinfo->flags.in_error_pkt = save_in_error_pkt;
}
@@ -4419,9 +4474,9 @@ dissect_pktdrop_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, packet_info *pi
}
static void
-dissect_pad_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, proto_tree *chunk_tree, proto_item *chunk_item)
+dissect_pad_chunk(tvbuff_t *chunk_tvb, uint16_t chunk_length, proto_tree *chunk_tree, proto_item *chunk_item)
{
- guint16 value_length;
+ uint16_t value_length;
if (chunk_tree) {
value_length = chunk_length - CHUNK_HEADER_LENGTH;
@@ -4431,9 +4486,9 @@ dissect_pad_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, proto_tree *chunk_t
}
static void
-dissect_unknown_chunk(tvbuff_t *chunk_tvb, guint16 chunk_length, guint8 chunk_type, proto_tree *chunk_tree, proto_item *chunk_item)
+dissect_unknown_chunk(tvbuff_t *chunk_tvb, uint16_t chunk_length, uint8_t chunk_type, proto_tree *chunk_tree, proto_item *chunk_item)
{
- guint16 value_length;
+ uint16_t value_length;
if (chunk_tree) {
value_length = chunk_length - CHUNK_HEADER_LENGTH;
@@ -4457,25 +4512,25 @@ static const true_false_string sctp_chunk_bit_2_value = {
};
-static gboolean
+static bool
// NOLINTNEXTLINE(misc-no-recursion)
dissect_sctp_chunk(tvbuff_t *chunk_tvb,
packet_info *pinfo,
proto_tree *tree,
proto_tree *sctp_tree,
sctp_half_assoc_t *ha,
- gboolean useinfo)
+ bool useinfo)
{
- guint8 type;
- guint16 length, padding_length, reported_length;
- gboolean result;
+ uint8_t type;
+ uint16_t length, padding_length, reported_length;
+ bool result;
proto_item *flags_item, *chunk_item, *type_item, *length_item;
proto_tree *chunk_tree, *type_tree;
- result = FALSE;
+ result = false;
/* first extract the chunk header */
- type = tvb_get_guint8(chunk_tvb, CHUNK_TYPE_OFFSET);
+ type = tvb_get_uint8(chunk_tvb, CHUNK_TYPE_OFFSET);
length = tvb_get_ntohs(chunk_tvb, CHUNK_LENGTH_OFFSET);
reported_length = tvb_reported_length(chunk_tvb);
padding_length = reported_length - length;
@@ -4484,9 +4539,9 @@ dissect_sctp_chunk(tvbuff_t *chunk_tvb,
col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", val_to_str_const(type, chunk_type_values, "RESERVED"));
/* create proto_tree stuff */
- chunk_tree = proto_tree_add_subtree_format(sctp_tree, chunk_tvb, CHUNK_HEADER_OFFSET, reported_length,
- ett_sctp_chunk, &chunk_item, "%s chunk",
- val_to_str_const(type, chunk_type_values, "RESERVED"));
+ chunk_item = proto_tree_add_none_format(sctp_tree, hf_chunk, chunk_tvb, CHUNK_HEADER_OFFSET, reported_length,
+ "%s chunk", val_to_str_const(type, chunk_type_values, "RESERVED"));
+ chunk_tree = proto_item_add_subtree(chunk_item, ett_sctp_chunk);
if (tree) {
/* then insert the chunk header components into the protocol tree */
@@ -4509,7 +4564,7 @@ dissect_sctp_chunk(tvbuff_t *chunk_tvb,
}
if (type == SCTP_DATA_CHUNK_ID)
- result = TRUE;
+ result = true;
return result;
}
@@ -4527,10 +4582,10 @@ dissect_sctp_chunk(tvbuff_t *chunk_tvb,
increment_dissection_depth(pinfo);
switch(type) {
case SCTP_DATA_CHUNK_ID:
- result = dissect_data_chunk(chunk_tvb, length, pinfo, tree, chunk_tree, chunk_item, flags_item, ha, FALSE);
+ result = dissect_data_chunk(chunk_tvb, length, pinfo, tree, chunk_tree, chunk_item, flags_item, ha, false);
break;
case SCTP_I_DATA_CHUNK_ID:
- result = dissect_data_chunk(chunk_tvb, length, pinfo, tree, chunk_tree, chunk_item, flags_item, ha, TRUE);
+ result = dissect_data_chunk(chunk_tvb, length, pinfo, tree, chunk_tree, chunk_item, flags_item, ha, true);
break;
case SCTP_INIT_CHUNK_ID:
dissect_init_chunk(chunk_tvb, length, pinfo, chunk_tree, chunk_item);
@@ -4596,9 +4651,9 @@ dissect_sctp_chunk(tvbuff_t *chunk_tvb,
dissect_i_forward_tsn_chunk(chunk_tvb, length, chunk_tree, chunk_item);
break;
case SCTP_PKTDROP_CHUNK_ID:
- col_set_writable(pinfo->cinfo, -1, FALSE);
+ col_set_writable(pinfo->cinfo, -1, false);
dissect_pktdrop_chunk(chunk_tvb, length, pinfo, chunk_tree, chunk_item, flags_item);
- col_set_writable(pinfo->cinfo, -1, TRUE);
+ col_set_writable(pinfo->cinfo, -1, true);
break;
case SCTP_PAD_CHUNK_ID:
dissect_pad_chunk(chunk_tvb, length, chunk_tree, chunk_item);
@@ -4620,19 +4675,21 @@ dissect_sctp_chunk(tvbuff_t *chunk_tvb,
static void
// NOLINTNEXTLINE(misc-no-recursion)
-dissect_sctp_chunks(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *sctp_item, proto_tree *sctp_tree, sctp_half_assoc_t *ha, gboolean encapsulated)
+dissect_sctp_chunks(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_item *sctp_item, proto_tree *sctp_tree, sctp_half_assoc_t *ha, bool encapsulated, proto_item *vt)
{
+ proto_item *pi;
tvbuff_t *chunk_tvb;
- guint16 length, total_length, remaining_length;
- gint last_offset, offset;
- gboolean sctp_item_length_set;
+ uint16_t length, total_length, remaining_length;
+ int last_offset, offset;
+ bool sctp_item_length_set;
assoc_info_t tmpinfo;
infodata_t id_dir;
+ bool first_chunk = true;
/* the common header of the datagram is already handled */
last_offset = 0;
offset = COMMON_HEADER_LENGTH;
- sctp_item_length_set = FALSE;
+ sctp_item_length_set = false;
while((remaining_length = tvb_reported_length_remaining(tvb, offset))) {
/* extract the chunk length and compute number of padding bytes */
@@ -4652,56 +4709,76 @@ dissect_sctp_chunks(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_i
if (sctp_info.number_of_tvbs < MAXIMUM_NUMBER_OF_TVBS)
sctp_info.tvb[sctp_info.number_of_tvbs++] = chunk_tvb;
else
- sctp_info.incomplete = TRUE;
+ sctp_info.incomplete = true;
}
- if (enable_association_indexing) {
- tmpinfo.assoc_index = -1;
- tmpinfo.sport = sctp_info.sport;
- tmpinfo.dport = sctp_info.dport;
- tmpinfo.vtag_reflected = FALSE;
- if (tvb_get_guint8(chunk_tvb, CHUNK_TYPE_OFFSET) == SCTP_ABORT_CHUNK_ID) {
- if ((tvb_get_guint8(chunk_tvb, CHUNK_FLAGS_OFFSET) & SCTP_ABORT_CHUNK_T_BIT) != 0) {
- tmpinfo.vtag_reflected = TRUE;
+ if (first_chunk) {
+ first_chunk = false;
+ if (enable_association_indexing) {
+ tmpinfo.assoc_index = -1;
+ tmpinfo.direction = 1;
+ copy_address_shallow(&tmpinfo.saddr, &pinfo->src);
+ copy_address_shallow(&tmpinfo.daddr, &pinfo->dst);
+ tmpinfo.sport = sctp_info.sport;
+ tmpinfo.dport = sctp_info.dport;
+ bool vtag_reflected = false;
+ /* Certain chunk types have exceptional Verification Tag handling
+ * ( see https://datatracker.ietf.org/doc/html/rfc9260#section-8.5.1 )
+ * XXX: Those chunk types shouldn't be bundled with other chunk types
+ * (ABORT can be bundled after other control types, but ABORT with the
+ * T bit set should not be) and there should be an expert info if so.
+ * Should we use the association from the first chunk or the last
+ * chunk in such a case?
+ */
+ if (tvb_get_uint8(chunk_tvb, CHUNK_TYPE_OFFSET) == SCTP_ABORT_CHUNK_ID) {
+ if ((tvb_get_uint8(chunk_tvb, CHUNK_FLAGS_OFFSET) & SCTP_ABORT_CHUNK_T_BIT) != 0) {
+ vtag_reflected = true;
+ }
}
- }
- if (tvb_get_guint8(chunk_tvb, CHUNK_TYPE_OFFSET) == SCTP_SHUTDOWN_COMPLETE_CHUNK_ID) {
- if ((tvb_get_guint8(chunk_tvb, CHUNK_FLAGS_OFFSET) & SCTP_SHUTDOWN_COMPLETE_CHUNK_T_BIT) != 0) {
- tmpinfo.vtag_reflected = TRUE;
+ if (tvb_get_uint8(chunk_tvb, CHUNK_TYPE_OFFSET) == SCTP_SHUTDOWN_COMPLETE_CHUNK_ID) {
+ if ((tvb_get_uint8(chunk_tvb, CHUNK_FLAGS_OFFSET) & SCTP_SHUTDOWN_COMPLETE_CHUNK_T_BIT) != 0) {
+ vtag_reflected = true;
+ }
}
- }
- if (tmpinfo.vtag_reflected) {
- tmpinfo.verification_tag2 = sctp_info.verification_tag;
- tmpinfo.verification_tag1 = 0;
- }
- else {
- tmpinfo.verification_tag1 = sctp_info.verification_tag;
- tmpinfo.verification_tag2 = 0;
- }
- if (tvb_get_guint8(chunk_tvb, CHUNK_TYPE_OFFSET) == SCTP_INIT_CHUNK_ID) {
- tmpinfo.initiate_tag = tvb_get_ntohl(sctp_info.tvb[0], 4);
- }
- else {
- tmpinfo.initiate_tag = 0;
+ if (vtag_reflected) {
+ tmpinfo.verification_tag1 = 0;
+ tmpinfo.verification_tag2 = sctp_info.verification_tag;
+ }
+ else {
+ tmpinfo.verification_tag1 = sctp_info.verification_tag;
+ tmpinfo.verification_tag2 = 0;
+ }
+ if (tvb_get_uint8(chunk_tvb, CHUNK_TYPE_OFFSET) == SCTP_INIT_CHUNK_ID) {
+ tmpinfo.verification_tag1 = 0;
+ tmpinfo.verification_tag2 = tvb_get_ntohl(sctp_info.tvb[0], 4);
+ }
+ if (tvb_get_uint8(chunk_tvb, CHUNK_TYPE_OFFSET) == SCTP_INIT_ACK_CHUNK_ID) {
+ tmpinfo.verification_tag2 = tvb_get_ntohl(sctp_info.tvb[0], 4);
+ }
+
+ id_dir = find_assoc_index(&tmpinfo, pinfo);
+ pi = proto_tree_add_uint(sctp_tree, hf_sctp_assoc_index, tvb, 0 , 0, id_dir.assoc_index);
+ /* XXX: Should we set these if encapsulated is true or not? */
+ sctp_info.assoc_index = id_dir.assoc_index;
+ sctp_info.direction = id_dir.direction;
+
+ } else {
+ pi = proto_tree_add_uint_format_value(sctp_tree, hf_sctp_assoc_index, tvb, 0 , 0, sctp_info.assoc_index, "disabled (enable in preferences)");
}
- id_dir = find_assoc_index(&tmpinfo, PINFO_FD_VISITED(pinfo));
- sctp_info.assoc_index = id_dir.assoc_index;
- sctp_info.direction = id_dir.direction;
- } else {
- sctp_info.assoc_index = -1;
- sctp_info.direction = ASSOC_NOT_FOUND;
+ proto_item_set_generated(pi);
+ proto_tree_move_item(sctp_tree, vt, pi);
}
/* call dissect_sctp_chunk for the actual work */
if (dissect_sctp_chunk(chunk_tvb, pinfo, tree, sctp_tree, ha, !encapsulated) && (tree)) {
proto_item_set_len(sctp_item, offset - last_offset + DATA_CHUNK_HEADER_LENGTH);
- sctp_item_length_set = TRUE;
+ sctp_item_length_set = true;
offset += total_length;
last_offset = offset;
if (tvb_reported_length_remaining(tvb, offset) > 0) {
sctp_item = proto_tree_add_item(tree, proto_sctp, tvb, offset, -1, ENC_NA);
sctp_tree = proto_item_add_subtree(sctp_item, ett_sctp);
- sctp_item_length_set = FALSE;
+ sctp_item_length_set = false;
}
} else {
/* get rid of the dissected chunk */
@@ -4715,17 +4792,17 @@ dissect_sctp_chunks(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, proto_i
static void
// NOLINTNEXTLINE(misc-no-recursion)
-dissect_sctp_packet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean encapsulated)
+dissect_sctp_packet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, bool encapsulated)
{
- guint32 checksum = 0, calculated_crc32c = 0, calculated_adler32 = 0;
- guint16 source_port, destination_port;
- guint captured_length, reported_length;
- gboolean crc32c_correct = FALSE, adler32_correct = FALSE;
+ uint32_t checksum = 0, calculated_crc32c = 0, calculated_adler32 = 0;
+ uint16_t source_port, destination_port;
+ unsigned captured_length, reported_length;
+ bool crc32c_correct = false, adler32_correct = false;
proto_item *sctp_item, *hidden_item;
proto_tree *sctp_tree;
- guint32 vtag;
+ uint32_t vtag;
sctp_half_assoc_t *ha = NULL;
- proto_item *pi, *vt = NULL;
+ proto_item *vt = NULL;
captured_length = tvb_captured_length(tvb);
reported_length = tvb_reported_length(tvb);
@@ -4742,13 +4819,13 @@ dissect_sctp_packet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolea
case SCTP_CHECKSUM_ADLER32:
calculated_adler32 = sctp_adler32(tvb, captured_length);
adler32_correct = (checksum == calculated_adler32);
- sctp_info.adler32_calculated = TRUE;
+ sctp_info.adler32_calculated = true;
sctp_info.adler32_correct = adler32_correct;
break;
case SCTP_CHECKSUM_CRC32C:
calculated_crc32c = sctp_crc32c(tvb, captured_length);
crc32c_correct = (checksum == calculated_crc32c);
- sctp_info.crc32c_calculated = TRUE;
+ sctp_info.crc32c_calculated = true;
sctp_info.crc32c_correct = crc32c_correct;
break;
case SCTP_CHECKSUM_AUTOMATIC:
@@ -4756,9 +4833,9 @@ dissect_sctp_packet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolea
adler32_correct = (checksum == calculated_adler32);
calculated_crc32c = sctp_crc32c(tvb, captured_length);
crc32c_correct = (checksum == calculated_crc32c);
- sctp_info.adler32_calculated = TRUE;
+ sctp_info.adler32_calculated = true;
sctp_info.adler32_correct = adler32_correct;
- sctp_info.crc32c_calculated = TRUE;
+ sctp_info.crc32c_calculated = true;
sctp_info.crc32c_correct = crc32c_correct;
break;
}
@@ -4836,31 +4913,22 @@ dissect_sctp_packet(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolea
}
/* add all chunks of the sctp datagram to the protocol tree */
- dissect_sctp_chunks(tvb, pinfo, tree, sctp_item, sctp_tree, ha, encapsulated);
+ dissect_sctp_chunks(tvb, pinfo, tree, sctp_item, sctp_tree, ha, encapsulated, vt);
- /* add assoc_index and move it behind the verification tag */
- if (enable_association_indexing) {
- pi = proto_tree_add_uint(sctp_tree, hf_sctp_assoc_index, tvb, 0 , 0, sctp_info.assoc_index);
- }
- else {
- pi = proto_tree_add_uint_format_value(sctp_tree, hf_sctp_assoc_index, tvb, 0 , 0, sctp_info.assoc_index, "disabled (enable in preferences)");
- }
- proto_item_set_generated(pi);
- proto_tree_move_item(sctp_tree, vt, pi);
}
-static gboolean
-capture_sctp(const guchar *pd _U_, int offset _U_, int len _U_, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header _U_)
+static bool
+capture_sctp(const unsigned char *pd _U_, int offset _U_, int len _U_, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header _U_)
{
capture_dissector_increment_count(cpinfo, proto_sctp);
- return TRUE;
+ return true;
}
static int
dissect_sctp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
{
- guint16 source_port, destination_port;
- guint number_of_ppid;
+ uint16_t source_port, destination_port;
+ unsigned number_of_ppid;
/* Extract the common header */
source_port = tvb_get_ntohs(tvb, SOURCE_PORT_OFFSET);
@@ -4896,6 +4964,9 @@ dissect_sctp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
sctp_info.vtag_reflected = 0;
sctp_info.number_of_tvbs = 0;
sctp_info.verification_tag = tvb_get_ntohl(tvb, VERIFICATION_TAG_OFFSET);
+ /* Initialize these to unknown */
+ sctp_info.assoc_index = -1;
+ sctp_info.direction = ASSOC_NOT_FOUND;
sctp_info.sport = pinfo->srcport;
sctp_info.dport = pinfo->destport;
@@ -4905,9 +4976,22 @@ dissect_sctp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
p_add_proto_data(pinfo->pool, pinfo, hf_source_port, pinfo->curr_layer_num, GUINT_TO_POINTER(pinfo->srcport));
p_add_proto_data(pinfo->pool, pinfo, hf_destination_port, pinfo->curr_layer_num, GUINT_TO_POINTER(pinfo->destport));
- dissect_sctp_packet(tvb, pinfo, tree, FALSE);
- if (!pinfo->flags.in_error_pkt && sctp_info.number_of_tvbs > 0)
- tap_queue_packet(sctp_tap, pinfo, &sctp_info);
+ TRY {
+ dissect_sctp_packet(tvb, pinfo, tree, false);
+ }
+
+ FINALLY {
+ if (!pinfo->flags.in_error_pkt && sctp_info.number_of_tvbs > 0)
+ /* XXX: If a (only present in an expired Internet-Draft)
+ * PKTDROP chunk is present, that shouldn't stop us from
+ * tapping the information from the outer encapsulation,
+ * but we'd have to be careful about not updating sctp_info
+ * with information from the encapsulated packet.
+ */
+ tap_queue_packet(sctp_tap, pinfo, &sctp_info);
+ }
+
+ ENDTRY;
return tvb_captured_length(tvb);
}
@@ -4927,6 +5011,7 @@ proto_register_sctp(void)
{ &hf_checksum_adler, { "Checksum (Adler)", "sctp.checksum", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_checksum_crc32c, { "Checksum (CRC32C)", "sctp.checksum", FT_UINT32, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_checksum_status, { "Checksum Status", "sctp.checksum.status", FT_UINT8, BASE_NONE, VALS(proto_checksum_vals), 0x0, NULL, HFILL } },
+ { &hf_chunk, { "Chunk", "sctp.chunk", FT_NONE, BASE_NONE, NULL, 0x0, NULL, HFILL } },
{ &hf_chunk_type, { "Chunk type", "sctp.chunk_type", FT_UINT8, BASE_DEC, VALS(chunk_type_values), 0x0, NULL, HFILL } },
{ &hf_chunk_flags, { "Chunk flags", "sctp.chunk_flags", FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } },
{ &hf_chunk_bit_1, { "Bit", "sctp.chunk_bit_1", FT_BOOLEAN, 8, TFS(&sctp_chunk_bit_1_value), SCTP_CHUNK_BIT_1, NULL, HFILL } },
@@ -5077,7 +5162,7 @@ proto_register_sctp(void)
};
/* Setup protocol subtree array */
- static gint *ett[] = {
+ static int *ett[] = {
&ett_sctp,
&ett_sctp_chunk,
&ett_sctp_chunk_parameter,
@@ -5164,7 +5249,7 @@ proto_register_sctp(void)
chunk_types_uat = uat_new("Chunk types for the statistics dialog",
sizeof(type_field_t),
"statistics_chunk_types",
- TRUE,
+ true,
&type_fields,
&num_type_fields,
0,
@@ -5189,7 +5274,7 @@ proto_register_sctp(void)
&show_relative_tsns);
prefs_register_enum_preference(sctp_module, "checksum", "Checksum type",
"The type of checksum used in SCTP packets",
- &sctp_checksum, sctp_checksum_options, FALSE);
+ &sctp_checksum, sctp_checksum_options, false);
prefs_register_bool_preference(sctp_module, "show_always_control_chunks",
"Show always control chunks",
"Show always SCTP control chunks in the Info column",
@@ -5232,7 +5317,7 @@ proto_register_sctp(void)
sctp_ppi_dissector_table = register_dissector_table("sctp.ppi", "SCTP payload protocol identifier", proto_sctp, FT_UINT32, BASE_HEX);
sctp_handle = register_dissector("sctp", dissect_sctp, proto_sctp);
- sctp_heur_subdissector_list = register_heur_dissector_list("sctp", proto_sctp);
+ sctp_heur_subdissector_list = register_heur_dissector_list_with_description("sctp", "SCTP payload", proto_sctp);
register_init_routine(sctp_init);
register_cleanup_routine(sctp_cleanup);
@@ -5243,7 +5328,12 @@ proto_register_sctp(void)
register_decode_as(&sctp_da_port);
register_decode_as(&sctp_da_ppi);
- register_conversation_table(proto_sctp, FALSE, sctp_conversation_packet, sctp_endpoint_packet);
+ register_conversation_table(proto_sctp, false, sctp_conversation_packet, sctp_endpoint_packet);
+
+ assoc_info_map = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(),
+ sctp_assoc_hash, sctp_assoc_equal);
+ assoc_info_half_map = wmem_map_new_autoreset(wmem_epan_scope(), wmem_file_scope(),
+ sctp_assoc_half_hash, sctp_assoc_half_equal);
}
void