1 /* Do not modify this file. Changes will be overwritten. */
2 /* Generated automatically by the ASN.1 to Wireshark dissector compiler */
4 /* ../../tools/asn2wrs.py -b -p cdt -c ./cdt.cnf -s ./packet-cdt-template -D . -O ../../epan/dissectors cdt.asn */
6 /* Input file: packet-cdt-template.c */
8 #line 1 "../../asn1/cdt/packet-cdt-template.c"
11 * Routines for Compressed Data Type packet dissection.
13 * Copyright 2005, Stig Bjorlykke <stig@bjorlykke.org>, Thales Norway AS
15 * Wireshark - Network traffic analyzer
16 * By Gerald Combs <gerald@wireshark.org>
17 * Copyright 1998 Gerald Combs
19 * This program is free software; you can redistribute it and/or
20 * modify it under the terms of the GNU General Public License
21 * as published by the Free Software Foundation; either version 2
22 * of the License, or (at your option) any later version.
24 * This program is distributed in the hope that it will be useful,
25 * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 * GNU General Public License for more details.
29 * You should have received a copy of the GNU General Public License
30 * along with this program; if not, write to the Free Software
31 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
33 * Ref: STANAG 4406 Annex E
38 #include <epan/packet.h>
39 #include <epan/oids.h>
40 #include <epan/expert.h>
41 #include <epan/asn1.h>
43 #include "packet-ber.h"
44 #include "packet-p1.h"
46 #include "packet-cdt.h"
48 #define CDT_UNDEFINED 0
49 #define CDT_EXTERNAL 1
54 #define PNAME "Compressed Data Type"
58 void proto_register_cdt(void);
59 void proto_reg_handoff_cdt(void);
61 static proto_tree *top_tree = NULL;
62 static proto_item *cdt_item = NULL;
64 static guint32 content_type = 0;
66 /* Initialize the protocol and registered fields */
67 static int proto_cdt = -1;
69 /*--- Included file: packet-cdt-hf.c ---*/
70 #line 1 "../../asn1/cdt/packet-cdt-hf.c"
71 static int hf_cdt_CompressedData_PDU = -1; /* CompressedData */
72 static int hf_cdt_compressionAlgorithm = -1; /* CompressionAlgorithmIdentifier */
73 static int hf_cdt_compressedContentInfo = -1; /* CompressedContentInfo */
74 static int hf_cdt_algorithmID_ShortForm = -1; /* AlgorithmID_ShortForm */
75 static int hf_cdt_algorithmID_OID = -1; /* OBJECT_IDENTIFIER */
76 static int hf_cdt_contentType = -1; /* T_contentType */
77 static int hf_cdt_contentType_ShortForm = -1; /* ContentType_ShortForm */
78 static int hf_cdt_contentType_OID = -1; /* T_contentType_OID */
79 static int hf_cdt_compressedContent = -1; /* CompressedContent */
81 /*--- End of included file: packet-cdt-hf.c ---*/
82 #line 61 "../../asn1/cdt/packet-cdt-template.c"
84 static dissector_handle_t data_handle = NULL;
86 /* Initialize the subtree pointers */
88 /*--- Included file: packet-cdt-ett.c ---*/
89 #line 1 "../../asn1/cdt/packet-cdt-ett.c"
90 static gint ett_cdt_CompressedData = -1;
91 static gint ett_cdt_CompressionAlgorithmIdentifier = -1;
92 static gint ett_cdt_CompressedContentInfo = -1;
93 static gint ett_cdt_T_contentType = -1;
95 /*--- End of included file: packet-cdt-ett.c ---*/
96 #line 66 "../../asn1/cdt/packet-cdt-template.c"
98 static expert_field ei_cdt_unable_compress_content = EI_INIT;
99 static expert_field ei_cdt_unable_uncompress_content = EI_INIT;
102 /*--- Included file: packet-cdt-fn.c ---*/
103 #line 1 "../../asn1/cdt/packet-cdt-fn.c"
105 static const value_string cdt_AlgorithmID_ShortForm_vals[] = {
106 { 0, "zlibCompress" },
112 dissect_cdt_AlgorithmID_ShortForm(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
113 #line 19 "../../asn1/cdt/cdt.cnf"
116 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
119 proto_item_append_text (cdt_item, ", %s",
120 val_to_str (value, cdt_AlgorithmID_ShortForm_vals,
123 col_append_fstr (actx->pinfo->cinfo, COL_INFO, "%s ",
124 val_to_str (value, cdt_AlgorithmID_ShortForm_vals,
135 dissect_cdt_OBJECT_IDENTIFIER(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
136 offset = dissect_ber_object_identifier(implicit_tag, actx, tree, tvb, offset, hf_index, NULL);
142 static const value_string cdt_CompressionAlgorithmIdentifier_vals[] = {
143 { 0, "algorithmID-ShortForm" },
144 { 1, "algorithmID-OID" },
148 static const ber_choice_t CompressionAlgorithmIdentifier_choice[] = {
149 { 0, &hf_cdt_algorithmID_ShortForm, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_cdt_AlgorithmID_ShortForm },
150 { 1, &hf_cdt_algorithmID_OID , BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_cdt_OBJECT_IDENTIFIER },
151 { 0, NULL, 0, 0, 0, NULL }
155 dissect_cdt_CompressionAlgorithmIdentifier(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
156 offset = dissect_ber_choice(actx, tree, tvb, offset,
157 CompressionAlgorithmIdentifier_choice, hf_index, ett_cdt_CompressionAlgorithmIdentifier,
164 static const value_string cdt_ContentType_ShortForm_vals[] = {
165 { 0, "unidentified" },
175 dissect_cdt_ContentType_ShortForm(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
176 #line 34 "../../asn1/cdt/cdt.cnf"
178 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
181 proto_item_append_text (cdt_item, ", %s",
182 val_to_str (content_type, cdt_ContentType_ShortForm_vals,
185 col_append_fstr (actx->pinfo->cinfo, COL_INFO, "%s ",
186 val_to_str (content_type, cdt_ContentType_ShortForm_vals,
197 dissect_cdt_T_contentType_OID(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
198 #line 48 "../../asn1/cdt/cdt.cnf"
199 const char *obj_id = NULL;
201 offset = dissect_ber_object_identifier_str(implicit_tag, actx, tree, tvb, offset, hf_index, &obj_id);
204 const char *name = oid_resolved_from_string (obj_id);
210 proto_item_append_text (cdt_item, ", %s", name);
212 col_append_fstr (actx->pinfo->cinfo, COL_INFO, "%s ", name);
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, &hf_cdt_contentType_ShortForm, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_cdt_ContentType_ShortForm },
229 { 1, &hf_cdt_contentType_OID , BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_cdt_T_contentType_OID },
230 { 0, NULL, 0, 0, 0, NULL }
234 dissect_cdt_T_contentType(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
235 offset = dissect_ber_choice(actx, tree, tvb, offset,
236 T_contentType_choice, hf_index, ett_cdt_T_contentType,
245 dissect_cdt_CompressedContent(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
246 #line 67 "../../asn1/cdt/cdt.cnf"
247 tvbuff_t *next_tvb = NULL, *compr_tvb = NULL;
248 int save_offset = offset;
250 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
253 if (compr_tvb == NULL) {
254 proto_tree_add_expert(top_tree, actx->pinfo, &ei_cdt_unable_compress_content,
255 tvb, save_offset, -1);
256 col_append_str (actx->pinfo->cinfo, COL_INFO,
257 "[Error: Unable to get compressed content]");
261 next_tvb = tvb_child_uncompress (tvb, compr_tvb, 0, tvb_length (compr_tvb));
263 if (next_tvb == NULL) {
264 proto_tree_add_expert(top_tree, actx->pinfo, &ei_cdt_unable_uncompress_content,
265 tvb, save_offset, -1);
266 col_append_str (actx->pinfo->cinfo, COL_INFO,
267 "[Error: Unable to uncompress content]");
271 add_new_data_source (actx->pinfo, next_tvb, "Uncompressed Content");
273 switch (content_type) {
275 call_dissector (data_handle, next_tvb, actx->pinfo, top_tree);
278 dissect_unknown_ber (actx->pinfo, next_tvb, 0, top_tree);
281 dissect_p1_mts_apdu (next_tvb, actx->pinfo, top_tree);
284 call_dissector (data_handle, next_tvb, actx->pinfo, top_tree);
294 static const ber_sequence_t CompressedContentInfo_sequence[] = {
295 { &hf_cdt_contentType , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_cdt_T_contentType },
296 { &hf_cdt_compressedContent, BER_CLASS_CON, 0, 0, dissect_cdt_CompressedContent },
297 { NULL, 0, 0, 0, NULL }
301 dissect_cdt_CompressedContentInfo(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
302 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
303 CompressedContentInfo_sequence, hf_index, ett_cdt_CompressedContentInfo);
309 static const ber_sequence_t CompressedData_sequence[] = {
310 { &hf_cdt_compressionAlgorithm, BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_cdt_CompressionAlgorithmIdentifier },
311 { &hf_cdt_compressedContentInfo, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_cdt_CompressedContentInfo },
312 { NULL, 0, 0, 0, NULL }
316 dissect_cdt_CompressedData(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
317 #line 11 "../../asn1/cdt/cdt.cnf"
320 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
321 CompressedData_sequence, hf_index, ett_cdt_CompressedData);
331 static void dissect_CompressedData_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
333 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
334 dissect_cdt_CompressedData(FALSE, tvb, 0, &asn1_ctx, tree, hf_cdt_CompressedData_PDU);
338 /*--- End of included file: packet-cdt-fn.c ---*/
339 #line 71 "../../asn1/cdt/packet-cdt-template.c"
342 /*--- proto_register_cdt -------------------------------------------*/
345 ** Dissect Compressed Data Type
347 void dissect_cdt (tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
349 proto_tree *tree = NULL;
351 /* save parent_tree so subdissectors can create new top nodes */
352 top_tree = parent_tree;
355 cdt_item = proto_tree_add_item (parent_tree, proto_cdt, tvb, 0, -1, ENC_NA);
356 tree = proto_item_add_subtree (cdt_item, ett_cdt_CompressedData);
361 col_set_str (pinfo->cinfo, COL_PROTOCOL, "CDT");
362 col_clear (pinfo->cinfo, COL_INFO);
364 dissect_CompressedData_PDU (tvb, pinfo, tree);
367 void proto_register_cdt (void) {
370 static hf_register_info hf[] = {
372 /*--- Included file: packet-cdt-hfarr.c ---*/
373 #line 1 "../../asn1/cdt/packet-cdt-hfarr.c"
374 { &hf_cdt_CompressedData_PDU,
375 { "CompressedData", "cdt.CompressedData_element",
376 FT_NONE, BASE_NONE, NULL, 0,
378 { &hf_cdt_compressionAlgorithm,
379 { "compressionAlgorithm", "cdt.compressionAlgorithm",
380 FT_UINT32, BASE_DEC, VALS(cdt_CompressionAlgorithmIdentifier_vals), 0,
381 "CompressionAlgorithmIdentifier", HFILL }},
382 { &hf_cdt_compressedContentInfo,
383 { "compressedContentInfo", "cdt.compressedContentInfo_element",
384 FT_NONE, BASE_NONE, NULL, 0,
386 { &hf_cdt_algorithmID_ShortForm,
387 { "algorithmID-ShortForm", "cdt.algorithmID_ShortForm",
388 FT_INT32, BASE_DEC, VALS(cdt_AlgorithmID_ShortForm_vals), 0,
390 { &hf_cdt_algorithmID_OID,
391 { "algorithmID-OID", "cdt.algorithmID_OID",
392 FT_OID, BASE_NONE, NULL, 0,
393 "OBJECT_IDENTIFIER", HFILL }},
394 { &hf_cdt_contentType,
395 { "contentType", "cdt.contentType",
396 FT_UINT32, BASE_DEC, VALS(cdt_T_contentType_vals), 0,
398 { &hf_cdt_contentType_ShortForm,
399 { "contentType-ShortForm", "cdt.contentType_ShortForm",
400 FT_INT32, BASE_DEC, VALS(cdt_ContentType_ShortForm_vals), 0,
402 { &hf_cdt_contentType_OID,
403 { "contentType-OID", "cdt.contentType_OID",
404 FT_OID, BASE_NONE, NULL, 0,
406 { &hf_cdt_compressedContent,
407 { "compressedContent", "cdt.compressedContent",
408 FT_BYTES, BASE_NONE, NULL, 0,
411 /*--- End of included file: packet-cdt-hfarr.c ---*/
412 #line 103 "../../asn1/cdt/packet-cdt-template.c"
415 /* List of subtrees */
416 static gint *ett[] = {
418 /*--- Included file: packet-cdt-ettarr.c ---*/
419 #line 1 "../../asn1/cdt/packet-cdt-ettarr.c"
420 &ett_cdt_CompressedData,
421 &ett_cdt_CompressionAlgorithmIdentifier,
422 &ett_cdt_CompressedContentInfo,
423 &ett_cdt_T_contentType,
425 /*--- End of included file: packet-cdt-ettarr.c ---*/
426 #line 108 "../../asn1/cdt/packet-cdt-template.c"
429 static ei_register_info ei[] = {
430 { &ei_cdt_unable_compress_content, { "cdt.unable_compress_content", PI_UNDECODED, PI_ERROR, "Unable to get compressed content", EXPFILL }},
431 { &ei_cdt_unable_uncompress_content, { "cdt.unable_uncompress_content", PI_UNDECODED, PI_ERROR, "Unable to get uncompressed content", EXPFILL }},
434 expert_module_t* expert_cdt;
436 /* Register protocol */
437 proto_cdt = proto_register_protocol (PNAME, PSNAME, PFNAME);
439 /* Register fields and subtrees */
440 proto_register_field_array (proto_cdt, hf, array_length(hf));
441 proto_register_subtree_array (ett, array_length(ett));
442 expert_cdt = expert_register_protocol(proto_cdt);
443 expert_register_field_array(expert_cdt, ei, array_length(ei));
447 /*--- proto_reg_handoff_cdt ---------------------------------------*/
448 void proto_reg_handoff_cdt (void) {
450 /*--- Included file: packet-cdt-dis-tab.c ---*/
451 #line 1 "../../asn1/cdt/packet-cdt-dis-tab.c"
452 register_ber_oid_dissector("1.3.26.0.4406.0.4.2", dissect_CompressedData_PDU, proto_cdt, "cdt");
455 /*--- End of included file: packet-cdt-dis-tab.c ---*/
456 #line 131 "../../asn1/cdt/packet-cdt-template.c"
458 data_handle = find_dissector ("data");