aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-twamp.c
diff options
context:
space:
mode:
Diffstat (limited to 'epan/dissectors/packet-twamp.c')
-rw-r--r--epan/dissectors/packet-twamp.c172
1 files changed, 92 insertions, 80 deletions
diff --git a/epan/dissectors/packet-twamp.c b/epan/dissectors/packet-twamp.c
index 9f0041547f..88138582d2 100644
--- a/epan/dissectors/packet-twamp.c
+++ b/epan/dissectors/packet-twamp.c
@@ -19,6 +19,7 @@
* (not yet implemented)
* RFC 6038: TWAMP Reflect Octets and Symmetrical Size Features
* (not yet implemented)
+ * RFC 8186: Support of the IEEE 1588 Timestamp Format in TWAMP
*/
#include <config.h>
@@ -42,6 +43,8 @@ void proto_register_twamp(void);
#define TWAMP_MODE_AUTHENTICATED 0x2
#define TWAMP_MODE_ENCRYPTED 0x4
+#define TWAMP_ERROR_ESTIMATE_ZBIT 0x4000
+
enum twamp_control_state {
CONTROL_STATE_UNKNOWN = 0,
CONTROL_STATE_GREETING,
@@ -84,63 +87,63 @@ static dissector_handle_t twamp_test_handle;
static dissector_handle_t twamp_control_handle;
/* Protocol enabled flags */
-static int proto_owamp_test = -1;
-static int proto_twamp_test = -1;
-static int proto_twamp_control = -1;
-static gint ett_owamp_test = -1;
-static gint ett_twamp_test = -1;
-static gint ett_twamp_control = -1;
-static gint ett_twamp_error_estimate = -1;
+static int proto_owamp_test;
+static int proto_twamp_test;
+static int proto_twamp_control;
+static gint ett_owamp_test;
+static gint ett_twamp_test;
+static gint ett_twamp_control;
+static gint ett_twamp_error_estimate;
/* Twamp test fields */
-static int hf_twamp_seq_number = -1;
-static int hf_twamp_sender_timestamp = -1;
-static int hf_twamp_error_estimate = -1;
-static int hf_twamp_mbz1 = -1;
-static int hf_twamp_receive_timestamp = -1;
-static int hf_twamp_sender_seq_number = -1;
-static int hf_twamp_timestamp = -1;
-static int hf_twamp_sender_error_estimate = -1;
-static int hf_twamp_mbz2 = -1;
-static int hf_twamp_sender_ttl = -1;
-static int hf_twamp_padding = -1;
-static int hf_twamp_error_estimate_multiplier = -1;
-static int hf_twamp_error_estimate_scale = -1;
-static int hf_twamp_error_estimate_b14 = -1;
-static int hf_twamp_error_estimate_b15 = -1;
+static int hf_twamp_seq_number;
+static int hf_twamp_sender_timestamp;
+static int hf_twamp_error_estimate;
+static int hf_twamp_mbz1;
+static int hf_twamp_receive_timestamp;
+static int hf_twamp_sender_seq_number;
+static int hf_twamp_timestamp;
+static int hf_twamp_sender_error_estimate;
+static int hf_twamp_mbz2;
+static int hf_twamp_sender_ttl;
+static int hf_twamp_padding;
+static int hf_twamp_error_estimate_multiplier;
+static int hf_twamp_error_estimate_scale;
+static int hf_twamp_error_estimate_b14;
+static int hf_twamp_error_estimate_b15;
/* Twamp control fields */
-static int hf_twamp_control_unused = -1;
-static int hf_twamp_control_command = -1;
-static int hf_twamp_control_modes = -1;
-static int hf_twamp_control_mode = -1;
-static int hf_twamp_control_challenge = -1;
-static int hf_twamp_control_salt = -1;
-static int hf_twamp_control_count = -1;
-static int hf_twamp_control_keyid = -1;
-static int hf_twamp_control_sessionid = -1;
-static int hf_twamp_control_iv = -1;
-static int hf_twamp_control_ipvn = -1;
-static int hf_twamp_control_conf_sender = -1;
-static int hf_twamp_control_conf_receiver = -1;
-static int hf_twamp_control_number_of_schedule_slots = -1;
-static int hf_twamp_control_number_of_packets = -1;
-static int hf_twamp_control_start_time = -1;
-static int hf_twamp_control_accept = -1;
-static int hf_twamp_control_timeout = -1;
-static int hf_twamp_control_type_p = -1;
-static int hf_twamp_control_mbz1 = -1;
-static int hf_twamp_control_mbz2 = -1;
-static int hf_twamp_control_hmac = -1;
-static int hf_twamp_control_num_sessions = -1;
-static int hf_twamp_control_sender_port = -1;
-static int hf_twamp_control_server_uptime = -1;
-static int hf_twamp_control_receiver_port = -1;
-static int hf_twamp_control_padding_length = -1;
-static int hf_twamp_control_sender_ipv4 = -1;
-static int hf_twamp_control_sender_ipv6 = -1;
-static int hf_twamp_control_receiver_ipv4 = -1;
-static int hf_twamp_control_receiver_ipv6 = -1;
+static int hf_twamp_control_unused;
+static int hf_twamp_control_command;
+static int hf_twamp_control_modes;
+static int hf_twamp_control_mode;
+static int hf_twamp_control_challenge;
+static int hf_twamp_control_salt;
+static int hf_twamp_control_count;
+static int hf_twamp_control_keyid;
+static int hf_twamp_control_sessionid;
+static int hf_twamp_control_iv;
+static int hf_twamp_control_ipvn;
+static int hf_twamp_control_conf_sender;
+static int hf_twamp_control_conf_receiver;
+static int hf_twamp_control_number_of_schedule_slots;
+static int hf_twamp_control_number_of_packets;
+static int hf_twamp_control_start_time;
+static int hf_twamp_control_accept;
+static int hf_twamp_control_timeout;
+static int hf_twamp_control_type_p;
+static int hf_twamp_control_mbz1;
+static int hf_twamp_control_mbz2;
+static int hf_twamp_control_hmac;
+static int hf_twamp_control_num_sessions;
+static int hf_twamp_control_sender_port;
+static int hf_twamp_control_server_uptime;
+static int hf_twamp_control_receiver_port;
+static int hf_twamp_control_padding_length;
+static int hf_twamp_control_sender_ipv4;
+static int hf_twamp_control_sender_ipv6;
+static int hf_twamp_control_receiver_ipv4;
+static int hf_twamp_control_receiver_ipv6;
static const value_string twamp_control_accept_vals[] = {
{ 0, "OK" },
@@ -296,10 +299,10 @@ dissect_twamp_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void
session = (twamp_session_t*) list->data;
session->receiver_port = receiver_port;
- cp->conversation = find_conversation(pinfo->fd->num, &pinfo->dst, &pinfo->src, ENDPOINT_UDP,
+ cp->conversation = find_conversation(pinfo->fd->num, &pinfo->dst, &pinfo->src, CONVERSATION_UDP,
session->sender_port, session->receiver_port, 0);
if (cp->conversation == NULL /*|| cp->conversation->dissector_handle != twamp_test_handle*/) {
- cp->conversation = conversation_new(pinfo->fd->num, &pinfo->dst, &pinfo->src, ENDPOINT_UDP,
+ cp->conversation = conversation_new(pinfo->fd->num, &pinfo->dst, &pinfo->src, CONVERSATION_UDP,
session->sender_port, session->receiver_port, 0);
if (cp->conversation) {
/* create conversation specific data for test sessions */
@@ -337,7 +340,7 @@ dissect_twamp_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void
it = proto_tree_add_item(tree, proto_twamp_control, tvb, 0, -1, ENC_NA);
twamp_tree = proto_item_add_subtree(it, ett_twamp_control);
- col_add_fstr(pinfo->cinfo, COL_INFO, "%s", val_to_str_const(cp->state, twamp_control_state_vals, "Unknown"));
+ col_add_str(pinfo->cinfo, COL_INFO, val_to_str_const(cp->state, twamp_control_state_vals, "Unknown"));
switch (cp->state) {
case CONTROL_STATE_GREETING:
@@ -532,6 +535,11 @@ static const true_false_string tfs_twamp_sbit_tfs = {
"No notion of external synchronization"
};
+static const true_false_string tfs_twamp_zbit_tfs = {
+ "Abbreviated PTP Timestamp (RFC8186)",
+ "Always Zero (RFC5357) or NTP Timestamp (RFC8186)"
+};
+
static int
dissect_owamp_test(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
{
@@ -594,7 +602,10 @@ dissect_twamp_test(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *da
proto_tree_add_item(twamp_tree, hf_twamp_seq_number, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
- proto_tree_add_item(twamp_tree, hf_twamp_timestamp, tvb, offset, 8, ENC_TIME_NTP | ENC_BIG_ENDIAN);
+ if (tvb_get_ntohs(tvb, offset + 8) & TWAMP_ERROR_ESTIMATE_ZBIT)
+ proto_tree_add_item(twamp_tree, hf_twamp_timestamp, tvb, offset, 8, ENC_TIME_SECS_NSECS | ENC_BIG_ENDIAN);
+ else
+ proto_tree_add_item(twamp_tree, hf_twamp_timestamp, tvb, offset, 8, ENC_TIME_NTP | ENC_BIG_ENDIAN);
offset += 8;
/*
@@ -612,16 +623,22 @@ dissect_twamp_test(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *da
if (tvb_reported_length(tvb) - offset >= 27) {
proto_tree_add_item (twamp_tree, hf_twamp_mbz1, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
- proto_tree_add_item(twamp_tree, hf_twamp_receive_timestamp, tvb, offset, 8, ENC_TIME_NTP | ENC_BIG_ENDIAN);
+ if (tvb_get_ntohs(tvb, offset - 4) & TWAMP_ERROR_ESTIMATE_ZBIT)
+ proto_tree_add_item(twamp_tree, hf_twamp_receive_timestamp, tvb, offset, 8, ENC_TIME_SECS_NSECS | ENC_BIG_ENDIAN);
+ else
+ proto_tree_add_item(twamp_tree, hf_twamp_receive_timestamp, tvb, offset, 8, ENC_TIME_NTP | ENC_BIG_ENDIAN);
offset += 8;
proto_tree_add_item (twamp_tree, hf_twamp_sender_seq_number, tvb, offset, 4, ENC_BIG_ENDIAN);
offset += 4;
- proto_tree_add_item(twamp_tree, hf_twamp_sender_timestamp, tvb, offset, 8, ENC_TIME_NTP | ENC_BIG_ENDIAN);
+ if (tvb_get_ntohs(tvb, offset) & TWAMP_ERROR_ESTIMATE_ZBIT)
+ proto_tree_add_item(twamp_tree, hf_twamp_sender_timestamp, tvb, offset, 8, ENC_TIME_NTP | ENC_BIG_ENDIAN);
+ else
+ proto_tree_add_item(twamp_tree, hf_twamp_sender_timestamp, tvb, offset, 8, ENC_TIME_SECS_NSECS | ENC_BIG_ENDIAN);
offset += 8;
- proto_tree_add_item (twamp_tree, hf_twamp_sender_error_estimate, tvb, offset, 2, ENC_BIG_ENDIAN);
+ proto_tree_add_bitmask(twamp_tree, tvb, offset, hf_twamp_sender_error_estimate, ett_twamp_error_estimate, twamp_error_estimate_flags, ENC_BIG_ENDIAN);
offset += 2;
proto_tree_add_item (twamp_tree, hf_twamp_mbz2, tvb, offset, 2, ENC_BIG_ENDIAN);
offset += 2;
@@ -652,7 +669,7 @@ void proto_register_twamp(void)
{"Error Estimate", "twamp.test.error_estimate", FT_UINT16,
BASE_DEC_HEX, NULL, 0x0, NULL, HFILL}},
{&hf_twamp_mbz1,
- {"MBZ", "twamp.test.mbz1", FT_UINT8, BASE_DEC_HEX,
+ {"MBZ", "twamp.test.mbz1", FT_UINT16, BASE_DEC_HEX,
NULL, 0x0, NULL, HFILL}},
{&hf_twamp_receive_timestamp,
{"Receive Timestamp", "twamp.test.receive_timestamp", FT_ABSOLUTE_TIME, ABSOLUTE_TIME_LOCAL, NULL, 0x0, NULL, HFILL}},
@@ -665,7 +682,7 @@ void proto_register_twamp(void)
{"Sender Error Estimate", "twamp.test.sender_error_estimate",
FT_UINT16, BASE_DEC_HEX, NULL, 0x0, NULL, HFILL}},
{&hf_twamp_mbz2,
- {"MBZ", "twamp.test.mbz2", FT_UINT8, BASE_DEC_HEX,
+ {"MBZ", "twamp.test.mbz2", FT_UINT16, BASE_DEC_HEX,
NULL, 0x0, NULL, HFILL}},
{&hf_twamp_sender_ttl,
{"Sender TTL", "twamp.test.sender_ttl", FT_UINT8, BASE_DEC,
@@ -681,7 +698,7 @@ void proto_register_twamp(void)
NULL, 0x3f00, NULL, HFILL } },
{ &hf_twamp_error_estimate_b14,
{ "Z", "twamp.test.error_estimate.z", FT_BOOLEAN, 16,
- NULL, 0x4000, NULL, HFILL } },
+ TFS(&tfs_twamp_zbit_tfs), 0x4000, NULL, HFILL } },
{ &hf_twamp_error_estimate_b15,
{ "S", "twamp.test.error_estimate.s", FT_BOOLEAN, 16,
TFS(&tfs_twamp_sbit_tfs), 0x8000, NULL, HFILL } },
@@ -801,10 +818,7 @@ void proto_register_twamp(void)
/* Register the protocol */
- proto_twamp_test = proto_register_protocol(
- "TwoWay Active Measurement Test Protocol",
- "TWAMP-Test",
- "twamp.test");
+ proto_twamp_test = proto_register_protocol("TwoWay Active Measurement Test Protocol", "TWAMP-Test", "twamp.test");
/* Register the field array */
proto_register_field_array (proto_twamp_test, hf_twamp_test,
@@ -814,11 +828,11 @@ void proto_register_twamp(void)
proto_register_subtree_array (ett_twamp_test_arr,
array_length(ett_twamp_test_arr));
+ /* Register the dissector handle */
+ twamp_test_handle = register_dissector("twamp.test", dissect_twamp_test, proto_twamp_test);
+
/* Register the protocol */
- proto_twamp_control = proto_register_protocol(
- "TwoWay Active Measurement Control Protocol",
- "TWAMP-Control",
- "twamp.control");
+ proto_twamp_control = proto_register_protocol("TwoWay Active Measurement Control Protocol", "TWAMP-Control", "twamp.control");
/* Register the field array */
proto_register_field_array (proto_twamp_control, hf_twamp_control,
@@ -828,20 +842,18 @@ void proto_register_twamp(void)
proto_register_subtree_array (ett_twamp_control_arr,
array_length(ett_twamp_control_arr));
- proto_owamp_test = proto_register_protocol(
- "One-way Active Measurement Protocol",
- "OWAMP-Test",
- "owamp.test");
+ /* Register the dissector handle */
+ twamp_control_handle = register_dissector("twamp.control", dissect_twamp_server_greeting, proto_twamp_control);
+ /* Register the protocol */
+ proto_owamp_test = proto_register_protocol("One-way Active Measurement Protocol", "OWAMP-Test", "owamp.test");
+
+ /* Register the dissector handle */
+ owamp_test_handle = register_dissector("owamp.test", dissect_owamp_test, proto_owamp_test);
}
void proto_reg_handoff_twamp(void)
{
- twamp_test_handle = create_dissector_handle(dissect_twamp_test, proto_twamp_test);
-
- owamp_test_handle = create_dissector_handle(dissect_owamp_test, proto_owamp_test);
-
- twamp_control_handle = create_dissector_handle(dissect_twamp_server_greeting, proto_twamp_control);
dissector_add_uint("tcp.port", TWAMP_CONTROL_PORT, twamp_control_handle);
dissector_add_for_decode_as("udp.port", twamp_test_handle);