summaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-avsp.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:14:26 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:14:26 +0000
commitc4e8a3222648fcf22ca207f1815ebbf7cd144eeb (patch)
tree93d5c6aa93d9987680dd1adad5685e2ad698f223 /epan/dissectors/packet-avsp.c
parentAdding upstream version 4.2.6. (diff)
downloadwireshark-upstream.tar.xz
wireshark-upstream.zip
Adding upstream version 4.4.0.upstream/4.4.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'epan/dissectors/packet-avsp.c')
-rw-r--r--epan/dissectors/packet-avsp.c123
1 files changed, 54 insertions, 69 deletions
diff --git a/epan/dissectors/packet-avsp.c b/epan/dissectors/packet-avsp.c
index c68347f1..5c99bbe2 100644
--- a/epan/dissectors/packet-avsp.c
+++ b/epan/dissectors/packet-avsp.c
@@ -60,30 +60,30 @@ void proto_reg_handoff_avsp(void);
void proto_register_avsp(void);
static dissector_handle_t avsp_handle;
-static int proto_avsp = -1;
+static int proto_avsp;
/* sub trees */
-static gint ett_avsp = -1;
-static gint ett_avsp_ts_48 = -1;
-static gint ett_avsp_ts_64 = -1;
-static gint ett_avsp_tgen_hdr = -1;
-static gint ett_avsp_tgen_hdr_ctrl = -1;
-static gint ett_avsp_tgen_payload = -1;
+static int ett_avsp;
+static int ett_avsp_ts_48;
+static int ett_avsp_ts_64;
+static int ett_avsp_tgen_hdr;
+static int ett_avsp_tgen_hdr_ctrl;
+static int ett_avsp_tgen_payload;
/* AVSP Timestamp subtype header fields */
-static int hf_avsp_subtype = -1;
-static int hf_avsp_ts_version = -1;
-static int hf_avsp_ts_64_tai = -1;
-static int hf_avsp_ts_64_utc = -1;
-static int hf_avsp_ts_64_sec = -1;
-static int hf_avsp_ts_64_ns = -1;
-static int hf_avsp_ts_48_tai = -1;
-static int hf_avsp_ts_48_utc = -1;
-static int hf_avsp_ts_48_sec = -1;
-static int hf_avsp_ts_48_ns = -1;
-
-static int hf_avsp_etype = -1;
-static int hf_avsp_trailer = -1;
+static int hf_avsp_subtype;
+static int hf_avsp_ts_version;
+static int hf_avsp_ts_64_tai;
+static int hf_avsp_ts_64_utc;
+static int hf_avsp_ts_64_sec;
+static int hf_avsp_ts_64_ns;
+static int hf_avsp_ts_48_tai;
+static int hf_avsp_ts_48_utc;
+static int hf_avsp_ts_48_sec;
+static int hf_avsp_ts_48_ns;
+
+static int hf_avsp_etype;
+static int hf_avsp_trailer;
/*
TGen subtype format
@@ -104,16 +104,15 @@ static int hf_avsp_trailer = -1;
*/
/* AVSP TGen subtype header fields */
-static int hf_avsp_tgen_version = -1;
-static int hf_avsp_tgen_hdr = -1;
-static int hf_avsp_tgen_hdr_ctrl = -1;
-static int hf_avsp_tgen_hdr_ctrl_fcs_inverted = -1;
-static int hf_avsp_tgen_hdr_ctrl_reserved = -1;
-static int hf_avsp_tgen_hdr_seq_num = -1;
-static int hf_avsp_tgen_hdr_payload_len = -1;
-static int hf_avsp_tgen_payload = -1;
-static int hf_avsp_tgen_payload_data = -1;
-static int hf_avsp_tgen_trailer = -1;
+static int hf_avsp_tgen_version;
+static int hf_avsp_tgen_hdr;
+static int hf_avsp_tgen_hdr_ctrl;
+static int hf_avsp_tgen_hdr_ctrl_fcs_inverted;
+static int hf_avsp_tgen_hdr_ctrl_reserved;
+static int hf_avsp_tgen_hdr_seq_num;
+static int hf_avsp_tgen_hdr_payload_len;
+static int hf_avsp_tgen_payload;
+static int hf_avsp_tgen_payload_data;
static int* const avsp_tgen_ctrl[] = {
&hf_avsp_tgen_hdr_ctrl_fcs_inverted,
@@ -142,21 +141,20 @@ static const value_string tgen_versions[] = {
{0, NULL}
};
-static expert_field ei_avsp_unknown_subtype = EI_INIT;
-static expert_field ei_avsp_ts_unknown_version = EI_INIT;
-static expert_field ei_avsp_tgen_unknown_version = EI_INIT;
+static expert_field ei_avsp_unknown_subtype;
+static expert_field ei_avsp_ts_unknown_version;
+static expert_field ei_avsp_tgen_unknown_version;
static int
dissect_avsp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_)
{
- volatile guint8 offset = 0;
- guint32 version, subtype, tgen_payload_len = 0;
- guint64 tgen_ctrl;
- guint32 tgen_seq_num;
+ volatile int offset = 0;
+ uint32_t version, subtype, tgen_payload_len = 0;
+ uint64_t tgen_ctrl;
+ uint32_t tgen_seq_num;
const char* str;
tvbuff_t* volatile tgen_payload_tvb = NULL;
- tvbuff_t* volatile trailer_tvb = NULL;
col_set_str(pinfo->cinfo, COL_PROTOCOL, "AVSP");
col_clear(pinfo->cinfo, COL_INFO);
@@ -195,7 +193,7 @@ dissect_avsp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_
ti = proto_tree_add_item(avsp_tree, hf_avsp_ts_64_tai, tvb, 0, -1,
ENC_NA);
avsp_64_tree = proto_item_add_subtree(ti, ett_avsp);
- col_add_str(pinfo->cinfo, COL_INFO, "64bit TAI timestamp");
+ col_set_str(pinfo->cinfo, COL_INFO, "64bit TAI timestamp");
proto_tree_add_item(avsp_64_tree, hf_avsp_ts_64_sec, tvb, offset,
4, ENC_BIG_ENDIAN);
offset += 4;
@@ -207,7 +205,7 @@ dissect_avsp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_
ti = proto_tree_add_item(avsp_tree, hf_avsp_ts_64_utc, tvb, 0, -1,
ENC_NA);
avsp_64_tree = proto_item_add_subtree(ti, ett_avsp);
- col_add_str(pinfo->cinfo, COL_INFO, "64bit UTC timestamp");
+ col_set_str(pinfo->cinfo, COL_INFO, "64bit UTC timestamp");
proto_tree_add_item(avsp_64_tree, hf_avsp_ts_64_sec, tvb, offset,
4, ENC_BIG_ENDIAN);
offset += 4;
@@ -219,7 +217,7 @@ dissect_avsp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_
ti = proto_tree_add_item(avsp_tree, hf_avsp_ts_48_tai, tvb, 0, -1,
ENC_NA);
avsp_48_tree = proto_item_add_subtree(ti, ett_avsp);
- col_add_str(pinfo->cinfo, COL_INFO, "48bit TAI timestamp");
+ col_set_str(pinfo->cinfo, COL_INFO, "48bit TAI timestamp");
proto_tree_add_item(avsp_48_tree, hf_avsp_ts_48_sec, tvb, offset,
2, ENC_BIG_ENDIAN);
offset += 2;
@@ -231,7 +229,7 @@ dissect_avsp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_
ti = proto_tree_add_item(avsp_tree, hf_avsp_ts_48_utc, tvb, 0, -1,
ENC_NA);
avsp_48_tree = proto_item_add_subtree(ti, ett_avsp);
- col_add_str(pinfo->cinfo, COL_INFO, "48bit UTC timestamp");
+ col_set_str(pinfo->cinfo, COL_INFO, "48bit UTC timestamp");
proto_tree_add_item(avsp_48_tree, hf_avsp_ts_48_sec, tvb, offset,
2, ENC_BIG_ENDIAN);
offset += 2;
@@ -245,7 +243,7 @@ dissect_avsp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_
return tvb_captured_length(tvb);
}
- guint16 encap_proto;
+ uint16_t encap_proto;
encap_proto = tvb_get_ntohs(tvb, offset);
proto_tree_add_uint(avsp_tree, hf_avsp_etype, tvb, offset, 2, encap_proto);
offset += 2;
@@ -271,7 +269,7 @@ dissect_avsp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_
switch (version) {
case ARISTA_TGEN_VER_1:
- col_add_str(pinfo->cinfo, COL_INFO, "Arista TGen Frame");
+ col_set_str(pinfo->cinfo, COL_INFO, "Arista TGen Frame");
/* Get TGen Header Control Word. */
ti = proto_tree_add_item(avsp_tree, hf_avsp_tgen_hdr, tvb, offset, 6,
@@ -304,36 +302,26 @@ dissect_avsp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_
TRY {
tgen_payload_tvb = tvb_new_subset_length(tvb, offset, tgen_payload_len);
- trailer_tvb = tvb_new_subset_remaining(tvb, offset + tgen_payload_len);
}
CATCH_BOUNDS_ERRORS {
- /* Either:
-
+ /* So:
the packet doesn't have "tgen_payload_len" bytes worth of
captured data left in it so the "tvb_new_subset_length()"
creating "payload_tvb" threw an exception
- or
-
- the packet has exactly "tgen_payload_len" bytes worth of
- captured data left in it, so the "tvb_new_subset_remaining()"
- creating "trailer_tvb" threw an exception.
-
- In either case, this means that all the data in the frame
- is within the length value, so we give all the data to the
- payload and have no trailer. */
+ This means that all the data in the frame is within the
+ length value, so we give all the data to the payload. */
tgen_payload_tvb = tvb_new_subset_remaining(tvb, offset);
- trailer_tvb = NULL;
}
ENDTRY;
/* Get the TGen payload captured length. */
- guint16 tgen_payload_captured_len = tvb_captured_length(tgen_payload_tvb);
+ uint16_t tgen_payload_captured_len = tvb_captured_length(tgen_payload_tvb);
/* Add the TGen payload to the tree, with a heading that displays
the TGgen payload captured length. */
- ti = proto_tree_add_bytes_format(avsp_tree, hf_avsp_tgen_payload_data,
- tgen_payload_tvb, 0, -1, NULL, "TGen Payload (%u byte%s)",
+ ti = proto_tree_add_none_format(avsp_tree, hf_avsp_tgen_payload,
+ tgen_payload_tvb, 0, -1, "TGen Payload (%u byte%s)",
tgen_payload_captured_len,
plurality(tgen_payload_captured_len, "", "s"));
avsp_tgen_payload = proto_item_add_subtree(ti, ett_avsp_tgen_payload);
@@ -345,8 +333,11 @@ dissect_avsp(tvbuff_t* tvb, packet_info* pinfo, proto_tree* tree, void* data _U_
been truncated) we can set the length of the entire AVSP protocol. */
proto_item_set_len(avsp_ti, offset + tgen_payload_captured_len);
- /* If there is a trailer, then add it to the tree. */
- add_ethernet_trailer(pinfo, tree, avsp_tree, hf_avsp_tgen_trailer, tvb, trailer_tvb, -1);
+ /* We have a length field, so set it here so that the higher level
+ * (ethertype) dissector can add the trailer. That way the FCS
+ * will be calculated correctly.
+ */
+ set_actual_length(tvb, offset + tgen_payload_captured_len);
break;
default:
@@ -501,16 +492,10 @@ void proto_register_avsp(void)
NULL, 0x0,
NULL, HFILL}
},
- { &hf_avsp_tgen_trailer,
- {"Trailer", "avsp.tgen.trailer",
- FT_BYTES, BASE_NONE,
- NULL, 0x0,
- "Ethernet Trailer or Checksum", HFILL }
- },
};
/* Setup protocol subtree array */
- static gint* ett[] = {
+ static int* ett[] = {
&ett_avsp, /* main avsp tree */
&ett_avsp_ts_48, /* subtree above for 48 bit timestamp */
&ett_avsp_ts_64, /* subtree above for 64 bit timestamp */