2 * Routines for X.511 (X.500 Directory Asbtract Service) and X.519 DAP 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/prefs.h>
28 #include <epan/expert.h>
29 #include <epan/oids.h>
30 #include <epan/asn1.h>
32 #include "packet-ber.h"
33 #include "packet-acse.h"
34 #include "packet-ros.h"
35 #include "packet-idmp.h"
37 #include "packet-x509if.h"
38 #include "packet-x509af.h"
39 #include "packet-x509sat.h"
40 #include "packet-crmf.h"
42 #include "packet-dsp.h"
43 #include "packet-disp.h"
44 #include "packet-dap.h"
45 #include <epan/strutil.h>
47 /* we don't have a separate dissector for X519 -
48 most of DAP is defined in X511 */
49 #define PNAME "X.519 Directory Access Protocol"
53 void proto_register_dap(void);
54 void proto_reg_handoff_dap(void);
56 static guint global_dap_tcp_port = 102;
57 static dissector_handle_t tpkt_handle;
58 static void prefs_register_dap(void); /* forward declaration for use in preferences registration */
61 /* Initialize the protocol and registered fields */
62 static int proto_dap = -1;
65 #include "packet-dap-hf.c"
67 /* Initialize the subtree pointers */
68 static gint ett_dap = -1;
69 #include "packet-dap-ett.c"
71 static expert_field ei_dap_anonymous = EI_INIT;
73 #include "packet-dap-val.h"
75 #include "packet-dap-table.c" /* operation and error codes */
77 #include "packet-dap-fn.c"
79 #include "packet-dap-table11.c" /* operation argument/result dissectors */
80 #include "packet-dap-table21.c" /* error dissector */
82 static const ros_info_t dap_ros_info = {
86 dap_opr_code_string_vals,
88 dap_err_code_string_vals,
93 /*--- proto_register_dap -------------------------------------------*/
94 void proto_register_dap(void) {
97 static hf_register_info hf[] =
99 #include "packet-dap-hfarr.c"
102 /* List of subtrees */
103 static gint *ett[] = {
105 #include "packet-dap-ettarr.c"
108 static ei_register_info ei[] = {
109 { &ei_dap_anonymous, { "dap.anonymous", PI_PROTOCOL, PI_NOTE, "Anonymous", EXPFILL }},
112 module_t *dap_module;
113 expert_module_t* expert_dap;
115 /* Register protocol */
116 proto_dap = proto_register_protocol(PNAME, PSNAME, PFNAME);
118 /* Register fields and subtrees */
119 proto_register_field_array(proto_dap, hf, array_length(hf));
120 proto_register_subtree_array(ett, array_length(ett));
121 expert_dap = expert_register_protocol(proto_dap);
122 expert_register_field_array(expert_dap, ei, array_length(ei));
124 /* Register our configuration options for DAP, particularly our port */
126 dap_module = prefs_register_protocol_subtree("OSI/X.500", proto_dap, prefs_register_dap);
128 prefs_register_uint_preference(dap_module, "tcp.port", "DAP TCP Port",
129 "Set the port for DAP operations (if other"
130 " than the default of 102)",
131 10, &global_dap_tcp_port);
136 /*--- proto_reg_handoff_dap --- */
137 void proto_reg_handoff_dap(void) {
139 /* #include "packet-dap-dis-tab.c" */
141 /* APPLICATION CONTEXT */
143 oid_add_from_string("id-ac-directory-access","2.5.3.1");
145 /* ABSTRACT SYNTAXES */
147 /* Register DAP with ROS (with no use of RTSE) */
148 register_ros_protocol_info("2.5.9.1", &dap_ros_info, 0, "id-as-directory-access", FALSE);
150 register_idmp_protocol_info("2.5.33.0", &dap_ros_info, 0, "dap-ip");
152 /* remember the tpkt handler for change in preferences */
153 tpkt_handle = find_dissector("tpkt");
155 /* AttributeValueAssertions */
156 x509if_register_fmt(hf_dap_equality, "=");
157 x509if_register_fmt(hf_dap_greaterOrEqual, ">=");
158 x509if_register_fmt(hf_dap_lessOrEqual, "<=");
159 x509if_register_fmt(hf_dap_approximateMatch, "=~");
161 x509if_register_fmt(hf_dap_present, "= *");
167 prefs_register_dap(void)
169 static guint tcp_port = 0;
171 /* de-register the old port */
172 /* port 102 is registered by TPKT - don't undo this! */
173 if((tcp_port > 0) && (tcp_port != 102) && tpkt_handle)
174 dissector_delete_uint("tcp.port", tcp_port, tpkt_handle);
176 /* Set our port number for future use */
177 tcp_port = global_dap_tcp_port;
179 if((tcp_port > 0) && (tcp_port != 102) && tpkt_handle)
180 dissector_add_uint("tcp.port", global_dap_tcp_port, tpkt_handle);