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>
43 #include <epan/oid_resolv.h>
45 #include "packet-ber.h"
46 #include "packet-x411.h"
48 #include "packet-cdt.h"
50 #define PNAME "Compressed Data Type"
54 static proto_tree *top_tree = NULL;
55 static proto_item *cdt_item = NULL;
57 /* Initialize the protocol and registered fields */
60 /*--- Included file: packet-cdt-hf.c ---*/
61 #line 1 "packet-cdt-hf.c"
62 static int hf_cdt_CompressedData_PDU = -1; /* CompressedData */
63 static int hf_cdt_compressionAlgorithm = -1; /* CompressionAlgorithmIdentifier */
64 static int hf_cdt_compressedContentInfo = -1; /* CompressedContentInfo */
65 static int hf_cdt_algorithmID_ShortForm = -1; /* AlgorithmID_ShortForm */
66 static int hf_cdt_algorithmID_OID = -1; /* OBJECT_IDENTIFIER */
67 static int hf_cdt_contentType = -1; /* T_contentType */
68 static int hf_cdt_contentType_ShortForm = -1; /* ContentType_ShortForm */
69 static int hf_cdt_contentType_OID = -1; /* OBJECT_IDENTIFIER */
70 static int hf_cdt_compressedContent = -1; /* CompressedContent */
72 /*--- End of included file: packet-cdt-hf.c ---*/
73 #line 52 "packet-cdt-template.c"
75 /* Initialize the subtree pointers */
77 /*--- Included file: packet-cdt-ett.c ---*/
78 #line 1 "packet-cdt-ett.c"
79 static gint ett_cdt_CompressedData = -1;
80 static gint ett_cdt_CompressionAlgorithmIdentifier = -1;
81 static gint ett_cdt_CompressedContentInfo = -1;
82 static gint ett_cdt_T_contentType = -1;
84 /*--- End of included file: packet-cdt-ett.c ---*/
85 #line 55 "packet-cdt-template.c"
88 /*--- Included file: packet-cdt-fn.c ---*/
89 #line 1 "packet-cdt-fn.c"
90 /*--- Fields for imported types ---*/
94 static const value_string cdt_AlgorithmID_ShortForm_vals[] = {
95 { 0, "zlibCompress" },
101 dissect_cdt_AlgorithmID_ShortForm(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
105 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
108 proto_item_append_text (cdt_item, ", %s",
109 val_to_str (value, cdt_AlgorithmID_ShortForm_vals,
112 if (check_col (pinfo->cinfo, COL_INFO))
113 col_append_fstr (pinfo->cinfo, COL_INFO, "%s ",
114 val_to_str (value, cdt_AlgorithmID_ShortForm_vals,
121 static int dissect_algorithmID_ShortForm_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
122 return dissect_cdt_AlgorithmID_ShortForm(TRUE, tvb, offset, pinfo, tree, hf_cdt_algorithmID_ShortForm);
128 dissect_cdt_OBJECT_IDENTIFIER(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
130 const char *obj_id = NULL;
132 offset = dissect_ber_object_identifier_str(implicit_tag, pinfo, tree, tvb, offset, hf_index, &obj_id);
135 const char *name = get_oid_str_name (obj_id);
141 proto_item_append_text (cdt_item, ", %s", name);
143 if (check_col (pinfo->cinfo, COL_INFO))
144 col_append_fstr (pinfo->cinfo, COL_INFO, "%s ", name);
151 static int dissect_algorithmID_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_algorithmID_OID);
154 static int dissect_contentType_OID_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
155 return dissect_cdt_OBJECT_IDENTIFIER(TRUE, tvb, offset, pinfo, tree, hf_cdt_contentType_OID);
159 static const value_string cdt_CompressionAlgorithmIdentifier_vals[] = {
160 { 0, "algorithmID-ShortForm" },
161 { 1, "algorithmID-OID" },
165 static const ber_choice_t CompressionAlgorithmIdentifier_choice[] = {
166 { 0, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_algorithmID_ShortForm_impl },
167 { 1, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_algorithmID_OID_impl },
172 dissect_cdt_CompressionAlgorithmIdentifier(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
173 offset = dissect_ber_choice(pinfo, tree, tvb, offset,
174 CompressionAlgorithmIdentifier_choice, hf_index, ett_cdt_CompressionAlgorithmIdentifier,
179 static int dissect_compressionAlgorithm(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
180 return dissect_cdt_CompressionAlgorithmIdentifier(FALSE, tvb, offset, pinfo, tree, hf_cdt_compressionAlgorithm);
184 static const value_string cdt_ContentType_ShortForm_vals[] = {
185 { 0, "unidentified" },
195 dissect_cdt_ContentType_ShortForm(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
199 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
202 proto_item_append_text (cdt_item, ", %s",
203 val_to_str (value, cdt_ContentType_ShortForm_vals,
206 if (check_col (pinfo->cinfo, COL_INFO))
207 col_append_fstr (pinfo->cinfo, COL_INFO, "%s ",
208 val_to_str (value, cdt_ContentType_ShortForm_vals,
215 static int dissect_contentType_ShortForm_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
216 return dissect_cdt_ContentType_ShortForm(TRUE, tvb, offset, pinfo, tree, hf_cdt_contentType_ShortForm);
220 static const value_string cdt_T_contentType_vals[] = {
221 { 0, "contentType-ShortForm" },
222 { 1, "contentType-OID" },
226 static const ber_choice_t T_contentType_choice[] = {
227 { 0, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_contentType_ShortForm_impl },
228 { 1, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_contentType_OID_impl },
233 dissect_cdt_T_contentType(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
234 offset = dissect_ber_choice(pinfo, tree, tvb, offset,
235 T_contentType_choice, hf_index, ett_cdt_T_contentType,
240 static int dissect_contentType(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
241 return dissect_cdt_T_contentType(FALSE, tvb, offset, pinfo, tree, hf_cdt_contentType);
247 dissect_cdt_CompressedContent(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
249 tvbuff_t *next_tvb = NULL, *compr_tvb = NULL;
250 int save_offset = offset;
252 offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
255 if (compr_tvb == NULL) {
256 proto_tree_add_text (top_tree, tvb, save_offset, -1,
257 "[Error: Unable to get compressed content]");
258 if (check_col (pinfo->cinfo, COL_INFO))
259 col_append_fstr (pinfo->cinfo, COL_INFO,
260 "[Error: Unable to get compressed content]");
264 next_tvb = tvb_uncompress (compr_tvb, 0, tvb_length (compr_tvb));
266 if (next_tvb == NULL) {
267 proto_tree_add_text (top_tree, tvb, save_offset, -1,
268 "[Error: Unable to uncompress content]");
269 if (check_col (pinfo->cinfo, COL_INFO))
270 col_append_fstr (pinfo->cinfo, COL_INFO,
271 "[Error: Unable to uncompress content]");
275 tvb_set_child_real_data_tvbuff (tvb, next_tvb);
276 add_new_data_source (pinfo, next_tvb, "Uncompressed Content");
278 dissect_x411_mts_apdu (next_tvb, pinfo, top_tree);
284 static int dissect_compressedContent(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
285 return dissect_cdt_CompressedContent(FALSE, tvb, offset, pinfo, tree, hf_cdt_compressedContent);
289 static const ber_sequence_t CompressedContentInfo_sequence[] = {
290 { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_contentType },
291 { BER_CLASS_CON, 0, 0, dissect_compressedContent },
296 dissect_cdt_CompressedContentInfo(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
297 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
298 CompressedContentInfo_sequence, hf_index, ett_cdt_CompressedContentInfo);
302 static int dissect_compressedContentInfo(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
303 return dissect_cdt_CompressedContentInfo(FALSE, tvb, offset, pinfo, tree, hf_cdt_compressedContentInfo);
307 static const ber_sequence_t CompressedData_sequence[] = {
308 { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_compressionAlgorithm },
309 { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_compressedContentInfo },
314 dissect_cdt_CompressedData(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
315 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
316 CompressedData_sequence, hf_index, ett_cdt_CompressedData);
323 static void dissect_CompressedData_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
324 dissect_cdt_CompressedData(FALSE, tvb, 0, pinfo, tree, hf_cdt_CompressedData_PDU);
328 /*--- End of included file: packet-cdt-fn.c ---*/
329 #line 57 "packet-cdt-template.c"
332 /*--- proto_register_cdt -------------------------------------------*/
335 ** Dissect Compressed Data Type
337 void dissect_cdt (tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
339 proto_tree *tree = NULL;
341 /* save parent_tree so subdissectors can create new top nodes */
342 top_tree = parent_tree;
345 cdt_item = proto_tree_add_item (parent_tree, proto_cdt, tvb, 0, -1, FALSE);
346 tree = proto_item_add_subtree (cdt_item, ett_cdt_CompressedData);
349 if (check_col (pinfo->cinfo, COL_PROTOCOL))
350 col_set_str (pinfo->cinfo, COL_PROTOCOL, "CDT");
351 if (check_col (pinfo->cinfo, COL_INFO))
352 col_clear (pinfo->cinfo, COL_INFO);
354 dissect_CompressedData_PDU (tvb, pinfo, tree);
357 void proto_register_cdt (void) {
360 static hf_register_info hf[] = {
362 /*--- Included file: packet-cdt-hfarr.c ---*/
363 #line 1 "packet-cdt-hfarr.c"
364 { &hf_cdt_CompressedData_PDU,
365 { "CompressedData", "cdt.CompressedData",
366 FT_NONE, BASE_NONE, NULL, 0,
367 "cdt.CompressedData", HFILL }},
368 { &hf_cdt_compressionAlgorithm,
369 { "compressionAlgorithm", "cdt.compressionAlgorithm",
370 FT_UINT32, BASE_DEC, VALS(cdt_CompressionAlgorithmIdentifier_vals), 0,
371 "cdt.CompressionAlgorithmIdentifier", HFILL }},
372 { &hf_cdt_compressedContentInfo,
373 { "compressedContentInfo", "cdt.compressedContentInfo",
374 FT_NONE, BASE_NONE, NULL, 0,
375 "cdt.CompressedContentInfo", HFILL }},
376 { &hf_cdt_algorithmID_ShortForm,
377 { "algorithmID-ShortForm", "cdt.algorithmID_ShortForm",
378 FT_INT32, BASE_DEC, VALS(cdt_AlgorithmID_ShortForm_vals), 0,
379 "cdt.AlgorithmID_ShortForm", HFILL }},
380 { &hf_cdt_algorithmID_OID,
381 { "algorithmID-OID", "cdt.algorithmID_OID",
382 FT_OID, BASE_NONE, NULL, 0,
383 "cdt.OBJECT_IDENTIFIER", HFILL }},
384 { &hf_cdt_contentType,
385 { "contentType", "cdt.contentType",
386 FT_UINT32, BASE_DEC, VALS(cdt_T_contentType_vals), 0,
387 "cdt.T_contentType", HFILL }},
388 { &hf_cdt_contentType_ShortForm,
389 { "contentType-ShortForm", "cdt.contentType_ShortForm",
390 FT_INT32, BASE_DEC, VALS(cdt_ContentType_ShortForm_vals), 0,
391 "cdt.ContentType_ShortForm", HFILL }},
392 { &hf_cdt_contentType_OID,
393 { "contentType-OID", "cdt.contentType_OID",
394 FT_OID, BASE_NONE, NULL, 0,
395 "cdt.OBJECT_IDENTIFIER", HFILL }},
396 { &hf_cdt_compressedContent,
397 { "compressedContent", "cdt.compressedContent",
398 FT_BYTES, BASE_HEX, NULL, 0,
399 "cdt.CompressedContent", HFILL }},
401 /*--- End of included file: packet-cdt-hfarr.c ---*/
402 #line 89 "packet-cdt-template.c"
405 /* List of subtrees */
406 static gint *ett[] = {
408 /*--- Included file: packet-cdt-ettarr.c ---*/
409 #line 1 "packet-cdt-ettarr.c"
410 &ett_cdt_CompressedData,
411 &ett_cdt_CompressionAlgorithmIdentifier,
412 &ett_cdt_CompressedContentInfo,
413 &ett_cdt_T_contentType,
415 /*--- End of included file: packet-cdt-ettarr.c ---*/
416 #line 94 "packet-cdt-template.c"
419 /* Register protocol */
420 proto_cdt = proto_register_protocol (PNAME, PSNAME, PFNAME);
422 /* Register fields and subtrees */
423 proto_register_field_array (proto_cdt, hf, array_length(hf));
424 proto_register_subtree_array (ett, array_length(ett));
429 /*--- proto_reg_handoff_cdt ---------------------------------------*/
430 void proto_reg_handoff_cdt (void) {
432 /*--- Included file: packet-cdt-dis-tab.c ---*/
433 #line 1 "packet-cdt-dis-tab.c"
434 register_ber_oid_dissector("1.3.26.0.4406.0.4.2", dissect_CompressedData_PDU, proto_cdt, "cdt");
437 /*--- End of included file: packet-cdt-dis-tab.c ---*/
438 #line 109 "packet-cdt-template.c"