2 * Routines for X.518 (X.500 Distributed Operations) 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/oids.h>
34 #include <epan/asn1.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 dissector_handle_t tpkt_handle;
56 void prefs_register_dsp(void); /* forward declaration for use in preferences registration */
59 /* Initialize the protocol and registered fields */
60 static int proto_dsp = -1;
62 static struct SESSION_DATA_STRUCTURE* session = NULL;
64 #include "packet-dsp-hf.c"
66 /* Initialize the subtree pointers */
67 static gint ett_dsp = -1;
68 #include "packet-dsp-ett.c"
70 #include "packet-dsp-fn.c"
73 * Dissect X518 PDUs inside a ROS PDUs
76 dissect_dsp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
80 proto_item *item=NULL;
81 proto_tree *tree=NULL;
82 int (*dsp_dissector)(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, asn1_ctx_t *actx, proto_tree *tree, int hf_index _U_) = NULL;
86 asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
88 /* do we have operation information from the ROS dissector? */
89 if( !pinfo->private_data ){
91 proto_tree_add_text(parent_tree, tvb, offset, -1,
92 "Internal error: can't get operation information from ROS dissector.");
96 session = ( (struct SESSION_DATA_STRUCTURE*)(pinfo->private_data) );
100 item = proto_tree_add_item(parent_tree, proto_dsp, tvb, 0, -1, FALSE);
101 tree = proto_item_add_subtree(item, ett_dsp);
103 col_set_str(pinfo->cinfo, COL_PROTOCOL, "DAP");
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 col_set_str(pinfo->cinfo, COL_INFO, dsp_op_name);
257 while (tvb_reported_length_remaining(tvb, offset) > 0){
259 offset=(*dsp_dissector)(FALSE, tvb, offset, &asn1_ctx, tree, -1);
260 if(offset == old_offset){
261 proto_tree_add_text(tree, tvb, offset, -1,"Internal error, zero-byte DSP PDU");
269 /*--- proto_register_dsp -------------------------------------------*/
270 void proto_register_dsp(void) {
273 static hf_register_info hf[] =
275 #include "packet-dsp-hfarr.c"
278 /* List of subtrees */
279 static gint *ett[] = {
281 #include "packet-dsp-ettarr.c"
283 module_t *dsp_module;
285 /* Register protocol */
286 proto_dsp = proto_register_protocol(PNAME, PSNAME, PFNAME);
288 register_dissector("dsp", dissect_dsp, proto_dsp);
290 /* Register fields and subtrees */
291 proto_register_field_array(proto_dsp, hf, array_length(hf));
292 proto_register_subtree_array(ett, array_length(ett));
294 /* Register our configuration options for DSP, particularly our port */
296 dsp_module = prefs_register_protocol_subtree("OSI/X.500", proto_dsp, prefs_register_dsp);
298 prefs_register_uint_preference(dsp_module, "tcp.port", "DSP TCP Port",
299 "Set the port for DSP operations (if other"
300 " than the default of 102)",
301 10, &global_dsp_tcp_port);
307 /*--- proto_reg_handoff_dsp --- */
308 void proto_reg_handoff_dsp(void) {
309 dissector_handle_t dsp_handle;
311 #include "packet-dsp-dis-tab.c"
313 /* APPLICATION CONTEXT */
315 oid_add_from_string("id-ac-directory-system","2.5.3.2");
317 /* ABSTRACT SYNTAXES */
319 /* remember the tpkt handler for change in preferences */
320 tpkt_handle = find_dissector("tpkt");
322 /* Register DSP with ROS (with no use of RTSE) */
323 dsp_handle = find_dissector("dsp");
324 register_ros_oid_dissector_handle("2.5.9.2", dsp_handle, 0, "id-as-directory-system", FALSE);
328 void prefs_register_dsp(void) {
329 static guint tcp_port = 0;
331 /* de-register the old port */
332 /* port 102 is registered by TPKT - don't undo this! */
333 if((tcp_port > 0) && (tcp_port != 102) && tpkt_handle)
334 dissector_delete("tcp.port", tcp_port, tpkt_handle);
336 /* Set our port number for future use */
337 tcp_port = global_dsp_tcp_port;
339 if((tcp_port > 0) && (tcp_port != 102) && tpkt_handle)
340 dissector_add("tcp.port", global_dsp_tcp_port, tpkt_handle);