1 /* Do not modify this file. */
2 /* It is created automatically by the ASN.1 to Wireshark dissector compiler */
4 /* ../../tools/asn2wrs.py -b -e -p cdt -c cdt.cnf -s packet-cdt-template cdt.asn */
6 /* Input file: packet-cdt-template.c */
8 #line 1 "packet-cdt-template.c"
11 * Routines for Compressed Data Type packet dissection.
13 * Copyright 2005, Stig Bj>rlykke <stig@bjorlykke.org>, Thales Norway AS
17 * Wireshark - Network traffic analyzer
18 * By Gerald Combs <gerald@wireshark.org>
19 * Copyright 1998 Gerald Combs
21 * This program is free software; you can redistribute it and/or
22 * modify it under the terms of the GNU General Public License
23 * as published by the Free Software Foundation; either version 2
24 * of the License, or (at your option) any later version.
26 * This program is distributed in the hope that it will be useful,
27 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 * GNU General Public License for more details.
31 * You should have received a copy of the GNU General Public License
32 * along with this program; if not, write to the Free Software
33 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
35 * Ref: STANAG 4406 Annex E
42 #include <epan/packet.h>
44 #include "packet-ber.h"
45 #include "packet-x411.h"
47 #define PNAME "Compressed Data Type"
51 static proto_tree *top_tree = NULL;
52 static proto_item *cdt_item = NULL;
54 /* Initialize the protocol and registered fields */
57 /*--- Included file: packet-cdt-hf.c ---*/
58 #line 1 "packet-cdt-hf.c"
59 static int hf_cdt_CompressedData_PDU = -1; /* CompressedData */
60 static int hf_cdt_compressionAlgorithm = -1; /* CompressionAlgorithmIdentifier */
61 static int hf_cdt_compressedContentInfo = -1; /* CompressedContentInfo */
62 static int hf_cdt_algorithmID_ShortForm = -1; /* AlgorithmID_ShortForm */
63 static int hf_cdt_algorithmID_OID = -1; /* OBJECT_IDENTIFIER */
64 static int hf_cdt_contentType = -1; /* T_contentType */
65 static int hf_cdt_contentType_ShortForm = -1; /* ContentType_ShortForm */
66 static int hf_cdt_contentType_OID = -1; /* OBJECT_IDENTIFIER */
67 static int hf_cdt_compressedContent = -1; /* CompressedContent */
69 /*--- End of included file: packet-cdt-hf.c ---*/
70 #line 49 "packet-cdt-template.c"
72 /* Initialize the subtree pointers */
74 /*--- Included file: packet-cdt-ett.c ---*/
75 #line 1 "packet-cdt-ett.c"
76 static gint ett_cdt_CompressedData = -1;
77 static gint ett_cdt_CompressionAlgorithmIdentifier = -1;
78 static gint ett_cdt_CompressedContentInfo = -1;
79 static gint ett_cdt_T_contentType = -1;
81 /*--- End of included file: packet-cdt-ett.c ---*/
82 #line 52 "packet-cdt-template.c"
85 /*--- Included file: packet-cdt-fn.c ---*/
86 #line 1 "packet-cdt-fn.c"
87 /*--- Fields for imported types ---*/
91 static const value_string cdt_AlgorithmID_ShortForm_vals[] = {
92 { 0, "zlibCompress" },
98 dissect_cdt_AlgorithmID_ShortForm(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
102 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
105 proto_item_append_text (cdt_item, ", %s",
106 val_to_str (value, cdt_AlgorithmID_ShortForm_vals,
109 if (check_col (pinfo->cinfo, COL_INFO))
110 col_append_fstr (pinfo->cinfo, COL_INFO, "%s ",
111 val_to_str (value, cdt_AlgorithmID_ShortForm_vals,
118 static int dissect_algorithmID_ShortForm_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
119 return dissect_cdt_AlgorithmID_ShortForm(TRUE, tvb, offset, pinfo, tree, hf_cdt_algorithmID_ShortForm);
125 dissect_cdt_OBJECT_IDENTIFIER(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
127 const char *obj_id = NULL;
129 offset = dissect_ber_object_identifier_str(implicit_tag, pinfo, tree, tvb, offset, hf_index, &obj_id);
132 const char *name = get_oid_str_name (obj_id);
138 proto_item_append_text (cdt_item, ", %s", name);
140 if (check_col (pinfo->cinfo, COL_INFO))
141 col_append_fstr (pinfo->cinfo, COL_INFO, "%s ", name);
148 static int dissect_algorithmID_OID_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
149 return dissect_cdt_OBJECT_IDENTIFIER(TRUE, tvb, offset, pinfo, tree, hf_cdt_algorithmID_OID);
151 static int dissect_contentType_OID_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
152 return dissect_cdt_OBJECT_IDENTIFIER(TRUE, tvb, offset, pinfo, tree, hf_cdt_contentType_OID);
156 static const value_string cdt_CompressionAlgorithmIdentifier_vals[] = {
157 { 0, "algorithmID-ShortForm" },
158 { 1, "algorithmID-OID" },
162 static const ber_choice_t CompressionAlgorithmIdentifier_choice[] = {
163 { 0, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_algorithmID_ShortForm_impl },
164 { 1, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_algorithmID_OID_impl },
169 dissect_cdt_CompressionAlgorithmIdentifier(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
170 offset = dissect_ber_choice(pinfo, tree, tvb, offset,
171 CompressionAlgorithmIdentifier_choice, hf_index, ett_cdt_CompressionAlgorithmIdentifier,
176 static int dissect_compressionAlgorithm(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
177 return dissect_cdt_CompressionAlgorithmIdentifier(FALSE, tvb, offset, pinfo, tree, hf_cdt_compressionAlgorithm);
181 static const value_string cdt_ContentType_ShortForm_vals[] = {
182 { 0, "unidentified" },
192 dissect_cdt_ContentType_ShortForm(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
196 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
199 proto_item_append_text (cdt_item, ", %s",
200 val_to_str (value, cdt_ContentType_ShortForm_vals,
203 if (check_col (pinfo->cinfo, COL_INFO))
204 col_append_fstr (pinfo->cinfo, COL_INFO, "%s ",
205 val_to_str (value, cdt_ContentType_ShortForm_vals,
212 static int dissect_contentType_ShortForm_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
213 return dissect_cdt_ContentType_ShortForm(TRUE, tvb, offset, pinfo, tree, hf_cdt_contentType_ShortForm);
217 static const value_string cdt_T_contentType_vals[] = {
218 { 0, "contentType-ShortForm" },
219 { 1, "contentType-OID" },
223 static const ber_choice_t T_contentType_choice[] = {
224 { 0, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_contentType_ShortForm_impl },
225 { 1, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_contentType_OID_impl },
230 dissect_cdt_T_contentType(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
231 offset = dissect_ber_choice(pinfo, tree, tvb, offset,
232 T_contentType_choice, hf_index, ett_cdt_T_contentType,
237 static int dissect_contentType(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
238 return dissect_cdt_T_contentType(FALSE, tvb, offset, pinfo, tree, hf_cdt_contentType);
244 dissect_cdt_CompressedContent(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
246 tvbuff_t *next_tvb = NULL, *compr_tvb = NULL;
247 int save_offset = offset;
249 offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
252 if (compr_tvb == NULL) {
253 proto_tree_add_text (top_tree, tvb, save_offset, -1,
254 "[Error: Unable to get compressed content]");
255 if (check_col (pinfo->cinfo, COL_INFO))
256 col_append_fstr (pinfo->cinfo, COL_INFO,
257 "[Error: Unable to get compressed content]");
261 next_tvb = tvb_uncompress (compr_tvb, 0, tvb_length (compr_tvb));
263 if (next_tvb == NULL) {
264 proto_tree_add_text (top_tree, tvb, save_offset, -1,
265 "[Error: Unable to uncompress content]");
266 if (check_col (pinfo->cinfo, COL_INFO))
267 col_append_fstr (pinfo->cinfo, COL_INFO,
268 "[Error: Unable to uncompress content]");
272 tvb_set_child_real_data_tvbuff (tvb, next_tvb);
273 add_new_data_source (pinfo, next_tvb, "Uncompressed Content");
275 dissect_x411_mts_apdu (next_tvb, pinfo, top_tree);
281 static int dissect_compressedContent(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
282 return dissect_cdt_CompressedContent(FALSE, tvb, offset, pinfo, tree, hf_cdt_compressedContent);
286 static const ber_sequence_t CompressedContentInfo_sequence[] = {
287 { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_contentType },
288 { BER_CLASS_CON, 0, 0, dissect_compressedContent },
293 dissect_cdt_CompressedContentInfo(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
294 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
295 CompressedContentInfo_sequence, hf_index, ett_cdt_CompressedContentInfo);
299 static int dissect_compressedContentInfo(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
300 return dissect_cdt_CompressedContentInfo(FALSE, tvb, offset, pinfo, tree, hf_cdt_compressedContentInfo);
304 static const ber_sequence_t CompressedData_sequence[] = {
305 { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_compressionAlgorithm },
306 { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_compressedContentInfo },
311 dissect_cdt_CompressedData(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
312 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
313 CompressedData_sequence, hf_index, ett_cdt_CompressedData);
320 static void dissect_CompressedData_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
321 dissect_cdt_CompressedData(FALSE, tvb, 0, pinfo, tree, hf_cdt_CompressedData_PDU);
325 /*--- End of included file: packet-cdt-fn.c ---*/
326 #line 54 "packet-cdt-template.c"
329 /*--- proto_register_cdt -------------------------------------------*/
332 ** Dissect Compressed Data Type
334 void dissect_cdt (tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
336 proto_tree *tree = NULL;
338 /* save parent_tree so subdissectors can create new top nodes */
339 top_tree = parent_tree;
342 cdt_item = proto_tree_add_item (parent_tree, proto_cdt, tvb, 0, -1, FALSE);
343 tree = proto_item_add_subtree (cdt_item, ett_cdt_CompressedData);
346 if (check_col (pinfo->cinfo, COL_PROTOCOL))
347 col_set_str (pinfo->cinfo, COL_PROTOCOL, "CDT");
348 if (check_col (pinfo->cinfo, COL_INFO))
349 col_clear (pinfo->cinfo, COL_INFO);
351 dissect_CompressedData_PDU (tvb, pinfo, tree);
354 void proto_register_cdt (void) {
357 static hf_register_info hf[] = {
359 /*--- Included file: packet-cdt-hfarr.c ---*/
360 #line 1 "packet-cdt-hfarr.c"
361 { &hf_cdt_CompressedData_PDU,
362 { "CompressedData", "cdt.CompressedData",
363 FT_NONE, BASE_NONE, NULL, 0,
364 "CompressedData", HFILL }},
365 { &hf_cdt_compressionAlgorithm,
366 { "compressionAlgorithm", "cdt.compressionAlgorithm",
367 FT_UINT32, BASE_DEC, VALS(cdt_CompressionAlgorithmIdentifier_vals), 0,
368 "CompressedData/compressionAlgorithm", HFILL }},
369 { &hf_cdt_compressedContentInfo,
370 { "compressedContentInfo", "cdt.compressedContentInfo",
371 FT_NONE, BASE_NONE, NULL, 0,
372 "CompressedData/compressedContentInfo", HFILL }},
373 { &hf_cdt_algorithmID_ShortForm,
374 { "algorithmID-ShortForm", "cdt.algorithmID_ShortForm",
375 FT_INT32, BASE_DEC, VALS(cdt_AlgorithmID_ShortForm_vals), 0,
376 "CompressionAlgorithmIdentifier/algorithmID-ShortForm", HFILL }},
377 { &hf_cdt_algorithmID_OID,
378 { "algorithmID-OID", "cdt.algorithmID_OID",
379 FT_OID, BASE_NONE, NULL, 0,
380 "CompressionAlgorithmIdentifier/algorithmID-OID", HFILL }},
381 { &hf_cdt_contentType,
382 { "contentType", "cdt.contentType",
383 FT_UINT32, BASE_DEC, VALS(cdt_T_contentType_vals), 0,
384 "CompressedContentInfo/contentType", HFILL }},
385 { &hf_cdt_contentType_ShortForm,
386 { "contentType-ShortForm", "cdt.contentType_ShortForm",
387 FT_INT32, BASE_DEC, VALS(cdt_ContentType_ShortForm_vals), 0,
388 "CompressedContentInfo/contentType/contentType-ShortForm", HFILL }},
389 { &hf_cdt_contentType_OID,
390 { "contentType-OID", "cdt.contentType_OID",
391 FT_OID, BASE_NONE, NULL, 0,
392 "CompressedContentInfo/contentType/contentType-OID", HFILL }},
393 { &hf_cdt_compressedContent,
394 { "compressedContent", "cdt.compressedContent",
395 FT_BYTES, BASE_HEX, NULL, 0,
396 "CompressedContentInfo/compressedContent", HFILL }},
398 /*--- End of included file: packet-cdt-hfarr.c ---*/
399 #line 86 "packet-cdt-template.c"
402 /* List of subtrees */
403 static gint *ett[] = {
405 /*--- Included file: packet-cdt-ettarr.c ---*/
406 #line 1 "packet-cdt-ettarr.c"
407 &ett_cdt_CompressedData,
408 &ett_cdt_CompressionAlgorithmIdentifier,
409 &ett_cdt_CompressedContentInfo,
410 &ett_cdt_T_contentType,
412 /*--- End of included file: packet-cdt-ettarr.c ---*/
413 #line 91 "packet-cdt-template.c"
416 /* Register protocol */
417 proto_cdt = proto_register_protocol (PNAME, PSNAME, PFNAME);
419 /* Register fields and subtrees */
420 proto_register_field_array (proto_cdt, hf, array_length(hf));
421 proto_register_subtree_array (ett, array_length(ett));
426 /*--- proto_reg_handoff_cdt ---------------------------------------*/
427 void proto_reg_handoff_cdt (void) {
429 /*--- Included file: packet-cdt-dis-tab.c ---*/
430 #line 1 "packet-cdt-dis-tab.c"
431 register_ber_oid_dissector("1.3.26.0.4406.0.4.2", dissect_CompressedData_PDU, proto_cdt, "cdt");
434 /*--- End of included file: packet-cdt-dis-tab.c ---*/
435 #line 106 "packet-cdt-template.c"