summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-stt.c
diff options
context:
space:
mode:
Diffstat (limited to 'epan/dissectors/packet-stt.c')
-rw-r--r--epan/dissectors/packet-stt.c195
1 files changed, 99 insertions, 96 deletions
diff --git a/epan/dissectors/packet-stt.c b/epan/dissectors/packet-stt.c
index 26f55159..9cf76c1f 100644
--- a/epan/dissectors/packet-stt.c
+++ b/epan/dissectors/packet-stt.c
@@ -21,12 +21,15 @@
#include <epan/ipproto.h>
#include <epan/prefs.h>
#include <epan/reassemble.h>
-#include <epan/to_str.h>
+#include <epan/tfs.h>
+#include <epan/unit_strings.h>
+
+#include <wsutil/array.h>
#include "packet-ip.h"
-static gboolean pref_reassemble = TRUE;
-static gboolean pref_check_checksum = FALSE;
+static bool pref_reassemble = true;
+static bool pref_check_checksum;
/* IANA ref:
* https://www.iana.org/assignments/service-names-port-numbers/service-names-port-numbers.xhtml
@@ -53,74 +56,74 @@ static gboolean pref_check_checksum = FALSE;
void proto_register_stt(void);
void proto_reg_handoff_stt(void);
-static int proto_stt = -1;
-
-static int hf_stt_stream_id = -1;
-static int hf_stt_dport = -1;
-static int hf_stt_pkt_len = -1;
-static int hf_stt_seg_off = -1;
-static int hf_stt_pkt_id = -1;
-static int hf_stt_checksum = -1;
-static int hf_stt_checksum_status = -1;
-static int hf_stt_tcp_data = -1;
-static int hf_stt_tcp_data_offset = -1;
-static int hf_stt_tcp_flags = -1;
-static int hf_stt_tcp_rsvd = -1;
-static int hf_stt_tcp_ns = -1;
-static int hf_stt_tcp_cwr = -1;
-static int hf_stt_tcp_ece = -1;
-static int hf_stt_tcp_urg = -1;
-static int hf_stt_tcp_ack = -1;
-static int hf_stt_tcp_psh = -1;
-static int hf_stt_tcp_rst = -1;
-static int hf_stt_tcp_syn = -1;
-static int hf_stt_tcp_fin = -1;
-static int hf_stt_tcp_window = -1;
-static int hf_stt_tcp_urg_ptr = -1;
-
-static int hf_stt_version = -1;
-static int hf_stt_flags = -1;
-static int hf_stt_flag_rsvd = -1;
-static int hf_stt_flag_tcp = -1;
-static int hf_stt_flag_ipv4 = -1;
-static int hf_stt_flag_partial = -1;
-static int hf_stt_flag_verified = -1;
-static int hf_stt_l4_offset = -1;
-static int hf_stt_reserved_8 = -1;
-static int hf_stt_mss = -1;
-static int hf_stt_vlan = -1;
-static int hf_stt_pcp = -1;
-static int hf_stt_v = -1;
-static int hf_stt_vlan_id= -1;
-static int hf_stt_context_id = -1;
-static int hf_stt_padding = -1;
-
-static int hf_segments = -1;
-static int hf_segment = -1;
-static int hf_segment_overlap = -1;
-static int hf_segment_overlap_conflict = -1;
-static int hf_segment_multiple_tails = -1;
-static int hf_segment_too_long_fragment = -1;
-static int hf_segment_error = -1;
-static int hf_segment_count = -1;
-static int hf_reassembled_in = -1;
-static int hf_reassembled_length = -1;
-
-static int ett_stt = -1;
-static int ett_stt_tcp_data = -1;
-static int ett_stt_tcp_flags = -1;
-static int ett_stt_flgs = -1;
-static int ett_stt_vlan = -1;
-static int ett_segment = -1;
-static int ett_segments = -1;
+static int proto_stt;
+
+static int hf_stt_stream_id;
+static int hf_stt_dport;
+static int hf_stt_pkt_len;
+static int hf_stt_seg_off;
+static int hf_stt_pkt_id;
+static int hf_stt_checksum;
+static int hf_stt_checksum_status;
+static int hf_stt_tcp_data;
+static int hf_stt_tcp_data_offset;
+static int hf_stt_tcp_flags;
+static int hf_stt_tcp_rsvd;
+static int hf_stt_tcp_ns;
+static int hf_stt_tcp_cwr;
+static int hf_stt_tcp_ece;
+static int hf_stt_tcp_urg;
+static int hf_stt_tcp_ack;
+static int hf_stt_tcp_psh;
+static int hf_stt_tcp_rst;
+static int hf_stt_tcp_syn;
+static int hf_stt_tcp_fin;
+static int hf_stt_tcp_window;
+static int hf_stt_tcp_urg_ptr;
+
+static int hf_stt_version;
+static int hf_stt_flags;
+static int hf_stt_flag_rsvd;
+static int hf_stt_flag_tcp;
+static int hf_stt_flag_ipv4;
+static int hf_stt_flag_partial;
+static int hf_stt_flag_verified;
+static int hf_stt_l4_offset;
+static int hf_stt_reserved_8;
+static int hf_stt_mss;
+static int hf_stt_vlan;
+static int hf_stt_pcp;
+static int hf_stt_v;
+static int hf_stt_vlan_id;
+static int hf_stt_context_id;
+static int hf_stt_padding;
+
+static int hf_segments;
+static int hf_segment;
+static int hf_segment_overlap;
+static int hf_segment_overlap_conflict;
+static int hf_segment_multiple_tails;
+static int hf_segment_too_long_fragment;
+static int hf_segment_error;
+static int hf_segment_count;
+static int hf_reassembled_in;
+static int hf_reassembled_length;
+
+static int ett_stt;
+static int ett_stt_tcp_data;
+static int ett_stt_tcp_flags;
+static int ett_stt_flgs;
+static int ett_stt_vlan;
+static int ett_segment;
+static int ett_segments;
static reassembly_table stt_reassembly_table;
-static expert_field ei_stt_ver_unknown = EI_INIT;
-static expert_field ei_stt_checksum_bad = EI_INIT;
-static expert_field ei_stt_data_offset_bad = EI_INIT;
-static expert_field ei_stt_l4_offset = EI_INIT;
-static expert_field ei_stt_mss = EI_INIT;
+static expert_field ei_stt_ver_unknown;
+static expert_field ei_stt_checksum_bad;
+static expert_field ei_stt_data_offset_bad;
+static expert_field ei_stt_l4_offset;
+static expert_field ei_stt_mss;
static dissector_handle_t eth_handle;
@@ -156,12 +159,12 @@ static const fragment_items frag_items = {
static tvbuff_t *
handle_segment(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
- guint32 pkt_id, guint16 pkt_len, guint16 seg_off)
+ uint32_t pkt_id, uint16_t pkt_len, uint16_t seg_off)
{
fragment_head *frags;
int offset;
- guint32 frag_data_len;
- gboolean more_frags;
+ uint32_t frag_data_len;
+ bool more_frags;
/* Skip fake TCP header after the first segment. */
if (seg_off == 0) {
@@ -192,28 +195,28 @@ handle_segment(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
static void
dissect_stt_checksum(tvbuff_t *tvb, packet_info *pinfo, proto_tree *stt_tree)
{
- gboolean can_checksum = !pinfo->fragmented &&
+ bool can_checksum = !pinfo->fragmented &&
tvb_bytes_exist(tvb, 0, tvb_reported_length(tvb));
if (can_checksum && pref_check_checksum) {
vec_t cksum_vec[4];
- guint32 phdr[2];
+ uint32_t phdr[2];
/* Set up the fields of the pseudo-header. */
- SET_CKSUM_VEC_PTR(cksum_vec[0], (const guint8 *)pinfo->src.data,
+ SET_CKSUM_VEC_PTR(cksum_vec[0], (const uint8_t *)pinfo->src.data,
pinfo->src.len);
- SET_CKSUM_VEC_PTR(cksum_vec[1], (const guint8 *)pinfo->dst.data,
+ SET_CKSUM_VEC_PTR(cksum_vec[1], (const uint8_t *)pinfo->dst.data,
pinfo->dst.len);
switch (pinfo->src.type) {
case AT_IPv4:
phdr[0] = g_htonl((IP_PROTO_TCP<<16) + tvb_reported_length(tvb));
- SET_CKSUM_VEC_PTR(cksum_vec[2], (const guint8 *)phdr, 4);
+ SET_CKSUM_VEC_PTR(cksum_vec[2], (const uint8_t *)phdr, 4);
break;
case AT_IPv6:
phdr[0] = g_htonl(tvb_reported_length(tvb));
phdr[1] = g_htonl(IP_PROTO_TCP);
- SET_CKSUM_VEC_PTR(cksum_vec[2], (const guint8 *)phdr, 8);
+ SET_CKSUM_VEC_PTR(cksum_vec[2], (const uint8_t *)phdr, 8);
break;
default:
@@ -283,7 +286,7 @@ dissect_tcp_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *stt_tree)
tcp_tree = proto_item_add_subtree(tcp_item, ett_stt_tcp_data);
proto_item_set_text(tcp_item, "TCP Data");
- data_offset = hi_nibble(tvb_get_guint8(tvb, offset)) * 4;
+ data_offset = hi_nibble(tvb_get_uint8(tvb, offset)) * 4;
data_offset_item = proto_tree_add_uint(tcp_tree,
hf_stt_tcp_data_offset,
tvb, offset, 1,
@@ -330,9 +333,9 @@ dissect_stt_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *stt_tree,
{
proto_tree *vlan_tree;
proto_item *ver_item, *l4_offset_item, *vlan_item, *mss_item;
- guint8 flags;
- guint32 version, l4_offset, mss, attributes;
- guint64 context_id;
+ uint8_t flags;
+ uint32_t version, l4_offset, mss, attributes;
+ uint64_t context_id;
int offset = STT_TCP_HDR_LEN;
/*
@@ -363,7 +366,7 @@ dissect_stt_tree(tvbuff_t *tvb, packet_info *pinfo, proto_tree *stt_tree,
offset++;
/* Flags */
- flags = tvb_get_guint8(tvb, offset);
+ flags = tvb_get_uint8(tvb, offset);
offset = dissect_stt_flags(stt_tree, tvb, offset);
/* Layer 4 offset */
@@ -438,9 +441,9 @@ dissect_stt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
proto_item *stt_item;
proto_tree *stt_tree;
tvbuff_t *next_tvb;
- guint16 seg_off, pkt_len, rx_bytes;
- guint8 sub_off;
- gboolean frag_save, is_seg;
+ uint16_t seg_off, pkt_len, rx_bytes;
+ uint8_t sub_off;
+ bool frag_save, is_seg;
/* Make entry in Protocol column on summary display. */
col_set_str(pinfo->cinfo, COL_PROTOCOL, "STT");
@@ -460,9 +463,9 @@ dissect_stt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
is_seg = pkt_len > rx_bytes;
if (is_seg) {
- guint32 pkt_id = tvb_get_ntohl(tvb, STT_TCP_OFF_PKT_ID);
+ uint32_t pkt_id = tvb_get_ntohl(tvb, STT_TCP_OFF_PKT_ID);
- pinfo->fragmented = TRUE;
+ pinfo->fragmented = true;
col_add_fstr(pinfo->cinfo, COL_INFO,
"STT Segment (ID: 0x%x Len: %hu, Off: %hu)",
pkt_id, pkt_len, seg_off);
@@ -476,12 +479,12 @@ dissect_stt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (reasm_tvb) {
tvb = reasm_tvb;
pinfo->fragmented = frag_save;
- is_seg = FALSE;
+ is_seg = false;
}
} else if (seg_off == 0) {
/* If we're not reassembling, move ahead as if we have the
* whole frame. */
- is_seg = FALSE;
+ is_seg = false;
}
}
@@ -509,23 +512,23 @@ dissect_stt(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
pinfo->fragmented = frag_save;
}
-static gboolean
+static bool
dissect_stt_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
void *iph)
{
/* Make sure we at least have a TCP header */
if (ws_ip_protocol(iph) != IP_PROTO_TCP ||
tvb_captured_length(tvb) < STT_TCP_HDR_LEN) {
- return FALSE;
+ return false;
}
/* Check the TCP destination port */
if (tvb_get_ntohs(tvb, STT_TCP_OFF_DPORT) != TCP_PORT_STT) {
- return FALSE;
+ return false;
}
dissect_stt(tvb, pinfo, tree);
- return TRUE;
+ return true;
}
/* Register STT with Wireshark */
@@ -575,7 +578,7 @@ proto_register_stt(void)
},
{ &hf_stt_tcp_data_offset,
{ "Data Offset", "stt.tcp.data_offset",
- FT_UINT8, BASE_DEC|BASE_UNIT_STRING, &units_byte_bytes, 0x0,
+ FT_UINT8, BASE_DEC|BASE_UNIT_STRING, UNS(&units_byte_bytes), 0x0,
NULL, HFILL,
},
},
@@ -816,7 +819,7 @@ proto_register_stt(void)
{ &hf_segments,
{ "Reassembled STT Segments", "stt.segments",
FT_NONE, BASE_NONE, NULL, 0x0,
- "STT Segments", HFILL
+ NULL, HFILL
},
},
{ &hf_reassembled_in,
@@ -834,7 +837,7 @@ proto_register_stt(void)
};
/* Setup protocol subtree array */
- static gint *ett[] = {
+ static int *ett[] = {
&ett_stt,
&ett_stt_tcp_data,
&ett_stt_tcp_flags,