2 * Routines for DVB (ETSI EN 300 468) Network Information Table (NIT) dissection
3 * Copyright 2012, Guy Martin <gmsoft@tuxicoman.be>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
14 #include <epan/packet.h>
16 #include "packet-mpeg-sect.h"
17 #include "packet-mpeg-descriptor.h"
19 void proto_register_dvb_nit(void);
20 void proto_reg_handoff_dvb_nit(void);
22 static int proto_dvb_nit
;
23 static int hf_dvb_nit_network_id
;
24 static int hf_dvb_nit_reserved1
;
25 static int hf_dvb_nit_version_number
;
26 static int hf_dvb_nit_current_next_indicator
;
27 static int hf_dvb_nit_section_number
;
28 static int hf_dvb_nit_last_section_number
;
29 static int hf_dvb_nit_reserved2
;
31 static int hf_dvb_nit_network_descriptors_length
;
32 static int hf_dvb_nit_reserved3
;
33 static int hf_dvb_nit_transport_stream_loop_length
;
35 static int hf_dvb_nit_transport_stream_id
;
36 static int hf_dvb_nit_original_network_id
;
37 static int hf_dvb_nit_reserved4
;
38 static int hf_dvb_nit_transport_descriptors_length
;
40 static int ett_dvb_nit
;
41 static int ett_dvb_nit_ts
;
43 static dissector_handle_t dvb_nit_handle
;
45 #define DVB_NIT_RESERVED1_MASK 0xC0
46 #define DVB_NIT_VERSION_NUMBER_MASK 0x3E
47 #define DVB_NIT_CURRENT_NEXT_INDICATOR_MASK 0x01
48 #define DVB_NIT_RESERVED2_MASK 0xF000
49 #define DVB_NIT_NETWORK_DESCRIPTORS_LENGTH_MASK 0x0FFF
50 #define DVB_NIT_RESERVED3_MASK 0xF000
51 #define DVB_NIT_TRANSPORT_STREAM_LOOP_LENGTH_MASK 0x0FFF
52 #define DVB_NIT_RESERVED4_MASK 0xF000
53 #define DVB_NIT_TRANSPORT_DESCRIPTORS_LENGTH_MASK 0x0FFF
56 dissect_dvb_nit(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
60 unsigned ts_desc_len
, desc_loop_len
, ts_end
;
65 proto_tree
*dvb_nit_tree
;
66 proto_tree
*dvb_nit_ts_tree
;
68 col_set_str(pinfo
->cinfo
, COL_INFO
, "Network Information Table (NIT)");
70 ti
= proto_tree_add_item(tree
, proto_dvb_nit
, tvb
, offset
, -1, ENC_NA
);
71 dvb_nit_tree
= proto_item_add_subtree(ti
, ett_dvb_nit
);
73 offset
+= packet_mpeg_sect_header(tvb
, offset
, dvb_nit_tree
, NULL
, NULL
);
75 proto_tree_add_item(dvb_nit_tree
, hf_dvb_nit_network_id
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
78 proto_tree_add_item(dvb_nit_tree
, hf_dvb_nit_reserved1
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
79 proto_tree_add_item(dvb_nit_tree
, hf_dvb_nit_version_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
80 proto_tree_add_item(dvb_nit_tree
, hf_dvb_nit_current_next_indicator
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
83 proto_tree_add_item(dvb_nit_tree
, hf_dvb_nit_section_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
86 proto_tree_add_item(dvb_nit_tree
, hf_dvb_nit_last_section_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
89 proto_tree_add_item(dvb_nit_tree
, hf_dvb_nit_reserved2
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
90 proto_tree_add_item(dvb_nit_tree
, hf_dvb_nit_network_descriptors_length
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
91 desc_loop_len
= tvb_get_ntohs(tvb
, offset
) & DVB_NIT_NETWORK_DESCRIPTORS_LENGTH_MASK
;
94 offset
+= proto_mpeg_descriptor_loop_dissect(tvb
, offset
, desc_loop_len
, dvb_nit_tree
);
96 proto_tree_add_item(dvb_nit_tree
, hf_dvb_nit_reserved3
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
97 proto_tree_add_item(dvb_nit_tree
, hf_dvb_nit_transport_stream_loop_length
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
98 ts_end
= offset
+ (tvb_get_ntohs(tvb
, offset
) & DVB_NIT_TRANSPORT_STREAM_LOOP_LENGTH_MASK
);
101 while (offset
< ts_end
) {
102 tsid
= tvb_get_ntohs(tvb
, offset
);
103 ts_desc_len
= 3 + (tvb_get_ntohs(tvb
, offset
+ 4) & DVB_NIT_TRANSPORT_DESCRIPTORS_LENGTH_MASK
);
105 dvb_nit_ts_tree
= proto_tree_add_subtree_format(dvb_nit_tree
, tvb
, offset
, ts_desc_len
,
106 ett_dvb_nit_ts
, NULL
, "Stream ID=0x%04hx", tsid
);
108 proto_tree_add_item(dvb_nit_ts_tree
, hf_dvb_nit_transport_stream_id
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
111 proto_tree_add_item(dvb_nit_ts_tree
, hf_dvb_nit_original_network_id
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
114 proto_tree_add_item(dvb_nit_ts_tree
, hf_dvb_nit_reserved4
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
115 proto_tree_add_item(dvb_nit_ts_tree
, hf_dvb_nit_transport_descriptors_length
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
116 desc_loop_len
= tvb_get_ntohs(tvb
, offset
) & DVB_NIT_TRANSPORT_DESCRIPTORS_LENGTH_MASK
;
119 offset
+= proto_mpeg_descriptor_loop_dissect(tvb
, offset
, desc_loop_len
, dvb_nit_ts_tree
);
122 offset
+= packet_mpeg_sect_crc(tvb
, pinfo
, dvb_nit_tree
, 0, offset
);
124 proto_item_set_len(ti
, offset
);
130 proto_register_dvb_nit(void)
133 static hf_register_info hf
[] = {
135 { &hf_dvb_nit_network_id
, {
136 "Network ID", "dvb_nit.sid",
137 FT_UINT16
, BASE_HEX
, NULL
, 0, NULL
, HFILL
140 { &hf_dvb_nit_reserved1
, {
141 "Reserved", "dvb_nit.reserved1",
142 FT_UINT8
, BASE_HEX
, NULL
, DVB_NIT_RESERVED1_MASK
, NULL
, HFILL
145 { &hf_dvb_nit_version_number
, {
146 "Version Number", "dvb_nit.version",
147 FT_UINT8
, BASE_HEX
, NULL
, DVB_NIT_VERSION_NUMBER_MASK
, NULL
, HFILL
150 { &hf_dvb_nit_current_next_indicator
, {
151 "Current/Next Indicator", "dvb_nit.cur_next_ind",
152 FT_BOOLEAN
, 8, TFS(&tfs_current_not_yet
), DVB_NIT_CURRENT_NEXT_INDICATOR_MASK
, NULL
, HFILL
155 { &hf_dvb_nit_section_number
, {
156 "Section Number", "dvb_nit.sect_num",
157 FT_UINT8
, BASE_DEC
, NULL
, 0, NULL
, HFILL
160 { &hf_dvb_nit_last_section_number
, {
161 "Last Section Number", "dvb_nit.last_sect_num",
162 FT_UINT8
, BASE_DEC
, NULL
, 0, NULL
, HFILL
165 { &hf_dvb_nit_reserved2
, {
166 "Reserved", "dvb_nit.reserved2",
167 FT_UINT16
, BASE_HEX
, NULL
, DVB_NIT_RESERVED2_MASK
, NULL
, HFILL
170 { &hf_dvb_nit_network_descriptors_length
, {
171 "Network Descriptors Length", "dvb_nit.network_desc_len",
172 FT_UINT16
, BASE_DEC
, NULL
, DVB_NIT_NETWORK_DESCRIPTORS_LENGTH_MASK
, NULL
, HFILL
175 { &hf_dvb_nit_reserved3
, {
176 "Reserved", "dvb_nit.reserved3",
177 FT_UINT16
, BASE_HEX
, NULL
, DVB_NIT_RESERVED3_MASK
, NULL
, HFILL
180 { &hf_dvb_nit_transport_stream_loop_length
, {
181 "Transport Stream Loop Length", "dvb_nit.ts_loop_len",
182 FT_UINT16
, BASE_DEC
, NULL
, DVB_NIT_TRANSPORT_STREAM_LOOP_LENGTH_MASK
, NULL
, HFILL
185 { &hf_dvb_nit_transport_stream_id
, {
186 "Transport Stream ID", "dvb_nit.ts.id",
187 FT_UINT16
, BASE_HEX
, NULL
, 0, NULL
, HFILL
190 { &hf_dvb_nit_original_network_id
, {
191 "Original Network ID", "dvb_nit.ts.original_network_id",
192 FT_UINT16
, BASE_HEX
, NULL
, 0, NULL
, HFILL
195 { &hf_dvb_nit_reserved4
, {
196 "Reserved", "dvb_nit.ts.reserved",
197 FT_UINT16
, BASE_HEX
, NULL
, DVB_NIT_RESERVED4_MASK
, NULL
, HFILL
200 { &hf_dvb_nit_transport_descriptors_length
, {
201 "Transport Descriptors Length", "dvb_nit.ts.desc_len",
202 FT_UINT16
, BASE_DEC
, NULL
, DVB_NIT_TRANSPORT_DESCRIPTORS_LENGTH_MASK
, NULL
, HFILL
207 static int *ett
[] = {
212 proto_dvb_nit
= proto_register_protocol("DVB Network Information Table", "DVB NIT", "dvb_nit");
214 proto_register_field_array(proto_dvb_nit
, hf
, array_length(hf
));
215 proto_register_subtree_array(ett
, array_length(ett
));
217 dvb_nit_handle
= register_dissector("dvb_nit", dissect_dvb_nit
, proto_dvb_nit
);
221 void proto_reg_handoff_dvb_nit(void)
223 dissector_add_uint("mpeg_sect.tid", DVB_NIT_TID
, dvb_nit_handle
);
224 dissector_add_uint("mpeg_sect.tid", DVB_NIT_TID_OTHER
, dvb_nit_handle
);
229 * Editor modelines - https://www.wireshark.org/tools/modelines.html
234 * indent-tabs-mode: nil
237 * vi: set shiftwidth=4 tabstop=8 expandtab:
238 * :indentSize=4:tabSize=8:noTabs=true: