1 /* Do not modify this file. */
2 /* It is created automatically by the ASN.1 to Ethereal dissector compiler */
4 /* ../../tools/asn2eth.py -X -b -e -p ldap -c ldap.cnf -s packet-ldap-template Lightweight-Directory-Access-Protocol-V3.asn */
6 /* Input file: packet-ldap-template.c */
8 #line 1 "packet-ldap-template.c"
10 * Routines for ldap packet dissection
12 * See RFC 1777 (LDAP v2), RFC 2251 (LDAP v3), and RFC 2222 (SASL).
16 * Ethereal - Network traffic analyzer
17 * By Gerald Combs <gerald@ethereal.com>
18 * Copyright 1998 Gerald Combs
20 * This program is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU General Public License
22 * as published by the Free Software Foundation; either version 2
23 * of the License, or (at your option) any later version.
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
36 * This is not a complete implementation. It doesn't handle the full version 3, more specifically,
37 * it handles only the commands of version 2, but any additional characteristics of the ver3 command are supported.
38 * It's also missing extensible search filters.
40 * There should probably be alot more error checking, I simply assume that if we have a full packet, it will be a complete
43 * AFAIK, it will handle all messages used by the OpenLDAP 1.2.9 server and libraries which was my goal. I do plan to add
44 * the remaining commands as time permits but this is not a priority to me. Send me an email if you need it and I'll see what
48 * nazard@dragoninc.on.ca
52 * 11/11/2002 - Fixed problem when decoding LDAP with desegmentation enabled and the
53 * ASN.1 BER Universal Class Tag: "Sequence Of" header is encapsulated across 2
57 * ronald.henderson@cognicaseusa.com
61 * 20-JAN-2004 - added decoding of MS-CLDAP netlogon RPC
62 * using information from the SNIA 2003 conference paper :
63 * Active Directory Domain Controller Location Service
69 * 17-DEC-2004 - added basic decoding for LDAP Controls
70 * 20-DEC-2004 - added handling for GSS-API encrypted blobs
72 * Stefan Metzmacher <metze@samba.org>
74 * 15-NOV-2005 - Changed to use the asn2eth compiler
75 * Anders Broman <anders.broman@ericsson.com>
87 #include <epan/packet.h>
88 #include <epan/conversation.h>
89 #include <epan/prefs.h>
91 #include <epan/emem.h>
92 #include <epan/oid_resolv.h>
93 #include <epan/strutil.h>
95 #include "packet-frame.h"
96 #include "packet-ldap.h"
98 #include "packet-ber.h"
99 #include "packet-per.h"
101 #define PNAME "Lightweight-Directory-Access-Protocol"
102 #define PSNAME "LDAP"
103 #define PFNAME "ldap"
105 /* Initialize the protocol and registered fields */
106 static int ldap_tap = -1;
107 static int proto_ldap = -1;
108 static int proto_cldap = -1;
110 static int hf_ldap_sasl_buffer_length = -1;
111 static int hf_ldap_response_in = -1;
112 static int hf_ldap_response_to = -1;
113 static int hf_ldap_time = -1;
115 static int hf_mscldap_netlogon_type = -1;
116 static int hf_mscldap_netlogon_flags = -1;
117 static int hf_mscldap_netlogon_flags_pdc = -1;
118 static int hf_mscldap_netlogon_flags_gc = -1;
119 static int hf_mscldap_netlogon_flags_ldap = -1;
120 static int hf_mscldap_netlogon_flags_ds = -1;
121 static int hf_mscldap_netlogon_flags_kdc = -1;
122 static int hf_mscldap_netlogon_flags_timeserv = -1;
123 static int hf_mscldap_netlogon_flags_closest = -1;
124 static int hf_mscldap_netlogon_flags_writable = -1;
125 static int hf_mscldap_netlogon_flags_good_timeserv = -1;
126 static int hf_mscldap_netlogon_flags_ndnc = -1;
127 static int hf_mscldap_domain_guid = -1;
128 static int hf_mscldap_forest = -1;
129 static int hf_mscldap_domain = -1;
130 static int hf_mscldap_hostname = -1;
131 static int hf_mscldap_nb_domain = -1;
132 static int hf_mscldap_nb_hostname = -1;
133 static int hf_mscldap_username = -1;
134 static int hf_mscldap_sitename = -1;
135 static int hf_mscldap_clientsitename = -1;
136 static int hf_mscldap_netlogon_version = -1;
137 static int hf_mscldap_netlogon_lm_token = -1;
138 static int hf_mscldap_netlogon_nt_token = -1;
141 /*--- Included file: packet-ldap-hf.c ---*/
142 #line 1 "packet-ldap-hf.c"
143 static int hf_ldap_LDAPMessage_PDU = -1; /* LDAPMessage */
144 static int hf_ldap_messageID = -1; /* MessageID */
145 static int hf_ldap_protocolOp = -1; /* ProtocolOp */
146 static int hf_ldap_controls = -1; /* Controls */
147 static int hf_ldap_bindRequest = -1; /* BindRequest */
148 static int hf_ldap_bindResponse = -1; /* BindResponse */
149 static int hf_ldap_unbindRequest = -1; /* UnbindRequest */
150 static int hf_ldap_searchRequest = -1; /* SearchRequest */
151 static int hf_ldap_searchResEntry = -1; /* SearchResultEntry */
152 static int hf_ldap_searchResDone = -1; /* SearchResultDone */
153 static int hf_ldap_searchResRef = -1; /* SearchResultReference */
154 static int hf_ldap_modifyRequest = -1; /* ModifyRequest */
155 static int hf_ldap_modifyResponse = -1; /* ModifyResponse */
156 static int hf_ldap_addRequest = -1; /* AddRequest */
157 static int hf_ldap_addResponse = -1; /* AddResponse */
158 static int hf_ldap_delRequest = -1; /* DelRequest */
159 static int hf_ldap_delResponse = -1; /* DelResponse */
160 static int hf_ldap_modDNRequest = -1; /* ModifyDNRequest */
161 static int hf_ldap_modDNResponse = -1; /* ModifyDNResponse */
162 static int hf_ldap_compareRequest = -1; /* CompareRequest */
163 static int hf_ldap_compareResponse = -1; /* CompareResponse */
164 static int hf_ldap_abandonRequest = -1; /* AbandonRequest */
165 static int hf_ldap_extendedReq = -1; /* ExtendedRequest */
166 static int hf_ldap_extendedResp = -1; /* ExtendedResponse */
167 static int hf_ldap_AttributeDescriptionList_item = -1; /* AttributeDescription */
168 static int hf_ldap_attributeDesc = -1; /* AttributeDescription */
169 static int hf_ldap_assertionValue = -1; /* AssertionValue */
170 static int hf_ldap_type = -1; /* AttributeDescription */
171 static int hf_ldap_vals = -1; /* SET_OF_AttributeValue */
172 static int hf_ldap_vals_item = -1; /* AttributeValue */
173 static int hf_ldap_resultCode = -1; /* T_resultCode */
174 static int hf_ldap_matchedDN = -1; /* LDAPDN */
175 static int hf_ldap_errorMessage = -1; /* ErrorMessage */
176 static int hf_ldap_referral = -1; /* Referral */
177 static int hf_ldap_Referral_item = -1; /* LDAPURL */
178 static int hf_ldap_Controls_item = -1; /* Control */
179 static int hf_ldap_controlType = -1; /* ControlType */
180 static int hf_ldap_criticality = -1; /* BOOLEAN */
181 static int hf_ldap_controlValue = -1; /* OCTET_STRING */
182 static int hf_ldap_version = -1; /* INTEGER_1_127 */
183 static int hf_ldap_name = -1; /* LDAPDN */
184 static int hf_ldap_authentication = -1; /* AuthenticationChoice */
185 static int hf_ldap_simple = -1; /* Simple */
186 static int hf_ldap_sasl = -1; /* SaslCredentials */
187 static int hf_ldap_mechanism = -1; /* Mechanism */
188 static int hf_ldap_credentials = -1; /* Credentials */
189 static int hf_ldap_bindResponse_resultCode = -1; /* BindResponse_resultCode */
190 static int hf_ldap_serverSaslCreds = -1; /* ServerSaslCreds */
191 static int hf_ldap_baseObject = -1; /* LDAPDN */
192 static int hf_ldap_scope = -1; /* T_scope */
193 static int hf_ldap_derefAliases = -1; /* T_derefAliases */
194 static int hf_ldap_sizeLimit = -1; /* INTEGER_0_maxInt */
195 static int hf_ldap_timeLimit = -1; /* INTEGER_0_maxInt */
196 static int hf_ldap_typesOnly = -1; /* BOOLEAN */
197 static int hf_ldap_filter = -1; /* Filter */
198 static int hf_ldap_searchRequest_attributes = -1; /* AttributeDescriptionList */
199 static int hf_ldap_and = -1; /* SET_OF_Filter */
200 static int hf_ldap_and_item = -1; /* Filter */
201 static int hf_ldap_or = -1; /* SET_OF_Filter */
202 static int hf_ldap_or_item = -1; /* Filter */
203 static int hf_ldap_not = -1; /* Filter */
204 static int hf_ldap_equalityMatch = -1; /* AttributeValueAssertion */
205 static int hf_ldap_substrings = -1; /* SubstringFilter */
206 static int hf_ldap_greaterOrEqual = -1; /* AttributeValueAssertion */
207 static int hf_ldap_lessOrEqual = -1; /* AttributeValueAssertion */
208 static int hf_ldap_present = -1; /* AttributeDescription */
209 static int hf_ldap_approxMatch = -1; /* AttributeValueAssertion */
210 static int hf_ldap_extensibleMatch = -1; /* MatchingRuleAssertion */
211 static int hf_ldap_substringFilter_substrings = -1; /* T_substrings */
212 static int hf_ldap_substrings_item = -1; /* T_substrings_item */
213 static int hf_ldap_initial = -1; /* LDAPString */
214 static int hf_ldap_any = -1; /* LDAPString */
215 static int hf_ldap_final = -1; /* LDAPString */
216 static int hf_ldap_matchingRule = -1; /* MatchingRuleId */
217 static int hf_ldap_matchValue = -1; /* AssertionValue */
218 static int hf_ldap_dnAttributes = -1; /* BOOLEAN */
219 static int hf_ldap_objectName = -1; /* LDAPDN */
220 static int hf_ldap_searchResultEntry_attributes = -1; /* PartialAttributeList */
221 static int hf_ldap_PartialAttributeList_item = -1; /* PartialAttributeList_item */
222 static int hf_ldap_SearchResultReference_item = -1; /* LDAPURL */
223 static int hf_ldap_object = -1; /* LDAPDN */
224 static int hf_ldap_modifyRequest_modification = -1; /* ModifyRequest_modification */
225 static int hf_ldap_modification_item = -1; /* T_modification_item */
226 static int hf_ldap_operation = -1; /* T_operation */
227 static int hf_ldap_modification = -1; /* AttributeTypeAndValues */
228 static int hf_ldap_entry = -1; /* LDAPDN */
229 static int hf_ldap_attributes = -1; /* AttributeList */
230 static int hf_ldap_AttributeList_item = -1; /* AttributeList_item */
231 static int hf_ldap_newrdn = -1; /* RelativeLDAPDN */
232 static int hf_ldap_deleteoldrdn = -1; /* BOOLEAN */
233 static int hf_ldap_newSuperior = -1; /* LDAPDN */
234 static int hf_ldap_ava = -1; /* AttributeValueAssertion */
235 static int hf_ldap_requestName = -1; /* LDAPOID */
236 static int hf_ldap_requestValue = -1; /* OCTET_STRING */
237 static int hf_ldap_extendedResponse_resultCode = -1; /* ExtendedResponse_resultCode */
238 static int hf_ldap_responseName = -1; /* ResponseName */
239 static int hf_ldap_response = -1; /* OCTET_STRING */
241 /*--- End of included file: packet-ldap-hf.c ---*/
242 #line 133 "packet-ldap-template.c"
244 /* Initialize the subtree pointers */
245 static gint ett_ldap = -1;
246 static gint ett_ldap_msg = -1;
247 static gint ett_ldap_sasl_blob = -1;
248 static guint ett_ldap_payload = -1;
249 static gint ett_mscldap_netlogon_flags = -1;
252 /*--- Included file: packet-ldap-ett.c ---*/
253 #line 1 "packet-ldap-ett.c"
254 static gint ett_ldap_LDAPMessage = -1;
255 static gint ett_ldap_ProtocolOp = -1;
256 static gint ett_ldap_AttributeDescriptionList = -1;
257 static gint ett_ldap_AttributeValueAssertion = -1;
258 static gint ett_ldap_Attribute = -1;
259 static gint ett_ldap_SET_OF_AttributeValue = -1;
260 static gint ett_ldap_LDAPResult = -1;
261 static gint ett_ldap_Referral = -1;
262 static gint ett_ldap_Controls = -1;
263 static gint ett_ldap_Control = -1;
264 static gint ett_ldap_BindRequest = -1;
265 static gint ett_ldap_AuthenticationChoice = -1;
266 static gint ett_ldap_SaslCredentials = -1;
267 static gint ett_ldap_BindResponse = -1;
268 static gint ett_ldap_SearchRequest = -1;
269 static gint ett_ldap_Filter = -1;
270 static gint ett_ldap_SET_OF_Filter = -1;
271 static gint ett_ldap_SubstringFilter = -1;
272 static gint ett_ldap_T_substrings = -1;
273 static gint ett_ldap_T_substrings_item = -1;
274 static gint ett_ldap_MatchingRuleAssertion = -1;
275 static gint ett_ldap_SearchResultEntry = -1;
276 static gint ett_ldap_PartialAttributeList = -1;
277 static gint ett_ldap_PartialAttributeList_item = -1;
278 static gint ett_ldap_SearchResultReference = -1;
279 static gint ett_ldap_ModifyRequest = -1;
280 static gint ett_ldap_ModifyRequest_modification = -1;
281 static gint ett_ldap_T_modification_item = -1;
282 static gint ett_ldap_AttributeTypeAndValues = -1;
283 static gint ett_ldap_AddRequest = -1;
284 static gint ett_ldap_AttributeList = -1;
285 static gint ett_ldap_AttributeList_item = -1;
286 static gint ett_ldap_ModifyDNRequest = -1;
287 static gint ett_ldap_CompareRequest = -1;
288 static gint ett_ldap_ExtendedRequest = -1;
289 static gint ett_ldap_ExtendedResponse = -1;
291 /*--- End of included file: packet-ldap-ett.c ---*/
292 #line 142 "packet-ldap-template.c"
294 static dissector_table_t ldap_name_dissector_table=NULL;
296 /* desegmentation of LDAP */
297 static gboolean ldap_desegment = TRUE;
298 static guint ldap_tcp_port = 389;
299 static gboolean do_protocolop = FALSE;
300 static gchar *attr_type = NULL;
301 static gboolean is_binary_attr_type = FALSE;
303 #define TCP_PORT_LDAP 389
304 #define UDP_PORT_CLDAP 389
305 #define TCP_PORT_GLOBALCAT_LDAP 3268 /* Windows 2000 Global Catalog */
307 static dissector_handle_t gssapi_handle;
308 static dissector_handle_t gssapi_wrap_handle;
311 /* different types of rpc calls ontop of ms cldap */
312 #define MSCLDAP_RPC_NETLOGON 1
314 /* Message type Choice values */
315 static const value_string ldap_ProtocolOp_choice_vals[] = {
316 { 0, "bindRequest" },
317 { 1, "bindResponse" },
318 { 2, "unbindRequest" },
319 { 3, "searchRequest" },
320 { 4, "searchResEntry" },
321 { 5, "searchResDone" },
322 { 6, "searchResRef" },
323 { 7, "modifyRequest" },
324 { 8, "modifyResponse" },
326 { 10, "addResponse" },
327 { 11, "delRequest" },
328 { 12, "delResponse" },
329 { 13, "modDNRequest" },
330 { 14, "modDNResponse" },
331 { 15, "compareRequest" },
332 { 16, "compareResponse" },
333 { 17, "abandonRequest" },
334 { 18, "extendedReq" },
335 { 19, "extendedResp" },
339 * Data structure attached to a conversation, giving authentication
340 * information from a bind request.
341 * We keep a linked list of them, so that we can free up all the
342 * authentication mechanism strings.
344 typedef struct ldap_conv_info_t {
345 struct ldap_conv_info_t *next;
346 guint auth_type; /* authentication type */
347 char *auth_mech; /* authentication mechanism */
348 guint32 first_auth_frame; /* first frame that would use a security layer */
349 GHashTable *unmatched;
355 static ldap_conv_info_t *ldap_info_items;
358 ldap_info_hash_matched(gconstpointer k)
360 const ldap_call_response_t *key = k;
362 return key->messageId;
366 ldap_info_equal_matched(gconstpointer k1, gconstpointer k2)
368 const ldap_call_response_t *key1 = k1;
369 const ldap_call_response_t *key2 = k2;
371 if( key1->req_frame && key2->req_frame && (key1->req_frame!=key2->req_frame) ){
374 /* a response may span multiple frames
375 if( key1->rep_frame && key2->rep_frame && (key1->rep_frame!=key2->rep_frame) ){
380 return key1->messageId==key2->messageId;
384 ldap_info_hash_unmatched(gconstpointer k)
386 const ldap_call_response_t *key = k;
388 return key->messageId;
392 ldap_info_equal_unmatched(gconstpointer k1, gconstpointer k2)
394 const ldap_call_response_t *key1 = k1;
395 const ldap_call_response_t *key2 = k2;
397 return key1->messageId==key2->messageId;
400 /* Global variables */
401 char *mechanism = NULL;
402 static gint MessageID =-1;
403 static gint ProtocolOp = -1;
404 static gint result = 0;
405 static proto_item *ldm_tree = NULL; /* item to add text to */
407 static void ldap_do_protocolop(packet_info *pinfo)
413 valstr = val_to_str(ProtocolOp, ldap_ProtocolOp_choice_vals, "Unknown (%%u)");
415 if(check_col(pinfo->cinfo, COL_INFO))
416 col_append_fstr(pinfo->cinfo, COL_INFO, "%s(%u) ", valstr, MessageID);
419 proto_item_append_text(ldm_tree, " %s(%d)", valstr, MessageID);
421 do_protocolop = FALSE;
426 static ldap_call_response_t *
427 ldap_match_call_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint messageId, guint protocolOpTag)
429 ldap_call_response_t lcr, *lcrp=NULL;
430 ldap_conv_info_t *ldap_info = (ldap_conv_info_t *)pinfo->private_data;
432 /* first see if we have already matched this */
434 lcr.messageId=messageId;
435 switch(protocolOpTag){
437 case LDAP_REQ_SEARCH:
438 case LDAP_REQ_MODIFY:
440 case LDAP_REQ_DELETE:
441 case LDAP_REQ_MODRDN:
442 case LDAP_REQ_COMPARE:
444 lcr.req_frame=pinfo->fd->num;
448 case LDAP_RES_SEARCH_ENTRY:
449 case LDAP_RES_SEARCH_REF:
450 case LDAP_RES_SEARCH_RESULT:
451 case LDAP_RES_MODIFY:
453 case LDAP_RES_DELETE:
454 case LDAP_RES_MODRDN:
455 case LDAP_RES_COMPARE:
456 lcr.is_request=FALSE;
458 lcr.rep_frame=pinfo->fd->num;
461 lcrp=g_hash_table_lookup(ldap_info->matched, &lcr);
465 lcrp->is_request=lcr.is_request;
469 /* we haven't found a match - try and match it up */
471 switch(protocolOpTag){
473 case LDAP_REQ_SEARCH:
474 case LDAP_REQ_MODIFY:
476 case LDAP_REQ_DELETE:
477 case LDAP_REQ_MODRDN:
478 case LDAP_REQ_COMPARE:
480 /* this a a request - add it to the unmatched list */
482 /* check that we dont already have one of those in the
483 unmatched list and if so remove it */
485 lcr.messageId=messageId;
486 lcrp=g_hash_table_lookup(ldap_info->unmatched, &lcr);
488 g_hash_table_remove(ldap_info->unmatched, lcrp);
490 /* if we cant reuse the old one, grab a new chunk */
492 lcrp=se_alloc(sizeof(ldap_call_response_t));
494 lcrp->messageId=messageId;
495 lcrp->req_frame=pinfo->fd->num;
496 lcrp->req_time=pinfo->fd->abs_ts;
498 lcrp->protocolOpTag=protocolOpTag;
499 lcrp->is_request=TRUE;
500 g_hash_table_insert(ldap_info->unmatched, lcrp, lcrp);
504 case LDAP_RES_SEARCH_ENTRY:
505 case LDAP_RES_SEARCH_REF:
506 case LDAP_RES_SEARCH_RESULT:
507 case LDAP_RES_MODIFY:
509 case LDAP_RES_DELETE:
510 case LDAP_RES_MODRDN:
511 case LDAP_RES_COMPARE:
513 /* this is a result - it should be in our unmatched list */
515 lcr.messageId=messageId;
516 lcrp=g_hash_table_lookup(ldap_info->unmatched, &lcr);
520 if(!lcrp->rep_frame){
521 g_hash_table_remove(ldap_info->unmatched, lcrp);
522 lcrp->rep_frame=pinfo->fd->num;
523 lcrp->is_request=FALSE;
524 g_hash_table_insert(ldap_info->matched, lcrp, lcrp);
532 /* we have found a match */
535 if(lcrp->is_request){
536 proto_tree_add_uint(tree, hf_ldap_response_in, tvb, 0, 0, lcrp->rep_frame);
539 proto_tree_add_uint(tree, hf_ldap_response_to, tvb, 0, 0, lcrp->req_frame);
540 nstime_delta(&ns, &pinfo->fd->abs_ts, &lcrp->req_time);
541 proto_tree_add_time(tree, hf_ldap_time, tvb, 0, 0, &ns);
549 /*--- Included file: packet-ldap-fn.c ---*/
550 #line 1 "packet-ldap-fn.c"
551 /*--- Cyclic dependencies ---*/
553 /* Filter -> Filter/and -> Filter */
554 /* Filter -> Filter */
555 static int dissect_ldap_Filter(gboolean implicit_tag, tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree, int hf_index);
557 static int dissect_filter(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
558 return dissect_ldap_Filter(FALSE, tvb, offset, pinfo, tree, hf_ldap_filter);
560 static int dissect_and_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
561 return dissect_ldap_Filter(FALSE, tvb, offset, pinfo, tree, hf_ldap_and_item);
563 static int dissect_or_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
564 return dissect_ldap_Filter(FALSE, tvb, offset, pinfo, tree, hf_ldap_or_item);
566 static int dissect_not_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
567 return dissect_ldap_Filter(TRUE, tvb, offset, pinfo, tree, hf_ldap_not);
571 /*--- Fields for imported types ---*/
577 dissect_ldap_MessageID(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
580 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
590 static int dissect_messageID(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
591 return dissect_ldap_MessageID(FALSE, tvb, offset, pinfo, tree, hf_ldap_messageID);
597 dissect_ldap_INTEGER_1_127(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
598 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
603 static int dissect_version(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
604 return dissect_ldap_INTEGER_1_127(FALSE, tvb, offset, pinfo, tree, hf_ldap_version);
610 dissect_ldap_LDAPString(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
612 tvbuff_t *parameter_tvb = NULL;
614 gchar *sc = NULL; /* semi-colon pointer */
616 offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
620 if (parameter_tvb || (hf_index == hf_ldap_baseObject)) {
622 ldap_do_protocolop(pinfo);
625 ldapstring = tvb_get_string(parameter_tvb, 0, tvb_length_remaining(parameter_tvb, 0));
627 ldapstring = "<ROOT>";
629 if(hf_index == hf_ldap_baseObject) {
630 /* this is search - but it on the scanline */
631 if(check_col(pinfo->cinfo, COL_INFO))
632 col_append_fstr(pinfo->cinfo, COL_INFO, "\"%s\" ", ldapstring);
635 proto_item_append_text(ldm_tree, " \"%s\"", ldapstring);
636 } else if ((hf_index == hf_ldap_errorMessage) && result) { /* only show message if not success */
637 if(check_col(pinfo->cinfo, COL_INFO))
638 col_append_fstr(pinfo->cinfo, COL_INFO, "(%s) ", ldapstring);
641 proto_item_append_text(ldm_tree, " (%s)", ldapstring);
642 } else if (hf_index == hf_ldap_objectName) {
643 if(check_col(pinfo->cinfo, COL_INFO))
644 col_append_fstr(pinfo->cinfo, COL_INFO, "\"%s\" ", ldapstring);
647 proto_item_append_text(ldm_tree, " \"%s\"", ldapstring);
648 } else if (hf_index == hf_ldap_type) {
649 /* remember attribute type name */
650 attr_type = ep_strdup(ldapstring);
652 /* append it to the parent entry */
653 proto_item_append_text(tree, " %s", attr_type);
655 /* remove the ";binary" component if present */
656 if((sc = strchr(attr_type, ';')) != NULL) {
657 if(!strcmp(sc, ";binary")) {
658 *sc = '\0'; /* terminate the string */
659 is_binary_attr_type = TRUE;
662 is_binary_attr_type = FALSE;
667 if(parameter_tvb && ldapstring)
675 static int dissect_initial_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
676 return dissect_ldap_LDAPString(TRUE, tvb, offset, pinfo, tree, hf_ldap_initial);
678 static int dissect_any_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
679 return dissect_ldap_LDAPString(TRUE, tvb, offset, pinfo, tree, hf_ldap_any);
681 static int dissect_final_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
682 return dissect_ldap_LDAPString(TRUE, tvb, offset, pinfo, tree, hf_ldap_final);
688 dissect_ldap_LDAPDN(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
689 offset = dissect_ldap_LDAPString(implicit_tag, tvb, offset, pinfo, tree, hf_index);
693 static int dissect_matchedDN(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
694 return dissect_ldap_LDAPDN(FALSE, tvb, offset, pinfo, tree, hf_ldap_matchedDN);
696 static int dissect_name(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
697 return dissect_ldap_LDAPDN(FALSE, tvb, offset, pinfo, tree, hf_ldap_name);
699 static int dissect_baseObject(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
700 return dissect_ldap_LDAPDN(FALSE, tvb, offset, pinfo, tree, hf_ldap_baseObject);
702 static int dissect_objectName(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
703 return dissect_ldap_LDAPDN(FALSE, tvb, offset, pinfo, tree, hf_ldap_objectName);
705 static int dissect_object(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
706 return dissect_ldap_LDAPDN(FALSE, tvb, offset, pinfo, tree, hf_ldap_object);
708 static int dissect_entry(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
709 return dissect_ldap_LDAPDN(FALSE, tvb, offset, pinfo, tree, hf_ldap_entry);
711 static int dissect_newSuperior_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
712 return dissect_ldap_LDAPDN(TRUE, tvb, offset, pinfo, tree, hf_ldap_newSuperior);
718 dissect_ldap_Simple(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
720 ldap_conv_info_t *ldap_info;
722 offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
726 ldap_info = pinfo->private_data;
727 ldap_info->auth_type = LDAP_AUTH_SIMPLE;
729 pinfo->private_data = ldap_info;
735 static int dissect_simple_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
736 return dissect_ldap_Simple(TRUE, tvb, offset, pinfo, tree, hf_ldap_simple);
742 dissect_ldap_Mechanism(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
745 ldap_conv_info_t *ldap_info;
746 tvbuff_t *parameter_tvb;
747 char *mechanism = NULL;
748 offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
751 ldap_info = pinfo->private_data;
752 ldap_info->auth_type = LDAP_AUTH_SASL;
758 * We need to remember the authentication type and mechanism for this
761 * XXX - actually, we might need to remember more than one
762 * type and mechanism, if you can unbind and rebind with a
763 * different type and/or mechanism.
765 mechanism = tvb_get_string(parameter_tvb, 0, tvb_length_remaining(parameter_tvb,0));
766 ldap_info->first_auth_frame = 0; /* not known until we see the bind reply */
768 * If the mechanism in this request is an empty string (which is
769 * returned as a null pointer), use the saved mechanism instead.
770 * Otherwise, if the saved mechanism is an empty string (null),
771 * save this mechanism.
773 if (mechanism == NULL)
774 mechanism = ldap_info->auth_mech;
776 if (ldap_info->auth_mech == NULL) {
777 g_free(ldap_info->auth_mech);
779 ldap_info->auth_mech = mechanism;
781 pinfo->private_data = ldap_info;
787 static int dissect_mechanism(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
788 return dissect_ldap_Mechanism(FALSE, tvb, offset, pinfo, tree, hf_ldap_mechanism);
794 dissect_ldap_Credentials(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
797 tvbuff_t *parameter_tvb;
798 ldap_conv_info_t *ldap_info;
800 offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
806 ldap_info = pinfo->private_data;
807 if (ldap_info->auth_mech != NULL && strcmp(ldap_info->auth_mech, "GSS-SPNEGO") == 0) {
809 * This is a GSS-API token ancapsulated within GSS-SPNEGO.
812 call_dissector(gssapi_handle, parameter_tvb, pinfo, tree);
813 } else if (ldap_info->auth_mech != NULL && strcmp(ldap_info->auth_mech, "GSSAPI") == 0) {
815 * This is a raw GSS-API token.
818 call_dissector(gssapi_handle, parameter_tvb, pinfo, tree);
820 pinfo->private_data = ldap_info;
826 static int dissect_credentials(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
827 return dissect_ldap_Credentials(FALSE, tvb, offset, pinfo, tree, hf_ldap_credentials);
831 static const ber_sequence_t SaslCredentials_sequence[] = {
832 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_mechanism },
833 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_credentials },
838 dissect_ldap_SaslCredentials(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
839 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
840 SaslCredentials_sequence, hf_index, ett_ldap_SaslCredentials);
844 static int dissect_sasl_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
845 return dissect_ldap_SaslCredentials(TRUE, tvb, offset, pinfo, tree, hf_ldap_sasl);
849 static const value_string ldap_AuthenticationChoice_vals[] = {
855 static const ber_choice_t AuthenticationChoice_choice[] = {
856 { 0, BER_CLASS_CON, 0, 0, dissect_simple_impl },
857 { 3, BER_CLASS_CON, 3, 0, dissect_sasl_impl },
862 dissect_ldap_AuthenticationChoice(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
868 offset = dissect_ber_choice(pinfo, tree, tvb, offset,
869 AuthenticationChoice_choice, hf_index, ett_ldap_AuthenticationChoice,
873 ldap_do_protocolop(pinfo);
875 if((branch > -1) && (branch < (gint)(sizeof AuthenticationChoice_choice/sizeof AuthenticationChoice_choice[0])))
876 auth = AuthenticationChoice_choice[branch].value;
878 valstr = val_to_str(auth, ldap_AuthenticationChoice_vals, "Unknown auth(%u)");
880 if (check_col(pinfo->cinfo, COL_INFO))
881 col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", valstr);
884 proto_item_append_text(ldm_tree, " %s", valstr);
891 static int dissect_authentication(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
892 return dissect_ldap_AuthenticationChoice(FALSE, tvb, offset, pinfo, tree, hf_ldap_authentication);
896 static const ber_sequence_t BindRequest_sequence[] = {
897 { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_version },
898 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_name },
899 { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_authentication },
904 dissect_ldap_BindRequest(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
905 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
906 BindRequest_sequence, hf_index, ett_ldap_BindRequest);
910 static int dissect_bindRequest(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
911 return dissect_ldap_BindRequest(FALSE, tvb, offset, pinfo, tree, hf_ldap_bindRequest);
915 static const value_string ldap_BindResponse_resultCode_vals[] = {
917 { 1, "operationsError" },
918 { 2, "protocolError" },
919 { 3, "timeLimitExceeded" },
920 { 4, "sizeLimitExceeded" },
921 { 5, "compareFalse" },
922 { 6, "compareTrue" },
923 { 7, "authMethodNotSupported" },
924 { 8, "strongAuthRequired" },
926 { 11, "adminLimitExceeded" },
927 { 12, "unavailableCriticalExtension" },
928 { 13, "confidentialityRequired" },
929 { 14, "saslBindInProgress" },
930 { 16, "noSuchAttribute" },
931 { 17, "undefinedAttributeType" },
932 { 18, "inappropriateMatching" },
933 { 19, "constraintViolation" },
934 { 20, "attributeOrValueExists" },
935 { 21, "invalidAttributeSyntax" },
936 { 32, "noSuchObject" },
937 { 33, "aliasProblem" },
938 { 34, "invalidDNSyntax" },
939 { 36, "aliasDereferencingProblem" },
940 { 48, "inappropriateAuthentication" },
941 { 49, "invalidCredentials" },
942 { 50, "insufficientAccessRights" },
944 { 52, "unavailable" },
945 { 53, "unwillingToPerform" },
946 { 54, "loopDetect" },
947 { 64, "namingViolation" },
948 { 65, "objectClassViolation" },
949 { 66, "notAllowedOnNonLeaf" },
950 { 67, "notAllowedOnRDN" },
951 { 68, "entryAlreadyExists" },
952 { 69, "objectClassModsProhibited" },
953 { 71, "affectsMultipleDSAs" },
960 dissect_ldap_BindResponse_resultCode(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
965 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
969 ldap_do_protocolop(pinfo);
973 valstr = val_to_str(result, ldap_BindResponse_resultCode_vals, "Unknown result(%u)");
975 if (check_col(pinfo->cinfo, COL_INFO))
976 col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", valstr);
979 proto_item_append_text(ldm_tree, " %s", valstr);
988 static int dissect_bindResponse_resultCode(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
989 return dissect_ldap_BindResponse_resultCode(FALSE, tvb, offset, pinfo, tree, hf_ldap_bindResponse_resultCode);
995 dissect_ldap_ErrorMessage(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
996 offset = dissect_ldap_LDAPString(implicit_tag, tvb, offset, pinfo, tree, hf_index);
1000 static int dissect_errorMessage(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1001 return dissect_ldap_ErrorMessage(FALSE, tvb, offset, pinfo, tree, hf_ldap_errorMessage);
1007 dissect_ldap_LDAPURL(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1008 offset = dissect_ldap_LDAPString(implicit_tag, tvb, offset, pinfo, tree, hf_index);
1012 static int dissect_Referral_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1013 return dissect_ldap_LDAPURL(FALSE, tvb, offset, pinfo, tree, hf_ldap_Referral_item);
1015 static int dissect_SearchResultReference_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1016 return dissect_ldap_LDAPURL(FALSE, tvb, offset, pinfo, tree, hf_ldap_SearchResultReference_item);
1020 static const ber_sequence_t Referral_sequence_of[1] = {
1021 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_Referral_item },
1025 dissect_ldap_Referral(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1026 offset = dissect_ber_sequence_of(implicit_tag, pinfo, tree, tvb, offset,
1027 Referral_sequence_of, hf_index, ett_ldap_Referral);
1031 static int dissect_referral_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1032 return dissect_ldap_Referral(TRUE, tvb, offset, pinfo, tree, hf_ldap_referral);
1038 dissect_ldap_ServerSaslCreds(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1039 #line 178 "ldap.cnf"
1041 tvbuff_t *parameter_tvb;
1042 ldap_conv_info_t *ldap_info;
1044 offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1049 ldap_info = pinfo->private_data;
1050 switch (ldap_info->auth_type) {
1052 /* For Kerberos V4, dissect it as a ticket. */
1053 /* XXX - what about LDAP_AUTH_SIMPLE? */
1055 case LDAP_AUTH_SASL:
1057 * All frames after this are assumed to use a security layer.
1059 * XXX - won't work if there's another reply, with the security
1060 * layer, starting in the same TCP segment that ends this
1061 * reply, but as LDAP is a request/response protocol, and
1062 * as the client probably can't start using authentication until
1063 * it gets the bind reply and the server won't send a reply until
1064 * it gets a request, that probably won't happen.
1066 * XXX - that assumption is invalid; it's not clear where the
1067 * hell you find out whether there's any security layer. In
1068 * one capture, we have two GSS-SPNEGO negotiations, both of
1069 * which select MS KRB5, and the only differences in the tokens
1070 * is in the RC4-HMAC ciphertext. The various
1071 * draft-ietf--cat-sasl-gssapi-NN.txt drafts seem to imply
1072 * that the RFC 2222 spoo with the bitmask and maximum
1073 * output message size stuff is done - but where does that
1074 * stuff show up? Is it in the ciphertext, which means it's
1075 * presumably encrypted?
1077 * Grrr. We have to do a gross heuristic, checking whether the
1078 * putative LDAP message begins with 0x00 or not, making the
1079 * assumption that we won't have more than 2^24 bytes of
1080 * encapsulated stuff.
1082 ldap_info->first_auth_frame = pinfo->fd->num + 1;
1083 if (ldap_info->auth_mech != NULL &&
1084 strcmp(ldap_info->auth_mech, "GSS-SPNEGO") == 0) {
1086 * This is a GSS-API token.
1088 call_dissector(gssapi_handle, parameter_tvb, pinfo, tree);
1089 } else if (ldap_info->auth_mech != NULL &&
1090 strcmp(ldap_info->auth_mech, "GSSAPI") == 0) {
1092 * This is a GSS-API token.
1094 call_dissector(gssapi_handle, parameter_tvb, pinfo, tree);
1098 pinfo->private_data = ldap_info;
1104 static int dissect_serverSaslCreds_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1105 return dissect_ldap_ServerSaslCreds(TRUE, tvb, offset, pinfo, tree, hf_ldap_serverSaslCreds);
1109 static const ber_sequence_t BindResponse_sequence[] = {
1110 { BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_bindResponse_resultCode },
1111 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_matchedDN },
1112 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_errorMessage },
1113 { BER_CLASS_CON, 3, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_referral_impl },
1114 { BER_CLASS_CON, 7, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_serverSaslCreds_impl },
1119 dissect_ldap_BindResponse(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1120 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1121 BindResponse_sequence, hf_index, ett_ldap_BindResponse);
1125 static int dissect_bindResponse(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1126 return dissect_ldap_BindResponse(FALSE, tvb, offset, pinfo, tree, hf_ldap_bindResponse);
1132 dissect_ldap_UnbindRequest(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1133 #line 419 "ldap.cnf"
1135 implicit_tag = TRUE; /* correct problem with asn2eth */
1137 offset = dissect_ber_null(implicit_tag, pinfo, tree, tvb, offset, hf_index);
1140 ldap_do_protocolop(pinfo);
1146 static int dissect_unbindRequest(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1147 return dissect_ldap_UnbindRequest(FALSE, tvb, offset, pinfo, tree, hf_ldap_unbindRequest);
1151 static const value_string ldap_T_scope_vals[] = {
1152 { 0, "baseObject" },
1153 { 1, "singleLevel" },
1154 { 2, "wholeSubtree" },
1160 dissect_ldap_T_scope(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1161 #line 299 "ldap.cnf"
1164 const gchar *valstr;
1166 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1170 ldap_do_protocolop(pinfo);
1172 valstr = val_to_str(scope, ldap_T_scope_vals, "Unknown scope(%u)");
1174 if (check_col(pinfo->cinfo, COL_INFO))
1175 col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", valstr);
1178 proto_item_append_text(ldm_tree, " %s", valstr);
1184 static int dissect_scope(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1185 return dissect_ldap_T_scope(FALSE, tvb, offset, pinfo, tree, hf_ldap_scope);
1189 static const value_string ldap_T_derefAliases_vals[] = {
1190 { 0, "neverDerefAliases" },
1191 { 1, "derefInSearching" },
1192 { 2, "derefFindingBaseObj" },
1193 { 3, "derefAlways" },
1199 dissect_ldap_T_derefAliases(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1200 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1205 static int dissect_derefAliases(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1206 return dissect_ldap_T_derefAliases(FALSE, tvb, offset, pinfo, tree, hf_ldap_derefAliases);
1212 dissect_ldap_INTEGER_0_maxInt(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1213 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1218 static int dissect_sizeLimit(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1219 return dissect_ldap_INTEGER_0_maxInt(FALSE, tvb, offset, pinfo, tree, hf_ldap_sizeLimit);
1221 static int dissect_timeLimit(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1222 return dissect_ldap_INTEGER_0_maxInt(FALSE, tvb, offset, pinfo, tree, hf_ldap_timeLimit);
1228 dissect_ldap_BOOLEAN(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1229 offset = dissect_ber_boolean(implicit_tag, pinfo, tree, tvb, offset, hf_index);
1233 static int dissect_criticality(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1234 return dissect_ldap_BOOLEAN(FALSE, tvb, offset, pinfo, tree, hf_ldap_criticality);
1236 static int dissect_typesOnly(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1237 return dissect_ldap_BOOLEAN(FALSE, tvb, offset, pinfo, tree, hf_ldap_typesOnly);
1239 static int dissect_dnAttributes_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1240 return dissect_ldap_BOOLEAN(TRUE, tvb, offset, pinfo, tree, hf_ldap_dnAttributes);
1242 static int dissect_deleteoldrdn(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1243 return dissect_ldap_BOOLEAN(FALSE, tvb, offset, pinfo, tree, hf_ldap_deleteoldrdn);
1247 static const ber_sequence_t SET_OF_Filter_set_of[1] = {
1248 { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_and_item },
1252 dissect_ldap_SET_OF_Filter(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1253 offset = dissect_ber_set_of(implicit_tag, pinfo, tree, tvb, offset,
1254 SET_OF_Filter_set_of, hf_index, ett_ldap_SET_OF_Filter);
1258 static int dissect_and_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1259 return dissect_ldap_SET_OF_Filter(TRUE, tvb, offset, pinfo, tree, hf_ldap_and);
1261 static int dissect_or_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1262 return dissect_ldap_SET_OF_Filter(TRUE, tvb, offset, pinfo, tree, hf_ldap_or);
1268 dissect_ldap_AttributeDescription(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1269 offset = dissect_ldap_LDAPString(implicit_tag, tvb, offset, pinfo, tree, hf_index);
1273 static int dissect_AttributeDescriptionList_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1274 return dissect_ldap_AttributeDescription(FALSE, tvb, offset, pinfo, tree, hf_ldap_AttributeDescriptionList_item);
1276 static int dissect_attributeDesc(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1277 return dissect_ldap_AttributeDescription(FALSE, tvb, offset, pinfo, tree, hf_ldap_attributeDesc);
1279 static int dissect_type(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1280 return dissect_ldap_AttributeDescription(FALSE, tvb, offset, pinfo, tree, hf_ldap_type);
1282 static int dissect_type_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1283 return dissect_ldap_AttributeDescription(TRUE, tvb, offset, pinfo, tree, hf_ldap_type);
1285 static int dissect_present_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1286 return dissect_ldap_AttributeDescription(TRUE, tvb, offset, pinfo, tree, hf_ldap_present);
1292 dissect_ldap_AssertionValue(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1293 offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1298 static int dissect_assertionValue(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1299 return dissect_ldap_AssertionValue(FALSE, tvb, offset, pinfo, tree, hf_ldap_assertionValue);
1301 static int dissect_matchValue_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1302 return dissect_ldap_AssertionValue(TRUE, tvb, offset, pinfo, tree, hf_ldap_matchValue);
1306 static const ber_sequence_t AttributeValueAssertion_sequence[] = {
1307 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_attributeDesc },
1308 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_assertionValue },
1313 dissect_ldap_AttributeValueAssertion(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1314 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1315 AttributeValueAssertion_sequence, hf_index, ett_ldap_AttributeValueAssertion);
1319 static int dissect_equalityMatch_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1320 return dissect_ldap_AttributeValueAssertion(TRUE, tvb, offset, pinfo, tree, hf_ldap_equalityMatch);
1322 static int dissect_greaterOrEqual_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1323 return dissect_ldap_AttributeValueAssertion(TRUE, tvb, offset, pinfo, tree, hf_ldap_greaterOrEqual);
1325 static int dissect_lessOrEqual_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1326 return dissect_ldap_AttributeValueAssertion(TRUE, tvb, offset, pinfo, tree, hf_ldap_lessOrEqual);
1328 static int dissect_approxMatch_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1329 return dissect_ldap_AttributeValueAssertion(TRUE, tvb, offset, pinfo, tree, hf_ldap_approxMatch);
1331 static int dissect_ava(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1332 return dissect_ldap_AttributeValueAssertion(FALSE, tvb, offset, pinfo, tree, hf_ldap_ava);
1336 static const value_string ldap_T_substrings_item_vals[] = {
1343 static const ber_choice_t T_substrings_item_choice[] = {
1344 { 0, BER_CLASS_CON, 0, 0, dissect_initial_impl },
1345 { 1, BER_CLASS_CON, 1, 0, dissect_any_impl },
1346 { 2, BER_CLASS_CON, 2, 0, dissect_final_impl },
1347 { 0, 0, 0, 0, NULL }
1351 dissect_ldap_T_substrings_item(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1352 offset = dissect_ber_choice(pinfo, tree, tvb, offset,
1353 T_substrings_item_choice, hf_index, ett_ldap_T_substrings_item,
1358 static int dissect_substrings_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1359 return dissect_ldap_T_substrings_item(FALSE, tvb, offset, pinfo, tree, hf_ldap_substrings_item);
1363 static const ber_sequence_t T_substrings_sequence_of[1] = {
1364 { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_substrings_item },
1368 dissect_ldap_T_substrings(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1369 offset = dissect_ber_sequence_of(implicit_tag, pinfo, tree, tvb, offset,
1370 T_substrings_sequence_of, hf_index, ett_ldap_T_substrings);
1374 static int dissect_substringFilter_substrings(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1375 return dissect_ldap_T_substrings(FALSE, tvb, offset, pinfo, tree, hf_ldap_substringFilter_substrings);
1379 static const ber_sequence_t SubstringFilter_sequence[] = {
1380 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_type },
1381 { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_substringFilter_substrings },
1386 dissect_ldap_SubstringFilter(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1387 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1388 SubstringFilter_sequence, hf_index, ett_ldap_SubstringFilter);
1392 static int dissect_substrings_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1393 return dissect_ldap_SubstringFilter(TRUE, tvb, offset, pinfo, tree, hf_ldap_substrings);
1399 dissect_ldap_MatchingRuleId(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1400 offset = dissect_ldap_LDAPString(implicit_tag, tvb, offset, pinfo, tree, hf_index);
1404 static int dissect_matchingRule_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1405 return dissect_ldap_MatchingRuleId(TRUE, tvb, offset, pinfo, tree, hf_ldap_matchingRule);
1409 static const ber_sequence_t MatchingRuleAssertion_sequence[] = {
1410 { BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_matchingRule_impl },
1411 { BER_CLASS_CON, 2, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_type_impl },
1412 { BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_matchValue_impl },
1413 { BER_CLASS_CON, 4, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_dnAttributes_impl },
1418 dissect_ldap_MatchingRuleAssertion(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1419 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1420 MatchingRuleAssertion_sequence, hf_index, ett_ldap_MatchingRuleAssertion);
1424 static int dissect_extensibleMatch_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1425 return dissect_ldap_MatchingRuleAssertion(TRUE, tvb, offset, pinfo, tree, hf_ldap_extensibleMatch);
1429 static const value_string ldap_Filter_vals[] = {
1433 { 3, "equalityMatch" },
1434 { 4, "substrings" },
1435 { 5, "greaterOrEqual" },
1436 { 6, "lessOrEqual" },
1438 { 8, "approxMatch" },
1439 { 9, "extensibleMatch" },
1443 static const ber_choice_t Filter_choice[] = {
1444 { 0, BER_CLASS_CON, 0, 0, dissect_and_impl },
1445 { 1, BER_CLASS_CON, 1, 0, dissect_or_impl },
1446 { 2, BER_CLASS_CON, 2, 0, dissect_not_impl },
1447 { 3, BER_CLASS_CON, 3, 0, dissect_equalityMatch_impl },
1448 { 4, BER_CLASS_CON, 4, 0, dissect_substrings_impl },
1449 { 5, BER_CLASS_CON, 5, 0, dissect_greaterOrEqual_impl },
1450 { 6, BER_CLASS_CON, 6, 0, dissect_lessOrEqual_impl },
1451 { 7, BER_CLASS_CON, 7, 0, dissect_present_impl },
1452 { 8, BER_CLASS_CON, 8, 0, dissect_approxMatch_impl },
1453 { 9, BER_CLASS_CON, 9, 0, dissect_extensibleMatch_impl },
1454 { 0, 0, 0, 0, NULL }
1458 dissect_ldap_Filter(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1459 offset = dissect_ber_choice(pinfo, tree, tvb, offset,
1460 Filter_choice, hf_index, ett_ldap_Filter,
1467 static const ber_sequence_t AttributeDescriptionList_sequence_of[1] = {
1468 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_AttributeDescriptionList_item },
1472 dissect_ldap_AttributeDescriptionList(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1473 offset = dissect_ber_sequence_of(implicit_tag, pinfo, tree, tvb, offset,
1474 AttributeDescriptionList_sequence_of, hf_index, ett_ldap_AttributeDescriptionList);
1478 static int dissect_searchRequest_attributes(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1479 return dissect_ldap_AttributeDescriptionList(FALSE, tvb, offset, pinfo, tree, hf_ldap_searchRequest_attributes);
1483 static const ber_sequence_t SearchRequest_sequence[] = {
1484 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_baseObject },
1485 { BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_scope },
1486 { BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_derefAliases },
1487 { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_sizeLimit },
1488 { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_timeLimit },
1489 { BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_NOOWNTAG, dissect_typesOnly },
1490 { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_filter },
1491 { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_searchRequest_attributes },
1496 dissect_ldap_SearchRequest(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1497 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1498 SearchRequest_sequence, hf_index, ett_ldap_SearchRequest);
1502 static int dissect_searchRequest(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1503 return dissect_ldap_SearchRequest(FALSE, tvb, offset, pinfo, tree, hf_ldap_searchRequest);
1509 dissect_ldap_AttributeValue(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1510 #line 361 "ldap.cnf"
1516 int old_offset = offset;
1518 /* extract the value of the octetstring */
1519 offset = dissect_ber_octet_string(FALSE, pinfo, NULL, tvb, offset, hf_index, &next_tvb);
1521 /* if we have an attribute type that isn't binary see if there is a better dissector */
1522 if(!attr_type || !dissector_try_string(ldap_name_dissector_table, attr_type, next_tvb, pinfo, tree)) {
1523 offset = old_offset;
1525 /* do the default thing */
1526 offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1532 len = tvb_length_remaining(next_tvb, 0);
1534 for(i = 0; i < len; i++)
1535 if(!g_ascii_isprint(tvb_get_guint8(next_tvb, i)))
1539 string = tvb_get_string(next_tvb, 0, tvb_length_remaining(next_tvb, 0));
1541 pi = get_ber_last_created_item();
1543 proto_item_set_text(pi, string);
1551 static int dissect_vals_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1552 return dissect_ldap_AttributeValue(FALSE, tvb, offset, pinfo, tree, hf_ldap_vals_item);
1556 static const ber_sequence_t SET_OF_AttributeValue_set_of[1] = {
1557 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_vals_item },
1561 dissect_ldap_SET_OF_AttributeValue(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1562 offset = dissect_ber_set_of(implicit_tag, pinfo, tree, tvb, offset,
1563 SET_OF_AttributeValue_set_of, hf_index, ett_ldap_SET_OF_AttributeValue);
1567 static int dissect_vals(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1568 return dissect_ldap_SET_OF_AttributeValue(FALSE, tvb, offset, pinfo, tree, hf_ldap_vals);
1572 static const ber_sequence_t PartialAttributeList_item_sequence[] = {
1573 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_type },
1574 { BER_CLASS_UNI, BER_UNI_TAG_SET, BER_FLAGS_NOOWNTAG, dissect_vals },
1579 dissect_ldap_PartialAttributeList_item(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1580 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1581 PartialAttributeList_item_sequence, hf_index, ett_ldap_PartialAttributeList_item);
1585 static int dissect_PartialAttributeList_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1586 return dissect_ldap_PartialAttributeList_item(FALSE, tvb, offset, pinfo, tree, hf_ldap_PartialAttributeList_item);
1590 static const ber_sequence_t PartialAttributeList_sequence_of[1] = {
1591 { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_PartialAttributeList_item },
1595 dissect_ldap_PartialAttributeList(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1596 offset = dissect_ber_sequence_of(implicit_tag, pinfo, tree, tvb, offset,
1597 PartialAttributeList_sequence_of, hf_index, ett_ldap_PartialAttributeList);
1601 static int dissect_searchResultEntry_attributes(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1602 return dissect_ldap_PartialAttributeList(FALSE, tvb, offset, pinfo, tree, hf_ldap_searchResultEntry_attributes);
1606 static const ber_sequence_t SearchResultEntry_sequence[] = {
1607 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_objectName },
1608 { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_searchResultEntry_attributes },
1613 dissect_ldap_SearchResultEntry(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1614 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1615 SearchResultEntry_sequence, hf_index, ett_ldap_SearchResultEntry);
1619 static int dissect_searchResEntry(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1620 return dissect_ldap_SearchResultEntry(FALSE, tvb, offset, pinfo, tree, hf_ldap_searchResEntry);
1624 static const value_string ldap_T_resultCode_vals[] = {
1626 { 1, "operationsError" },
1627 { 2, "protocolError" },
1628 { 3, "timeLimitExceeded" },
1629 { 4, "sizeLimitExceeded" },
1630 { 5, "compareFalse" },
1631 { 6, "compareTrue" },
1632 { 7, "authMethodNotSupported" },
1633 { 8, "strongAuthRequired" },
1635 { 11, "adminLimitExceeded" },
1636 { 12, "unavailableCriticalExtension" },
1637 { 13, "confidentialityRequired" },
1638 { 14, "saslBindInProgress" },
1639 { 16, "noSuchAttribute" },
1640 { 17, "undefinedAttributeType" },
1641 { 18, "inappropriateMatching" },
1642 { 19, "constraintViolation" },
1643 { 20, "attributeOrValueExists" },
1644 { 21, "invalidAttributeSyntax" },
1645 { 32, "noSuchObject" },
1646 { 33, "aliasProblem" },
1647 { 34, "invalidDNSyntax" },
1648 { 36, "aliasDereferencingProblem" },
1649 { 48, "inappropriateAuthentication" },
1650 { 49, "invalidCredentials" },
1651 { 50, "insufficientAccessRights" },
1653 { 52, "unavailable" },
1654 { 53, "unwillingToPerform" },
1655 { 54, "loopDetect" },
1656 { 64, "namingViolation" },
1657 { 65, "objectClassViolation" },
1658 { 66, "notAllowedOnNonLeaf" },
1659 { 67, "notAllowedOnRDN" },
1660 { 68, "entryAlreadyExists" },
1661 { 69, "objectClassModsProhibited" },
1662 { 71, "affectsMultipleDSAs" },
1669 dissect_ldap_T_resultCode(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1670 #line 318 "ldap.cnf"
1672 const gchar *valstr;
1674 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1678 ldap_do_protocolop(pinfo);
1682 valstr = val_to_str(result, ldap_T_resultCode_vals, "Unknown result(%u)");
1684 if (check_col(pinfo->cinfo, COL_INFO))
1685 col_append_fstr(pinfo->cinfo, COL_INFO, "%s ", valstr);
1688 proto_item_append_text(ldm_tree, " %s", valstr);
1696 static int dissect_resultCode(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1697 return dissect_ldap_T_resultCode(FALSE, tvb, offset, pinfo, tree, hf_ldap_resultCode);
1701 static const ber_sequence_t LDAPResult_sequence[] = {
1702 { BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_resultCode },
1703 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_matchedDN },
1704 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_errorMessage },
1705 { BER_CLASS_CON, 3, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_referral_impl },
1710 dissect_ldap_LDAPResult(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1711 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1712 LDAPResult_sequence, hf_index, ett_ldap_LDAPResult);
1720 dissect_ldap_SearchResultDone(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1721 offset = dissect_ldap_LDAPResult(implicit_tag, tvb, offset, pinfo, tree, hf_index);
1725 static int dissect_searchResDone(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1726 return dissect_ldap_SearchResultDone(FALSE, tvb, offset, pinfo, tree, hf_ldap_searchResDone);
1730 static const ber_sequence_t SearchResultReference_sequence_of[1] = {
1731 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_SearchResultReference_item },
1735 dissect_ldap_SearchResultReference(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1736 offset = dissect_ber_sequence_of(implicit_tag, pinfo, tree, tvb, offset,
1737 SearchResultReference_sequence_of, hf_index, ett_ldap_SearchResultReference);
1741 static int dissect_searchResRef(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1742 return dissect_ldap_SearchResultReference(FALSE, tvb, offset, pinfo, tree, hf_ldap_searchResRef);
1746 static const value_string ldap_T_operation_vals[] = {
1755 dissect_ldap_T_operation(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1756 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
1761 static int dissect_operation(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1762 return dissect_ldap_T_operation(FALSE, tvb, offset, pinfo, tree, hf_ldap_operation);
1766 static const ber_sequence_t AttributeTypeAndValues_sequence[] = {
1767 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_type },
1768 { BER_CLASS_UNI, BER_UNI_TAG_SET, BER_FLAGS_NOOWNTAG, dissect_vals },
1773 dissect_ldap_AttributeTypeAndValues(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1774 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1775 AttributeTypeAndValues_sequence, hf_index, ett_ldap_AttributeTypeAndValues);
1779 static int dissect_modification(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1780 return dissect_ldap_AttributeTypeAndValues(FALSE, tvb, offset, pinfo, tree, hf_ldap_modification);
1784 static const ber_sequence_t T_modification_item_sequence[] = {
1785 { BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_operation },
1786 { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_modification },
1791 dissect_ldap_T_modification_item(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1792 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1793 T_modification_item_sequence, hf_index, ett_ldap_T_modification_item);
1797 static int dissect_modification_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1798 return dissect_ldap_T_modification_item(FALSE, tvb, offset, pinfo, tree, hf_ldap_modification_item);
1802 static const ber_sequence_t ModifyRequest_modification_sequence_of[1] = {
1803 { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_modification_item },
1807 dissect_ldap_ModifyRequest_modification(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1808 offset = dissect_ber_sequence_of(implicit_tag, pinfo, tree, tvb, offset,
1809 ModifyRequest_modification_sequence_of, hf_index, ett_ldap_ModifyRequest_modification);
1813 static int dissect_modifyRequest_modification(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1814 return dissect_ldap_ModifyRequest_modification(FALSE, tvb, offset, pinfo, tree, hf_ldap_modifyRequest_modification);
1818 static const ber_sequence_t ModifyRequest_sequence[] = {
1819 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_object },
1820 { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_modifyRequest_modification },
1825 dissect_ldap_ModifyRequest(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1826 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1827 ModifyRequest_sequence, hf_index, ett_ldap_ModifyRequest);
1831 static int dissect_modifyRequest(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1832 return dissect_ldap_ModifyRequest(FALSE, tvb, offset, pinfo, tree, hf_ldap_modifyRequest);
1838 dissect_ldap_ModifyResponse(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1839 offset = dissect_ldap_LDAPResult(implicit_tag, tvb, offset, pinfo, tree, hf_index);
1843 static int dissect_modifyResponse(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1844 return dissect_ldap_ModifyResponse(FALSE, tvb, offset, pinfo, tree, hf_ldap_modifyResponse);
1848 static const ber_sequence_t AttributeList_item_sequence[] = {
1849 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_type },
1850 { BER_CLASS_UNI, BER_UNI_TAG_SET, BER_FLAGS_NOOWNTAG, dissect_vals },
1855 dissect_ldap_AttributeList_item(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1856 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1857 AttributeList_item_sequence, hf_index, ett_ldap_AttributeList_item);
1861 static int dissect_AttributeList_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1862 return dissect_ldap_AttributeList_item(FALSE, tvb, offset, pinfo, tree, hf_ldap_AttributeList_item);
1866 static const ber_sequence_t AttributeList_sequence_of[1] = {
1867 { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_AttributeList_item },
1871 dissect_ldap_AttributeList(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1872 offset = dissect_ber_sequence_of(implicit_tag, pinfo, tree, tvb, offset,
1873 AttributeList_sequence_of, hf_index, ett_ldap_AttributeList);
1877 static int dissect_attributes(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1878 return dissect_ldap_AttributeList(FALSE, tvb, offset, pinfo, tree, hf_ldap_attributes);
1882 static const ber_sequence_t AddRequest_sequence[] = {
1883 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_entry },
1884 { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_attributes },
1889 dissect_ldap_AddRequest(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1890 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1891 AddRequest_sequence, hf_index, ett_ldap_AddRequest);
1895 static int dissect_addRequest(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1896 return dissect_ldap_AddRequest(FALSE, tvb, offset, pinfo, tree, hf_ldap_addRequest);
1902 dissect_ldap_AddResponse(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1903 offset = dissect_ldap_LDAPResult(implicit_tag, tvb, offset, pinfo, tree, hf_index);
1907 static int dissect_addResponse(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1908 return dissect_ldap_AddResponse(FALSE, tvb, offset, pinfo, tree, hf_ldap_addResponse);
1914 dissect_ldap_DelRequest(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1915 offset = dissect_ldap_LDAPDN(implicit_tag, tvb, offset, pinfo, tree, hf_index);
1919 static int dissect_delRequest(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1920 return dissect_ldap_DelRequest(FALSE, tvb, offset, pinfo, tree, hf_ldap_delRequest);
1926 dissect_ldap_DelResponse(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1927 offset = dissect_ldap_LDAPResult(implicit_tag, tvb, offset, pinfo, tree, hf_index);
1931 static int dissect_delResponse(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1932 return dissect_ldap_DelResponse(FALSE, tvb, offset, pinfo, tree, hf_ldap_delResponse);
1938 dissect_ldap_RelativeLDAPDN(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1939 offset = dissect_ldap_LDAPString(implicit_tag, tvb, offset, pinfo, tree, hf_index);
1943 static int dissect_newrdn(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1944 return dissect_ldap_RelativeLDAPDN(FALSE, tvb, offset, pinfo, tree, hf_ldap_newrdn);
1948 static const ber_sequence_t ModifyDNRequest_sequence[] = {
1949 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_entry },
1950 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_newrdn },
1951 { BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_NOOWNTAG, dissect_deleteoldrdn },
1952 { BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_newSuperior_impl },
1957 dissect_ldap_ModifyDNRequest(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1958 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1959 ModifyDNRequest_sequence, hf_index, ett_ldap_ModifyDNRequest);
1963 static int dissect_modDNRequest(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1964 return dissect_ldap_ModifyDNRequest(FALSE, tvb, offset, pinfo, tree, hf_ldap_modDNRequest);
1970 dissect_ldap_ModifyDNResponse(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1971 offset = dissect_ldap_LDAPResult(implicit_tag, tvb, offset, pinfo, tree, hf_index);
1975 static int dissect_modDNResponse(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1976 return dissect_ldap_ModifyDNResponse(FALSE, tvb, offset, pinfo, tree, hf_ldap_modDNResponse);
1980 static const ber_sequence_t CompareRequest_sequence[] = {
1981 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_entry },
1982 { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ava },
1987 dissect_ldap_CompareRequest(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
1988 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
1989 CompareRequest_sequence, hf_index, ett_ldap_CompareRequest);
1993 static int dissect_compareRequest(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
1994 return dissect_ldap_CompareRequest(FALSE, tvb, offset, pinfo, tree, hf_ldap_compareRequest);
2000 dissect_ldap_CompareResponse(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2001 offset = dissect_ldap_LDAPResult(implicit_tag, tvb, offset, pinfo, tree, hf_index);
2005 static int dissect_compareResponse(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2006 return dissect_ldap_CompareResponse(FALSE, tvb, offset, pinfo, tree, hf_ldap_compareResponse);
2012 dissect_ldap_AbandonRequest(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2013 offset = dissect_ldap_MessageID(implicit_tag, tvb, offset, pinfo, tree, hf_index);
2017 static int dissect_abandonRequest(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2018 return dissect_ldap_AbandonRequest(FALSE, tvb, offset, pinfo, tree, hf_ldap_abandonRequest);
2024 dissect_ldap_LDAPOID(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2027 tvbuff_t *parameter_tvb;
2029 proto_item *item = NULL;
2033 offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
2039 item = get_ber_last_created_item();
2040 name = get_oid_str_name(tvb_get_string(parameter_tvb, 0, tvb_length_remaining(parameter_tvb,0)));
2042 proto_item_append_text(item, " (%s)", name);
2043 proto_item_append_text(tree, " %s", name);
2050 static int dissect_requestName_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2051 return dissect_ldap_LDAPOID(TRUE, tvb, offset, pinfo, tree, hf_ldap_requestName);
2057 dissect_ldap_OCTET_STRING(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2058 offset = dissect_ber_octet_string(implicit_tag, pinfo, tree, tvb, offset, hf_index,
2063 static int dissect_controlValue(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2064 return dissect_ldap_OCTET_STRING(FALSE, tvb, offset, pinfo, tree, hf_ldap_controlValue);
2066 static int dissect_requestValue_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2067 return dissect_ldap_OCTET_STRING(TRUE, tvb, offset, pinfo, tree, hf_ldap_requestValue);
2069 static int dissect_response_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2070 return dissect_ldap_OCTET_STRING(TRUE, tvb, offset, pinfo, tree, hf_ldap_response);
2074 static const ber_sequence_t ExtendedRequest_sequence[] = {
2075 { BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_requestName_impl },
2076 { BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_requestValue_impl },
2081 dissect_ldap_ExtendedRequest(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2082 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
2083 ExtendedRequest_sequence, hf_index, ett_ldap_ExtendedRequest);
2087 static int dissect_extendedReq(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2088 return dissect_ldap_ExtendedRequest(FALSE, tvb, offset, pinfo, tree, hf_ldap_extendedReq);
2092 static const value_string ldap_ExtendedResponse_resultCode_vals[] = {
2094 { 1, "operationsError" },
2095 { 2, "protocolError" },
2096 { 3, "timeLimitExceeded" },
2097 { 4, "sizeLimitExceeded" },
2098 { 5, "compareFalse" },
2099 { 6, "compareTrue" },
2100 { 7, "authMethodNotSupported" },
2101 { 8, "strongAuthRequired" },
2103 { 11, "adminLimitExceeded" },
2104 { 12, "unavailableCriticalExtension" },
2105 { 13, "confidentialityRequired" },
2106 { 14, "saslBindInProgress" },
2107 { 16, "noSuchAttribute" },
2108 { 17, "undefinedAttributeType" },
2109 { 18, "inappropriateMatching" },
2110 { 19, "constraintViolation" },
2111 { 20, "attributeOrValueExists" },
2112 { 21, "invalidAttributeSyntax" },
2113 { 32, "noSuchObject" },
2114 { 33, "aliasProblem" },
2115 { 34, "invalidDNSyntax" },
2116 { 36, "aliasDereferencingProblem" },
2117 { 48, "inappropriateAuthentication" },
2118 { 49, "invalidCredentials" },
2119 { 50, "insufficientAccessRights" },
2121 { 52, "unavailable" },
2122 { 53, "unwillingToPerform" },
2123 { 54, "loopDetect" },
2124 { 64, "namingViolation" },
2125 { 65, "objectClassViolation" },
2126 { 66, "notAllowedOnNonLeaf" },
2127 { 67, "notAllowedOnRDN" },
2128 { 68, "entryAlreadyExists" },
2129 { 69, "objectClassModsProhibited" },
2130 { 71, "affectsMultipleDSAs" },
2137 dissect_ldap_ExtendedResponse_resultCode(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2138 offset = dissect_ber_integer(implicit_tag, pinfo, tree, tvb, offset, hf_index,
2143 static int dissect_extendedResponse_resultCode(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2144 return dissect_ldap_ExtendedResponse_resultCode(FALSE, tvb, offset, pinfo, tree, hf_ldap_extendedResponse_resultCode);
2150 dissect_ldap_ResponseName(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2151 offset = dissect_ldap_LDAPOID(implicit_tag, tvb, offset, pinfo, tree, hf_index);
2155 static int dissect_responseName_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2156 return dissect_ldap_ResponseName(TRUE, tvb, offset, pinfo, tree, hf_ldap_responseName);
2160 static const ber_sequence_t ExtendedResponse_sequence[] = {
2161 { BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_extendedResponse_resultCode },
2162 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_matchedDN },
2163 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_errorMessage },
2164 { BER_CLASS_CON, 3, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_referral_impl },
2165 { BER_CLASS_CON, 10, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_responseName_impl },
2166 { BER_CLASS_CON, 11, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_response_impl },
2171 dissect_ldap_ExtendedResponse(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2172 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
2173 ExtendedResponse_sequence, hf_index, ett_ldap_ExtendedResponse);
2177 static int dissect_extendedResp(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2178 return dissect_ldap_ExtendedResponse(FALSE, tvb, offset, pinfo, tree, hf_ldap_extendedResp);
2182 static const value_string ldap_ProtocolOp_vals[] = {
2183 { 0, "bindRequest" },
2184 { 1, "bindResponse" },
2185 { 2, "unbindRequest" },
2186 { 3, "searchRequest" },
2187 { 4, "searchResEntry" },
2188 { 5, "searchResDone" },
2189 { 19, "searchResRef" },
2190 { 6, "modifyRequest" },
2191 { 7, "modifyResponse" },
2192 { 8, "addRequest" },
2193 { 9, "addResponse" },
2194 { 10, "delRequest" },
2195 { 11, "delResponse" },
2196 { 12, "modDNRequest" },
2197 { 13, "modDNResponse" },
2198 { 14, "compareRequest" },
2199 { 15, "compareResponse" },
2200 { 16, "abandonRequest" },
2201 { 23, "extendedReq" },
2202 { 24, "extendedResp" },
2206 static const ber_choice_t ProtocolOp_choice[] = {
2207 { 0, BER_CLASS_APP, 0, BER_FLAGS_NOOWNTAG, dissect_bindRequest },
2208 { 1, BER_CLASS_APP, 1, BER_FLAGS_NOOWNTAG, dissect_bindResponse },
2209 { 2, BER_CLASS_APP, 2, BER_FLAGS_NOOWNTAG, dissect_unbindRequest },
2210 { 3, BER_CLASS_APP, 3, BER_FLAGS_NOOWNTAG, dissect_searchRequest },
2211 { 4, BER_CLASS_APP, 4, BER_FLAGS_NOOWNTAG, dissect_searchResEntry },
2212 { 5, BER_CLASS_APP, 5, BER_FLAGS_NOOWNTAG, dissect_searchResDone },
2213 { 19, BER_CLASS_APP, 19, BER_FLAGS_NOOWNTAG, dissect_searchResRef },
2214 { 6, BER_CLASS_APP, 6, BER_FLAGS_NOOWNTAG, dissect_modifyRequest },
2215 { 7, BER_CLASS_APP, 7, BER_FLAGS_NOOWNTAG, dissect_modifyResponse },
2216 { 8, BER_CLASS_APP, 8, BER_FLAGS_NOOWNTAG, dissect_addRequest },
2217 { 9, BER_CLASS_APP, 9, BER_FLAGS_NOOWNTAG, dissect_addResponse },
2218 { 10, BER_CLASS_APP, 10, BER_FLAGS_NOOWNTAG, dissect_delRequest },
2219 { 11, BER_CLASS_APP, 11, BER_FLAGS_NOOWNTAG, dissect_delResponse },
2220 { 12, BER_CLASS_APP, 12, BER_FLAGS_NOOWNTAG, dissect_modDNRequest },
2221 { 13, BER_CLASS_APP, 13, BER_FLAGS_NOOWNTAG, dissect_modDNResponse },
2222 { 14, BER_CLASS_APP, 14, BER_FLAGS_NOOWNTAG, dissect_compareRequest },
2223 { 15, BER_CLASS_APP, 15, BER_FLAGS_NOOWNTAG, dissect_compareResponse },
2224 { 16, BER_CLASS_APP, 16, BER_FLAGS_NOOWNTAG, dissect_abandonRequest },
2225 { 23, BER_CLASS_APP, 23, BER_FLAGS_NOOWNTAG, dissect_extendedReq },
2226 { 24, BER_CLASS_APP, 24, BER_FLAGS_NOOWNTAG, dissect_extendedResp },
2227 { 0, 0, 0, 0, NULL }
2231 dissect_ldap_ProtocolOp(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2234 ldap_call_response_t *lcrp;
2235 ldap_conv_info_t *ldap_info = (ldap_conv_info_t *)pinfo->private_data;
2236 do_protocolop = TRUE;
2239 offset = dissect_ber_choice(pinfo, tree, tvb, offset,
2240 ProtocolOp_choice, hf_index, ett_ldap_ProtocolOp,
2245 lcrp=ldap_match_call_response(tvb, pinfo, tree, MessageID, ProtocolOp);
2247 tap_queue_packet(ldap_tap, pinfo, lcrp);
2250 /* XXX: the count will not work if the results span multiple TCP packets */
2252 if(ldap_info && tree) { /* only count once - on tree pass */
2253 switch(ProtocolOp) {
2255 case LDAP_RES_SEARCH_ENTRY:
2256 ldap_info->num_results++;
2258 proto_item_append_text(tree, " [%d result%s]",
2259 ldap_info->num_results, ldap_info->num_results == 1 ? "" : "s");
2263 case LDAP_RES_SEARCH_RESULT:
2265 if (check_col(pinfo->cinfo, COL_INFO))
2266 col_append_fstr(pinfo->cinfo, COL_INFO, " [%d result%s]",
2267 ldap_info->num_results, ldap_info->num_results == 1 ? "" : "s");
2269 proto_item_append_text(tree, " [%d result%s]",
2270 ldap_info->num_results, ldap_info->num_results == 1 ? "" : "s");
2272 ldap_info->num_results = 0;
2282 static int dissect_protocolOp(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2283 return dissect_ldap_ProtocolOp(FALSE, tvb, offset, pinfo, tree, hf_ldap_protocolOp);
2289 dissect_ldap_ControlType(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2290 offset = dissect_ldap_LDAPOID(implicit_tag, tvb, offset, pinfo, tree, hf_index);
2294 static int dissect_controlType(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2295 return dissect_ldap_ControlType(FALSE, tvb, offset, pinfo, tree, hf_ldap_controlType);
2299 static const ber_sequence_t Control_sequence[] = {
2300 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_controlType },
2301 { BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_criticality },
2302 { BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_controlValue },
2307 dissect_ldap_Control(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2308 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
2309 Control_sequence, hf_index, ett_ldap_Control);
2313 static int dissect_Controls_item(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2314 return dissect_ldap_Control(FALSE, tvb, offset, pinfo, tree, hf_ldap_Controls_item);
2318 static const ber_sequence_t Controls_sequence_of[1] = {
2319 { BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_Controls_item },
2323 dissect_ldap_Controls(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2324 offset = dissect_ber_sequence_of(implicit_tag, pinfo, tree, tvb, offset,
2325 Controls_sequence_of, hf_index, ett_ldap_Controls);
2329 static int dissect_controls_impl(packet_info *pinfo, proto_tree *tree, tvbuff_t *tvb, int offset) {
2330 return dissect_ldap_Controls(TRUE, tvb, offset, pinfo, tree, hf_ldap_controls);
2334 static const ber_sequence_t LDAPMessage_sequence[] = {
2335 { BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_messageID },
2336 { BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_protocolOp },
2337 { BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_controls_impl },
2342 dissect_ldap_LDAPMessage(gboolean implicit_tag _U_, tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree, int hf_index _U_) {
2343 offset = dissect_ber_sequence(implicit_tag, pinfo, tree, tvb, offset,
2344 LDAPMessage_sequence, hf_index, ett_ldap_LDAPMessage);
2353 static void dissect_LDAPMessage_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
2354 dissect_ldap_LDAPMessage(FALSE, tvb, 0, pinfo, tree, hf_ldap_LDAPMessage_PDU);
2358 /*--- End of included file: packet-ldap-fn.c ---*/
2359 #line 398 "packet-ldap-template.c"
2362 dissect_ldap_payload(tvbuff_t *tvb, packet_info *pinfo,
2363 proto_tree *tree, ldap_conv_info_t *ldap_info,
2364 gboolean rest_is_pad, gboolean is_mscldap)
2367 gboolean first_time = TRUE;
2368 guint length_remaining;
2370 int messageOffset = 0;
2371 guint headerLength = 0;
2373 tvbuff_t *msg_tvb = NULL;
2375 gboolean pc, ind = 0;
2378 while (tvb_reported_length_remaining(tvb, offset) > 0) {
2380 * This will throw an exception if we don't have any data left.
2381 * That's what we want. (See "tcp_dissect_pdus()", which is
2384 length_remaining = tvb_ensure_length_remaining(tvb, offset);
2386 if (rest_is_pad && length_remaining < 6) return;
2390 * with a "Sequence Of" header.
2391 * Can we do reassembly?
2393 if (ldap_desegment && pinfo->can_desegment) {
2395 * Yes - is the "Sequence Of" header split across segment
2396 * boundaries? We require at least 6 bytes for the header
2397 * which allows for a 4 byte length (ASN.1 BER).
2399 if (length_remaining < 6) {
2400 /* stop if the caller says that we are given all data and the rest is padding
2401 * this is for the SASL GSSAPI case when the data is only signed and not sealed
2403 pinfo->desegment_offset = offset;
2404 pinfo->desegment_len = 6 - length_remaining;
2410 * OK, try to read the "Sequence Of" header; this gets the total
2411 * length of the LDAP message.
2413 messageOffset = get_ber_identifier(tvb, offset, &class, &pc, &ber_tag);
2414 messageOffset = get_ber_length(tree, tvb, messageOffset, &msg_len, &ind);
2416 if (ber_tag == BER_UNI_TAG_SEQUENCE) {
2418 * Add the length of the "Sequence Of" header to the message
2421 headerLength = messageOffset - offset;
2422 msg_len += headerLength;
2423 if (msg_len < headerLength) {
2425 * The message length was probably so large that the total length
2428 * Report this as an error.
2430 show_reported_bounds_error(tvb, pinfo, tree);
2435 * We couldn't parse the header; just make it the amount of data
2436 * remaining in the tvbuff, so we'll give up on this segment
2437 * after attempting to parse the message - there's nothing more
2438 * we can do. "dissect_ldap_message()" will display the error.
2440 msg_len = length_remaining;
2444 * Is the message split across segment boundaries?
2446 if (length_remaining < msg_len) {
2447 /* provide a hint to TCP where the next PDU starts */
2448 pinfo->want_pdu_tracking=2;
2449 pinfo->bytes_until_next_pdu= msg_len - length_remaining;
2451 * Can we do reassembly?
2453 if (ldap_desegment && pinfo->can_desegment) {
2455 * Yes. Tell the TCP dissector where the data for this message
2456 * starts in the data it handed us, and how many more bytes
2457 * we need, and return.
2459 pinfo->desegment_offset = offset;
2460 pinfo->desegment_len = msg_len - length_remaining;
2467 * Construct a tvbuff containing the amount of the payload we have
2468 * available. Make its reported length the amount of data in the
2471 * XXX - if reassembly isn't enabled. the subdissector will throw a
2472 * BoundsError exception, rather than a ReportedBoundsError exception.
2473 * We really want a tvbuff where the length is "length", the reported
2474 * length is "plen", and the "if the snapshot length were infinite"
2475 * length is the minimum of the reported length of the tvbuff handed
2476 * to us and "plen", with a new type of exception thrown if the offset
2477 * is within the reported length but beyond that third length, with
2478 * that exception getting the "Unreassembled Packet" error.
2480 length = length_remaining;
2481 if (length > msg_len) length = msg_len;
2482 msg_tvb = tvb_new_subset(tvb, offset, length, msg_len);
2485 * Now dissect the LDAP message.
2488 /*dissect_ldap_message(msg_tvb, 0, pinfo, msg_tree, msg_item, first_time, ldap_info, is_mscldap);*/
2489 ldap_info->first_time= first_time;
2490 ldap_info->is_mscldap = is_mscldap;
2491 pinfo->private_data = ldap_info;
2492 dissect_LDAPMessage_PDU(msg_tvb, pinfo, tree);
2502 dissect_ldap_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean is_mscldap)
2505 conversation_t *conversation;
2506 gboolean doing_sasl_security = FALSE;
2507 guint length_remaining;
2508 ldap_conv_info_t *ldap_info = NULL;
2509 proto_item *ldap_item = NULL;
2510 proto_tree *ldap_tree = NULL;
2513 * Do we have a conversation for this connection?
2515 conversation = find_conversation(pinfo->fd->num, &pinfo->src, &pinfo->dst,
2516 pinfo->ptype, pinfo->srcport,
2517 pinfo->destport, 0);
2518 if (conversation == NULL) {
2519 /* We don't yet have a conversation, so create one. */
2520 conversation = conversation_new(pinfo->fd->num, &pinfo->src, &pinfo->dst,
2521 pinfo->ptype, pinfo->srcport,
2522 pinfo->destport, 0);
2527 * Do we already have a type and mechanism?
2529 ldap_info = conversation_get_proto_data(conversation, proto_ldap);
2530 if (ldap_info == NULL) {
2531 /* No. Attach that information to the conversation, and add
2532 * it to the list of information structures.
2534 ldap_info = se_alloc(sizeof(ldap_conv_info_t));
2535 ldap_info->auth_type = 0;
2536 ldap_info->auth_mech = 0;
2537 ldap_info->first_auth_frame = 0;
2538 ldap_info->matched=g_hash_table_new(ldap_info_hash_matched, ldap_info_equal_matched);
2539 ldap_info->unmatched=g_hash_table_new(ldap_info_hash_unmatched, ldap_info_equal_unmatched);
2540 ldap_info->num_results = 0;
2542 conversation_add_proto_data(conversation, proto_ldap, ldap_info);
2544 ldap_info->next = ldap_info_items;
2545 ldap_info_items = ldap_info;
2549 switch (ldap_info->auth_type) {
2550 case LDAP_AUTH_SASL:
2552 * It's SASL; are we using a security layer?
2554 if (ldap_info->first_auth_frame != 0 &&
2555 pinfo->fd->num >= ldap_info->first_auth_frame) {
2556 doing_sasl_security = TRUE; /* yes */
2560 while (tvb_reported_length_remaining(tvb, offset) > 0) {
2563 * This will throw an exception if we don't have any data left.
2564 * That's what we want. (See "tcp_dissect_pdus()", which is
2565 * similar, but doesn't have to deal with the SASL issues.
2566 * XXX - can we make "tcp_dissect_pdus()" provide enough information
2567 * to the "get_pdu_len" routine so that we could have one dealing
2568 * with the SASL issues, have that routine deal with SASL and
2569 * ASN.1, and just use "tcp_dissect_pdus()"?)
2571 length_remaining = tvb_ensure_length_remaining(tvb, offset);
2574 * Try to find out if we have a plain LDAP buffer
2575 * with a "Sequence Of" header or a SASL buffer with
2576 * Can we do reassembly?
2578 if (ldap_desegment && pinfo->can_desegment) {
2580 * Yes - is the "Sequence Of" header split across segment
2581 * boundaries? We require at least 6 bytes for the header
2582 * which allows for a 4 byte length (ASN.1 BER).
2583 * For the SASL case we need at least 4 bytes, so this is
2584 * no problem here because we check for 6 bytes ans sasl buffers
2585 * with less than 2 bytes should not exist...
2587 if (length_remaining < 6) {
2588 pinfo->desegment_offset = offset;
2589 pinfo->desegment_len = 6 - length_remaining;
2594 /* It might still be a packet containing a SASL security layer
2595 * but its just that we never saw the BIND packet.
2596 * check if it looks like it could be a SASL blob here
2597 * and in that case just assume it is GSS-SPNEGO
2599 if(!doing_sasl_security && (tvb_bytes_exist(tvb, offset, 5))
2600 &&(tvb_get_ntohl(tvb, offset)<=(guint)(tvb_reported_length_remaining(tvb, offset)-4))
2601 &&(tvb_get_guint8(tvb, offset+4)==0x60) ){
2602 ldap_info->auth_type=LDAP_AUTH_SASL;
2603 ldap_info->first_auth_frame=pinfo->fd->num;
2604 ldap_info->auth_mech=g_strdup("GSS-SPNEGO");
2605 doing_sasl_security=TRUE;
2609 * This is the first PDU, set the Protocol column and clear the
2612 if (check_col(pinfo->cinfo, COL_PROTOCOL)) col_set_str(pinfo->cinfo, COL_PROTOCOL, pinfo->current_proto);
2613 if (check_col(pinfo->cinfo, COL_INFO)) col_clear(pinfo->cinfo, COL_INFO);
2615 ldap_item = proto_tree_add_item(tree, proto_ldap, tvb, 0, -1, FALSE);
2616 ldap_tree = proto_item_add_subtree(ldap_item, ett_ldap);
2619 * Might we be doing a SASL security layer and, if so, *are* we doing
2622 * Just because we've seen a bind reply for SASL, that doesn't mean
2623 * that we're using a SASL security layer; I've seen captures in
2624 * which some SASL negotiations lead to a security layer being used
2625 * and other negotiations don't, and it's not obvious what's different
2626 * in the two negotiations. Therefore, we assume that if the first
2627 * byte is 0, it's a length for a SASL security layer (that way, we
2628 * never reassemble more than 16 megabytes, protecting us from
2629 * chewing up *too* much memory), and otherwise that it's an LDAP
2630 * message (actually, if it's an LDAP message it should begin with 0x30,
2631 * but we want to parse garbage as LDAP messages rather than really
2635 if (doing_sasl_security && tvb_get_guint8(tvb, offset) == 0) {
2636 proto_item *sasl_item = NULL;
2637 proto_tree *sasl_tree = NULL;
2639 guint sasl_len, sasl_msg_len, length;
2641 * Yes. The frame begins with a 4-byte big-endian length.
2642 * And we know we have at least 6 bytes
2646 * Get the SASL length, which is the length of data in the buffer
2647 * following the length (i.e., it's 4 less than the total length).
2649 * XXX - do we need to reassemble buffers? For now, we
2650 * assume that each LDAP message is entirely contained within
2653 sasl_len = tvb_get_ntohl(tvb, offset);
2654 sasl_msg_len = sasl_len + 4;
2655 if (sasl_msg_len < 4) {
2657 * The message length was probably so large that the total length
2660 * Report this as an error.
2662 show_reported_bounds_error(tvb, pinfo, tree);
2667 * Is the buffer split across segment boundaries?
2669 if (length_remaining < sasl_msg_len) {
2670 /* provide a hint to TCP where the next PDU starts */
2671 pinfo->want_pdu_tracking = 2;
2672 pinfo->bytes_until_next_pdu= sasl_msg_len - length_remaining;
2674 * Can we do reassembly?
2676 if (ldap_desegment && pinfo->can_desegment) {
2678 * Yes. Tell the TCP dissector where the data for this message
2679 * starts in the data it handed us, and how many more bytes we
2682 pinfo->desegment_offset = offset;
2683 pinfo->desegment_len = sasl_msg_len - length_remaining;
2689 * Construct a tvbuff containing the amount of the payload we have
2690 * available. Make its reported length the amount of data in the PDU.
2692 * XXX - if reassembly isn't enabled. the subdissector will throw a
2693 * BoundsError exception, rather than a ReportedBoundsError exception.
2694 * We really want a tvbuff where the length is "length", the reported
2695 * length is "plen", and the "if the snapshot length were infinite"
2696 * length is the minimum of the reported length of the tvbuff handed
2697 * to us and "plen", with a new type of exception thrown if the offset
2698 * is within the reported length but beyond that third length, with
2699 * that exception getting the "Unreassembled Packet" error.
2701 length = length_remaining;
2702 if (length > sasl_msg_len) length = sasl_msg_len;
2703 sasl_tvb = tvb_new_subset(tvb, offset, length, sasl_msg_len);
2706 proto_tree_add_uint(ldap_tree, hf_ldap_sasl_buffer_length, sasl_tvb, 0, 4,
2709 sasl_item = proto_tree_add_text(ldap_tree, sasl_tvb, 0, sasl_msg_len, "SASL buffer");
2710 sasl_tree = proto_item_add_subtree(sasl_item, ett_ldap_sasl_blob);
2713 if (ldap_info->auth_mech != NULL &&
2714 strcmp(ldap_info->auth_mech, "GSS-SPNEGO") == 0) {
2715 tvbuff_t *gssapi_tvb, *plain_tvb = NULL, *decr_tvb= NULL;
2720 * This is GSS-API (using SPNEGO, but we should be done with
2721 * the negotiation by now).
2723 * Dissect the GSS_Wrap() token; it'll return the length of
2724 * the token, from which we compute the offset in the tvbuff at
2725 * which the plaintext data, i.e. the LDAP message, begins.
2727 length = tvb_length_remaining(sasl_tvb, 4);
2728 if ((guint)length > sasl_len)
2730 gssapi_tvb = tvb_new_subset(sasl_tvb, 4, length, sasl_len);
2732 /* Attempt decryption of the GSSAPI wrapped data if possible */
2733 pinfo->decrypt_gssapi_tvb=DECRYPT_GSSAPI_NORMAL;
2734 pinfo->gssapi_wrap_tvb=NULL;
2735 pinfo->gssapi_encrypted_tvb=NULL;
2736 pinfo->gssapi_decrypted_tvb=NULL;
2737 ver_len = call_dissector(gssapi_wrap_handle, gssapi_tvb, pinfo, sasl_tree);
2738 /* if we could unwrap, do a tvb shuffle */
2739 if(pinfo->gssapi_decrypted_tvb){
2740 decr_tvb=pinfo->gssapi_decrypted_tvb;
2743 pinfo->decrypt_gssapi_tvb=0;
2744 pinfo->gssapi_wrap_tvb=NULL;
2745 pinfo->gssapi_encrypted_tvb=NULL;
2746 pinfo->gssapi_decrypted_tvb=NULL;
2749 * if len is 0 it probably mean that we got a PDU that is not
2750 * aligned to the start of the segment.
2757 * if we don't have unwrapped data,
2758 * see if the wrapping involved encryption of the
2759 * data; if not, just use the plaintext data.
2762 if(!pinfo->gssapi_data_encrypted){
2763 plain_tvb = tvb_new_subset(gssapi_tvb, ver_len, -1, -1);
2768 proto_item *enc_item = NULL;
2769 proto_tree *enc_tree = NULL;
2772 * The LDAP message was encrypted in the packet, and has
2773 * been decrypted; dissect the decrypted LDAP message.
2776 enc_item = proto_tree_add_text(sasl_tree, gssapi_tvb, ver_len, -1,
2777 "GSS-API Encrypted payload (%d byte%s)",
2779 plurality(sasl_len - ver_len, "", "s"));
2780 enc_tree = proto_item_add_subtree(enc_item, ett_ldap_payload);
2782 dissect_ldap_payload(decr_tvb, pinfo, enc_tree, ldap_info, TRUE, is_mscldap);
2783 } else if (plain_tvb) {
2784 proto_item *plain_item = NULL;
2785 proto_tree *plain_tree = NULL;
2788 * The LDAP message wasn't encrypted in the packet;
2789 * dissect the plain LDAP message.
2792 plain_item = proto_tree_add_text(sasl_tree, gssapi_tvb, ver_len, -1,
2793 "GSS-API payload (%d byte%s)",
2795 plurality(sasl_len - ver_len, "", "s"));
2796 plain_tree = proto_item_add_subtree(plain_item, ett_ldap_payload);
2799 dissect_ldap_payload(plain_tvb, pinfo, plain_tree, ldap_info, TRUE, is_mscldap);
2802 * The LDAP message was encrypted in the packet, and was
2803 * not decrypted; just show it as encrypted data.
2805 if (check_col(pinfo->cinfo, COL_INFO)) {
2806 col_add_fstr(pinfo->cinfo, COL_INFO, "LDAP GSS-API Encrypted payload (%d byte%s)",
2808 plurality(sasl_len - ver_len, "", "s"));
2811 proto_tree_add_text(sasl_tree, gssapi_tvb, ver_len, -1,
2812 "GSS-API Encrypted payload (%d byte%s)",
2814 plurality(sasl_len - ver_len, "", "s"));
2818 offset += sasl_msg_len;
2820 /* plain LDAP, so dissect the payload */
2821 dissect_ldap_payload(tvb, pinfo, ldap_tree, ldap_info, FALSE, is_mscldap);
2822 /* dissect_ldap_payload() has it's own loop so go out here */
2828 static int dissect_mscldap_string(tvbuff_t *tvb, int offset, char *str, int maxlen, gboolean prepend_dot)
2832 len=tvb_get_guint8(tvb, offset);
2837 /* add potential field separation dot */
2850 /* ops its a mscldap compressed string */
2852 new_offset=tvb_get_guint8(tvb, offset);
2853 if (new_offset == offset - 1)
2854 THROW(ReportedBoundsError);
2857 dissect_mscldap_string(tvb, new_offset, str, maxlen, FALSE);
2871 return offset; /* will mess up offset in caller, is unlikely */
2873 tvb_memcpy(tvb, str, offset, len);
2880 len=tvb_get_guint8(tvb, offset);
2887 /* These flag bits were found to be defined in the samba sources.
2888 * I hope they are correct (but have serious doubts about the CLOSEST
2889 * bit being used or being meaningful).
2891 static const true_false_string tfs_ads_pdc = {
2895 static const true_false_string tfs_ads_gc = {
2896 "This is a GLOBAL CATALOGUE of forest",
2897 "This is NOT a global catalog of forest"
2899 static const true_false_string tfs_ads_ldap = {
2900 "This is an LDAP server",
2901 "This is NOT an ldap server"
2903 static const true_false_string tfs_ads_ds = {
2904 "This dc supports DS",
2905 "This dc does NOT support ds"
2907 static const true_false_string tfs_ads_kdc = {
2908 "This is a KDC (kerberos)",
2909 "This is NOT a kdc (kerberos)"
2911 static const true_false_string tfs_ads_timeserv = {
2912 "This dc is running TIME SERVICES (ntp)",
2913 "This dc is NOT running time services (ntp)"
2915 static const true_false_string tfs_ads_closest = {
2916 "This is the CLOSEST dc (unreliable?)",
2917 "This is NOT the closest dc"
2919 static const true_false_string tfs_ads_writable = {
2920 "This dc is WRITABLE",
2921 "This dc is NOT writable"
2923 static const true_false_string tfs_ads_good_timeserv = {
2924 "This dc has a GOOD TIME SERVICE (i.e. hardware clock)",
2925 "This dc does NOT have a good time service (i.e. no hardware clock)"
2927 static const true_false_string tfs_ads_ndnc = {
2928 "Domain is NON-DOMAIN NC serviced by ldap server",
2929 "Domain is NOT non-domain nc serviced by ldap server"
2931 static int dissect_mscldap_netlogon_flags(proto_tree *parent_tree, tvbuff_t *tvb, int offset)
2935 proto_tree *tree=NULL;
2936 guint fields[] = { hf_mscldap_netlogon_flags_ndnc,
2937 hf_mscldap_netlogon_flags_good_timeserv,
2938 hf_mscldap_netlogon_flags_writable,
2939 hf_mscldap_netlogon_flags_closest,
2940 hf_mscldap_netlogon_flags_timeserv,
2941 hf_mscldap_netlogon_flags_kdc,
2942 hf_mscldap_netlogon_flags_ds,
2943 hf_mscldap_netlogon_flags_ldap,
2944 hf_mscldap_netlogon_flags_gc,
2945 hf_mscldap_netlogon_flags_pdc,
2948 header_field_info *hfi;
2949 gboolean one_bit_set = FALSE;
2951 flags=tvb_get_letohl(tvb, offset);
2952 item=proto_tree_add_item(parent_tree, hf_mscldap_netlogon_flags, tvb, offset, 4, TRUE);
2954 tree = proto_item_add_subtree(item, ett_mscldap_netlogon_flags);
2957 proto_item_append_text(item, " (");
2959 for(field = fields; *field; field++) {
2960 proto_tree_add_boolean(tree, *field, tvb, offset, 4, flags);
2961 hfi = proto_registrar_get_nth(*field);
2963 if(flags & hfi->bitmask) {
2966 proto_item_append_text(item, ", ");
2970 proto_item_append_text(item, hfi->name);
2975 proto_item_append_text(item, ")");
2982 static void dissect_NetLogon_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
2984 int old_offset, offset=0;
2990 /*XXX someone that knows what the type means should add that knowledge here*/
2991 proto_tree_add_item(tree, hf_mscldap_netlogon_type, tvb, offset, 4, TRUE);
2995 offset = dissect_mscldap_netlogon_flags(tree, tvb, offset);
2998 proto_tree_add_item(tree, hf_mscldap_domain_guid, tvb, offset, 16, TRUE);
3003 offset=dissect_mscldap_string(tvb, offset, str, 255, FALSE);
3004 proto_tree_add_string(tree, hf_mscldap_forest, tvb, old_offset, offset-old_offset, str);
3008 offset=dissect_mscldap_string(tvb, offset, str, 255, FALSE);
3009 proto_tree_add_string(tree, hf_mscldap_domain, tvb, old_offset, offset-old_offset, str);
3013 offset=dissect_mscldap_string(tvb, offset, str, 255, FALSE);
3014 proto_tree_add_string(tree, hf_mscldap_hostname, tvb, old_offset, offset-old_offset, str);
3016 /* NetBios Domain */
3018 offset=dissect_mscldap_string(tvb, offset, str, 255, FALSE);
3019 proto_tree_add_string(tree, hf_mscldap_nb_domain, tvb, old_offset, offset-old_offset, str);
3021 /* NetBios Hostname */
3023 offset=dissect_mscldap_string(tvb, offset, str, 255, FALSE);
3024 proto_tree_add_string(tree, hf_mscldap_nb_hostname, tvb, old_offset, offset-old_offset, str);
3028 offset=dissect_mscldap_string(tvb, offset, str, 255, FALSE);
3029 proto_tree_add_string(tree, hf_mscldap_username, tvb, old_offset, offset-old_offset, str);
3033 offset=dissect_mscldap_string(tvb, offset, str, 255, FALSE);
3034 proto_tree_add_string(tree, hf_mscldap_sitename, tvb, old_offset, offset-old_offset, str);
3038 offset=dissect_mscldap_string(tvb, offset, str, 255, FALSE);
3039 proto_tree_add_string(tree, hf_mscldap_clientsitename, tvb, old_offset, offset-old_offset, str);
3042 proto_tree_add_item(tree, hf_mscldap_netlogon_version, tvb, offset, 4, TRUE);
3046 proto_tree_add_item(tree, hf_mscldap_netlogon_lm_token, tvb, offset, 2, TRUE);
3050 proto_tree_add_item(tree, hf_mscldap_netlogon_nt_token, tvb, offset, 2, TRUE);
3057 dissect_ldap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3059 dissect_ldap_pdu(tvb, pinfo, tree, FALSE);
3064 dissect_mscldap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
3066 dissect_ldap_pdu(tvb, pinfo, tree, TRUE);
3074 ldap_conv_info_t *ldap_info;
3076 /* Free up state attached to the ldap_info structures */
3077 for (ldap_info = ldap_info_items; ldap_info != NULL; ldap_info = ldap_info->next) {
3078 if (ldap_info->auth_mech != NULL) {
3079 g_free(ldap_info->auth_mech);
3080 ldap_info->auth_mech=NULL;
3082 g_hash_table_destroy(ldap_info->matched);
3083 ldap_info->matched=NULL;
3084 g_hash_table_destroy(ldap_info->unmatched);
3085 ldap_info->unmatched=NULL;
3088 ldap_info_items = NULL;
3093 register_ldap_name_dissector_handle(const char *attr_type, dissector_handle_t dissector)
3095 dissector_add_string("ldap.name", attr_type, dissector);
3099 register_ldap_name_dissector(const char *attr_type, dissector_t dissector, int proto)
3101 dissector_handle_t dissector_handle;
3103 dissector_handle=create_dissector_handle(dissector, proto);
3104 register_ldap_name_dissector_handle(attr_type, dissector_handle);
3108 /*--- proto_register_ldap -------------------------------------------*/
3109 void proto_register_ldap(void) {
3111 /* List of fields */
3113 static hf_register_info hf[] = {
3115 { &hf_ldap_sasl_buffer_length,
3116 { "SASL Buffer Length", "ldap.sasl_buffer_length",
3117 FT_UINT32, BASE_DEC, NULL, 0x0,
3118 "SASL Buffer Length", HFILL }},
3119 { &hf_ldap_response_in,
3120 { "Response In", "ldap.response_in",
3121 FT_FRAMENUM, BASE_DEC, NULL, 0x0,
3122 "The response to this LDAP request is in this frame", HFILL }},
3123 { &hf_ldap_response_to,
3124 { "Response To", "ldap.response_to",
3125 FT_FRAMENUM, BASE_DEC, NULL, 0x0,
3126 "This is a response to the LDAP request in this frame", HFILL }},
3128 { "Time", "ldap.time",
3129 FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
3130 "The time between the Call and the Reply", HFILL }},
3132 { &hf_mscldap_netlogon_type,
3133 { "Type", "mscldap.netlogon.type",
3134 FT_UINT32, BASE_DEC, NULL, 0x0,
3135 "Type of <please tell ethereal developers what this type is>", HFILL }},
3137 { &hf_mscldap_netlogon_version,
3138 { "Version", "mscldap.netlogon.version",
3139 FT_UINT32, BASE_DEC, NULL, 0x0,
3140 "Version of <please tell ethereal developers what this type is>", HFILL }},
3142 { &hf_mscldap_netlogon_lm_token,
3143 { "LM Token", "mscldap.netlogon.lm_token",
3144 FT_UINT16, BASE_HEX, NULL, 0x0,
3145 "LM Token", HFILL }},
3147 { &hf_mscldap_netlogon_nt_token,
3148 { "NT Token", "mscldap.netlogon.nt_token",
3149 FT_UINT16, BASE_HEX, NULL, 0x0,
3150 "NT Token", HFILL }},
3152 { &hf_mscldap_netlogon_flags,
3153 { "Flags", "mscldap.netlogon.flags",
3154 FT_UINT32, BASE_HEX, NULL, 0x0,
3155 "Netlogon flags describing the DC properties", HFILL }},
3157 { &hf_mscldap_domain_guid,
3158 { "Domain GUID", "mscldap.domain.guid",
3159 FT_BYTES, BASE_HEX, NULL, 0x0,
3160 "Domain GUID", HFILL }},
3162 { &hf_mscldap_forest,
3163 { "Forest", "mscldap.forest",
3164 FT_STRING, BASE_NONE, NULL, 0x0,
3167 { &hf_mscldap_domain,
3168 { "Domain", "mscldap.domain",
3169 FT_STRING, BASE_NONE, NULL, 0x0,
3170 "Domainname", HFILL }},
3172 { &hf_mscldap_hostname,
3173 { "Hostname", "mscldap.hostname",
3174 FT_STRING, BASE_NONE, NULL, 0x0,
3175 "Hostname", HFILL }},
3177 { &hf_mscldap_nb_domain,
3178 { "NetBios Domain", "mscldap.nb_domain",
3179 FT_STRING, BASE_NONE, NULL, 0x0,
3180 "NetBios Domainname", HFILL }},
3182 { &hf_mscldap_nb_hostname,
3183 { "NetBios Hostname", "mscldap.nb_hostname",
3184 FT_STRING, BASE_NONE, NULL, 0x0,
3185 "NetBios Hostname", HFILL }},
3187 { &hf_mscldap_username,
3188 { "User", "mscldap.username",
3189 FT_STRING, BASE_NONE, NULL, 0x0,
3190 "User name", HFILL }},
3192 { &hf_mscldap_sitename,
3193 { "Site", "mscldap.sitename",
3194 FT_STRING, BASE_NONE, NULL, 0x0,
3195 "Site name", HFILL }},
3197 { &hf_mscldap_clientsitename,
3198 { "Client Site", "mscldap.clientsitename",
3199 FT_STRING, BASE_NONE, NULL, 0x0,
3200 "Client Site name", HFILL }},
3202 { &hf_mscldap_netlogon_flags_pdc,
3203 { "PDC", "mscldap.netlogon.flags.pdc", FT_BOOLEAN, 32,
3204 TFS(&tfs_ads_pdc), 0x00000001, "Is this DC a PDC or not?", HFILL }},
3206 { &hf_mscldap_netlogon_flags_gc,
3207 { "GC", "mscldap.netlogon.flags.gc", FT_BOOLEAN, 32,
3208 TFS(&tfs_ads_gc), 0x00000004, "Does this dc service as a GLOBAL CATALOGUE?", HFILL }},
3210 { &hf_mscldap_netlogon_flags_ldap,
3211 { "LDAP", "mscldap.netlogon.flags.ldap", FT_BOOLEAN, 32,
3212 TFS(&tfs_ads_ldap), 0x00000008, "Does this DC act as an LDAP server?", HFILL }},
3214 { &hf_mscldap_netlogon_flags_ds,
3215 { "DS", "mscldap.netlogon.flags.ds", FT_BOOLEAN, 32,
3216 TFS(&tfs_ads_ds), 0x00000010, "Does this dc provide DS services?", HFILL }},
3218 { &hf_mscldap_netlogon_flags_kdc,
3219 { "KDC", "mscldap.netlogon.flags.kdc", FT_BOOLEAN, 32,
3220 TFS(&tfs_ads_kdc), 0x00000020, "Does this dc act as a KDC?", HFILL }},
3222 { &hf_mscldap_netlogon_flags_timeserv,
3223 { "Time Serv", "mscldap.netlogon.flags.timeserv", FT_BOOLEAN, 32,
3224 TFS(&tfs_ads_timeserv), 0x00000040, "Does this dc provide time services (ntp) ?", HFILL }},
3226 { &hf_mscldap_netlogon_flags_closest,
3227 { "Closest", "mscldap.netlogon.flags.closest", FT_BOOLEAN, 32,
3228 TFS(&tfs_ads_closest), 0x00000080, "Is this the closest dc? (is this used at all?)", HFILL }},
3230 { &hf_mscldap_netlogon_flags_writable,
3231 { "Writable", "mscldap.netlogon.flags.writable", FT_BOOLEAN, 32,
3232 TFS(&tfs_ads_writable), 0x00000100, "Is this dc writable? (i.e. can it update the AD?)", HFILL }},
3234 { &hf_mscldap_netlogon_flags_good_timeserv,
3235 { "Good Time Serv", "mscldap.netlogon.flags.good_timeserv", FT_BOOLEAN, 32,
3236 TFS(&tfs_ads_good_timeserv), 0x00000200, "Is this a Good Time Server? (i.e. does it have a hardware clock)", HFILL }},
3238 { &hf_mscldap_netlogon_flags_ndnc,
3239 { "NDNC", "mscldap.netlogon.flags.ndnc", FT_BOOLEAN, 32,
3240 TFS(&tfs_ads_ndnc), 0x00000400, "Is this an NDNC dc?", HFILL }},
3243 /*--- Included file: packet-ldap-hfarr.c ---*/
3244 #line 1 "packet-ldap-hfarr.c"
3245 { &hf_ldap_LDAPMessage_PDU,
3246 { "LDAPMessage", "ldap.LDAPMessage",
3247 FT_NONE, BASE_NONE, NULL, 0,
3248 "LDAPMessage", HFILL }},
3249 { &hf_ldap_messageID,
3250 { "messageID", "ldap.messageID",
3251 FT_UINT32, BASE_DEC, NULL, 0,
3252 "LDAPMessage/messageID", HFILL }},
3253 { &hf_ldap_protocolOp,
3254 { "protocolOp", "ldap.protocolOp",
3255 FT_UINT32, BASE_DEC, VALS(ldap_ProtocolOp_vals), 0,
3256 "LDAPMessage/protocolOp", HFILL }},
3257 { &hf_ldap_controls,
3258 { "controls", "ldap.controls",
3259 FT_UINT32, BASE_DEC, NULL, 0,
3260 "LDAPMessage/controls", HFILL }},
3261 { &hf_ldap_bindRequest,
3262 { "bindRequest", "ldap.bindRequest",
3263 FT_NONE, BASE_NONE, NULL, 0,
3264 "ProtocolOp/bindRequest", HFILL }},
3265 { &hf_ldap_bindResponse,
3266 { "bindResponse", "ldap.bindResponse",
3267 FT_NONE, BASE_NONE, NULL, 0,
3268 "ProtocolOp/bindResponse", HFILL }},
3269 { &hf_ldap_unbindRequest,
3270 { "unbindRequest", "ldap.unbindRequest",
3271 FT_NONE, BASE_NONE, NULL, 0,
3272 "ProtocolOp/unbindRequest", HFILL }},
3273 { &hf_ldap_searchRequest,
3274 { "searchRequest", "ldap.searchRequest",
3275 FT_NONE, BASE_NONE, NULL, 0,
3276 "ProtocolOp/searchRequest", HFILL }},
3277 { &hf_ldap_searchResEntry,
3278 { "searchResEntry", "ldap.searchResEntry",
3279 FT_NONE, BASE_NONE, NULL, 0,
3280 "ProtocolOp/searchResEntry", HFILL }},
3281 { &hf_ldap_searchResDone,
3282 { "searchResDone", "ldap.searchResDone",
3283 FT_NONE, BASE_NONE, NULL, 0,
3284 "ProtocolOp/searchResDone", HFILL }},
3285 { &hf_ldap_searchResRef,
3286 { "searchResRef", "ldap.searchResRef",
3287 FT_UINT32, BASE_DEC, NULL, 0,
3288 "ProtocolOp/searchResRef", HFILL }},
3289 { &hf_ldap_modifyRequest,
3290 { "modifyRequest", "ldap.modifyRequest",
3291 FT_NONE, BASE_NONE, NULL, 0,
3292 "ProtocolOp/modifyRequest", HFILL }},
3293 { &hf_ldap_modifyResponse,
3294 { "modifyResponse", "ldap.modifyResponse",
3295 FT_NONE, BASE_NONE, NULL, 0,
3296 "ProtocolOp/modifyResponse", HFILL }},
3297 { &hf_ldap_addRequest,
3298 { "addRequest", "ldap.addRequest",
3299 FT_NONE, BASE_NONE, NULL, 0,
3300 "ProtocolOp/addRequest", HFILL }},
3301 { &hf_ldap_addResponse,
3302 { "addResponse", "ldap.addResponse",
3303 FT_NONE, BASE_NONE, NULL, 0,
3304 "ProtocolOp/addResponse", HFILL }},
3305 { &hf_ldap_delRequest,
3306 { "delRequest", "ldap.delRequest",
3307 FT_STRING, BASE_NONE, NULL, 0,
3308 "ProtocolOp/delRequest", HFILL }},
3309 { &hf_ldap_delResponse,
3310 { "delResponse", "ldap.delResponse",
3311 FT_NONE, BASE_NONE, NULL, 0,
3312 "ProtocolOp/delResponse", HFILL }},
3313 { &hf_ldap_modDNRequest,
3314 { "modDNRequest", "ldap.modDNRequest",
3315 FT_NONE, BASE_NONE, NULL, 0,
3316 "ProtocolOp/modDNRequest", HFILL }},
3317 { &hf_ldap_modDNResponse,
3318 { "modDNResponse", "ldap.modDNResponse",
3319 FT_NONE, BASE_NONE, NULL, 0,
3320 "ProtocolOp/modDNResponse", HFILL }},
3321 { &hf_ldap_compareRequest,
3322 { "compareRequest", "ldap.compareRequest",
3323 FT_NONE, BASE_NONE, NULL, 0,
3324 "ProtocolOp/compareRequest", HFILL }},
3325 { &hf_ldap_compareResponse,
3326 { "compareResponse", "ldap.compareResponse",
3327 FT_NONE, BASE_NONE, NULL, 0,
3328 "ProtocolOp/compareResponse", HFILL }},
3329 { &hf_ldap_abandonRequest,
3330 { "abandonRequest", "ldap.abandonRequest",
3331 FT_UINT32, BASE_DEC, NULL, 0,
3332 "ProtocolOp/abandonRequest", HFILL }},
3333 { &hf_ldap_extendedReq,
3334 { "extendedReq", "ldap.extendedReq",
3335 FT_NONE, BASE_NONE, NULL, 0,
3336 "ProtocolOp/extendedReq", HFILL }},
3337 { &hf_ldap_extendedResp,
3338 { "extendedResp", "ldap.extendedResp",
3339 FT_NONE, BASE_NONE, NULL, 0,
3340 "ProtocolOp/extendedResp", HFILL }},
3341 { &hf_ldap_AttributeDescriptionList_item,
3342 { "Item", "ldap.AttributeDescriptionList_item",
3343 FT_STRING, BASE_NONE, NULL, 0,
3344 "AttributeDescriptionList/_item", HFILL }},
3345 { &hf_ldap_attributeDesc,
3346 { "attributeDesc", "ldap.attributeDesc",
3347 FT_STRING, BASE_NONE, NULL, 0,
3348 "AttributeValueAssertion/attributeDesc", HFILL }},
3349 { &hf_ldap_assertionValue,
3350 { "assertionValue", "ldap.assertionValue",
3351 FT_BYTES, BASE_HEX, NULL, 0,
3352 "AttributeValueAssertion/assertionValue", HFILL }},
3354 { "type", "ldap.type",
3355 FT_STRING, BASE_NONE, NULL, 0,
3358 { "vals", "ldap.vals",
3359 FT_UINT32, BASE_DEC, NULL, 0,
3361 { &hf_ldap_vals_item,
3362 { "Item", "ldap.vals_item",
3363 FT_BYTES, BASE_HEX, NULL, 0,
3365 { &hf_ldap_resultCode,
3366 { "resultCode", "ldap.resultCode",
3367 FT_UINT32, BASE_DEC, VALS(ldap_T_resultCode_vals), 0,
3368 "LDAPResult/resultCode", HFILL }},
3369 { &hf_ldap_matchedDN,
3370 { "matchedDN", "ldap.matchedDN",
3371 FT_STRING, BASE_NONE, NULL, 0,
3373 { &hf_ldap_errorMessage,
3374 { "errorMessage", "ldap.errorMessage",
3375 FT_STRING, BASE_NONE, NULL, 0,
3377 { &hf_ldap_referral,
3378 { "referral", "ldap.referral",
3379 FT_UINT32, BASE_DEC, NULL, 0,
3381 { &hf_ldap_Referral_item,
3382 { "Item", "ldap.Referral_item",
3383 FT_STRING, BASE_NONE, NULL, 0,
3384 "Referral/_item", HFILL }},
3385 { &hf_ldap_Controls_item,
3386 { "Item", "ldap.Controls_item",
3387 FT_NONE, BASE_NONE, NULL, 0,
3388 "Controls/_item", HFILL }},
3389 { &hf_ldap_controlType,
3390 { "controlType", "ldap.controlType",
3391 FT_STRING, BASE_NONE, NULL, 0,
3392 "Control/controlType", HFILL }},
3393 { &hf_ldap_criticality,
3394 { "criticality", "ldap.criticality",
3395 FT_BOOLEAN, 8, NULL, 0,
3396 "Control/criticality", HFILL }},
3397 { &hf_ldap_controlValue,
3398 { "controlValue", "ldap.controlValue",
3399 FT_BYTES, BASE_HEX, NULL, 0,
3400 "Control/controlValue", HFILL }},
3402 { "version", "ldap.version",
3403 FT_UINT32, BASE_DEC, NULL, 0,
3404 "BindRequest/version", HFILL }},
3406 { "name", "ldap.name",
3407 FT_STRING, BASE_NONE, NULL, 0,
3408 "BindRequest/name", HFILL }},
3409 { &hf_ldap_authentication,
3410 { "authentication", "ldap.authentication",
3411 FT_UINT32, BASE_DEC, VALS(ldap_AuthenticationChoice_vals), 0,
3412 "BindRequest/authentication", HFILL }},
3414 { "simple", "ldap.simple",
3415 FT_BYTES, BASE_HEX, NULL, 0,
3416 "AuthenticationChoice/simple", HFILL }},
3418 { "sasl", "ldap.sasl",
3419 FT_NONE, BASE_NONE, NULL, 0,
3420 "AuthenticationChoice/sasl", HFILL }},
3421 { &hf_ldap_mechanism,
3422 { "mechanism", "ldap.mechanism",
3423 FT_STRING, BASE_NONE, NULL, 0,
3424 "SaslCredentials/mechanism", HFILL }},
3425 { &hf_ldap_credentials,
3426 { "credentials", "ldap.credentials",
3427 FT_BYTES, BASE_HEX, NULL, 0,
3428 "SaslCredentials/credentials", HFILL }},
3429 { &hf_ldap_bindResponse_resultCode,
3430 { "resultCode", "ldap.resultCode",
3431 FT_UINT32, BASE_DEC, VALS(ldap_BindResponse_resultCode_vals), 0,
3432 "BindResponse/resultCode", HFILL }},
3433 { &hf_ldap_serverSaslCreds,
3434 { "serverSaslCreds", "ldap.serverSaslCreds",
3435 FT_BYTES, BASE_HEX, NULL, 0,
3436 "BindResponse/serverSaslCreds", HFILL }},
3437 { &hf_ldap_baseObject,
3438 { "baseObject", "ldap.baseObject",
3439 FT_STRING, BASE_NONE, NULL, 0,
3440 "SearchRequest/baseObject", HFILL }},
3442 { "scope", "ldap.scope",
3443 FT_UINT32, BASE_DEC, VALS(ldap_T_scope_vals), 0,
3444 "SearchRequest/scope", HFILL }},
3445 { &hf_ldap_derefAliases,
3446 { "derefAliases", "ldap.derefAliases",
3447 FT_UINT32, BASE_DEC, VALS(ldap_T_derefAliases_vals), 0,
3448 "SearchRequest/derefAliases", HFILL }},
3449 { &hf_ldap_sizeLimit,
3450 { "sizeLimit", "ldap.sizeLimit",
3451 FT_UINT32, BASE_DEC, NULL, 0,
3452 "SearchRequest/sizeLimit", HFILL }},
3453 { &hf_ldap_timeLimit,
3454 { "timeLimit", "ldap.timeLimit",
3455 FT_UINT32, BASE_DEC, NULL, 0,
3456 "SearchRequest/timeLimit", HFILL }},
3457 { &hf_ldap_typesOnly,
3458 { "typesOnly", "ldap.typesOnly",
3459 FT_BOOLEAN, 8, NULL, 0,
3460 "SearchRequest/typesOnly", HFILL }},
3462 { "filter", "ldap.filter",
3463 FT_UINT32, BASE_DEC, VALS(ldap_Filter_vals), 0,
3464 "SearchRequest/filter", HFILL }},
3465 { &hf_ldap_searchRequest_attributes,
3466 { "attributes", "ldap.attributes",
3467 FT_UINT32, BASE_DEC, NULL, 0,
3468 "SearchRequest/attributes", HFILL }},
3470 { "and", "ldap.and",
3471 FT_UINT32, BASE_DEC, NULL, 0,
3472 "Filter/and", HFILL }},
3473 { &hf_ldap_and_item,
3474 { "Item", "ldap.and_item",
3475 FT_UINT32, BASE_DEC, VALS(ldap_Filter_vals), 0,
3476 "Filter/and/_item", HFILL }},
3479 FT_UINT32, BASE_DEC, NULL, 0,
3480 "Filter/or", HFILL }},
3482 { "Item", "ldap.or_item",
3483 FT_UINT32, BASE_DEC, VALS(ldap_Filter_vals), 0,
3484 "Filter/or/_item", HFILL }},
3486 { "not", "ldap.not",
3487 FT_UINT32, BASE_DEC, VALS(ldap_Filter_vals), 0,
3488 "Filter/not", HFILL }},
3489 { &hf_ldap_equalityMatch,
3490 { "equalityMatch", "ldap.equalityMatch",
3491 FT_NONE, BASE_NONE, NULL, 0,
3492 "Filter/equalityMatch", HFILL }},
3493 { &hf_ldap_substrings,
3494 { "substrings", "ldap.substrings",
3495 FT_NONE, BASE_NONE, NULL, 0,
3496 "Filter/substrings", HFILL }},
3497 { &hf_ldap_greaterOrEqual,
3498 { "greaterOrEqual", "ldap.greaterOrEqual",
3499 FT_NONE, BASE_NONE, NULL, 0,
3500 "Filter/greaterOrEqual", HFILL }},
3501 { &hf_ldap_lessOrEqual,
3502 { "lessOrEqual", "ldap.lessOrEqual",
3503 FT_NONE, BASE_NONE, NULL, 0,
3504 "Filter/lessOrEqual", HFILL }},
3506 { "present", "ldap.present",
3507 FT_STRING, BASE_NONE, NULL, 0,
3508 "Filter/present", HFILL }},
3509 { &hf_ldap_approxMatch,
3510 { "approxMatch", "ldap.approxMatch",
3511 FT_NONE, BASE_NONE, NULL, 0,
3512 "Filter/approxMatch", HFILL }},
3513 { &hf_ldap_extensibleMatch,
3514 { "extensibleMatch", "ldap.extensibleMatch",
3515 FT_NONE, BASE_NONE, NULL, 0,
3516 "Filter/extensibleMatch", HFILL }},
3517 { &hf_ldap_substringFilter_substrings,
3518 { "substrings", "ldap.substrings",
3519 FT_UINT32, BASE_DEC, NULL, 0,
3520 "SubstringFilter/substrings", HFILL }},
3521 { &hf_ldap_substrings_item,
3522 { "Item", "ldap.substrings_item",
3523 FT_UINT32, BASE_DEC, VALS(ldap_T_substrings_item_vals), 0,
3524 "SubstringFilter/substrings/_item", HFILL }},
3526 { "initial", "ldap.initial",
3527 FT_STRING, BASE_NONE, NULL, 0,
3528 "SubstringFilter/substrings/_item/initial", HFILL }},
3530 { "any", "ldap.any",
3531 FT_STRING, BASE_NONE, NULL, 0,
3532 "SubstringFilter/substrings/_item/any", HFILL }},
3534 { "final", "ldap.final",
3535 FT_STRING, BASE_NONE, NULL, 0,
3536 "SubstringFilter/substrings/_item/final", HFILL }},
3537 { &hf_ldap_matchingRule,
3538 { "matchingRule", "ldap.matchingRule",
3539 FT_STRING, BASE_NONE, NULL, 0,
3540 "MatchingRuleAssertion/matchingRule", HFILL }},
3541 { &hf_ldap_matchValue,
3542 { "matchValue", "ldap.matchValue",
3543 FT_BYTES, BASE_HEX, NULL, 0,
3544 "MatchingRuleAssertion/matchValue", HFILL }},
3545 { &hf_ldap_dnAttributes,
3546 { "dnAttributes", "ldap.dnAttributes",
3547 FT_BOOLEAN, 8, NULL, 0,
3548 "MatchingRuleAssertion/dnAttributes", HFILL }},
3549 { &hf_ldap_objectName,
3550 { "objectName", "ldap.objectName",
3551 FT_STRING, BASE_NONE, NULL, 0,
3552 "SearchResultEntry/objectName", HFILL }},
3553 { &hf_ldap_searchResultEntry_attributes,
3554 { "attributes", "ldap.attributes",
3555 FT_UINT32, BASE_DEC, NULL, 0,
3556 "SearchResultEntry/attributes", HFILL }},
3557 { &hf_ldap_PartialAttributeList_item,
3558 { "Item", "ldap.PartialAttributeList_item",
3559 FT_NONE, BASE_NONE, NULL, 0,
3560 "PartialAttributeList/_item", HFILL }},
3561 { &hf_ldap_SearchResultReference_item,
3562 { "Item", "ldap.SearchResultReference_item",
3563 FT_STRING, BASE_NONE, NULL, 0,
3564 "SearchResultReference/_item", HFILL }},
3566 { "object", "ldap.object",
3567 FT_STRING, BASE_NONE, NULL, 0,
3568 "ModifyRequest/object", HFILL }},
3569 { &hf_ldap_modifyRequest_modification,
3570 { "modification", "ldap.modification",
3571 FT_UINT32, BASE_DEC, NULL, 0,
3572 "ModifyRequest/modification", HFILL }},
3573 { &hf_ldap_modification_item,
3574 { "Item", "ldap.modification_item",
3575 FT_NONE, BASE_NONE, NULL, 0,
3576 "ModifyRequest/modification/_item", HFILL }},
3577 { &hf_ldap_operation,
3578 { "operation", "ldap.operation",
3579 FT_UINT32, BASE_DEC, VALS(ldap_T_operation_vals), 0,
3580 "ModifyRequest/modification/_item/operation", HFILL }},
3581 { &hf_ldap_modification,
3582 { "modification", "ldap.modification",
3583 FT_NONE, BASE_NONE, NULL, 0,
3584 "ModifyRequest/modification/_item/modification", HFILL }},
3586 { "entry", "ldap.entry",
3587 FT_STRING, BASE_NONE, NULL, 0,
3589 { &hf_ldap_attributes,
3590 { "attributes", "ldap.attributes",
3591 FT_UINT32, BASE_DEC, NULL, 0,
3592 "AddRequest/attributes", HFILL }},
3593 { &hf_ldap_AttributeList_item,
3594 { "Item", "ldap.AttributeList_item",
3595 FT_NONE, BASE_NONE, NULL, 0,
3596 "AttributeList/_item", HFILL }},
3598 { "newrdn", "ldap.newrdn",
3599 FT_STRING, BASE_NONE, NULL, 0,
3600 "ModifyDNRequest/newrdn", HFILL }},
3601 { &hf_ldap_deleteoldrdn,
3602 { "deleteoldrdn", "ldap.deleteoldrdn",
3603 FT_BOOLEAN, 8, NULL, 0,
3604 "ModifyDNRequest/deleteoldrdn", HFILL }},
3605 { &hf_ldap_newSuperior,
3606 { "newSuperior", "ldap.newSuperior",
3607 FT_STRING, BASE_NONE, NULL, 0,
3608 "ModifyDNRequest/newSuperior", HFILL }},
3610 { "ava", "ldap.ava",
3611 FT_NONE, BASE_NONE, NULL, 0,
3612 "CompareRequest/ava", HFILL }},
3613 { &hf_ldap_requestName,
3614 { "requestName", "ldap.requestName",
3615 FT_STRING, BASE_NONE, NULL, 0,
3616 "ExtendedRequest/requestName", HFILL }},
3617 { &hf_ldap_requestValue,
3618 { "requestValue", "ldap.requestValue",
3619 FT_BYTES, BASE_HEX, NULL, 0,
3620 "ExtendedRequest/requestValue", HFILL }},
3621 { &hf_ldap_extendedResponse_resultCode,
3622 { "resultCode", "ldap.resultCode",
3623 FT_UINT32, BASE_DEC, VALS(ldap_ExtendedResponse_resultCode_vals), 0,
3624 "ExtendedResponse/resultCode", HFILL }},
3625 { &hf_ldap_responseName,
3626 { "responseName", "ldap.responseName",
3627 FT_STRING, BASE_NONE, NULL, 0,
3628 "ExtendedResponse/responseName", HFILL }},
3629 { &hf_ldap_response,
3630 { "response", "ldap.response",
3631 FT_BYTES, BASE_HEX, NULL, 0,
3632 "ExtendedResponse/response", HFILL }},
3634 /*--- End of included file: packet-ldap-hfarr.c ---*/
3635 #line 1281 "packet-ldap-template.c"
3638 /* List of subtrees */
3639 static gint *ett[] = {
3642 &ett_ldap_sasl_blob,
3644 &ett_mscldap_netlogon_flags,
3647 /*--- Included file: packet-ldap-ettarr.c ---*/
3648 #line 1 "packet-ldap-ettarr.c"
3649 &ett_ldap_LDAPMessage,
3650 &ett_ldap_ProtocolOp,
3651 &ett_ldap_AttributeDescriptionList,
3652 &ett_ldap_AttributeValueAssertion,
3653 &ett_ldap_Attribute,
3654 &ett_ldap_SET_OF_AttributeValue,
3655 &ett_ldap_LDAPResult,
3659 &ett_ldap_BindRequest,
3660 &ett_ldap_AuthenticationChoice,
3661 &ett_ldap_SaslCredentials,
3662 &ett_ldap_BindResponse,
3663 &ett_ldap_SearchRequest,
3665 &ett_ldap_SET_OF_Filter,
3666 &ett_ldap_SubstringFilter,
3667 &ett_ldap_T_substrings,
3668 &ett_ldap_T_substrings_item,
3669 &ett_ldap_MatchingRuleAssertion,
3670 &ett_ldap_SearchResultEntry,
3671 &ett_ldap_PartialAttributeList,
3672 &ett_ldap_PartialAttributeList_item,
3673 &ett_ldap_SearchResultReference,
3674 &ett_ldap_ModifyRequest,
3675 &ett_ldap_ModifyRequest_modification,
3676 &ett_ldap_T_modification_item,
3677 &ett_ldap_AttributeTypeAndValues,
3678 &ett_ldap_AddRequest,
3679 &ett_ldap_AttributeList,
3680 &ett_ldap_AttributeList_item,
3681 &ett_ldap_ModifyDNRequest,
3682 &ett_ldap_CompareRequest,
3683 &ett_ldap_ExtendedRequest,
3684 &ett_ldap_ExtendedResponse,
3686 /*--- End of included file: packet-ldap-ettarr.c ---*/
3687 #line 1292 "packet-ldap-template.c"
3690 module_t *ldap_module;
3692 /* Register protocol */
3693 proto_ldap = proto_register_protocol(PNAME, PSNAME, PFNAME);
3694 /* Register fields and subtrees */
3695 proto_register_field_array(proto_ldap, hf, array_length(hf));
3696 proto_register_subtree_array(ett, array_length(ett));
3699 register_dissector("ldap", dissect_ldap, proto_ldap);
3701 ldap_module = prefs_register_protocol(proto_ldap, NULL);
3702 prefs_register_bool_preference(ldap_module, "desegment_ldap_messages",
3703 "Reassemble LDAP messages spanning multiple TCP segments",
3704 "Whether the LDAP dissector should reassemble messages spanning multiple TCP segments."
3705 " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings, and disable \"Verify length\" in the BER protocol settings",
3708 prefs_register_uint_preference(ldap_module, "tcp.port", "LDAP TCP Port",
3709 "Set the port for LDAP operations",
3710 10, &ldap_tcp_port);
3712 proto_cldap = proto_register_protocol(
3713 "Connectionless Lightweight Directory Access Protocol",
3716 register_init_routine(ldap_reinit);
3717 ldap_tap=register_tap("ldap");
3719 ldap_name_dissector_table = register_dissector_table("ldap.name", "LDAP Attribute Type Dissectors", FT_STRING, BASE_NONE);
3725 /*--- proto_reg_handoff_ldap ---------------------------------------*/
3727 proto_reg_handoff_ldap(void)
3729 dissector_handle_t ldap_handle, cldap_handle;
3730 ldap_handle = create_dissector_handle(dissect_ldap, proto_ldap);
3732 dissector_add("tcp.port", ldap_tcp_port, ldap_handle);
3733 dissector_add("tcp.port", TCP_PORT_GLOBALCAT_LDAP, ldap_handle);
3735 cldap_handle = create_dissector_handle(dissect_mscldap, proto_cldap);
3736 dissector_add("udp.port", UDP_PORT_CLDAP, cldap_handle);
3738 gssapi_handle = find_dissector("gssapi");
3739 gssapi_wrap_handle = find_dissector("gssapi_verf");
3741 /* http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dsml/dsml/ldap_controls_and_session_support.asp */
3742 register_ber_oid_name("1.2.840.113556.1.4.319","LDAP_PAGED_RESULT_OID_STRING");
3743 register_ber_oid_name("1.2.840.113556.1.4.417","LDAP_SERVER_SHOW_DELETED_OID");
3744 register_ber_oid_name("1.2.840.113556.1.4.473","LDAP_SERVER_SORT_OID");
3745 register_ber_oid_name("1.2.840.113556.1.4.521","LDAP_SERVER_CROSSDOM_MOVE_TARGET_OID");
3746 register_ber_oid_name("1.2.840.113556.1.4.528","LDAP_SERVER_NOTIFICATION_OID");
3747 register_ber_oid_name("1.2.840.113556.1.4.529","LDAP_SERVER_EXTENDED_DN_OID");
3748 register_ber_oid_name("1.2.840.113556.1.4.619","LDAP_SERVER_LAZY_COMMIT_OID");
3749 register_ber_oid_name("1.2.840.113556.1.4.801","LDAP_SERVER_SD_FLAGS_OID");
3750 register_ber_oid_name("1.2.840.113556.1.4.805","LDAP_SERVER_TREE_DELETE_OID");
3751 register_ber_oid_name("1.2.840.113556.1.4.841","LDAP_SERVER_DIRSYNC_OID");
3752 register_ber_oid_name("1.2.840.113556.1.4.970 ","None");
3753 register_ber_oid_name("1.2.840.113556.1.4.1338","LDAP_SERVER_VERIFY_NAME_OID");
3754 register_ber_oid_name("1.2.840.113556.1.4.1339","LDAP_SERVER_DOMAIN_SCOPE_OID");
3755 register_ber_oid_name("1.2.840.113556.1.4.1340","LDAP_SERVER_SEARCH_OPTIONS_OID");
3756 register_ber_oid_name("1.2.840.113556.1.4.1413","LDAP_SERVER_PERMISSIVE_MODIFY_OID");
3757 register_ber_oid_name("1.2.840.113556.1.4.1504","LDAP_SERVER_ASQ_OID");
3758 register_ber_oid_name("1.2.840.113556.1.4.1781","LDAP_SERVER_FAST_BIND_OID");
3759 register_ber_oid_name("1.3.6.1.4.1.1466.101.119.1","None");
3760 register_ber_oid_name("1.3.6.1.4.1.1466.20037","LDAP_START_TLS_OID");
3761 register_ber_oid_name("2.16.840.1.113730.3.4.9","LDAP_CONTROL_VLVREQUEST VLV");
3763 register_ldap_name_dissector("netlogon", dissect_NetLogon_PDU, proto_cldap);