From ad6947eb713c5b282e819a955e9e8c97250bcb72 Mon Sep 17 00:00:00 2001 From: Timo Warns Date: Tue, 9 May 2023 17:38:12 +0200 Subject: [PATCH] GNSS: add dissector for EGNOS Message Server (EMS) files Add dissector for EGNOS Message Server (EMS) files including entries with EGNOS SBAS navigation messages. --- doc/release-notes.adoc | 1 + epan/dissectors/CMakeLists.txt | 1 + epan/dissectors/packet-egnos-ems.c | 101 +++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+) create mode 100644 epan/dissectors/packet-egnos-ems.c diff --git a/doc/release-notes.adoc b/doc/release-notes.adoc index d1caa95eae..6f216ad8a0 100644 --- a/doc/release-notes.adoc +++ b/doc/release-notes.adoc @@ -109,6 +109,7 @@ The following features are new (or have been significantly updated) since versio MAC NR Framed (mac-nr-framed) RF4CE Network Layer (RF4CE) RF4CE Profile (RF4CE Profile) +EGNOS Message Server (EMS) file format -- === Updated Protocol Support diff --git a/epan/dissectors/CMakeLists.txt b/epan/dissectors/CMakeLists.txt index bf046ea518..259371e9cc 100644 --- a/epan/dissectors/CMakeLists.txt +++ b/epan/dissectors/CMakeLists.txt @@ -1075,6 +1075,7 @@ set(DISSECTOR_SRC ${CMAKE_CURRENT_SOURCE_DIR}/packet-edonkey.c ${CMAKE_CURRENT_SOURCE_DIR}/packet-egd.c ${CMAKE_CURRENT_SOURCE_DIR}/packet-eero.c + ${CMAKE_CURRENT_SOURCE_DIR}/packet-egnos-ems.c ${CMAKE_CURRENT_SOURCE_DIR}/packet-ehdlc.c ${CMAKE_CURRENT_SOURCE_DIR}/packet-ehs.c ${CMAKE_CURRENT_SOURCE_DIR}/packet-eigrp.c diff --git a/epan/dissectors/packet-egnos-ems.c b/epan/dissectors/packet-egnos-ems.c new file mode 100644 index 0000000000..f347620414 --- /dev/null +++ b/epan/dissectors/packet-egnos-ems.c @@ -0,0 +1,101 @@ +/* packet-ems.c + * EGNOS Message Server file format dissection. + * + * By Timo Warns + * Copyright 2023 Timo Warns + * + * Wireshark - Network traffic analyzer + * By Gerald Combs + * Copyright 1998 Gerald Combs + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "config.h" +#include +#include + +/* + * Dissects PCAPs mapped from the EMS file format as defined by the "EGNOS + * Messager Server User Interface Document" (E-RD-SYS-E31-011-ESA, Issue 2) + */ + +/* Initialize the protocol and registered fields */ +static int proto_ems = -1; + +static int hf_ems_prn = -1; +static int hf_ems_year = -1; +static int hf_ems_month = -1; +static int hf_ems_day = -1; +static int hf_ems_hour = -1; +static int hf_ems_minute = -1; +static int hf_ems_second = -1; +static int hf_ems_mt = -1; + +static int ett_ems = -1; + +static dissector_handle_t ems_handle; + +/* Dissect EMS data record */ +static int dissect_ems(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_) { + tvbuff_t *next_tvb; + + col_set_str(pinfo->cinfo, COL_PROTOCOL, "EMS"); + col_clear(pinfo->cinfo, COL_INFO); + + proto_item *ti = proto_tree_add_item(tree, proto_ems, tvb, 0, 40, ENC_NA); + proto_tree *ems_tree = proto_item_add_subtree(ti, ett_ems); + + proto_tree_add_item(ems_tree, hf_ems_prn, tvb, 0, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(ems_tree, hf_ems_year, tvb, 1, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(ems_tree, hf_ems_month, tvb, 2, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(ems_tree, hf_ems_day, tvb, 3, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(ems_tree, hf_ems_hour, tvb, 4, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(ems_tree, hf_ems_minute, tvb, 5, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(ems_tree, hf_ems_second, tvb, 6, 1, ENC_BIG_ENDIAN); + proto_tree_add_item(ems_tree, hf_ems_mt, tvb, 7, 1, ENC_BIG_ENDIAN); + + next_tvb = tvb_new_subset_remaining(tvb, 8); + + dissector_handle_t sbas_l1_dissector_handle = find_dissector("sbas_l1"); + if (sbas_l1_dissector_handle) { + call_dissector(sbas_l1_dissector_handle, next_tvb, pinfo, tree); + } + else { + call_data_dissector(next_tvb, pinfo, tree); + } + + return tvb_captured_length(tvb); +} + +void proto_register_ems(void) { + + static hf_register_info hf[] = { + {&hf_ems_prn, {"PRN", "ems.prn", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + {&hf_ems_year, {"Year", "ems.year", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + {&hf_ems_month, {"Month", "ems.month", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + {&hf_ems_day, {"Day", "ems.day", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + {&hf_ems_hour, {"Hour", "ems.hour", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + {&hf_ems_minute, {"Minute", "ems.minute", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + {&hf_ems_second, {"Second", "ems.second", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + {&hf_ems_mt, {"Message Type", "ems.mt", FT_UINT8, BASE_DEC, NULL, 0x0, NULL, HFILL }}, + }; + + static gint *ett[] = { + &ett_ems, + }; + + proto_ems = proto_register_protocol("EGNOS Message Server file", "EMS", "ems"); + ems_handle = register_dissector("ems", dissect_ems, proto_ems); + + proto_register_field_array(proto_ems, hf, array_length(hf)); + proto_register_subtree_array(ett, array_length(ett)); +} + +void proto_reg_handoff_ems(void) { + static gboolean initialized = FALSE; + + if (!initialized) { + dissector_add_uint("wtap_encap", WTAP_ENCAP_EMS, ems_handle); + } +}