From d4cad23807cd61a6ec7df7ff89ed2256807ae3f2 Mon Sep 17 00:00:00 2001 From: Martin Mayer Date: Mon, 11 Oct 2021 15:49:19 +0200 Subject: [PATCH] Added Allied Telesis Loop Detection Frames --- AUTHORS.src | 4 + docbook/release-notes.adoc | 1 + epan/dissectors/CMakeLists.txt | 1 + epan/dissectors/packet-at-ldf.c | 162 ++++++++++++++++++++++++++++++++ epan/dissectors/packet-llc.c | 9 +- 5 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 epan/dissectors/packet-at-ldf.c diff --git a/AUTHORS.src b/AUTHORS.src index b87e2b89aa..e43566ef3a 100644 --- a/AUTHORS.src +++ b/AUTHORS.src @@ -3742,6 +3742,10 @@ Erik Rigtorp { Support for reading ZSTD and LZ4 compressed files } +Martin Mayer { + Allied Telesis Loop Detection Frames (LDF) dissector +} + and by: Georgi Guninski diff --git a/docbook/release-notes.adoc b/docbook/release-notes.adoc index 124565f7ab..e1d5e08fa9 100644 --- a/docbook/release-notes.adoc +++ b/docbook/release-notes.adoc @@ -128,6 +128,7 @@ Vector Informatik Binary Log File (BLF) // "Full protocol name (Abbreviation)" [commaize] -- +Allied Telesis Loop Detection Frames (AT LDF) Bluetooth Link Manager Protocol (BT LMP) Bundle Protocol version 7 (BPv7) Bundle Protocol version 7 Security (BPSec) diff --git a/epan/dissectors/CMakeLists.txt b/epan/dissectors/CMakeLists.txt index 0c1e4e1738..559d1ef37b 100644 --- a/epan/dissectors/CMakeLists.txt +++ b/epan/dissectors/CMakeLists.txt @@ -726,6 +726,7 @@ set(DISSECTOR_SRC ${CMAKE_CURRENT_SOURCE_DIR}/packet-assa_r3.c ${CMAKE_CURRENT_SOURCE_DIR}/packet-asterix.c ${CMAKE_CURRENT_SOURCE_DIR}/packet-at.c + ${CMAKE_CURRENT_SOURCE_DIR}/packet-at-ldf.c ${CMAKE_CURRENT_SOURCE_DIR}/packet-atalk.c ${CMAKE_CURRENT_SOURCE_DIR}/packet-ath.c ${CMAKE_CURRENT_SOURCE_DIR}/packet-atm.c diff --git a/epan/dissectors/packet-at-ldf.c b/epan/dissectors/packet-at-ldf.c new file mode 100644 index 0000000000..fb76bc5be4 --- /dev/null +++ b/epan/dissectors/packet-at-ldf.c @@ -0,0 +1,162 @@ +/* packet-at-ldf.c + * Dissector for Allied Telesis Loop Detection Frames + * + * Copyright (c) 2021 by Martin Mayer + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "config.h" +#include + +#define AT_LDF_LLC_CTRL 0xE3 + +void proto_register_at_ldf(void); +void proto_reg_handoff_at_ldf(void); + +static int proto_at_ldf = -1; + +/* Fields */ +static int hf_at_ldf_version = -1; +static int hf_at_ldf_src_vlan = -1; +static int hf_at_ldf_src_port = -1; +static int hf_at_ldf_ttl = -1; +static int hf_at_ldf_id = -1; +static int hf_at_ldf_text = -1; + +static gint ett_at_ldf = -1; + +static int +dissect_at_ldf(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree _U_, void *data _U_) +{ + /* + * Packet description + * + * The frame is an LLC frame (non-SNAP) with DSAP=0, SSAP=0, Control=0xE3. + * Ethernet destination address is the non-existing device address + * with Allied Telesis OUI (00:00:f4:27:71:01). + * + * The payload contains information about protocol version, source VLAN and port, + * TTL, random LDF identifier and an informational text. + */ + + + /* Check if packet is destined to AT test address */ + if(pinfo->dl_dst.type == AT_ETHER) { + const guint8 *dstaddr; + dstaddr = (const guint8 *)pinfo->dl_dst.data; + if( + dstaddr[0] != 0x00 || + dstaddr[1] != 0x00 || + dstaddr[2] != 0xF4 || + dstaddr[3] != 0x27 || + dstaddr[4] != 0x71 || + dstaddr[5] != 0x01 + ) return 0; + } else { + return 0; + } + + col_set_str(pinfo->cinfo, COL_PROTOCOL, "ATLDF"); + col_clear(pinfo->cinfo,COL_INFO); + col_add_fstr(pinfo->cinfo, COL_INFO, "Source VLAN: %u, Port: %u", + tvb_get_guint16(tvb, 1, ENC_BIG_ENDIAN), + tvb_get_guint16(tvb, 5, ENC_BIG_ENDIAN)); + + proto_item *ti = proto_tree_add_item(tree, proto_at_ldf, tvb, 0, -1, ENC_NA); + proto_tree *at_ldf_tree = proto_item_add_subtree(ti, ett_at_ldf); + + gint offset = 0; + proto_tree_add_item(at_ldf_tree, hf_at_ldf_version, tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; + proto_tree_add_item(at_ldf_tree, hf_at_ldf_src_vlan, tvb, offset, 2, ENC_BIG_ENDIAN); + offset += 2; + proto_tree_add_item(at_ldf_tree, hf_at_ldf_src_port, tvb, offset, 4, ENC_BIG_ENDIAN); + offset += 4; + proto_tree_add_item(at_ldf_tree, hf_at_ldf_ttl, tvb, offset, 1, ENC_BIG_ENDIAN); + offset += 1; + proto_tree_add_item(at_ldf_tree, hf_at_ldf_id, tvb, offset, 7, ENC_BIG_ENDIAN); + offset += 7; + proto_tree_add_item(at_ldf_tree, hf_at_ldf_text, tvb, offset, -1, ENC_BIG_ENDIAN); + + return tvb_captured_length(tvb); +} + +void +proto_register_at_ldf(void) +{ + static hf_register_info hf[] = { + { &hf_at_ldf_version, + { "Version", "atldf.version", + FT_UINT8, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_at_ldf_src_vlan, + { "Source VLAN", "atldf.vlan", + FT_UINT16, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_at_ldf_src_port, + { "Source Port", "atldf.port", + FT_UINT32, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_at_ldf_ttl, + { "Time to Live", "atldf.ttl", + FT_UINT8, BASE_DEC, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_at_ldf_id, + { "Identifier", "atldf.id", + FT_UINT56, BASE_HEX, + NULL, 0x0, + NULL, HFILL } + }, + { &hf_at_ldf_text, + { "Information", "atldf.info", + FT_STRINGZPAD, STR_ASCII, + NULL, 0x0, + NULL, HFILL } + } + }; + + static gint *ett[] = { + &ett_at_ldf + }; + + proto_at_ldf = proto_register_protocol ("Allied Telesis Loop Detection", "AT LDF", "atldf"); + + proto_register_field_array(proto_at_ldf, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); +} + +void +proto_reg_handoff_at_ldf(void) +{ + + static dissector_handle_t at_ldf_handle; + + at_ldf_handle = create_dissector_handle(dissect_at_ldf, proto_at_ldf); + dissector_add_uint("llc.control", AT_LDF_LLC_CTRL, at_ldf_handle); +} + +/* + * Editor modelines - https://www.wireshark.org/tools/modelines.html + * + * Local variables: + * c-basic-offset: 4 + * tab-width: 8 + * indent-tabs-mode: nil + * End: + * + * vi: set shiftwidth=4 tabstop=8 expandtab: + * :indentSize=4:tabSize=8:noTabs=true: + */ diff --git a/epan/dissectors/packet-llc.c b/epan/dissectors/packet-llc.c index 91c573fea8..c45c6651c0 100644 --- a/epan/dissectors/packet-llc.c +++ b/epan/dissectors/packet-llc.c @@ -78,6 +78,7 @@ static dissector_table_t xid_subdissector_table; static dissector_table_t ethertype_subdissector_table; static dissector_table_t hpteam_subdissector_table; +static dissector_table_t other_control_dissector_table; static dissector_handle_t bpdu_handle; static dissector_handle_t eth_withoutfcs_handle; @@ -470,7 +471,11 @@ dissect_llc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data) } } } else { - call_data_dissector(next_tvb, pinfo, tree); + if (!dissector_try_uint( + other_control_dissector_table, control, + next_tvb, pinfo, tree)) { + call_data_dissector(next_tvb, pinfo, tree); + } } } } @@ -835,6 +840,8 @@ proto_register_llc(void) "LLC SAP", proto_llc, FT_UINT8, BASE_HEX); xid_subdissector_table = register_dissector_table("llc.xid_dsap", "LLC XID SAP", proto_llc, FT_UINT8, BASE_HEX); + other_control_dissector_table = register_dissector_table("llc.control", + "LLC Control", proto_llc, FT_UINT16, BASE_HEX); register_capture_dissector_table("llc.dsap", "LLC"); llc_handle = register_dissector("llc", dissect_llc, proto_llc);