2 * Routines for X.501 (DSA Operational Attributes) packet dissection
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #include <epan/packet.h>
32 #include <epan/prefs.h>
33 #include <epan/conversation.h>
38 #include "packet-ber.h"
39 #include "packet-acse.h"
40 #include "packet-ros.h"
42 #include "packet-x509sat.h"
43 #include "packet-x509af.h"
44 #include "packet-x509if.h"
45 #include "packet-dap.h"
46 #include "packet-dsp.h"
47 #include "packet-crmf.h"
50 #include "packet-dop.h"
52 #define PNAME "X.501 Directory Operational Binding Management Protocol"
56 static guint global_dop_tcp_port = 102;
57 static guint tcp_port = 0;
58 static dissector_handle_t tpkt_handle = NULL;
59 void prefs_register_dop(void); /* forwad declaration for use in preferences registration */
61 /* Initialize the protocol and registered fields */
64 static struct SESSION_DATA_STRUCTURE* session = NULL;
65 static const char *binding_type = NULL; /* binding_type */
67 static int call_dop_oid_callback(char *base_oid, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *col_info);
69 #include "packet-dop-hf.c"
71 /* Initialize the subtree pointers */
72 static gint ett_dop = -1;
73 #include "packet-dop-ett.c"
75 #include "packet-dop-fn.c"
78 call_dop_oid_callback(char *base_oid, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, char *col_info)
80 char binding_param[BER_MAX_OID_STR_LEN];
82 g_snprintf(binding_param, BER_MAX_OID_STR_LEN, "%s.%s", base_oid, binding_type ? binding_type : "");
84 if (col_info && (check_col(pinfo->cinfo, COL_INFO)))
85 col_append_fstr(pinfo->cinfo, COL_INFO, " %s", col_info);
87 return call_ber_oid_callback(binding_param, tvb, offset, pinfo, tree);
92 * Dissect DOP PDUs inside a ROS PDUs
95 dissect_dop(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
99 proto_item *item=NULL;
100 proto_tree *tree=NULL;
101 int (*dop_dissector)(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) = NULL;
104 /* do we have operation information from the ROS dissector? */
105 if( !pinfo->private_data ){
107 proto_tree_add_text(parent_tree, tvb, offset, -1,
108 "Internal error: can't get operation information from ROS dissector.");
112 session = ( (struct SESSION_DATA_STRUCTURE*)(pinfo->private_data) );
116 item = proto_tree_add_item(parent_tree, proto_dop, tvb, 0, -1, FALSE);
117 tree = proto_item_add_subtree(item, ett_dop);
119 if (check_col(pinfo->cinfo, COL_PROTOCOL))
120 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DOP");
121 if (check_col(pinfo->cinfo, COL_INFO))
122 col_clear(pinfo->cinfo, COL_INFO);
124 switch(session->ros_op & ROS_OP_MASK) {
125 case (ROS_OP_BIND | ROS_OP_ARGUMENT): /* BindInvoke */
126 dop_dissector = dissect_dop_DSAOperationalManagementBindArgument;
127 dop_op_name = "DSA-Operational-Bind-Argument";
129 case (ROS_OP_BIND | ROS_OP_RESULT): /* BindResult */
130 dop_dissector = dissect_dop_DSAOperationalManagementBindResult;
131 dop_op_name = "DSA-Operational-Bind-Result";
133 case (ROS_OP_BIND | ROS_OP_ERROR): /* BindError */
134 dop_dissector = dissect_dop_DSAOperationalManagementBindError;
135 dop_op_name = "DSA-Operational-Management-Bind-Error";
137 case (ROS_OP_INVOKE | ROS_OP_ARGUMENT): /* Invoke Argument */
138 switch(session->ros_op & ROS_OP_OPCODE_MASK) {
139 case 100: /* establish */
140 dop_dissector = dissect_dop_EstablishOperationalBindingArgument;
141 dop_op_name = "Establish-Operational-Binding-Argument";
143 case 101: /* terminate */
144 dop_dissector = dissect_dop_TerminateOperationalBindingArgument;
145 dop_op_name = "Terminate-Operational-Binding-Argument";
147 case 102: /* modify */
148 dop_dissector = dissect_dop_ModifyOperationalBindingArgument;
149 dop_op_name = "Modify-Operational-Binding-Argument";
152 proto_tree_add_text(tree, tvb, offset, -1,"Unsupported DOP Argument opcode (%d)",
153 session->ros_op & ROS_OP_OPCODE_MASK);
157 case (ROS_OP_INVOKE | ROS_OP_RESULT): /* Return Result */
158 switch(session->ros_op & ROS_OP_OPCODE_MASK) {
159 case 100: /* establish */
160 dop_dissector = dissect_dop_EstablishOperationalBindingResult;
161 dop_op_name = "Establish-Operational-Binding-Result";
163 case 101: /* terminate */
164 dop_dissector = dissect_dop_TerminateOperationalBindingResult;
165 dop_op_name = "Terminate-Operational-Binding-Result";
167 case 102: /* modify */
168 dop_dissector = dissect_dop_ModifyOperationalBindingResult;
169 dop_op_name = "Modify-Operational-Binding-Result";
172 proto_tree_add_text(tree, tvb, offset, -1,"Unsupported DOP Result opcode (%d)",
173 session->ros_op & ROS_OP_OPCODE_MASK);
177 case (ROS_OP_INVOKE | ROS_OP_ERROR): /* Return Error */
178 switch(session->ros_op & ROS_OP_OPCODE_MASK) {
179 case 100: /* operational-binding */
180 dop_dissector = dissect_dop_OpBindingErrorParam;
181 dop_op_name = "Operational-Binding-Error";
184 proto_tree_add_text(tree, tvb, offset, -1,"Unsupported DOP Error opcode (%d)",
185 session->ros_op & ROS_OP_OPCODE_MASK);
190 proto_tree_add_text(tree, tvb, offset, -1,"Unsupported DOP PDU");
195 if (check_col(pinfo->cinfo, COL_INFO))
196 col_add_str(pinfo->cinfo, COL_INFO, dop_op_name);
198 while (tvb_reported_length_remaining(tvb, offset) > 0){
200 offset=(*dop_dissector)(FALSE, tvb, offset, pinfo , tree, -1);
201 if(offset == old_offset){
202 proto_tree_add_text(tree, tvb, offset, -1,"Internal error, zero-byte DOP PDU");
203 offset = tvb_length(tvb);
212 /*--- proto_register_dop -------------------------------------------*/
213 void proto_register_dop(void) {
216 static hf_register_info hf[] =
218 #include "packet-dop-hfarr.c"
221 /* List of subtrees */
222 static gint *ett[] = {
224 #include "packet-dop-ettarr.c"
227 module_t *dop_module;
229 /* Register protocol */
230 proto_dop = proto_register_protocol(PNAME, PSNAME, PFNAME);
232 register_dissector("dop", dissect_dop, proto_dop);
234 /* Register fields and subtrees */
235 proto_register_field_array(proto_dop, hf, array_length(hf));
236 proto_register_subtree_array(ett, array_length(ett));
238 /* Register our configuration options for DOP, particularly our port */
240 #ifdef PREFERENCE_GROUPING
241 dop_module = prefs_register_protocol_subtree("OSI/X.500", proto_dop, prefs_register_dop);
243 dop_module = prefs_register_protocol(proto_dop, prefs_register_dop);
246 prefs_register_uint_preference(dop_module, "tcp.port", "DOP TCP Port",
247 "Set the port for DOP operations (if other"
248 " than the default of 102)",
249 10, &global_dop_tcp_port);
255 /*--- proto_reg_handoff_dop --- */
256 void proto_reg_handoff_dop(void) {
257 dissector_handle_t handle = NULL;
259 #include "packet-dop-dis-tab.c"
260 /* APPLICATION CONTEXT */
262 register_ber_oid_name("2.5.3.3", "id-ac-directory-operational-binding-management");
264 /* ABSTRACT SYNTAXES */
266 /* Register DOP with ROS (with no use of RTSE) */
267 if((handle = find_dissector("dop"))) {
268 register_ros_oid_dissector_handle("2.5.9.4", handle, 0, "id-as-directory-operational-binding-management", FALSE);
273 register_ber_oid_name("2.5.19.1", "shadow-agreement");
274 register_ber_oid_name("2.5.19.2", "hierarchical-agreement");
275 register_ber_oid_name("2.5.19.3", "non-specific-hierarchical-agreement");
277 /* ACCESS CONTROL SCHEMES */
278 register_ber_oid_name("2.5.28.1", "basic-ACS");
279 register_ber_oid_name("2.5.28.2", "simplified-ACS");
280 register_ber_oid_name("2.5.28.3", "ruleBased-ACS");
281 register_ber_oid_name("2.5.28.4", "ruleAndBasic-ACS");
282 register_ber_oid_name("2.5.28.5", "ruleAndSimple-ACS");
284 /* ADMINISTRATIVE ROLES */
285 register_ber_oid_name("2.5.23.1", "id-ar-autonomousArea");
286 register_ber_oid_name("2.5.23.2", "id-ar-accessControlSpecificArea");
287 register_ber_oid_name("2.5.23.3", "id-ar-accessControlInnerArea");
288 register_ber_oid_name("2.5.23.4", "id-ar-subschemaAdminSpecificArea");
289 register_ber_oid_name("2.5.23.5", "id-ar-collectiveAttributeSpecificArea");
290 register_ber_oid_name("2.5.23.6", "id-ar-collectiveAttributeInnerArea");
291 register_ber_oid_name("2.5.23.7", "id-ar-contextDefaultSpecificArea");
292 register_ber_oid_name("2.5.23.8", "id-ar-serviceSpecificArea");
294 /* remember the tpkt handler for change in preferences */
295 tpkt_handle = find_dissector("tpkt");
299 void prefs_register_dop(void) {
301 /* de-register the old port */
302 /* port 102 is registered by TPKT - don't undo this! */
303 if((tcp_port != 102) && tpkt_handle)
304 dissector_delete("tcp.port", tcp_port, tpkt_handle);
306 /* Set our port number for future use */
307 tcp_port = global_dop_tcp_port;
309 if((tcp_port > 0) && (tcp_port != 102) && tpkt_handle)
310 dissector_add("tcp.port", global_dop_tcp_port, tpkt_handle);