diff options
Diffstat (limited to 'epan/dissectors/packet-erf.c')
-rw-r--r-- | epan/dissectors/packet-erf.c | 1371 |
1 files changed, 673 insertions, 698 deletions
diff --git a/epan/dissectors/packet-erf.c b/epan/dissectors/packet-erf.c index c7247970..f28f932e 100644 --- a/epan/dissectors/packet-erf.c +++ b/epan/dissectors/packet-erf.c @@ -14,7 +14,8 @@ #include <epan/expert.h> #include <epan/prefs.h> #include <epan/ipproto.h> -#include <epan/to_str.h> +#include <epan/tfs.h> +#include <epan/unit_strings.h> #include <wsutil/str_util.h> #include <wiretap/wtap.h> #include <wiretap/erf_record.h> @@ -34,9 +35,9 @@ void proto_reg_handoff_erf(void); typedef struct sdh_g707_format_s { - guint8 m_sdh_line_rate; - guint8 m_vc_size ; - gint8 m_vc_index_array[DECHAN_MAX_AUG_INDEX]; + uint8_t m_sdh_line_rate; + uint8_t m_vc_size ; + int8_t m_vc_index_array[DECHAN_MAX_AUG_INDEX]; /* i = 3 --> ITU-T letter #D - index of AUG-16 * i = 2 --> ITU-T letter #C - index of AUG-4, * i = 1 --> ITU-T letter #B - index of AUG-1 @@ -47,226 +48,235 @@ static dissector_handle_t erf_handle; static dissector_table_t erf_dissector_table; /* Initialize the protocol and registered fields */ -static int proto_erf = -1; - -static int hf_erf_ts = -1; -static int hf_erf_rectype = -1; -static int hf_erf_type = -1; -static int hf_erf_ehdr = -1; -static int hf_erf_ehdr_t = -1; -static int hf_erf_flags = -1; -static int hf_erf_flags_cap = -1; -static int hf_erf_flags_vlen = -1; -static int hf_erf_flags_trunc = -1; -static int hf_erf_flags_rxe = -1; -static int hf_erf_flags_dse = -1; -static int hf_erf_flags_res = -1; - -static int hf_erf_rlen = -1; -static int hf_erf_lctr = -1; -static int hf_erf_color = -1; -static int hf_erf_wlen = -1; +static int proto_erf; + +static int hf_erf_ts; +static int hf_erf_rectype; +static int hf_erf_type; +static int hf_erf_ehdr; +static int hf_erf_ehdr_t; +static int hf_erf_flags; +static int hf_erf_flags_cap; +static int hf_erf_flags_if_raw; +static int hf_erf_flags_vlen; +static int hf_erf_flags_trunc; +static int hf_erf_flags_rxe; +static int hf_erf_flags_dse; +static int hf_erf_flags_res; + +static int hf_erf_rlen; +static int hf_erf_lctr; +static int hf_erf_color; +static int hf_erf_wlen; /* Classification extension header */ /* InterceptID extension header */ -static int hf_erf_ehdr_int_res1 = -1; -static int hf_erf_ehdr_int_id = -1; -static int hf_erf_ehdr_int_res2 = -1; +static int hf_erf_ehdr_int_res1; +static int hf_erf_ehdr_int_id; +static int hf_erf_ehdr_int_res2; /* Raw Link extension header */ -static int hf_erf_ehdr_raw_link_res = -1; -static int hf_erf_ehdr_raw_link_seqnum = -1; -static int hf_erf_ehdr_raw_link_rate = -1; -static int hf_erf_ehdr_raw_link_type = -1; +static int hf_erf_ehdr_raw_link_res; +static int hf_erf_ehdr_raw_link_seqnum; +static int hf_erf_ehdr_raw_link_rate; +static int hf_erf_ehdr_raw_link_type; /* Classification extension header */ -static int hf_erf_ehdr_class_flags = -1; -static int hf_erf_ehdr_class_flags_sh = -1; -static int hf_erf_ehdr_class_flags_shm = -1; -static int hf_erf_ehdr_class_flags_res1 = -1; -static int hf_erf_ehdr_class_flags_user = -1; -static int hf_erf_ehdr_class_flags_res2 = -1; -static int hf_erf_ehdr_class_flags_drop = -1; -static int hf_erf_ehdr_class_flags_str = -1; -static int hf_erf_ehdr_class_seqnum = -1; +static int hf_erf_ehdr_class_flags; +static int hf_erf_ehdr_class_flags_sh; +static int hf_erf_ehdr_class_flags_shm; +static int hf_erf_ehdr_class_flags_res1; +static int hf_erf_ehdr_class_flags_user; +static int hf_erf_ehdr_class_flags_res2; +static int hf_erf_ehdr_class_flags_drop; +static int hf_erf_ehdr_class_flags_str; +static int hf_erf_ehdr_class_seqnum; /* BFS extension header */ -static int hf_erf_ehdr_bfs_hash = -1; -static int hf_erf_ehdr_bfs_color = -1; -static int hf_erf_ehdr_bfs_raw_hash = -1; +static int hf_erf_ehdr_bfs_hash; +static int hf_erf_ehdr_bfs_color; +static int hf_erf_ehdr_bfs_raw_hash; /* Channelised extension header */ -static int hf_erf_ehdr_chan_morebits = -1; -static int hf_erf_ehdr_chan_morefrag = -1; -static int hf_erf_ehdr_chan_seqnum = -1; -static int hf_erf_ehdr_chan_res = -1; -static int hf_erf_ehdr_chan_virt_container_id = -1; -static int hf_erf_ehdr_chan_assoc_virt_container_size = -1; -static int hf_erf_ehdr_chan_rate = -1; -static int hf_erf_ehdr_chan_type = -1; +static int hf_erf_ehdr_chan_morebits; +static int hf_erf_ehdr_chan_morefrag; +static int hf_erf_ehdr_chan_seqnum; +static int hf_erf_ehdr_chan_res; +static int hf_erf_ehdr_chan_virt_container_id; +static int hf_erf_ehdr_chan_assoc_virt_container_size; +static int hf_erf_ehdr_chan_rate; +static int hf_erf_ehdr_chan_type; /* Filter Hash extension header */ -static int hf_erf_ehdr_signature_payload_hash = -1; -static int hf_erf_ehdr_signature_color = -1; -static int hf_erf_ehdr_signature_flow_hash = -1; +static int hf_erf_ehdr_signature_payload_hash; +static int hf_erf_ehdr_signature_color; +static int hf_erf_ehdr_signature_flow_hash; /* Flow ID extension header */ -static int hf_erf_ehdr_flow_id_source_id = -1; -static int hf_erf_ehdr_flow_id_hash_type = -1; -static int hf_erf_ehdr_flow_id_hash_type_type = -1; -static int hf_erf_ehdr_flow_id_hash_type_inner = -1; -static int hf_erf_ehdr_flow_id_stack_type = -1; -static int hf_erf_ehdr_flow_id_flow_hash = -1; +static int hf_erf_ehdr_flow_id_source_id; +static int hf_erf_ehdr_flow_id_hash_type; +static int hf_erf_ehdr_flow_id_hash_type_type; +static int hf_erf_ehdr_flow_id_hash_type_inner; +static int hf_erf_ehdr_flow_id_stack_type; +static int hf_erf_ehdr_flow_id_flow_hash; /* Host ID extension header */ -static int hf_erf_ehdr_host_id_sourceid = -1; -static int hf_erf_ehdr_host_id_hostid = -1; +static int hf_erf_ehdr_host_id_sourceid; +static int hf_erf_ehdr_host_id_hostid; /* Anchor ID extension header */ -static int hf_erf_ehdr_anchor_id_definition = -1; -static int hf_erf_ehdr_anchor_id_reserved = -1; -static int hf_erf_ehdr_anchor_id_anchorid = -1; -static int hf_erf_ehdr_anchor_id_flags = -1; +static int hf_erf_ehdr_anchor_id_definition; +static int hf_erf_ehdr_anchor_id_reserved; +static int hf_erf_ehdr_anchor_id_anchorid; +static int hf_erf_ehdr_anchor_id_flags; -static int hf_erf_anchor_linked = -1; -static int hf_erf_anchor_anchorid = -1; -static int hf_erf_anchor_hostid = -1; +static int hf_erf_anchor_linked; +static int hf_erf_anchor_anchorid; +static int hf_erf_anchor_hostid; /* Generated Host ID/Source ID */ -static int hf_erf_sourceid = -1; -static int hf_erf_hostid = -1; -static int hf_erf_source_current = -1; -static int hf_erf_source_next = -1; -static int hf_erf_source_prev = -1; +static int hf_erf_sourceid; +static int hf_erf_hostid; +static int hf_erf_source_current; +static int hf_erf_source_next; +static int hf_erf_source_prev; /* Entropy extension header */ -static int hf_erf_ehdr_entropy_entropy = -1; -static int hf_erf_ehdr_entropy_entropy_raw = -1; -static int hf_erf_ehdr_entropy_reserved = -1; +static int hf_erf_ehdr_entropy_entropy; +static int hf_erf_ehdr_entropy_entropy_raw; +static int hf_erf_ehdr_entropy_reserved; /* Unknown extension header */ -static int hf_erf_ehdr_unk = -1; +static int hf_erf_ehdr_unk; /* MC HDLC Header */ -static int hf_erf_mc_hdlc = -1; -static int hf_erf_mc_hdlc_cn = -1; -static int hf_erf_mc_hdlc_res1 = -1; -static int hf_erf_mc_hdlc_res2 = -1; -static int hf_erf_mc_hdlc_fcse = -1; -static int hf_erf_mc_hdlc_sre = -1; -static int hf_erf_mc_hdlc_lre = -1; -static int hf_erf_mc_hdlc_afe = -1; -static int hf_erf_mc_hdlc_oe = -1; -static int hf_erf_mc_hdlc_lbe = -1; -static int hf_erf_mc_hdlc_first = -1; -static int hf_erf_mc_hdlc_res3 = -1; +static int hf_erf_mc_hdlc; +static int hf_erf_mc_hdlc_cn; +static int hf_erf_mc_hdlc_res1; +static int hf_erf_mc_hdlc_res2; +static int hf_erf_mc_hdlc_fcse; +static int hf_erf_mc_hdlc_sre; +static int hf_erf_mc_hdlc_lre; +static int hf_erf_mc_hdlc_afe; +static int hf_erf_mc_hdlc_oe; +static int hf_erf_mc_hdlc_lbe; +static int hf_erf_mc_hdlc_first; +static int hf_erf_mc_hdlc_res3; /* MC RAW Header */ -static int hf_erf_mc_raw = -1; -static int hf_erf_mc_raw_int = -1; -static int hf_erf_mc_raw_res1 = -1; -static int hf_erf_mc_raw_sre = -1; -static int hf_erf_mc_raw_lre = -1; -static int hf_erf_mc_raw_res2 = -1; -static int hf_erf_mc_raw_lbe = -1; -static int hf_erf_mc_raw_first = -1; -static int hf_erf_mc_raw_res3 = -1; +static int hf_erf_mc_raw; +static int hf_erf_mc_raw_int; +static int hf_erf_mc_raw_res1; +static int hf_erf_mc_raw_sre; +static int hf_erf_mc_raw_lre; +static int hf_erf_mc_raw_res2; +static int hf_erf_mc_raw_lbe; +static int hf_erf_mc_raw_first; +static int hf_erf_mc_raw_res3; /* MC ATM Header */ -static int hf_erf_mc_atm = -1; -static int hf_erf_mc_atm_cn = -1; -static int hf_erf_mc_atm_res1 = -1; -static int hf_erf_mc_atm_mul = -1; -static int hf_erf_mc_atm_port = -1; -static int hf_erf_mc_atm_res2 = -1; -static int hf_erf_mc_atm_lbe = -1; -static int hf_erf_mc_atm_hec = -1; -static int hf_erf_mc_atm_crc10 = -1; -static int hf_erf_mc_atm_oamcell = -1; -static int hf_erf_mc_atm_first = -1; -static int hf_erf_mc_atm_res3 = -1; +static int hf_erf_mc_atm; +static int hf_erf_mc_atm_cn; +static int hf_erf_mc_atm_res1; +static int hf_erf_mc_atm_mul; +static int hf_erf_mc_atm_port; +static int hf_erf_mc_atm_res2; +static int hf_erf_mc_atm_lbe; +static int hf_erf_mc_atm_hec; +static int hf_erf_mc_atm_crc10; +static int hf_erf_mc_atm_oamcell; +static int hf_erf_mc_atm_first; +static int hf_erf_mc_atm_res3; /* MC Raw link Header */ -static int hf_erf_mc_rawl = -1; -static int hf_erf_mc_rawl_cn = -1; -static int hf_erf_mc_rawl_res1 = -1; -static int hf_erf_mc_rawl_lbe = -1; -static int hf_erf_mc_rawl_first = -1; -static int hf_erf_mc_rawl_res2 = -1; +static int hf_erf_mc_rawl; +static int hf_erf_mc_rawl_cn; +static int hf_erf_mc_rawl_res1; +static int hf_erf_mc_rawl_lbe; +static int hf_erf_mc_rawl_first; +static int hf_erf_mc_rawl_res2; /* MC AAL5 Header */ -static int hf_erf_mc_aal5 = -1; -static int hf_erf_mc_aal5_cn = -1; -static int hf_erf_mc_aal5_res1 = -1; -static int hf_erf_mc_aal5_port = -1; -static int hf_erf_mc_aal5_crcck = -1; -static int hf_erf_mc_aal5_crce = -1; -static int hf_erf_mc_aal5_lenck = -1; -static int hf_erf_mc_aal5_lene = -1; -static int hf_erf_mc_aal5_res2 = -1; -static int hf_erf_mc_aal5_first = -1; -static int hf_erf_mc_aal5_res3 = -1; +static int hf_erf_mc_aal5; +static int hf_erf_mc_aal5_cn; +static int hf_erf_mc_aal5_res1; +static int hf_erf_mc_aal5_port; +static int hf_erf_mc_aal5_crcck; +static int hf_erf_mc_aal5_crce; +static int hf_erf_mc_aal5_lenck; +static int hf_erf_mc_aal5_lene; +static int hf_erf_mc_aal5_res2; +static int hf_erf_mc_aal5_first; +static int hf_erf_mc_aal5_res3; /* MC AAL2 Header */ -static int hf_erf_mc_aal2 = -1; -static int hf_erf_mc_aal2_cn = -1; -static int hf_erf_mc_aal2_res1 = -1; -static int hf_erf_mc_aal2_res2 = -1; -static int hf_erf_mc_aal2_port = -1; -static int hf_erf_mc_aal2_res3 = -1; -static int hf_erf_mc_aal2_first = -1; -static int hf_erf_mc_aal2_maale = -1; -static int hf_erf_mc_aal2_lene = -1; -static int hf_erf_mc_aal2_cid = -1; +static int hf_erf_mc_aal2; +static int hf_erf_mc_aal2_cn; +static int hf_erf_mc_aal2_res1; +static int hf_erf_mc_aal2_res2; +static int hf_erf_mc_aal2_port; +static int hf_erf_mc_aal2_res3; +static int hf_erf_mc_aal2_first; +static int hf_erf_mc_aal2_maale; +static int hf_erf_mc_aal2_lene; +static int hf_erf_mc_aal2_cid; /* AAL2 Header */ -static int hf_erf_aal2 = -1; -static int hf_erf_aal2_cid = -1; -static int hf_erf_aal2_maale = -1; -static int hf_erf_aal2_maalei = -1; -static int hf_erf_aal2_first = -1; -static int hf_erf_aal2_res1 = -1; +static int hf_erf_aal2; +static int hf_erf_aal2_cid; +static int hf_erf_aal2_maale; +static int hf_erf_aal2_maalei; +static int hf_erf_aal2_first; +static int hf_erf_aal2_res1; /* ERF Ethernet header/pad */ -static int hf_erf_eth = -1; -static int hf_erf_eth_off = -1; -static int hf_erf_eth_pad = -1; +static int hf_erf_eth; +static int hf_erf_eth_off; +static int hf_erf_eth_pad; /* ERF Meta record tag */ -static int hf_erf_meta_tag_type = -1; -static int hf_erf_meta_tag_len = -1; -static int hf_erf_meta_tag_unknown = -1; +static int hf_erf_meta_tag_type; +static int hf_erf_meta_tag_len; +static int hf_erf_meta_tag_unknown; /* Initialize the subtree pointers */ -static gint ett_erf = -1; -static gint ett_erf_pseudo_hdr = -1; -static gint ett_erf_rectype = -1; -static gint ett_erf_hash_type = -1; -static gint ett_erf_flags = -1; -static gint ett_erf_mc_hdlc = -1; -static gint ett_erf_mc_raw = -1; -static gint ett_erf_mc_atm = -1; -static gint ett_erf_mc_rawlink = -1; -static gint ett_erf_mc_aal5 = -1; -static gint ett_erf_mc_aal2 = -1; -static gint ett_erf_aal2 = -1; -static gint ett_erf_eth = -1; -static gint ett_erf_meta = -1; -static gint ett_erf_meta_tag = -1; -static gint ett_erf_source = -1; -static gint ett_erf_anchor = -1; -static gint ett_erf_anchor_flags = -1; -static gint ett_erf_entropy_value = -1; - -static expert_field ei_erf_extension_headers_not_shown = EI_INIT; -static expert_field ei_erf_packet_loss = EI_INIT; -static expert_field ei_erf_checksum_error = EI_INIT; -static expert_field ei_erf_meta_section_len_error = EI_INIT; -static expert_field ei_erf_meta_truncated_record = EI_INIT; -static expert_field ei_erf_meta_truncated_tag = EI_INIT; -static expert_field ei_erf_meta_zero_len_tag = EI_INIT; -static expert_field ei_erf_meta_reset = EI_INIT; +static int ett_erf; +static int ett_erf_pseudo_hdr; +static int ett_erf_rectype; +static int ett_erf_hash_type; +static int ett_erf_flags; +static int ett_erf_mc_hdlc; +static int ett_erf_mc_raw; +static int ett_erf_mc_atm; +static int ett_erf_mc_rawlink; +static int ett_erf_mc_aal5; +static int ett_erf_mc_aal2; +static int ett_erf_aal2; +static int ett_erf_eth; +static int ett_erf_meta; +static int ett_erf_meta_tag; +static int ett_erf_source; +static int ett_erf_anchor; +static int ett_erf_anchor_flags; +static int ett_erf_entropy_value; + +static expert_field ei_erf_extension_headers_not_shown; +static expert_field ei_erf_packet_loss; +static expert_field ei_erf_mc_hdlc_checksum_error; +static expert_field ei_erf_mc_hdlc_short_error; +static expert_field ei_erf_mc_hdlc_long_error; +static expert_field ei_erf_mc_hdlc_abort_error; +static expert_field ei_erf_mc_hdlc_octet_error; +static expert_field ei_erf_mc_hdlc_lost_byte_error; +static expert_field ei_erf_rx_error; +static expert_field ei_erf_ds_error; +static expert_field ei_erf_truncation_error; +static expert_field ei_erf_meta_section_len_error; +static expert_field ei_erf_meta_truncated_record; +static expert_field ei_erf_meta_truncated_tag; +static expert_field ei_erf_meta_zero_len_tag; +static expert_field ei_erf_meta_reset; typedef enum { ERF_HDLC_CHDLC = 0, @@ -277,10 +287,10 @@ typedef enum { ERF_HDLC_MAX = 5 } erf_hdlc_type_vals; -static gint erf_hdlc_type = ERF_HDLC_GUESS; +static int erf_hdlc_type = ERF_HDLC_GUESS; static dissector_handle_t chdlc_handle, ppp_handle, frelay_handle, mtp2_handle; -static gboolean erf_rawcell_first = FALSE; +static bool erf_rawcell_first; typedef enum { ERF_AAL5_GUESS = 0, @@ -288,22 +298,11 @@ typedef enum { ERF_AAL5_UNSPEC = 2 } erf_aal5_type_val; -static gint erf_aal5_type = ERF_AAL5_GUESS; +static int erf_aal5_type = ERF_AAL5_GUESS; static dissector_handle_t atm_untruncated_handle; static dissector_handle_t sdh_handle; -/* ERF Header */ -#define ERF_HDR_TYPE_MASK 0x7f -#define ERF_HDR_EHDR_MASK 0x80 -#define ERF_HDR_FLAGS_MASK 0xff -#define ERF_HDR_CAP_MASK 0x03 -#define ERF_HDR_VLEN_MASK 0x04 -#define ERF_HDR_TRUNC_MASK 0x08 -#define ERF_HDR_RXE_MASK 0x10 -#define ERF_HDR_DSE_MASK 0x20 -#define ERF_HDR_RES_MASK 0xC0 - /* ERF Extension Header */ #define ERF_EHDR_FLOW_ID_HASH_TYPE_TYPE_MASK 0x7f #define ERF_EHDR_FLOW_ID_HASH_TYPE_INNER_MASK 0x80 @@ -457,7 +456,7 @@ static const value_string ehdr_type_vals[] = { { 0, NULL } }; -/* Used for Provenance ext_hdrs_added/remvoed, should match the field abbreviation */ +/* Used for Provenance ext_hdrs_added/removed, should match the field abbreviation */ static const value_string ehdr_type_vals_short[] = { { ERF_EXT_HDR_TYPE_CLASSIFICATION , "class"}, { ERF_EXT_HDR_TYPE_INTERCEPTID , "int"}, @@ -703,12 +702,12 @@ static const header_field_info erf_smart_trunc_default_flags[] = { }; typedef struct { - guint16 code; + uint16_t code; header_field_info hfinfo; } erf_meta_hf_template_t; typedef struct { - gint ett_value; + int ett_value; /* * XXX: Must be at least array_length(ehdr_type_vals). Should change to * dynamic (possibly using new proto tree API) if many more fields defined. @@ -721,12 +720,12 @@ typedef struct { } erf_meta_tag_info_ex_t; typedef struct { - guint16 code; - guint16 section; + uint16_t code; + uint16_t section; const erf_meta_hf_template_t* tag_template; const erf_meta_hf_template_t* section_template; - gint ett; + int ett; int hf_value; erf_meta_tag_info_ex_t *extra; /* TODO: could add a type_value and callback here for greater flexibility */ @@ -744,7 +743,7 @@ typedef struct { typedef struct { wmem_map_t* source_map; wmem_map_t* host_anchor_map; - guint64 implicit_host_id; + uint64_t implicit_host_id; } erf_state_t; typedef struct { @@ -753,7 +752,7 @@ typedef struct { } erf_source_info_t; typedef struct { - guint frame_num; + unsigned frame_num; } erf_anchored_info_t; typedef struct { @@ -762,19 +761,19 @@ typedef struct { } erf_host_anchor_info_t; typedef struct { - guint64 host_id; - guint64 anchor_id; + uint64_t host_id; + uint64_t anchor_id; } erf_anchor_key_t; -#define ERF_SOURCE_KEY(host_id, source_id) (((guint64) host_id << 16) | source_id) -#define ERF_TAG_INFO_KEY(tag_info) (((guint32) (tag_info)->section << 16) | (tag_info)->code) +#define ERF_SOURCE_KEY(host_id, source_id) (((uint64_t) host_id << 16) | source_id) +#define ERF_TAG_INFO_KEY(tag_info) (((uint32_t) (tag_info)->section << 16) | (tag_info)->code) static erf_meta_index_t erf_meta_index; static erf_state_t erf_state; /* * XXX: These header_field_info are used as templates for dynamically building - * per-section fields for each tag, as well as appropiate value_string arrays. + * per-section fields for each tag, as well as appropriate value_string arrays. * We abuse the abbrev field to store the short name of the tags. */ static const erf_meta_hf_template_t erf_meta_tags[] = { @@ -839,8 +838,8 @@ static const erf_meta_hf_template_t erf_meta_tags[] = { { ERF_META_TAG_ext_hdrs_added, { "Extension Headers Added", "ext_hdrs_added", FT_BYTES, BASE_NO_DISPLAY_VALUE, NULL, 0x0, NULL, HFILL } }, { ERF_META_TAG_ext_hdrs_removed, { "Extension Headers Removed", "ext_hdrs_removed", FT_BYTES, BASE_NO_DISPLAY_VALUE, NULL, 0x0, NULL, HFILL } }, { ERF_META_TAG_relative_snaplen, { "Relative Snap Length", "relative_snaplen", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } }, - { ERF_META_TAG_temperature, { "Temperature", "temperature", FT_FLOAT, BASE_NONE|BASE_UNIT_STRING, &units_degree_celsius, 0x0, NULL, HFILL } }, - { ERF_META_TAG_power, { "Power Consumption", "power", FT_FLOAT, BASE_NONE|BASE_UNIT_STRING, &units_watt, 0x0, NULL, HFILL } }, + { ERF_META_TAG_temperature, { "Temperature", "temperature", FT_FLOAT, BASE_NONE|BASE_UNIT_STRING, UNS(&units_degree_celsius), 0x0, NULL, HFILL } }, + { ERF_META_TAG_power, { "Power Consumption", "power", FT_FLOAT, BASE_NONE|BASE_UNIT_STRING, UNS(&units_watt), 0x0, NULL, HFILL } }, { ERF_META_TAG_vendor, { "Vendor", "vendor", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } }, { ERF_META_TAG_cpu_threads, { "CPU Threads", "cpu_threads", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } }, @@ -929,8 +928,8 @@ static const erf_meta_hf_template_t erf_meta_tags[] = { { ERF_META_TAG_responder_retx, { "Responder Retransmissions", "responder_retx", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } }, { ERF_META_TAG_initiator_zwin, { "Initiator Zero Window Count", "initiator_zwin", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } }, { ERF_META_TAG_responder_zwin, { "Responder Zero Window Count", "responder_zwin", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } }, - { ERF_META_TAG_initiator_tcp_flags, { "Initiator TCP Flags", "initiator_zwin", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } }, - { ERF_META_TAG_responder_tcp_flags, { "Responder TCP Flags", "responder_zwin", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } }, + { ERF_META_TAG_initiator_tcp_flags, { "Initiator TCP Flags", "initiator_flags", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } }, + { ERF_META_TAG_responder_tcp_flags, { "Responder TCP Flags", "responder_flags", FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } }, { ERF_META_TAG_tcp_irtt, { "TCP Initial Round Trip Time", "tcp_irtt", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0, NULL, HFILL } }, { ERF_META_TAG_start_time, { "Start Time", "start_time", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_UTC, NULL, 0x0, NULL, HFILL } }, @@ -960,8 +959,8 @@ static const erf_meta_hf_template_t erf_meta_tags[] = { { ERF_META_TAG_stream_buf_drop, { "Stream Buffer Drop", "stream_buf_drop", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } }, { ERF_META_TAG_pkt_drop, { "Packet Drop", "packet_drop", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } }, { ERF_META_TAG_record_drop, { "Record Drop", "record_drop", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } }, - { ERF_META_TAG_bandwidth, { "Bandwidth", "bandwidth", FT_UINT64, BASE_DEC|BASE_UNIT_STRING, &units_bit_sec, 0x0, NULL, HFILL } }, - { ERF_META_TAG_duration, { "Duration", "packet_drop", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0, NULL, HFILL } }, + { ERF_META_TAG_bandwidth, { "Bandwidth", "bandwidth", FT_UINT64, BASE_DEC|BASE_UNIT_STRING, UNS(&units_bit_sec), 0x0, NULL, HFILL } }, + { ERF_META_TAG_duration, { "Duration", "duration", FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0, NULL, HFILL } }, { ERF_META_TAG_top_index, { "Top N Index", "top_index", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } }, { ERF_META_TAG_concurrent_flows, { "Concurrent Flows", "concurrent_flows", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } }, { ERF_META_TAG_active_flows, { "Active Flows", "active_flows", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } }, @@ -970,13 +969,13 @@ static const erf_meta_hf_template_t erf_meta_tags[] = { { ERF_META_TAG_active_endpoints, { "Active Endpoints", "active_endpoints", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } }, { ERF_META_TAG_tx_pkts, { "Transmitted Packets", "tx_packets", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } }, { ERF_META_TAG_tx_bytes, { "Transmitted Bytes", "tx_bytes", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } }, - { ERF_META_TAG_rx_bandwidth, { "Receive Bandwidth", "rx_bandwidth", FT_UINT64, BASE_DEC|BASE_UNIT_STRING, &units_bit_sec, 0x0, NULL, HFILL } }, - { ERF_META_TAG_tx_bandwidth, { "Transmit Bandwidth", "tx_bandwidth", FT_UINT64, BASE_DEC|BASE_UNIT_STRING, &units_bit_sec, 0x0, NULL, HFILL } }, + { ERF_META_TAG_rx_bandwidth, { "Receive Bandwidth", "rx_bandwidth", FT_UINT64, BASE_DEC|BASE_UNIT_STRING, UNS(&units_bit_sec), 0x0, NULL, HFILL } }, + { ERF_META_TAG_tx_bandwidth, { "Transmit Bandwidth", "tx_bandwidth", FT_UINT64, BASE_DEC|BASE_UNIT_STRING, UNS(&units_bit_sec), 0x0, NULL, HFILL } }, { ERF_META_TAG_records, { "Records", "records", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } }, { ERF_META_TAG_record_bytes, { "Record Bytes", "record_bytes", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } }, { ERF_META_TAG_pkt_drop_bytes, { "Packet Drop Bytes", "packet_drop_bytes", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } }, { ERF_META_TAG_record_drop_bytes, { "Record Drop Bytes", "record_drop_bytes", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } }, - { ERF_META_TAG_drop_bandwidth, { "Drop Bandwidth", "drop_bandwidth", FT_UINT64, BASE_DEC|BASE_UNIT_STRING, &units_bit_sec, 0x0, NULL, HFILL } }, + { ERF_META_TAG_drop_bandwidth, { "Drop Bandwidth", "drop_bandwidth", FT_UINT64, BASE_DEC|BASE_UNIT_STRING, UNS(&units_bit_sec), 0x0, NULL, HFILL } }, { ERF_META_TAG_retx_pkts, { "Retransmitted Packets", "retx_packets", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } }, { ERF_META_TAG_zwin_pkts, { "Zero-Window Packets", "zwin_packets", FT_UINT64, BASE_DEC, NULL, 0x0, NULL, HFILL } }, @@ -1043,13 +1042,13 @@ static const erf_meta_hf_template_t erf_meta_tags[] = { { ERF_META_TAG_ntp_rootdelay, { "NTP Root Delay", "ntp_root_delay", FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL } }, { ERF_META_TAG_ntp_rootdisp, { "NTP Root Dispersion", "ntp_root_dispersion", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } }, { ERF_META_TAG_ntp_offset, { "NTP Offset", "ntp_offset", FT_INT32, BASE_DEC, NULL, 0x0, NULL, HFILL } }, - { ERF_META_TAG_ntp_frequency, { "NTP Frequency", "ntp_frequency", FT_INT32, BASE_DEC|BASE_UNIT_STRING, &units_hz, 0x0, NULL, HFILL } }, + { ERF_META_TAG_ntp_frequency, { "NTP Frequency", "ntp_frequency", FT_INT32, BASE_DEC|BASE_UNIT_STRING, UNS(&units_hz), 0x0, NULL, HFILL } }, { ERF_META_TAG_ntp_sys_jitter, { "NTP System Jitter", "ntp_sys_jitter", FT_UINT32, BASE_DEC, NULL, 0x0, NULL, HFILL } }, { ERF_META_TAG_ntp_peer_remote, { "NTP Peer Remote", "ntp_peer_remote", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } }, { ERF_META_TAG_ntp_peer_refid, { "NTP Peer Refid", "ntp_peer_refid", FT_STRING, BASE_NONE, NULL, 0x0, NULL, HFILL } } }; -/* Sections are also tags, but enumerate them seperately to make logic simpler */ +/* Sections are also tags, but enumerate them separately to make logic simpler */ static const erf_meta_hf_template_t erf_meta_sections[] = { /* * Some tags (such as generation time) can appear before the first section, @@ -1091,7 +1090,7 @@ static int erf_type_has_color(unsigned int type) { } static erf_meta_tag_info_ex_t* erf_meta_tag_info_ex_new(wmem_allocator_t *allocator) { - gsize i = 0; + size_t i = 0; erf_meta_tag_info_ex_t *extra = wmem_new0(allocator, erf_meta_tag_info_ex_t); extra->ett_value = -1; @@ -1120,7 +1119,7 @@ static erf_meta_tag_info_t* init_section_fields(wmem_array_t *hfri_table, wmem_array_t *ett_table, const erf_meta_hf_template_t *section) { erf_meta_tag_info_t *section_info; - gint *ett_tmp; /* wmem_array_append needs actual memory to copy from */ + int *ett_tmp; /* wmem_array_append needs actual memory to copy from */ hf_register_info hfri_tmp[] = { { NULL, { "Section ID", NULL, FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, /* Section ID */ { NULL, { "Section Length", NULL, FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL }}, /* Section Length */ @@ -1185,8 +1184,8 @@ init_tag_value_subfields(wmem_array_t *hfri_table, erf_meta_tag_info_t *tag_info static erf_meta_tag_info_t* init_ext_hdrs_tag_value_subfields(wmem_array_t *hfri_table, erf_meta_tag_info_t *tag_info) { - gsize i = 0; - gsize num_known_ext_hdrs = array_length(ehdr_type_vals) -1 /*null terminated*/; + size_t i = 0; + size_t num_known_ext_hdrs = array_length(ehdr_type_vals) -1 /*null terminated*/; hf_register_info hfri_tmp = { NULL, { NULL, NULL, FT_BOOLEAN, 32, NULL, 0x1, NULL, HFILL } }; /* Value, will be filled from template */ DISSECTOR_ASSERT(array_length(ehdr_type_vals_short) > num_known_ext_hdrs); @@ -1200,7 +1199,7 @@ init_ext_hdrs_tag_value_subfields(wmem_array_t *hfri_table, erf_meta_tag_info_t for (i = 0; i < num_known_ext_hdrs; i++) { /* Add value subfield */ hfri_tmp.p_id = &tag_info->extra->hf_values[4+i]; - hfri_tmp.hfinfo.bitmask = (guint64)1 << ehdr_type_vals[i].value; + hfri_tmp.hfinfo.bitmask = (uint64_t)1 << ehdr_type_vals[i].value; hfri_tmp.hfinfo.name = ehdr_type_vals[i].strptr; hfri_tmp.hfinfo.abbrev = wmem_strconcat(wmem_epan_scope(), "erf.meta.", tag_info->section_template->hfinfo.abbrev, ".", tag_info->tag_template->hfinfo.abbrev, ".", ehdr_type_vals_short[i].strptr, NULL); @@ -1235,7 +1234,7 @@ static erf_meta_tag_info_t* init_tag_fields(wmem_array_t *hfri_table, wmem_array_t *ett_table, const erf_meta_hf_template_t *section, const erf_meta_hf_template_t *tag) { erf_meta_tag_info_t *tag_info; - gint *ett_tmp; /* wmem_array_append needs actual memory to copy from */ + int *ett_tmp; /* wmem_array_append needs actual memory to copy from */ tag_info = erf_meta_tag_info_new(wmem_epan_scope(), section, tag); @@ -1319,7 +1318,7 @@ init_meta_tags(void) erf_meta_index.vs_list = wmem_array_new(wmem_epan_scope(), sizeof(value_string)); erf_meta_index.vs_abbrev_list = wmem_array_new(wmem_epan_scope(), sizeof(value_string)); erf_meta_index.hfri = wmem_array_new(wmem_epan_scope(), sizeof(hf_register_info)); - erf_meta_index.ett = wmem_array_new(wmem_epan_scope(), sizeof(gint*)); + erf_meta_index.ett = wmem_array_new(wmem_epan_scope(), sizeof(int*)); /* Generate tag fields */ for (j = 0; j < array_length(erf_meta_tags); j++) { @@ -1375,14 +1374,14 @@ static inline value_string *erf_to_value_string(wmem_array_t *array) { return (value_string *)wmem_array_get_raw(array); } -static guint erf_anchor_key_hash(gconstpointer key) { +static unsigned erf_anchor_key_hash(const void *key) { const erf_anchor_key_t *anchor_key = (const erf_anchor_key_t*) key; - return ((guint32)anchor_key->host_id ^ (guint32)anchor_key->anchor_id); + return ((uint32_t)anchor_key->host_id ^ (uint32_t)anchor_key->anchor_id); } -static gboolean erf_anchor_key_equal(gconstpointer a, gconstpointer b) { +static gboolean erf_anchor_key_equal(const void *a, const void *b) { const erf_anchor_key_t *anchor_key_a = (const erf_anchor_key_t*) a ; const erf_anchor_key_t *anchor_key_b = (const erf_anchor_key_t*) b ; @@ -1390,7 +1389,7 @@ static gboolean erf_anchor_key_equal(gconstpointer a, gconstpointer b) { (anchor_key_a->anchor_id & ERF_EXT_HDR_TYPE_ANCHOR_ID) == (anchor_key_b->anchor_id & ERF_EXT_HDR_TYPE_ANCHOR_ID); } -static void erf_host_anchor_info_insert(packet_info *pinfo, guint64 host_id, guint64 anchor_id, guint8 flags _U_) { +static void erf_host_anchor_info_insert(packet_info *pinfo, uint64_t host_id, uint64_t anchor_id, uint8_t flags _U_) { erf_host_anchor_info_t *anchor_info; erf_anchor_key_t key = {host_id, anchor_id}; erf_anchored_info_t *anchored_info; @@ -1425,15 +1424,15 @@ static void erf_host_anchor_info_insert(packet_info *pinfo, guint64 host_id, gui static int -erf_source_append(guint64 host_id, guint8 source_id, guint32 num) +erf_source_append(uint64_t host_id, uint8_t source_id, uint32_t num) { erf_source_info_t *source_info; - guint64 source_key = ERF_SOURCE_KEY(host_id, source_id); + uint64_t source_key = ERF_SOURCE_KEY(host_id, source_id); source_info = (erf_source_info_t*) wmem_map_lookup(erf_state.source_map, &source_key); if (!source_info) { - guint64 *source_key_ptr = wmem_new(wmem_file_scope(), guint64); + uint64_t *source_key_ptr = wmem_new(wmem_file_scope(), uint64_t); *source_key_ptr = source_key; source_info = (erf_source_info_t*) wmem_new(wmem_file_scope(), erf_source_info_t); @@ -1454,14 +1453,14 @@ erf_source_append(guint64 host_id, guint8 source_id, guint32 num) return 0; } -static guint32 -erf_source_find_closest(guint64 host_id, guint8 source_id, guint32 fnum, guint32 *fnum_next_ptr) { +static uint32_t +erf_source_find_closest(uint64_t host_id, uint8_t source_id, uint32_t fnum, uint32_t *fnum_next_ptr) { wmem_list_frame_t *list_frame = NULL; wmem_list_frame_t *list_frame_prev = NULL; erf_source_info_t *source_info = NULL; - guint64 source_key = ERF_SOURCE_KEY(host_id, source_id); - guint32 fnum_prev = G_MAXUINT32; - guint32 fnum_next = G_MAXUINT32; + uint64_t source_key = ERF_SOURCE_KEY(host_id, source_id); + uint32_t fnum_prev = UINT32_MAX; + uint32_t fnum_next = UINT32_MAX; source_info = (erf_source_info_t*) wmem_map_lookup(erf_state.source_map, &source_key); @@ -1473,19 +1472,19 @@ erf_source_find_closest(guint64 host_id, guint8 source_id, guint32 fnum, guint32 /* If looking at a metadata record, get the real previous meta frame */ if (fnum_prev == fnum) { list_frame_prev = wmem_list_frame_prev(list_frame); - fnum_prev = list_frame_prev ? GPOINTER_TO_UINT(wmem_list_frame_data(list_frame_prev)) : G_MAXUINT32; + fnum_prev = list_frame_prev ? GPOINTER_TO_UINT(wmem_list_frame_data(list_frame_prev)) : UINT32_MAX; } list_frame = wmem_list_frame_next(list_frame); - fnum_next = list_frame ? GPOINTER_TO_UINT(wmem_list_frame_data(list_frame)) : G_MAXUINT32; + fnum_next = list_frame ? GPOINTER_TO_UINT(wmem_list_frame_data(list_frame)) : UINT32_MAX; } else { /* * XXX: Edge case: still need the first meta record to find the next one at the * beginning of the file. */ list_frame = wmem_list_head(source_info->meta_list); - fnum_next = list_frame ? GPOINTER_TO_UINT(wmem_list_frame_data(list_frame)) : G_MAXUINT32; - fnum_prev = G_MAXUINT32; + fnum_next = list_frame ? GPOINTER_TO_UINT(wmem_list_frame_data(list_frame)) : UINT32_MAX; + fnum_prev = UINT32_MAX; } } @@ -1497,7 +1496,7 @@ erf_source_find_closest(guint64 host_id, guint8 source_id, guint32 fnum, guint32 /* Copy of atm_guess_traffic_type from atm.c in /wiretap */ static void -erf_atm_guess_lane_type(tvbuff_t *tvb, int offset, guint len, +erf_atm_guess_lane_type(tvbuff_t *tvb, int offset, unsigned len, struct atm_phdr *atm_info) { if (len >= 2) { @@ -1521,7 +1520,7 @@ erf_atm_guess_lane_type(tvbuff_t *tvb, int offset, guint len, } static void -erf_atm_guess_traffic_type(tvbuff_t *tvb, int offset, guint len, +erf_atm_guess_traffic_type(tvbuff_t *tvb, int offset, unsigned len, struct atm_phdr *atm_info) { /* @@ -1561,7 +1560,7 @@ erf_atm_guess_traffic_type(tvbuff_t *tvb, int offset, guint len, */ if (len >= 3) { - guint8 mtp3b; + uint8_t mtp3b; if (tvb_get_ntoh24(tvb, offset) == 0xAAAA03) { /* * Looks like a SNAP header; assume it's LLC @@ -1576,7 +1575,7 @@ erf_atm_guess_traffic_type(tvbuff_t *tvb, int offset, guint len, * Ethernet header) we can try it as a SSCOP frame. */ atm_info->aal = AAL_SIGNALLING; - } else if (((mtp3b = tvb_get_guint8(tvb, offset)) == 0x83) || (mtp3b == 0x81)) { + } else if (((mtp3b = tvb_get_uint8(tvb, offset)) == 0x83) || (mtp3b == 0x81)) { /* * MTP3b headers often encapsulate * a SCCP or MTN in the 3G network. @@ -1603,66 +1602,58 @@ erf_atm_guess_traffic_type(tvbuff_t *tvb, int offset, guint len, static void dissect_classification_ex_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int idx) { - if (tree) { - proto_item *flags_item; - proto_tree *flags_tree; - guint64 hdr = pinfo->pseudo_header->erf.ehdr_list[idx].ehdr; - guint32 value = ((guint32)(hdr >> 32)) & EHDR_CLASS_FLAGS_MASK; - - flags_item = proto_tree_add_uint(tree, hf_erf_ehdr_class_flags, tvb, 0, 0, value); - flags_tree = proto_item_add_subtree(flags_item, ett_erf_flags); - - proto_tree_add_uint(flags_tree, hf_erf_ehdr_class_flags_sh, tvb, 0, 0, value); - proto_tree_add_uint(flags_tree, hf_erf_ehdr_class_flags_shm, tvb, 0, 0, value); - proto_tree_add_uint(flags_tree, hf_erf_ehdr_class_flags_res1, tvb, 0, 0, value); - proto_tree_add_uint(flags_tree, hf_erf_ehdr_class_flags_user, tvb, 0, 0, value); - proto_tree_add_uint(flags_tree, hf_erf_ehdr_class_flags_res2, tvb, 0, 0, value); - proto_tree_add_uint(flags_tree, hf_erf_ehdr_class_flags_drop, tvb, 0, 0, value); - proto_tree_add_uint(flags_tree, hf_erf_ehdr_class_flags_str, tvb, 0, 0, value); - - proto_tree_add_uint(tree, hf_erf_ehdr_class_seqnum, tvb, 0, 0, (guint32)hdr); - } + proto_item *flags_item; + proto_tree *flags_tree; + uint64_t hdr = pinfo->pseudo_header->erf.ehdr_list[idx].ehdr; + uint32_t value = ((uint32_t)(hdr >> 32)) & EHDR_CLASS_FLAGS_MASK; + + flags_item = proto_tree_add_uint(tree, hf_erf_ehdr_class_flags, tvb, 0, 0, value); + flags_tree = proto_item_add_subtree(flags_item, ett_erf_flags); + + proto_tree_add_uint(flags_tree, hf_erf_ehdr_class_flags_sh, tvb, 0, 0, value); + proto_tree_add_uint(flags_tree, hf_erf_ehdr_class_flags_shm, tvb, 0, 0, value); + proto_tree_add_uint(flags_tree, hf_erf_ehdr_class_flags_res1, tvb, 0, 0, value); + proto_tree_add_uint(flags_tree, hf_erf_ehdr_class_flags_user, tvb, 0, 0, value); + proto_tree_add_uint(flags_tree, hf_erf_ehdr_class_flags_res2, tvb, 0, 0, value); + proto_tree_add_uint(flags_tree, hf_erf_ehdr_class_flags_drop, tvb, 0, 0, value); + proto_tree_add_uint(flags_tree, hf_erf_ehdr_class_flags_str, tvb, 0, 0, value); + + proto_tree_add_uint(tree, hf_erf_ehdr_class_seqnum, tvb, 0, 0, (uint32_t)hdr); } static void dissect_intercept_ex_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int idx) { - if (tree) { - guint64 hdr = pinfo->pseudo_header->erf.ehdr_list[idx].ehdr; + uint64_t hdr = pinfo->pseudo_header->erf.ehdr_list[idx].ehdr; - proto_tree_add_uint(tree, hf_erf_ehdr_int_res1, tvb, 0, 0, (guint8)((hdr >> 48) & 0xFF)); - proto_tree_add_uint(tree, hf_erf_ehdr_int_id, tvb, 0, 0, (guint16)((hdr >> 32 ) & 0xFFFF)); - proto_tree_add_uint(tree, hf_erf_ehdr_int_res2, tvb, 0, 0, (guint32)hdr); - } + proto_tree_add_uint(tree, hf_erf_ehdr_int_res1, tvb, 0, 0, (uint8_t)((hdr >> 48) & 0xFF)); + proto_tree_add_uint(tree, hf_erf_ehdr_int_id, tvb, 0, 0, (uint16_t)((hdr >> 32 ) & 0xFFFF)); + proto_tree_add_uint(tree, hf_erf_ehdr_int_res2, tvb, 0, 0, (uint32_t)hdr); } static void dissect_raw_link_ex_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int idx) { - if (tree) { - guint64 hdr = pinfo->pseudo_header->erf.ehdr_list[idx].ehdr; + uint64_t hdr = pinfo->pseudo_header->erf.ehdr_list[idx].ehdr; - proto_tree_add_uint(tree, hf_erf_ehdr_raw_link_res , tvb, 0, 0, (guint32)((hdr >> 32) & 0xFFFFFF)); - proto_tree_add_uint(tree, hf_erf_ehdr_raw_link_seqnum , tvb, 0, 0, (guint32)((hdr >> 16) & 0xffff)); - proto_tree_add_uint(tree, hf_erf_ehdr_raw_link_rate, tvb, 0, 0, (guint32)((hdr >> 8) & 0x00ff)); - proto_tree_add_uint(tree, hf_erf_ehdr_raw_link_type, tvb, 0, 0, (guint32)(hdr & 0x00ff)); - } + proto_tree_add_uint(tree, hf_erf_ehdr_raw_link_res , tvb, 0, 0, (uint32_t)((hdr >> 32) & 0xFFFFFF)); + proto_tree_add_uint(tree, hf_erf_ehdr_raw_link_seqnum , tvb, 0, 0, (uint32_t)((hdr >> 16) & 0xffff)); + proto_tree_add_uint(tree, hf_erf_ehdr_raw_link_rate, tvb, 0, 0, (uint32_t)((hdr >> 8) & 0x00ff)); + proto_tree_add_uint(tree, hf_erf_ehdr_raw_link_type, tvb, 0, 0, (uint32_t)(hdr & 0x00ff)); } static void dissect_bfs_ex_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int idx) { - if (tree) { - guint64 hdr = pinfo->pseudo_header->erf.ehdr_list[idx].ehdr; + uint64_t hdr = pinfo->pseudo_header->erf.ehdr_list[idx].ehdr; - proto_tree_add_uint(tree, hf_erf_ehdr_bfs_hash, tvb, 0, 0, (guint32)((hdr >> 48) & 0xFF)); - proto_tree_add_uint(tree, hf_erf_ehdr_bfs_color, tvb, 0, 0, (guint32)((hdr >> 32) & 0xFFFF)); - proto_tree_add_uint(tree, hf_erf_ehdr_bfs_raw_hash, tvb, 0, 0, (guint32)(hdr & 0xFFFFFFFF)); - } + proto_tree_add_uint(tree, hf_erf_ehdr_bfs_hash, tvb, 0, 0, (uint32_t)((hdr >> 48) & 0xFF)); + proto_tree_add_uint(tree, hf_erf_ehdr_bfs_color, tvb, 0, 0, (uint32_t)((hdr >> 32) & 0xFFFF)); + proto_tree_add_uint(tree, hf_erf_ehdr_bfs_raw_hash, tvb, 0, 0, (uint32_t)(hdr & 0xFFFFFFFF)); } static int -channelised_fill_sdh_g707_format(sdh_g707_format_t* in_fmt, guint16 bit_flds, guint8 vc_size, guint8 rate) +channelised_fill_sdh_g707_format(sdh_g707_format_t* in_fmt, uint16_t bit_flds, uint8_t vc_size, uint8_t rate) { int i = 0; /* i = 3 --> ITU-T letter #D - index of AUG-16 * i = 2 --> ITU-T letter #C - index of AUG-4, @@ -1685,7 +1676,7 @@ channelised_fill_sdh_g707_format(sdh_g707_format_t* in_fmt, guint16 bit_flds, gu /* for STM64 traffic,from #D and so on .. */ for (i = (rate - 2); i >= 0; i--) { - guint8 aug_n_index = 0; + uint8_t aug_n_index = 0; /*if AUG-n is bigger than vc-size*/ if ( i >= (vc_size - 1)) @@ -1706,7 +1697,7 @@ static void channelised_fill_vc_id_string(wmem_strbuf_t* out_string, sdh_g707_format_t* in_fmt) { int i; - gboolean is_printed = FALSE; + bool is_printed = false; static const char* g_vc_size_strings[] = { "unknown", /*0x0*/ @@ -1738,7 +1729,7 @@ channelised_fill_vc_id_string(wmem_strbuf_t* out_string, sdh_g707_format_t* in_f wmem_strbuf_append_printf(out_string, "%s%d", ((is_printed)?", ":""), in_fmt->m_vc_index_array[i]); - is_printed = TRUE; + is_printed = true; } } @@ -1750,7 +1741,7 @@ channelised_fill_vc_id_string(wmem_strbuf_t* out_string, sdh_g707_format_t* in_f wmem_strbuf_append_printf(out_string, "%s%d", ((is_printed)?", ":""), in_fmt->m_vc_index_array[i]); - is_printed = TRUE; + is_printed = true; } } if ( ! is_printed ) @@ -1760,7 +1751,7 @@ channelised_fill_vc_id_string(wmem_strbuf_t* out_string, sdh_g707_format_t* in_f { wmem_strbuf_append_printf(out_string, "%s0", ((is_printed)?", ":"")); - is_printed = TRUE; + is_printed = true; } } wmem_strbuf_append_c(out_string, ')'); @@ -1770,50 +1761,44 @@ channelised_fill_vc_id_string(wmem_strbuf_t* out_string, sdh_g707_format_t* in_f static void dissect_channelised_ex_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int idx) { - guint64 hdr = pinfo->pseudo_header->erf.ehdr_list[idx].ehdr; - guint8 vc_id = (guint8)((hdr >> 24) & 0xFF); - guint8 vc_size = (guint8)((hdr >> 16) & 0xFF); - guint8 line_rate = (guint8)((hdr >> 8) & 0xFF); + uint64_t hdr = pinfo->pseudo_header->erf.ehdr_list[idx].ehdr; + uint8_t vc_id = (uint8_t)((hdr >> 24) & 0xFF); + uint8_t vc_size = (uint8_t)((hdr >> 16) & 0xFF); + uint8_t line_rate = (uint8_t)((hdr >> 8) & 0xFF); sdh_g707_format_t g707_format; wmem_strbuf_t *vc_id_string = wmem_strbuf_create(pinfo->pool); channelised_fill_sdh_g707_format(&g707_format, vc_id, vc_size, line_rate); channelised_fill_vc_id_string(vc_id_string, &g707_format); - if (tree) { - proto_tree_add_boolean(tree, hf_erf_ehdr_chan_morebits, tvb, 0, 0, (guint8)((hdr >> 63) & 0x1)); - proto_tree_add_boolean(tree, hf_erf_ehdr_chan_morefrag, tvb, 0, 0, (guint8)((hdr >> 55) & 0x1)); - proto_tree_add_uint(tree, hf_erf_ehdr_chan_seqnum, tvb, 0, 0, (guint16)((hdr >> 40) & 0x7FFF)); - proto_tree_add_uint(tree, hf_erf_ehdr_chan_res, tvb, 0, 0, (guint8)((hdr >> 32) & 0xFF)); - proto_tree_add_uint_format_value(tree, hf_erf_ehdr_chan_virt_container_id, tvb, 0, 0, vc_id, - "0x%.2x (g.707: %s)", vc_id, wmem_strbuf_get_str(vc_id_string)); - proto_tree_add_uint(tree, hf_erf_ehdr_chan_assoc_virt_container_size, tvb, 0, 0, vc_size); - proto_tree_add_uint(tree, hf_erf_ehdr_chan_rate, tvb, 0, 0, line_rate); - proto_tree_add_uint(tree, hf_erf_ehdr_chan_type, tvb, 0, 0, (guint8)((hdr >> 0) & 0xFF)); - } + proto_tree_add_boolean(tree, hf_erf_ehdr_chan_morebits, tvb, 0, 0, (uint8_t)((hdr >> 63) & 0x1)); + proto_tree_add_boolean(tree, hf_erf_ehdr_chan_morefrag, tvb, 0, 0, (uint8_t)((hdr >> 55) & 0x1)); + proto_tree_add_uint(tree, hf_erf_ehdr_chan_seqnum, tvb, 0, 0, (uint16_t)((hdr >> 40) & 0x7FFF)); + proto_tree_add_uint(tree, hf_erf_ehdr_chan_res, tvb, 0, 0, (uint8_t)((hdr >> 32) & 0xFF)); + proto_tree_add_uint_format_value(tree, hf_erf_ehdr_chan_virt_container_id, tvb, 0, 0, vc_id, + "0x%.2x (g.707: %s)", vc_id, wmem_strbuf_get_str(vc_id_string)); + proto_tree_add_uint(tree, hf_erf_ehdr_chan_assoc_virt_container_size, tvb, 0, 0, vc_size); + proto_tree_add_uint(tree, hf_erf_ehdr_chan_rate, tvb, 0, 0, line_rate); + proto_tree_add_uint(tree, hf_erf_ehdr_chan_type, tvb, 0, 0, (uint8_t)((hdr >> 0) & 0xFF)); } static void dissect_signature_ex_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int idx) { - if(tree) { - guint64 hdr = pinfo->pseudo_header->erf.ehdr_list[idx].ehdr; + uint64_t hdr = pinfo->pseudo_header->erf.ehdr_list[idx].ehdr; - proto_tree_add_uint(tree, hf_erf_ehdr_signature_payload_hash, tvb, 0, 0, (guint32)((hdr >> 32) & 0xFFFFFF)); - proto_tree_add_uint(tree, hf_erf_ehdr_signature_color, tvb, 0, 0, (guint8)((hdr >> 24) & 0xFF)); - proto_tree_add_uint(tree, hf_erf_ehdr_signature_flow_hash, tvb, 0, 0, (guint32)(hdr & 0xFFFFFF)); - } + proto_tree_add_uint(tree, hf_erf_ehdr_signature_payload_hash, tvb, 0, 0, (uint32_t)((hdr >> 32) & 0xFFFFFF)); + proto_tree_add_uint(tree, hf_erf_ehdr_signature_color, tvb, 0, 0, (uint8_t)((hdr >> 24) & 0xFF)); + proto_tree_add_uint(tree, hf_erf_ehdr_signature_flow_hash, tvb, 0, 0, (uint32_t)(hdr & 0xFFFFFF)); } static void dissect_host_id_ex_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int idx) { - if(tree) { - guint64 hdr = pinfo->pseudo_header->erf.ehdr_list[idx].ehdr; + uint64_t hdr = pinfo->pseudo_header->erf.ehdr_list[idx].ehdr; - proto_tree_add_uint(tree, hf_erf_ehdr_host_id_sourceid, tvb, 0, 0, (guint8)((hdr >> 48) & 0xFF)); - proto_tree_add_uint64(tree, hf_erf_ehdr_host_id_hostid, tvb, 0, 0, (hdr & ERF_EHDR_HOST_ID_MASK)); - } + proto_tree_add_uint(tree, hf_erf_ehdr_host_id_sourceid, tvb, 0, 0, (uint8_t)((hdr >> 48) & 0xFF)); + proto_tree_add_uint64(tree, hf_erf_ehdr_host_id_hostid, tvb, 0, 0, (hdr & ERF_EHDR_HOST_ID_MASK)); } static void @@ -1826,46 +1811,42 @@ dissect_anchor_id_ex_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, NULL }; - if(tree) { - guint64 hdr = pinfo->pseudo_header->erf.ehdr_list[idx].ehdr; + uint64_t hdr = pinfo->pseudo_header->erf.ehdr_list[idx].ehdr; - proto_tree_add_bitmask_value(tree, tvb, 0, hf_erf_ehdr_anchor_id_flags, ett_erf_anchor_flags, anchor_flags, (guint8)(hdr >> 48) & 0xff); - proto_tree_add_uint64(tree, hf_erf_ehdr_anchor_id_anchorid, tvb, 0, 0, (hdr & ERF_EHDR_ANCHOR_ID_MASK)); - } + proto_tree_add_bitmask_value(tree, tvb, 0, hf_erf_ehdr_anchor_id_flags, ett_erf_anchor_flags, anchor_flags, (uint8_t)(hdr >> 48) & 0xff); + proto_tree_add_uint64(tree, hf_erf_ehdr_anchor_id_anchorid, tvb, 0, 0, (hdr & ERF_EHDR_ANCHOR_ID_MASK)); } static void dissect_flow_id_ex_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int idx) { - if(tree) { - guint64 hdr = pinfo->pseudo_header->erf.ehdr_list[idx].ehdr; - guint8 hash_type = (guint8)((hdr >> 40) & 0xFF); - proto_item *hash_type_item; - proto_tree *hash_type_tree; - - proto_tree_add_uint(tree, hf_erf_ehdr_flow_id_source_id, tvb, 0, 0, (guint8)((hdr >> 48) & 0xFF)); - - hash_type_item = proto_tree_add_uint_format_value(tree, hf_erf_ehdr_flow_id_hash_type, tvb, 0, 0, hash_type, - "0x%02x (%s%s)", - hash_type, - (hash_type & ERF_EHDR_FLOW_ID_HASH_TYPE_INNER_MASK) ? "Inner " : "", - val_to_str_const( - (hash_type & ERF_EHDR_FLOW_ID_HASH_TYPE_TYPE_MASK), - erf_hash_type, - "Unknown Type")); - - hash_type_tree = proto_item_add_subtree(hash_type_item, ett_erf_hash_type); - proto_tree_add_uint(hash_type_tree, hf_erf_ehdr_flow_id_hash_type_type, tvb, 0, 0, hash_type); - proto_tree_add_uint(hash_type_tree, hf_erf_ehdr_flow_id_hash_type_inner, tvb, 0, 0, hash_type); - - proto_tree_add_uint(tree, hf_erf_ehdr_flow_id_stack_type, tvb, 0, 0, (guint8)((hdr >> 32) & 0xFF)); - proto_tree_add_uint(tree, hf_erf_ehdr_flow_id_flow_hash, tvb, 0, 0, (guint32)(hdr & 0xFFFFFFFF)); - } + uint64_t hdr = pinfo->pseudo_header->erf.ehdr_list[idx].ehdr; + uint8_t hash_type = (uint8_t)((hdr >> 40) & 0xFF); + proto_item *hash_type_item; + proto_tree *hash_type_tree; + + proto_tree_add_uint(tree, hf_erf_ehdr_flow_id_source_id, tvb, 0, 0, (uint8_t)((hdr >> 48) & 0xFF)); + + hash_type_item = proto_tree_add_uint_format_value(tree, hf_erf_ehdr_flow_id_hash_type, tvb, 0, 0, hash_type, + "0x%02x (%s%s)", + hash_type, + (hash_type & ERF_EHDR_FLOW_ID_HASH_TYPE_INNER_MASK) ? "Inner " : "", + val_to_str_const( + (hash_type & ERF_EHDR_FLOW_ID_HASH_TYPE_TYPE_MASK), + erf_hash_type, + "Unknown Type")); + + hash_type_tree = proto_item_add_subtree(hash_type_item, ett_erf_hash_type); + proto_tree_add_uint(hash_type_tree, hf_erf_ehdr_flow_id_hash_type_type, tvb, 0, 0, hash_type); + proto_tree_add_uint(hash_type_tree, hf_erf_ehdr_flow_id_hash_type_inner, tvb, 0, 0, hash_type); + + proto_tree_add_uint(tree, hf_erf_ehdr_flow_id_stack_type, tvb, 0, 0, (uint8_t)((hdr >> 32) & 0xFF)); + proto_tree_add_uint(tree, hf_erf_ehdr_flow_id_flow_hash, tvb, 0, 0, (uint32_t)(hdr & 0xFFFFFFFF)); } static float -entropy_from_entropy_header_value(guint8 entropy_hdr_value) +entropy_from_entropy_header_value(uint8_t entropy_hdr_value) { /* mapping 1-255 to 0.0-8.0 */ /* 255 is 8.0 */ @@ -1877,36 +1858,34 @@ entropy_from_entropy_header_value(guint8 entropy_hdr_value) static void dissect_entropy_ex_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int idx) { - if(tree) { - guint64 hdr = pinfo->pseudo_header->erf.ehdr_list[idx].ehdr; - guint8 entropy_hdr_value = (guint8)((hdr >> 48) & 0xFF); - float entropy; - proto_item *pi; - proto_tree *entropy_value_tree; + uint64_t hdr = pinfo->pseudo_header->erf.ehdr_list[idx].ehdr; + uint8_t entropy_hdr_value = (uint8_t)((hdr >> 48) & 0xFF); + float entropy; + proto_item *pi; + proto_tree *entropy_value_tree; - entropy = entropy_from_entropy_header_value(entropy_hdr_value); + entropy = entropy_from_entropy_header_value(entropy_hdr_value); - pi = proto_tree_add_float_format_value(tree, hf_erf_ehdr_entropy_entropy, tvb, 0, 0, entropy, - "%.2f %s", (double) entropy, entropy == 0.0f ? "(not calculated)":"bits"); - entropy_value_tree = proto_item_add_subtree(pi, ett_erf_entropy_value); - proto_tree_add_uint(entropy_value_tree, hf_erf_ehdr_entropy_entropy_raw, tvb, 0, 0, entropy_hdr_value); + pi = proto_tree_add_float_format_value(tree, hf_erf_ehdr_entropy_entropy, tvb, 0, 0, entropy, + "%.2f %s", (double) entropy, entropy == 0.0f ? "(not calculated)":"bits"); + entropy_value_tree = proto_item_add_subtree(pi, ett_erf_entropy_value); + proto_tree_add_uint(entropy_value_tree, hf_erf_ehdr_entropy_entropy_raw, tvb, 0, 0, entropy_hdr_value); - proto_tree_add_uint64(tree, hf_erf_ehdr_entropy_reserved, tvb, 0, 0, (hdr & 0xFFFFFFFFFFFF)); - } + proto_tree_add_uint64(tree, hf_erf_ehdr_entropy_reserved, tvb, 0, 0, (hdr & 0xFFFFFFFFFFFF)); } -static guint64 -find_host_id(packet_info *pinfo, gboolean *has_anchor_definition) { - guint64 hdr; - guint8 type; - guint8 has_more = pinfo->pseudo_header->erf.phdr.type & 0x80; +static uint64_t +find_host_id(packet_info *pinfo, bool *has_anchor_definition) { + uint64_t hdr; + uint8_t type; + uint8_t has_more = pinfo->pseudo_header->erf.phdr.type & 0x80; int i = 0; - guint64 host_id = ERF_META_HOST_ID_IMPLICIT; - gboolean anchor_definition = FALSE; + uint64_t host_id = ERF_META_HOST_ID_IMPLICIT; + bool anchor_definition = false; while(has_more && (i < MAX_ERF_EHDR)) { hdr = pinfo->pseudo_header->erf.ehdr_list[i].ehdr; - type = (guint8) (hdr >> 56); + type = (uint8_t) (hdr >> 56); switch (type & 0x7f) { case ERF_EXT_HDR_TYPE_HOST_ID: @@ -1915,7 +1894,7 @@ find_host_id(packet_info *pinfo, gboolean *has_anchor_definition) { break; case ERF_EXT_HDR_TYPE_ANCHOR_ID: if ((hdr & ERF_EHDR_ANCHOR_ID_DEFINITION_MASK)) - anchor_definition = TRUE; + anchor_definition = true; break; } has_more = type & 0x80; @@ -1928,325 +1907,303 @@ find_host_id(packet_info *pinfo, gboolean *has_anchor_definition) { return host_id; } -static void dissect_host_anchor_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint64 host_id, guint64 anchor_id, guint8 anchor _U_) { +static void dissect_host_anchor_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, uint64_t host_id, uint64_t anchor_id, uint8_t anchor _U_) { - if(tree) { - erf_anchor_key_t key = {host_id, anchor_id}; - erf_host_anchor_info_t *anchor_info; - erf_anchored_info_t *anchored_info; - wmem_list_frame_t *frame; - wmem_list_t *frame_list; - proto_item *pi = NULL; - proto_tree *subtree; + erf_anchor_key_t key = {host_id, anchor_id}; + erf_host_anchor_info_t *anchor_info; + erf_anchored_info_t *anchored_info; + wmem_list_frame_t *frame; + wmem_list_t *frame_list; + proto_item *pi = NULL; + proto_tree *subtree; - /* TODO: top level linking to most recent frame like we have for Host ID? */ - subtree = proto_tree_add_subtree_format(tree, tvb, 0, 0, ett_erf_anchor, &pi, "Host ID: 0x%012" PRIx64 ", Anchor ID: 0x%012" PRIx64, host_id & ERF_EHDR_HOST_ID_MASK, anchor_id & ERF_EHDR_ANCHOR_ID_MASK); - proto_item_set_generated(pi); + /* TODO: top level linking to most recent frame like we have for Host ID? */ + subtree = proto_tree_add_subtree_format(tree, tvb, 0, 0, ett_erf_anchor, &pi, "Host ID: 0x%012" PRIx64 ", Anchor ID: 0x%012" PRIx64, host_id & ERF_EHDR_HOST_ID_MASK, anchor_id & ERF_EHDR_ANCHOR_ID_MASK); + proto_item_set_generated(pi); - pi = proto_tree_add_uint64(subtree, hf_erf_anchor_hostid, tvb, 0, 0, host_id & ERF_EHDR_HOST_ID_MASK); - proto_item_set_generated(pi); - pi = proto_tree_add_uint64(subtree, hf_erf_anchor_anchorid, tvb, 0, 0, anchor_id & ERF_EHDR_ANCHOR_ID_MASK); - proto_item_set_generated(pi); + pi = proto_tree_add_uint64(subtree, hf_erf_anchor_hostid, tvb, 0, 0, host_id & ERF_EHDR_HOST_ID_MASK); + proto_item_set_generated(pi); + pi = proto_tree_add_uint64(subtree, hf_erf_anchor_anchorid, tvb, 0, 0, anchor_id & ERF_EHDR_ANCHOR_ID_MASK); + proto_item_set_generated(pi); - anchor_info = (erf_host_anchor_info_t*)wmem_map_lookup(erf_state.host_anchor_map, &key); + anchor_info = (erf_host_anchor_info_t*)wmem_map_lookup(erf_state.host_anchor_map, &key); - if(!anchor_info) { - return; - } + if(!anchor_info) { + return; + } - frame_list = anchor_info->anchored_list; - - /* Try to link frames */ - frame = wmem_list_head(frame_list); - while(frame != NULL) { - anchored_info = (erf_anchored_info_t*)wmem_list_frame_data(frame); - if(pinfo->num != anchored_info->frame_num) { - /* Don't list the frame itself */ - pi = proto_tree_add_uint(subtree, hf_erf_anchor_linked, tvb, 0, 0, anchored_info->frame_num); - proto_item_set_generated(pi); - /* XXX: Need to do this each time because pinfo is discarded. Filtering does not reset visited as it does not do a full redissect. - We also might not catch all frames in the first pass (e.g. comment after record). */ - mark_frame_as_depended_upon(pinfo->fd, anchored_info->frame_num); - } - frame = wmem_list_frame_next(frame); + frame_list = anchor_info->anchored_list; + + /* Try to link frames */ + frame = wmem_list_head(frame_list); + while(frame != NULL) { + anchored_info = (erf_anchored_info_t*)wmem_list_frame_data(frame); + if(pinfo->num != anchored_info->frame_num) { + /* Don't list the frame itself */ + pi = proto_tree_add_uint(subtree, hf_erf_anchor_linked, tvb, 0, 0, anchored_info->frame_num); + proto_item_set_generated(pi); + /* XXX: Need to do this each time because pinfo is discarded. Filtering does not reset visited as it does not do a full redissect. + We also might not catch all frames in the first pass (e.g. comment after record). */ + mark_frame_as_depended_upon(pinfo->fd, anchored_info->frame_num); } + frame = wmem_list_frame_next(frame); } } static void -dissect_host_id_source_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint64 host_id, guint8 source_id) +dissect_host_id_source_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, uint64_t host_id, uint8_t source_id) { - if (tree) { - proto_tree *hostid_tree; - proto_item *pi = NULL; - guint32 fnum_current = G_MAXUINT32; - guint32 fnum = G_MAXUINT32; - guint32 fnum_next = G_MAXUINT32; + proto_tree *hostid_tree; + proto_item *pi = NULL; + uint32_t fnum_current = UINT32_MAX; + uint32_t fnum = UINT32_MAX; + uint32_t fnum_next = UINT32_MAX; - fnum = erf_source_find_closest(host_id, source_id, pinfo->num, &fnum_next); + fnum = erf_source_find_closest(host_id, source_id, pinfo->num, &fnum_next); - if (fnum != G_MAXUINT32) { - fnum_current = fnum; - } else { - /* XXX: Possibly undesireable side effect: first metadata record links to next */ - fnum_current = fnum_next; - } + if (fnum != UINT32_MAX) { + fnum_current = fnum; + } else { + /* XXX: Possibly undesirable side effect: first metadata record links to next */ + fnum_current = fnum_next; + } - if (fnum_current != G_MAXUINT32) { - pi = proto_tree_add_uint_format(tree, hf_erf_source_current, tvb, 0, 0, fnum_current, - "Host ID: 0x%012" PRIx64 ", Source ID: %u", host_id, source_id&0xFF); - hostid_tree = proto_item_add_subtree(pi, ett_erf_source); - } else { - /* If we have no frame number to link against, just add a static subtree */ - hostid_tree = proto_tree_add_subtree_format(tree, tvb, 0, 0, ett_erf_source, &pi, - "Host ID: 0x%012" PRIx64 ", Source ID: %u", host_id, source_id&0xFF); - } - proto_item_set_generated(pi); + if (fnum_current != UINT32_MAX) { + pi = proto_tree_add_uint_format(tree, hf_erf_source_current, tvb, 0, 0, fnum_current, + "Host ID: 0x%012" PRIx64 ", Source ID: %u", host_id, source_id&0xFF); + hostid_tree = proto_item_add_subtree(pi, ett_erf_source); + } else { + /* If we have no frame number to link against, just add a static subtree */ + hostid_tree = proto_tree_add_subtree_format(tree, tvb, 0, 0, ett_erf_source, &pi, + "Host ID: 0x%012" PRIx64 ", Source ID: %u", host_id, source_id&0xFF); + } + proto_item_set_generated(pi); + + pi = proto_tree_add_uint64(hostid_tree, hf_erf_hostid, tvb, 0, 0, host_id); + proto_item_set_generated(pi); + pi = proto_tree_add_uint(hostid_tree, hf_erf_sourceid, tvb, 0, 0, source_id); + proto_item_set_generated(pi); - pi = proto_tree_add_uint64(hostid_tree, hf_erf_hostid, tvb, 0, 0, host_id); + if (fnum_next != UINT32_MAX) { + pi = proto_tree_add_uint(hostid_tree, hf_erf_source_next, tvb, 0, 0, fnum_next); proto_item_set_generated(pi); - pi = proto_tree_add_uint(hostid_tree, hf_erf_sourceid, tvb, 0, 0, source_id); + /* XXX: Save the surrounding nearest periodic records when we do a filtered save so we keep native ERF metadata */ + mark_frame_as_depended_upon(pinfo->fd, fnum_next); + } + if (fnum != UINT32_MAX) { + pi = proto_tree_add_uint(hostid_tree, hf_erf_source_prev, tvb, 0, 0, fnum); proto_item_set_generated(pi); - - if (fnum_next != G_MAXUINT32) { - pi = proto_tree_add_uint(hostid_tree, hf_erf_source_next, tvb, 0, 0, fnum_next); - proto_item_set_generated(pi); - /* XXX: Save the surrounding nearest periodic records when we do a filtered save so we keep native ERF metadata */ - mark_frame_as_depended_upon(pinfo->fd, fnum_next); - } - if (fnum != G_MAXUINT32) { - pi = proto_tree_add_uint(hostid_tree, hf_erf_source_prev, tvb, 0, 0, fnum); - proto_item_set_generated(pi); - mark_frame_as_depended_upon(pinfo->fd, fnum); - } + mark_frame_as_depended_upon(pinfo->fd, fnum); } } static void dissect_unknown_ex_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int idx) { - if (tree) { - guint64 hdr = pinfo->pseudo_header->erf.ehdr_list[idx].ehdr; + uint64_t hdr = pinfo->pseudo_header->erf.ehdr_list[idx].ehdr; - proto_tree_add_uint64(tree, hf_erf_ehdr_unk, tvb, 0, 0, hdr); - } + proto_tree_add_uint64(tree, hf_erf_ehdr_unk, tvb, 0, 0, hdr); } static void dissect_mc_hdlc_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - if (tree) { - proto_item *mc_hdlc_item; - proto_tree *mc_hdlc_tree; - guint32 mc_hdlc; - proto_item *pi; - - /* Multi Channel HDLC Header */ - mc_hdlc_item = proto_tree_add_uint(tree, hf_erf_mc_hdlc, tvb, 0, 0, pinfo->pseudo_header->erf.subhdr.mc_hdr); - mc_hdlc_tree = proto_item_add_subtree(mc_hdlc_item, ett_erf_mc_hdlc); - mc_hdlc = pinfo->pseudo_header->erf.subhdr.mc_hdr; - - proto_tree_add_uint(mc_hdlc_tree, hf_erf_mc_hdlc_cn, tvb, 0, 0, mc_hdlc); - proto_tree_add_uint(mc_hdlc_tree, hf_erf_mc_hdlc_res1, tvb, 0, 0, mc_hdlc); - proto_tree_add_uint(mc_hdlc_tree, hf_erf_mc_hdlc_res2, tvb, 0, 0, mc_hdlc); - pi=proto_tree_add_uint(mc_hdlc_tree, hf_erf_mc_hdlc_fcse, tvb, 0, 0, mc_hdlc); - if (mc_hdlc & MC_HDLC_FCSE_MASK) - expert_add_info_format(pinfo, pi, &ei_erf_checksum_error, "ERF MC FCS Error"); - - pi=proto_tree_add_uint(mc_hdlc_tree, hf_erf_mc_hdlc_sre, tvb, 0, 0, mc_hdlc); - if (mc_hdlc & MC_HDLC_SRE_MASK) - expert_add_info_format(pinfo, pi, &ei_erf_checksum_error, "ERF MC Short Record Error, <5 bytes"); - - pi=proto_tree_add_uint(mc_hdlc_tree, hf_erf_mc_hdlc_lre, tvb, 0, 0, mc_hdlc); - if (mc_hdlc & MC_HDLC_LRE_MASK) - expert_add_info_format(pinfo, pi, &ei_erf_checksum_error, "ERF MC Long Record Error, >2047 bytes"); - - pi=proto_tree_add_uint(mc_hdlc_tree, hf_erf_mc_hdlc_afe, tvb, 0, 0, mc_hdlc); - if (mc_hdlc & MC_HDLC_AFE_MASK) - expert_add_info_format(pinfo, pi, &ei_erf_checksum_error, "ERF MC Aborted Frame Error"); - - pi=proto_tree_add_uint(mc_hdlc_tree, hf_erf_mc_hdlc_oe, tvb, 0, 0, mc_hdlc); - if (mc_hdlc & MC_HDLC_OE_MASK) - expert_add_info_format(pinfo, pi, &ei_erf_checksum_error, "ERF MC Octet Error, the closing flag was not octet aligned after bit unstuffing"); - - pi=proto_tree_add_uint(mc_hdlc_tree, hf_erf_mc_hdlc_lbe, tvb, 0, 0, mc_hdlc); - if (mc_hdlc & MC_HDLC_LBE_MASK) - expert_add_info_format(pinfo, pi, &ei_erf_checksum_error, "ERF MC Lost Byte Error"); - - proto_tree_add_uint(mc_hdlc_tree, hf_erf_mc_hdlc_first, tvb, 0, 0, mc_hdlc); - proto_tree_add_uint(mc_hdlc_tree, hf_erf_mc_hdlc_res3, tvb, 0, 0, mc_hdlc); - } + proto_item *mc_hdlc_item; + proto_tree *mc_hdlc_tree; + uint32_t mc_hdlc; + proto_item *pi; + + /* Multi Channel HDLC Header */ + mc_hdlc_item = proto_tree_add_uint(tree, hf_erf_mc_hdlc, tvb, 0, 0, pinfo->pseudo_header->erf.subhdr.mc_hdr); + mc_hdlc_tree = proto_item_add_subtree(mc_hdlc_item, ett_erf_mc_hdlc); + mc_hdlc = pinfo->pseudo_header->erf.subhdr.mc_hdr; + + proto_tree_add_uint(mc_hdlc_tree, hf_erf_mc_hdlc_cn, tvb, 0, 0, mc_hdlc); + proto_tree_add_uint(mc_hdlc_tree, hf_erf_mc_hdlc_res1, tvb, 0, 0, mc_hdlc); + proto_tree_add_uint(mc_hdlc_tree, hf_erf_mc_hdlc_res2, tvb, 0, 0, mc_hdlc); + pi=proto_tree_add_uint(mc_hdlc_tree, hf_erf_mc_hdlc_fcse, tvb, 0, 0, mc_hdlc); + if (mc_hdlc & MC_HDLC_FCSE_MASK) + expert_add_info(pinfo, pi, &ei_erf_mc_hdlc_checksum_error); + + pi=proto_tree_add_uint(mc_hdlc_tree, hf_erf_mc_hdlc_sre, tvb, 0, 0, mc_hdlc); + if (mc_hdlc & MC_HDLC_SRE_MASK) + expert_add_info(pinfo, pi, &ei_erf_mc_hdlc_short_error); + + pi=proto_tree_add_uint(mc_hdlc_tree, hf_erf_mc_hdlc_lre, tvb, 0, 0, mc_hdlc); + if (mc_hdlc & MC_HDLC_LRE_MASK) + expert_add_info(pinfo, pi, &ei_erf_mc_hdlc_long_error); + + pi=proto_tree_add_uint(mc_hdlc_tree, hf_erf_mc_hdlc_afe, tvb, 0, 0, mc_hdlc); + if (mc_hdlc & MC_HDLC_AFE_MASK) + expert_add_info(pinfo, pi, &ei_erf_mc_hdlc_abort_error); + + pi=proto_tree_add_uint(mc_hdlc_tree, hf_erf_mc_hdlc_oe, tvb, 0, 0, mc_hdlc); + if (mc_hdlc & MC_HDLC_OE_MASK) + expert_add_info(pinfo, pi, &ei_erf_mc_hdlc_octet_error); + + pi=proto_tree_add_uint(mc_hdlc_tree, hf_erf_mc_hdlc_lbe, tvb, 0, 0, mc_hdlc); + if (mc_hdlc & MC_HDLC_LBE_MASK) + expert_add_info(pinfo, pi, &ei_erf_mc_hdlc_lost_byte_error); + + proto_tree_add_uint(mc_hdlc_tree, hf_erf_mc_hdlc_first, tvb, 0, 0, mc_hdlc); + proto_tree_add_uint(mc_hdlc_tree, hf_erf_mc_hdlc_res3, tvb, 0, 0, mc_hdlc); } static void dissect_mc_raw_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - if (tree) { - proto_item *mc_raw_item; - proto_tree *mc_raw_tree; - guint32 mc_raw; - - /* Multi Channel RAW Header */ - mc_raw_item = proto_tree_add_uint(tree, hf_erf_mc_raw, tvb, 0, 0, pinfo->pseudo_header->erf.subhdr.mc_hdr); - mc_raw_tree = proto_item_add_subtree(mc_raw_item, ett_erf_mc_raw); - mc_raw = pinfo->pseudo_header->erf.subhdr.mc_hdr; - - proto_tree_add_uint(mc_raw_tree, hf_erf_mc_raw_int, tvb, 0, 0, mc_raw); - proto_tree_add_uint(mc_raw_tree, hf_erf_mc_raw_res1, tvb, 0, 0, mc_raw); - proto_tree_add_uint(mc_raw_tree, hf_erf_mc_raw_sre, tvb, 0, 0, mc_raw); - proto_tree_add_uint(mc_raw_tree, hf_erf_mc_raw_lre, tvb, 0, 0, mc_raw); - proto_tree_add_uint(mc_raw_tree, hf_erf_mc_raw_res2, tvb, 0, 0, mc_raw); - proto_tree_add_uint(mc_raw_tree, hf_erf_mc_raw_lbe, tvb, 0, 0, mc_raw); - proto_tree_add_uint(mc_raw_tree, hf_erf_mc_raw_first, tvb, 0, 0, mc_raw); - proto_tree_add_uint(mc_raw_tree, hf_erf_mc_raw_res3, tvb, 0, 0, mc_raw); - } + proto_item *mc_raw_item; + proto_tree *mc_raw_tree; + uint32_t mc_raw; + + /* Multi Channel RAW Header */ + mc_raw_item = proto_tree_add_uint(tree, hf_erf_mc_raw, tvb, 0, 0, pinfo->pseudo_header->erf.subhdr.mc_hdr); + mc_raw_tree = proto_item_add_subtree(mc_raw_item, ett_erf_mc_raw); + mc_raw = pinfo->pseudo_header->erf.subhdr.mc_hdr; + + proto_tree_add_uint(mc_raw_tree, hf_erf_mc_raw_int, tvb, 0, 0, mc_raw); + proto_tree_add_uint(mc_raw_tree, hf_erf_mc_raw_res1, tvb, 0, 0, mc_raw); + proto_tree_add_uint(mc_raw_tree, hf_erf_mc_raw_sre, tvb, 0, 0, mc_raw); + proto_tree_add_uint(mc_raw_tree, hf_erf_mc_raw_lre, tvb, 0, 0, mc_raw); + proto_tree_add_uint(mc_raw_tree, hf_erf_mc_raw_res2, tvb, 0, 0, mc_raw); + proto_tree_add_uint(mc_raw_tree, hf_erf_mc_raw_lbe, tvb, 0, 0, mc_raw); + proto_tree_add_uint(mc_raw_tree, hf_erf_mc_raw_first, tvb, 0, 0, mc_raw); + proto_tree_add_uint(mc_raw_tree, hf_erf_mc_raw_res3, tvb, 0, 0, mc_raw); } static void dissect_mc_atm_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - if (tree) { - proto_item *mc_atm_item; - proto_tree *mc_atm_tree; - guint32 mc_atm; - - /*"Multi Channel ATM Header"*/ - mc_atm_item = proto_tree_add_uint(tree, hf_erf_mc_atm, tvb, 0, 0, pinfo->pseudo_header->erf.subhdr.mc_hdr); - mc_atm_tree = proto_item_add_subtree(mc_atm_item, ett_erf_mc_atm); - mc_atm = pinfo->pseudo_header->erf.subhdr.mc_hdr; - - proto_tree_add_uint(mc_atm_tree, hf_erf_mc_atm_cn, tvb, 0, 0, mc_atm); - proto_tree_add_uint(mc_atm_tree, hf_erf_mc_atm_res1, tvb, 0, 0, mc_atm); - proto_tree_add_uint(mc_atm_tree, hf_erf_mc_atm_mul, tvb, 0, 0, mc_atm); - - proto_tree_add_uint(mc_atm_tree, hf_erf_mc_atm_port, tvb, 0, 0, mc_atm); - proto_tree_add_uint(mc_atm_tree, hf_erf_mc_atm_res2, tvb, 0, 0, mc_atm); - - proto_tree_add_uint(mc_atm_tree, hf_erf_mc_atm_lbe, tvb, 0, 0, mc_atm); - proto_tree_add_uint(mc_atm_tree, hf_erf_mc_atm_hec, tvb, 0, 0, mc_atm); - proto_tree_add_uint(mc_atm_tree, hf_erf_mc_atm_crc10, tvb, 0, 0, mc_atm); - proto_tree_add_uint(mc_atm_tree, hf_erf_mc_atm_oamcell, tvb, 0, 0, mc_atm); - proto_tree_add_uint(mc_atm_tree, hf_erf_mc_atm_first, tvb, 0, 0, mc_atm); - proto_tree_add_uint(mc_atm_tree, hf_erf_mc_atm_res3, tvb, 0, 0, mc_atm); - } + proto_item *mc_atm_item; + proto_tree *mc_atm_tree; + uint32_t mc_atm; + + /*"Multi Channel ATM Header"*/ + mc_atm_item = proto_tree_add_uint(tree, hf_erf_mc_atm, tvb, 0, 0, pinfo->pseudo_header->erf.subhdr.mc_hdr); + mc_atm_tree = proto_item_add_subtree(mc_atm_item, ett_erf_mc_atm); + mc_atm = pinfo->pseudo_header->erf.subhdr.mc_hdr; + + proto_tree_add_uint(mc_atm_tree, hf_erf_mc_atm_cn, tvb, 0, 0, mc_atm); + proto_tree_add_uint(mc_atm_tree, hf_erf_mc_atm_res1, tvb, 0, 0, mc_atm); + proto_tree_add_uint(mc_atm_tree, hf_erf_mc_atm_mul, tvb, 0, 0, mc_atm); + + proto_tree_add_uint(mc_atm_tree, hf_erf_mc_atm_port, tvb, 0, 0, mc_atm); + proto_tree_add_uint(mc_atm_tree, hf_erf_mc_atm_res2, tvb, 0, 0, mc_atm); + + proto_tree_add_uint(mc_atm_tree, hf_erf_mc_atm_lbe, tvb, 0, 0, mc_atm); + proto_tree_add_uint(mc_atm_tree, hf_erf_mc_atm_hec, tvb, 0, 0, mc_atm); + proto_tree_add_uint(mc_atm_tree, hf_erf_mc_atm_crc10, tvb, 0, 0, mc_atm); + proto_tree_add_uint(mc_atm_tree, hf_erf_mc_atm_oamcell, tvb, 0, 0, mc_atm); + proto_tree_add_uint(mc_atm_tree, hf_erf_mc_atm_first, tvb, 0, 0, mc_atm); + proto_tree_add_uint(mc_atm_tree, hf_erf_mc_atm_res3, tvb, 0, 0, mc_atm); } static void dissect_mc_rawlink_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - if (tree) { - proto_item *mc_rawl_item; - proto_tree *mc_rawl_tree; - guint32 mc_rawl; - - /* Multi Channel RAW Link Header */ - mc_rawl_item = proto_tree_add_uint(tree, hf_erf_mc_rawl, tvb, 0, 0, pinfo->pseudo_header->erf.subhdr.mc_hdr); - mc_rawl_tree = proto_item_add_subtree(mc_rawl_item, ett_erf_mc_rawlink); - mc_rawl = pinfo->pseudo_header->erf.subhdr.mc_hdr; - - proto_tree_add_uint(mc_rawl_tree, hf_erf_mc_rawl_cn, tvb, 0, 0, mc_rawl); - proto_tree_add_uint(mc_rawl_tree, hf_erf_mc_rawl_res1, tvb, 0, 0, mc_rawl); - proto_tree_add_uint(mc_rawl_tree, hf_erf_mc_rawl_lbe, tvb, 0, 0, mc_rawl); - proto_tree_add_uint(mc_rawl_tree, hf_erf_mc_rawl_first, tvb, 0, 0, mc_rawl); - proto_tree_add_uint(mc_rawl_tree, hf_erf_mc_rawl_res2, tvb, 0, 0, mc_rawl); - } + proto_item *mc_rawl_item; + proto_tree *mc_rawl_tree; + uint32_t mc_rawl; + + /* Multi Channel RAW Link Header */ + mc_rawl_item = proto_tree_add_uint(tree, hf_erf_mc_rawl, tvb, 0, 0, pinfo->pseudo_header->erf.subhdr.mc_hdr); + mc_rawl_tree = proto_item_add_subtree(mc_rawl_item, ett_erf_mc_rawlink); + mc_rawl = pinfo->pseudo_header->erf.subhdr.mc_hdr; + + proto_tree_add_uint(mc_rawl_tree, hf_erf_mc_rawl_cn, tvb, 0, 0, mc_rawl); + proto_tree_add_uint(mc_rawl_tree, hf_erf_mc_rawl_res1, tvb, 0, 0, mc_rawl); + proto_tree_add_uint(mc_rawl_tree, hf_erf_mc_rawl_lbe, tvb, 0, 0, mc_rawl); + proto_tree_add_uint(mc_rawl_tree, hf_erf_mc_rawl_first, tvb, 0, 0, mc_rawl); + proto_tree_add_uint(mc_rawl_tree, hf_erf_mc_rawl_res2, tvb, 0, 0, mc_rawl); } static void dissect_mc_aal5_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - if (tree) { - proto_item *mc_aal5_item; - proto_tree *mc_aal5_tree; - guint32 mc_aal5; - - /* Multi Channel AAL5 Header */ - mc_aal5_item = proto_tree_add_uint(tree, hf_erf_mc_aal5, tvb, 0, 0, pinfo->pseudo_header->erf.subhdr.mc_hdr); - mc_aal5_tree = proto_item_add_subtree(mc_aal5_item, ett_erf_mc_aal5); - mc_aal5 = pinfo->pseudo_header->erf.subhdr.mc_hdr; - - proto_tree_add_uint(mc_aal5_tree, hf_erf_mc_aal5_cn, tvb, 0, 0, mc_aal5); - proto_tree_add_uint(mc_aal5_tree, hf_erf_mc_aal5_res1, tvb, 0, 0, mc_aal5); - - proto_tree_add_uint(mc_aal5_tree, hf_erf_mc_aal5_port, tvb, 0, 0, mc_aal5); - proto_tree_add_uint(mc_aal5_tree, hf_erf_mc_aal5_crcck, tvb, 0, 0, mc_aal5); - proto_tree_add_uint(mc_aal5_tree, hf_erf_mc_aal5_crce, tvb, 0, 0, mc_aal5); - proto_tree_add_uint(mc_aal5_tree, hf_erf_mc_aal5_lenck, tvb, 0, 0, mc_aal5); - proto_tree_add_uint(mc_aal5_tree, hf_erf_mc_aal5_lene, tvb, 0, 0, mc_aal5); - - proto_tree_add_uint(mc_aal5_tree, hf_erf_mc_aal5_res2, tvb, 0, 0, mc_aal5); - proto_tree_add_uint(mc_aal5_tree, hf_erf_mc_aal5_first, tvb, 0, 0, mc_aal5); - proto_tree_add_uint(mc_aal5_tree, hf_erf_mc_aal5_res3, tvb, 0, 0, mc_aal5); - } + proto_item *mc_aal5_item; + proto_tree *mc_aal5_tree; + uint32_t mc_aal5; + + /* Multi Channel AAL5 Header */ + mc_aal5_item = proto_tree_add_uint(tree, hf_erf_mc_aal5, tvb, 0, 0, pinfo->pseudo_header->erf.subhdr.mc_hdr); + mc_aal5_tree = proto_item_add_subtree(mc_aal5_item, ett_erf_mc_aal5); + mc_aal5 = pinfo->pseudo_header->erf.subhdr.mc_hdr; + + proto_tree_add_uint(mc_aal5_tree, hf_erf_mc_aal5_cn, tvb, 0, 0, mc_aal5); + proto_tree_add_uint(mc_aal5_tree, hf_erf_mc_aal5_res1, tvb, 0, 0, mc_aal5); + + proto_tree_add_uint(mc_aal5_tree, hf_erf_mc_aal5_port, tvb, 0, 0, mc_aal5); + proto_tree_add_uint(mc_aal5_tree, hf_erf_mc_aal5_crcck, tvb, 0, 0, mc_aal5); + proto_tree_add_uint(mc_aal5_tree, hf_erf_mc_aal5_crce, tvb, 0, 0, mc_aal5); + proto_tree_add_uint(mc_aal5_tree, hf_erf_mc_aal5_lenck, tvb, 0, 0, mc_aal5); + proto_tree_add_uint(mc_aal5_tree, hf_erf_mc_aal5_lene, tvb, 0, 0, mc_aal5); + + proto_tree_add_uint(mc_aal5_tree, hf_erf_mc_aal5_res2, tvb, 0, 0, mc_aal5); + proto_tree_add_uint(mc_aal5_tree, hf_erf_mc_aal5_first, tvb, 0, 0, mc_aal5); + proto_tree_add_uint(mc_aal5_tree, hf_erf_mc_aal5_res3, tvb, 0, 0, mc_aal5); } static void dissect_mc_aal2_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - if (tree) { - proto_item *mc_aal2_item; - proto_tree *mc_aal2_tree; - guint32 mc_aal2; - - /* Multi Channel AAL2 Header */ - mc_aal2_item = proto_tree_add_uint(tree, hf_erf_mc_aal2, tvb, 0, 0, pinfo->pseudo_header->erf.subhdr.mc_hdr); - mc_aal2_tree = proto_item_add_subtree(mc_aal2_item, ett_erf_mc_aal2); - mc_aal2 = pinfo->pseudo_header->erf.subhdr.mc_hdr; - - proto_tree_add_uint(mc_aal2_tree, hf_erf_mc_aal2_cn, tvb, 0, 0, mc_aal2); - proto_tree_add_uint(mc_aal2_tree, hf_erf_mc_aal2_res1, tvb, 0, 0, mc_aal2); - proto_tree_add_uint(mc_aal2_tree, hf_erf_mc_aal2_res2, tvb, 0, 0, mc_aal2); - - proto_tree_add_uint(mc_aal2_tree, hf_erf_mc_aal2_port, tvb, 0, 0, mc_aal2); - proto_tree_add_uint(mc_aal2_tree, hf_erf_mc_aal2_res3, tvb, 0, 0, mc_aal2); - proto_tree_add_uint(mc_aal2_tree, hf_erf_mc_aal2_first, tvb, 0, 0, mc_aal2); - proto_tree_add_uint(mc_aal2_tree, hf_erf_mc_aal2_maale, tvb, 0, 0, mc_aal2); - proto_tree_add_uint(mc_aal2_tree, hf_erf_mc_aal2_lene, tvb, 0, 0, mc_aal2); - - proto_tree_add_uint(mc_aal2_tree, hf_erf_mc_aal2_cid, tvb, 0, 0, mc_aal2); - } + proto_item *mc_aal2_item; + proto_tree *mc_aal2_tree; + uint32_t mc_aal2; + + /* Multi Channel AAL2 Header */ + mc_aal2_item = proto_tree_add_uint(tree, hf_erf_mc_aal2, tvb, 0, 0, pinfo->pseudo_header->erf.subhdr.mc_hdr); + mc_aal2_tree = proto_item_add_subtree(mc_aal2_item, ett_erf_mc_aal2); + mc_aal2 = pinfo->pseudo_header->erf.subhdr.mc_hdr; + + proto_tree_add_uint(mc_aal2_tree, hf_erf_mc_aal2_cn, tvb, 0, 0, mc_aal2); + proto_tree_add_uint(mc_aal2_tree, hf_erf_mc_aal2_res1, tvb, 0, 0, mc_aal2); + proto_tree_add_uint(mc_aal2_tree, hf_erf_mc_aal2_res2, tvb, 0, 0, mc_aal2); + + proto_tree_add_uint(mc_aal2_tree, hf_erf_mc_aal2_port, tvb, 0, 0, mc_aal2); + proto_tree_add_uint(mc_aal2_tree, hf_erf_mc_aal2_res3, tvb, 0, 0, mc_aal2); + proto_tree_add_uint(mc_aal2_tree, hf_erf_mc_aal2_first, tvb, 0, 0, mc_aal2); + proto_tree_add_uint(mc_aal2_tree, hf_erf_mc_aal2_maale, tvb, 0, 0, mc_aal2); + proto_tree_add_uint(mc_aal2_tree, hf_erf_mc_aal2_lene, tvb, 0, 0, mc_aal2); + + proto_tree_add_uint(mc_aal2_tree, hf_erf_mc_aal2_cid, tvb, 0, 0, mc_aal2); } static void dissect_aal2_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - if (tree) { - proto_item *aal2_item; - proto_tree *aal2_tree; - guint32 aal2; + proto_item *aal2_item; + proto_tree *aal2_tree; + uint32_t aal2; - /* AAL2 Header */ - aal2_item = proto_tree_add_uint(tree, hf_erf_aal2, tvb, 0, 0, pinfo->pseudo_header->erf.subhdr.mc_hdr); - aal2_tree = proto_item_add_subtree(aal2_item, ett_erf_aal2); - aal2 = pinfo->pseudo_header->erf.subhdr.aal2_hdr; + /* AAL2 Header */ + aal2_item = proto_tree_add_uint(tree, hf_erf_aal2, tvb, 0, 0, pinfo->pseudo_header->erf.subhdr.mc_hdr); + aal2_tree = proto_item_add_subtree(aal2_item, ett_erf_aal2); + aal2 = pinfo->pseudo_header->erf.subhdr.aal2_hdr; - proto_tree_add_uint(aal2_tree, hf_erf_aal2_cid, tvb, 0, 0, aal2); + proto_tree_add_uint(aal2_tree, hf_erf_aal2_cid, tvb, 0, 0, aal2); - proto_tree_add_uint(aal2_tree, hf_erf_aal2_maale, tvb, 0, 0, aal2); + proto_tree_add_uint(aal2_tree, hf_erf_aal2_maale, tvb, 0, 0, aal2); - proto_tree_add_uint(aal2_tree, hf_erf_aal2_maalei, tvb, 0, 0, aal2); - proto_tree_add_uint(aal2_tree, hf_erf_aal2_first, tvb, 0, 0, aal2); - proto_tree_add_uint(aal2_tree, hf_erf_aal2_res1, tvb, 0, 0, aal2); - } + proto_tree_add_uint(aal2_tree, hf_erf_aal2_maalei, tvb, 0, 0, aal2); + proto_tree_add_uint(aal2_tree, hf_erf_aal2_first, tvb, 0, 0, aal2); + proto_tree_add_uint(aal2_tree, hf_erf_aal2_res1, tvb, 0, 0, aal2); } static void dissect_eth_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - if (tree) { - proto_item *eth_item; - proto_tree *eth_tree; - guint8 eth_offset, eth_pad; + proto_item *eth_item; + proto_tree *eth_tree; + uint8_t eth_offset, eth_pad; - eth_item = proto_tree_add_item(tree, hf_erf_eth, tvb, 0, 0, ENC_NA); + eth_item = proto_tree_add_item(tree, hf_erf_eth, tvb, 0, 0, ENC_NA); - eth_tree = proto_item_add_subtree(eth_item, ett_erf_eth); - eth_offset = pinfo->pseudo_header->erf.subhdr.eth_hdr.offset; - eth_pad = pinfo->pseudo_header->erf.subhdr.eth_hdr.pad; + eth_tree = proto_item_add_subtree(eth_item, ett_erf_eth); + eth_offset = pinfo->pseudo_header->erf.subhdr.eth_hdr.offset; + eth_pad = pinfo->pseudo_header->erf.subhdr.eth_hdr.pad; - proto_tree_add_uint(eth_tree, hf_erf_eth_off, tvb, 0, 0, eth_offset); - proto_tree_add_uint(eth_tree, hf_erf_eth_pad, tvb, 0, 0, eth_pad); - } + proto_tree_add_uint(eth_tree, hf_erf_eth_off, tvb, 0, 0, eth_offset); + proto_tree_add_uint(eth_tree, hf_erf_eth_pad, tvb, 0, 0, eth_pad); } static void @@ -2255,6 +2212,7 @@ dissect_erf_pseudo_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item *pi; proto_item *flags_item, *rectype_item; proto_tree *flags_tree, *rectype_tree; + bool has_flags = false; proto_tree_add_uint64(tree, hf_erf_ts, tvb, 0, 0, pinfo->pseudo_header->erf.phdr.ts); @@ -2274,31 +2232,37 @@ dissect_erf_pseudo_header(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) flags_item=proto_tree_add_uint(tree, hf_erf_flags, tvb, 0, 0, pinfo->pseudo_header->erf.phdr.flags); flags_tree = proto_item_add_subtree(flags_item, ett_erf_flags); - proto_tree_add_uint(flags_tree, hf_erf_flags_cap, tvb, 0, 0, pinfo->pseudo_header->erf.phdr.flags); - proto_item_append_text(flags_item, " (Capture Interface: %d", pinfo->pseudo_header->erf.phdr.flags & ERF_HDR_CAP_MASK); + proto_tree_add_uint(flags_tree, hf_erf_flags_if_raw, tvb, 0, 0, pinfo->pseudo_header->erf.phdr.flags); proto_tree_add_uint(flags_tree, hf_erf_flags_vlen, tvb, 0, 0, pinfo->pseudo_header->erf.phdr.flags); pi=proto_tree_add_uint(flags_tree, hf_erf_flags_trunc, tvb, 0, 0, pinfo->pseudo_header->erf.phdr.flags); if (pinfo->pseudo_header->erf.phdr.flags & ERF_HDR_TRUNC_MASK) { - proto_item_append_text(flags_item, "; ERF Truncation Error"); - expert_add_info_format(pinfo, pi, &ei_erf_checksum_error, "ERF Truncation Error"); + proto_item_append_text(flags_item, "(ERF Truncation Error"); + expert_add_info(pinfo, pi, &ei_erf_truncation_error); + has_flags = true; } pi=proto_tree_add_uint(flags_tree, hf_erf_flags_rxe, tvb, 0, 0, pinfo->pseudo_header->erf.phdr.flags); if (pinfo->pseudo_header->erf.phdr.flags & ERF_HDR_RXE_MASK) { - proto_item_append_text(flags_item, "; ERF Rx Error"); - expert_add_info_format(pinfo, pi, &ei_erf_checksum_error, "ERF Rx Error"); + proto_item_append_text(flags_item, "%sERF Rx Error", has_flags ? "; " : "("); + expert_add_info(pinfo, pi, &ei_erf_rx_error); + has_flags = true; } pi=proto_tree_add_uint(flags_tree, hf_erf_flags_dse, tvb, 0, 0, pinfo->pseudo_header->erf.phdr.flags); if (pinfo->pseudo_header->erf.phdr.flags & ERF_HDR_DSE_MASK) { - proto_item_append_text(flags_item, "; ERF DS Error"); - expert_add_info_format(pinfo, pi, &ei_erf_checksum_error, "ERF DS Error"); + proto_item_append_text(flags_item, "%sERF DS Error", has_flags ? "; " : "("); + expert_add_info(pinfo, pi, &ei_erf_ds_error); + has_flags = true; + } + if (has_flags) { + proto_item_append_text(flags_item, ")"); } - proto_item_append_text(flags_item, ")"); proto_tree_add_uint(flags_tree, hf_erf_flags_res, tvb, 0, 0, pinfo->pseudo_header->erf.phdr.flags); + proto_tree_add_uint(tree, hf_erf_flags_cap, tvb, 0, 0, erf_interface_id_from_flags(pinfo->pseudo_header->erf.phdr.flags)); + proto_tree_add_uint(tree, hf_erf_rlen, tvb, 0, 0, pinfo->pseudo_header->erf.phdr.rlen); if (erf_type_has_color(pinfo->pseudo_header->erf.phdr.type)) { @@ -2317,16 +2281,16 @@ dissect_erf_pseudo_extension_header(tvbuff_t *tvb, packet_info *pinfo, proto_tre { proto_item *pi; proto_item *ehdr_tree; - guint64 hdr; - guint8 type; - guint8 has_more = pinfo->pseudo_header->erf.phdr.type & 0x80; + uint64_t hdr; + uint8_t type; + uint8_t has_more = pinfo->pseudo_header->erf.phdr.type & 0x80; int i = 0; - int max = sizeof(pinfo->pseudo_header->erf.ehdr_list)/sizeof(struct erf_ehdr); + int max = array_length(pinfo->pseudo_header->erf.ehdr_list); - guint64 host_id = ERF_META_HOST_ID_IMPLICIT; - guint8 source_id = 0; - gboolean found_host_id = FALSE; - gboolean has_anchor_definition = FALSE; + uint64_t host_id = ERF_META_HOST_ID_IMPLICIT; + uint8_t source_id = 0; + bool found_host_id = false; + bool has_anchor_definition = false; /* * Get the first Host ID of the record (which may not be the first extension @@ -2342,14 +2306,14 @@ dissect_erf_pseudo_extension_header(tvbuff_t *tvb, packet_info *pinfo, proto_tre * Host ID 0 (unset). */ host_id = erf_state.implicit_host_id; - found_host_id = FALSE; + found_host_id = false; } else { - found_host_id = TRUE; + found_host_id = true; } while(has_more && (i < max)) { hdr = pinfo->pseudo_header->erf.ehdr_list[i].ehdr; - type = (guint8) (hdr >> 56); + type = (uint8_t) (hdr >> 56); pi = proto_tree_add_uint(tree, hf_erf_ehdr_t, tvb, 0, 0, (type & 0x7f)); ehdr_tree = proto_item_add_subtree(pi, ett_erf_pseudo_hdr); @@ -2375,13 +2339,13 @@ dissect_erf_pseudo_extension_header(tvbuff_t *tvb, packet_info *pinfo, proto_tre break; case ERF_EXT_HDR_TYPE_FLOW_ID: if (source_id == 0) { - source_id = (guint8)((hdr >> 48) & 0xFF); + source_id = (uint8_t)((hdr >> 48) & 0xFF); } dissect_flow_id_ex_header(tvb, pinfo, ehdr_tree, i); break; case ERF_EXT_HDR_TYPE_HOST_ID: host_id = hdr & ERF_EHDR_HOST_ID_MASK; - source_id = (guint8)((hdr >> 48) & 0xFF); + source_id = (uint8_t)((hdr >> 48) & 0xFF); dissect_host_id_ex_header(tvb, pinfo, ehdr_tree, i); /* Track and dissect combined Host ID and Source ID(s) */ @@ -2412,9 +2376,9 @@ dissect_erf_pseudo_extension_header(tvbuff_t *tvb, packet_info *pinfo, proto_tre case ERF_EXT_HDR_TYPE_ANCHOR_ID: dissect_anchor_id_ex_header(tvb, pinfo, ehdr_tree, i); if (!PINFO_FD_VISITED(pinfo)) { - erf_host_anchor_info_insert(pinfo, host_id, hdr & ERF_EHDR_ANCHOR_ID_MASK, (guint8)(hdr >> 48)); + erf_host_anchor_info_insert(pinfo, host_id, hdr & ERF_EHDR_ANCHOR_ID_MASK, (uint8_t)(hdr >> 48)); } - dissect_host_anchor_id(tvb, pinfo, tree, host_id, hdr & ERF_EHDR_ANCHOR_ID_MASK, (guint8)(hdr >> 48)); + dissect_host_anchor_id(tvb, pinfo, tree, host_id, hdr & ERF_EHDR_ANCHOR_ID_MASK, (uint8_t)(hdr >> 48)); break; case ERF_EXT_HDR_TYPE_ENTROPY: dissect_entropy_ex_header(tvb, pinfo, ehdr_tree, i); @@ -2451,9 +2415,9 @@ dissect_erf_pseudo_extension_header(tvbuff_t *tvb, packet_info *pinfo, proto_tre } } -guint64* erf_get_ehdr(packet_info *pinfo, guint8 hdrtype, gint* afterindex) { - guint8 type; - guint8 has_more; +uint64_t* erf_get_ehdr(packet_info *pinfo, uint8_t hdrtype, int* afterindex) { + uint8_t type; + uint8_t has_more; int max; int i = afterindex ? *afterindex + 1 : 0; /*allow specifying instance to start after for use in loop*/ @@ -2461,11 +2425,11 @@ guint64* erf_get_ehdr(packet_info *pinfo, guint8 hdrtype, gint* afterindex) { return NULL; has_more = pinfo->pseudo_header->erf.phdr.type & 0x80; - max = sizeof(pinfo->pseudo_header->erf.ehdr_list)/sizeof(struct erf_ehdr); + max = array_length(pinfo->pseudo_header->erf.ehdr_list); while(has_more && (i < max)) { - type = (guint8) (pinfo->pseudo_header->erf.ehdr_list[i].ehdr >> 56); + type = (uint8_t) (pinfo->pseudo_header->erf.ehdr_list[i].ehdr >> 56); if ((type & 0x7f) == (hdrtype & 0x7f)) { if (afterindex) @@ -2516,19 +2480,19 @@ dissect_meta_tag_bitfield(proto_item *section_tree, tvbuff_t *tvb, int offset, e } static proto_item* -dissect_meta_tag_ext_hdrs(proto_item *section_tree, tvbuff_t *tvb, int offset, gint taglength, erf_meta_tag_info_t *tag_info, proto_item **out_tag_tree, expert_field **out_truncated_expert) +dissect_meta_tag_ext_hdrs(proto_item *section_tree, tvbuff_t *tvb, int offset, int taglength, erf_meta_tag_info_t *tag_info, proto_item **out_tag_tree, expert_field **out_truncated_expert) { proto_item *tag_pi = NULL; proto_tree *subtree = NULL; proto_item *subtree_pi = NULL; int i; - guint32 ext_hdrs[4] = {0, 0, 0, 0}; + uint32_t ext_hdrs[4] = {0, 0, 0, 0}; int int_offset = 0; - int int_avail = MIN(taglength / 4, 4);; + int int_avail = MIN(taglength / 4, 4); int bit_offset = 0; int ext_hdr_num = 0; - gboolean first = TRUE; - gboolean all_set = TRUE; + bool first = true; + bool all_set = true; DISSECTOR_ASSERT(tag_info->extra); @@ -2536,9 +2500,9 @@ dissect_meta_tag_ext_hdrs(proto_item *section_tree, tvbuff_t *tvb, int offset, g *out_tag_tree = proto_item_add_subtree(tag_pi, tag_info->ett); for (int_offset = 0; int_offset < int_avail; int_offset++) { - ext_hdrs[int_offset] = tvb_get_guint32(tvb, offset + 4 + int_offset*4, ENC_BIG_ENDIAN); - if (ext_hdrs[int_offset] != G_MAXUINT32) - all_set = FALSE; + ext_hdrs[int_offset] = tvb_get_uint32(tvb, offset + 4 + int_offset*4, ENC_BIG_ENDIAN); + if (ext_hdrs[int_offset] != UINT32_MAX) + all_set = false; } /* Special case: all specified bits are 1 means all extension headers */ @@ -2568,7 +2532,7 @@ dissect_meta_tag_ext_hdrs(proto_item *section_tree, tvbuff_t *tvb, int offset, g if (!all_set) proto_item_append_text(tag_pi, "%s %s", first ? ":" : ",", val_to_str(ext_hdr_num, ehdr_type_vals, "%d")); - first = FALSE; + first = false; } ext_hdr_num++; @@ -2586,12 +2550,12 @@ dissect_meta_tag_ext_hdrs(proto_item *section_tree, tvbuff_t *tvb, int offset, g return tag_pi; } -static void erf_ts_to_nstime(guint64 timestamp, nstime_t* t, gboolean is_relative) { - guint64 ts = timestamp; +static void erf_ts_to_nstime(uint64_t timestamp, nstime_t* t, bool is_relative) { + uint64_t ts = timestamp; /* relative ERF timestamps are signed, convert as if unsigned then flip back */ if (is_relative) { - ts = (guint64) ABS((gint64)timestamp); + ts = (uint64_t) ABS((int64_t)timestamp); } @@ -2604,7 +2568,7 @@ static void erf_ts_to_nstime(guint64 timestamp, nstime_t* t, gboolean is_relativ t->secs += 1; } - if (is_relative && (gint64)timestamp < 0) { + if (is_relative && (int64_t)timestamp < 0) { /* * Set both signs to negative for consistency with other nstime code * and so -0.123 works. @@ -2615,7 +2579,7 @@ static void erf_ts_to_nstime(guint64 timestamp, nstime_t* t, gboolean is_relativ } /* TODO: Would be nice if default FT_RELATIVE_TIME formatter was prettier */ -static proto_item *dissect_relative_time(proto_tree *tree, const int hfindex, tvbuff_t *tvb, gint offset, gint length, nstime_t* t) { +static proto_item *dissect_relative_time(proto_tree *tree, const int hfindex, tvbuff_t *tvb, int offset, int length, nstime_t* t) { proto_item *pi = NULL; DISSECTOR_ASSERT(t); @@ -2630,16 +2594,16 @@ static proto_item *dissect_relative_time(proto_tree *tree, const int hfindex, tv return pi; } -static proto_item *dissect_ptp_timeinterval(proto_tree *tree, const int hfindex, tvbuff_t *tvb, gint offset, gint length, gint64 timeinterval) { +static proto_item *dissect_ptp_timeinterval(proto_tree *tree, const int hfindex, tvbuff_t *tvb, int offset, int length, int64_t timeinterval) { nstime_t t; - guint64 ti, ti_ns; + uint64_t ti, ti_ns; - ti = (guint64) ABS(timeinterval); + ti = (uint64_t) ABS(timeinterval); ti += (ti & 0x8000) << 1; /* rounding */ ti_ns = ti >> 16; t.secs = (time_t) (ti_ns / NS_PER_S); - t.nsecs = (guint32)(ti_ns % NS_PER_S); + t.nsecs = (uint32_t)(ti_ns % NS_PER_S); if (t.nsecs >= NS_PER_S) { t.nsecs -= NS_PER_S; t.secs += 1; @@ -2711,14 +2675,14 @@ dissect_meta_record_tags(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { proto_item *section_tree = tree; proto_item *sectionlen_pi = NULL; - guint16 sectiontype = ERF_META_SECTION_NONE; - guint16 tagtype = 0; - guint16 taglength = 0; - const gchar *tagvalstring = NULL; + uint16_t sectiontype = ERF_META_SECTION_NONE; + uint16_t tagtype = 0; + uint16_t taglength = 0; + const char *tagvalstring = NULL; erf_meta_tag_info_t *tag_info; int expected_length = 0; expert_field *truncated_expert = NULL; - gboolean skip_truncated = FALSE; + bool skip_truncated = false; /* Used for search entry and unknown tags */ erf_meta_hf_template_t tag_template_unknown = { 0, { "Unknown", "unknown", @@ -2728,8 +2692,8 @@ dissect_meta_record_tags(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { int offset = 0; int sectionoffset = 0; - guint16 sectionid = 0; - guint16 sectionlen = 0; + uint16_t sectionid = 0; + uint16_t sectionlen = 0; int remaining_len = 0; int captured_length = (int) tvb_captured_length(tvb); @@ -2745,7 +2709,7 @@ dissect_meta_record_tags(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { tag_tree = NULL; tag_pi = NULL; truncated_expert = NULL; - skip_truncated = FALSE; + skip_truncated = false; if (ERF_META_IS_SECTION(tagtype)) sectiontype = tagtype; @@ -2762,7 +2726,7 @@ dissect_meta_record_tags(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { /* Get expected length (minimum length in the case of ns_host_*) */ expected_length = meta_tag_expected_length(tag_info); - if (remaining_len < (gint32)taglength + 4 || taglength < expected_length) { + if (remaining_len < (int32_t)taglength + 4 || taglength < expected_length) { /* * Malformed tag, just dissect type and length. Top level tag * dissection means can't add the subtree and type/length first. @@ -2770,7 +2734,7 @@ dissect_meta_record_tags(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { * Allow too-long tags for now (and proto_tree generally generates * a warning for these anyway). */ - skip_truncated = TRUE; + skip_truncated = true; truncated_expert = &ei_erf_meta_truncated_tag; } @@ -2783,7 +2747,7 @@ dissect_meta_record_tags(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { truncated_expert = &ei_erf_meta_zero_len_tag; /* XXX: Still dissect normally too if string/unknown or section header */ if (expected_length != 0) { - skip_truncated = TRUE; + skip_truncated = true; } } } @@ -2842,11 +2806,11 @@ dissect_meta_record_tags(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { } else if (!skip_truncated) { /* Not section header tag (and not truncated) */ enum ftenum tag_ft; char pi_label[ITEM_LABEL_LENGTH+1]; - gboolean dissected = TRUE; - guint32 value32; - guint64 value64; + bool dissected = true; + uint32_t value32; + uint64_t value64; float float_value; - gchar *tmp = NULL; + char *tmp = NULL; tag_ft = tag_info->tag_template->hfinfo.type; pi_label[0] = '\0'; @@ -2871,20 +2835,20 @@ dissect_meta_record_tags(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { case ERF_META_TAG_if_rx_power: case ERF_META_TAG_if_tx_power: value32 = tvb_get_ntohl(tvb, offset + 4); - tag_pi = proto_tree_add_int_format_value(section_tree, tag_info->hf_value, tvb, offset + 4, taglength, (gint32) value32, "%.2fdBm", (double)((gint32) value32)/100.0); + tag_pi = proto_tree_add_int_format_value(section_tree, tag_info->hf_value, tvb, offset + 4, taglength, (int32_t) value32, "%.2fdBm", (double)((int32_t) value32)/100.0); break; case ERF_META_TAG_temperature: case ERF_META_TAG_power: value32 = tvb_get_ntohl(tvb, offset + 4); - float_value = (float)((gint32) value32)/1000.0f; + float_value = (float)((int32_t) value32)/1000.0f; tag_pi = proto_tree_add_float(section_tree, tag_info->hf_value, tvb, offset + 4, taglength, float_value); break; case ERF_META_TAG_loc_lat: case ERF_META_TAG_loc_long: value32 = tvb_get_ntohl(tvb, offset + 4); - tag_pi = proto_tree_add_int_format_value(section_tree, tag_info->hf_value, tvb, offset + 4, taglength, (gint32) value32, "%.2f", (double)((gint32) value32)*1000000.0); + tag_pi = proto_tree_add_int_format_value(section_tree, tag_info->hf_value, tvb, offset + 4, taglength, (int32_t) value32, "%.2f", (double)((int32_t) value32)*1000000.0); break; case ERF_META_TAG_mask_cidr: @@ -2963,7 +2927,7 @@ dissect_meta_record_tags(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { case ERF_META_TAG_ptp_offset_from_master: case ERF_META_TAG_ptp_mean_path_delay: value64 = tvb_get_ntoh64(tvb, offset + 4); - tag_pi = dissect_ptp_timeinterval(section_tree, tag_info->hf_value, tvb, offset + 4, taglength, (gint64) value64); + tag_pi = dissect_ptp_timeinterval(section_tree, tag_info->hf_value, tvb, offset + 4, taglength, (int64_t) value64); break; case ERF_META_TAG_ptp_current_utc_offset: @@ -2972,7 +2936,7 @@ dissect_meta_record_tags(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { value32 = tvb_get_ntohl(tvb, offset + 4); /* PTP value is signed */ - t.secs = (gint32) value32; + t.secs = (int32_t) value32; t.nsecs = 0; tag_pi = dissect_relative_time(section_tree, tag_info->hf_value, tvb, offset + 4, taglength, &t); @@ -2989,7 +2953,7 @@ dissect_meta_record_tags(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { { float entropy; value32 = tvb_get_ntohl(tvb, offset + 4); - entropy = entropy_from_entropy_header_value((guint8) value32); + entropy = entropy_from_entropy_header_value((uint8_t) value32); tag_pi = proto_tree_add_float_format_value(section_tree, tag_info->hf_value, tvb, 0, 0, entropy, "%.2f %s", (double) entropy, entropy == 0.0f ? "(not calculated)":"bits"); @@ -3002,7 +2966,7 @@ dissect_meta_record_tags(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { break; default: - dissected = FALSE; + dissected = false; break; } @@ -3024,7 +2988,7 @@ dissect_meta_record_tags(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { * here. For now do by hand. */ nstime_t t; - guint64 ts; + uint64_t ts; ts = tvb_get_letoh64(tvb, offset + 4); erf_ts_to_nstime(ts, &t, tag_ft == FT_RELATIVE_TIME); @@ -3060,7 +3024,7 @@ dissect_meta_record_tags(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { expert_add_info(pinfo, tag_pi, truncated_expert); } - offset += (((guint32)taglength + 4) + 0x3U) & ~0x3U; + offset += (((uint32_t)taglength + 4) + 0x3U) & ~0x3U; } if (remaining_len != 0) { @@ -3077,22 +3041,22 @@ dissect_meta_record_tags(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { static int dissect_erf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) { - guint8 flags; - guint8 erf_type; - guint32 atm_hdr = 0; + uint8_t flags; + uint8_t erf_type; + uint32_t atm_hdr = 0; proto_tree *erf_tree; proto_item *erf_item; erf_hdlc_type_vals hdlc_type; - guint8 first_byte; + uint8_t first_byte; tvbuff_t *new_tvb; - guint8 aal2_cid; + uint8_t aal2_cid; struct atm_phdr atm_info; erf_type=pinfo->pseudo_header->erf.phdr.type & 0x7F; col_set_str(pinfo->cinfo, COL_PROTOCOL, "ERF"); - col_add_fstr(pinfo->cinfo, COL_INFO, "%s", + col_add_str(pinfo->cinfo, COL_INFO, val_to_str(erf_type, erf_type_vals, "Unknown type %u")); erf_item = proto_tree_add_item(tree, proto_erf, tvb, 0, -1, ENC_NA); @@ -3331,7 +3295,7 @@ dissect_erf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) if (hdlc_type == ERF_HDLC_GUESS) { /* Try to guess the type. */ - first_byte = tvb_get_guint8(tvb, 0); + first_byte = tvb_get_uint8(tvb, 0); if (first_byte == 0x0f || first_byte == 0x8f) hdlc_type = ERF_HDLC_CHDLC; else { @@ -3405,7 +3369,10 @@ proto_register_erf(void) FT_UINT8, BASE_HEX, NULL, 0x0, NULL, HFILL } }, { &hf_erf_flags_cap, { "Capture interface", "erf.flags.cap", - FT_UINT8, BASE_DEC, NULL, ERF_HDR_CAP_MASK, NULL, HFILL } }, + FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL } }, + { &hf_erf_flags_if_raw, + { "Raw interface", "erf.flags.if_raw", + FT_UINT8, BASE_HEX, NULL, ERF_HDR_CAP_MASK, NULL, HFILL } }, { &hf_erf_flags_vlen, { "Varying record length", "erf.flags.vlen", FT_UINT8, BASE_DEC, NULL, ERF_HDR_VLEN_MASK, NULL, HFILL } }, @@ -3420,7 +3387,7 @@ proto_register_erf(void) FT_UINT8, BASE_DEC, NULL, ERF_HDR_DSE_MASK, NULL, HFILL } }, { &hf_erf_flags_res, { "Reserved", "erf.flags.res", - FT_UINT8, BASE_HEX, NULL, ERF_HDR_RES_MASK, NULL, HFILL } }, + FT_UINT8, BASE_DEC, NULL, ERF_HDR_RES_MASK, NULL, HFILL } }, { &hf_erf_rlen, { "Record length", "erf.rlen", FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL } }, @@ -3860,7 +3827,7 @@ proto_register_erf(void) FT_BYTES, BASE_NONE, NULL, 0x0, NULL, HFILL } } }; - static gint *ett[] = { + static int *ett[] = { &ett_erf, &ett_erf_pseudo_hdr, &ett_erf_rectype, @@ -3899,9 +3866,17 @@ proto_register_erf(void) }; static ei_register_info ei[] = { - { &ei_erf_checksum_error, { "erf.checksum.error", PI_CHECKSUM, PI_ERROR, "ERF MC FCS Error", EXPFILL }}, - { &ei_erf_packet_loss, { "erf.packet_loss", PI_SEQUENCE, PI_WARN, "Packet loss occurred between previous and current packet", EXPFILL }}, - { &ei_erf_extension_headers_not_shown, { "erf.ehdr.more_not_shown", PI_SEQUENCE, PI_WARN, "More extension headers were present, not shown", EXPFILL }}, + { &ei_erf_mc_hdlc_checksum_error, { "erf.mchdlc.checksum.error", PI_CHECKSUM, PI_ERROR, "ERF MC HDLC FCS Error", EXPFILL }}, + { &ei_erf_mc_hdlc_short_error, { "erf.mchdlc.short.error", PI_RECEIVE, PI_ERROR, "ERF MC HDLC Short Record Error, <5 bytes", EXPFILL }}, + { &ei_erf_mc_hdlc_long_error, { "erf.mchdlc.long.error", PI_RECEIVE, PI_ERROR, "ERF MC HDLC Long Record Error, >2047 bytes", EXPFILL }}, + { &ei_erf_mc_hdlc_abort_error, { "erf.mchdlc.abort.error", PI_RECEIVE, PI_ERROR, "ERF MC HDLC Aborted Frame Error", EXPFILL }}, + { &ei_erf_mc_hdlc_octet_error, { "erf.mchdlc.octet.error", PI_RECEIVE, PI_ERROR, "ERF MC HDLC Octet Error, the closing flag was not octet aligned after bit unstuffing", EXPFILL }}, + { &ei_erf_mc_hdlc_lost_byte_error, { "erf.mchdlc.lost_byte.error", PI_RECEIVE, PI_ERROR, "ERF MC HDLC Lost Byte Error", EXPFILL }}, + { &ei_erf_rx_error, { "erf.rx.error", PI_INTERFACE, PI_ERROR, "ERF RX Error", EXPFILL }}, + { &ei_erf_ds_error, { "erf.ds.error", PI_INTERFACE, PI_ERROR, "ERF DS Error", EXPFILL }}, + { &ei_erf_truncation_error, { "erf.truncation.error", PI_INTERFACE, PI_ERROR, "ERF Truncation Error", EXPFILL }}, + { &ei_erf_packet_loss, { "erf.packet_loss", PI_INTERFACE, PI_WARN, "Packet loss occurred between previous and current packet", EXPFILL }}, + { &ei_erf_extension_headers_not_shown, { "erf.ehdr.more_not_shown", PI_INTERFACE, PI_WARN, "More extension headers were present, not shown", EXPFILL }}, { &ei_erf_meta_section_len_error, { "erf.meta.section_len.error", PI_PROTOCOL, PI_ERROR, "Provenance Section Length incorrect", EXPFILL }}, { &ei_erf_meta_truncated_record, { "erf.meta.truncated_record", PI_MALFORMED, PI_ERROR, "Provenance truncated record", EXPFILL }}, { &ei_erf_meta_truncated_tag, { "erf.meta.truncated_tag", PI_PROTOCOL, PI_ERROR, "Provenance truncated tag", EXPFILL }}, @@ -3924,13 +3899,13 @@ proto_register_erf(void) /* Register per-section Provenance fields */ proto_register_field_array(proto_erf, (hf_register_info*) wmem_array_get_raw(erf_meta_index.hfri), (int) wmem_array_get_count(erf_meta_index.hfri)); - proto_register_subtree_array((gint**) wmem_array_get_raw(erf_meta_index.ett), (int) wmem_array_get_count(erf_meta_index.ett)); + proto_register_subtree_array((int**) wmem_array_get_raw(erf_meta_index.ett), (int) wmem_array_get_count(erf_meta_index.ett)); erf_module = prefs_register_protocol(proto_erf, NULL); prefs_register_enum_preference(erf_module, "hdlc_type", "ERF_HDLC Layer 2", "Protocol encapsulated in HDLC records", - &erf_hdlc_type, erf_hdlc_options, FALSE); + &erf_hdlc_type, erf_hdlc_options, false); prefs_register_bool_preference(erf_module, "rawcell_first", "Raw ATM cells are first cell of AAL5 PDU", @@ -3941,7 +3916,7 @@ proto_register_erf(void) prefs_register_enum_preference(erf_module, "aal5_type", "ATM AAL5 packet type", "Protocol encapsulated in ATM AAL5 packets", - &erf_aal5_type, erf_aal5_options, FALSE); + &erf_aal5_type, erf_aal5_options, false); /* * We just use eth_maybefcs now and respect the Ethernet preference. |