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 * SPDX-License-Identifier: GPL-2.0-or-later
14 #include <epan/packet.h>
15 #include <epan/expert.h>
16 #include <epan/oids.h>
17 #include <epan/asn1.h>
18 #include <epan/proto_data.h>
19 #include <wsutil/array.h>
20 #include "packet-ber.h"
21 #include "packet-acse.h"
22 #include "packet-x509if.h"
23 #include "packet-cmip.h"
25 #define PNAME "X711 CMIP"
29 void proto_register_cmip(void);
30 void proto_reg_handoff_cmip(void);
32 /* XXX some stuff we need until we can get rid of it */
33 #include "packet-ses.h"
34 #include "packet-pres.h"
36 /* Initialize the protocol and registered fields */
37 static int proto_cmip
;
38 static int hf_cmip_actionType_OID
;
39 static int hf_cmip_eventType_OID
;
40 static int hf_cmip_attributeId_OID
;
41 static int hf_cmip_errorId_OID
;
43 #include "packet-cmip-hf.c"
45 /* Initialize the subtree pointers */
47 #include "packet-cmip-ett.c"
49 static expert_field ei_wrong_spdu_type
;
51 static uint32_t opcode
;
53 static dissector_handle_t cmip_handle
;
56 static dissector_table_t attribute_id_dissector_table
;
58 #include "packet-cmip-table.c"
60 static int opcode_type
;
61 #define OPCODE_INVOKE 1
62 #define OPCODE_RETURN_RESULT 2
63 #define OPCODE_RETURN_ERROR 3
64 #define OPCODE_REJECT 4
66 static const char *object_identifier_id
;
68 #include "packet-cmip-val.h"
69 #include "packet-cmip-fn.c"
74 /* XXX this one should be broken out later and moved into the conformance file */
76 dissect_cmip(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*parent_tree
, void* data
)
78 struct SESSION_DATA_STRUCTURE
* session
;
82 asn1_ctx_init(&asn1_ctx
, ASN1_ENC_BER
, true, pinfo
);
84 /* Reject the packet if data is NULL */
87 session
= (struct SESSION_DATA_STRUCTURE
*)data
;
89 if(session
->spdu_type
== 0 ) {
90 proto_tree_add_expert_format(parent_tree
, pinfo
, &ei_wrong_spdu_type
, tvb
, 0, -1,
91 "Internal error: wrong spdu type %x from session dissector.", session
->spdu_type
);
95 asn1_ctx
.private_data
= session
;
97 item
= proto_tree_add_item(parent_tree
, proto_cmip
, tvb
, 0, -1, ENC_NA
);
98 tree
= proto_item_add_subtree(item
, ett_cmip
);
100 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "CMIP");
101 col_clear(pinfo
->cinfo
, COL_INFO
);
102 switch(session
->spdu_type
){
103 case SES_CONNECTION_REQUEST
:
104 case SES_CONNECTION_ACCEPT
:
108 dissect_cmip_CMIPUserInfo(false,tvb
,0,&asn1_ctx
,tree
,-1);
111 dissect_cmip_CMIPAbortInfo(false,tvb
,0,&asn1_ctx
,tree
,-1);
113 case SES_DATA_TRANSFER
:
114 dissect_cmip_ROS(false,tvb
,0,&asn1_ctx
,tree
,-1);
120 return tvb_captured_length(tvb
);
123 /*--- proto_register_cmip ----------------------------------------------*/
124 void proto_register_cmip(void) {
127 static hf_register_info hf
[] = {
128 { &hf_cmip_actionType_OID
,
129 { "actionType", "cmip.actionType_OID",
130 FT_STRING
, BASE_NONE
, NULL
, 0,
132 { &hf_cmip_eventType_OID
,
133 { "eventType", "cmip.eventType_OID",
134 FT_STRING
, BASE_NONE
, NULL
, 0,
136 { &hf_cmip_attributeId_OID
,
137 { "attributeId", "cmip.attributeId_OID",
138 FT_STRING
, BASE_NONE
, NULL
, 0,
140 { &hf_cmip_errorId_OID
,
141 { "errorId", "cmip.errorId_OID",
142 FT_STRING
, BASE_NONE
, NULL
, 0,
145 #include "packet-cmip-hfarr.c"
148 /* List of subtrees */
149 static int *ett
[] = {
151 #include "packet-cmip-ettarr.c"
154 static ei_register_info ei
[] = {
155 { &ei_wrong_spdu_type
, { "cmip.wrong_spdu_type", PI_PROTOCOL
, PI_ERROR
, "Internal error: wrong spdu type", EXPFILL
}},
158 expert_module_t
* expert_cmip
;
160 /* Register protocol */
161 proto_cmip
= proto_register_protocol(PNAME
, PSNAME
, PFNAME
);
162 cmip_handle
= register_dissector("cmip", dissect_cmip
, proto_cmip
);
164 /* Register fields and subtrees */
165 proto_register_field_array(proto_cmip
, hf
, array_length(hf
));
166 proto_register_subtree_array(ett
, array_length(ett
));
167 expert_cmip
= expert_register_protocol(proto_cmip
);
168 expert_register_field_array(expert_cmip
, ei
, array_length(ei
));
170 #include "packet-cmip-dis-tab.c"
171 oid_add_from_string("discriminatorId(1)","2.9.3.2.7.1");
173 attribute_id_dissector_table
= register_dissector_table("cmip.attribute_id", "CMIP Attribute Id", proto_cmip
, FT_UINT32
, BASE_DEC
);
178 /*--- proto_reg_handoff_cmip -------------------------------------------*/
179 void proto_reg_handoff_cmip(void) {
180 register_ber_oid_dissector_handle("2.9.0.0.2", cmip_handle
, proto_cmip
, "cmip");
181 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)");
183 oid_add_from_string("2.9.3.2.3.1","managedObjectClass(3) alarmRecord(1)");
184 oid_add_from_string("2.9.3.2.3.2","managedObjectClass(3) attributeValueChangeRecord(2)");
185 oid_add_from_string("2.9.3.2.3.3","managedObjectClass(3) discriminator(3)");
186 oid_add_from_string("2.9.3.2.3.4","managedObjectClass(3) eventForwardingDiscriminator(4)");
187 oid_add_from_string("2.9.3.2.3.5","managedObjectClass(3) eventLogRecord(5)");
188 oid_add_from_string("2.9.3.2.3.6","managedObjectClass(3) log(6)");
189 oid_add_from_string("2.9.3.2.3.7","managedObjectClass(3) logRecord(7)");
190 oid_add_from_string("2.9.3.2.3.8","managedObjectClass(3) objectCreationRecord(8)");
191 oid_add_from_string("2.9.3.2.3.9","managedObjectClass(3) objectDeletionRecord(9)");
192 oid_add_from_string("2.9.3.2.3.10","managedObjectClass(3) relationshipChangeRecord(10)");
193 oid_add_from_string("2.9.3.2.3.11","managedObjectClass(3) securityAlarmReportRecord(11)");
194 oid_add_from_string("2.9.3.2.3.12","managedObjectClass(3) stateChangeRecord(12)");
195 oid_add_from_string("2.9.3.2.3.13","managedObjectClass(3) system(13)");
196 oid_add_from_string("2.9.3.2.3.14","managedObjectClass(3) top(14)");
197 oid_add_from_string("2.9.3.2.4.14","administrativeStatePackage(14)");
198 oid_add_from_string("2.9.1.1.4","joint-iso-itu-t(2) ms(9) cmip(1) cmip-pci(1) abstractSyntax(4)");
200 /*#include "packet-cmip-dis-tab.c" */