1 /* packet-dvb-data-mpe.c
2 * Routines for DVB-DATA (ETSI EN 301 192) MultiProtocol Encapsulation
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/to_str.h>
32 #include <epan/dissectors/packet-mpeg-sect.h>
34 void proto_register_dvb_data_mpe(void);
35 void proto_reg_handoff_dvb_data_mpe(void);
37 static int proto_dvb_data_mpe
= -1;
38 static int hf_dvb_data_mpe_reserved
= -1;
39 static int hf_dvb_data_mpe_payload_scrambling_control
= -1;
40 static int hf_dvb_data_mpe_address_scrambling_control
= -1;
41 static int hf_dvb_data_mpe_llc_snap_flag
= -1;
42 static int hf_dvb_data_mpe_current_next_indicator
= -1;
43 static int hf_dvb_data_mpe_section_number
= -1;
44 static int hf_dvb_data_mpe_last_section_number
= -1;
45 static int hf_dvb_data_mpe_dst_mac
= -1;
47 static gint ett_dvb_data_mpe
= -1;
49 static dissector_handle_t ip_handle
;
50 static dissector_handle_t llc_handle
;
52 #define DVB_DATA_MPE_TID 0x3E
55 #define DVB_DATA_MPE_RESERVED_MASK 0xC0
56 #define DVB_DATA_MPE_PAYLOAD_SCRAMBLING_MASK 0x30
57 #define DVB_DATA_MPE_ADDRESS_SCRAMBLING_MASK 0x0C
58 #define DVB_DATA_MPE_LLC_SNAP_FLAG_MASK 0x02
59 #define DVB_DATA_MPE_CURRENT_NEXT_INDICATOR_MASK 0x01
61 static const value_string dvb_rcs_cur_next_vals
[] = {
63 { 0x0, "Not yet applicable" },
64 { 0x1, "Currently applicable" },
71 dissect_dvb_data_mpe(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
74 guint offset
= 0, tot_len
= 0;
79 proto_tree
*dvb_data_mpe_tree
;
81 tvbuff_t
*mac_bytes_tvb
[6];
84 /* The TVB should start right after the section_length in the Section packet */
86 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "DVB-DATA");
87 col_set_str(pinfo
->cinfo
, COL_INFO
, "MultiProtocol Encapsulation");
89 ti
= proto_tree_add_item(tree
, proto_dvb_data_mpe
, tvb
, offset
, -1, ENC_NA
);
90 dvb_data_mpe_tree
= proto_item_add_subtree(ti
, ett_dvb_data_mpe
);
92 offset
+= packet_mpeg_sect_header(tvb
, offset
, dvb_data_mpe_tree
, &tot_len
, NULL
);
95 /* Parse the DMC-CC private section header */
97 mac_bytes_tvb
[5] = tvb_new_subset(tvb
, offset
, 1, 1);
99 mac_bytes_tvb
[4] = tvb_new_subset(tvb
, offset
, 1, 1);
102 proto_tree_add_item(dvb_data_mpe_tree
, hf_dvb_data_mpe_reserved
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
103 proto_tree_add_item(dvb_data_mpe_tree
, hf_dvb_data_mpe_payload_scrambling_control
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
104 proto_tree_add_item(dvb_data_mpe_tree
, hf_dvb_data_mpe_address_scrambling_control
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
105 proto_tree_add_item(dvb_data_mpe_tree
, hf_dvb_data_mpe_llc_snap_flag
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
106 proto_tree_add_item(dvb_data_mpe_tree
, hf_dvb_data_mpe_current_next_indicator
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
107 llc_snap_flag
= tvb_get_guint8(tvb
, offset
) & DVB_DATA_MPE_LLC_SNAP_FLAG_MASK
;
110 proto_tree_add_item(dvb_data_mpe_tree
, hf_dvb_data_mpe_section_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
113 proto_tree_add_item(dvb_data_mpe_tree
, hf_dvb_data_mpe_last_section_number
, tvb
, offset
, 1, ENC_BIG_ENDIAN
);
116 for (i
= 3; i
>= 0; i
--) {
117 mac_bytes_tvb
[i
] = tvb_new_subset(tvb
, offset
, 1, 1);
121 mac_tvb
= tvb_new_composite();
123 for (i
= 0; i
< 6; i
++)
124 tvb_composite_append(mac_tvb
, mac_bytes_tvb
[i
]);
126 tvb_composite_finalize(mac_tvb
);
128 proto_tree_add_item(dvb_data_mpe_tree
, hf_dvb_data_mpe_dst_mac
, mac_tvb
, 0 , 6, ENC_NA
);
129 col_add_str(pinfo
->cinfo
, COL_RES_DL_DST
, tvb_ether_to_str(mac_tvb
, 0));
131 data_tvb
= tvb_new_subset_remaining(tvb
, offset
);
134 call_dissector(llc_handle
, data_tvb
, pinfo
, tree
);
136 call_dissector(ip_handle
, data_tvb
, pinfo
, tree
);
139 packet_mpeg_sect_crc(tvb
, pinfo
, dvb_data_mpe_tree
, 0, tot_len
- 1);
145 proto_register_dvb_data_mpe(void)
148 static hf_register_info hf
[] = {
150 /* DSM-CC common fields */
151 { &hf_dvb_data_mpe_reserved
, {
152 "Reserved", "dvb_data_mpe.reserved",
153 FT_UINT8
, BASE_HEX
, NULL
, DVB_DATA_MPE_RESERVED_MASK
, NULL
, HFILL
156 { &hf_dvb_data_mpe_payload_scrambling_control
, {
157 "Payload Scrambling Control", "dvb_data_mpe.pload_scrambling",
158 FT_UINT8
, BASE_HEX
, NULL
, DVB_DATA_MPE_PAYLOAD_SCRAMBLING_MASK
, NULL
, HFILL
161 { &hf_dvb_data_mpe_address_scrambling_control
, {
162 "Address Scrambling Control", "dvb_data_mpe.addr_scrambling",
163 FT_UINT8
, BASE_HEX
, NULL
, DVB_DATA_MPE_ADDRESS_SCRAMBLING_MASK
, NULL
, HFILL
166 { &hf_dvb_data_mpe_llc_snap_flag
, {
167 "LLC SNAP Flag", "dvb_data_mpe.llc_snap_flag",
168 FT_UINT8
, BASE_HEX
, NULL
, DVB_DATA_MPE_LLC_SNAP_FLAG_MASK
, NULL
, HFILL
171 { &hf_dvb_data_mpe_current_next_indicator
, {
172 "Current/Next Indicator", "mpeg_sect.cur_next_ind",
173 FT_UINT8
, BASE_HEX
, VALS(dvb_rcs_cur_next_vals
), DVB_DATA_MPE_CURRENT_NEXT_INDICATOR_MASK
, NULL
, HFILL
176 { &hf_dvb_data_mpe_section_number
, {
177 "Section Number", "dvb_data_mpe.sect_num",
178 FT_UINT8
, BASE_DEC
, NULL
, 0, NULL
, HFILL
181 { &hf_dvb_data_mpe_last_section_number
, {
182 "Last Section Number", "dvb_data_mpe.last_sect_num",
183 FT_UINT8
, BASE_DEC
, NULL
, 0, NULL
, HFILL
186 { &hf_dvb_data_mpe_dst_mac
, {
187 "Destination MAC address", "dvb_data_mpe.dst_mac",
188 FT_BYTES
, BASE_NONE
, NULL
, 0, NULL
, HFILL
194 static gint
*ett
[] = {
198 proto_dvb_data_mpe
= proto_register_protocol("DVB-DATA MultiProtocol Encapsulation", "DVB-DATA MPE", "dvb_data_mpe");
199 proto_register_field_array(proto_dvb_data_mpe
, hf
, array_length(hf
));
201 proto_register_subtree_array(ett
, array_length(ett
));
207 proto_reg_handoff_dvb_data_mpe(void)
210 dissector_handle_t dvb_data_mpe_handle
;
212 dvb_data_mpe_handle
= create_dissector_handle(dissect_dvb_data_mpe
, proto_dvb_data_mpe
);
213 dissector_add_uint("mpeg_sect.tid", DVB_DATA_MPE_TID
, dvb_data_mpe_handle
);
215 ip_handle
= find_dissector("ip");
216 llc_handle
= find_dissector("llc");
221 * Editor modelines - http://www.wireshark.org/tools/modelines.html
226 * indent-tabs-mode: nil
229 * vi: set shiftwidth=4 tabstop=8 expandtab:
230 * :indentSize=4:tabSize=8:noTabs=true: