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>
45 #include <epan/asn1.h>
47 #include "packet-ber.h"
48 #include "packet-x411.h"
50 #include "packet-cdt.h"
52 #define PNAME "Compressed Data Type"
56 static proto_tree *top_tree = NULL;
57 static proto_item *cdt_item = NULL;
59 /* Initialize the protocol and registered fields */
62 /*--- Included file: packet-cdt-hf.c ---*/
63 #line 1 "packet-cdt-hf.c"
64 static int hf_cdt_CompressedData_PDU = -1; /* CompressedData */
65 static int hf_cdt_compressionAlgorithm = -1; /* CompressionAlgorithmIdentifier */
66 static int hf_cdt_compressedContentInfo = -1; /* CompressedContentInfo */
67 static int hf_cdt_algorithmID_ShortForm = -1; /* AlgorithmID_ShortForm */
68 static int hf_cdt_algorithmID_OID = -1; /* OBJECT_IDENTIFIER */
69 static int hf_cdt_contentType = -1; /* T_contentType */
70 static int hf_cdt_contentType_ShortForm = -1; /* ContentType_ShortForm */
71 static int hf_cdt_contentType_OID = -1; /* OBJECT_IDENTIFIER */
72 static int hf_cdt_compressedContent = -1; /* CompressedContent */
74 /*--- End of included file: packet-cdt-hf.c ---*/
75 #line 54 "packet-cdt-template.c"
77 /* Initialize the subtree pointers */
79 /*--- Included file: packet-cdt-ett.c ---*/
80 #line 1 "packet-cdt-ett.c"
81 static gint ett_cdt_CompressedData = -1;
82 static gint ett_cdt_CompressionAlgorithmIdentifier = -1;
83 static gint ett_cdt_CompressedContentInfo = -1;
84 static gint ett_cdt_T_contentType = -1;
86 /*--- End of included file: packet-cdt-ett.c ---*/
87 #line 57 "packet-cdt-template.c"
90 /*--- Included file: packet-cdt-fn.c ---*/
91 #line 1 "packet-cdt-fn.c"
92 /*--- Fields for imported types ---*/
96 static const value_string cdt_AlgorithmID_ShortForm_vals[] = {
97 { 0, "zlibCompress" },
103 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_) {
107 offset = dissect_ber_integer(implicit_tag, actx->pinfo, tree, tvb, offset, hf_index,
110 proto_item_append_text (cdt_item, ", %s",
111 val_to_str (value, cdt_AlgorithmID_ShortForm_vals,
114 if (check_col (actx->pinfo->cinfo, COL_INFO))
115 col_append_fstr (actx->pinfo->cinfo, COL_INFO, "%s ",
116 val_to_str (value, cdt_AlgorithmID_ShortForm_vals,
123 static int dissect_algorithmID_ShortForm_impl(proto_tree *tree _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_) {
124 return dissect_cdt_AlgorithmID_ShortForm(TRUE, tvb, offset, actx, tree, hf_cdt_algorithmID_ShortForm);
130 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_) {
132 const char *obj_id = NULL;
134 offset = dissect_ber_object_identifier_str(implicit_tag, actx->pinfo, tree, tvb, offset, hf_index, &obj_id);
137 const char *name = get_oid_str_name (obj_id);
143 proto_item_append_text (cdt_item, ", %s", name);
145 if (check_col (actx->pinfo->cinfo, COL_INFO))
146 col_append_fstr (actx->pinfo->cinfo, COL_INFO, "%s ", name);
153 static int dissect_algorithmID_OID_impl(proto_tree *tree _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_) {
154 return dissect_cdt_OBJECT_IDENTIFIER(TRUE, tvb, offset, actx, tree, hf_cdt_algorithmID_OID);
156 static int dissect_contentType_OID_impl(proto_tree *tree _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_) {
157 return dissect_cdt_OBJECT_IDENTIFIER(TRUE, tvb, offset, actx, tree, hf_cdt_contentType_OID);
161 static const value_string cdt_CompressionAlgorithmIdentifier_vals[] = {
162 { 0, "algorithmID-ShortForm" },
163 { 1, "algorithmID-OID" },
167 static const ber_choice_t CompressionAlgorithmIdentifier_choice[] = {
168 { 0, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_algorithmID_ShortForm_impl },
169 { 1, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_algorithmID_OID_impl },
174 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_) {
175 offset = dissect_ber_choice(actx, tree, tvb, offset,
176 CompressionAlgorithmIdentifier_choice, hf_index, ett_cdt_CompressionAlgorithmIdentifier,
181 static int dissect_compressionAlgorithm(proto_tree *tree _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_) {
182 return dissect_cdt_CompressionAlgorithmIdentifier(FALSE, tvb, offset, actx, tree, hf_cdt_compressionAlgorithm);
186 static const value_string cdt_ContentType_ShortForm_vals[] = {
187 { 0, "unidentified" },
197 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_) {
201 offset = dissect_ber_integer(implicit_tag, actx->pinfo, tree, tvb, offset, hf_index,
204 proto_item_append_text (cdt_item, ", %s",
205 val_to_str (value, cdt_ContentType_ShortForm_vals,
208 if (check_col (actx->pinfo->cinfo, COL_INFO))
209 col_append_fstr (actx->pinfo->cinfo, COL_INFO, "%s ",
210 val_to_str (value, cdt_ContentType_ShortForm_vals,
217 static int dissect_contentType_ShortForm_impl(proto_tree *tree _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_) {
218 return dissect_cdt_ContentType_ShortForm(TRUE, tvb, offset, actx, tree, hf_cdt_contentType_ShortForm);
222 static const value_string cdt_T_contentType_vals[] = {
223 { 0, "contentType-ShortForm" },
224 { 1, "contentType-OID" },
228 static const ber_choice_t T_contentType_choice[] = {
229 { 0, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_contentType_ShortForm_impl },
230 { 1, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_contentType_OID_impl },
235 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_) {
236 offset = dissect_ber_choice(actx, tree, tvb, offset,
237 T_contentType_choice, hf_index, ett_cdt_T_contentType,
242 static int dissect_contentType(proto_tree *tree _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_) {
243 return dissect_cdt_T_contentType(FALSE, tvb, offset, actx, tree, hf_cdt_contentType);
249 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_) {
251 tvbuff_t *next_tvb = NULL, *compr_tvb = NULL;
252 proto_item *tf = NULL;
253 int save_offset = offset;
255 offset = dissect_ber_octet_string(implicit_tag, actx->pinfo, tree, tvb, offset, hf_index,
258 if (compr_tvb == NULL) {
259 tf = proto_tree_add_text (top_tree, tvb, save_offset, -1,
260 "[Error: Unable to get compressed content]");
261 expert_add_info_format (actx->pinfo, tf, PI_UNDECODED, PI_ERROR,
262 "Unable to get compressed content");
263 if (check_col (actx->pinfo->cinfo, COL_INFO))
264 col_append_fstr (actx->pinfo->cinfo, COL_INFO,
265 "[Error: Unable to get compressed content]");
269 next_tvb = tvb_uncompress (compr_tvb, 0, tvb_length (compr_tvb));
271 if (next_tvb == NULL) {
272 tf = proto_tree_add_text (top_tree, tvb, save_offset, -1,
273 "[Error: Unable to uncompress content]");
274 expert_add_info_format (actx->pinfo, tf, PI_UNDECODED, PI_ERROR,
275 "Unable to uncompress content");
276 if (check_col (actx->pinfo->cinfo, COL_INFO))
277 col_append_fstr (actx->pinfo->cinfo, COL_INFO,
278 "[Error: Unable to uncompress content]");
282 tvb_set_child_real_data_tvbuff (tvb, next_tvb);
283 add_new_data_source (actx->pinfo, next_tvb, "Uncompressed Content");
285 dissect_x411_mts_apdu (next_tvb, actx->pinfo, top_tree);
291 static int dissect_compressedContent(proto_tree *tree _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_) {
292 return dissect_cdt_CompressedContent(FALSE, tvb, offset, actx, tree, hf_cdt_compressedContent);
296 static const ber_sequence_t CompressedContentInfo_sequence[] = {
297 { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_contentType },
298 { BER_CLASS_CON, 0, 0, dissect_compressedContent },
303 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_) {
304 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
305 CompressedContentInfo_sequence, hf_index, ett_cdt_CompressedContentInfo);
309 static int dissect_compressedContentInfo(proto_tree *tree _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_) {
310 return dissect_cdt_CompressedContentInfo(FALSE, tvb, offset, actx, tree, hf_cdt_compressedContentInfo);
314 static const ber_sequence_t CompressedData_sequence[] = {
315 { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_compressionAlgorithm },
316 { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_compressedContentInfo },
321 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_) {
322 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
323 CompressedData_sequence, hf_index, ett_cdt_CompressedData);
330 static void dissect_CompressedData_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
332 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
333 dissect_cdt_CompressedData(FALSE, tvb, 0, &asn1_ctx, tree, hf_cdt_CompressedData_PDU);
337 /*--- End of included file: packet-cdt-fn.c ---*/
338 #line 59 "packet-cdt-template.c"
341 /*--- proto_register_cdt -------------------------------------------*/
344 ** Dissect Compressed Data Type
346 void dissect_cdt (tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
348 proto_tree *tree = NULL;
350 /* save parent_tree so subdissectors can create new top nodes */
351 top_tree = parent_tree;
354 cdt_item = proto_tree_add_item (parent_tree, proto_cdt, tvb, 0, -1, FALSE);
355 tree = proto_item_add_subtree (cdt_item, ett_cdt_CompressedData);
358 if (check_col (pinfo->cinfo, COL_PROTOCOL))
359 col_set_str (pinfo->cinfo, COL_PROTOCOL, "CDT");
360 if (check_col (pinfo->cinfo, COL_INFO))
361 col_clear (pinfo->cinfo, COL_INFO);
363 dissect_CompressedData_PDU (tvb, pinfo, tree);
366 void proto_register_cdt (void) {
369 static hf_register_info hf[] = {
371 /*--- Included file: packet-cdt-hfarr.c ---*/
372 #line 1 "packet-cdt-hfarr.c"
373 { &hf_cdt_CompressedData_PDU,
374 { "CompressedData", "cdt.CompressedData",
375 FT_NONE, BASE_NONE, NULL, 0,
376 "cdt.CompressedData", HFILL }},
377 { &hf_cdt_compressionAlgorithm,
378 { "compressionAlgorithm", "cdt.compressionAlgorithm",
379 FT_UINT32, BASE_DEC, VALS(cdt_CompressionAlgorithmIdentifier_vals), 0,
380 "cdt.CompressionAlgorithmIdentifier", HFILL }},
381 { &hf_cdt_compressedContentInfo,
382 { "compressedContentInfo", "cdt.compressedContentInfo",
383 FT_NONE, BASE_NONE, NULL, 0,
384 "cdt.CompressedContentInfo", HFILL }},
385 { &hf_cdt_algorithmID_ShortForm,
386 { "algorithmID-ShortForm", "cdt.algorithmID_ShortForm",
387 FT_INT32, BASE_DEC, VALS(cdt_AlgorithmID_ShortForm_vals), 0,
388 "cdt.AlgorithmID_ShortForm", HFILL }},
389 { &hf_cdt_algorithmID_OID,
390 { "algorithmID-OID", "cdt.algorithmID_OID",
391 FT_OID, BASE_NONE, NULL, 0,
392 "cdt.OBJECT_IDENTIFIER", HFILL }},
393 { &hf_cdt_contentType,
394 { "contentType", "cdt.contentType",
395 FT_UINT32, BASE_DEC, VALS(cdt_T_contentType_vals), 0,
396 "cdt.T_contentType", HFILL }},
397 { &hf_cdt_contentType_ShortForm,
398 { "contentType-ShortForm", "cdt.contentType_ShortForm",
399 FT_INT32, BASE_DEC, VALS(cdt_ContentType_ShortForm_vals), 0,
400 "cdt.ContentType_ShortForm", HFILL }},
401 { &hf_cdt_contentType_OID,
402 { "contentType-OID", "cdt.contentType_OID",
403 FT_OID, BASE_NONE, NULL, 0,
404 "cdt.OBJECT_IDENTIFIER", HFILL }},
405 { &hf_cdt_compressedContent,
406 { "compressedContent", "cdt.compressedContent",
407 FT_BYTES, BASE_HEX, NULL, 0,
408 "cdt.CompressedContent", HFILL }},
410 /*--- End of included file: packet-cdt-hfarr.c ---*/
411 #line 91 "packet-cdt-template.c"
414 /* List of subtrees */
415 static gint *ett[] = {
417 /*--- Included file: packet-cdt-ettarr.c ---*/
418 #line 1 "packet-cdt-ettarr.c"
419 &ett_cdt_CompressedData,
420 &ett_cdt_CompressionAlgorithmIdentifier,
421 &ett_cdt_CompressedContentInfo,
422 &ett_cdt_T_contentType,
424 /*--- End of included file: packet-cdt-ettarr.c ---*/
425 #line 96 "packet-cdt-template.c"
428 /* Register protocol */
429 proto_cdt = proto_register_protocol (PNAME, PSNAME, PFNAME);
431 /* Register fields and subtrees */
432 proto_register_field_array (proto_cdt, hf, array_length(hf));
433 proto_register_subtree_array (ett, array_length(ett));
438 /*--- proto_reg_handoff_cdt ---------------------------------------*/
439 void proto_reg_handoff_cdt (void) {
441 /*--- Included file: packet-cdt-dis-tab.c ---*/
442 #line 1 "packet-cdt-dis-tab.c"
443 register_ber_oid_dissector("1.3.26.0.4406.0.4.2", dissect_CompressedData_PDU, proto_cdt, "cdt");
446 /*--- End of included file: packet-cdt-dis-tab.c ---*/
447 #line 111 "packet-cdt-template.c"