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>
44 #include <epan/expert.h>
46 #include "packet-ber.h"
47 #include "packet-x411.h"
49 #include "packet-cdt.h"
51 #define PNAME "Compressed Data Type"
55 static proto_tree *top_tree = NULL;
56 static proto_item *cdt_item = NULL;
58 /* Initialize the protocol and registered fields */
61 /*--- Included file: packet-cdt-hf.c ---*/
62 #line 1 "packet-cdt-hf.c"
63 static int hf_cdt_CompressedData_PDU = -1; /* CompressedData */
64 static int hf_cdt_compressionAlgorithm = -1; /* CompressionAlgorithmIdentifier */
65 static int hf_cdt_compressedContentInfo = -1; /* CompressedContentInfo */
66 static int hf_cdt_algorithmID_ShortForm = -1; /* AlgorithmID_ShortForm */
67 static int hf_cdt_algorithmID_OID = -1; /* OBJECT_IDENTIFIER */
68 static int hf_cdt_contentType = -1; /* T_contentType */
69 static int hf_cdt_contentType_ShortForm = -1; /* ContentType_ShortForm */
70 static int hf_cdt_contentType_OID = -1; /* OBJECT_IDENTIFIER */
71 static int hf_cdt_compressedContent = -1; /* CompressedContent */
73 /*--- End of included file: packet-cdt-hf.c ---*/
74 #line 53 "packet-cdt-template.c"
76 /* Initialize the subtree pointers */
78 /*--- Included file: packet-cdt-ett.c ---*/
79 #line 1 "packet-cdt-ett.c"
80 static gint ett_cdt_CompressedData = -1;
81 static gint ett_cdt_CompressionAlgorithmIdentifier = -1;
82 static gint ett_cdt_CompressedContentInfo = -1;
83 static gint ett_cdt_T_contentType = -1;
85 /*--- End of included file: packet-cdt-ett.c ---*/
86 #line 56 "packet-cdt-template.c"
89 /*--- Included file: packet-cdt-fn.c ---*/
90 #line 1 "packet-cdt-fn.c"
91 /*--- Fields for imported types ---*/
95 static const value_string cdt_AlgorithmID_ShortForm_vals[] = {
96 { 0, "zlibCompress" },
102 dissect_cdt_AlgorithmID_ShortForm(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int hf_index _U_) {
106 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
109 proto_item_append_text (cdt_item, ", %s",
110 val_to_str (value, cdt_AlgorithmID_ShortForm_vals,
113 if (check_col (pinfo->cinfo, COL_INFO))
114 col_append_fstr (pinfo->cinfo, COL_INFO, "%s ",
115 val_to_str (value, cdt_AlgorithmID_ShortForm_vals,
122 static int dissect_algorithmID_ShortForm_impl(packet_info *pinfo _U_, proto_tree *tree _U_, tvbuff_t *tvb _U_, int offset _U_) {
123 return dissect_cdt_AlgorithmID_ShortForm(TRUE, tvb, offset, pinfo, tree, hf_cdt_algorithmID_ShortForm);
129 dissect_cdt_OBJECT_IDENTIFIER(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int hf_index _U_) {
131 const char *obj_id = NULL;
133 offset = dissect_ber_object_identifier_str(implicit_tag, pinfo, tree, tvb, offset, hf_index, &obj_id);
136 const char *name = get_oid_str_name (obj_id);
142 proto_item_append_text (cdt_item, ", %s", name);
144 if (check_col (pinfo->cinfo, COL_INFO))
145 col_append_fstr (pinfo->cinfo, COL_INFO, "%s ", name);
152 static int dissect_algorithmID_OID_impl(packet_info *pinfo _U_, proto_tree *tree _U_, tvbuff_t *tvb _U_, int offset _U_) {
153 return dissect_cdt_OBJECT_IDENTIFIER(TRUE, tvb, offset, pinfo, tree, hf_cdt_algorithmID_OID);
155 static int dissect_contentType_OID_impl(packet_info *pinfo _U_, proto_tree *tree _U_, tvbuff_t *tvb _U_, int offset _U_) {
156 return dissect_cdt_OBJECT_IDENTIFIER(TRUE, tvb, offset, pinfo, tree, hf_cdt_contentType_OID);
160 static const value_string cdt_CompressionAlgorithmIdentifier_vals[] = {
161 { 0, "algorithmID-ShortForm" },
162 { 1, "algorithmID-OID" },
166 static const ber_choice_t CompressionAlgorithmIdentifier_choice[] = {
167 { 0, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_algorithmID_ShortForm_impl },
168 { 1, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_algorithmID_OID_impl },
173 dissect_cdt_CompressionAlgorithmIdentifier(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int hf_index _U_) {
174 offset = dissect_ber_choice(pinfo, tree, tvb, offset,
175 CompressionAlgorithmIdentifier_choice, hf_index, ett_cdt_CompressionAlgorithmIdentifier,
180 static int dissect_compressionAlgorithm(packet_info *pinfo _U_, proto_tree *tree _U_, tvbuff_t *tvb _U_, int offset _U_) {
181 return dissect_cdt_CompressionAlgorithmIdentifier(FALSE, tvb, offset, pinfo, tree, hf_cdt_compressionAlgorithm);
185 static const value_string cdt_ContentType_ShortForm_vals[] = {
186 { 0, "unidentified" },
196 dissect_cdt_ContentType_ShortForm(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int hf_index _U_) {
200 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
203 proto_item_append_text (cdt_item, ", %s",
204 val_to_str (value, cdt_ContentType_ShortForm_vals,
207 if (check_col (pinfo->cinfo, COL_INFO))
208 col_append_fstr (pinfo->cinfo, COL_INFO, "%s ",
209 val_to_str (value, cdt_ContentType_ShortForm_vals,
216 static int dissect_contentType_ShortForm_impl(packet_info *pinfo _U_, proto_tree *tree _U_, tvbuff_t *tvb _U_, int offset _U_) {
217 return dissect_cdt_ContentType_ShortForm(TRUE, tvb, offset, pinfo, tree, hf_cdt_contentType_ShortForm);
221 static const value_string cdt_T_contentType_vals[] = {
222 { 0, "contentType-ShortForm" },
223 { 1, "contentType-OID" },
227 static const ber_choice_t T_contentType_choice[] = {
228 { 0, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_contentType_ShortForm_impl },
229 { 1, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_contentType_OID_impl },
234 dissect_cdt_T_contentType(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int hf_index _U_) {
235 offset = dissect_ber_choice(pinfo, tree, tvb, offset,
236 T_contentType_choice, hf_index, ett_cdt_T_contentType,
241 static int dissect_contentType(packet_info *pinfo _U_, proto_tree *tree _U_, tvbuff_t *tvb _U_, int offset _U_) {
242 return dissect_cdt_T_contentType(FALSE, tvb, offset, pinfo, tree, hf_cdt_contentType);
248 dissect_cdt_CompressedContent(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int hf_index _U_) {
250 tvbuff_t *next_tvb = NULL, *compr_tvb = NULL;
251 proto_item *tf = NULL;
252 int save_offset = offset;
254 offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
257 if (compr_tvb == NULL) {
258 tf = proto_tree_add_text (top_tree, tvb, save_offset, -1,
259 "[Error: Unable to get compressed content]");
260 expert_add_info_format (pinfo, tf, PI_UNDECODED, PI_ERROR,
261 "Unable to get compressed content");
262 if (check_col (pinfo->cinfo, COL_INFO))
263 col_append_fstr (pinfo->cinfo, COL_INFO,
264 "[Error: Unable to get compressed content]");
268 next_tvb = tvb_uncompress (compr_tvb, 0, tvb_length (compr_tvb));
270 if (next_tvb == NULL) {
271 tf = proto_tree_add_text (top_tree, tvb, save_offset, -1,
272 "[Error: Unable to uncompress content]");
273 expert_add_info_format (pinfo, tf, PI_UNDECODED, PI_ERROR,
274 "Unable to uncompress content");
275 if (check_col (pinfo->cinfo, COL_INFO))
276 col_append_fstr (pinfo->cinfo, COL_INFO,
277 "[Error: Unable to uncompress content]");
281 tvb_set_child_real_data_tvbuff (tvb, next_tvb);
282 add_new_data_source (pinfo, next_tvb, "Uncompressed Content");
284 dissect_x411_mts_apdu (next_tvb, pinfo, top_tree);
290 static int dissect_compressedContent(packet_info *pinfo _U_, proto_tree *tree _U_, tvbuff_t *tvb _U_, int offset _U_) {
291 return dissect_cdt_CompressedContent(FALSE, tvb, offset, pinfo, tree, hf_cdt_compressedContent);
295 static const ber_sequence_t CompressedContentInfo_sequence[] = {
296 { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_contentType },
297 { BER_CLASS_CON, 0, 0, dissect_compressedContent },
302 dissect_cdt_CompressedContentInfo(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int hf_index _U_) {
303 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
304 CompressedContentInfo_sequence, hf_index, ett_cdt_CompressedContentInfo);
308 static int dissect_compressedContentInfo(packet_info *pinfo _U_, proto_tree *tree _U_, tvbuff_t *tvb _U_, int offset _U_) {
309 return dissect_cdt_CompressedContentInfo(FALSE, tvb, offset, pinfo, tree, hf_cdt_compressedContentInfo);
313 static const ber_sequence_t CompressedData_sequence[] = {
314 { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_compressionAlgorithm },
315 { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_compressedContentInfo },
320 dissect_cdt_CompressedData(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, packet_info *pinfo _U_, proto_tree *tree _U_, int hf_index _U_) {
321 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
322 CompressedData_sequence, hf_index, ett_cdt_CompressedData);
329 static void dissect_CompressedData_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
330 dissect_cdt_CompressedData(FALSE, tvb, 0, pinfo, tree, hf_cdt_CompressedData_PDU);
334 /*--- End of included file: packet-cdt-fn.c ---*/
335 #line 58 "packet-cdt-template.c"
338 /*--- proto_register_cdt -------------------------------------------*/
341 ** Dissect Compressed Data Type
343 void dissect_cdt (tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
345 proto_tree *tree = NULL;
347 /* save parent_tree so subdissectors can create new top nodes */
348 top_tree = parent_tree;
351 cdt_item = proto_tree_add_item (parent_tree, proto_cdt, tvb, 0, -1, FALSE);
352 tree = proto_item_add_subtree (cdt_item, ett_cdt_CompressedData);
355 if (check_col (pinfo->cinfo, COL_PROTOCOL))
356 col_set_str (pinfo->cinfo, COL_PROTOCOL, "CDT");
357 if (check_col (pinfo->cinfo, COL_INFO))
358 col_clear (pinfo->cinfo, COL_INFO);
360 dissect_CompressedData_PDU (tvb, pinfo, tree);
363 void proto_register_cdt (void) {
366 static hf_register_info hf[] = {
368 /*--- Included file: packet-cdt-hfarr.c ---*/
369 #line 1 "packet-cdt-hfarr.c"
370 { &hf_cdt_CompressedData_PDU,
371 { "CompressedData", "cdt.CompressedData",
372 FT_NONE, BASE_NONE, NULL, 0,
373 "cdt.CompressedData", HFILL }},
374 { &hf_cdt_compressionAlgorithm,
375 { "compressionAlgorithm", "cdt.compressionAlgorithm",
376 FT_UINT32, BASE_DEC, VALS(cdt_CompressionAlgorithmIdentifier_vals), 0,
377 "cdt.CompressionAlgorithmIdentifier", HFILL }},
378 { &hf_cdt_compressedContentInfo,
379 { "compressedContentInfo", "cdt.compressedContentInfo",
380 FT_NONE, BASE_NONE, NULL, 0,
381 "cdt.CompressedContentInfo", HFILL }},
382 { &hf_cdt_algorithmID_ShortForm,
383 { "algorithmID-ShortForm", "cdt.algorithmID_ShortForm",
384 FT_INT32, BASE_DEC, VALS(cdt_AlgorithmID_ShortForm_vals), 0,
385 "cdt.AlgorithmID_ShortForm", HFILL }},
386 { &hf_cdt_algorithmID_OID,
387 { "algorithmID-OID", "cdt.algorithmID_OID",
388 FT_OID, BASE_NONE, NULL, 0,
389 "cdt.OBJECT_IDENTIFIER", HFILL }},
390 { &hf_cdt_contentType,
391 { "contentType", "cdt.contentType",
392 FT_UINT32, BASE_DEC, VALS(cdt_T_contentType_vals), 0,
393 "cdt.T_contentType", HFILL }},
394 { &hf_cdt_contentType_ShortForm,
395 { "contentType-ShortForm", "cdt.contentType_ShortForm",
396 FT_INT32, BASE_DEC, VALS(cdt_ContentType_ShortForm_vals), 0,
397 "cdt.ContentType_ShortForm", HFILL }},
398 { &hf_cdt_contentType_OID,
399 { "contentType-OID", "cdt.contentType_OID",
400 FT_OID, BASE_NONE, NULL, 0,
401 "cdt.OBJECT_IDENTIFIER", HFILL }},
402 { &hf_cdt_compressedContent,
403 { "compressedContent", "cdt.compressedContent",
404 FT_BYTES, BASE_HEX, NULL, 0,
405 "cdt.CompressedContent", HFILL }},
407 /*--- End of included file: packet-cdt-hfarr.c ---*/
408 #line 90 "packet-cdt-template.c"
411 /* List of subtrees */
412 static gint *ett[] = {
414 /*--- Included file: packet-cdt-ettarr.c ---*/
415 #line 1 "packet-cdt-ettarr.c"
416 &ett_cdt_CompressedData,
417 &ett_cdt_CompressionAlgorithmIdentifier,
418 &ett_cdt_CompressedContentInfo,
419 &ett_cdt_T_contentType,
421 /*--- End of included file: packet-cdt-ettarr.c ---*/
422 #line 95 "packet-cdt-template.c"
425 /* Register protocol */
426 proto_cdt = proto_register_protocol (PNAME, PSNAME, PFNAME);
428 /* Register fields and subtrees */
429 proto_register_field_array (proto_cdt, hf, array_length(hf));
430 proto_register_subtree_array (ett, array_length(ett));
435 /*--- proto_reg_handoff_cdt ---------------------------------------*/
436 void proto_reg_handoff_cdt (void) {
438 /*--- Included file: packet-cdt-dis-tab.c ---*/
439 #line 1 "packet-cdt-dis-tab.c"
440 register_ber_oid_dissector("1.3.26.0.4406.0.4.2", dissect_CompressedData_PDU, proto_cdt, "cdt");
443 /*--- End of included file: packet-cdt-dis-tab.c ---*/
444 #line 110 "packet-cdt-template.c"