2 * Routines for X.711 CMIP packet dissection
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include <epan/packet.h>
27 #include <epan/expert.h>
28 #include <epan/oids.h>
29 #include <epan/asn1.h>
31 #include "packet-ber.h"
32 #include "packet-acse.h"
33 #include "packet-x509if.h"
34 #include "packet-cmip.h"
36 #define PNAME "X711 CMIP"
40 void proto_register_cmip(void);
41 void proto_reg_handoff_cmip(void);
43 /* XXX some stuff we need until we can get rid of it */
44 #include "packet-ses.h"
45 #include "packet-pres.h"
47 /* Initialize the protocol and registered fields */
48 static int proto_cmip = -1;
49 static int hf_cmip_actionType_OID = -1;
50 static int hf_cmip_eventType_OID = -1;
51 static int hf_cmip_attributeId_OID = -1;
52 static int hf_cmip_errorId_OID = -1;
53 static int hf_DiscriminatorConstruct = -1;
54 static int hf_Destination = -1;
55 static int hf_NameBinding = -1;
56 static int hf_ObjectClass = -1;
57 #include "packet-cmip-hf.c"
59 /* Initialize the subtree pointers */
60 static gint ett_cmip = -1;
61 #include "packet-cmip-ett.c"
63 static expert_field ei_wrong_spdu_type = EI_INIT;
65 static guint32 opcode;
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 const char *object_identifier_id;
80 #include "packet-cmip-val.h"
81 #include "packet-cmip-fn.c"
86 /* XXX this one should be broken out later and moved into the conformance file */
88 dissect_cmip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void* data)
90 struct SESSION_DATA_STRUCTURE* session;
94 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
96 /* Reject the packet if data is NULL */
99 session = (struct SESSION_DATA_STRUCTURE*)data;
101 if(session->spdu_type == 0 ) {
102 proto_tree_add_expert_format(parent_tree, pinfo, &ei_wrong_spdu_type, tvb, 0, -1,
103 "Internal error: wrong spdu type %x from session dissector.", session->spdu_type);
107 asn1_ctx.private_data = session;
109 item = proto_tree_add_item(parent_tree, proto_cmip, tvb, 0, -1, ENC_NA);
110 tree = proto_item_add_subtree(item, ett_cmip);
112 col_set_str(pinfo->cinfo, COL_PROTOCOL, "CMIP");
113 col_clear(pinfo->cinfo, COL_INFO);
114 switch(session->spdu_type){
115 case SES_CONNECTION_REQUEST:
116 case SES_CONNECTION_ACCEPT:
120 dissect_cmip_CMIPUserInfo(FALSE,tvb,0,&asn1_ctx,tree,-1);
123 dissect_cmip_CMIPAbortInfo(FALSE,tvb,0,&asn1_ctx,tree,-1);
125 case SES_DATA_TRANSFER:
126 dissect_cmip_ROS(FALSE,tvb,0,&asn1_ctx,tree,-1);
132 return tvb_captured_length(tvb);
135 /*--- proto_register_cmip ----------------------------------------------*/
136 void proto_register_cmip(void) {
139 static hf_register_info hf[] = {
140 { &hf_cmip_actionType_OID,
141 { "actionType", "cmip.actionType_OID",
142 FT_STRING, BASE_NONE, NULL, 0,
144 { &hf_cmip_eventType_OID,
145 { "eventType", "cmip.eventType_OID",
146 FT_STRING, BASE_NONE, NULL, 0,
148 { &hf_cmip_attributeId_OID,
149 { "attributeId", "cmip.attributeId_OID",
150 FT_STRING, BASE_NONE, NULL, 0,
152 { &hf_cmip_errorId_OID,
153 { "errorId", "cmip.errorId_OID",
154 FT_STRING, BASE_NONE, NULL, 0,
156 { &hf_DiscriminatorConstruct,
157 { "DiscriminatorConstruct", "cmip.DiscriminatorConstruct",
158 FT_UINT32, BASE_DEC, NULL, 0,
161 { "Destination", "cmip.Destination",
162 FT_UINT32, BASE_DEC, NULL, 0,
165 { "NameBinding", "cmip.NameBinding",
166 FT_STRING, BASE_NONE, NULL, 0,
169 { "ObjectClass", "cmip.ObjectClass",
170 FT_UINT32, BASE_DEC, VALS(cmip_ObjectClass_vals), 0,
173 #include "packet-cmip-hfarr.c"
176 /* List of subtrees */
177 static gint *ett[] = {
179 #include "packet-cmip-ettarr.c"
182 static ei_register_info ei[] = {
183 { &ei_wrong_spdu_type, { "cmip.wrong_spdu_type", PI_PROTOCOL, PI_ERROR, "Internal error: wrong spdu type", EXPFILL }},
186 expert_module_t* expert_cmip;
188 /* Register protocol */
189 proto_cmip = proto_register_protocol(PNAME, PSNAME, PFNAME);
190 register_dissector("cmip", dissect_cmip, proto_cmip);
192 /* Register fields and subtrees */
193 proto_register_field_array(proto_cmip, hf, array_length(hf));
194 proto_register_subtree_array(ett, array_length(ett));
195 expert_cmip = expert_register_protocol(proto_cmip);
196 expert_register_field_array(expert_cmip, ei, array_length(ei));
198 #include "packet-cmip-dis-tab.c"
199 oid_add_from_string("discriminatorId(1)","2.9.3.2.7.1");
201 attribute_id_dissector_table = register_dissector_table("cmip.attribute_id", "CMIP Attribute Id", FT_UINT32, BASE_DEC, DISSECTOR_TABLE_NOT_ALLOW_DUPLICATE);
206 /*--- proto_reg_handoff_cmip -------------------------------------------*/
207 void proto_reg_handoff_cmip(void) {
208 dissector_handle_t cmip_handle = find_dissector("cmip");
210 register_ber_oid_dissector_handle("2.9.0.0.2", cmip_handle, proto_cmip, "cmip");
211 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)");
213 oid_add_from_string("2.9.3.2.3.1","managedObjectClass(3) alarmRecord(1)");
214 oid_add_from_string("2.9.3.2.3.2","managedObjectClass(3) attributeValueChangeRecord(2)");
215 oid_add_from_string("2.9.3.2.3.3","managedObjectClass(3) discriminator(3)");
216 oid_add_from_string("2.9.3.2.3.4","managedObjectClass(3) eventForwardingDiscriminator(4)");
217 oid_add_from_string("2.9.3.2.3.5","managedObjectClass(3) eventLogRecord(5)");
218 oid_add_from_string("2.9.3.2.3.6","managedObjectClass(3) log(6)");
219 oid_add_from_string("2.9.3.2.3.7","managedObjectClass(3) logRecord(7)");
220 oid_add_from_string("2.9.3.2.3.8","managedObjectClass(3) objectCreationRecord(8)");
221 oid_add_from_string("2.9.3.2.3.9","managedObjectClass(3) objectDeletionRecord(9)");
222 oid_add_from_string("2.9.3.2.3.10","managedObjectClass(3) relationshipChangeRecord(10)");
223 oid_add_from_string("2.9.3.2.3.11","managedObjectClass(3) securityAlarmReportRecord(11)");
224 oid_add_from_string("2.9.3.2.3.12","managedObjectClass(3) stateChangeRecord(12)");
225 oid_add_from_string("2.9.3.2.3.13","managedObjectClass(3) system(13)");
226 oid_add_from_string("2.9.3.2.3.14","managedObjectClass(3) top(14)");
227 oid_add_from_string("2.9.3.2.4.14","administrativeStatePackage(14)");
228 oid_add_from_string("2.9.1.1.4","joint-iso-itu-t(2) ms(9) cmip(1) cmip-pci(1) abstractSyntax(4)");
230 /*#include "packet-cmip-dis-tab.c" */