From f30c5fee2a8d05f424ae1d733d0d99006eff930c Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Fri, 10 Oct 2014 12:09:21 +0200 Subject: tools: Minor adjustments to CHDR dissector --- tools/chdr-dissector/packet-chdr.c | 52 ++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 25 deletions(-) (limited to 'tools/chdr-dissector') diff --git a/tools/chdr-dissector/packet-chdr.c b/tools/chdr-dissector/packet-chdr.c index acacf817d..cce46bb84 100644 --- a/tools/chdr-dissector/packet-chdr.c +++ b/tools/chdr-dissector/packet-chdr.c @@ -1,8 +1,7 @@ -/* - * packet-chdr.c +/* * Dissector for UHD CHDR packets * - * Copyright 2010-2013 Ettus Research LLC + * Copyright 2010-2014 Ettus Research LLC * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -26,13 +25,15 @@ #include #include +#include "../../host/lib/usrp/x300/x300_fw_common.h" + #define LOG_HEADER "[UHD CHDR] " #ifndef min #define min(a,b) ((amatch_uint == CHDR_PORT){ is_network = TRUE; flag_offset = 0; @@ -159,12 +160,13 @@ static void dissect_chdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) len = tvb_reported_length(tvb); col_append_str(pinfo->cinfo, COL_PROTOCOL, "/CHDR"); - col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "CHDR", - tvb_format_text_wsp(tvb, 0, len)); + /* This throws a warning: */ + /*col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "CHDR", tvb_format_text_wsp(tvb, 0, len));*/ + col_append_sep_fstr(pinfo->cinfo, COL_INFO, NULL, "CHDR"); if (tree){ int chdr_size = -1; - + if (len >= 4){ chdr_size = 8; bytes = tvb_get_string(tvb, 0, 4); @@ -172,13 +174,13 @@ static void dissect_chdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) if (flag_has_time) chdr_size += 8; // 64-bit timestamp } - + /* Start with a top-level item to add everything else to */ item = proto_tree_add_item(tree, proto_chdr, tvb, 0, min(len, chdr_size), ENC_NA); - + if (len >= 4){ chdr_tree = proto_item_add_subtree(item, ett_chdr); - + header_item = proto_tree_add_item(chdr_tree, hf_chdr_hdr, tvb, flag_offset, 1, endianness); header_tree = proto_item_add_subtree(header_item, ett_chdr_header); @@ -191,7 +193,7 @@ static void dissect_chdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* These lines add sequence, packet_size and stream ID */ proto_tree_add_item(chdr_tree, hf_chdr_sequence, tvb, (is_network ? 0:2), 2, endianness); proto_tree_add_item(chdr_tree, hf_chdr_packet_size, tvb, (is_network ? 2:0), 2, endianness); - + if (len >= 8){ /* stream id can be broken down to 4 sections. these are collapsed in a subtree */ stream_item = proto_tree_add_item(chdr_tree, hf_chdr_stream_id, tvb, 4, 4, endianness); @@ -200,7 +202,7 @@ static void dissect_chdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_item(stream_tree, hf_chdr_src_ep, tvb, id_pos[1], 1, ENC_NA); proto_tree_add_item(stream_tree, hf_chdr_dst_dev, tvb, id_pos[2], 1, ENC_NA); proto_tree_add_item(stream_tree, hf_chdr_dst_ep, tvb, id_pos[3], 1, ENC_NA); - + /* if has_time flag is present interpret timestamp */ if ((flag_has_time) && (len >= 16)){ if (is_network) @@ -211,21 +213,21 @@ static void dissect_chdr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_tree_add_uint64(chdr_tree, hf_chdr_timestamp, tvb, 8, 8, timestamp); } } - + int remaining_bytes = (len - chdr_size); int show_raw_payload = (remaining_bytes > 0); - + if (hf_chdr_is_extension){ if (remaining_bytes == 8){ // Interpret this as a response packet response_item = proto_tree_add_item(chdr_tree, hf_chdr_ext_response, tvb, chdr_size, 8, endianness); response_tree = proto_item_add_subtree(response_item, ett_chdr_response); - + proto_tree_add_item(response_tree, hf_chdr_ext_status_code, tvb, chdr_size, 4, endianness); /* This will show the 12-bits of sequence ID in the last 2 bytes */ proto_tree_add_item(response_tree, hf_chdr_ext_seq_num, tvb, (chdr_size + 4 + (is_network ? 2 : 0)), 2, endianness); } } - + if (show_raw_payload) proto_tree_add_item(chdr_tree, hf_chdr_payload, tvb, chdr_size, -1, ENC_NA); } -- cgit v1.2.3