2 * Routines for X.518 (X.500 Distributed Operations) packet dissection
7 * Ethereal - Network traffic analyzer
8 * By Gerald Combs <gerald@ethereal.com>
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-x509if.h"
43 #include "packet-x509af.h"
44 #include "packet-x509sat.h"
46 #include "packet-dap.h"
47 #include "packet-dsp.h"
50 #define PNAME "X.519 Directory System Protocol"
54 static guint global_dsp_tcp_port = 102;
55 static guint tcp_port = 0;
56 static dissector_handle_t tpkt_handle = NULL;
57 void prefs_register_dsp(void); /* forwad declaration for use in preferences registration */
60 /* Initialize the protocol and registered fields */
63 static struct SESSION_DATA_STRUCTURE* session = NULL;
65 #include "packet-dsp-hf.c"
67 /* Initialize the subtree pointers */
68 static gint ett_dsp = -1;
69 #include "packet-dsp-ett.c"
71 #include "packet-dsp-fn.c"
74 * Dissect X518 PDUs inside a ROS PDUs
77 dissect_dsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
81 proto_item *item=NULL;
82 proto_tree *tree=NULL;
83 int (*dsp_dissector)(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) = NULL;
86 /* do we have operation information from the ROS dissector? */
87 if( !pinfo->private_data ){
89 proto_tree_add_text(parent_tree, tvb, offset, -1,
90 "Internal error: can't get operation information from ROS dissector.");
94 session = ( (struct SESSION_DATA_STRUCTURE*)(pinfo->private_data) );
98 item = proto_tree_add_item(parent_tree, proto_dsp, tvb, 0, -1, FALSE);
99 tree = proto_item_add_subtree(item, ett_dsp);
101 if (check_col(pinfo->cinfo, COL_PROTOCOL))
102 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DAP");
103 if (check_col(pinfo->cinfo, COL_INFO))
104 col_clear(pinfo->cinfo, COL_INFO);
106 switch(session->ros_op & ROS_OP_MASK) {
107 case (ROS_OP_BIND | ROS_OP_ARGUMENT): /* BindInvoke */
108 dsp_dissector = dissect_dsp_DSASystemBindArgument;
109 dsp_op_name = "System-Bind-Argument";
111 case (ROS_OP_BIND | ROS_OP_RESULT): /* BindResult */
112 dsp_dissector = dissect_dsp_DSASystemBindResult;
113 dsp_op_name = "System-Bind-Result";
115 case (ROS_OP_BIND | ROS_OP_ERROR): /* BindError */
116 dsp_dissector = dissect_dsp_DSASystemBindError;
117 dsp_op_name = "System-Bind-Error";
119 case (ROS_OP_INVOKE | ROS_OP_ARGUMENT): /* Invoke Argument */
120 switch(session->ros_op & ROS_OP_OPCODE_MASK) {
122 dsp_dissector = dissect_dsp_ChainedReadArgument;
123 dsp_op_name = "Chained-Read-Argument";
125 case 2: /* compare */
126 dsp_dissector = dissect_dsp_ChainedCompareArgument;
127 dsp_op_name = "Chained-Compare-Argument";
129 case 3: /* abandon */
130 dsp_dissector = dissect_dsp_ChainedAbandonArgument;
131 dsp_op_name = "Chained-Abandon-Argument";
134 dsp_dissector = dissect_dsp_ChainedListArgument;
135 dsp_op_name = "Chained-List-Argument";
138 dsp_dissector = dissect_dsp_ChainedSearchArgument;
139 dsp_op_name = "Chained-Search-Argument";
141 case 6: /* addEntry */
142 dsp_dissector = dissect_dsp_ChainedAddEntryArgument;
143 dsp_op_name = "Chained-Add-Entry-Argument";
145 case 7: /* removeEntry */
146 dsp_dissector = dissect_dsp_ChainedRemoveEntryArgument;
147 dsp_op_name = "Chained-Remove-Entry-Argument";
149 case 8: /* modifyEntry */
150 dsp_dissector = dissect_dsp_ChainedModifyEntryArgument;
151 dsp_op_name = "ChainedModify-Entry-Argument";
153 case 9: /* modifyDN */
154 dsp_dissector = dissect_dsp_ChainedModifyDNArgument;
155 dsp_op_name = "ChainedModify-DN-Argument";
158 proto_tree_add_text(tree, tvb, offset, -1,"Unsupported DSP opcode (%d)",
159 session->ros_op & ROS_OP_OPCODE_MASK);
163 case (ROS_OP_INVOKE | ROS_OP_RESULT): /* Return Result */
164 switch(session->ros_op & ROS_OP_OPCODE_MASK) {
166 dsp_dissector = dissect_dsp_ChainedReadResult;
167 dsp_op_name = "Chained-Read-Result";
169 case 2: /* compare */
170 dsp_dissector = dissect_dsp_ChainedCompareResult;
171 dsp_op_name = "Chained-Compare-Result";
173 case 3: /* abandon */
174 dsp_dissector = dissect_dsp_ChainedAbandonResult;
175 dsp_op_name = "Chained-Abandon-Result";
178 dsp_dissector = dissect_dsp_ChainedListResult;
179 dsp_op_name = "Chained-List-Result";
182 dsp_dissector = dissect_dsp_ChainedSearchResult;
183 dsp_op_name = "Chained-Search-Result";
185 case 6: /* addEntry */
186 dsp_dissector = dissect_dsp_ChainedAddEntryResult;
187 dsp_op_name = "Chained-Add-Entry-Result";
189 case 7: /* removeEntry */
190 dsp_dissector = dissect_dsp_ChainedRemoveEntryResult;
191 dsp_op_name = "Chained-Remove-Entry-Result";
193 case 8: /* modifyEntry */
194 dsp_dissector = dissect_dsp_ChainedModifyEntryResult;
195 dsp_op_name = "Chained-Modify-Entry-Result";
197 case 9: /* modifyDN */
198 dsp_dissector = dissect_dsp_ChainedModifyDNResult;
199 dsp_op_name = "ChainedModify-DN-Result";
202 proto_tree_add_text(tree, tvb, offset, -1,"Unsupported DSP opcode");
206 case (ROS_OP_INVOKE | ROS_OP_ERROR): /* Return Error */
207 switch(session->ros_op & ROS_OP_OPCODE_MASK) {
208 case 1: /* attributeError */
209 dsp_dissector = dissect_dap_AttributeError;
210 dsp_op_name = "Attribute-Error";
212 case 2: /* nameError */
213 dsp_dissector = dissect_dap_NameError;
214 dsp_op_name = "Name-Error";
216 case 3: /* serviceError */
217 dsp_dissector = dissect_dap_ServiceError;
218 dsp_op_name = "Service-Error";
220 case 4: /* referral */
221 dsp_dissector = dissect_dap_Referral;
222 dsp_op_name = "Referral";
224 case 5: /* abandoned */
225 dsp_dissector = dissect_dap_Abandoned;
226 dsp_op_name = "Abandoned";
228 case 6: /* securityError */
229 dsp_dissector = dissect_dap_SecurityError;
230 dsp_op_name = "Security-Error";
232 case 7: /* abandonFailed */
233 dsp_dissector = dissect_dap_AbandonFailedError;
234 dsp_op_name = "Abandon-Failed-Error";
236 case 8: /* updateError */
237 dsp_dissector = dissect_dap_UpdateError;
238 dsp_op_name = "Update-Error";
240 case 9: /* DSAReferral */
241 dsp_dissector = dissect_dsp_DSAReferral;
242 dsp_op_name = "DSA-Referral";
245 proto_tree_add_text(tree, tvb, offset, -1,"Unsupported DSP errcode");
250 proto_tree_add_text(tree, tvb, offset, -1,"Unsupported DSP PDU");
255 if (check_col(pinfo->cinfo, COL_INFO))
256 col_add_str(pinfo->cinfo, COL_INFO, dsp_op_name);
258 while (tvb_reported_length_remaining(tvb, offset) > 0){
260 offset=(*dsp_dissector)(FALSE, tvb, offset, pinfo , tree, -1);
261 if(offset == old_offset){
262 proto_tree_add_text(tree, tvb, offset, -1,"Internal error, zero-byte DSP PDU");
263 offset = tvb_length(tvb);
271 /*--- proto_register_dsp -------------------------------------------*/
272 void proto_register_dsp(void) {
275 static hf_register_info hf[] =
277 #include "packet-dsp-hfarr.c"
280 /* List of subtrees */
281 static gint *ett[] = {
283 #include "packet-dsp-ettarr.c"
285 module_t *dsp_module;
287 /* Register protocol */
288 proto_dsp = proto_register_protocol(PNAME, PSNAME, PFNAME);
290 /* initially disable the protocol */
291 proto_set_decoding(proto_dsp, FALSE);
293 register_dissector("dsp", dissect_dsp, proto_dsp);
295 /* Register fields and subtrees */
296 proto_register_field_array(proto_dsp, hf, array_length(hf));
297 proto_register_subtree_array(ett, array_length(ett));
299 /* Register our configuration options for DSP, particularly our port */
301 #ifdef PREFERENCE_GROUPING
302 dsp_module = prefs_register_protocol_subtree("OSI/X.500", proto_dsp, prefs_register_dsp);
304 dsp_module = prefs_register_protocol(proto_dsp, prefs_register_dsp);
307 prefs_register_uint_preference(dsp_module, "tcp.port", "DSP TCP Port",
308 "Set the port for DSP operations (if other"
309 " than the default of 102)",
310 10, &global_dsp_tcp_port);
316 /*--- proto_reg_handoff_dsp --- */
317 void proto_reg_handoff_dsp(void) {
318 dissector_handle_t handle = NULL;
320 #include "packet-dsp-dis-tab.c"
322 /* APPLICATION CONTEXT */
324 register_ber_oid_name("2.5.3.2", "id-ac-directory-system");
326 /* ABSTRACT SYNTAXES */
328 /* Register DSP with ROS (with no use of RTSE) */
329 if((handle = find_dissector("dsp"))) {
330 register_ros_oid_dissector_handle("2.5.9.2", handle, 0, "id-as-directory-system", FALSE);
336 void prefs_register_dsp(void) {
338 /* de-register the old port */
339 /* port 102 is registered by TPKT - don't undo this! */
340 if((tcp_port != 102) && tpkt_handle)
341 dissector_delete("tcp.port", tcp_port, tpkt_handle);
343 /* Set our port number for future use */
344 tcp_port = global_dsp_tcp_port;
346 if((tcp_port > 0) && (tcp_port != 102) && tpkt_handle)
347 dissector_add("tcp.port", global_dsp_tcp_port, tpkt_handle);