1 /* Do not modify this file. */
2 /* It is created automatically by the ASN.1 to Wireshark dissector compiler */
4 /* ../../tools/asn2wrs.py -b -p cdt -c ./cdt.cnf -s ./packet-cdt-template -D . 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
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/oids.h>
44 #include <epan/expert.h>
45 #include <epan/asn1.h>
47 #include "packet-ber.h"
48 #include "packet-p1.h"
50 #include "packet-cdt.h"
52 #define CDT_UNDEFINED 0
53 #define CDT_EXTERNAL 1
58 #define PNAME "Compressed Data Type"
62 static proto_tree *top_tree = NULL;
63 static proto_item *cdt_item = NULL;
65 static guint32 content_type = 0;
67 /* Initialize the protocol and registered fields */
68 static int proto_cdt = -1;
70 /*--- Included file: packet-cdt-hf.c ---*/
71 #line 1 "../../asn1/cdt/packet-cdt-hf.c"
72 static int hf_cdt_CompressedData_PDU = -1; /* CompressedData */
73 static int hf_cdt_compressionAlgorithm = -1; /* CompressionAlgorithmIdentifier */
74 static int hf_cdt_compressedContentInfo = -1; /* CompressedContentInfo */
75 static int hf_cdt_algorithmID_ShortForm = -1; /* AlgorithmID_ShortForm */
76 static int hf_cdt_algorithmID_OID = -1; /* OBJECT_IDENTIFIER */
77 static int hf_cdt_contentType = -1; /* T_contentType */
78 static int hf_cdt_contentType_ShortForm = -1; /* ContentType_ShortForm */
79 static int hf_cdt_contentType_OID = -1; /* T_contentType_OID */
80 static int hf_cdt_compressedContent = -1; /* CompressedContent */
82 /*--- End of included file: packet-cdt-hf.c ---*/
83 #line 62 "../../asn1/cdt/packet-cdt-template.c"
85 static dissector_handle_t data_handle = NULL;
87 /* Initialize the subtree pointers */
89 /*--- Included file: packet-cdt-ett.c ---*/
90 #line 1 "../../asn1/cdt/packet-cdt-ett.c"
91 static gint ett_cdt_CompressedData = -1;
92 static gint ett_cdt_CompressionAlgorithmIdentifier = -1;
93 static gint ett_cdt_CompressedContentInfo = -1;
94 static gint ett_cdt_T_contentType = -1;
96 /*--- End of included file: packet-cdt-ett.c ---*/
97 #line 67 "../../asn1/cdt/packet-cdt-template.c"
100 /*--- Included file: packet-cdt-fn.c ---*/
101 #line 1 "../../asn1/cdt/packet-cdt-fn.c"
103 static const value_string cdt_AlgorithmID_ShortForm_vals[] = {
104 { 0, "zlibCompress" },
110 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_) {
111 #line 21 "../../asn1/cdt/cdt.cnf"
114 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
117 proto_item_append_text (cdt_item, ", %s",
118 val_to_str (value, cdt_AlgorithmID_ShortForm_vals,
121 col_append_fstr (actx->pinfo->cinfo, COL_INFO, "%s ",
122 val_to_str (value, cdt_AlgorithmID_ShortForm_vals,
133 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_) {
134 offset = dissect_ber_object_identifier(implicit_tag, actx, tree, tvb, offset, hf_index, NULL);
140 static const value_string cdt_CompressionAlgorithmIdentifier_vals[] = {
141 { 0, "algorithmID-ShortForm" },
142 { 1, "algorithmID-OID" },
146 static const ber_choice_t CompressionAlgorithmIdentifier_choice[] = {
147 { 0, &hf_cdt_algorithmID_ShortForm, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_cdt_AlgorithmID_ShortForm },
148 { 1, &hf_cdt_algorithmID_OID , BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_cdt_OBJECT_IDENTIFIER },
149 { 0, NULL, 0, 0, 0, NULL }
153 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_) {
154 offset = dissect_ber_choice(actx, tree, tvb, offset,
155 CompressionAlgorithmIdentifier_choice, hf_index, ett_cdt_CompressionAlgorithmIdentifier,
162 static const value_string cdt_ContentType_ShortForm_vals[] = {
163 { 0, "unidentified" },
173 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_) {
174 #line 36 "../../asn1/cdt/cdt.cnf"
176 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
179 proto_item_append_text (cdt_item, ", %s",
180 val_to_str (content_type, cdt_ContentType_ShortForm_vals,
183 col_append_fstr (actx->pinfo->cinfo, COL_INFO, "%s ",
184 val_to_str (content_type, cdt_ContentType_ShortForm_vals,
195 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_) {
196 #line 50 "../../asn1/cdt/cdt.cnf"
197 const char *obj_id = NULL;
199 offset = dissect_ber_object_identifier_str(implicit_tag, actx, tree, tvb, offset, hf_index, &obj_id);
202 const char *name = oid_resolved_from_string (obj_id);
208 proto_item_append_text (cdt_item, ", %s", name);
210 col_append_fstr (actx->pinfo->cinfo, COL_INFO, "%s ", name);
219 static const value_string cdt_T_contentType_vals[] = {
220 { 0, "contentType-ShortForm" },
221 { 1, "contentType-OID" },
225 static const ber_choice_t T_contentType_choice[] = {
226 { 0, &hf_cdt_contentType_ShortForm, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_cdt_ContentType_ShortForm },
227 { 1, &hf_cdt_contentType_OID , BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_cdt_T_contentType_OID },
228 { 0, NULL, 0, 0, 0, NULL }
232 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_) {
233 offset = dissect_ber_choice(actx, tree, tvb, offset,
234 T_contentType_choice, hf_index, ett_cdt_T_contentType,
243 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_) {
244 #line 69 "../../asn1/cdt/cdt.cnf"
245 tvbuff_t *next_tvb = NULL, *compr_tvb = NULL;
246 proto_item *tf = NULL;
247 int save_offset = offset;
249 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
252 if (compr_tvb == NULL) {
253 tf = proto_tree_add_text (top_tree, tvb, save_offset, -1,
254 "[Error: Unable to get compressed content]");
255 expert_add_info_format (actx->pinfo, tf, PI_UNDECODED, PI_ERROR,
256 "Unable to get compressed content");
257 col_append_str (actx->pinfo->cinfo, COL_INFO,
258 "[Error: Unable to get compressed content]");
262 next_tvb = tvb_child_uncompress (tvb, compr_tvb, 0, tvb_length (compr_tvb));
264 if (next_tvb == NULL) {
265 tf = proto_tree_add_text (top_tree, tvb, save_offset, -1,
266 "[Error: Unable to uncompress content]");
267 expert_add_info_format (actx->pinfo, tf, PI_UNDECODED, PI_ERROR,
268 "Unable to uncompress content");
269 col_append_str (actx->pinfo->cinfo, COL_INFO,
270 "[Error: Unable to uncompress content]");
274 add_new_data_source (actx->pinfo, next_tvb, "Uncompressed Content");
276 switch (content_type) {
278 call_dissector (data_handle, next_tvb, actx->pinfo, top_tree);
281 dissect_unknown_ber (actx->pinfo, next_tvb, 0, top_tree);
284 dissect_p1_mts_apdu (next_tvb, actx->pinfo, top_tree);
287 call_dissector (data_handle, next_tvb, actx->pinfo, top_tree);
297 static const ber_sequence_t CompressedContentInfo_sequence[] = {
298 { &hf_cdt_contentType , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_cdt_T_contentType },
299 { &hf_cdt_compressedContent, BER_CLASS_CON, 0, 0, dissect_cdt_CompressedContent },
300 { NULL, 0, 0, 0, NULL }
304 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_) {
305 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
306 CompressedContentInfo_sequence, hf_index, ett_cdt_CompressedContentInfo);
312 static const ber_sequence_t CompressedData_sequence[] = {
313 { &hf_cdt_compressionAlgorithm, BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_cdt_CompressionAlgorithmIdentifier },
314 { &hf_cdt_compressedContentInfo, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_cdt_CompressedContentInfo },
315 { NULL, 0, 0, 0, NULL }
319 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_) {
320 #line 13 "../../asn1/cdt/cdt.cnf"
323 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
324 CompressedData_sequence, hf_index, ett_cdt_CompressedData);
334 static void dissect_CompressedData_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
336 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
337 dissect_cdt_CompressedData(FALSE, tvb, 0, &asn1_ctx, tree, hf_cdt_CompressedData_PDU);
341 /*--- End of included file: packet-cdt-fn.c ---*/
342 #line 69 "../../asn1/cdt/packet-cdt-template.c"
345 /*--- proto_register_cdt -------------------------------------------*/
348 ** Dissect Compressed Data Type
350 void dissect_cdt (tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
352 proto_tree *tree = NULL;
354 /* save parent_tree so subdissectors can create new top nodes */
355 top_tree = parent_tree;
358 cdt_item = proto_tree_add_item (parent_tree, proto_cdt, tvb, 0, -1, ENC_NA);
359 tree = proto_item_add_subtree (cdt_item, ett_cdt_CompressedData);
362 col_set_str (pinfo->cinfo, COL_PROTOCOL, "CDT");
363 col_clear (pinfo->cinfo, COL_INFO);
365 dissect_CompressedData_PDU (tvb, pinfo, tree);
368 void proto_register_cdt (void) {
371 static hf_register_info hf[] = {
373 /*--- Included file: packet-cdt-hfarr.c ---*/
374 #line 1 "../../asn1/cdt/packet-cdt-hfarr.c"
375 { &hf_cdt_CompressedData_PDU,
376 { "CompressedData", "cdt.CompressedData",
377 FT_NONE, BASE_NONE, NULL, 0,
379 { &hf_cdt_compressionAlgorithm,
380 { "compressionAlgorithm", "cdt.compressionAlgorithm",
381 FT_UINT32, BASE_DEC, VALS(cdt_CompressionAlgorithmIdentifier_vals), 0,
382 "CompressionAlgorithmIdentifier", HFILL }},
383 { &hf_cdt_compressedContentInfo,
384 { "compressedContentInfo", "cdt.compressedContentInfo",
385 FT_NONE, BASE_NONE, NULL, 0,
387 { &hf_cdt_algorithmID_ShortForm,
388 { "algorithmID-ShortForm", "cdt.algorithmID_ShortForm",
389 FT_INT32, BASE_DEC, VALS(cdt_AlgorithmID_ShortForm_vals), 0,
391 { &hf_cdt_algorithmID_OID,
392 { "algorithmID-OID", "cdt.algorithmID_OID",
393 FT_OID, BASE_NONE, NULL, 0,
394 "OBJECT_IDENTIFIER", HFILL }},
395 { &hf_cdt_contentType,
396 { "contentType", "cdt.contentType",
397 FT_UINT32, BASE_DEC, VALS(cdt_T_contentType_vals), 0,
399 { &hf_cdt_contentType_ShortForm,
400 { "contentType-ShortForm", "cdt.contentType_ShortForm",
401 FT_INT32, BASE_DEC, VALS(cdt_ContentType_ShortForm_vals), 0,
403 { &hf_cdt_contentType_OID,
404 { "contentType-OID", "cdt.contentType_OID",
405 FT_OID, BASE_NONE, NULL, 0,
407 { &hf_cdt_compressedContent,
408 { "compressedContent", "cdt.compressedContent",
409 FT_BYTES, BASE_NONE, NULL, 0,
412 /*--- End of included file: packet-cdt-hfarr.c ---*/
413 #line 99 "../../asn1/cdt/packet-cdt-template.c"
416 /* List of subtrees */
417 static gint *ett[] = {
419 /*--- Included file: packet-cdt-ettarr.c ---*/
420 #line 1 "../../asn1/cdt/packet-cdt-ettarr.c"
421 &ett_cdt_CompressedData,
422 &ett_cdt_CompressionAlgorithmIdentifier,
423 &ett_cdt_CompressedContentInfo,
424 &ett_cdt_T_contentType,
426 /*--- End of included file: packet-cdt-ettarr.c ---*/
427 #line 104 "../../asn1/cdt/packet-cdt-template.c"
430 /* Register protocol */
431 proto_cdt = proto_register_protocol (PNAME, PSNAME, PFNAME);
433 /* Register fields and subtrees */
434 proto_register_field_array (proto_cdt, hf, array_length(hf));
435 proto_register_subtree_array (ett, array_length(ett));
440 /*--- proto_reg_handoff_cdt ---------------------------------------*/
441 void proto_reg_handoff_cdt (void) {
443 /*--- Included file: packet-cdt-dis-tab.c ---*/
444 #line 1 "../../asn1/cdt/packet-cdt-dis-tab.c"
445 register_ber_oid_dissector("1.3.26.0.4406.0.4.2", dissect_CompressedData_PDU, proto_cdt, "cdt");
448 /*--- End of included file: packet-cdt-dis-tab.c ---*/
449 #line 119 "../../asn1/cdt/packet-cdt-template.c"
451 data_handle = find_dissector ("data");