HACK: 1. try to match RowsetProperties
[wireshark-wip.git] / asn1 / cmip / packet-cmip-template.c
blob32be20c9e3d31a318114ab0dd1f21ba014cfc6d4
1 /* packet-cmip.c
2 * Routines for X.711 CMIP packet dissection
3 * Ronnie Sahlberg 2004
5 * $Id$
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include "config.h"
28 #include <glib.h>
29 #include <epan/packet.h>
30 #include <epan/oids.h>
31 #include <epan/asn1.h>
33 #include "packet-ber.h"
34 #include "packet-acse.h"
35 #include "packet-x509if.h"
36 #include "packet-cmip.h"
38 #define PNAME "X711 CMIP"
39 #define PSNAME "CMIP"
40 #define PFNAME "cmip"
42 void proto_register_cmip(void);
43 void proto_reg_handoff_cmip(void);
45 /* XXX some stuff we need until we can get rid of it */
46 #include "packet-ses.h"
47 #include "packet-pres.h"
49 /* Initialize the protocol and registered fields */
50 static int proto_cmip = -1;
51 static int hf_cmip_actionType_OID = -1;
52 static int hf_cmip_eventType_OID = -1;
53 static int hf_cmip_attributeId_OID = -1;
54 static int hf_cmip_errorId_OID = -1;
55 static int hf_DiscriminatorConstruct = -1;
56 static int hf_Destination = -1;
57 static int hf_NameBinding = -1;
58 static int hf_ObjectClass = -1;
59 #include "packet-cmip-hf.c"
61 /* Initialize the subtree pointers */
62 static gint ett_cmip = -1;
63 #include "packet-cmip-ett.c"
65 static guint32 opcode;
67 /* Dissector table */
68 static dissector_table_t attribute_id_dissector_table;
70 #include "packet-cmip-table.c"
72 static int opcode_type;
73 #define OPCODE_INVOKE 1
74 #define OPCODE_RETURN_RESULT 2
75 #define OPCODE_RETURN_ERROR 3
76 #define OPCODE_REJECT 4
78 static int attributeform;
79 #define ATTRIBUTE_LOCAL_FORM 0
80 #define ATTRIBUTE_GLOBAL_FORM 1
81 static int attribute_local_id;
82 static const char *attribute_identifier_id;
84 static const char *attributevalueassertion_id;
86 static const char *object_identifier_id;
88 static int objectclassform;
89 #define OBJECTCLASS_LOCAL_FORM 0
90 #define OBJECTCLASS_GLOBAL_FORM 1
91 static const char *objectclass_identifier_id;
93 #include "packet-cmip-val.h"
94 #include "packet-cmip-fn.c"
99 /* XXX this one should be broken out later and moved into the conformance file */
100 static int
101 dissect_cmip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data)
103 struct SESSION_DATA_STRUCTURE* session;
104 proto_item *item;
105 proto_tree *tree;
106 asn1_ctx_t asn1_ctx;
107 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
109 session = (struct SESSION_DATA_STRUCTURE*)data;
111 /* do we have spdu type from the session dissector? */
112 if( !session ){
113 proto_tree_add_text(parent_tree, tvb, 0, -1,
114 "Internal error:can't get spdu type from session dissector.");
115 return 0;
118 if(session->spdu_type == 0 ) {
119 proto_tree_add_text(parent_tree, tvb, 0, -1,
120 "Internal error:wrong spdu type %x from session dissector.",session->spdu_type);
121 return 0;
124 asn1_ctx.private_data = session;
126 item = proto_tree_add_item(parent_tree, proto_cmip, tvb, 0, -1, ENC_NA);
127 tree = proto_item_add_subtree(item, ett_cmip);
129 col_set_str(pinfo->cinfo, COL_PROTOCOL, "CMIP");
130 col_clear(pinfo->cinfo, COL_INFO);
131 switch(session->spdu_type){
132 case SES_CONNECTION_REQUEST:
133 case SES_CONNECTION_ACCEPT:
134 case SES_DISCONNECT:
135 case SES_FINISH:
136 case SES_REFUSE:
137 dissect_cmip_CMIPUserInfo(FALSE,tvb,0,&asn1_ctx,tree,-1);
138 break;
139 case SES_ABORT:
140 dissect_cmip_CMIPAbortInfo(FALSE,tvb,0,&asn1_ctx,tree,-1);
141 break;
142 case SES_DATA_TRANSFER:
143 dissect_cmip_ROS(FALSE,tvb,0,&asn1_ctx,tree,-1);
144 break;
145 default:
149 return tvb_length(tvb);
152 /*--- proto_register_cmip ----------------------------------------------*/
153 void proto_register_cmip(void) {
155 /* List of fields */
156 static hf_register_info hf[] = {
157 { &hf_cmip_actionType_OID,
158 { "actionType", "cmip.actionType_OID",
159 FT_STRING, BASE_NONE, NULL, 0,
160 NULL, HFILL }},
161 { &hf_cmip_eventType_OID,
162 { "eventType", "cmip.eventType_OID",
163 FT_STRING, BASE_NONE, NULL, 0,
164 NULL, HFILL }},
165 { &hf_cmip_attributeId_OID,
166 { "attributeId", "cmip.attributeId_OID",
167 FT_STRING, BASE_NONE, NULL, 0,
168 NULL, HFILL }},
169 { &hf_cmip_errorId_OID,
170 { "errorId", "cmip.errorId_OID",
171 FT_STRING, BASE_NONE, NULL, 0,
172 NULL, HFILL }},
173 { &hf_DiscriminatorConstruct,
174 { "DiscriminatorConstruct", "cmip.DiscriminatorConstruct",
175 FT_UINT32, BASE_DEC, NULL, 0,
176 NULL, HFILL }},
177 { &hf_Destination,
178 { "Destination", "cmip.Destination",
179 FT_UINT32, BASE_DEC, NULL, 0,
180 NULL, HFILL }},
181 { &hf_NameBinding,
182 { "NameBinding", "cmip.NameBinding",
183 FT_STRING, BASE_NONE, NULL, 0,
184 NULL, HFILL }},
185 { &hf_ObjectClass,
186 { "ObjectClass", "cmip.ObjectClass",
187 FT_UINT32, BASE_DEC, VALS(cmip_ObjectClass_vals), 0,
188 NULL, HFILL }},
190 #include "packet-cmip-hfarr.c"
193 /* List of subtrees */
194 static gint *ett[] = {
195 &ett_cmip,
196 #include "packet-cmip-ettarr.c"
199 /* Register protocol */
200 proto_cmip = proto_register_protocol(PNAME, PSNAME, PFNAME);
201 new_register_dissector("cmip", dissect_cmip, proto_cmip);
203 /* Register fields and subtrees */
204 proto_register_field_array(proto_cmip, hf, array_length(hf));
205 proto_register_subtree_array(ett, array_length(ett));
206 #include "packet-cmip-dis-tab.c"
207 oid_add_from_string("discriminatorId(1)","2.9.3.2.7.1");
209 attribute_id_dissector_table = register_dissector_table("cmip.attribute_id", "CMIP Attribute Id", FT_UINT32, BASE_DEC);
214 /*--- proto_reg_handoff_cmip -------------------------------------------*/
215 void proto_reg_handoff_cmip(void) {
216 dissector_handle_t cmip_handle = find_dissector("cmip");
218 register_ber_oid_dissector_handle("2.9.0.0.2", cmip_handle, proto_cmip, "cmip");
219 register_ber_oid_dissector_handle("2.9.1.1.4", cmip_handle, proto_cmip, "joint-iso-itu-t(2) ms(9) cmip(1) cmip-pci(1) abstractSyntax(4)");
221 oid_add_from_string("2.9.3.2.3.1","managedObjectClass(3) alarmRecord(1)");
222 oid_add_from_string("2.9.3.2.3.2","managedObjectClass(3) attributeValueChangeRecord(2)");
223 oid_add_from_string("2.9.3.2.3.3","managedObjectClass(3) discriminator(3)");
224 oid_add_from_string("2.9.3.2.3.4","managedObjectClass(3) eventForwardingDiscriminator(4)");
225 oid_add_from_string("2.9.3.2.3.5","managedObjectClass(3) eventLogRecord(5)");
226 oid_add_from_string("2.9.3.2.3.6","managedObjectClass(3) log(6)");
227 oid_add_from_string("2.9.3.2.3.7","managedObjectClass(3) logRecord(7)");
228 oid_add_from_string("2.9.3.2.3.8","managedObjectClass(3) objectCreationRecord(8)");
229 oid_add_from_string("2.9.3.2.3.9","managedObjectClass(3) objectDeletionRecord(9)");
230 oid_add_from_string("2.9.3.2.3.10","managedObjectClass(3) relationshipChangeRecord(10)");
231 oid_add_from_string("2.9.3.2.3.11","managedObjectClass(3) securityAlarmReportRecord(11)");
232 oid_add_from_string("2.9.3.2.3.12","managedObjectClass(3) stateChangeRecord(12)");
233 oid_add_from_string("2.9.3.2.3.13","managedObjectClass(3) system(13)");
234 oid_add_from_string("2.9.3.2.3.14","managedObjectClass(3) top(14)");
235 oid_add_from_string("2.9.3.2.4.14","administrativeStatePackage(14)");
236 oid_add_from_string("2.9.1.1.4","joint-iso-itu-t(2) ms(9) cmip(1) cmip-pci(1) abstractSyntax(4)");
238 /*#include "packet-cmip-dis-tab.c" */