HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / dissectors / packet-cdt.c
blob46fbc961dfa32ce315980e54208cf492315003ca
1 /* Do not modify this file. Changes will be overwritten. */
2 /* Generated automatically by the ASN.1 to Wireshark dissector compiler */
3 /* packet-cdt.c */
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"
9 /* packet-cdt.c
11 * Routines for Compressed Data Type packet dissection.
13 * Copyright 2005, Stig Bjorlykke <stig@bjorlykke.org>, Thales Norway AS
15 * $Id$
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
35 * Ref: STANAG 4406 Annex E
38 #include "config.h"
40 #include <epan/packet.h>
41 #include <epan/oids.h>
42 #include <epan/expert.h>
43 #include <epan/asn1.h>
45 #include "packet-ber.h"
46 #include "packet-p1.h"
48 #include "packet-cdt.h"
50 #define CDT_UNDEFINED 0
51 #define CDT_EXTERNAL 1
52 #define CDT_P1 2
53 #define CDT_P3 3
54 #define CDT_P7 4
56 #define PNAME "Compressed Data Type"
57 #define PSNAME "CDT"
58 #define PFNAME "cdt"
60 static proto_tree *top_tree = NULL;
61 static proto_item *cdt_item = NULL;
63 static guint32 content_type = 0;
65 /* Initialize the protocol and registered fields */
66 static int proto_cdt = -1;
68 /*--- Included file: packet-cdt-hf.c ---*/
69 #line 1 "../../asn1/cdt/packet-cdt-hf.c"
70 static int hf_cdt_CompressedData_PDU = -1; /* CompressedData */
71 static int hf_cdt_compressionAlgorithm = -1; /* CompressionAlgorithmIdentifier */
72 static int hf_cdt_compressedContentInfo = -1; /* CompressedContentInfo */
73 static int hf_cdt_algorithmID_ShortForm = -1; /* AlgorithmID_ShortForm */
74 static int hf_cdt_algorithmID_OID = -1; /* OBJECT_IDENTIFIER */
75 static int hf_cdt_contentType = -1; /* T_contentType */
76 static int hf_cdt_contentType_ShortForm = -1; /* ContentType_ShortForm */
77 static int hf_cdt_contentType_OID = -1; /* T_contentType_OID */
78 static int hf_cdt_compressedContent = -1; /* CompressedContent */
80 /*--- End of included file: packet-cdt-hf.c ---*/
81 #line 60 "../../asn1/cdt/packet-cdt-template.c"
83 static dissector_handle_t data_handle = NULL;
85 /* Initialize the subtree pointers */
87 /*--- Included file: packet-cdt-ett.c ---*/
88 #line 1 "../../asn1/cdt/packet-cdt-ett.c"
89 static gint ett_cdt_CompressedData = -1;
90 static gint ett_cdt_CompressionAlgorithmIdentifier = -1;
91 static gint ett_cdt_CompressedContentInfo = -1;
92 static gint ett_cdt_T_contentType = -1;
94 /*--- End of included file: packet-cdt-ett.c ---*/
95 #line 65 "../../asn1/cdt/packet-cdt-template.c"
97 static expert_field ei_cdt_unable_compress_content = EI_INIT;
98 static expert_field ei_cdt_unable_uncompress_content = EI_INIT;
101 /*--- Included file: packet-cdt-fn.c ---*/
102 #line 1 "../../asn1/cdt/packet-cdt-fn.c"
104 static const value_string cdt_AlgorithmID_ShortForm_vals[] = {
105 { 0, "zlibCompress" },
106 { 0, NULL }
110 static int
111 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_) {
112 #line 21 "../../asn1/cdt/cdt.cnf"
113 guint32 value;
115 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
116 &value);
118 proto_item_append_text (cdt_item, ", %s",
119 val_to_str (value, cdt_AlgorithmID_ShortForm_vals,
120 "unknown"));
122 col_append_fstr (actx->pinfo->cinfo, COL_INFO, "%s ",
123 val_to_str (value, cdt_AlgorithmID_ShortForm_vals,
124 "unknown"));
128 return offset;
133 static int
134 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_) {
135 offset = dissect_ber_object_identifier(implicit_tag, actx, tree, tvb, offset, hf_index, NULL);
137 return offset;
141 static const value_string cdt_CompressionAlgorithmIdentifier_vals[] = {
142 { 0, "algorithmID-ShortForm" },
143 { 1, "algorithmID-OID" },
144 { 0, NULL }
147 static const ber_choice_t CompressionAlgorithmIdentifier_choice[] = {
148 { 0, &hf_cdt_algorithmID_ShortForm, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_cdt_AlgorithmID_ShortForm },
149 { 1, &hf_cdt_algorithmID_OID , BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_cdt_OBJECT_IDENTIFIER },
150 { 0, NULL, 0, 0, 0, NULL }
153 static int
154 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_) {
155 offset = dissect_ber_choice(actx, tree, tvb, offset,
156 CompressionAlgorithmIdentifier_choice, hf_index, ett_cdt_CompressionAlgorithmIdentifier,
157 NULL);
159 return offset;
163 static const value_string cdt_ContentType_ShortForm_vals[] = {
164 { 0, "unidentified" },
165 { 1, "external" },
166 { 2, "p1" },
167 { 3, "p3" },
168 { 4, "p7" },
169 { 0, NULL }
173 static int
174 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_) {
175 #line 36 "../../asn1/cdt/cdt.cnf"
177 offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
178 &content_type);
180 proto_item_append_text (cdt_item, ", %s",
181 val_to_str (content_type, cdt_ContentType_ShortForm_vals,
182 "unknown"));
184 col_append_fstr (actx->pinfo->cinfo, COL_INFO, "%s ",
185 val_to_str (content_type, cdt_ContentType_ShortForm_vals,
186 "unknown"));
190 return offset;
195 static int
196 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_) {
197 #line 50 "../../asn1/cdt/cdt.cnf"
198 const char *obj_id = NULL;
200 offset = dissect_ber_object_identifier_str(implicit_tag, actx, tree, tvb, offset, hf_index, &obj_id);
202 if (obj_id) {
203 const char *name = oid_resolved_from_string (obj_id);
205 if (!name) {
206 name = obj_id;
209 proto_item_append_text (cdt_item, ", %s", name);
211 col_append_fstr (actx->pinfo->cinfo, COL_INFO, "%s ", name);
216 return offset;
220 static const value_string cdt_T_contentType_vals[] = {
221 { 0, "contentType-ShortForm" },
222 { 1, "contentType-OID" },
223 { 0, NULL }
226 static const ber_choice_t T_contentType_choice[] = {
227 { 0, &hf_cdt_contentType_ShortForm, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_cdt_ContentType_ShortForm },
228 { 1, &hf_cdt_contentType_OID , BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_cdt_T_contentType_OID },
229 { 0, NULL, 0, 0, 0, NULL }
232 static int
233 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_) {
234 offset = dissect_ber_choice(actx, tree, tvb, offset,
235 T_contentType_choice, hf_index, ett_cdt_T_contentType,
236 NULL);
238 return offset;
243 static int
244 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_) {
245 #line 69 "../../asn1/cdt/cdt.cnf"
246 tvbuff_t *next_tvb = NULL, *compr_tvb = NULL;
247 int save_offset = offset;
249 offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
250 &compr_tvb);
252 if (compr_tvb == NULL) {
253 proto_tree_add_expert(top_tree, actx->pinfo, &ei_cdt_unable_compress_content,
254 tvb, save_offset, -1);
255 col_append_str (actx->pinfo->cinfo, COL_INFO,
256 "[Error: Unable to get compressed content]");
257 return offset;
260 next_tvb = tvb_child_uncompress (tvb, compr_tvb, 0, tvb_length (compr_tvb));
262 if (next_tvb == NULL) {
263 proto_tree_add_expert(top_tree, actx->pinfo, &ei_cdt_unable_uncompress_content,
264 tvb, save_offset, -1);
265 col_append_str (actx->pinfo->cinfo, COL_INFO,
266 "[Error: Unable to uncompress content]");
267 return offset;
270 add_new_data_source (actx->pinfo, next_tvb, "Uncompressed Content");
272 switch (content_type) {
273 case CDT_UNDEFINED:
274 call_dissector (data_handle, next_tvb, actx->pinfo, top_tree);
275 break;
276 case CDT_EXTERNAL:
277 dissect_unknown_ber (actx->pinfo, next_tvb, 0, top_tree);
278 break;
279 case CDT_P1:
280 dissect_p1_mts_apdu (next_tvb, actx->pinfo, top_tree);
281 break;
282 default:
283 call_dissector (data_handle, next_tvb, actx->pinfo, top_tree);
284 break;
289 return offset;
293 static const ber_sequence_t CompressedContentInfo_sequence[] = {
294 { &hf_cdt_contentType , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_cdt_T_contentType },
295 { &hf_cdt_compressedContent, BER_CLASS_CON, 0, 0, dissect_cdt_CompressedContent },
296 { NULL, 0, 0, 0, NULL }
299 static int
300 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_) {
301 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
302 CompressedContentInfo_sequence, hf_index, ett_cdt_CompressedContentInfo);
304 return offset;
308 static const ber_sequence_t CompressedData_sequence[] = {
309 { &hf_cdt_compressionAlgorithm, BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_cdt_CompressionAlgorithmIdentifier },
310 { &hf_cdt_compressedContentInfo, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_cdt_CompressedContentInfo },
311 { NULL, 0, 0, 0, NULL }
315 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_) {
316 #line 13 "../../asn1/cdt/cdt.cnf"
317 content_type = 0;
319 offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
320 CompressedData_sequence, hf_index, ett_cdt_CompressedData);
325 return offset;
328 /*--- PDUs ---*/
330 static void dissect_CompressedData_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
331 asn1_ctx_t asn1_ctx;
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 70 "../../asn1/cdt/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;
353 if (parent_tree) {
354 cdt_item = proto_tree_add_item (parent_tree, proto_cdt, tvb, 0, -1, ENC_NA);
355 tree = proto_item_add_subtree (cdt_item, ett_cdt_CompressedData);
358 col_set_str (pinfo->cinfo, COL_PROTOCOL, "CDT");
359 col_clear (pinfo->cinfo, COL_INFO);
361 dissect_CompressedData_PDU (tvb, pinfo, tree);
364 void proto_register_cdt (void) {
366 /* List of fields */
367 static hf_register_info hf[] = {
369 /*--- Included file: packet-cdt-hfarr.c ---*/
370 #line 1 "../../asn1/cdt/packet-cdt-hfarr.c"
371 { &hf_cdt_CompressedData_PDU,
372 { "CompressedData", "cdt.CompressedData_element",
373 FT_NONE, BASE_NONE, NULL, 0,
374 NULL, HFILL }},
375 { &hf_cdt_compressionAlgorithm,
376 { "compressionAlgorithm", "cdt.compressionAlgorithm",
377 FT_UINT32, BASE_DEC, VALS(cdt_CompressionAlgorithmIdentifier_vals), 0,
378 "CompressionAlgorithmIdentifier", HFILL }},
379 { &hf_cdt_compressedContentInfo,
380 { "compressedContentInfo", "cdt.compressedContentInfo_element",
381 FT_NONE, BASE_NONE, NULL, 0,
382 NULL, HFILL }},
383 { &hf_cdt_algorithmID_ShortForm,
384 { "algorithmID-ShortForm", "cdt.algorithmID_ShortForm",
385 FT_INT32, BASE_DEC, VALS(cdt_AlgorithmID_ShortForm_vals), 0,
386 NULL, HFILL }},
387 { &hf_cdt_algorithmID_OID,
388 { "algorithmID-OID", "cdt.algorithmID_OID",
389 FT_OID, BASE_NONE, NULL, 0,
390 "OBJECT_IDENTIFIER", HFILL }},
391 { &hf_cdt_contentType,
392 { "contentType", "cdt.contentType",
393 FT_UINT32, BASE_DEC, VALS(cdt_T_contentType_vals), 0,
394 NULL, HFILL }},
395 { &hf_cdt_contentType_ShortForm,
396 { "contentType-ShortForm", "cdt.contentType_ShortForm",
397 FT_INT32, BASE_DEC, VALS(cdt_ContentType_ShortForm_vals), 0,
398 NULL, HFILL }},
399 { &hf_cdt_contentType_OID,
400 { "contentType-OID", "cdt.contentType_OID",
401 FT_OID, BASE_NONE, NULL, 0,
402 NULL, HFILL }},
403 { &hf_cdt_compressedContent,
404 { "compressedContent", "cdt.compressedContent",
405 FT_BYTES, BASE_NONE, NULL, 0,
406 NULL, HFILL }},
408 /*--- End of included file: packet-cdt-hfarr.c ---*/
409 #line 100 "../../asn1/cdt/packet-cdt-template.c"
412 /* List of subtrees */
413 static gint *ett[] = {
415 /*--- Included file: packet-cdt-ettarr.c ---*/
416 #line 1 "../../asn1/cdt/packet-cdt-ettarr.c"
417 &ett_cdt_CompressedData,
418 &ett_cdt_CompressionAlgorithmIdentifier,
419 &ett_cdt_CompressedContentInfo,
420 &ett_cdt_T_contentType,
422 /*--- End of included file: packet-cdt-ettarr.c ---*/
423 #line 105 "../../asn1/cdt/packet-cdt-template.c"
426 static ei_register_info ei[] = {
427 { &ei_cdt_unable_compress_content, { "cdt.unable_compress_content", PI_UNDECODED, PI_ERROR, "Unable to get compressed content", EXPFILL }},
428 { &ei_cdt_unable_uncompress_content, { "cdt.unable_uncompress_content", PI_UNDECODED, PI_ERROR, "Unable to get uncompressed content", EXPFILL }},
431 expert_module_t* expert_cdt;
433 /* Register protocol */
434 proto_cdt = proto_register_protocol (PNAME, PSNAME, PFNAME);
436 /* Register fields and subtrees */
437 proto_register_field_array (proto_cdt, hf, array_length(hf));
438 proto_register_subtree_array (ett, array_length(ett));
439 expert_cdt = expert_register_protocol(proto_cdt);
440 expert_register_field_array(expert_cdt, ei, array_length(ei));
444 /*--- proto_reg_handoff_cdt ---------------------------------------*/
445 void proto_reg_handoff_cdt (void) {
447 /*--- Included file: packet-cdt-dis-tab.c ---*/
448 #line 1 "../../asn1/cdt/packet-cdt-dis-tab.c"
449 register_ber_oid_dissector("1.3.26.0.4406.0.4.2", dissect_CompressedData_PDU, proto_cdt, "cdt");
452 /*--- End of included file: packet-cdt-dis-tab.c ---*/
453 #line 128 "../../asn1/cdt/packet-cdt-template.c"
455 data_handle = find_dissector ("data");