[-Wmissing-prototypes]
[metze/wireshark/wip.git] / asn1 / cdt / packet-cdt-template.c
1 /* packet-cdt.c
2  *
3  * Routines for Compressed Data Type packet dissection.
4  *
5  * Copyright 2005, Stig Bjorlykke <stig@bjorlykke.org>, Thales Norway AS
6  *
7  * $Id$
8  *
9  * Wireshark - Network traffic analyzer
10  * By Gerald Combs <gerald@wireshark.org>
11  * Copyright 1998 Gerald Combs
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26  *
27  * Ref: STANAG 4406 Annex E
28  */
29
30 #include "config.h"
31
32 #include <epan/packet.h>
33 #include <epan/oids.h>
34 #include <epan/expert.h>
35 #include <epan/asn1.h>
36
37 #include "packet-ber.h"
38 #include "packet-p1.h"
39
40 #include "packet-cdt.h"
41
42 #define CDT_UNDEFINED  0
43 #define CDT_EXTERNAL   1
44 #define CDT_P1         2
45 #define CDT_P3         3
46 #define CDT_P7         4
47
48 #define PNAME  "Compressed Data Type"
49 #define PSNAME "CDT"
50 #define PFNAME "cdt"
51
52 static proto_tree *top_tree = NULL;
53 static proto_item *cdt_item = NULL;
54
55 static guint32 content_type = 0;
56
57 /* Initialize the protocol and registered fields */
58 static int proto_cdt = -1;
59 #include "packet-cdt-hf.c"
60
61 static dissector_handle_t data_handle = NULL;
62
63 /* Initialize the subtree pointers */
64 #include "packet-cdt-ett.c"
65
66 #include "packet-cdt-fn.c"
67
68
69 /*--- proto_register_cdt -------------------------------------------*/
70
71 /*
72 ** Dissect Compressed Data Type
73 */
74 void dissect_cdt (tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
75 {
76   proto_tree *tree = NULL;
77
78   /* save parent_tree so subdissectors can create new top nodes */
79   top_tree = parent_tree;
80
81   if (parent_tree) {
82     cdt_item = proto_tree_add_item (parent_tree, proto_cdt, tvb, 0, -1, ENC_NA);
83     tree = proto_item_add_subtree (cdt_item, ett_cdt_CompressedData);
84   }
85
86   col_set_str (pinfo->cinfo, COL_PROTOCOL, "CDT");
87   col_clear (pinfo->cinfo, COL_INFO);
88
89   dissect_CompressedData_PDU (tvb, pinfo, tree);
90 }
91
92 void proto_register_cdt (void) {
93
94   /* List of fields */
95   static hf_register_info hf[] = {
96 #include "packet-cdt-hfarr.c"
97   };
98
99   /* List of subtrees */
100   static gint *ett[] = {
101 #include "packet-cdt-ettarr.c"
102   };
103
104   /* Register protocol */
105   proto_cdt = proto_register_protocol (PNAME, PSNAME, PFNAME);
106
107   /* Register fields and subtrees */
108   proto_register_field_array (proto_cdt, hf, array_length(hf));
109   proto_register_subtree_array (ett, array_length(ett));
110
111 }
112
113
114 /*--- proto_reg_handoff_cdt ---------------------------------------*/
115 void proto_reg_handoff_cdt (void) {
116 #include "packet-cdt-dis-tab.c"
117
118   data_handle = find_dissector ("data");
119 }