2 * Routines for DVB (ETSI EN 300 468) Network Information Table (NIT) dissection
3 * Copyright 2012, Guy Martin <gmsoft@tuxicoman.be>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include <epan/packet.h>
31 #include <epan/dissectors/packet-mpeg-sect.h>
33 #include "packet-mpeg-descriptor.h"
35 void proto_register_dvb_nit(void);
36 void proto_reg_handoff_dvb_nit(void);
38 static int proto_dvb_nit
= -1;
39 static int hf_dvb_nit_network_id
= -1;
40 static int hf_dvb_nit_reserved1
= -1;
41 static int hf_dvb_nit_version_number
= -1;
42 static int hf_dvb_nit_current_next_indicator
= -1;
43 static int hf_dvb_nit_section_number
= -1;
44 static int hf_dvb_nit_last_section_number
= -1;
45 static int hf_dvb_nit_reserved2
= -1;
47 static int hf_dvb_nit_network_descriptors_length
= -1;
48 static int hf_dvb_nit_reserved3
= -1;
49 static int hf_dvb_nit_transport_stream_loop_length
= -1;
51 static int hf_dvb_nit_transport_stream_id
= -1;
52 static int hf_dvb_nit_original_network_id
= -1;
53 static int hf_dvb_nit_reserved4
= -1;
54 static int hf_dvb_nit_transport_descriptors_length
= -1;
56 static gint ett_dvb_nit
= -1;
57 static gint ett_dvb_nit_ts
= -1;
60 #define DVB_NIT_TID 0x40
61 #define DVB_NIT_TID_OTHER 0x41
63 #define DVB_NIT_RESERVED1_MASK 0xC0
64 #define DVB_NIT_VERSION_NUMBER_MASK 0x3E
65 #define DVB_NIT_CURRENT_NEXT_INDICATOR_MASK 0x01
66 #define DVB_NIT_RESERVED2_MASK 0xF000
67 #define DVB_NIT_NETWORK_DESCRIPTORS_LENGTH_MASK 0x0FFF
68 #define DVB_NIT_RESERVED3_MASK 0xF000
69 #define DVB_NIT_TRANSPORT_STREAM_LOOP_LENGTH_MASK 0x0FFF
70 #define DVB_NIT_RESERVED4_MASK 0xF000
71 #define DVB_NIT_TRANSPORT_DESCRIPTORS_LENGTH_MASK 0x0FFF
73 static const value_string dvb_nit_cur_next_vals
[] = {
74 { 0, "Not yet applicable" },
75 { 1, "Currently applicable" },
82 dissect_dvb_nit(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
86 guint ts_desc_len
, desc_loop_len
, ts_end
;
91 proto_tree
*dvb_nit_tree
;
93 proto_tree
*dvb_nit_ts_tree
;
95 col_set_str(pinfo
->cinfo
, COL_INFO
, "Network Information Table (NIT)");
97 ti
= proto_tree_add_item(tree
, proto_dvb_nit
, tvb
, offset
, -1, ENC_NA
);
98 dvb_nit_tree
= proto_item_add_subtree(ti
, ett_dvb_nit
);
100 offset
+= packet_mpeg_sect_header(tvb
, offset
, dvb_nit_tree
, NULL
, NULL
);
102 proto_tree_add_item(dvb_nit_tree
, hf_dvb_nit_network_id
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
105 proto_tree_add_item(dvb_nit_tree
, hf_dvb_nit_reserved1
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
106 proto_tree_add_item(dvb_nit_tree
, hf_dvb_nit_version_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
107 proto_tree_add_item(dvb_nit_tree
, hf_dvb_nit_current_next_indicator
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
110 proto_tree_add_item(dvb_nit_tree
, hf_dvb_nit_section_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
113 proto_tree_add_item(dvb_nit_tree
, hf_dvb_nit_last_section_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
116 proto_tree_add_item(dvb_nit_tree
, hf_dvb_nit_reserved2
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
117 proto_tree_add_item(dvb_nit_tree
, hf_dvb_nit_network_descriptors_length
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
118 desc_loop_len
= tvb_get_ntohs(tvb
, offset
) & DVB_NIT_NETWORK_DESCRIPTORS_LENGTH_MASK
;
121 offset
+= proto_mpeg_descriptor_loop_dissect(tvb
, offset
, desc_loop_len
, dvb_nit_tree
);
123 proto_tree_add_item(dvb_nit_tree
, hf_dvb_nit_reserved3
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
124 proto_tree_add_item(dvb_nit_tree
, hf_dvb_nit_transport_stream_loop_length
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
125 ts_end
= offset
+ (tvb_get_ntohs(tvb
, offset
) & DVB_NIT_TRANSPORT_STREAM_LOOP_LENGTH_MASK
);
128 while (offset
< ts_end
) {
129 tsid
= tvb_get_ntohs(tvb
, offset
);
130 ts_desc_len
= 3 + (tvb_get_ntohs(tvb
, offset
+ 4) & DVB_NIT_TRANSPORT_DESCRIPTORS_LENGTH_MASK
);
132 tsi
= proto_tree_add_text(dvb_nit_tree
, tvb
, offset
, ts_desc_len
, "Stream ID=0x%04hx", tsid
);
133 dvb_nit_ts_tree
= proto_item_add_subtree(tsi
, ett_dvb_nit_ts
);
135 proto_tree_add_item(dvb_nit_ts_tree
, hf_dvb_nit_transport_stream_id
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
138 proto_tree_add_item(dvb_nit_ts_tree
, hf_dvb_nit_original_network_id
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
141 proto_tree_add_item(dvb_nit_ts_tree
, hf_dvb_nit_reserved4
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
142 proto_tree_add_item(dvb_nit_ts_tree
, hf_dvb_nit_transport_descriptors_length
, tvb
, offset
, 2, ENC_BIG_ENDIAN
);
143 desc_loop_len
= tvb_get_ntohs(tvb
, offset
) & DVB_NIT_TRANSPORT_DESCRIPTORS_LENGTH_MASK
;
146 offset
+= proto_mpeg_descriptor_loop_dissect(tvb
, offset
, desc_loop_len
, dvb_nit_ts_tree
);
149 offset
+= packet_mpeg_sect_crc(tvb
, pinfo
, dvb_nit_tree
, 0, offset
);
151 proto_item_set_len(ti
, offset
);
157 proto_register_dvb_nit(void)
160 static hf_register_info hf
[] = {
162 { &hf_dvb_nit_network_id
, {
163 "Network ID", "dvb_nit.sid",
164 FT_UINT16
, BASE_HEX
, NULL
, 0, NULL
, HFILL
167 { &hf_dvb_nit_reserved1
, {
168 "Reserved", "dvb_nit.reserved1",
169 FT_UINT8
, BASE_HEX
, NULL
, DVB_NIT_RESERVED1_MASK
, NULL
, HFILL
172 { &hf_dvb_nit_version_number
, {
173 "Version Number", "dvb_nit.version",
174 FT_UINT8
, BASE_HEX
, NULL
, DVB_NIT_VERSION_NUMBER_MASK
, NULL
, HFILL
177 { &hf_dvb_nit_current_next_indicator
, {
178 "Current/Next Indicator", "dvb_nit.cur_next_ind",
179 FT_UINT8
, BASE_DEC
, VALS(dvb_nit_cur_next_vals
), DVB_NIT_CURRENT_NEXT_INDICATOR_MASK
, NULL
, HFILL
182 { &hf_dvb_nit_section_number
, {
183 "Section Number", "dvb_nit.sect_num",
184 FT_UINT8
, BASE_DEC
, NULL
, 0, NULL
, HFILL
187 { &hf_dvb_nit_last_section_number
, {
188 "Last Section Number", "dvb_nit.last_sect_num",
189 FT_UINT8
, BASE_DEC
, NULL
, 0, NULL
, HFILL
192 { &hf_dvb_nit_reserved2
, {
193 "Reserved", "dvb_nit.reserved2",
194 FT_UINT16
, BASE_HEX
, NULL
, DVB_NIT_RESERVED2_MASK
, NULL
, HFILL
197 { &hf_dvb_nit_network_descriptors_length
, {
198 "Network Descriptors Length", "dvb_nit.network_desc_len",
199 FT_UINT16
, BASE_DEC
, NULL
, DVB_NIT_NETWORK_DESCRIPTORS_LENGTH_MASK
, NULL
, HFILL
202 { &hf_dvb_nit_reserved3
, {
203 "Reserved", "dvb_nit.reserved3",
204 FT_UINT16
, BASE_HEX
, NULL
, DVB_NIT_RESERVED3_MASK
, NULL
, HFILL
207 { &hf_dvb_nit_transport_stream_loop_length
, {
208 "Transport Stream Loop Length", "dvb_nit.ts_loop_len",
209 FT_UINT16
, BASE_DEC
, NULL
, DVB_NIT_TRANSPORT_STREAM_LOOP_LENGTH_MASK
, NULL
, HFILL
212 { &hf_dvb_nit_transport_stream_id
, {
213 "Transport Stream ID", "dvb_nit.ts.id",
214 FT_UINT16
, BASE_HEX
, NULL
, 0, NULL
, HFILL
217 { &hf_dvb_nit_original_network_id
, {
218 "Original Network ID", "dvb_nit.ts.original_network_id",
219 FT_UINT16
, BASE_HEX
, NULL
, 0, NULL
, HFILL
222 { &hf_dvb_nit_reserved4
, {
223 "Reserved", "dvb_nit.ts.reserved",
224 FT_UINT16
, BASE_HEX
, NULL
, DVB_NIT_RESERVED4_MASK
, NULL
, HFILL
227 { &hf_dvb_nit_transport_descriptors_length
, {
228 "Transport Descriptors Length", "dvb_nit.ts.desc_len",
229 FT_UINT16
, BASE_DEC
, NULL
, DVB_NIT_TRANSPORT_DESCRIPTORS_LENGTH_MASK
, NULL
, HFILL
234 static gint
*ett
[] = {
239 proto_dvb_nit
= proto_register_protocol("DVB Network Information Table", "DVB NIT", "dvb_nit");
241 proto_register_field_array(proto_dvb_nit
, hf
, array_length(hf
));
242 proto_register_subtree_array(ett
, array_length(ett
));
244 new_register_dissector("dvb_nit", dissect_dvb_nit
, proto_dvb_nit
);
248 void proto_reg_handoff_dvb_nit(void)
250 dissector_handle_t dvb_nit_handle
;
252 dvb_nit_handle
= find_dissector("dvb_nit");
254 dissector_add_uint("mpeg_sect.tid", DVB_NIT_TID
, dvb_nit_handle
);
255 dissector_add_uint("mpeg_sect.tid", DVB_NIT_TID_OTHER
, dvb_nit_handle
);
260 * Editor modelines - http://www.wireshark.org/tools/modelines.html
265 * indent-tabs-mode: nil
268 * vi: set shiftwidth=4 tabstop=8 expandtab:
269 * :indentSize=4:tabSize=8:noTabs=true: