2 * EGNOS Message Server file format dissection.
4 * By Timo Warns <timo.warns@gmail.com>
5 * Copyright 2023 Timo Warns
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@unicom.net>
9 * Copyright 1998 Gerald Combs
11 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include <epan/packet.h>
16 #include <wiretap/wtap.h>
19 * Dissects PCAPs mapped from the EMS file format as defined by the "EGNOS
20 * Messager Server User Interface Document" (E-RD-SYS-E31-011-ESA, Issue 2)
23 /* Initialize the protocol and registered fields */
26 static int hf_ems_prn
;
27 static int hf_ems_year
;
28 static int hf_ems_month
;
29 static int hf_ems_day
;
30 static int hf_ems_hour
;
31 static int hf_ems_minute
;
32 static int hf_ems_second
;
37 static dissector_handle_t ems_handle
;
39 /* Dissect EMS data record */
40 static int dissect_ems(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
) {
43 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "EMS");
44 col_clear(pinfo
->cinfo
, COL_INFO
);
46 uint8_t prn
, year
, month
, day
, hour
, minute
, second
, mt
;
47 prn
= tvb_get_uint8(tvb
, 0);
48 year
= tvb_get_uint8(tvb
, 1);
49 month
= tvb_get_uint8(tvb
, 2);
50 day
= tvb_get_uint8(tvb
, 3);
51 hour
= tvb_get_uint8(tvb
, 4);
52 minute
= tvb_get_uint8(tvb
, 5);
53 second
= tvb_get_uint8(tvb
, 6);
54 mt
= tvb_get_uint8(tvb
, 7);
56 proto_tree
*ems_tree
= proto_tree_add_subtree_format(tree
, tvb
, 0, 40,
57 ett_ems
, NULL
, "EMS (%04d-%02d-%02d %02d:%02d:%02d PRN%d MT%d)",
58 2000 + year
, month
, day
, hour
, minute
, second
, prn
, mt
);
60 proto_tree_add_item(ems_tree
, hf_ems_prn
, tvb
, 0, 1, ENC_BIG_ENDIAN
);
61 proto_tree_add_item(ems_tree
, hf_ems_year
, tvb
, 1, 1, ENC_BIG_ENDIAN
);
62 proto_tree_add_item(ems_tree
, hf_ems_month
, tvb
, 2, 1, ENC_BIG_ENDIAN
);
63 proto_tree_add_item(ems_tree
, hf_ems_day
, tvb
, 3, 1, ENC_BIG_ENDIAN
);
64 proto_tree_add_item(ems_tree
, hf_ems_hour
, tvb
, 4, 1, ENC_BIG_ENDIAN
);
65 proto_tree_add_item(ems_tree
, hf_ems_minute
, tvb
, 5, 1, ENC_BIG_ENDIAN
);
66 proto_tree_add_item(ems_tree
, hf_ems_second
, tvb
, 6, 1, ENC_BIG_ENDIAN
);
67 proto_tree_add_item(ems_tree
, hf_ems_mt
, tvb
, 7, 1, ENC_BIG_ENDIAN
);
69 next_tvb
= tvb_new_subset_remaining(tvb
, 8);
71 dissector_handle_t sbas_l1_dissector_handle
= find_dissector("sbas_l1");
72 if (sbas_l1_dissector_handle
) {
73 call_dissector(sbas_l1_dissector_handle
, next_tvb
, pinfo
, tree
);
76 call_data_dissector(next_tvb
, pinfo
, tree
);
79 return tvb_captured_length(tvb
);
82 void proto_register_ems(void) {
84 static hf_register_info hf
[] = {
85 {&hf_ems_prn
, {"PRN", "ems.prn", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
86 {&hf_ems_year
, {"Year", "ems.year", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
87 {&hf_ems_month
, {"Month", "ems.month", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
88 {&hf_ems_day
, {"Day", "ems.day", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
89 {&hf_ems_hour
, {"Hour", "ems.hour", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
90 {&hf_ems_minute
, {"Minute", "ems.minute", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
91 {&hf_ems_second
, {"Second", "ems.second", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
92 {&hf_ems_mt
, {"Message Type", "ems.mt", FT_UINT8
, BASE_DEC
, NULL
, 0x0, NULL
, HFILL
}},
99 proto_ems
= proto_register_protocol("EGNOS Message Server file", "EMS", "ems");
100 ems_handle
= register_dissector("ems", dissect_ems
, proto_ems
);
102 proto_register_field_array(proto_ems
, hf
, array_length(hf
));
103 proto_register_subtree_array(ett
, array_length(ett
));
106 void proto_reg_handoff_ems(void) {
107 static bool initialized
= false;
110 dissector_add_uint("wtap_encap", WTAP_ENCAP_EMS
, ems_handle
);