forked from osmocom/wireshark
Minor cleanup, including:
- Remove unneeded #includes; - Simplify code slightly; - Remove unused ett variable and related; - Remove empty proto_reg_handoff...() functions; - Fix a few cases of "set but unused". - Do some whitespace changes. svn path=/trunk/; revision=43748
This commit is contained in:
parent
1e95104860
commit
f41a04b7ab
|
@ -40,16 +40,9 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <epan/packet.h>
|
#include <epan/packet.h>
|
||||||
#include <epan/addr_resolv.h>
|
#include <epan/emem.h>
|
||||||
#include <epan/prefs.h>
|
#include <epan/prefs.h>
|
||||||
#include <epan/strutil.h>
|
|
||||||
|
|
||||||
void proto_reg_handoff_dmx_chan(void);
|
|
||||||
|
|
||||||
static int proto_dmx_chan = -1;
|
static int proto_dmx_chan = -1;
|
||||||
|
|
||||||
|
@ -62,8 +55,8 @@ static int ett_dmx_chan = -1;
|
||||||
* Here are the global variables associated with the preferences for DMX
|
* Here are the global variables associated with the preferences for DMX
|
||||||
*/
|
*/
|
||||||
static gint global_disp_chan_val_type = 0;
|
static gint global_disp_chan_val_type = 0;
|
||||||
static gint global_disp_col_count = 16;
|
static gint global_disp_col_count = 16;
|
||||||
static gint global_disp_chan_nr_type = 0;
|
static gint global_disp_chan_nr_type = 0;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dissect_dmx_chan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
dissect_dmx_chan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
||||||
|
@ -72,24 +65,24 @@ dissect_dmx_chan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
||||||
col_clear(pinfo->cinfo, COL_INFO);
|
col_clear(pinfo->cinfo, COL_INFO);
|
||||||
|
|
||||||
if (tree != NULL) {
|
if (tree != NULL) {
|
||||||
const char* chan_format[] = {
|
static const char *chan_format[] = {
|
||||||
"%2u%% ",
|
"%2u%% ",
|
||||||
"0x%02x ",
|
"0x%02x ",
|
||||||
"%3u "
|
"%3u "
|
||||||
};
|
};
|
||||||
const char* string_format[] = {
|
static const char *string_format[] = {
|
||||||
"0x%03x: %s",
|
"0x%03x: %s",
|
||||||
"%3u: %s"
|
"%3u: %s"
|
||||||
};
|
};
|
||||||
emem_strbuf_t *chan_str = ep_strbuf_new_label("");
|
emem_strbuf_t *chan_str = ep_strbuf_new_label("");
|
||||||
proto_item *item;
|
proto_item *item;
|
||||||
guint16 length,r,c,row_count;
|
guint16 length,r,c,row_count;
|
||||||
guint8 v;
|
guint8 v;
|
||||||
unsigned offset = 0;
|
unsigned offset = 0;
|
||||||
|
|
||||||
proto_tree *ti = proto_tree_add_item(tree, proto_dmx_chan, tvb,
|
proto_tree *ti = proto_tree_add_item(tree, proto_dmx_chan, tvb,
|
||||||
offset, -1, FALSE);
|
offset, -1, FALSE);
|
||||||
proto_tree *dmx_chan_tree = proto_item_add_subtree(ti, ett_dmx_chan);
|
proto_tree *dmx_chan_tree = proto_item_add_subtree(ti, ett_dmx_chan);
|
||||||
|
|
||||||
length = tvb_reported_length_remaining(tvb, offset);
|
length = tvb_reported_length_remaining(tvb, offset);
|
||||||
|
|
||||||
|
@ -123,7 +116,6 @@ dissect_dmx_chan(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
||||||
item = proto_tree_add_item(dmx_chan_tree, hf_dmx_chan_output_data_filter, tvb,
|
item = proto_tree_add_item(dmx_chan_tree, hf_dmx_chan_output_data_filter, tvb,
|
||||||
offset, length, ENC_NA );
|
offset, length, ENC_NA );
|
||||||
PROTO_ITEM_SET_HIDDEN(item);
|
PROTO_ITEM_SET_HIDDEN(item);
|
||||||
offset += length;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,7 +190,3 @@ proto_register_dmx_chan(void)
|
||||||
col_count, ENC_BIG_ENDIAN);
|
col_count, ENC_BIG_ENDIAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
proto_reg_handoff_dmx_chan(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
|
@ -40,19 +40,10 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <epan/packet.h>
|
#include <epan/packet.h>
|
||||||
#include <epan/addr_resolv.h>
|
|
||||||
#include <epan/prefs.h>
|
|
||||||
#include <epan/strutil.h>
|
|
||||||
|
|
||||||
#define DMX_SC_SIP 0xCF
|
#define DMX_SC_SIP 0xCF
|
||||||
|
|
||||||
void proto_reg_handoff_dmx_sip(void);
|
|
||||||
|
|
||||||
static int proto_dmx_sip = -1;
|
static int proto_dmx_sip = -1;
|
||||||
|
|
||||||
static int hf_dmx_sip_byte_count = -1;
|
static int hf_dmx_sip_byte_count = -1;
|
||||||
|
@ -80,8 +71,8 @@ static int ett_dmx_sip = -1;
|
||||||
static guint8
|
static guint8
|
||||||
dmx_sip_checksum(tvbuff_t *tvb, unsigned length)
|
dmx_sip_checksum(tvbuff_t *tvb, unsigned length)
|
||||||
{
|
{
|
||||||
guint8 sum = DMX_SC_SIP;
|
guint8 sum = DMX_SC_SIP;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
for (i = 0; i < length; i++)
|
for (i = 0; i < length; i++)
|
||||||
sum += tvb_get_guint8(tvb, i);
|
sum += tvb_get_guint8(tvb, i);
|
||||||
return sum;
|
return sum;
|
||||||
|
@ -94,9 +85,9 @@ dissect_dmx_sip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
||||||
col_clear(pinfo->cinfo, COL_INFO);
|
col_clear(pinfo->cinfo, COL_INFO);
|
||||||
|
|
||||||
if (tree != NULL) {
|
if (tree != NULL) {
|
||||||
unsigned offset = 0;
|
unsigned offset = 0;
|
||||||
unsigned byte_count;
|
unsigned byte_count;
|
||||||
unsigned checksum, checksum_shouldbe;
|
unsigned checksum, checksum_shouldbe;
|
||||||
proto_item *item;
|
proto_item *item;
|
||||||
proto_tree *checksum_tree;
|
proto_tree *checksum_tree;
|
||||||
|
|
||||||
|
@ -314,7 +305,3 @@ proto_register_dmx_sip(void)
|
||||||
register_dissector("dmx-sip", dissect_dmx_sip, proto_dmx_sip);
|
register_dissector("dmx-sip", dissect_dmx_sip, proto_dmx_sip);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
proto_reg_handoff_dmx_sip(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
|
@ -40,19 +40,10 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <epan/packet.h>
|
#include <epan/packet.h>
|
||||||
#include <epan/addr_resolv.h>
|
|
||||||
#include <epan/prefs.h>
|
|
||||||
#include <epan/strutil.h>
|
|
||||||
|
|
||||||
#define DMX_TEST_PACKET_SIZE 512
|
#define DMX_TEST_PACKET_SIZE 512
|
||||||
#define DMX_TEST_VALUE 0x55
|
#define DMX_TEST_VALUE 0x55
|
||||||
|
|
||||||
void proto_reg_handoff_dmx_test(void);
|
|
||||||
|
|
||||||
static int proto_dmx_test = -1;
|
static int proto_dmx_test = -1;
|
||||||
|
|
||||||
|
@ -69,9 +60,9 @@ dissect_dmx_test(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
||||||
col_clear(pinfo->cinfo, COL_INFO);
|
col_clear(pinfo->cinfo, COL_INFO);
|
||||||
|
|
||||||
if (tree != NULL) {
|
if (tree != NULL) {
|
||||||
unsigned offset = 0;
|
unsigned offset = 0;
|
||||||
unsigned size, i, test_data_is_ok;
|
unsigned size, i, test_data_is_ok;
|
||||||
proto_tree* test_data_tree;
|
proto_tree *test_data_tree;
|
||||||
proto_item *item;
|
proto_item *item;
|
||||||
|
|
||||||
proto_tree *ti = proto_tree_add_item(tree, proto_dmx_test, tvb,
|
proto_tree *ti = proto_tree_add_item(tree, proto_dmx_test, tvb,
|
||||||
|
@ -151,8 +142,3 @@ proto_register_dmx_test(void)
|
||||||
proto_register_subtree_array(ett, array_length(ett));
|
proto_register_subtree_array(ett, array_length(ett));
|
||||||
register_dissector("dmx-test", dissect_dmx_test, proto_dmx_test);
|
register_dissector("dmx-test", dissect_dmx_test, proto_dmx_test);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
proto_reg_handoff_dmx_test(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
|
@ -40,16 +40,7 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <epan/packet.h>
|
#include <epan/packet.h>
|
||||||
#include <epan/addr_resolv.h>
|
|
||||||
#include <epan/prefs.h>
|
|
||||||
#include <epan/strutil.h>
|
|
||||||
|
|
||||||
void proto_reg_handoff_dmx_text(void);
|
|
||||||
|
|
||||||
static int proto_dmx_text = -1;
|
static int proto_dmx_text = -1;
|
||||||
|
|
||||||
|
@ -85,7 +76,6 @@ dissect_dmx_text(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
||||||
|
|
||||||
proto_tree_add_item(dmx_text_tree, hf_dmx_text_string, tvb,
|
proto_tree_add_item(dmx_text_tree, hf_dmx_text_string, tvb,
|
||||||
offset, size, ENC_BIG_ENDIAN);
|
offset, size, ENC_BIG_ENDIAN);
|
||||||
offset += size;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +110,3 @@ proto_register_dmx_text(void)
|
||||||
register_dissector("dmx-text", dissect_dmx_text, proto_dmx_text);
|
register_dissector("dmx-text", dissect_dmx_text, proto_dmx_text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
proto_reg_handoff_dmx_text(void)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
* This dissector is written by
|
* This dissector is written by
|
||||||
*
|
*
|
||||||
* Erwin Rol <erwin@erwinrol.com>
|
* Erwin Rol <erwin@erwinrol.com>
|
||||||
* Copyright 2012 Erwin Rol
|
* Copyright 2012 Erwin Rol
|
||||||
*
|
*
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor
|
||||||
|
@ -41,14 +41,7 @@
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <epan/packet.h>
|
#include <epan/packet.h>
|
||||||
#include <epan/addr_resolv.h>
|
|
||||||
#include <epan/prefs.h>
|
|
||||||
#include <epan/strutil.h>
|
|
||||||
|
|
||||||
#define DMX_SC_DMX 0x00
|
#define DMX_SC_DMX 0x00
|
||||||
#define DMX_SC_TEXT 0x17
|
#define DMX_SC_TEXT 0x17
|
||||||
|
@ -70,23 +63,21 @@ void proto_reg_handoff_dmx(void);
|
||||||
static int proto_dmx = -1;
|
static int proto_dmx = -1;
|
||||||
|
|
||||||
static int hf_dmx_start_code = -1;
|
static int hf_dmx_start_code = -1;
|
||||||
static int hf_dmx_frame_data = -1;
|
|
||||||
|
|
||||||
static int ett_dmx = -1;
|
|
||||||
|
|
||||||
static dissector_handle_t rdm_handle;
|
static dissector_handle_t rdm_handle;
|
||||||
static dissector_handle_t dmx_chan_handle;
|
static dissector_handle_t dmx_chan_handle;
|
||||||
static dissector_handle_t dmx_test_handle;
|
static dissector_handle_t dmx_test_handle;
|
||||||
static dissector_handle_t dmx_text_handle;
|
static dissector_handle_t dmx_text_handle;
|
||||||
static dissector_handle_t dmx_sip_handle;
|
static dissector_handle_t dmx_sip_handle;
|
||||||
|
static dissector_handle_t data_handle;
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
dissect_dmx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
dissect_dmx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
||||||
{
|
{
|
||||||
tvbuff_t *next_tvb = NULL;
|
tvbuff_t *next_tvb;
|
||||||
unsigned offset = 0;
|
unsigned offset = 0;
|
||||||
guint8 start_code;
|
guint8 start_code;
|
||||||
|
|
||||||
col_set_str(pinfo->cinfo, COL_PROTOCOL, "DMX");
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "DMX");
|
||||||
col_clear(pinfo->cinfo, COL_INFO);
|
col_clear(pinfo->cinfo, COL_INFO);
|
||||||
|
@ -96,31 +87,27 @@ dissect_dmx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
|
||||||
offset, 1, ENC_BIG_ENDIAN);
|
offset, 1, ENC_BIG_ENDIAN);
|
||||||
offset++;
|
offset++;
|
||||||
|
|
||||||
|
next_tvb = tvb_new_subset_remaining(tvb, offset);
|
||||||
|
|
||||||
switch (start_code) {
|
switch (start_code) {
|
||||||
case DMX_SC_DMX:
|
case DMX_SC_DMX:
|
||||||
next_tvb = tvb_new_subset_remaining(tvb, offset);
|
|
||||||
call_dissector(dmx_chan_handle, next_tvb, pinfo, tree);
|
call_dissector(dmx_chan_handle, next_tvb, pinfo, tree);
|
||||||
break;
|
break;
|
||||||
case DMX_SC_TEXT:
|
case DMX_SC_TEXT:
|
||||||
next_tvb = tvb_new_subset_remaining(tvb, offset);
|
|
||||||
call_dissector(dmx_text_handle, next_tvb, pinfo, tree);
|
call_dissector(dmx_text_handle, next_tvb, pinfo, tree);
|
||||||
break;
|
break;
|
||||||
case DMX_SC_TEST:
|
case DMX_SC_TEST:
|
||||||
next_tvb = tvb_new_subset_remaining(tvb, offset);
|
|
||||||
call_dissector(dmx_test_handle, next_tvb, pinfo, tree);
|
call_dissector(dmx_test_handle, next_tvb, pinfo, tree);
|
||||||
break;
|
break;
|
||||||
case DMX_SC_RDM:
|
case DMX_SC_RDM:
|
||||||
next_tvb = tvb_new_subset_remaining(tvb, offset);
|
|
||||||
call_dissector(rdm_handle, next_tvb, pinfo, tree);
|
call_dissector(rdm_handle, next_tvb, pinfo, tree);
|
||||||
break;
|
break;
|
||||||
case DMX_SC_SIP:
|
case DMX_SC_SIP:
|
||||||
next_tvb = tvb_new_subset_remaining(tvb, offset);
|
|
||||||
call_dissector(dmx_sip_handle, next_tvb, pinfo, tree);
|
call_dissector(dmx_sip_handle, next_tvb, pinfo, tree);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (offset < tvb_length(tvb))
|
if (offset < tvb_length(tvb))
|
||||||
proto_tree_add_item(tree, hf_dmx_frame_data, tvb,
|
call_dissector(data_handle, next_tvb, pinfo, tree);
|
||||||
offset, -1, ENC_NA);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,33 +120,20 @@ proto_register_dmx(void)
|
||||||
{ "Start Code", "dmx.start_code",
|
{ "Start Code", "dmx.start_code",
|
||||||
FT_UINT8, BASE_HEX, VALS(dmx_sc_vals), 0x0,
|
FT_UINT8, BASE_HEX, VALS(dmx_sc_vals), 0x0,
|
||||||
NULL, HFILL }},
|
NULL, HFILL }},
|
||||||
{ &hf_dmx_frame_data,
|
|
||||||
{ "Frame Data", "dmx.frame_data",
|
|
||||||
FT_BYTES, BASE_NONE, NULL, 0x0,
|
|
||||||
NULL, HFILL }},
|
|
||||||
};
|
|
||||||
|
|
||||||
static gint *ett[] = {
|
|
||||||
&ett_dmx
|
|
||||||
};
|
};
|
||||||
|
|
||||||
proto_dmx = proto_register_protocol("DMX", "DMX", "dmx");
|
proto_dmx = proto_register_protocol("DMX", "DMX", "dmx");
|
||||||
proto_register_field_array(proto_dmx, hf, array_length(hf));
|
proto_register_field_array(proto_dmx, hf, array_length(hf));
|
||||||
proto_register_subtree_array(ett, array_length(ett));
|
|
||||||
register_dissector("dmx", dissect_dmx, proto_dmx);
|
register_dissector("dmx", dissect_dmx, proto_dmx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
proto_reg_handoff_dmx(void)
|
proto_reg_handoff_dmx(void)
|
||||||
{
|
{
|
||||||
static gboolean dmx_initialized = FALSE;
|
rdm_handle = find_dissector("rdm");
|
||||||
|
dmx_chan_handle = find_dissector("dmx-chan");
|
||||||
if (!dmx_initialized) {
|
dmx_test_handle = find_dissector("dmx-test");
|
||||||
rdm_handle = find_dissector("rdm");
|
dmx_text_handle = find_dissector("dmx-text");
|
||||||
dmx_chan_handle = find_dissector("dmx-chan");
|
dmx_sip_handle = find_dissector("dmx-sip");
|
||||||
dmx_test_handle = find_dissector("dmx-test");
|
data_handle = find_dissector("data");
|
||||||
dmx_text_handle = find_dissector("dmx-text");
|
|
||||||
dmx_sip_handle = find_dissector("dmx-sip");
|
|
||||||
dmx_initialized = TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue