2010-03-16 06:58:25 +00:00
|
|
|
/* packet-interlink.c
|
|
|
|
* Routines for Interlink protocol packet disassembly
|
|
|
|
* By Uwe Girlich <uwe.girlich@philosys.de>
|
|
|
|
* Copyright 2010 Uwe Girlich
|
|
|
|
*
|
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
2018-02-12 11:23:27 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
2010-03-16 06:58:25 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <epan/packet.h>
|
|
|
|
|
2013-12-14 12:45:57 +00:00
|
|
|
void proto_register_interlink(void);
|
|
|
|
void proto_reg_handoff_interlink(void);
|
2010-03-16 06:58:25 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* No public information available.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static int proto_interlink = -1;
|
|
|
|
|
|
|
|
static int hf_interlink_id = -1;
|
|
|
|
static int hf_interlink_version = -1;
|
|
|
|
static int hf_interlink_cmd = -1;
|
|
|
|
static int hf_interlink_seq = -1;
|
|
|
|
static int hf_interlink_flags = -1;
|
|
|
|
static int hf_interlink_flags_req_ack = -1;
|
|
|
|
static int hf_interlink_flags_inc_ack_port = -1;
|
|
|
|
static int hf_interlink_block_type = -1;
|
|
|
|
static int hf_interlink_block_version = -1;
|
|
|
|
static int hf_interlink_block_length = -1;
|
|
|
|
|
|
|
|
static gint ett_interlink = -1;
|
|
|
|
static gint ett_interlink_header = -1;
|
|
|
|
static gint ett_interlink_flags = -1;
|
|
|
|
static gint ett_interlink_block = -1;
|
|
|
|
|
|
|
|
static dissector_handle_t data_handle;
|
|
|
|
static dissector_table_t subdissector_table;
|
2016-12-17 01:06:11 +00:00
|
|
|
static dissector_handle_t interlink_handle;
|
2010-03-16 06:58:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
static const value_string names_cmd[] = {
|
|
|
|
{ 1, "Data" },
|
|
|
|
{ 2, "Ack" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-11-09 01:15:22 +00:00
|
|
|
static int
|
|
|
|
dissect_interlink(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
|
2010-03-16 06:58:25 +00:00
|
|
|
{
|
|
|
|
int offset = 0;
|
2014-06-29 13:13:51 +00:00
|
|
|
proto_tree *il_tree;
|
|
|
|
proto_item *il_item;
|
2010-03-16 06:58:25 +00:00
|
|
|
proto_tree *ilh_tree = NULL;
|
|
|
|
proto_tree *ilb_tree = NULL;
|
|
|
|
guint8 ilb_type;
|
|
|
|
guint8 ilb_version;
|
|
|
|
guint16 type_version = 0;
|
|
|
|
dissector_handle_t handle;
|
|
|
|
tvbuff_t *next_tvb;
|
|
|
|
|
2010-03-16 07:45:12 +00:00
|
|
|
col_set_str(pinfo->cinfo, COL_PROTOCOL, "INTERLINK");
|
|
|
|
col_clear(pinfo->cinfo, COL_INFO);
|
2010-03-16 06:58:25 +00:00
|
|
|
|
2014-06-29 13:13:51 +00:00
|
|
|
il_item = proto_tree_add_item(tree, proto_interlink,
|
|
|
|
tvb, 0, 16, ENC_NA);
|
|
|
|
il_tree = proto_item_add_subtree(il_item, ett_interlink);
|
2010-03-16 06:58:25 +00:00
|
|
|
|
2014-06-29 13:13:51 +00:00
|
|
|
ilh_tree = proto_tree_add_subtree(il_tree, tvb, 0, 12, ett_interlink_header, NULL, "Interlink Header");
|
2010-03-16 06:58:25 +00:00
|
|
|
|
2010-03-16 07:53:48 +00:00
|
|
|
if (ilh_tree) {
|
2011-10-15 18:46:26 +00:00
|
|
|
proto_tree_add_item(ilh_tree, hf_interlink_id, tvb, offset, 4, ENC_ASCII|ENC_NA);
|
2010-03-16 07:53:48 +00:00
|
|
|
offset += 4;
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(ilh_tree, hf_interlink_version, tvb, offset, 2, ENC_LITTLE_ENDIAN);
|
2010-03-16 07:53:48 +00:00
|
|
|
offset += 2;
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(ilh_tree, hf_interlink_cmd, tvb, offset, 2, ENC_LITTLE_ENDIAN);
|
2010-03-16 07:53:48 +00:00
|
|
|
offset += 2;
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(ilh_tree, hf_interlink_seq, tvb, offset, 2, ENC_LITTLE_ENDIAN);
|
2010-03-16 07:53:48 +00:00
|
|
|
offset += 2;
|
2010-09-24 18:46:28 +00:00
|
|
|
} else {
|
|
|
|
offset += 10;
|
2010-03-16 07:53:48 +00:00
|
|
|
}
|
|
|
|
|
2010-03-16 06:58:25 +00:00
|
|
|
if (ilh_tree) {
|
2020-06-19 01:14:46 +00:00
|
|
|
static int * const flags[] = {
|
2014-11-30 17:51:30 +00:00
|
|
|
&hf_interlink_flags_req_ack,
|
|
|
|
&hf_interlink_flags_inc_ack_port,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
proto_tree_add_bitmask(ilh_tree, tvb, offset, hf_interlink_flags, ett_interlink_flags, flags, ENC_LITTLE_ENDIAN);
|
|
|
|
|
2010-03-16 06:58:25 +00:00
|
|
|
}
|
|
|
|
offset += 2;
|
|
|
|
|
2014-06-29 13:13:51 +00:00
|
|
|
ilb_tree = proto_tree_add_subtree(il_tree, tvb, offset, 4, ett_interlink_block, NULL, "Block Header");
|
2010-03-16 06:58:25 +00:00
|
|
|
|
|
|
|
ilb_type = tvb_get_guint8(tvb, offset);
|
|
|
|
ilb_version = tvb_get_guint8(tvb, offset + 1);
|
|
|
|
type_version = ilb_type << 8 | ilb_version;
|
2010-09-22 07:18:49 +00:00
|
|
|
col_append_fstr(pinfo->cinfo, COL_INFO, "Type: %d, Version: %d",
|
2010-03-16 06:58:25 +00:00
|
|
|
ilb_type, ilb_version);
|
|
|
|
|
2010-03-16 07:53:48 +00:00
|
|
|
if (ilb_tree) {
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(ilb_tree, hf_interlink_block_type, tvb, offset, 1, ENC_BIG_ENDIAN);
|
2010-03-16 07:53:48 +00:00
|
|
|
offset += 1;
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(ilb_tree, hf_interlink_block_version, tvb, offset, 1, ENC_BIG_ENDIAN);
|
2010-03-16 07:53:48 +00:00
|
|
|
offset += 1;
|
2011-10-06 03:35:44 +00:00
|
|
|
proto_tree_add_item(ilb_tree, hf_interlink_block_length, tvb, offset, 2, ENC_LITTLE_ENDIAN);
|
2010-03-16 07:53:48 +00:00
|
|
|
offset += 2;
|
2010-09-24 18:46:28 +00:00
|
|
|
} else {
|
|
|
|
offset += 4;
|
2010-03-16 07:53:48 +00:00
|
|
|
}
|
2010-03-16 06:58:25 +00:00
|
|
|
|
|
|
|
/* Generate a new tvb for the rest. */
|
|
|
|
next_tvb = tvb_new_subset_remaining(tvb, offset);
|
|
|
|
|
|
|
|
/* Probably a sub-dissector exists for this type/version combination. */
|
2010-12-20 05:35:29 +00:00
|
|
|
handle = dissector_get_uint_handle(subdissector_table, type_version);
|
2010-03-16 06:58:25 +00:00
|
|
|
|
|
|
|
/* Without a proper sub-dissector, we use "data". */
|
|
|
|
if (handle == NULL) handle = data_handle;
|
|
|
|
|
|
|
|
/* Call the sub-dissector. */
|
|
|
|
call_dissector(handle, next_tvb, pinfo, tree);
|
2015-11-09 01:15:22 +00:00
|
|
|
|
|
|
|
return tvb_captured_length(tvb);
|
2010-03-16 06:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
2012-09-16 17:26:49 +00:00
|
|
|
dissect_interlink_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
|
2010-03-16 06:58:25 +00:00
|
|
|
{
|
|
|
|
if (!tvb_bytes_exist(tvb, 0, 4)) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (
|
|
|
|
tvb_get_guint8(tvb,0) != 'I' ||
|
|
|
|
tvb_get_guint8(tvb,1) != 'L' ||
|
|
|
|
tvb_get_guint8(tvb,2) != 'N' ||
|
|
|
|
tvb_get_guint8(tvb,3) != 'K'
|
|
|
|
)
|
|
|
|
return FALSE;
|
|
|
|
|
2015-11-09 01:15:22 +00:00
|
|
|
dissect_interlink(tvb, pinfo, tree, data);
|
2010-03-16 06:58:25 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_interlink(void)
|
|
|
|
{
|
|
|
|
static hf_register_info hf[] = {
|
|
|
|
{ &hf_interlink_id, {
|
|
|
|
"Magic ID", "interlink.id", FT_STRING,
|
|
|
|
BASE_NONE, NULL, 0, NULL, HFILL }},
|
|
|
|
{ &hf_interlink_version, {
|
|
|
|
"Version", "interlink.version", FT_UINT16,
|
|
|
|
BASE_DEC, NULL, 0, NULL, HFILL }},
|
|
|
|
{ &hf_interlink_cmd, {
|
|
|
|
"Command", "interlink.cmd", FT_UINT16,
|
|
|
|
BASE_DEC, VALS(names_cmd), 0, NULL, HFILL }},
|
|
|
|
{ &hf_interlink_seq, {
|
|
|
|
"Sequence", "interlink.seq", FT_UINT16,
|
|
|
|
BASE_DEC, NULL, 0, NULL, HFILL }},
|
|
|
|
{ &hf_interlink_flags, {
|
|
|
|
"Flags", "interlink.flags", FT_UINT16,
|
|
|
|
BASE_HEX, NULL, 0, NULL, HFILL }},
|
|
|
|
{ &hf_interlink_flags_req_ack, {
|
|
|
|
"REQ_ACK", "interlink.flags.req_ack", FT_BOOLEAN,
|
Find and fix dissectors that should be using a default tfs.
Found using tools/check_tfs.py, included in this commit.
Here are the reports that were fixed here:
Examining:
All dissector modules
epan/dissectors/packet-assa_r3.c tfs_mortisepins_flags - could have used tfs_high_low from tfs.c instead: {High,Low}
epan/dissectors/packet-btle.c tfs_present_bit - could have used tfs_present_not_present from tfs.c instead: {Present,Not Present}
epan/dissectors/packet-dhcp.c tfs_fqdn_s - could have used tfs_server_client from tfs.c instead: {Server,Client}
epan/dissectors/packet-docsis-macmgmt.c mdd_tfs_on_off - could have used tfs_on_off from tfs.c instead: {On,Off}
epan/dissectors/packet-docsis-macmgmt.c mdd_tfs_en_dis - could have used tfs_enabled_disabled from tfs.c instead: {Enabled,Disabled}
epan/dissectors/packet-docsis-macmgmt.c req_not_req_tfs - could have used tfs_requested_not_requested from tfs.c instead: {Requested,Not Requested}
epan/dissectors/packet-docsis-tlv.c on_off_tfs - could have used tfs_on_off from tfs.c instead: {On,Off}
epan/dissectors/packet-docsis-tlv.c activation_tfs - could have used tfs_active_inactive from tfs.c instead: {Active,Inactive}
epan/dissectors/packet-docsis.c ena_dis_tfs - could have used tfs_enabled_disabled from tfs.c instead: {Enabled,Disabled}
epan/dissectors/packet-ecmp.c tfs_not_expected_expected - could have used tfs_odd_even from tfs.c instead: {Odd,Even}
epan/dissectors/packet-erf.c erf_link_status_tfs - could have used tfs_up_down from tfs.c instead: {Up,Down}
epan/dissectors/packet-h263.c on_off_flg - could have used tfs_on_off from tfs.c instead: {On,Off}
epan/dissectors/packet-h263.c cpm_flg - could have used tfs_on_off from tfs.c instead: {On,Off}
epan/dissectors/packet-interlink.c flags_set_notset - could have used tfs_set_notset from tfs.c instead: {Set,Not set}
epan/dissectors/packet-ip.c tos_set_low - could have used tfs_low_normal from tfs.c instead: {Low,Normal}
epan/dissectors/packet-ip.c tos_set_high - could have used tfs_high_normal from tfs.c instead: {High,Normal}
epan/dissectors/packet-isakmp.c flag_r - could have used tfs_response_request from tfs.c instead: {Response,Request}
epan/dissectors/packet-isis-lsp.c tfs_metric_supported_not_supported - could have used tfs_no_yes from tfs.c instead: {No,Yes}
epan/dissectors/packet-kerberos.c supported_tfs - could have used tfs_supported_not_supported from tfs.c instead: {Supported,Not supported}
epan/dissectors/packet-kerberos.c set_tfs - could have used tfs_set_notset from tfs.c instead: {Set,Not set}
epan/dissectors/packet-mac-lte.c mac_lte_scell_status_vals - could have used tfs_activated_deactivated from tfs.c instead: {Activated,Deactivated}
epan/dissectors/packet-p_mul.c no_yes - could have used tfs_no_yes from tfs.c instead: {No,Yes}
epan/dissectors/packet-pgm.c opts_present - could have used tfs_present_not_present from tfs.c instead: {Present,Not Present}
epan/dissectors/packet-rsl.c rsl_ms_fpc_epc_mode_vals - could have used tfs_inuse_not_inuse from tfs.c instead: {In use,Not in use}
epan/dissectors/packet-sita.c tfs_sita_on_off - could have used tfs_on_off from tfs.c instead: {On,Off}
epan/dissectors/packet-vines.c tfs_vine_rtp_no_yes - could have used tfs_no_yes from tfs.c instead: {No,Yes}
epan/dissectors/packet-vnc.c button_mask_tfs - could have used tfs_pressed_not_pressed from tfs.c instead: {Pressed,Not pressed}
27 issues found
Change-Id: I7e53b491f20289955c9e9caa8357197d9010a5aa
Reviewed-on: https://code.wireshark.org/review/38087
Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-08-07 20:15:46 +00:00
|
|
|
16, TFS(&tfs_set_notset), 0x01, NULL, HFILL }},
|
2010-03-16 06:58:25 +00:00
|
|
|
{ &hf_interlink_flags_inc_ack_port, {
|
|
|
|
"INC_ACK_PORT", "interlink.flags.inc_ack_port", FT_BOOLEAN,
|
Find and fix dissectors that should be using a default tfs.
Found using tools/check_tfs.py, included in this commit.
Here are the reports that were fixed here:
Examining:
All dissector modules
epan/dissectors/packet-assa_r3.c tfs_mortisepins_flags - could have used tfs_high_low from tfs.c instead: {High,Low}
epan/dissectors/packet-btle.c tfs_present_bit - could have used tfs_present_not_present from tfs.c instead: {Present,Not Present}
epan/dissectors/packet-dhcp.c tfs_fqdn_s - could have used tfs_server_client from tfs.c instead: {Server,Client}
epan/dissectors/packet-docsis-macmgmt.c mdd_tfs_on_off - could have used tfs_on_off from tfs.c instead: {On,Off}
epan/dissectors/packet-docsis-macmgmt.c mdd_tfs_en_dis - could have used tfs_enabled_disabled from tfs.c instead: {Enabled,Disabled}
epan/dissectors/packet-docsis-macmgmt.c req_not_req_tfs - could have used tfs_requested_not_requested from tfs.c instead: {Requested,Not Requested}
epan/dissectors/packet-docsis-tlv.c on_off_tfs - could have used tfs_on_off from tfs.c instead: {On,Off}
epan/dissectors/packet-docsis-tlv.c activation_tfs - could have used tfs_active_inactive from tfs.c instead: {Active,Inactive}
epan/dissectors/packet-docsis.c ena_dis_tfs - could have used tfs_enabled_disabled from tfs.c instead: {Enabled,Disabled}
epan/dissectors/packet-ecmp.c tfs_not_expected_expected - could have used tfs_odd_even from tfs.c instead: {Odd,Even}
epan/dissectors/packet-erf.c erf_link_status_tfs - could have used tfs_up_down from tfs.c instead: {Up,Down}
epan/dissectors/packet-h263.c on_off_flg - could have used tfs_on_off from tfs.c instead: {On,Off}
epan/dissectors/packet-h263.c cpm_flg - could have used tfs_on_off from tfs.c instead: {On,Off}
epan/dissectors/packet-interlink.c flags_set_notset - could have used tfs_set_notset from tfs.c instead: {Set,Not set}
epan/dissectors/packet-ip.c tos_set_low - could have used tfs_low_normal from tfs.c instead: {Low,Normal}
epan/dissectors/packet-ip.c tos_set_high - could have used tfs_high_normal from tfs.c instead: {High,Normal}
epan/dissectors/packet-isakmp.c flag_r - could have used tfs_response_request from tfs.c instead: {Response,Request}
epan/dissectors/packet-isis-lsp.c tfs_metric_supported_not_supported - could have used tfs_no_yes from tfs.c instead: {No,Yes}
epan/dissectors/packet-kerberos.c supported_tfs - could have used tfs_supported_not_supported from tfs.c instead: {Supported,Not supported}
epan/dissectors/packet-kerberos.c set_tfs - could have used tfs_set_notset from tfs.c instead: {Set,Not set}
epan/dissectors/packet-mac-lte.c mac_lte_scell_status_vals - could have used tfs_activated_deactivated from tfs.c instead: {Activated,Deactivated}
epan/dissectors/packet-p_mul.c no_yes - could have used tfs_no_yes from tfs.c instead: {No,Yes}
epan/dissectors/packet-pgm.c opts_present - could have used tfs_present_not_present from tfs.c instead: {Present,Not Present}
epan/dissectors/packet-rsl.c rsl_ms_fpc_epc_mode_vals - could have used tfs_inuse_not_inuse from tfs.c instead: {In use,Not in use}
epan/dissectors/packet-sita.c tfs_sita_on_off - could have used tfs_on_off from tfs.c instead: {On,Off}
epan/dissectors/packet-vines.c tfs_vine_rtp_no_yes - could have used tfs_no_yes from tfs.c instead: {No,Yes}
epan/dissectors/packet-vnc.c button_mask_tfs - could have used tfs_pressed_not_pressed from tfs.c instead: {Pressed,Not pressed}
27 issues found
Change-Id: I7e53b491f20289955c9e9caa8357197d9010a5aa
Reviewed-on: https://code.wireshark.org/review/38087
Petri-Dish: Martin Mathieson <martin.r.mathieson@googlemail.com>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
2020-08-07 20:15:46 +00:00
|
|
|
16, TFS(&tfs_set_notset), 0x02, NULL, HFILL }},
|
2010-03-16 06:58:25 +00:00
|
|
|
{ &hf_interlink_block_type, {
|
|
|
|
"Type", "interlink.type", FT_UINT8,
|
2010-09-22 07:18:49 +00:00
|
|
|
BASE_DEC, NULL, 0, NULL, HFILL }},
|
2010-03-16 06:58:25 +00:00
|
|
|
{ &hf_interlink_block_version, {
|
|
|
|
"Version", "interlink.block_version", FT_UINT8,
|
|
|
|
BASE_DEC, NULL, 0, NULL, HFILL }},
|
|
|
|
{ &hf_interlink_block_length, {
|
|
|
|
"Length", "interlink.length", FT_UINT16,
|
|
|
|
BASE_DEC, NULL, 0, NULL, HFILL }},
|
|
|
|
};
|
|
|
|
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_interlink,
|
|
|
|
&ett_interlink_header,
|
|
|
|
&ett_interlink_flags,
|
|
|
|
&ett_interlink_block,
|
|
|
|
};
|
|
|
|
|
|
|
|
proto_interlink = proto_register_protocol("Interlink Protocol",
|
|
|
|
"Interlink",
|
|
|
|
"interlink");
|
|
|
|
proto_register_field_array(proto_interlink, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
2016-12-17 01:06:11 +00:00
|
|
|
interlink_handle = register_dissector("interlink", dissect_interlink, proto_interlink);
|
2010-03-16 06:58:25 +00:00
|
|
|
|
|
|
|
/* Probably someone will write sub-dissectors. You can never know. */
|
|
|
|
subdissector_table = register_dissector_table("interlink.type_version",
|
2016-08-30 22:51:54 +00:00
|
|
|
"Interlink type_version", proto_interlink, FT_UINT16, BASE_HEX);
|
2010-03-16 06:58:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_interlink(void)
|
|
|
|
{
|
|
|
|
/* Allow "Decode As" with any UDP packet. */
|
2016-10-05 20:33:54 +00:00
|
|
|
dissector_add_for_decode_as_with_preference("udp.port", interlink_handle);
|
2010-03-16 06:58:25 +00:00
|
|
|
|
|
|
|
/* Add our heuristic packet finder. */
|
2015-07-13 00:40:31 +00:00
|
|
|
heur_dissector_add("udp", dissect_interlink_heur, "Interlink over UDP", "interlink_udp", proto_interlink, HEURISTIC_ENABLE);
|
2010-03-16 06:58:25 +00:00
|
|
|
|
|
|
|
data_handle = find_dissector("data");
|
|
|
|
}
|
|
|
|
|
2014-09-30 20:59:17 +00:00
|
|
|
/*
|
2019-07-26 18:43:17 +00:00
|
|
|
* Editor modelines - https://www.wireshark.org/tools/modelines.html
|
2014-09-30 20:59:17 +00:00
|
|
|
*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* tab-width: 8
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
* End:
|
|
|
|
*
|
|
|
|
* vi: set shiftwidth=8 tabstop=8 noexpandtab:
|
|
|
|
* :indentSize=8:tabSize=8:noTabs=false:
|
|
|
|
*/
|