ldap: fix issue found by PVS Studio (V1001)
[metze/wireshark/wip.git] / epan / dissectors / packet-ldap.c
1 /* Do not modify this file. Changes will be overwritten.                      */
2 /* Generated automatically by the ASN.1 to Wireshark dissector compiler       */
3 /* packet-ldap.c                                                              */
4 /* asn2wrs.py -b -p ldap -c ./ldap.cnf -s ./packet-ldap-template -D . -O ../.. Lightweight-Directory-Access-Protocol-V3.asn */
5
6 /* Input file: packet-ldap-template.c */
7
8 #line 1 "./asn1/ldap/packet-ldap-template.c"
9 /* packet-ldap-template.c
10  * Routines for ldap packet dissection
11  *
12  * See RFC 1777 (LDtAP v2), RFC 4511 (LDAP v3), and RFC 2222 (SASL).
13  *
14  * Wireshark - Network traffic analyzer
15  * By Gerald Combs <gerald@wireshark.org>
16  * Copyright 1998 Gerald Combs
17  *
18  * SPDX-License-Identifier: GPL-2.0-or-later
19  */
20
21 /*
22  * This is not a complete implementation. It doesn't handle the full version 3, more specifically,
23  * it handles only the commands of version 2, but any additional characteristics of the ver3 command are supported.
24  * It's also missing extensible search filters.
25  *
26  * There should probably be a lot more error checking, I simply assume that if we have a full packet, it will be a complete
27  * and correct packet.
28  *
29  * 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
30  * 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
31  * I can do.
32  *
33  * Doug Nazar
34  * nazard@dragoninc.on.ca
35  */
36
37 /*
38  * 11/11/2002 - Fixed problem when decoding LDAP with desegmentation enabled and the
39  *              ASN.1 BER Universal Class Tag: "Sequence Of" header is encapsulated across 2
40  *              TCP segments.
41  *
42  * Ronald W. Henderson
43  * ronald.henderson@cognicaseusa.com
44  */
45
46 /*
47  * 20-JAN-2004 - added decoding of MS-CLDAP netlogon RPC
48  *               using information from the SNIA 2003 conference paper :
49  *               Active Directory Domain Controller Location Service
50  *                    by Anthony Liguori
51  * ronnie sahlberg
52  */
53
54 /*
55  * 17-DEC-2004 - added basic decoding for LDAP Controls
56  * 20-DEC-2004 - added handling for GSS-API encrypted blobs
57  *
58  * Stefan Metzmacher <metze@samba.org>
59  *
60  * 15-NOV-2005 - Changed to use the asn2wrs compiler
61  * Anders Broman <anders.broman@ericsson.com>
62  */
63
64 /*
65  * 3-AUG-2008 - Extended the cldap support to include all netlogon data types.
66  *              Updated cldap_netlogon_flags to include Windows 2008 flags
67  *              Expanded the ntver ldap option with bit field
68  *
69  * Gary Reynolds <gazzadownunder@yahoo.co.uk>
70  */
71
72 /*
73  * 09-DEC-2009 - Added support for RFC4533
74  *               Content Synchronization Operation (aka syncrepl)
75  * 11-DEC-2009 - Added support for IntermediateResponse (LDAP v3 from RFC 4511)
76  * Mathieu Parent <math.parent@gmail.com>
77  */
78
79 #include "config.h"
80
81 #include <epan/packet.h>
82 #include <epan/exceptions.h>
83 #include <epan/conversation.h>
84 #include <epan/prefs.h>
85 #include <epan/tap.h>
86 #include <epan/srt_table.h>
87 #include <epan/oids.h>
88 #include <epan/strutil.h>
89 #include <epan/show_exception.h>
90 #include <epan/asn1.h>
91 #include <epan/expert.h>
92 #include <epan/uat.h>
93 #include <wsutil/str_util.h>
94 #include "packet-frame.h"
95 #include "packet-tcp.h"
96 #include "packet-windows-common.h"
97 #include "packet-dcerpc.h"
98
99 #include "packet-ldap.h"
100 #include "packet-ntlmssp.h"
101 #include "packet-ssl.h"
102 #include "packet-ssl-utils.h"
103 #include "packet-smb-common.h"
104 #include "packet-gssapi.h"
105
106 #include "packet-ber.h"
107 #include "packet-per.h"
108 #include "packet-dns.h"
109
110 #define PNAME  "Lightweight Directory Access Protocol"
111 #define PSNAME "LDAP"
112 #define PFNAME "ldap"
113
114 void proto_register_ldap(void);
115 void proto_reg_handoff_ldap(void);
116
117 /* Initialize the protocol and registered fields */
118 static int ldap_tap = -1;
119 static int proto_ldap = -1;
120 static int proto_cldap = -1;
121
122 static int hf_ldap_sasl_buffer_length = -1;
123 static int hf_ldap_response_in = -1;
124 static int hf_ldap_response_to = -1;
125 static int hf_ldap_time = -1;
126 static int hf_ldap_guid = -1;
127
128 static int hf_mscldap_ntver_flags = -1;
129 static int hf_mscldap_ntver_flags_v1 = -1;
130 static int hf_mscldap_ntver_flags_v5 = -1;
131 static int hf_mscldap_ntver_flags_v5ex = -1;
132 static int hf_mscldap_ntver_flags_v5ep = -1;
133 static int hf_mscldap_ntver_flags_vcs = -1;
134 static int hf_mscldap_ntver_flags_vnt4 = -1;
135 static int hf_mscldap_ntver_flags_vpdc = -1;
136 static int hf_mscldap_ntver_flags_vip = -1;
137 static int hf_mscldap_ntver_flags_vl = -1;
138 static int hf_mscldap_ntver_flags_vgc = -1;
139
140 static int hf_mscldap_netlogon_ipaddress_family = -1;
141 static int hf_mscldap_netlogon_ipaddress_port = -1;
142 static int hf_mscldap_netlogon_ipaddress = -1;
143 static int hf_mscldap_netlogon_ipaddress_ipv4 = -1;
144 static int hf_mscldap_netlogon_opcode = -1;
145 static int hf_mscldap_netlogon_flags = -1;
146 static int hf_mscldap_netlogon_flags_pdc = -1;
147 static int hf_mscldap_netlogon_flags_gc = -1;
148 static int hf_mscldap_netlogon_flags_ldap = -1;
149 static int hf_mscldap_netlogon_flags_ds = -1;
150 static int hf_mscldap_netlogon_flags_kdc = -1;
151 static int hf_mscldap_netlogon_flags_timeserv = -1;
152 static int hf_mscldap_netlogon_flags_closest = -1;
153 static int hf_mscldap_netlogon_flags_writable = -1;
154 static int hf_mscldap_netlogon_flags_good_timeserv = -1;
155 static int hf_mscldap_netlogon_flags_ndnc = -1;
156 static int hf_mscldap_netlogon_flags_fnc = -1;
157 static int hf_mscldap_netlogon_flags_dnc = -1;
158 static int hf_mscldap_netlogon_flags_dns = -1;
159 static int hf_mscldap_netlogon_flags_wdc = -1;
160 static int hf_mscldap_netlogon_flags_rodc = -1;
161 static int hf_mscldap_domain_guid = -1;
162 static int hf_mscldap_forest = -1;
163 static int hf_mscldap_domain = -1;
164 static int hf_mscldap_hostname = -1;
165 static int hf_mscldap_nb_domain = -1;
166 static int hf_mscldap_nb_hostname = -1;
167 static int hf_mscldap_username = -1;
168 static int hf_mscldap_sitename = -1;
169 static int hf_mscldap_clientsitename = -1;
170 static int hf_mscldap_netlogon_lm_token = -1;
171 static int hf_mscldap_netlogon_nt_token = -1;
172 static int hf_ldap_sid = -1;
173 static int hf_ldap_AccessMask_ADS_CREATE_CHILD = -1;
174 static int hf_ldap_AccessMask_ADS_DELETE_CHILD = -1;
175 static int hf_ldap_AccessMask_ADS_LIST = -1;
176 static int hf_ldap_AccessMask_ADS_SELF_WRITE = -1;
177 static int hf_ldap_AccessMask_ADS_READ_PROP = -1;
178 static int hf_ldap_AccessMask_ADS_WRITE_PROP = -1;
179 static int hf_ldap_AccessMask_ADS_DELETE_TREE = -1;
180 static int hf_ldap_AccessMask_ADS_LIST_OBJECT = -1;
181 static int hf_ldap_AccessMask_ADS_CONTROL_ACCESS = -1;
182 static int hf_ldap_LDAPMessage_PDU = -1;
183 static int hf_ldap_object_security_flag = -1;
184 static int hf_ldap_ancestor_first_flag = -1;
185 static int hf_ldap_public_data_only_flag = -1;
186 static int hf_ldap_incremental_value_flag = -1;
187 static int hf_ldap_oid = -1;
188 static int hf_ldap_gssapi_encrypted_payload = -1;
189
190
191 /*--- Included file: packet-ldap-hf.c ---*/
192 #line 1 "./asn1/ldap/packet-ldap-hf.c"
193 static int hf_ldap_SearchControlValue_PDU = -1;   /* SearchControlValue */
194 static int hf_ldap_SortKeyList_PDU = -1;          /* SortKeyList */
195 static int hf_ldap_SortResult_PDU = -1;           /* SortResult */
196 static int hf_ldap_DirSyncControlValue_PDU = -1;  /* DirSyncControlValue */
197 static int hf_ldap_PasswdModifyRequestValue_PDU = -1;  /* PasswdModifyRequestValue */
198 static int hf_ldap_CancelRequestValue_PDU = -1;   /* CancelRequestValue */
199 static int hf_ldap_SyncRequestValue_PDU = -1;     /* SyncRequestValue */
200 static int hf_ldap_SyncStateValue_PDU = -1;       /* SyncStateValue */
201 static int hf_ldap_SyncDoneValue_PDU = -1;        /* SyncDoneValue */
202 static int hf_ldap_SyncInfoValue_PDU = -1;        /* SyncInfoValue */
203 static int hf_ldap_PasswordPolicyResponseValue_PDU = -1;  /* PasswordPolicyResponseValue */
204 static int hf_ldap_messageID = -1;                /* MessageID */
205 static int hf_ldap_protocolOp = -1;               /* ProtocolOp */
206 static int hf_ldap_controls = -1;                 /* Controls */
207 static int hf_ldap_bindRequest = -1;              /* BindRequest */
208 static int hf_ldap_bindResponse = -1;             /* BindResponse */
209 static int hf_ldap_unbindRequest = -1;            /* UnbindRequest */
210 static int hf_ldap_searchRequest = -1;            /* SearchRequest */
211 static int hf_ldap_searchResEntry = -1;           /* SearchResultEntry */
212 static int hf_ldap_searchResDone = -1;            /* SearchResultDone */
213 static int hf_ldap_searchResRef = -1;             /* SearchResultReference */
214 static int hf_ldap_modifyRequest = -1;            /* ModifyRequest */
215 static int hf_ldap_modifyResponse = -1;           /* ModifyResponse */
216 static int hf_ldap_addRequest = -1;               /* AddRequest */
217 static int hf_ldap_addResponse = -1;              /* AddResponse */
218 static int hf_ldap_delRequest = -1;               /* DelRequest */
219 static int hf_ldap_delResponse = -1;              /* DelResponse */
220 static int hf_ldap_modDNRequest = -1;             /* ModifyDNRequest */
221 static int hf_ldap_modDNResponse = -1;            /* ModifyDNResponse */
222 static int hf_ldap_compareRequest = -1;           /* CompareRequest */
223 static int hf_ldap_compareResponse = -1;          /* CompareResponse */
224 static int hf_ldap_abandonRequest = -1;           /* AbandonRequest */
225 static int hf_ldap_extendedReq = -1;              /* ExtendedRequest */
226 static int hf_ldap_extendedResp = -1;             /* ExtendedResponse */
227 static int hf_ldap_intermediateResponse = -1;     /* IntermediateResponse */
228 static int hf_ldap_AttributeDescriptionList_item = -1;  /* AttributeDescription */
229 static int hf_ldap_attributeDesc = -1;            /* AttributeDescription */
230 static int hf_ldap_assertionValue = -1;           /* AssertionValue */
231 static int hf_ldap_type = -1;                     /* AttributeDescription */
232 static int hf_ldap_vals = -1;                     /* SET_OF_AttributeValue */
233 static int hf_ldap_vals_item = -1;                /* AttributeValue */
234 static int hf_ldap_resultCode = -1;               /* T_resultCode */
235 static int hf_ldap_matchedDN = -1;                /* LDAPDN */
236 static int hf_ldap_errorMessage = -1;             /* ErrorMessage */
237 static int hf_ldap_referral = -1;                 /* Referral */
238 static int hf_ldap_Referral_item = -1;            /* LDAPURL */
239 static int hf_ldap_Controls_item = -1;            /* Control */
240 static int hf_ldap_controlType = -1;              /* ControlType */
241 static int hf_ldap_criticality = -1;              /* BOOLEAN */
242 static int hf_ldap_controlValue = -1;             /* T_controlValue */
243 static int hf_ldap_version = -1;                  /* INTEGER_1_127 */
244 static int hf_ldap_name = -1;                     /* LDAPDN */
245 static int hf_ldap_authentication = -1;           /* AuthenticationChoice */
246 static int hf_ldap_simple = -1;                   /* Simple */
247 static int hf_ldap_sasl = -1;                     /* SaslCredentials */
248 static int hf_ldap_ntlmsspNegotiate = -1;         /* T_ntlmsspNegotiate */
249 static int hf_ldap_ntlmsspAuth = -1;              /* T_ntlmsspAuth */
250 static int hf_ldap_mechanism = -1;                /* Mechanism */
251 static int hf_ldap_credentials = -1;              /* Credentials */
252 static int hf_ldap_bindResponse_resultCode = -1;  /* BindResponse_resultCode */
253 static int hf_ldap_bindResponse_matchedDN = -1;   /* T_bindResponse_matchedDN */
254 static int hf_ldap_serverSaslCreds = -1;          /* ServerSaslCreds */
255 static int hf_ldap_baseObject = -1;               /* LDAPDN */
256 static int hf_ldap_scope = -1;                    /* T_scope */
257 static int hf_ldap_derefAliases = -1;             /* T_derefAliases */
258 static int hf_ldap_sizeLimit = -1;                /* INTEGER_0_maxInt */
259 static int hf_ldap_timeLimit = -1;                /* INTEGER_0_maxInt */
260 static int hf_ldap_typesOnly = -1;                /* BOOLEAN */
261 static int hf_ldap_filter = -1;                   /* T_filter */
262 static int hf_ldap_searchRequest_attributes = -1;  /* AttributeDescriptionList */
263 static int hf_ldap_and = -1;                      /* T_and */
264 static int hf_ldap_and_item = -1;                 /* T_and_item */
265 static int hf_ldap_or = -1;                       /* T_or */
266 static int hf_ldap_or_item = -1;                  /* T_or_item */
267 static int hf_ldap_not = -1;                      /* T_not */
268 static int hf_ldap_equalityMatch = -1;            /* T_equalityMatch */
269 static int hf_ldap_substrings = -1;               /* SubstringFilter */
270 static int hf_ldap_greaterOrEqual = -1;           /* T_greaterOrEqual */
271 static int hf_ldap_lessOrEqual = -1;              /* T_lessOrEqual */
272 static int hf_ldap_present = -1;                  /* T_present */
273 static int hf_ldap_approxMatch = -1;              /* T_approxMatch */
274 static int hf_ldap_extensibleMatch = -1;          /* T_extensibleMatch */
275 static int hf_ldap_substringFilter_substrings = -1;  /* T_substringFilter_substrings */
276 static int hf_ldap_substringFilter_substrings_item = -1;  /* T_substringFilter_substrings_item */
277 static int hf_ldap_initial = -1;                  /* LDAPString */
278 static int hf_ldap_any = -1;                      /* LDAPString */
279 static int hf_ldap_final = -1;                    /* LDAPString */
280 static int hf_ldap_matchingRule = -1;             /* MatchingRuleId */
281 static int hf_ldap_matchValue = -1;               /* AssertionValue */
282 static int hf_ldap_dnAttributes = -1;             /* T_dnAttributes */
283 static int hf_ldap_objectName = -1;               /* LDAPDN */
284 static int hf_ldap_searchResultEntry_attributes = -1;  /* PartialAttributeList */
285 static int hf_ldap_PartialAttributeList_item = -1;  /* PartialAttributeList_item */
286 static int hf_ldap__untag_item = -1;              /* LDAPURL */
287 static int hf_ldap_object = -1;                   /* LDAPDN */
288 static int hf_ldap_modifyRequest_modification = -1;  /* ModifyRequest_modification */
289 static int hf_ldap_modifyRequest_modification_item = -1;  /* T_modifyRequest_modification_item */
290 static int hf_ldap_operation = -1;                /* T_operation */
291 static int hf_ldap_modification = -1;             /* AttributeTypeAndValues */
292 static int hf_ldap_entry = -1;                    /* LDAPDN */
293 static int hf_ldap_attributes = -1;               /* AttributeList */
294 static int hf_ldap_AttributeList_item = -1;       /* AttributeList_item */
295 static int hf_ldap_newrdn = -1;                   /* RelativeLDAPDN */
296 static int hf_ldap_deleteoldrdn = -1;             /* BOOLEAN */
297 static int hf_ldap_newSuperior = -1;              /* LDAPDN */
298 static int hf_ldap_ava = -1;                      /* AttributeValueAssertion */
299 static int hf_ldap_requestName = -1;              /* LDAPOID */
300 static int hf_ldap_requestValue = -1;             /* T_requestValue */
301 static int hf_ldap_extendedResponse_resultCode = -1;  /* ExtendedResponse_resultCode */
302 static int hf_ldap_responseName = -1;             /* ResponseName */
303 static int hf_ldap_response = -1;                 /* OCTET_STRING */
304 static int hf_ldap_intermediateResponse_responseValue = -1;  /* T_intermediateResponse_responseValue */
305 static int hf_ldap_size = -1;                     /* INTEGER */
306 static int hf_ldap_cookie = -1;                   /* OCTET_STRING */
307 static int hf_ldap_SortKeyList_item = -1;         /* SortKeyList_item */
308 static int hf_ldap_attributeType = -1;            /* AttributeDescription */
309 static int hf_ldap_orderingRule = -1;             /* MatchingRuleId */
310 static int hf_ldap_reverseOrder = -1;             /* BOOLEAN */
311 static int hf_ldap_sortResult = -1;               /* T_sortResult */
312 static int hf_ldap_flags = -1;                    /* DirSyncFlags */
313 static int hf_ldap_maxBytes = -1;                 /* INTEGER */
314 static int hf_ldap_userIdentity = -1;             /* OCTET_STRING */
315 static int hf_ldap_oldPasswd = -1;                /* OCTET_STRING */
316 static int hf_ldap_newPasswd = -1;                /* OCTET_STRING */
317 static int hf_ldap_cancelID = -1;                 /* MessageID */
318 static int hf_ldap_mode = -1;                     /* T_mode */
319 static int hf_ldap_reloadHint = -1;               /* BOOLEAN */
320 static int hf_ldap_state = -1;                    /* T_state */
321 static int hf_ldap_entryUUID = -1;                /* SyncUUID */
322 static int hf_ldap_refreshDeletes = -1;           /* BOOLEAN */
323 static int hf_ldap_newcookie = -1;                /* OCTET_STRING */
324 static int hf_ldap_refreshDelete = -1;            /* T_refreshDelete */
325 static int hf_ldap_refreshDone = -1;              /* BOOLEAN */
326 static int hf_ldap_refreshPresent = -1;           /* T_refreshPresent */
327 static int hf_ldap_syncIdSet = -1;                /* T_syncIdSet */
328 static int hf_ldap_syncUUIDs = -1;                /* SET_OF_SyncUUID */
329 static int hf_ldap_syncUUIDs_item = -1;           /* SyncUUID */
330 static int hf_ldap_warning = -1;                  /* T_warning */
331 static int hf_ldap_timeBeforeExpiration = -1;     /* INTEGER_0_maxInt */
332 static int hf_ldap_graceAuthNsRemaining = -1;     /* INTEGER_0_maxInt */
333 static int hf_ldap_error = -1;                    /* T_error */
334
335 /*--- End of included file: packet-ldap-hf.c ---*/
336 #line 183 "./asn1/ldap/packet-ldap-template.c"
337
338 /* Initialize the subtree pointers */
339 static gint ett_ldap = -1;
340 static gint ett_ldap_msg = -1;
341 static gint ett_ldap_sasl_blob = -1;
342 static gint ett_ldap_payload = -1;
343 static gint ett_mscldap_netlogon_flags = -1;
344 static gint ett_mscldap_ntver_flags = -1;
345 static gint ett_mscldap_ipdetails = -1;
346 static gint ett_ldap_DirSyncFlagsSubEntry = -1;
347
348
349 /*--- Included file: packet-ldap-ett.c ---*/
350 #line 1 "./asn1/ldap/packet-ldap-ett.c"
351 static gint ett_ldap_LDAPMessage = -1;
352 static gint ett_ldap_ProtocolOp = -1;
353 static gint ett_ldap_AttributeDescriptionList = -1;
354 static gint ett_ldap_AttributeValueAssertion = -1;
355 static gint ett_ldap_Attribute = -1;
356 static gint ett_ldap_SET_OF_AttributeValue = -1;
357 static gint ett_ldap_LDAPResult = -1;
358 static gint ett_ldap_Referral = -1;
359 static gint ett_ldap_Controls = -1;
360 static gint ett_ldap_Control = -1;
361 static gint ett_ldap_BindRequest_U = -1;
362 static gint ett_ldap_AuthenticationChoice = -1;
363 static gint ett_ldap_SaslCredentials = -1;
364 static gint ett_ldap_BindResponse_U = -1;
365 static gint ett_ldap_SearchRequest_U = -1;
366 static gint ett_ldap_Filter = -1;
367 static gint ett_ldap_T_and = -1;
368 static gint ett_ldap_T_or = -1;
369 static gint ett_ldap_SubstringFilter = -1;
370 static gint ett_ldap_T_substringFilter_substrings = -1;
371 static gint ett_ldap_T_substringFilter_substrings_item = -1;
372 static gint ett_ldap_MatchingRuleAssertion = -1;
373 static gint ett_ldap_SearchResultEntry_U = -1;
374 static gint ett_ldap_PartialAttributeList = -1;
375 static gint ett_ldap_PartialAttributeList_item = -1;
376 static gint ett_ldap_SEQUENCE_OF_LDAPURL = -1;
377 static gint ett_ldap_ModifyRequest_U = -1;
378 static gint ett_ldap_ModifyRequest_modification = -1;
379 static gint ett_ldap_T_modifyRequest_modification_item = -1;
380 static gint ett_ldap_AttributeTypeAndValues = -1;
381 static gint ett_ldap_AddRequest_U = -1;
382 static gint ett_ldap_AttributeList = -1;
383 static gint ett_ldap_AttributeList_item = -1;
384 static gint ett_ldap_ModifyDNRequest_U = -1;
385 static gint ett_ldap_CompareRequest_U = -1;
386 static gint ett_ldap_ExtendedRequest_U = -1;
387 static gint ett_ldap_ExtendedResponse_U = -1;
388 static gint ett_ldap_IntermediateResponse_U = -1;
389 static gint ett_ldap_SearchControlValue = -1;
390 static gint ett_ldap_SortKeyList = -1;
391 static gint ett_ldap_SortKeyList_item = -1;
392 static gint ett_ldap_SortResult = -1;
393 static gint ett_ldap_DirSyncControlValue = -1;
394 static gint ett_ldap_PasswdModifyRequestValue = -1;
395 static gint ett_ldap_CancelRequestValue = -1;
396 static gint ett_ldap_SyncRequestValue = -1;
397 static gint ett_ldap_SyncStateValue = -1;
398 static gint ett_ldap_SyncDoneValue = -1;
399 static gint ett_ldap_SyncInfoValue = -1;
400 static gint ett_ldap_T_refreshDelete = -1;
401 static gint ett_ldap_T_refreshPresent = -1;
402 static gint ett_ldap_T_syncIdSet = -1;
403 static gint ett_ldap_SET_OF_SyncUUID = -1;
404 static gint ett_ldap_PasswordPolicyResponseValue = -1;
405 static gint ett_ldap_T_warning = -1;
406
407 /*--- End of included file: packet-ldap-ett.c ---*/
408 #line 195 "./asn1/ldap/packet-ldap-template.c"
409
410 static expert_field ei_ldap_exceeded_filter_length = EI_INIT;
411 static expert_field ei_ldap_too_many_filter_elements = EI_INIT;
412
413 static dissector_table_t ldap_name_dissector_table=NULL;
414 static const char *object_identifier_id = NULL; /* LDAP OID */
415
416 static gboolean do_protocolop = FALSE;
417 static gchar    *attr_type = NULL;
418 static gboolean is_binary_attr_type = FALSE;
419 static gboolean ldap_found_in_frame = FALSE;
420
421 #define TCP_PORT_RANGE_LDAP             "389,3268" /* 3268 is Windows 2000 Global Catalog */
422 #define TCP_PORT_LDAPS                  636
423 #define UDP_PORT_CLDAP                  389
424
425 /* desegmentation of LDAP */
426 static gboolean ldap_desegment = TRUE;
427 static guint global_ldaps_tcp_port = TCP_PORT_LDAPS;
428 static guint ssl_port = 0;
429
430 static dissector_handle_t gssapi_handle;
431 static dissector_handle_t gssapi_wrap_handle;
432 static dissector_handle_t ntlmssp_handle;
433 static dissector_handle_t spnego_handle;
434 static dissector_handle_t ssl_handle;
435 static dissector_handle_t ldap_handle ;
436
437 static void prefs_register_ldap(void); /* forward declaration for use in preferences registration */
438
439
440 /* different types of rpc calls ontop of ms cldap */
441 #define MSCLDAP_RPC_NETLOGON  1
442
443 /* Message type Choice values */
444 static const value_string ldap_ProtocolOp_choice_vals[] = {
445   {   0, "bindRequest" },
446   {   1, "bindResponse" },
447   {   2, "unbindRequest" },
448   {   3, "searchRequest" },
449   {   4, "searchResEntry" },
450   {   5, "searchResDone" },
451   {   6, "searchResRef" },
452   {   7, "modifyRequest" },
453   {   8, "modifyResponse" },
454   {   9, "addRequest" },
455   {  10, "addResponse" },
456   {  11, "delRequest" },
457   {  12, "delResponse" },
458   {  13, "modDNRequest" },
459   {  14, "modDNResponse" },
460   {  15, "compareRequest" },
461   {  16, "compareResponse" },
462   {  17, "abandonRequest" },
463   {  18, "extendedReq" },
464   {  19, "extendedResp" },
465   {  20, "intermediateResponse" },
466   { 0, NULL }
467 };
468
469 /* Procedure names (used in Service Response Time */
470 const value_string ldap_procedure_names[] = {
471   {   0, "Bind" },
472   {   3, "Search" },
473   {   6, "Modify" },
474   {   8, "Add" },
475   {  10, "Delete" },
476   {  12, "Modrdn" },
477   {  14, "Compare" },
478   {  23, "Extended" },
479   { 0, NULL }
480 };
481
482 #define LOGON_PRIMARY_QUERY             7
483 #define LOGON_PRIMARY_RESPONSE         12
484 #define LOGON_SAM_LOGON_REQUEST        18
485 #define LOGON_SAM_LOGON_RESPONSE       19
486 #define LOGON_SAM_PAUSE_RESPONSE       20
487 #define LOGON_SAM_USER_UNKNOWN         21
488 #define LOGON_SAM_LOGON_RESPONSE_EX    23
489 #define LOGON_SAM_PAUSE_RESPONSE_EX    24
490 #define LOGON_SAM_USER_UNKNOWN_EX      25
491
492 static const value_string netlogon_opcode_vals[] = {
493   { LOGON_PRIMARY_QUERY,         "LOGON_PRIMARY_QUERY" },
494   { LOGON_PRIMARY_RESPONSE,      "LOGON_PRIMARY_RESPONSE" },
495   { LOGON_SAM_LOGON_REQUEST,     "LOGON_SAM_LOGON_REQUEST" },
496   { LOGON_SAM_LOGON_RESPONSE,    "LOGON_SAM_LOGON_RESPONSE" },
497   { LOGON_SAM_PAUSE_RESPONSE,    "LOGON_SAM_PAUSE_RESPONSE" },
498   { LOGON_SAM_LOGON_RESPONSE_EX, "LOGON_SAM_LOGON_RESPONSE_EX" },
499   { LOGON_SAM_PAUSE_RESPONSE_EX, "LOGON_SAM_PAUSE_RESPONSE_EX" },
500   { LOGON_SAM_USER_UNKNOWN_EX,   "LOGON_SAM_USER_UNKNOWN_EX" },
501   { 0, NULL }
502 };
503
504 #define LDAP_NUM_PROCEDURES     24
505
506 static void
507 ldapstat_init(struct register_srt* srt _U_, GArray* srt_array)
508 {
509   srt_stat_table *ldap_srt_table;
510   guint32 i;
511
512   ldap_srt_table = init_srt_table("LDAP Commands", NULL, srt_array, LDAP_NUM_PROCEDURES, NULL, "ldap.protocolOp", NULL);
513   for (i = 0; i < LDAP_NUM_PROCEDURES; i++)
514   {
515     init_srt_table_row(ldap_srt_table, i, val_to_str_const(i, ldap_procedure_names, "<unknown>"));
516   }
517 }
518
519 static int
520 ldapstat_packet(void *pldap, packet_info *pinfo, epan_dissect_t *edt _U_, const void *psi)
521 {
522   guint i = 0;
523   srt_stat_table *ldap_srt_table;
524   const ldap_call_response_t *ldap=(const ldap_call_response_t *)psi;
525   srt_data_t *data = (srt_data_t *)pldap;
526
527   /* we are only interested in reply packets */
528   if(ldap->is_request){
529     return 0;
530   }
531   /* if we havnt seen the request, just ignore it */
532   if(!ldap->req_frame){
533     return 0;
534   }
535
536   /* only use the commands we know how to handle */
537   switch(ldap->protocolOpTag){
538   case LDAP_REQ_BIND:
539   case LDAP_REQ_SEARCH:
540   case LDAP_REQ_MODIFY:
541   case LDAP_REQ_ADD:
542   case LDAP_REQ_DELETE:
543   case LDAP_REQ_MODRDN:
544   case LDAP_REQ_COMPARE:
545   case LDAP_REQ_EXTENDED:
546     break;
547   default:
548     return 0;
549   }
550
551   ldap_srt_table = g_array_index(data->srt_array, srt_stat_table*, i);
552
553   add_srt_table_data(ldap_srt_table, ldap->protocolOpTag, &ldap->req_time, pinfo);
554   return 1;
555 }
556
557 /*
558  * Data structure attached to a conversation, giving authentication
559  * information from a bind request.
560  */
561 typedef struct ldap_conv_info_t {
562   guint auth_type;    /* authentication type */
563   char *auth_mech;    /* authentication mechanism */
564   guint32 first_auth_frame;  /* first frame that would use a security layer */
565   wmem_map_t *unmatched;
566   wmem_map_t *matched;
567   gboolean is_mscldap;
568   guint32  num_results;
569   gboolean start_tls_pending;
570   guint32  start_tls_frame;
571 } ldap_conv_info_t;
572
573 static guint
574 ldap_info_hash_matched(gconstpointer k)
575 {
576   const ldap_call_response_t *key = (const ldap_call_response_t *)k;
577
578   return key->messageId;
579 }
580
581 static gint
582 ldap_info_equal_matched(gconstpointer k1, gconstpointer k2)
583 {
584   const ldap_call_response_t *key1 = (const ldap_call_response_t*)k1;
585   const ldap_call_response_t *key2 = (const ldap_call_response_t*)k2;
586
587   if( key1->req_frame && key2->req_frame && (key1->req_frame!=key2->req_frame) ){
588     return 0;
589   }
590   /* a response may span multiple frames
591   if( key1->rep_frame && key2->rep_frame && (key1->rep_frame!=key2->rep_frame) ){
592     return 0;
593   }
594   */
595
596   return key1->messageId==key2->messageId;
597 }
598
599 static guint
600 ldap_info_hash_unmatched(gconstpointer k)
601 {
602   const ldap_call_response_t *key = (const ldap_call_response_t*)k;
603
604   return key->messageId;
605 }
606
607 static gint
608 ldap_info_equal_unmatched(gconstpointer k1, gconstpointer k2)
609 {
610   const ldap_call_response_t *key1 = (const ldap_call_response_t*)k1;
611   const ldap_call_response_t *key2 = (const ldap_call_response_t*)k2;
612
613   return key1->messageId==key2->messageId;
614 }
615
616
617  /* These are the NtVer flags
618   http://msdn.microsoft.com/en-us/library/cc201035.aspx
619  */
620
621 static const true_false_string tfs_ntver_v1 = {
622   "Client requested version 1 netlogon response",
623   "Version 1 netlogon response not requested"
624 };
625
626 static const true_false_string tfs_ntver_v5 = {
627   "Client requested version 5 netlogon response",
628   "Version 5 netlogon response not requested"
629 };
630 static const true_false_string tfs_ntver_v5ex = {
631   "Client requested version 5 extended netlogon response",
632   "Version 5 extended response not requested"
633 };
634 static const true_false_string tfs_ntver_v5ep = {
635   "Client has requested IP address of the server",
636   "IP address of server not requested"
637 };
638 static const true_false_string tfs_ntver_vcs = {
639   "Client has asked for the closest site information",
640   "Closest site information not requested"
641 };
642 static const true_false_string tfs_ntver_vnt4 = {
643   "Client is requesting server to avoid NT4 emulation",
644   "Only full AD DS requested"
645 };
646 static const true_false_string tfs_ntver_vpdc = {
647   "Client has requested the Primary Domain Controller",
648   "Primary Domain Controller not requested"
649 };
650 static const true_false_string tfs_ntver_vip = {
651   "Client has requested IP details (obsolete)",
652   "IP details not requested (obsolete)"
653 };
654 static const true_false_string tfs_ntver_vl = {
655   "Client indicated that it is the local machine",
656   "Client is not the local machine"
657 };static const true_false_string tfs_ntver_vgc = {
658   "Client has requested a Global Catalog server",
659   "Global Catalog not requested"
660 };
661
662 /* Stuff for generation/handling of fields for custom AttributeValues */
663 typedef struct _attribute_type_t {
664   gchar* attribute_type;
665   gchar* attribute_desc;
666 } attribute_type_t;
667
668 static attribute_type_t* attribute_types = NULL;
669 static guint num_attribute_types = 0;
670
671 static GHashTable* attribute_types_hash = NULL;
672
673 static gboolean
674 attribute_types_update_cb(void *r, char **err)
675 {
676   attribute_type_t *rec = (attribute_type_t *)r;
677   char c;
678
679   if (rec->attribute_type == NULL) {
680     *err = g_strdup("Attribute type can't be empty");
681     return FALSE;
682   }
683
684   g_strstrip(rec->attribute_type);
685   if (rec->attribute_type[0] == 0) {
686     *err = g_strdup("Attribute type can't be empty");
687     return FALSE;
688   }
689
690   /* Check for invalid characters (to avoid asserting out when
691    * registering the field).
692    */
693   c = proto_check_field_name(rec->attribute_type);
694   if (c) {
695     *err = g_strdup_printf("Attribute type can't contain '%c'", c);
696     return FALSE;
697   }
698
699   *err = NULL;
700   return TRUE;
701 }
702
703 static void *
704 attribute_types_copy_cb(void* n, const void* o, size_t siz _U_)
705 {
706   attribute_type_t* new_rec = (attribute_type_t*)n;
707   const attribute_type_t* old_rec = (const attribute_type_t*)o;
708
709   new_rec->attribute_type = g_strdup(old_rec->attribute_type);
710   new_rec->attribute_desc = g_strdup(old_rec->attribute_desc);
711
712   return new_rec;
713 }
714
715 static void
716 attribute_types_free_cb(void*r)
717 {
718   attribute_type_t* rec = (attribute_type_t*)r;
719
720   g_free(rec->attribute_type);
721   g_free(rec->attribute_desc);
722 }
723
724 UAT_CSTRING_CB_DEF(attribute_types, attribute_type, attribute_type_t)
725 UAT_CSTRING_CB_DEF(attribute_types, attribute_desc, attribute_type_t)
726
727 /*
728  *
729  */
730 static gint*
731 get_hf_for_header(char* attribute_type)
732 {
733   gint* hf_id = NULL;
734
735   if (attribute_types_hash) {
736     hf_id = (gint*) g_hash_table_lookup(attribute_types_hash, attribute_type);
737   } else {
738     hf_id = NULL;
739   }
740
741   return hf_id;
742 }
743
744 /*
745  *
746  */
747 static void
748 attribute_types_initialize_cb(void)
749 {
750   static hf_register_info* hf;
751   gint* hf_id;
752   guint i;
753   gchar* attribute_type;
754
755   if (attribute_types_hash && hf) {
756     guint hf_size = g_hash_table_size (attribute_types_hash);
757     /* Deregister all fields */
758     for (i = 0; i < hf_size; i++) {
759       proto_deregister_field (proto_ldap, *(hf[i].p_id));
760       g_free (hf[i].p_id);
761     }
762     g_hash_table_destroy (attribute_types_hash);
763     proto_add_deregistered_data (hf);
764     attribute_types_hash = NULL;
765   }
766
767   if (num_attribute_types) {
768     attribute_types_hash = g_hash_table_new(g_str_hash, g_str_equal);
769     hf = g_new0(hf_register_info,num_attribute_types);
770
771     for (i = 0; i < num_attribute_types; i++) {
772       hf_id = g_new(gint,1);
773       *hf_id = -1;
774       attribute_type = g_strdup(attribute_types[i].attribute_type);
775
776       hf[i].p_id = hf_id;
777       hf[i].hfinfo.name = attribute_type;
778       hf[i].hfinfo.abbrev = g_strdup_printf("ldap.AttributeValue.%s", attribute_type);
779       hf[i].hfinfo.type = FT_STRING;
780       hf[i].hfinfo.display = BASE_NONE;
781       hf[i].hfinfo.strings = NULL;
782       hf[i].hfinfo.bitmask = 0;
783       hf[i].hfinfo.blurb = g_strdup(attribute_types[i].attribute_desc);
784       HFILL_INIT(hf[i]);
785
786       g_hash_table_insert(attribute_types_hash, attribute_type, hf_id);
787     }
788
789     proto_register_field_array(proto_ldap, hf, num_attribute_types);
790   }
791 }
792
793 /* MS-ADTS specification, section 7.3.1.1, NETLOGON_NT_VERSION Options Bits */
794 static int dissect_mscldap_ntver_flags(proto_tree *parent_tree, tvbuff_t *tvb, int offset)
795 {
796   static const int * flags[] = {
797     &hf_mscldap_ntver_flags_v1,
798     &hf_mscldap_ntver_flags_v5,
799     &hf_mscldap_ntver_flags_v5ex,
800     &hf_mscldap_ntver_flags_v5ep,
801     &hf_mscldap_ntver_flags_vcs,
802     &hf_mscldap_ntver_flags_vnt4,
803     &hf_mscldap_ntver_flags_vpdc,
804     &hf_mscldap_ntver_flags_vip,
805     &hf_mscldap_ntver_flags_vl,
806     &hf_mscldap_ntver_flags_vgc,
807     NULL
808   };
809
810   proto_tree_add_bitmask_with_flags(parent_tree, tvb, offset, hf_mscldap_ntver_flags,
811                            ett_mscldap_ntver_flags, flags, ENC_LITTLE_ENDIAN, BMT_NO_FALSE);
812   offset += 4;
813
814   return offset;
815 }
816
817 /* This string contains the last LDAPString that was decoded */
818 static const char *attributedesc_string=NULL;
819
820 /* This string contains the last AssertionValue that was decoded */
821 static char *ldapvalue_string=NULL;
822
823 /* if the octet string contain all printable ASCII characters, then
824  * display it as a string, othervise just display it in hex.
825  */
826 static int
827 dissect_ldap_AssertionValue(gboolean implicit_tag, tvbuff_t *tvb, int offset, asn1_ctx_t *actx _U_, proto_tree *tree, int hf_index)
828 {
829   gint8 ber_class;
830   gboolean pc, ind, is_ascii;
831   gint32 tag;
832   guint32 len, i;
833   const guchar *str;
834
835   if(!implicit_tag){
836     offset=get_ber_identifier(tvb, offset, &ber_class, &pc, &tag);
837     offset=get_ber_length(tvb, offset, &len, &ind);
838   } else {
839     len=tvb_reported_length_remaining(tvb,offset);
840   }
841
842   if(len==0){
843     return offset;
844   }
845
846
847   /*
848    * Some special/wellknown attributes in common LDAP (read AD)
849    * are neither ascii strings nor blobs of hex data.
850    * Special case these attributes and decode them more nicely.
851    *
852    * Add more special cases as required to prettify further
853    * (there can't be that many ones that are truly interesting)
854    */
855   if(attributedesc_string && !strncmp("DomainSid", attributedesc_string, 9)){
856     tvbuff_t *sid_tvb;
857     char *tmpstr;
858
859     /* this octet string contains an NT SID */
860     sid_tvb=tvb_new_subset_length(tvb, offset, len);
861     dissect_nt_sid(sid_tvb, 0, tree, "SID", &tmpstr, hf_index);
862     ldapvalue_string=tmpstr;
863
864     goto finished;
865   } else if ( (len==16) /* GUIDs are always 16 bytes */
866   && (attributedesc_string && !strncmp("DomainGuid", attributedesc_string, 10))) {
867     guint8 drep[4] = { 0x10, 0x00, 0x00, 0x00}; /* fake DREP struct */
868     e_guid_t uuid;
869
870     /* This octet string contained a GUID */
871     dissect_dcerpc_uuid_t(tvb, offset, actx->pinfo, tree, drep, hf_ldap_guid, &uuid);
872
873     ldapvalue_string=(char*)wmem_alloc(wmem_packet_scope(), 1024);
874     g_snprintf(ldapvalue_string, 1023, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
875                uuid.data1, uuid.data2, uuid.data3, uuid.data4[0], uuid.data4[1],
876                uuid.data4[2], uuid.data4[3], uuid.data4[4], uuid.data4[5],
877                uuid.data4[6], uuid.data4[7]);
878
879     goto finished;
880   } else if (attributedesc_string && !strncmp("NtVer", attributedesc_string, 5)){
881     guint32 flags;
882
883     len = 0;
884     /* get flag value to populate ldapvalue_string */
885     flags=tvb_get_letohl(tvb, offset);
886
887     ldapvalue_string=(char*)wmem_alloc(wmem_packet_scope(), 1024);
888     g_snprintf(ldapvalue_string, 1023, "0x%08x",flags);
889
890     /* populate bitmask subtree */
891     offset = dissect_mscldap_ntver_flags(tree, tvb, offset);
892
893     goto finished;
894
895
896   }
897
898   /*
899    * It was not one of our "wellknown" attributes so make the best
900    * we can and just try to see if it is an ascii string or if it
901    * is a binary blob.
902    *
903    * XXX - should we support reading RFC 2252-style schemas
904    * for LDAP, and using that to determine how to display
905    * attribute values and assertion values?
906    *
907    * -- I don't think there are full schemas available that describe the
908    *  interesting cases i.e. AD -- ronnie
909    */
910   str=tvb_get_ptr(tvb, offset, len);
911   is_ascii=TRUE;
912   for(i=0;i<len;i++){
913     if(!g_ascii_isprint(str[i])){
914       is_ascii=FALSE;
915       break;
916     }
917   }
918
919   /* convert the string into a printable string */
920   if(is_ascii){
921     ldapvalue_string=wmem_strndup(wmem_packet_scope(), str, len);
922   } else {
923     ldapvalue_string=(char*)wmem_alloc(wmem_packet_scope(), 3*len);
924     for(i=0;i<len;i++){
925       g_snprintf(ldapvalue_string+i*3,3,"%02x",str[i]&0xff);
926       ldapvalue_string[3*i+2]=':';
927     }
928     ldapvalue_string[3*len-1]=0;
929   }
930
931   proto_tree_add_string(tree, hf_index, tvb, offset, len, ldapvalue_string);
932
933
934 finished:
935   offset+=len;
936   return offset;
937 }
938
939 /* This string contains the last Filter item that was decoded */
940 static const char *Filter_string=NULL;
941 static const char *and_filter_string=NULL;
942 static const char *or_filter_string=NULL;
943 static const char *substring_value=NULL;
944 static const char *substring_item_init=NULL;
945 static const char *substring_item_any=NULL;
946 static const char *substring_item_final=NULL;
947 static const char *matching_rule_string=NULL;
948 static gboolean matching_rule_dnattr=FALSE;
949
950 #define MAX_FILTER_LEN 4096
951 static gint Filter_length;
952
953 #define MAX_FILTER_ELEMENTS 200
954 static gint Filter_elements;
955
956 /* Global variables */
957 static gint MessageID =-1;
958 static gint ProtocolOp = -1;
959 static gint result = 0;
960 static proto_item *ldm_tree = NULL; /* item to add text to */
961
962 static void ldap_do_protocolop(packet_info *pinfo)
963 {
964   const gchar* valstr;
965
966   if (do_protocolop) {
967
968     valstr = val_to_str(ProtocolOp, ldap_ProtocolOp_choice_vals, "Unknown (%%u)");
969
970     col_append_fstr(pinfo->cinfo, COL_INFO, "%s(%u) ", valstr, MessageID);
971
972     if(ldm_tree)
973       proto_item_append_text(ldm_tree, " %s(%d)", valstr, MessageID);
974
975     do_protocolop = FALSE;
976
977   }
978 }
979
980 static ldap_call_response_t *
981 ldap_match_call_response(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint messageId, guint protocolOpTag, ldap_conv_info_t *ldap_info)
982 {
983   ldap_call_response_t lcr, *lcrp=NULL;
984
985   /* first see if we have already matched this */
986
987       lcr.messageId=messageId;
988       switch(protocolOpTag){
989         case LDAP_REQ_BIND:
990         case LDAP_REQ_SEARCH:
991         case LDAP_REQ_MODIFY:
992         case LDAP_REQ_ADD:
993         case LDAP_REQ_DELETE:
994         case LDAP_REQ_MODRDN:
995         case LDAP_REQ_COMPARE:
996         case LDAP_REQ_EXTENDED:
997           lcr.is_request=TRUE;
998           lcr.req_frame=pinfo->num;
999           lcr.rep_frame=0;
1000           break;
1001         case LDAP_RES_BIND:
1002         case LDAP_RES_SEARCH_ENTRY:
1003         case LDAP_RES_SEARCH_REF:
1004         case LDAP_RES_SEARCH_RESULT:
1005         case LDAP_RES_MODIFY:
1006         case LDAP_RES_ADD:
1007         case LDAP_RES_DELETE:
1008         case LDAP_RES_MODRDN:
1009         case LDAP_RES_COMPARE:
1010         case LDAP_RES_EXTENDED:
1011         case LDAP_RES_INTERMEDIATE:
1012           lcr.is_request=FALSE;
1013           lcr.req_frame=0;
1014           lcr.rep_frame=pinfo->num;
1015           break;
1016         default:
1017           return NULL;
1018       }
1019       lcrp=(ldap_call_response_t *)wmem_map_lookup(ldap_info->matched, &lcr);
1020
1021       if(lcrp){
1022
1023         lcrp->is_request=lcr.is_request;
1024
1025       } else {
1026
1027         /* we haven't found a match - try and match it up */
1028
1029   switch(protocolOpTag){
1030       case LDAP_REQ_BIND:
1031       case LDAP_REQ_SEARCH:
1032       case LDAP_REQ_MODIFY:
1033       case LDAP_REQ_ADD:
1034       case LDAP_REQ_DELETE:
1035       case LDAP_REQ_MODRDN:
1036       case LDAP_REQ_COMPARE:
1037       case LDAP_REQ_EXTENDED:
1038
1039         /* this a a request - add it to the unmatched list */
1040
1041         /* check that we don't already have one of those in the
1042            unmatched list and if so remove it */
1043
1044         lcr.messageId=messageId;
1045         lcrp=(ldap_call_response_t *)wmem_map_lookup(ldap_info->unmatched, &lcr);
1046         if(lcrp){
1047           wmem_map_remove(ldap_info->unmatched, lcrp);
1048         }
1049         /* if we can't reuse the old one, grab a new chunk */
1050         if(!lcrp){
1051           lcrp=wmem_new0(wmem_file_scope(), ldap_call_response_t);
1052         }
1053         lcrp->messageId=messageId;
1054         lcrp->req_frame=pinfo->num;
1055         lcrp->req_time=pinfo->abs_ts;
1056         lcrp->rep_frame=0;
1057         lcrp->protocolOpTag=protocolOpTag;
1058         lcrp->is_request=TRUE;
1059         wmem_map_insert(ldap_info->unmatched, lcrp, lcrp);
1060         return NULL;
1061         break;
1062       case LDAP_RES_BIND:
1063       case LDAP_RES_SEARCH_ENTRY:
1064       case LDAP_RES_SEARCH_REF:
1065       case LDAP_RES_SEARCH_RESULT:
1066       case LDAP_RES_MODIFY:
1067       case LDAP_RES_ADD:
1068       case LDAP_RES_DELETE:
1069       case LDAP_RES_MODRDN:
1070       case LDAP_RES_COMPARE:
1071       case LDAP_RES_EXTENDED:
1072       case LDAP_RES_INTERMEDIATE:
1073
1074       /* this is a result - it should be in our unmatched list */
1075
1076         lcr.messageId=messageId;
1077         lcrp=(ldap_call_response_t *)wmem_map_lookup(ldap_info->unmatched, &lcr);
1078
1079         if(lcrp){
1080
1081           if(!lcrp->rep_frame){
1082             wmem_map_remove(ldap_info->unmatched, lcrp);
1083             lcrp->rep_frame=pinfo->num;
1084             lcrp->is_request=FALSE;
1085             wmem_map_insert(ldap_info->matched, lcrp, lcrp);
1086           }
1087         }
1088
1089         break;
1090       }
1091
1092     }
1093     /* we have found a match */
1094
1095     if(lcrp){
1096       proto_item *it;
1097
1098       if(lcrp->is_request){
1099         it=proto_tree_add_uint(tree, hf_ldap_response_in, tvb, 0, 0, lcrp->rep_frame);
1100         PROTO_ITEM_SET_GENERATED(it);
1101       } else {
1102         nstime_t ns;
1103         it=proto_tree_add_uint(tree, hf_ldap_response_to, tvb, 0, 0, lcrp->req_frame);
1104         PROTO_ITEM_SET_GENERATED(it);
1105         nstime_delta(&ns, &pinfo->abs_ts, &lcrp->req_time);
1106         it=proto_tree_add_time(tree, hf_ldap_time, tvb, 0, 0, &ns);
1107         PROTO_ITEM_SET_GENERATED(it);
1108       }
1109     }
1110
1111     return lcrp;
1112 }
1113
1114
1115 /*--- Included file: packet-ldap-fn.c ---*/
1116 #line 1 "./asn1/ldap/packet-ldap-fn.c"
1117 /*--- Cyclic dependencies ---*/
1118
1119 /* Filter -> Filter/and -> Filter/and/_item -> Filter */
1120 /* Filter -> Filter/or -> Filter/or/_item -> Filter */
1121 /* Filter -> Filter/not -> Filter */
1122 static int dissect_ldap_Filter(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_);
1123
1124
1125
1126
1127 static int
1128 dissect_ldap_MessageID(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1129 #line 91 "./asn1/ldap/ldap.cnf"
1130
1131   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
1132                                                 &MessageID);
1133
1134
1135   ldm_tree = tree;
1136
1137
1138
1139   return offset;
1140 }
1141
1142
1143
1144 static int
1145 dissect_ldap_INTEGER_1_127(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1146   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
1147                                                 NULL);
1148
1149   return offset;
1150 }
1151
1152
1153
1154 static int
1155 dissect_ldap_LDAPString(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1156 #line 301 "./asn1/ldap/ldap.cnf"
1157   tvbuff_t  *parameter_tvb = NULL;
1158   const char *ldapstring = NULL;
1159   gchar *sc = NULL; /* semi-colon pointer */
1160
1161   offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
1162                                        &parameter_tvb);
1163
1164
1165   if (parameter_tvb || (hf_index == hf_ldap_baseObject)) {
1166
1167   ldap_do_protocolop(actx->pinfo);
1168
1169   if(parameter_tvb)
1170     ldapstring = tvb_get_string_enc(wmem_packet_scope(), parameter_tvb, 0, tvb_reported_length_remaining(parameter_tvb, 0), ENC_UTF_8|ENC_NA);
1171
1172   if(hf_index == hf_ldap_baseObject) {
1173     /* this is search - put it on the scanline */
1174     if(!ldapstring || !*ldapstring)
1175       ldapstring = "<ROOT>";
1176
1177     col_append_fstr(actx->pinfo->cinfo, COL_INFO, "\"%s\" ", format_text(wmem_packet_scope(), ldapstring, strlen(ldapstring)));
1178
1179     if(ldm_tree)
1180       proto_item_append_text(ldm_tree, " \"%s\"", ldapstring);
1181
1182
1183     if(!parameter_tvb) {
1184
1185       proto_item_append_text(actx->created_item, " (%s)", ldapstring);
1186     }
1187
1188   } else if ((hf_index == hf_ldap_errorMessage) && ldapstring && *ldapstring) { /* only show message if not success */
1189     col_append_fstr(actx->pinfo->cinfo, COL_INFO, "(%s) ", format_text(wmem_packet_scope(), ldapstring, strlen(ldapstring)));
1190
1191     if(ldm_tree)
1192       proto_item_append_text(ldm_tree, " (%s)", ldapstring);
1193
1194     } else if ((hf_index == hf_ldap_objectName) ||
1195                (hf_index == hf_ldap_name) ||
1196                (hf_index == hf_ldap_entry) ||
1197                (hf_index == hf_ldap_object) ||
1198                (hf_index == hf_ldap_delRequest) ) {
1199
1200       if(!ldapstring || !*ldapstring)
1201         ldapstring = "<ROOT>";
1202
1203       col_append_fstr(actx->pinfo->cinfo, COL_INFO, "\"%s\" ", format_text(wmem_packet_scope(), ldapstring, strlen(ldapstring)));
1204
1205       if(ldm_tree)
1206         proto_item_append_text(ldm_tree, " \"%s\"", ldapstring);
1207       } else if (hf_index == hf_ldap_attributeDesc){
1208         /* remember the attribute description */
1209         attributedesc_string=ldapstring;
1210       } else if (hf_index == hf_ldap_initial){
1211         /* remember the substring item */
1212         substring_item_init=ldapstring;
1213       } else if (hf_index == hf_ldap_any){
1214         /* remember the substring item */
1215         substring_item_any=ldapstring;
1216       } else if (hf_index == hf_ldap_final){
1217         /* remember the substring item */
1218         substring_item_final=ldapstring;
1219       } else if (hf_index == hf_ldap_matchingRule){
1220         /* remember the matching rule */
1221         matching_rule_string=ldapstring;
1222       } else if (hf_index == hf_ldap_present){
1223         /* remember the present name */
1224         Filter_string=ldapstring;
1225       } else if (hf_index == hf_ldap_type) {
1226         /* remember attribute type name */
1227         attr_type = wmem_strdup(wmem_packet_scope(), ldapstring);
1228
1229         /* append it to the parent entry */
1230         proto_item_append_text(tree, " %s", attr_type);
1231
1232         /* remove the ";binary" component if present */
1233         if((sc = strchr(attr_type, ';')) != NULL) {
1234           if(!strcmp(sc, ";binary")) {
1235             *sc = '\0'; /* terminate the string */
1236             is_binary_attr_type = TRUE;
1237           }
1238         } else {
1239           is_binary_attr_type = FALSE;
1240         }
1241     }
1242
1243   }
1244
1245
1246
1247   return offset;
1248 }
1249
1250
1251
1252 static int
1253 dissect_ldap_LDAPDN(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1254   offset = dissect_ldap_LDAPString(implicit_tag, tvb, offset, actx, tree, hf_index);
1255
1256   return offset;
1257 }
1258
1259
1260
1261 static int
1262 dissect_ldap_Simple(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1263 #line 148 "./asn1/ldap/ldap.cnf"
1264 ldap_conv_info_t *ldap_info;
1265
1266   offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
1267                                        NULL);
1268
1269
1270   ldap_info = (ldap_conv_info_t *)actx->private_data;
1271   ldap_info->auth_type = LDAP_AUTH_SIMPLE;
1272
1273
1274
1275   return offset;
1276 }
1277
1278
1279
1280 static int
1281 dissect_ldap_Mechanism(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1282 #line 156 "./asn1/ldap/ldap.cnf"
1283
1284 ldap_conv_info_t *ldap_info;
1285 tvbuff_t  *parameter_tvb;
1286 char *mechanism = NULL;
1287   offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
1288                                        &parameter_tvb);
1289
1290   ldap_info = (ldap_conv_info_t *)actx->private_data;
1291   ldap_info->auth_type = LDAP_AUTH_SASL;
1292
1293   if (!parameter_tvb)
1294     return offset;
1295
1296   /*
1297    * We need to remember the authentication type and mechanism for this
1298    * conversation.
1299    *
1300    * XXX - actually, we might need to remember more than one
1301    * type and mechanism, if you can unbind and rebind with a
1302    * different type and/or mechanism.
1303    */
1304   if(!actx->pinfo->fd->flags.visited) {
1305     mechanism = tvb_get_string_enc(wmem_file_scope(), parameter_tvb, 0, tvb_reported_length_remaining(parameter_tvb,0), ENC_UTF_8|ENC_NA);
1306     ldap_info->first_auth_frame = 0; /* not known until we see the bind reply */
1307     /*
1308      * If the mechanism in this request is an empty string (which is
1309      * returned as a null pointer), use the saved mechanism instead.
1310      * Otherwise, if the saved mechanism is an empty string (null),
1311      * save this mechanism.
1312     */
1313     if (mechanism != NULL) {
1314       wmem_free(wmem_file_scope(), ldap_info->auth_mech);
1315       ldap_info->auth_mech = mechanism;
1316     }
1317   }
1318
1319
1320   return offset;
1321 }
1322
1323
1324
1325 static int
1326 dissect_ldap_Credentials(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1327 #line 190 "./asn1/ldap/ldap.cnf"
1328
1329 tvbuff_t *parameter_tvb;
1330 ldap_conv_info_t *ldap_info;
1331 gint8 ber_class;
1332 gboolean pc;
1333 gint32 tag;
1334
1335   offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
1336                                        &parameter_tvb);
1337
1338
1339   if (!parameter_tvb)
1340     return offset;
1341
1342   ldap_info = (ldap_conv_info_t *)actx->private_data;
1343   get_ber_identifier(parameter_tvb, 0, &ber_class, &pc, &tag);
1344
1345   /*if ((ldap_info->auth_mech != NULL) && (strcmp(ldap_info->auth_mech, "GSS-SPNEGO") == 0) && (ber_class==BER_CLASS_CON)) {*/
1346   if ((ldap_info->auth_mech != NULL) && (ber_class==BER_CLASS_CON)) {
1347     /*
1348      * This is a GSS-API token ancapsulated within GSS-SPNEGO.
1349      * We need to check the first byte to check whether the blob
1350      * contains SPNEGO or GSSAPI.
1351      * All SPNEGO PDUs are of class CONSTRUCTED while
1352      * GSS PDUs are class APPLICATION
1353      */
1354     if (parameter_tvb && (tvb_reported_length(parameter_tvb) > 0))
1355       call_dissector(spnego_handle, parameter_tvb, actx->pinfo, tree);
1356   }
1357   /*if ((ldap_info->auth_mech != NULL) && ((strcmp(ldap_info->auth_mech, "GSSAPI") == 0) || (ber_class==BER_CLASS_APP))) {*/
1358   if ((ldap_info->auth_mech != NULL) && (ber_class==BER_CLASS_APP)) {
1359     /*
1360      * This is a raw GSS-API token.
1361      */
1362     if (parameter_tvb && (tvb_reported_length(parameter_tvb) > 0)) {
1363       call_dissector(gssapi_handle, parameter_tvb, actx->pinfo, tree);
1364     }
1365   }
1366   /* Restore private data */
1367   actx->private_data = ldap_info;
1368
1369
1370
1371
1372   return offset;
1373 }
1374
1375
1376 static const ber_sequence_t SaslCredentials_sequence[] = {
1377   { &hf_ldap_mechanism      , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_Mechanism },
1378   { &hf_ldap_credentials    , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_Credentials },
1379   { NULL, 0, 0, 0, NULL }
1380 };
1381
1382 static int
1383 dissect_ldap_SaslCredentials(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1384   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
1385                                    SaslCredentials_sequence, hf_index, ett_ldap_SaslCredentials);
1386
1387   return offset;
1388 }
1389
1390
1391
1392 static int
1393 dissect_ldap_T_ntlmsspNegotiate(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1394 #line 689 "./asn1/ldap/ldap.cnf"
1395   /* make sure the protocol op comes first */
1396   ldap_do_protocolop(actx->pinfo);
1397
1398   call_dissector(ntlmssp_handle, tvb, actx->pinfo, tree);
1399   offset+=tvb_reported_length_remaining(tvb, offset);
1400
1401
1402
1403   return offset;
1404 }
1405
1406
1407
1408 static int
1409 dissect_ldap_T_ntlmsspAuth(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1410 #line 696 "./asn1/ldap/ldap.cnf"
1411   /* make sure the protocol op comes first */
1412   ldap_do_protocolop(actx->pinfo);
1413
1414   call_dissector(ntlmssp_handle, tvb, actx->pinfo, tree);
1415   offset+=tvb_reported_length_remaining(tvb, offset);
1416
1417
1418
1419   return offset;
1420 }
1421
1422
1423 static const value_string ldap_AuthenticationChoice_vals[] = {
1424   {   0, "simple" },
1425   {   3, "sasl" },
1426   {  10, "ntlmsspNegotiate" },
1427   {  11, "ntlmsspAuth" },
1428   { 0, NULL }
1429 };
1430
1431 static const ber_choice_t AuthenticationChoice_choice[] = {
1432   {   0, &hf_ldap_simple         , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_ldap_Simple },
1433   {   3, &hf_ldap_sasl           , BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_ldap_SaslCredentials },
1434   {  10, &hf_ldap_ntlmsspNegotiate, BER_CLASS_CON, 10, BER_FLAGS_IMPLTAG, dissect_ldap_T_ntlmsspNegotiate },
1435   {  11, &hf_ldap_ntlmsspAuth    , BER_CLASS_CON, 11, BER_FLAGS_IMPLTAG, dissect_ldap_T_ntlmsspAuth },
1436   { 0, NULL, 0, 0, 0, NULL }
1437 };
1438
1439 static int
1440 dissect_ldap_AuthenticationChoice(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1441 #line 486 "./asn1/ldap/ldap.cnf"
1442   gint branch = -1;
1443   gint auth = -1;
1444   const gchar *valstr;
1445
1446   offset = dissect_ber_choice(actx, tree, tvb, offset,
1447                                  AuthenticationChoice_choice, hf_index, ett_ldap_AuthenticationChoice,
1448                                  &branch);
1449
1450
1451   ldap_do_protocolop(actx->pinfo);
1452
1453   if((branch > -1) && (branch < (gint)(sizeof AuthenticationChoice_choice/sizeof AuthenticationChoice_choice[0])))
1454     auth = AuthenticationChoice_choice[branch].value;
1455
1456   valstr = val_to_str(auth, ldap_AuthenticationChoice_vals, "Unknown auth(%u)");
1457
1458   /* If auth is NTLM (10 or 11) don't add to column as the NTLM dissection will do this */
1459   if ((auth !=  10) && (auth != 11))
1460     col_append_fstr(actx->pinfo->cinfo, COL_INFO, "%s ", valstr);
1461
1462   if(ldm_tree)
1463     proto_item_append_text(ldm_tree, " %s", valstr);
1464
1465
1466
1467
1468   return offset;
1469 }
1470
1471
1472 static const ber_sequence_t BindRequest_U_sequence[] = {
1473   { &hf_ldap_version        , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ldap_INTEGER_1_127 },
1474   { &hf_ldap_name           , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_LDAPDN },
1475   { &hf_ldap_authentication , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ldap_AuthenticationChoice },
1476   { NULL, 0, 0, 0, NULL }
1477 };
1478
1479 static int
1480 dissect_ldap_BindRequest_U(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1481   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
1482                                    BindRequest_U_sequence, hf_index, ett_ldap_BindRequest_U);
1483
1484   return offset;
1485 }
1486
1487
1488
1489 static int
1490 dissect_ldap_BindRequest(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1491   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
1492                                       hf_index, BER_CLASS_APP, 0, TRUE, dissect_ldap_BindRequest_U);
1493
1494   return offset;
1495 }
1496
1497
1498 static const value_string ldap_BindResponse_resultCode_vals[] = {
1499   {   0, "success" },
1500   {   1, "operationsError" },
1501   {   2, "protocolError" },
1502   {   3, "timeLimitExceeded" },
1503   {   4, "sizeLimitExceeded" },
1504   {   5, "compareFalse" },
1505   {   6, "compareTrue" },
1506   {   7, "authMethodNotSupported" },
1507   {   8, "strongAuthRequired" },
1508   {  10, "referral" },
1509   {  11, "adminLimitExceeded" },
1510   {  12, "unavailableCriticalExtension" },
1511   {  13, "confidentialityRequired" },
1512   {  14, "saslBindInProgress" },
1513   {  16, "noSuchAttribute" },
1514   {  17, "undefinedAttributeType" },
1515   {  18, "inappropriateMatching" },
1516   {  19, "constraintViolation" },
1517   {  20, "attributeOrValueExists" },
1518   {  21, "invalidAttributeSyntax" },
1519   {  32, "noSuchObject" },
1520   {  33, "aliasProblem" },
1521   {  34, "invalidDNSyntax" },
1522   {  36, "aliasDereferencingProblem" },
1523   {  48, "inappropriateAuthentication" },
1524   {  49, "invalidCredentials" },
1525   {  50, "insufficientAccessRights" },
1526   {  51, "busy" },
1527   {  52, "unavailable" },
1528   {  53, "unwillingToPerform" },
1529   {  54, "loopDetect" },
1530   {  64, "namingViolation" },
1531   {  65, "objectClassViolation" },
1532   {  66, "notAllowedOnNonLeaf" },
1533   {  67, "notAllowedOnRDN" },
1534   {  68, "entryAlreadyExists" },
1535   {  69, "objectClassModsProhibited" },
1536   {  71, "affectsMultipleDSAs" },
1537   {  80, "other" },
1538   { 118, "canceled" },
1539   { 119, "noSuchOperation" },
1540   { 120, "tooLate" },
1541   { 121, "cannotCancel" },
1542   { 0, NULL }
1543 };
1544
1545
1546 static int
1547 dissect_ldap_BindResponse_resultCode(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1548 #line 420 "./asn1/ldap/ldap.cnf"
1549
1550   const gchar *valstr;
1551
1552   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
1553                                   &result);
1554
1555
1556   ldap_do_protocolop(actx->pinfo);
1557
1558   valstr = val_to_str(result, ldap_BindResponse_resultCode_vals, "Unknown result(%u)");
1559
1560   col_append_fstr(actx->pinfo->cinfo, COL_INFO, "%s ", valstr);
1561
1562   if(ldm_tree)
1563     proto_item_append_text(ldm_tree, " %s", valstr);
1564
1565
1566
1567   return offset;
1568 }
1569
1570
1571
1572 static int
1573 dissect_ldap_T_bindResponse_matchedDN(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1574 #line 703 "./asn1/ldap/ldap.cnf"
1575   tvbuff_t *new_tvb=NULL;
1576
1577   offset = dissect_ber_octet_string(FALSE, actx, tree, tvb, offset, hf_ldap_matchedDN, &new_tvb);
1578
1579   if(  new_tvb
1580   &&  (tvb_reported_length(new_tvb)>=7)
1581   &&  (!tvb_memeql(new_tvb, 0, "NTLMSSP", 7))){
1582
1583     /* make sure the protocol op comes first */
1584     ldap_do_protocolop(actx->pinfo);
1585
1586     call_dissector(ntlmssp_handle, new_tvb, actx->pinfo, tree);
1587   }
1588
1589
1590
1591   return offset;
1592 }
1593
1594
1595
1596 static int
1597 dissect_ldap_ErrorMessage(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1598   offset = dissect_ldap_LDAPString(implicit_tag, tvb, offset, actx, tree, hf_index);
1599
1600   return offset;
1601 }
1602
1603
1604
1605 static int
1606 dissect_ldap_LDAPURL(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1607   offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
1608                                        NULL);
1609
1610 #line 54 "./asn1/ldap/ldap.cnf"
1611   PROTO_ITEM_SET_URL(actx->created_item);
1612
1613
1614   return offset;
1615 }
1616
1617
1618 static const ber_sequence_t Referral_sequence_of[1] = {
1619   { &hf_ldap_Referral_item  , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_LDAPURL },
1620 };
1621
1622 static int
1623 dissect_ldap_Referral(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1624   offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
1625                                       Referral_sequence_of, hf_index, ett_ldap_Referral);
1626
1627   return offset;
1628 }
1629
1630
1631
1632 static int
1633 dissect_ldap_ServerSaslCreds(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1634 #line 231 "./asn1/ldap/ldap.cnf"
1635
1636 tvbuff_t *parameter_tvb = NULL;
1637 ldap_conv_info_t *ldap_info;
1638
1639   offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
1640                                        &parameter_tvb);
1641
1642   if (!parameter_tvb)
1643     return offset;
1644   ldap_info = (ldap_conv_info_t *)actx->private_data;
1645   switch (ldap_info->auth_type) {
1646
1647     /* For Kerberos V4, dissect it as a ticket. */
1648     /* XXX - what about LDAP_AUTH_SIMPLE? */
1649
1650   case LDAP_AUTH_SASL:
1651     /*
1652      * All frames after this are assumed to use a security layer.
1653      *
1654      * XXX - won't work if there's another reply, with the security
1655      * layer, starting in the same TCP segment that ends this
1656      * reply, but as LDAP is a request/response protocol, and
1657      * as the client probably can't start using authentication until
1658      * it gets the bind reply and the server won't send a reply until
1659      * it gets a request, that probably won't happen.
1660      *
1661      * XXX - that assumption is invalid; it's not clear where the
1662      * hell you find out whether there's any security layer.  In
1663      * one capture, we have two GSS-SPNEGO negotiations, both of
1664      * which select MS KRB5, and the only differences in the tokens
1665      * is in the RC4-HMAC ciphertext.  The various
1666      * draft-ietf--cat-sasl-gssapi-NN.txt drafts seem to imply
1667      * that the RFC 2222 spoo with the bitmask and maximum
1668      * output message size stuff is done - but where does that
1669      * stuff show up?  Is it in the ciphertext, which means it's
1670      * presumably encrypted?
1671      *
1672      * Grrr.  We have to do a gross heuristic, checking whether the
1673      * putative LDAP message begins with 0x00 or not, making the
1674      * assumption that we won't have more than 2^24 bytes of
1675      * encapsulated stuff.
1676      */
1677     ldap_info->first_auth_frame = actx->pinfo->num + 1;
1678     if (ldap_info->auth_mech != NULL &&
1679       strcmp(ldap_info->auth_mech, "GSS-SPNEGO") == 0) {
1680       /* It could be the second leg of GSS-SPNEGO wrapping NTLMSSP
1681        * which might not be wrapped in GSS-SPNEGO but be a raw
1682        * NTLMSSP blob
1683        */
1684       if ( (tvb_reported_length(parameter_tvb)>=7)
1685         &&   (!tvb_memeql(parameter_tvb, 0, "NTLMSSP", 7))){
1686         call_dissector(ntlmssp_handle, parameter_tvb, actx->pinfo, tree);
1687         break;
1688       }
1689       /*
1690        * This is a GSS-API token.
1691        */
1692       if(parameter_tvb && (tvb_reported_length(parameter_tvb) > 0))
1693         call_dissector(spnego_handle, parameter_tvb, actx->pinfo, tree);
1694     } else if (ldap_info->auth_mech != NULL &&
1695       strcmp(ldap_info->auth_mech, "GSSAPI") == 0) {
1696       /*
1697        * This is a GSS-API token.
1698        */
1699       if(parameter_tvb && (tvb_reported_length(parameter_tvb) > 0))
1700           call_dissector(gssapi_handle, parameter_tvb, actx->pinfo, tree);
1701     }
1702   break;
1703   }
1704   actx->private_data = ldap_info;
1705
1706
1707
1708   return offset;
1709 }
1710
1711
1712 static const ber_sequence_t BindResponse_U_sequence[] = {
1713   { &hf_ldap_bindResponse_resultCode, BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_ldap_BindResponse_resultCode },
1714   { &hf_ldap_bindResponse_matchedDN, BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_T_bindResponse_matchedDN },
1715   { &hf_ldap_errorMessage   , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_ErrorMessage },
1716   { &hf_ldap_referral       , BER_CLASS_CON, 3, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_Referral },
1717   { &hf_ldap_serverSaslCreds, BER_CLASS_CON, 7, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_ServerSaslCreds },
1718   { NULL, 0, 0, 0, NULL }
1719 };
1720
1721 static int
1722 dissect_ldap_BindResponse_U(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1723   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
1724                                    BindResponse_U_sequence, hf_index, ett_ldap_BindResponse_U);
1725
1726   return offset;
1727 }
1728
1729
1730
1731 static int
1732 dissect_ldap_BindResponse(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1733   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
1734                                       hf_index, BER_CLASS_APP, 1, TRUE, dissect_ldap_BindResponse_U);
1735
1736   return offset;
1737 }
1738
1739
1740
1741 static int
1742 dissect_ldap_NULL(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1743   offset = dissect_ber_null(implicit_tag, actx, tree, tvb, offset, hf_index);
1744
1745   return offset;
1746 }
1747
1748
1749
1750 static int
1751 dissect_ldap_UnbindRequest(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1752 #line 508 "./asn1/ldap/ldap.cnf"
1753
1754   implicit_tag = TRUE; /* correct problem with asn2wrs */
1755
1756   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
1757                                       hf_index, BER_CLASS_APP, 2, TRUE, dissect_ldap_NULL);
1758
1759
1760   ldap_do_protocolop(actx->pinfo);
1761
1762
1763
1764
1765
1766
1767
1768   return offset;
1769 }
1770
1771
1772 static const value_string ldap_T_scope_vals[] = {
1773   {   0, "baseObject" },
1774   {   1, "singleLevel" },
1775   {   2, "wholeSubtree" },
1776   { 0, NULL }
1777 };
1778
1779
1780 static int
1781 dissect_ldap_T_scope(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1782 #line 388 "./asn1/ldap/ldap.cnf"
1783
1784   guint32 scope = 0xffff;
1785   const gchar *valstr;
1786
1787   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
1788                                   &scope);
1789
1790
1791   ldap_do_protocolop(actx->pinfo);
1792
1793   valstr = val_to_str(scope, ldap_T_scope_vals, "Unknown scope(%u)");
1794
1795   col_append_fstr(actx->pinfo->cinfo, COL_INFO, "%s ", valstr);
1796
1797   if(ldm_tree)
1798     proto_item_append_text(ldm_tree, " %s", valstr);
1799
1800
1801
1802   return offset;
1803 }
1804
1805
1806 static const value_string ldap_T_derefAliases_vals[] = {
1807   {   0, "neverDerefAliases" },
1808   {   1, "derefInSearching" },
1809   {   2, "derefFindingBaseObj" },
1810   {   3, "derefAlways" },
1811   { 0, NULL }
1812 };
1813
1814
1815 static int
1816 dissect_ldap_T_derefAliases(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1817   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
1818                                   NULL);
1819
1820   return offset;
1821 }
1822
1823
1824
1825 static int
1826 dissect_ldap_INTEGER_0_maxInt(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1827   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
1828                                                 NULL);
1829
1830   return offset;
1831 }
1832
1833
1834
1835 static int
1836 dissect_ldap_BOOLEAN(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1837   offset = dissect_ber_boolean(implicit_tag, actx, tree, tvb, offset, hf_index, NULL);
1838
1839   return offset;
1840 }
1841
1842
1843
1844 static int
1845 dissect_ldap_T_and_item(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1846   offset = dissect_ldap_Filter(implicit_tag, tvb, offset, actx, tree, hf_index);
1847
1848 #line 554 "./asn1/ldap/ldap.cnf"
1849   if(and_filter_string){
1850     and_filter_string=wmem_strdup_printf(wmem_packet_scope(), "(&%s%s)",and_filter_string,Filter_string);
1851   } else {
1852     and_filter_string=Filter_string;
1853   }
1854
1855
1856   return offset;
1857 }
1858
1859
1860 static const ber_sequence_t T_and_set_of[1] = {
1861   { &hf_ldap_and_item       , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ldap_T_and_item },
1862 };
1863
1864 static int
1865 dissect_ldap_T_and(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1866 #line 561 "./asn1/ldap/ldap.cnf"
1867   proto_tree *tr=NULL;
1868   proto_item *it=NULL;
1869   const char *old_and_filter_string=and_filter_string;
1870
1871   and_filter_string=NULL;
1872
1873   tr=proto_tree_add_subtree(tree, tvb, offset, -1, ett_ldap_T_and, &it, "and: ");
1874   tree = tr;
1875
1876   offset = dissect_ber_set_of(implicit_tag, actx, tree, tvb, offset,
1877                                  T_and_set_of, hf_index, ett_ldap_T_and);
1878
1879
1880   if(and_filter_string) {
1881     proto_item_append_text(it, "%s", and_filter_string);
1882     Filter_string=wmem_strdup(wmem_packet_scope(), and_filter_string);
1883   }
1884   and_filter_string=old_and_filter_string;
1885
1886
1887
1888   return offset;
1889 }
1890
1891
1892
1893 static int
1894 dissect_ldap_T_or_item(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1895   offset = dissect_ldap_Filter(implicit_tag, tvb, offset, actx, tree, hf_index);
1896
1897 #line 579 "./asn1/ldap/ldap.cnf"
1898   if(or_filter_string){
1899     or_filter_string=wmem_strdup_printf(wmem_packet_scope(), "(|%s%s)",or_filter_string,Filter_string);
1900   } else {
1901     or_filter_string=Filter_string;
1902   }
1903
1904
1905
1906   return offset;
1907 }
1908
1909
1910 static const ber_sequence_t T_or_set_of[1] = {
1911   { &hf_ldap_or_item        , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ldap_T_or_item },
1912 };
1913
1914 static int
1915 dissect_ldap_T_or(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1916 #line 587 "./asn1/ldap/ldap.cnf"
1917   proto_tree *tr;
1918   proto_item *it;
1919   const char *old_or_filter_string=or_filter_string;
1920
1921   or_filter_string=NULL;
1922   tr=proto_tree_add_subtree(tree, tvb, offset, -1, ett_ldap_T_or, &it, "or: ");
1923   tree = tr;
1924
1925   offset = dissect_ber_set_of(implicit_tag, actx, tree, tvb, offset,
1926                                  T_or_set_of, hf_index, ett_ldap_T_or);
1927
1928   if(or_filter_string) {
1929     proto_item_append_text(it, "%s", or_filter_string);
1930     Filter_string=wmem_strdup(wmem_packet_scope(), or_filter_string);
1931   }
1932   or_filter_string=old_or_filter_string;
1933
1934
1935
1936   return offset;
1937 }
1938
1939
1940
1941 static int
1942 dissect_ldap_T_not(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1943   offset = dissect_ldap_Filter(implicit_tag, tvb, offset, actx, tree, hf_index);
1944
1945 #line 606 "./asn1/ldap/ldap.cnf"
1946   Filter_string=wmem_strdup_printf(wmem_packet_scope(), "(!%s)",string_or_null(Filter_string));
1947
1948
1949   return offset;
1950 }
1951
1952
1953
1954 static int
1955 dissect_ldap_AttributeDescription(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1956   offset = dissect_ldap_LDAPString(implicit_tag, tvb, offset, actx, tree, hf_index);
1957
1958   return offset;
1959 }
1960
1961
1962
1963 static const ber_sequence_t AttributeValueAssertion_sequence[] = {
1964   { &hf_ldap_attributeDesc  , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeDescription },
1965   { &hf_ldap_assertionValue , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_AssertionValue },
1966   { NULL, 0, 0, 0, NULL }
1967 };
1968
1969 static int
1970 dissect_ldap_AttributeValueAssertion(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1971   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
1972                                    AttributeValueAssertion_sequence, hf_index, ett_ldap_AttributeValueAssertion);
1973
1974   return offset;
1975 }
1976
1977
1978
1979 static int
1980 dissect_ldap_T_equalityMatch(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
1981   offset = dissect_ldap_AttributeValueAssertion(implicit_tag, tvb, offset, actx, tree, hf_index);
1982
1983 #line 531 "./asn1/ldap/ldap.cnf"
1984   Filter_string=wmem_strdup_printf(wmem_packet_scope(), "(%s=%s)",
1985                                    string_or_null(attributedesc_string),
1986                                    string_or_null(ldapvalue_string));
1987
1988
1989
1990   return offset;
1991 }
1992
1993
1994 static const value_string ldap_T_substringFilter_substrings_item_vals[] = {
1995   {   0, "initial" },
1996   {   1, "any" },
1997   {   2, "final" },
1998   { 0, NULL }
1999 };
2000
2001 static const ber_choice_t T_substringFilter_substrings_item_choice[] = {
2002   {   0, &hf_ldap_initial        , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_ldap_LDAPString },
2003   {   1, &hf_ldap_any            , BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_ldap_LDAPString },
2004   {   2, &hf_ldap_final          , BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_ldap_LDAPString },
2005   { 0, NULL, 0, 0, 0, NULL }
2006 };
2007
2008 static int
2009 dissect_ldap_T_substringFilter_substrings_item(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2010   offset = dissect_ber_choice(actx, tree, tvb, offset,
2011                                  T_substringFilter_substrings_item_choice, hf_index, ett_ldap_T_substringFilter_substrings_item,
2012                                  NULL);
2013
2014 #line 632 "./asn1/ldap/ldap.cnf"
2015   if (substring_item_final) {
2016     substring_value=wmem_strdup_printf(wmem_packet_scope(), "%s%s",
2017                                       (substring_value?substring_value:"*"),
2018                                        substring_item_final);
2019   } else if (substring_item_any) {
2020     substring_value=wmem_strdup_printf(wmem_packet_scope(), "%s%s*",
2021                                       (substring_value?substring_value:"*"),
2022                                        substring_item_any);
2023   } else if (substring_item_init) {
2024     substring_value=wmem_strdup_printf(wmem_packet_scope(), "%s*",
2025                                        substring_item_init);
2026   }
2027
2028
2029   return offset;
2030 }
2031
2032
2033 static const ber_sequence_t T_substringFilter_substrings_sequence_of[1] = {
2034   { &hf_ldap_substringFilter_substrings_item, BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ldap_T_substringFilter_substrings_item },
2035 };
2036
2037 static int
2038 dissect_ldap_T_substringFilter_substrings(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2039   offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
2040                                       T_substringFilter_substrings_sequence_of, hf_index, ett_ldap_T_substringFilter_substrings);
2041
2042   return offset;
2043 }
2044
2045
2046 static const ber_sequence_t SubstringFilter_sequence[] = {
2047   { &hf_ldap_type           , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeDescription },
2048   { &hf_ldap_substringFilter_substrings, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_T_substringFilter_substrings },
2049   { NULL, 0, 0, 0, NULL }
2050 };
2051
2052 static int
2053 dissect_ldap_SubstringFilter(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2054 #line 646 "./asn1/ldap/ldap.cnf"
2055   proto_tree *tr;
2056   proto_item *it;
2057   const char *old_substring_value=substring_value;
2058
2059   attr_type=NULL;
2060   substring_value=NULL;
2061   substring_item_init=NULL;
2062   substring_item_any=NULL;
2063   substring_item_final=NULL;
2064
2065   tr=proto_tree_add_subtree(tree, tvb, offset, -1, ett_ldap_SubstringFilter, &it, "substring: ");
2066   tree = tr;
2067
2068   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2069                                    SubstringFilter_sequence, hf_index, ett_ldap_SubstringFilter);
2070
2071   Filter_string=wmem_strdup_printf(wmem_packet_scope(), "(%s=%s)",
2072                                    string_or_null(attr_type),
2073                                    string_or_null(substring_value));
2074   proto_item_append_text(it, "%s", Filter_string);
2075   substring_value=old_substring_value;
2076
2077
2078
2079   return offset;
2080 }
2081
2082
2083
2084 static int
2085 dissect_ldap_T_greaterOrEqual(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2086   offset = dissect_ldap_AttributeValueAssertion(implicit_tag, tvb, offset, actx, tree, hf_index);
2087
2088 #line 537 "./asn1/ldap/ldap.cnf"
2089   Filter_string=wmem_strdup_printf(wmem_packet_scope(), "(%s>=%s)",
2090                                    string_or_null(attributedesc_string),
2091                                    string_or_null(ldapvalue_string));
2092
2093
2094
2095   return offset;
2096 }
2097
2098
2099
2100 static int
2101 dissect_ldap_T_lessOrEqual(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2102   offset = dissect_ldap_AttributeValueAssertion(implicit_tag, tvb, offset, actx, tree, hf_index);
2103
2104 #line 543 "./asn1/ldap/ldap.cnf"
2105   Filter_string=wmem_strdup_printf(wmem_packet_scope(), "(%s<=%s)",
2106                                    string_or_null(attributedesc_string),
2107                                    string_or_null(ldapvalue_string));
2108
2109
2110
2111   return offset;
2112 }
2113
2114
2115
2116 static int
2117 dissect_ldap_T_present(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2118   offset = dissect_ldap_AttributeDescription(implicit_tag, tvb, offset, actx, tree, hf_index);
2119
2120 #line 603 "./asn1/ldap/ldap.cnf"
2121   Filter_string=wmem_strdup_printf(wmem_packet_scope(), "(%s=*)",string_or_null(Filter_string));
2122
2123
2124   return offset;
2125 }
2126
2127
2128
2129 static int
2130 dissect_ldap_T_approxMatch(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2131   offset = dissect_ldap_AttributeValueAssertion(implicit_tag, tvb, offset, actx, tree, hf_index);
2132
2133 #line 549 "./asn1/ldap/ldap.cnf"
2134   Filter_string=wmem_strdup_printf(wmem_packet_scope(), "(%s~=%s)",
2135                                    string_or_null(attributedesc_string),
2136                                    string_or_null(ldapvalue_string));
2137
2138
2139   return offset;
2140 }
2141
2142
2143
2144 static int
2145 dissect_ldap_MatchingRuleId(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2146   offset = dissect_ldap_LDAPString(implicit_tag, tvb, offset, actx, tree, hf_index);
2147
2148   return offset;
2149 }
2150
2151
2152
2153 static int
2154 dissect_ldap_T_dnAttributes(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2155 #line 609 "./asn1/ldap/ldap.cnf"
2156   gboolean val;
2157
2158   offset = dissect_ber_boolean(implicit_tag, actx, tree, tvb, offset, hf_index, &val);
2159
2160
2161   matching_rule_dnattr = val;
2162
2163
2164
2165
2166   return offset;
2167 }
2168
2169
2170 static const ber_sequence_t MatchingRuleAssertion_sequence[] = {
2171   { &hf_ldap_matchingRule   , BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_MatchingRuleId },
2172   { &hf_ldap_type           , BER_CLASS_CON, 2, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_AttributeDescription },
2173   { &hf_ldap_matchValue     , BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_ldap_AssertionValue },
2174   { &hf_ldap_dnAttributes   , BER_CLASS_CON, 4, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_T_dnAttributes },
2175   { NULL, 0, 0, 0, NULL }
2176 };
2177
2178 static int
2179 dissect_ldap_MatchingRuleAssertion(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2180   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2181                                    MatchingRuleAssertion_sequence, hf_index, ett_ldap_MatchingRuleAssertion);
2182
2183   return offset;
2184 }
2185
2186
2187
2188 static int
2189 dissect_ldap_T_extensibleMatch(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2190 #line 618 "./asn1/ldap/ldap.cnf"
2191   attr_type=NULL;
2192   matching_rule_string=NULL;
2193   ldapvalue_string=NULL;
2194   matching_rule_dnattr=FALSE;
2195
2196
2197   offset = dissect_ldap_MatchingRuleAssertion(implicit_tag, tvb, offset, actx, tree, hf_index);
2198
2199 #line 624 "./asn1/ldap/ldap.cnf"
2200   Filter_string=wmem_strdup_printf(wmem_packet_scope(), "(%s:%s%s%s=%s)",
2201                                   (attr_type?attr_type:""),
2202                                   (matching_rule_dnattr?"dn:":""),
2203                                   (matching_rule_string?matching_rule_string:""),
2204                                   (matching_rule_string?":":""),
2205                                    string_or_null(ldapvalue_string));
2206
2207
2208   return offset;
2209 }
2210
2211
2212 static const value_string ldap_Filter_vals[] = {
2213   {   0, "and" },
2214   {   1, "or" },
2215   {   2, "not" },
2216   {   3, "equalityMatch" },
2217   {   4, "substrings" },
2218   {   5, "greaterOrEqual" },
2219   {   6, "lessOrEqual" },
2220   {   7, "present" },
2221   {   8, "approxMatch" },
2222   {   9, "extensibleMatch" },
2223   { 0, NULL }
2224 };
2225
2226 static const ber_choice_t Filter_choice[] = {
2227   {   0, &hf_ldap_and            , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_ldap_T_and },
2228   {   1, &hf_ldap_or             , BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_ldap_T_or },
2229   {   2, &hf_ldap_not            , BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_ldap_T_not },
2230   {   3, &hf_ldap_equalityMatch  , BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_ldap_T_equalityMatch },
2231   {   4, &hf_ldap_substrings     , BER_CLASS_CON, 4, BER_FLAGS_IMPLTAG, dissect_ldap_SubstringFilter },
2232   {   5, &hf_ldap_greaterOrEqual , BER_CLASS_CON, 5, BER_FLAGS_IMPLTAG, dissect_ldap_T_greaterOrEqual },
2233   {   6, &hf_ldap_lessOrEqual    , BER_CLASS_CON, 6, BER_FLAGS_IMPLTAG, dissect_ldap_T_lessOrEqual },
2234   {   7, &hf_ldap_present        , BER_CLASS_CON, 7, BER_FLAGS_IMPLTAG, dissect_ldap_T_present },
2235   {   8, &hf_ldap_approxMatch    , BER_CLASS_CON, 8, BER_FLAGS_IMPLTAG, dissect_ldap_T_approxMatch },
2236   {   9, &hf_ldap_extensibleMatch, BER_CLASS_CON, 9, BER_FLAGS_IMPLTAG, dissect_ldap_T_extensibleMatch },
2237   { 0, NULL, 0, 0, 0, NULL }
2238 };
2239
2240 static int
2241 dissect_ldap_Filter(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2242 #line 667 "./asn1/ldap/ldap.cnf"
2243   proto_tree *tr;
2244   proto_item *it;
2245   attributedesc_string=NULL;
2246
2247   if (Filter_length++ > MAX_FILTER_LEN) {
2248     expert_add_info_format(actx->pinfo, tree, &ei_ldap_exceeded_filter_length, "Filter length exceeds %u. Giving up.", MAX_FILTER_LEN);
2249     THROW(ReportedBoundsError);
2250   }
2251
2252   if (Filter_elements++ > MAX_FILTER_ELEMENTS) {
2253     expert_add_info_format(actx->pinfo, tree, &ei_ldap_too_many_filter_elements, "Found more than %u filter elements. Giving up.", MAX_FILTER_ELEMENTS);
2254     THROW(ReportedBoundsError);
2255   }
2256
2257   tr=proto_tree_add_subtree(tree, tvb, offset, -1, ett_ldap_Filter, &it, "Filter: ");
2258   tree = tr;
2259
2260   offset = dissect_ber_choice(actx, tree, tvb, offset,
2261                                  Filter_choice, hf_index, ett_ldap_Filter,
2262                                  NULL);
2263
2264   if(Filter_string)
2265     proto_item_append_text(it, "%s", string_or_null(Filter_string));
2266
2267
2268
2269   return offset;
2270 }
2271
2272
2273
2274 static int
2275 dissect_ldap_T_filter(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2276 #line 520 "./asn1/ldap/ldap.cnf"
2277   Filter_string=NULL;
2278   Filter_elements = 0;
2279   Filter_length = 0;
2280
2281
2282   offset = dissect_ldap_Filter(implicit_tag, tvb, offset, actx, tree, hf_index);
2283
2284 #line 525 "./asn1/ldap/ldap.cnf"
2285   Filter_string=NULL;
2286   and_filter_string=NULL;
2287   Filter_elements = 0;
2288   Filter_length = 0;
2289
2290
2291   return offset;
2292 }
2293
2294
2295 static const ber_sequence_t AttributeDescriptionList_sequence_of[1] = {
2296   { &hf_ldap_AttributeDescriptionList_item, BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeDescription },
2297 };
2298
2299 static int
2300 dissect_ldap_AttributeDescriptionList(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2301   offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
2302                                       AttributeDescriptionList_sequence_of, hf_index, ett_ldap_AttributeDescriptionList);
2303
2304   return offset;
2305 }
2306
2307
2308 static const ber_sequence_t SearchRequest_U_sequence[] = {
2309   { &hf_ldap_baseObject     , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_LDAPDN },
2310   { &hf_ldap_scope          , BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_ldap_T_scope },
2311   { &hf_ldap_derefAliases   , BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_ldap_T_derefAliases },
2312   { &hf_ldap_sizeLimit      , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ldap_INTEGER_0_maxInt },
2313   { &hf_ldap_timeLimit      , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ldap_INTEGER_0_maxInt },
2314   { &hf_ldap_typesOnly      , BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_NOOWNTAG, dissect_ldap_BOOLEAN },
2315   { &hf_ldap_filter         , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ldap_T_filter },
2316   { &hf_ldap_searchRequest_attributes, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeDescriptionList },
2317   { NULL, 0, 0, 0, NULL }
2318 };
2319
2320 static int
2321 dissect_ldap_SearchRequest_U(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2322   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2323                                    SearchRequest_U_sequence, hf_index, ett_ldap_SearchRequest_U);
2324
2325   return offset;
2326 }
2327
2328
2329
2330 static int
2331 dissect_ldap_SearchRequest(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2332   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2333                                       hf_index, BER_CLASS_APP, 3, TRUE, dissect_ldap_SearchRequest_U);
2334
2335   return offset;
2336 }
2337
2338
2339
2340 static int
2341 dissect_ldap_AttributeValue(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2342 #line 450 "./asn1/ldap/ldap.cnf"
2343
2344   tvbuff_t  *next_tvb = NULL;
2345   gchar *string;
2346   guint32 i, len;
2347   int old_offset = offset;
2348   gint *hf_id;
2349
2350   /* attr_type, should be set before calling this function */
2351
2352   /* extract the value of the octetstring */
2353   offset = dissect_ber_octet_string(FALSE, actx, NULL, tvb, offset, hf_index, &next_tvb);
2354
2355   /* first check if we have a custom attribute type configured */
2356   if ((hf_id = get_hf_for_header (attr_type)) != NULL)
2357     proto_tree_add_item (tree, *hf_id, next_tvb, 0, tvb_reported_length_remaining(next_tvb, 0), ENC_UTF_8|ENC_NA);
2358
2359   /* if we have an attribute type that isn't binary see if there is a better dissector */
2360   else if(!attr_type || !next_tvb || !dissector_try_string_new(ldap_name_dissector_table, attr_type, next_tvb, actx->pinfo, tree, FALSE, NULL)) {
2361     offset = old_offset;
2362
2363     /* do the default thing */
2364     offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
2365                                        NULL);
2366
2367
2368     len = tvb_reported_length_remaining(next_tvb, 0);
2369
2370     for(i = 0; i < len; i++)
2371       if(!g_ascii_isprint(tvb_get_guint8(next_tvb, i)))
2372         break;
2373
2374     if(i == len) {
2375       string = tvb_get_string_enc(wmem_packet_scope(), next_tvb, 0, tvb_reported_length_remaining(next_tvb, 0), ENC_ASCII|ENC_NA);
2376       proto_item_set_text(actx->created_item, "AttributeValue: %s", string);
2377     }
2378   }
2379
2380
2381
2382   return offset;
2383 }
2384
2385
2386 static const ber_sequence_t SET_OF_AttributeValue_set_of[1] = {
2387   { &hf_ldap_vals_item      , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeValue },
2388 };
2389
2390 static int
2391 dissect_ldap_SET_OF_AttributeValue(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2392   offset = dissect_ber_set_of(implicit_tag, actx, tree, tvb, offset,
2393                                  SET_OF_AttributeValue_set_of, hf_index, ett_ldap_SET_OF_AttributeValue);
2394
2395   return offset;
2396 }
2397
2398
2399 static const ber_sequence_t PartialAttributeList_item_sequence[] = {
2400   { &hf_ldap_type           , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeDescription },
2401   { &hf_ldap_vals           , BER_CLASS_UNI, BER_UNI_TAG_SET, BER_FLAGS_NOOWNTAG, dissect_ldap_SET_OF_AttributeValue },
2402   { NULL, 0, 0, 0, NULL }
2403 };
2404
2405 static int
2406 dissect_ldap_PartialAttributeList_item(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2407   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2408                                    PartialAttributeList_item_sequence, hf_index, ett_ldap_PartialAttributeList_item);
2409
2410   return offset;
2411 }
2412
2413
2414 static const ber_sequence_t PartialAttributeList_sequence_of[1] = {
2415   { &hf_ldap_PartialAttributeList_item, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_PartialAttributeList_item },
2416 };
2417
2418 static int
2419 dissect_ldap_PartialAttributeList(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2420   offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
2421                                       PartialAttributeList_sequence_of, hf_index, ett_ldap_PartialAttributeList);
2422
2423   return offset;
2424 }
2425
2426
2427 static const ber_sequence_t SearchResultEntry_U_sequence[] = {
2428   { &hf_ldap_objectName     , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_LDAPDN },
2429   { &hf_ldap_searchResultEntry_attributes, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_PartialAttributeList },
2430   { NULL, 0, 0, 0, NULL }
2431 };
2432
2433 static int
2434 dissect_ldap_SearchResultEntry_U(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2435   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2436                                    SearchResultEntry_U_sequence, hf_index, ett_ldap_SearchResultEntry_U);
2437
2438   return offset;
2439 }
2440
2441
2442
2443 static int
2444 dissect_ldap_SearchResultEntry(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2445   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2446                                       hf_index, BER_CLASS_APP, 4, TRUE, dissect_ldap_SearchResultEntry_U);
2447
2448   return offset;
2449 }
2450
2451
2452 static const value_string ldap_T_resultCode_vals[] = {
2453   {   0, "success" },
2454   {   1, "operationsError" },
2455   {   2, "protocolError" },
2456   {   3, "timeLimitExceeded" },
2457   {   4, "sizeLimitExceeded" },
2458   {   5, "compareFalse" },
2459   {   6, "compareTrue" },
2460   {   7, "authMethodNotSupported" },
2461   {   8, "strongAuthRequired" },
2462   {  10, "referral" },
2463   {  11, "adminLimitExceeded" },
2464   {  12, "unavailableCriticalExtension" },
2465   {  13, "confidentialityRequired" },
2466   {  14, "saslBindInProgress" },
2467   {  16, "noSuchAttribute" },
2468   {  17, "undefinedAttributeType" },
2469   {  18, "inappropriateMatching" },
2470   {  19, "constraintViolation" },
2471   {  20, "attributeOrValueExists" },
2472   {  21, "invalidAttributeSyntax" },
2473   {  32, "noSuchObject" },
2474   {  33, "aliasProblem" },
2475   {  34, "invalidDNSyntax" },
2476   {  36, "aliasDereferencingProblem" },
2477   {  48, "inappropriateAuthentication" },
2478   {  49, "invalidCredentials" },
2479   {  50, "insufficientAccessRights" },
2480   {  51, "busy" },
2481   {  52, "unavailable" },
2482   {  53, "unwillingToPerform" },
2483   {  54, "loopDetect" },
2484   {  64, "namingViolation" },
2485   {  65, "objectClassViolation" },
2486   {  66, "notAllowedOnNonLeaf" },
2487   {  67, "notAllowedOnRDN" },
2488   {  68, "entryAlreadyExists" },
2489   {  69, "objectClassModsProhibited" },
2490   {  71, "affectsMultipleDSAs" },
2491   {  80, "other" },
2492   { 118, "canceled" },
2493   { 119, "noSuchOperation" },
2494   { 120, "tooLate" },
2495   { 121, "cannotCancel" },
2496   { 0, NULL }
2497 };
2498
2499
2500 static int
2501 dissect_ldap_T_resultCode(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2502 #line 404 "./asn1/ldap/ldap.cnf"
2503
2504   const gchar *valstr;
2505
2506   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
2507                                   &result);
2508
2509
2510   ldap_do_protocolop(actx->pinfo);
2511
2512   valstr = val_to_str(result, ldap_T_resultCode_vals, "Unknown result(%u)");
2513
2514   col_append_fstr(actx->pinfo->cinfo, COL_INFO, "%s ", valstr);
2515
2516   if(ldm_tree)
2517     proto_item_append_text(ldm_tree, " %s", valstr);
2518
2519
2520
2521
2522   return offset;
2523 }
2524
2525
2526 static const ber_sequence_t LDAPResult_sequence[] = {
2527   { &hf_ldap_resultCode     , BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_ldap_T_resultCode },
2528   { &hf_ldap_matchedDN      , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_LDAPDN },
2529   { &hf_ldap_errorMessage   , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_ErrorMessage },
2530   { &hf_ldap_referral       , BER_CLASS_CON, 3, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_Referral },
2531   { NULL, 0, 0, 0, NULL }
2532 };
2533
2534 static int
2535 dissect_ldap_LDAPResult(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2536   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2537                                    LDAPResult_sequence, hf_index, ett_ldap_LDAPResult);
2538
2539   return offset;
2540 }
2541
2542
2543
2544 static int
2545 dissect_ldap_SearchResultDone(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2546   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2547                                       hf_index, BER_CLASS_APP, 5, TRUE, dissect_ldap_LDAPResult);
2548
2549   return offset;
2550 }
2551
2552
2553 static const ber_sequence_t SEQUENCE_OF_LDAPURL_sequence_of[1] = {
2554   { &hf_ldap__untag_item    , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_LDAPURL },
2555 };
2556
2557 static int
2558 dissect_ldap_SEQUENCE_OF_LDAPURL(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2559   offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
2560                                       SEQUENCE_OF_LDAPURL_sequence_of, hf_index, ett_ldap_SEQUENCE_OF_LDAPURL);
2561
2562   return offset;
2563 }
2564
2565
2566
2567 static int
2568 dissect_ldap_SearchResultReference(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2569 #line 795 "./asn1/ldap/ldap.cnf"
2570
2571   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2572                                       hf_index, BER_CLASS_APP, 19, TRUE, dissect_ldap_SEQUENCE_OF_LDAPURL);
2573
2574
2575   ldap_do_protocolop(actx->pinfo);
2576
2577
2578
2579
2580   return offset;
2581 }
2582
2583
2584 static const value_string ldap_T_operation_vals[] = {
2585   {   0, "add" },
2586   {   1, "delete" },
2587   {   2, "replace" },
2588   {   3, "increment" },
2589   { 0, NULL }
2590 };
2591
2592
2593 static int
2594 dissect_ldap_T_operation(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2595   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
2596                                   NULL);
2597
2598   return offset;
2599 }
2600
2601
2602 static const ber_sequence_t AttributeTypeAndValues_sequence[] = {
2603   { &hf_ldap_type           , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeDescription },
2604   { &hf_ldap_vals           , BER_CLASS_UNI, BER_UNI_TAG_SET, BER_FLAGS_NOOWNTAG, dissect_ldap_SET_OF_AttributeValue },
2605   { NULL, 0, 0, 0, NULL }
2606 };
2607
2608 static int
2609 dissect_ldap_AttributeTypeAndValues(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2610   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2611                                    AttributeTypeAndValues_sequence, hf_index, ett_ldap_AttributeTypeAndValues);
2612
2613   return offset;
2614 }
2615
2616
2617 static const ber_sequence_t T_modifyRequest_modification_item_sequence[] = {
2618   { &hf_ldap_operation      , BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_ldap_T_operation },
2619   { &hf_ldap_modification   , BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeTypeAndValues },
2620   { NULL, 0, 0, 0, NULL }
2621 };
2622
2623 static int
2624 dissect_ldap_T_modifyRequest_modification_item(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2625   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2626                                    T_modifyRequest_modification_item_sequence, hf_index, ett_ldap_T_modifyRequest_modification_item);
2627
2628   return offset;
2629 }
2630
2631
2632 static const ber_sequence_t ModifyRequest_modification_sequence_of[1] = {
2633   { &hf_ldap_modifyRequest_modification_item, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_T_modifyRequest_modification_item },
2634 };
2635
2636 static int
2637 dissect_ldap_ModifyRequest_modification(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2638   offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
2639                                       ModifyRequest_modification_sequence_of, hf_index, ett_ldap_ModifyRequest_modification);
2640
2641   return offset;
2642 }
2643
2644
2645 static const ber_sequence_t ModifyRequest_U_sequence[] = {
2646   { &hf_ldap_object         , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_LDAPDN },
2647   { &hf_ldap_modifyRequest_modification, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_ModifyRequest_modification },
2648   { NULL, 0, 0, 0, NULL }
2649 };
2650
2651 static int
2652 dissect_ldap_ModifyRequest_U(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2653   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2654                                    ModifyRequest_U_sequence, hf_index, ett_ldap_ModifyRequest_U);
2655
2656   return offset;
2657 }
2658
2659
2660
2661 static int
2662 dissect_ldap_ModifyRequest(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2663   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2664                                       hf_index, BER_CLASS_APP, 6, TRUE, dissect_ldap_ModifyRequest_U);
2665
2666   return offset;
2667 }
2668
2669
2670
2671 static int
2672 dissect_ldap_ModifyResponse(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2673   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2674                                       hf_index, BER_CLASS_APP, 7, TRUE, dissect_ldap_LDAPResult);
2675
2676   return offset;
2677 }
2678
2679
2680 static const ber_sequence_t AttributeList_item_sequence[] = {
2681   { &hf_ldap_type           , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeDescription },
2682   { &hf_ldap_vals           , BER_CLASS_UNI, BER_UNI_TAG_SET, BER_FLAGS_NOOWNTAG, dissect_ldap_SET_OF_AttributeValue },
2683   { NULL, 0, 0, 0, NULL }
2684 };
2685
2686 static int
2687 dissect_ldap_AttributeList_item(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2688   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2689                                    AttributeList_item_sequence, hf_index, ett_ldap_AttributeList_item);
2690
2691   return offset;
2692 }
2693
2694
2695 static const ber_sequence_t AttributeList_sequence_of[1] = {
2696   { &hf_ldap_AttributeList_item, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeList_item },
2697 };
2698
2699 static int
2700 dissect_ldap_AttributeList(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2701   offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
2702                                       AttributeList_sequence_of, hf_index, ett_ldap_AttributeList);
2703
2704   return offset;
2705 }
2706
2707
2708 static const ber_sequence_t AddRequest_U_sequence[] = {
2709   { &hf_ldap_entry          , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_LDAPDN },
2710   { &hf_ldap_attributes     , BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeList },
2711   { NULL, 0, 0, 0, NULL }
2712 };
2713
2714 static int
2715 dissect_ldap_AddRequest_U(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2716   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2717                                    AddRequest_U_sequence, hf_index, ett_ldap_AddRequest_U);
2718
2719   return offset;
2720 }
2721
2722
2723
2724 static int
2725 dissect_ldap_AddRequest(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2726   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2727                                       hf_index, BER_CLASS_APP, 8, TRUE, dissect_ldap_AddRequest_U);
2728
2729   return offset;
2730 }
2731
2732
2733
2734 static int
2735 dissect_ldap_AddResponse(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2736   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2737                                       hf_index, BER_CLASS_APP, 9, TRUE, dissect_ldap_LDAPResult);
2738
2739   return offset;
2740 }
2741
2742
2743
2744 static int
2745 dissect_ldap_DelRequest(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2746   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2747                                       hf_index, BER_CLASS_APP, 10, TRUE, dissect_ldap_LDAPDN);
2748
2749   return offset;
2750 }
2751
2752
2753
2754 static int
2755 dissect_ldap_DelResponse(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2756   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2757                                       hf_index, BER_CLASS_APP, 11, TRUE, dissect_ldap_LDAPResult);
2758
2759   return offset;
2760 }
2761
2762
2763
2764 static int
2765 dissect_ldap_RelativeLDAPDN(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2766   offset = dissect_ldap_LDAPString(implicit_tag, tvb, offset, actx, tree, hf_index);
2767
2768   return offset;
2769 }
2770
2771
2772 static const ber_sequence_t ModifyDNRequest_U_sequence[] = {
2773   { &hf_ldap_entry          , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_LDAPDN },
2774   { &hf_ldap_newrdn         , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_RelativeLDAPDN },
2775   { &hf_ldap_deleteoldrdn   , BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_NOOWNTAG, dissect_ldap_BOOLEAN },
2776   { &hf_ldap_newSuperior    , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_LDAPDN },
2777   { NULL, 0, 0, 0, NULL }
2778 };
2779
2780 static int
2781 dissect_ldap_ModifyDNRequest_U(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2782   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2783                                    ModifyDNRequest_U_sequence, hf_index, ett_ldap_ModifyDNRequest_U);
2784
2785   return offset;
2786 }
2787
2788
2789
2790 static int
2791 dissect_ldap_ModifyDNRequest(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2792   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2793                                       hf_index, BER_CLASS_APP, 12, TRUE, dissect_ldap_ModifyDNRequest_U);
2794
2795   return offset;
2796 }
2797
2798
2799
2800 static int
2801 dissect_ldap_ModifyDNResponse(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2802   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2803                                       hf_index, BER_CLASS_APP, 13, TRUE, dissect_ldap_LDAPResult);
2804
2805   return offset;
2806 }
2807
2808
2809 static const ber_sequence_t CompareRequest_U_sequence[] = {
2810   { &hf_ldap_entry          , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_LDAPDN },
2811   { &hf_ldap_ava            , BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeValueAssertion },
2812   { NULL, 0, 0, 0, NULL }
2813 };
2814
2815 static int
2816 dissect_ldap_CompareRequest_U(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2817   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2818                                    CompareRequest_U_sequence, hf_index, ett_ldap_CompareRequest_U);
2819
2820   return offset;
2821 }
2822
2823
2824
2825 static int
2826 dissect_ldap_CompareRequest(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2827   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2828                                       hf_index, BER_CLASS_APP, 14, TRUE, dissect_ldap_CompareRequest_U);
2829
2830   return offset;
2831 }
2832
2833
2834
2835 static int
2836 dissect_ldap_CompareResponse(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2837   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2838                                       hf_index, BER_CLASS_APP, 15, TRUE, dissect_ldap_LDAPResult);
2839
2840   return offset;
2841 }
2842
2843
2844
2845 static int
2846 dissect_ldap_AbandonRequest(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2847 #line 802 "./asn1/ldap/ldap.cnf"
2848
2849   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2850                                       hf_index, BER_CLASS_APP, 16, TRUE, dissect_ldap_MessageID);
2851
2852
2853   ldap_do_protocolop(actx->pinfo);
2854
2855
2856
2857   return offset;
2858 }
2859
2860
2861
2862 static int
2863 dissect_ldap_LDAPOID(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2864 #line 57 "./asn1/ldap/ldap.cnf"
2865
2866   tvbuff_t  *parameter_tvb;
2867   const gchar *name;
2868   ldap_conv_info_t *ldap_info = (ldap_conv_info_t *)actx->private_data;
2869
2870
2871   offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
2872                                        &parameter_tvb);
2873
2874 #line 65 "./asn1/ldap/ldap.cnf"
2875
2876   object_identifier_id = NULL;
2877
2878   if (!parameter_tvb)
2879     return offset;
2880
2881   object_identifier_id = tvb_get_string_enc(wmem_packet_scope(), parameter_tvb, 0, tvb_reported_length_remaining(parameter_tvb,0), ENC_UTF_8|ENC_NA);
2882   name = oid_resolved_from_string(wmem_packet_scope(), object_identifier_id);
2883
2884   if(name){
2885     proto_item_append_text(actx->created_item, " (%s)", name);
2886
2887     if((hf_index == hf_ldap_requestName) || (hf_index == hf_ldap_responseName)) {
2888       ldap_do_protocolop(actx->pinfo);
2889       col_append_fstr(actx->pinfo->cinfo, COL_INFO, "%s ", name);
2890     }
2891   }
2892
2893   /* Has the client requested the Start TLS operation? */
2894   if (ldap_info && hf_index == hf_ldap_requestName &&
2895     !strcmp(object_identifier_id, "1.3.6.1.4.1.1466.20037")) {
2896     /* remember we have asked to start_tls */
2897     ldap_info->start_tls_pending = TRUE;
2898   }
2899
2900
2901   return offset;
2902 }
2903
2904
2905
2906 static int
2907 dissect_ldap_T_requestValue(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2908 #line 737 "./asn1/ldap/ldap.cnf"
2909
2910   if((object_identifier_id != NULL) && oid_has_dissector(object_identifier_id)) {
2911     offset = call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, NULL);
2912   } else {
2913       offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
2914                                        NULL);
2915
2916   }
2917
2918
2919
2920   return offset;
2921 }
2922
2923
2924 static const ber_sequence_t ExtendedRequest_U_sequence[] = {
2925   { &hf_ldap_requestName    , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_ldap_LDAPOID },
2926   { &hf_ldap_requestValue   , BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_T_requestValue },
2927   { NULL, 0, 0, 0, NULL }
2928 };
2929
2930 static int
2931 dissect_ldap_ExtendedRequest_U(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2932   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
2933                                    ExtendedRequest_U_sequence, hf_index, ett_ldap_ExtendedRequest_U);
2934
2935   return offset;
2936 }
2937
2938
2939
2940 static int
2941 dissect_ldap_ExtendedRequest(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2942   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
2943                                       hf_index, BER_CLASS_APP, 23, TRUE, dissect_ldap_ExtendedRequest_U);
2944
2945   return offset;
2946 }
2947
2948
2949 static const value_string ldap_ExtendedResponse_resultCode_vals[] = {
2950   {   0, "success" },
2951   {   1, "operationsError" },
2952   {   2, "protocolError" },
2953   {   3, "timeLimitExceeded" },
2954   {   4, "sizeLimitExceeded" },
2955   {   5, "compareFalse" },
2956   {   6, "compareTrue" },
2957   {   7, "authMethodNotSupported" },
2958   {   8, "strongAuthRequired" },
2959   {  10, "referral" },
2960   {  11, "adminLimitExceeded" },
2961   {  12, "unavailableCriticalExtension" },
2962   {  13, "confidentialityRequired" },
2963   {  14, "saslBindInProgress" },
2964   {  16, "noSuchAttribute" },
2965   {  17, "undefinedAttributeType" },
2966   {  18, "inappropriateMatching" },
2967   {  19, "constraintViolation" },
2968   {  20, "attributeOrValueExists" },
2969   {  21, "invalidAttributeSyntax" },
2970   {  32, "noSuchObject" },
2971   {  33, "aliasProblem" },
2972   {  34, "invalidDNSyntax" },
2973   {  36, "aliasDereferencingProblem" },
2974   {  48, "inappropriateAuthentication" },
2975   {  49, "invalidCredentials" },
2976   {  50, "insufficientAccessRights" },
2977   {  51, "busy" },
2978   {  52, "unavailable" },
2979   {  53, "unwillingToPerform" },
2980   {  54, "loopDetect" },
2981   {  64, "namingViolation" },
2982   {  65, "objectClassViolation" },
2983   {  66, "notAllowedOnNonLeaf" },
2984   {  67, "notAllowedOnRDN" },
2985   {  68, "entryAlreadyExists" },
2986   {  69, "objectClassModsProhibited" },
2987   {  71, "affectsMultipleDSAs" },
2988   {  80, "other" },
2989   { 118, "canceled" },
2990   { 119, "noSuchOperation" },
2991   { 120, "tooLate" },
2992   { 121, "cannotCancel" },
2993   { 0, NULL }
2994 };
2995
2996
2997 static int
2998 dissect_ldap_ExtendedResponse_resultCode(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
2999 #line 435 "./asn1/ldap/ldap.cnf"
3000   guint32  resultCode;
3001   ldap_conv_info_t *ldap_info = (ldap_conv_info_t *)actx->private_data;
3002
3003   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
3004                                &resultCode);
3005   /* If Start TLS request was sent and resultCode is success... */
3006   if (ldap_info && ldap_info->start_tls_pending &&
3007       hf_index == hf_ldap_extendedResponse_resultCode && resultCode == 0) {
3008     /* The conversation will continue using SSL */
3009     ssl_starttls_ack(find_dissector("ssl"), actx->pinfo, ldap_handle);
3010     ldap_info->start_tls_pending = FALSE;
3011   }
3012
3013
3014
3015
3016   return offset;
3017 }
3018
3019
3020
3021 static int
3022 dissect_ldap_ResponseName(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3023   offset = dissect_ldap_LDAPOID(implicit_tag, tvb, offset, actx, tree, hf_index);
3024
3025   return offset;
3026 }
3027
3028
3029
3030 static int
3031 dissect_ldap_OCTET_STRING(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3032   offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
3033                                        NULL);
3034
3035   return offset;
3036 }
3037
3038
3039 static const ber_sequence_t ExtendedResponse_U_sequence[] = {
3040   { &hf_ldap_extendedResponse_resultCode, BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_ldap_ExtendedResponse_resultCode },
3041   { &hf_ldap_matchedDN      , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_LDAPDN },
3042   { &hf_ldap_errorMessage   , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_ErrorMessage },
3043   { &hf_ldap_referral       , BER_CLASS_CON, 3, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_Referral },
3044   { &hf_ldap_responseName   , BER_CLASS_CON, 10, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_ResponseName },
3045   { &hf_ldap_response       , BER_CLASS_CON, 11, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_OCTET_STRING },
3046   { NULL, 0, 0, 0, NULL }
3047 };
3048
3049 static int
3050 dissect_ldap_ExtendedResponse_U(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3051   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3052                                    ExtendedResponse_U_sequence, hf_index, ett_ldap_ExtendedResponse_U);
3053
3054   return offset;
3055 }
3056
3057
3058
3059 static int
3060 dissect_ldap_ExtendedResponse(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3061   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
3062                                       hf_index, BER_CLASS_APP, 24, TRUE, dissect_ldap_ExtendedResponse_U);
3063
3064   return offset;
3065 }
3066
3067
3068
3069 static int
3070 dissect_ldap_T_intermediateResponse_responseValue(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3071 #line 745 "./asn1/ldap/ldap.cnf"
3072
3073   const gchar *name;
3074
3075
3076 #line 749 "./asn1/ldap/ldap.cnf"
3077   if(ldm_tree && object_identifier_id) {
3078     proto_item_set_text(ldm_tree, "%s %s", "IntermediateResponse", object_identifier_id);
3079     name = oid_resolved_from_string(wmem_packet_scope(), object_identifier_id);
3080     if(name)
3081       proto_item_append_text(ldm_tree, " (%s)", name);
3082   }
3083   if((object_identifier_id != NULL) && oid_has_dissector(object_identifier_id)) {
3084     offset = call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, NULL);
3085   } else {
3086       offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
3087                                        NULL);
3088
3089   }
3090
3091
3092
3093   return offset;
3094 }
3095
3096
3097 static const ber_sequence_t IntermediateResponse_U_sequence[] = {
3098   { &hf_ldap_responseName   , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_ResponseName },
3099   { &hf_ldap_intermediateResponse_responseValue, BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_T_intermediateResponse_responseValue },
3100   { NULL, 0, 0, 0, NULL }
3101 };
3102
3103 static int
3104 dissect_ldap_IntermediateResponse_U(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3105   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3106                                    IntermediateResponse_U_sequence, hf_index, ett_ldap_IntermediateResponse_U);
3107
3108   return offset;
3109 }
3110
3111
3112
3113 static int
3114 dissect_ldap_IntermediateResponse(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3115   offset = dissect_ber_tagged_type(implicit_tag, actx, tree, tvb, offset,
3116                                       hf_index, BER_CLASS_APP, 25, TRUE, dissect_ldap_IntermediateResponse_U);
3117
3118   return offset;
3119 }
3120
3121
3122 static const value_string ldap_ProtocolOp_vals[] = {
3123   {   0, "bindRequest" },
3124   {   1, "bindResponse" },
3125   {   2, "unbindRequest" },
3126   {   3, "searchRequest" },
3127   {   4, "searchResEntry" },
3128   {   5, "searchResDone" },
3129   {  19, "searchResRef" },
3130   {   6, "modifyRequest" },
3131   {   7, "modifyResponse" },
3132   {   8, "addRequest" },
3133   {   9, "addResponse" },
3134   {  10, "delRequest" },
3135   {  11, "delResponse" },
3136   {  12, "modDNRequest" },
3137   {  13, "modDNResponse" },
3138   {  14, "compareRequest" },
3139   {  15, "compareResponse" },
3140   {  16, "abandonRequest" },
3141   {  23, "extendedReq" },
3142   {  24, "extendedResp" },
3143   {  25, "intermediateResponse" },
3144   { 0, NULL }
3145 };
3146
3147 static const ber_choice_t ProtocolOp_choice[] = {
3148   {   0, &hf_ldap_bindRequest    , BER_CLASS_APP, 0, BER_FLAGS_NOOWNTAG, dissect_ldap_BindRequest },
3149   {   1, &hf_ldap_bindResponse   , BER_CLASS_APP, 1, BER_FLAGS_NOOWNTAG, dissect_ldap_BindResponse },
3150   {   2, &hf_ldap_unbindRequest  , BER_CLASS_APP, 2, BER_FLAGS_NOOWNTAG, dissect_ldap_UnbindRequest },
3151   {   3, &hf_ldap_searchRequest  , BER_CLASS_APP, 3, BER_FLAGS_NOOWNTAG, dissect_ldap_SearchRequest },
3152   {   4, &hf_ldap_searchResEntry , BER_CLASS_APP, 4, BER_FLAGS_NOOWNTAG, dissect_ldap_SearchResultEntry },
3153   {   5, &hf_ldap_searchResDone  , BER_CLASS_APP, 5, BER_FLAGS_NOOWNTAG, dissect_ldap_SearchResultDone },
3154   {  19, &hf_ldap_searchResRef   , BER_CLASS_APP, 19, BER_FLAGS_NOOWNTAG, dissect_ldap_SearchResultReference },
3155   {   6, &hf_ldap_modifyRequest  , BER_CLASS_APP, 6, BER_FLAGS_NOOWNTAG, dissect_ldap_ModifyRequest },
3156   {   7, &hf_ldap_modifyResponse , BER_CLASS_APP, 7, BER_FLAGS_NOOWNTAG, dissect_ldap_ModifyResponse },
3157   {   8, &hf_ldap_addRequest     , BER_CLASS_APP, 8, BER_FLAGS_NOOWNTAG, dissect_ldap_AddRequest },
3158   {   9, &hf_ldap_addResponse    , BER_CLASS_APP, 9, BER_FLAGS_NOOWNTAG, dissect_ldap_AddResponse },
3159   {  10, &hf_ldap_delRequest     , BER_CLASS_APP, 10, BER_FLAGS_NOOWNTAG, dissect_ldap_DelRequest },
3160   {  11, &hf_ldap_delResponse    , BER_CLASS_APP, 11, BER_FLAGS_NOOWNTAG, dissect_ldap_DelResponse },
3161   {  12, &hf_ldap_modDNRequest   , BER_CLASS_APP, 12, BER_FLAGS_NOOWNTAG, dissect_ldap_ModifyDNRequest },
3162   {  13, &hf_ldap_modDNResponse  , BER_CLASS_APP, 13, BER_FLAGS_NOOWNTAG, dissect_ldap_ModifyDNResponse },
3163   {  14, &hf_ldap_compareRequest , BER_CLASS_APP, 14, BER_FLAGS_NOOWNTAG, dissect_ldap_CompareRequest },
3164   {  15, &hf_ldap_compareResponse, BER_CLASS_APP, 15, BER_FLAGS_NOOWNTAG, dissect_ldap_CompareResponse },
3165   {  16, &hf_ldap_abandonRequest , BER_CLASS_APP, 16, BER_FLAGS_NOOWNTAG, dissect_ldap_AbandonRequest },
3166   {  23, &hf_ldap_extendedReq    , BER_CLASS_APP, 23, BER_FLAGS_NOOWNTAG, dissect_ldap_ExtendedRequest },
3167   {  24, &hf_ldap_extendedResp   , BER_CLASS_APP, 24, BER_FLAGS_NOOWNTAG, dissect_ldap_ExtendedResponse },
3168   {  25, &hf_ldap_intermediateResponse, BER_CLASS_APP, 25, BER_FLAGS_NOOWNTAG, dissect_ldap_IntermediateResponse },
3169   { 0, NULL, 0, 0, 0, NULL }
3170 };
3171
3172 static int
3173 dissect_ldap_ProtocolOp(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3174 #line 99 "./asn1/ldap/ldap.cnf"
3175
3176   ldap_call_response_t *lcrp;
3177   ldap_conv_info_t *ldap_info = (ldap_conv_info_t *)actx->private_data;
3178   do_protocolop = TRUE;
3179
3180
3181   offset = dissect_ber_choice(actx, tree, tvb, offset,
3182                                  ProtocolOp_choice, hf_index, ett_ldap_ProtocolOp,
3183                                  &ProtocolOp);
3184
3185 #line 105 "./asn1/ldap/ldap.cnf"
3186
3187   if (ProtocolOp == -1) {
3188     return offset;
3189   }
3190
3191   /* ProtocolOp is the index, not the tag so convert it to the tag value */
3192   ProtocolOp = ldap_ProtocolOp_vals[ProtocolOp].value;
3193
3194   lcrp=ldap_match_call_response(tvb, actx->pinfo, tree, MessageID, ProtocolOp, ldap_info);
3195   if(lcrp){
3196     tap_queue_packet(ldap_tap, actx->pinfo, lcrp);
3197   }
3198
3199   /* XXX: the count will not work if the results span multiple TCP packets */
3200
3201   if(ldap_info) { /* only count once */
3202     switch(ProtocolOp) {
3203
3204     case LDAP_RES_SEARCH_ENTRY:
3205       if (!actx->pinfo->fd->flags.visited)
3206         ldap_info->num_results++;
3207
3208       proto_item_append_text(tree, " [%d result%s]",
3209                              ldap_info->num_results, ldap_info->num_results == 1 ? "" : "s");
3210
3211     break;
3212
3213     case LDAP_RES_SEARCH_RESULT:
3214
3215       col_append_fstr(actx->pinfo->cinfo, COL_INFO, " [%d result%s]",
3216                       ldap_info->num_results, ldap_info->num_results == 1 ? "" : "s");
3217
3218       proto_item_append_text(tree, " [%d result%s]",
3219                              ldap_info->num_results, ldap_info->num_results == 1 ? "" : "s");
3220
3221     break;
3222     default:
3223     break;
3224     }
3225   }
3226
3227
3228
3229   return offset;
3230 }
3231
3232
3233
3234 static int
3235 dissect_ldap_ControlType(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3236   offset = dissect_ldap_LDAPOID(implicit_tag, tvb, offset, actx, tree, hf_index);
3237
3238   return offset;
3239 }
3240
3241
3242
3243 static int
3244 dissect_ldap_T_controlValue(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3245 #line 718 "./asn1/ldap/ldap.cnf"
3246   gint8 ber_class;
3247   gboolean pc, ind;
3248   gint32 tag;
3249   guint32 len;
3250
3251   if((object_identifier_id != NULL) && oid_has_dissector(object_identifier_id)) {
3252     /* remove the OCTET STRING encoding */
3253     offset=dissect_ber_identifier(actx->pinfo, NULL, tvb, offset, &ber_class, &pc, &tag);
3254     offset=dissect_ber_length(actx->pinfo, NULL, tvb, offset, &len, &ind);
3255
3256     call_ber_oid_callback(object_identifier_id, tvb, offset, actx->pinfo, tree, NULL);
3257
3258     offset += len;
3259   } else {
3260       offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
3261                                        NULL);
3262
3263   }
3264
3265
3266
3267
3268   return offset;
3269 }
3270
3271
3272 static const ber_sequence_t Control_sequence[] = {
3273   { &hf_ldap_controlType    , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_ControlType },
3274   { &hf_ldap_criticality    , BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_BOOLEAN },
3275   { &hf_ldap_controlValue   , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_T_controlValue },
3276   { NULL, 0, 0, 0, NULL }
3277 };
3278
3279 static int
3280 dissect_ldap_Control(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3281   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3282                                    Control_sequence, hf_index, ett_ldap_Control);
3283
3284   return offset;
3285 }
3286
3287
3288 static const ber_sequence_t Controls_sequence_of[1] = {
3289   { &hf_ldap_Controls_item  , BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_Control },
3290 };
3291
3292 static int
3293 dissect_ldap_Controls(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3294   offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
3295                                       Controls_sequence_of, hf_index, ett_ldap_Controls);
3296
3297   return offset;
3298 }
3299
3300
3301 static const ber_sequence_t LDAPMessage_sequence[] = {
3302   { &hf_ldap_messageID      , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ldap_MessageID },
3303   { &hf_ldap_protocolOp     , BER_CLASS_ANY/*choice*/, -1/*choice*/, BER_FLAGS_NOOWNTAG|BER_FLAGS_NOTCHKTAG, dissect_ldap_ProtocolOp },
3304   { &hf_ldap_controls       , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_Controls },
3305   { NULL, 0, 0, 0, NULL }
3306 };
3307
3308 static int
3309 dissect_ldap_LDAPMessage(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3310   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3311                                    LDAPMessage_sequence, hf_index, ett_ldap_LDAPMessage);
3312
3313   return offset;
3314 }
3315
3316
3317
3318
3319
3320 static int
3321 dissect_ldap_INTEGER(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3322   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
3323                                                 NULL);
3324
3325   return offset;
3326 }
3327
3328
3329 static const ber_sequence_t SearchControlValue_sequence[] = {
3330   { &hf_ldap_size           , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ldap_INTEGER },
3331   { &hf_ldap_cookie         , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_OCTET_STRING },
3332   { NULL, 0, 0, 0, NULL }
3333 };
3334
3335 static int
3336 dissect_ldap_SearchControlValue(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3337   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3338                                    SearchControlValue_sequence, hf_index, ett_ldap_SearchControlValue);
3339
3340   return offset;
3341 }
3342
3343
3344 static const ber_sequence_t SortKeyList_item_sequence[] = {
3345   { &hf_ldap_attributeType  , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_AttributeDescription },
3346   { &hf_ldap_orderingRule   , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_MatchingRuleId },
3347   { &hf_ldap_reverseOrder   , BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_BOOLEAN },
3348   { NULL, 0, 0, 0, NULL }
3349 };
3350
3351 static int
3352 dissect_ldap_SortKeyList_item(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3353   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3354                                    SortKeyList_item_sequence, hf_index, ett_ldap_SortKeyList_item);
3355
3356   return offset;
3357 }
3358
3359
3360 static const ber_sequence_t SortKeyList_sequence_of[1] = {
3361   { &hf_ldap_SortKeyList_item, BER_CLASS_UNI, BER_UNI_TAG_SEQUENCE, BER_FLAGS_NOOWNTAG, dissect_ldap_SortKeyList_item },
3362 };
3363
3364 static int
3365 dissect_ldap_SortKeyList(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3366   offset = dissect_ber_sequence_of(implicit_tag, actx, tree, tvb, offset,
3367                                       SortKeyList_sequence_of, hf_index, ett_ldap_SortKeyList);
3368
3369   return offset;
3370 }
3371
3372
3373 static const value_string ldap_T_sortResult_vals[] = {
3374   {   0, "success" },
3375   {   1, "operationsError" },
3376   {   3, "timeLimitExceeded" },
3377   {   8, "strongAuthRequired" },
3378   {  11, "adminLimitExceeded" },
3379   {  16, "noSuchAttribute" },
3380   {  18, "inappropriateMatching" },
3381   {  50, "insufficientAccessRights" },
3382   {  51, "busy" },
3383   {  53, "unwillingToPerform" },
3384   {  80, "other" },
3385   { 0, NULL }
3386 };
3387
3388
3389 static int
3390 dissect_ldap_T_sortResult(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3391   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
3392                                   NULL);
3393
3394   return offset;
3395 }
3396
3397
3398 static const ber_sequence_t SortResult_sequence[] = {
3399   { &hf_ldap_sortResult     , BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_ldap_T_sortResult },
3400   { &hf_ldap_attributeType  , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_AttributeDescription },
3401   { NULL, 0, 0, 0, NULL }
3402 };
3403
3404 static int
3405 dissect_ldap_SortResult(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3406   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3407                                    SortResult_sequence, hf_index, ett_ldap_SortResult);
3408
3409   return offset;
3410 }
3411
3412
3413
3414 static int
3415 dissect_ldap_DirSyncFlags(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3416 #line 762 "./asn1/ldap/ldap.cnf"
3417   gint8 ber_class;
3418   gboolean pc;
3419   gint32 tag;
3420   guint32 len;
3421   gint32 val;
3422
3423   int otheroffset = offset;
3424   if(!implicit_tag){
3425     dissect_ber_identifier(actx->pinfo, tree, tvb, otheroffset, &ber_class, &pc, &tag);
3426     otheroffset=dissect_ber_length(actx->pinfo, tree, tvb, offset, &len, NULL);
3427   } else {
3428     gint32 remaining=tvb_reported_length_remaining(tvb, offset);
3429     len=remaining>0 ? remaining : 0;
3430   }
3431
3432   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, -1, &val);
3433
3434   if (val >0) {
3435     const int *flags[] = {
3436       &hf_ldap_object_security_flag,
3437       &hf_ldap_ancestor_first_flag,
3438       &hf_ldap_public_data_only_flag,
3439       &hf_ldap_incremental_value_flag,
3440       NULL
3441     };
3442
3443     proto_tree_add_bitmask_value_with_flags(tree, tvb, otheroffset+1, hf_index,
3444                                             ett_ldap_DirSyncFlagsSubEntry, flags, val, BMT_NO_APPEND);
3445   } else {
3446     proto_tree_add_uint(tree, hf_index, tvb, otheroffset+len, len, 0);
3447   }
3448
3449
3450
3451   return offset;
3452 }
3453
3454
3455 static const ber_sequence_t DirSyncControlValue_sequence[] = {
3456   { &hf_ldap_flags          , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ldap_DirSyncFlags },
3457   { &hf_ldap_maxBytes       , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ldap_INTEGER },
3458   { &hf_ldap_cookie         , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_OCTET_STRING },
3459   { NULL, 0, 0, 0, NULL }
3460 };
3461
3462 static int
3463 dissect_ldap_DirSyncControlValue(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3464   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3465                                    DirSyncControlValue_sequence, hf_index, ett_ldap_DirSyncControlValue);
3466
3467   return offset;
3468 }
3469
3470
3471 static const ber_sequence_t PasswdModifyRequestValue_sequence[] = {
3472   { &hf_ldap_userIdentity   , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_OCTET_STRING },
3473   { &hf_ldap_oldPasswd      , BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_OCTET_STRING },
3474   { &hf_ldap_newPasswd      , BER_CLASS_CON, 2, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_OCTET_STRING },
3475   { NULL, 0, 0, 0, NULL }
3476 };
3477
3478 static int
3479 dissect_ldap_PasswdModifyRequestValue(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3480   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3481                                    PasswdModifyRequestValue_sequence, hf_index, ett_ldap_PasswdModifyRequestValue);
3482
3483   return offset;
3484 }
3485
3486
3487 static const ber_sequence_t CancelRequestValue_sequence[] = {
3488   { &hf_ldap_cancelID       , BER_CLASS_UNI, BER_UNI_TAG_INTEGER, BER_FLAGS_NOOWNTAG, dissect_ldap_MessageID },
3489   { NULL, 0, 0, 0, NULL }
3490 };
3491
3492 static int
3493 dissect_ldap_CancelRequestValue(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3494   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3495                                    CancelRequestValue_sequence, hf_index, ett_ldap_CancelRequestValue);
3496
3497   return offset;
3498 }
3499
3500
3501 static const value_string ldap_T_mode_vals[] = {
3502   {   1, "refreshOnly" },
3503   {   3, "refreshAndPersist" },
3504   { 0, NULL }
3505 };
3506
3507
3508 static int
3509 dissect_ldap_T_mode(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3510   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
3511                                   NULL);
3512
3513   return offset;
3514 }
3515
3516
3517 static const ber_sequence_t SyncRequestValue_sequence[] = {
3518   { &hf_ldap_mode           , BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_ldap_T_mode },
3519   { &hf_ldap_cookie         , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_OCTET_STRING },
3520   { &hf_ldap_reloadHint     , BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_BOOLEAN },
3521   { NULL, 0, 0, 0, NULL }
3522 };
3523
3524 static int
3525 dissect_ldap_SyncRequestValue(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3526   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3527                                    SyncRequestValue_sequence, hf_index, ett_ldap_SyncRequestValue);
3528
3529   return offset;
3530 }
3531
3532
3533 static const value_string ldap_T_state_vals[] = {
3534   {   0, "present" },
3535   {   1, "add" },
3536   {   2, "modify" },
3537   {   3, "delete" },
3538   { 0, NULL }
3539 };
3540
3541
3542 static int
3543 dissect_ldap_T_state(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3544   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
3545                                   NULL);
3546
3547   return offset;
3548 }
3549
3550
3551
3552 static int
3553 dissect_ldap_SyncUUID(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3554   offset = dissect_ber_octet_string(implicit_tag, actx, tree, tvb, offset, hf_index,
3555                                        NULL);
3556
3557   return offset;
3558 }
3559
3560
3561 static const ber_sequence_t SyncStateValue_sequence[] = {
3562   { &hf_ldap_state          , BER_CLASS_UNI, BER_UNI_TAG_ENUMERATED, BER_FLAGS_NOOWNTAG, dissect_ldap_T_state },
3563   { &hf_ldap_entryUUID      , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_SyncUUID },
3564   { &hf_ldap_cookie         , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_OCTET_STRING },
3565   { NULL, 0, 0, 0, NULL }
3566 };
3567
3568 static int
3569 dissect_ldap_SyncStateValue(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3570   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3571                                    SyncStateValue_sequence, hf_index, ett_ldap_SyncStateValue);
3572
3573   return offset;
3574 }
3575
3576
3577 static const ber_sequence_t SyncDoneValue_sequence[] = {
3578   { &hf_ldap_cookie         , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_OCTET_STRING },
3579   { &hf_ldap_refreshDeletes , BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_BOOLEAN },
3580   { NULL, 0, 0, 0, NULL }
3581 };
3582
3583 static int
3584 dissect_ldap_SyncDoneValue(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3585   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3586                                    SyncDoneValue_sequence, hf_index, ett_ldap_SyncDoneValue);
3587
3588   return offset;
3589 }
3590
3591
3592 static const ber_sequence_t T_refreshDelete_sequence[] = {
3593   { &hf_ldap_cookie         , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_OCTET_STRING },
3594   { &hf_ldap_refreshDone    , BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_BOOLEAN },
3595   { NULL, 0, 0, 0, NULL }
3596 };
3597
3598 static int
3599 dissect_ldap_T_refreshDelete(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3600   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3601                                    T_refreshDelete_sequence, hf_index, ett_ldap_T_refreshDelete);
3602
3603   return offset;
3604 }
3605
3606
3607 static const ber_sequence_t T_refreshPresent_sequence[] = {
3608   { &hf_ldap_cookie         , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_OCTET_STRING },
3609   { &hf_ldap_refreshDone    , BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_BOOLEAN },
3610   { NULL, 0, 0, 0, NULL }
3611 };
3612
3613 static int
3614 dissect_ldap_T_refreshPresent(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3615   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3616                                    T_refreshPresent_sequence, hf_index, ett_ldap_T_refreshPresent);
3617
3618   return offset;
3619 }
3620
3621
3622 static const ber_sequence_t SET_OF_SyncUUID_set_of[1] = {
3623   { &hf_ldap_syncUUIDs_item , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_NOOWNTAG, dissect_ldap_SyncUUID },
3624 };
3625
3626 static int
3627 dissect_ldap_SET_OF_SyncUUID(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3628   offset = dissect_ber_set_of(implicit_tag, actx, tree, tvb, offset,
3629                                  SET_OF_SyncUUID_set_of, hf_index, ett_ldap_SET_OF_SyncUUID);
3630
3631   return offset;
3632 }
3633
3634
3635 static const ber_sequence_t T_syncIdSet_sequence[] = {
3636   { &hf_ldap_cookie         , BER_CLASS_UNI, BER_UNI_TAG_OCTETSTRING, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_OCTET_STRING },
3637   { &hf_ldap_refreshDeletes , BER_CLASS_UNI, BER_UNI_TAG_BOOLEAN, BER_FLAGS_OPTIONAL|BER_FLAGS_NOOWNTAG, dissect_ldap_BOOLEAN },
3638   { &hf_ldap_syncUUIDs      , BER_CLASS_UNI, BER_UNI_TAG_SET, BER_FLAGS_NOOWNTAG, dissect_ldap_SET_OF_SyncUUID },
3639   { NULL, 0, 0, 0, NULL }
3640 };
3641
3642 static int
3643 dissect_ldap_T_syncIdSet(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3644   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3645                                    T_syncIdSet_sequence, hf_index, ett_ldap_T_syncIdSet);
3646
3647   return offset;
3648 }
3649
3650
3651 static const value_string ldap_SyncInfoValue_vals[] = {
3652   {   0, "newcookie" },
3653   {   1, "refreshDelete" },
3654   {   2, "refreshPresent" },
3655   {   3, "syncIdSet" },
3656   { 0, NULL }
3657 };
3658
3659 static const ber_choice_t SyncInfoValue_choice[] = {
3660   {   0, &hf_ldap_newcookie      , BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_ldap_OCTET_STRING },
3661   {   1, &hf_ldap_refreshDelete  , BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_ldap_T_refreshDelete },
3662   {   2, &hf_ldap_refreshPresent , BER_CLASS_CON, 2, BER_FLAGS_IMPLTAG, dissect_ldap_T_refreshPresent },
3663   {   3, &hf_ldap_syncIdSet      , BER_CLASS_CON, 3, BER_FLAGS_IMPLTAG, dissect_ldap_T_syncIdSet },
3664   { 0, NULL, 0, 0, 0, NULL }
3665 };
3666
3667 static int
3668 dissect_ldap_SyncInfoValue(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3669   offset = dissect_ber_choice(actx, tree, tvb, offset,
3670                                  SyncInfoValue_choice, hf_index, ett_ldap_SyncInfoValue,
3671                                  NULL);
3672
3673   return offset;
3674 }
3675
3676
3677 static const value_string ldap_T_warning_vals[] = {
3678   {   0, "timeBeforeExpiration" },
3679   {   1, "graceAuthNsRemaining" },
3680   { 0, NULL }
3681 };
3682
3683 static const ber_choice_t T_warning_choice[] = {
3684   {   0, &hf_ldap_timeBeforeExpiration, BER_CLASS_CON, 0, BER_FLAGS_IMPLTAG, dissect_ldap_INTEGER_0_maxInt },
3685   {   1, &hf_ldap_graceAuthNsRemaining, BER_CLASS_CON, 1, BER_FLAGS_IMPLTAG, dissect_ldap_INTEGER_0_maxInt },
3686   { 0, NULL, 0, 0, 0, NULL }
3687 };
3688
3689 static int
3690 dissect_ldap_T_warning(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3691   offset = dissect_ber_choice(actx, tree, tvb, offset,
3692                                  T_warning_choice, hf_index, ett_ldap_T_warning,
3693                                  NULL);
3694
3695   return offset;
3696 }
3697
3698
3699 static const value_string ldap_T_error_vals[] = {
3700   {   0, "passwordExpired" },
3701   {   1, "accountLocked" },
3702   {   2, "changeAfterReset" },
3703   {   3, "passwordModNotAllowed" },
3704   {   4, "mustSupplyOldPassword" },
3705   {   5, "insufficientPasswordQuality" },
3706   {   6, "passwordTooShort" },
3707   {   7, "passwordTooYoung" },
3708   {   8, "passwordInHistory" },
3709   { 0, NULL }
3710 };
3711
3712
3713 static int
3714 dissect_ldap_T_error(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3715   offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index,
3716                                   NULL);
3717
3718   return offset;
3719 }
3720
3721
3722 static const ber_sequence_t PasswordPolicyResponseValue_sequence[] = {
3723   { &hf_ldap_warning        , BER_CLASS_CON, 0, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_T_warning },
3724   { &hf_ldap_error          , BER_CLASS_CON, 1, BER_FLAGS_OPTIONAL|BER_FLAGS_IMPLTAG, dissect_ldap_T_error },
3725   { NULL, 0, 0, 0, NULL }
3726 };
3727
3728 static int
3729 dissect_ldap_PasswordPolicyResponseValue(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
3730   offset = dissect_ber_sequence(implicit_tag, actx, tree, tvb, offset,
3731                                    PasswordPolicyResponseValue_sequence, hf_index, ett_ldap_PasswordPolicyResponseValue);
3732
3733   return offset;
3734 }
3735
3736 /*--- PDUs ---*/
3737
3738 static int dissect_SearchControlValue_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
3739   int offset = 0;
3740   asn1_ctx_t asn1_ctx;
3741   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
3742   offset = dissect_ldap_SearchControlValue(FALSE, tvb, offset, &asn1_ctx, tree, hf_ldap_SearchControlValue_PDU);
3743   return offset;
3744 }
3745 static int dissect_SortKeyList_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
3746   int offset = 0;
3747   asn1_ctx_t asn1_ctx;
3748   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
3749   offset = dissect_ldap_SortKeyList(FALSE, tvb, offset, &asn1_ctx, tree, hf_ldap_SortKeyList_PDU);
3750   return offset;
3751 }
3752 static int dissect_SortResult_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
3753   int offset = 0;
3754   asn1_ctx_t asn1_ctx;
3755   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
3756   offset = dissect_ldap_SortResult(FALSE, tvb, offset, &asn1_ctx, tree, hf_ldap_SortResult_PDU);
3757   return offset;
3758 }
3759 static int dissect_DirSyncControlValue_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
3760   int offset = 0;
3761   asn1_ctx_t asn1_ctx;
3762   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
3763   offset = dissect_ldap_DirSyncControlValue(FALSE, tvb, offset, &asn1_ctx, tree, hf_ldap_DirSyncControlValue_PDU);
3764   return offset;
3765 }
3766 static int dissect_PasswdModifyRequestValue_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
3767   int offset = 0;
3768   asn1_ctx_t asn1_ctx;
3769   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
3770   offset = dissect_ldap_PasswdModifyRequestValue(FALSE, tvb, offset, &asn1_ctx, tree, hf_ldap_PasswdModifyRequestValue_PDU);
3771   return offset;
3772 }
3773 static int dissect_CancelRequestValue_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
3774   int offset = 0;
3775   asn1_ctx_t asn1_ctx;
3776   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
3777   offset = dissect_ldap_CancelRequestValue(FALSE, tvb, offset, &asn1_ctx, tree, hf_ldap_CancelRequestValue_PDU);
3778   return offset;
3779 }
3780 static int dissect_SyncRequestValue_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
3781   int offset = 0;
3782   asn1_ctx_t asn1_ctx;
3783   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
3784   offset = dissect_ldap_SyncRequestValue(FALSE, tvb, offset, &asn1_ctx, tree, hf_ldap_SyncRequestValue_PDU);
3785   return offset;
3786 }
3787 static int dissect_SyncStateValue_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
3788   int offset = 0;
3789   asn1_ctx_t asn1_ctx;
3790   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
3791   offset = dissect_ldap_SyncStateValue(FALSE, tvb, offset, &asn1_ctx, tree, hf_ldap_SyncStateValue_PDU);
3792   return offset;
3793 }
3794 static int dissect_SyncDoneValue_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
3795   int offset = 0;
3796   asn1_ctx_t asn1_ctx;
3797   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
3798   offset = dissect_ldap_SyncDoneValue(FALSE, tvb, offset, &asn1_ctx, tree, hf_ldap_SyncDoneValue_PDU);
3799   return offset;
3800 }
3801 static int dissect_SyncInfoValue_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
3802   int offset = 0;
3803   asn1_ctx_t asn1_ctx;
3804   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
3805   offset = dissect_ldap_SyncInfoValue(FALSE, tvb, offset, &asn1_ctx, tree, hf_ldap_SyncInfoValue_PDU);
3806   return offset;
3807 }
3808 static int dissect_PasswordPolicyResponseValue_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_, void *data _U_) {
3809   int offset = 0;
3810   asn1_ctx_t asn1_ctx;
3811   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
3812   offset = dissect_ldap_PasswordPolicyResponseValue(FALSE, tvb, offset, &asn1_ctx, tree, hf_ldap_PasswordPolicyResponseValue_PDU);
3813   return offset;
3814 }
3815
3816
3817 /*--- End of included file: packet-ldap-fn.c ---*/
3818 #line 901 "./asn1/ldap/packet-ldap-template.c"
3819 static int dissect_LDAPMessage_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, ldap_conv_info_t *ldap_info) {
3820
3821   int offset = 0;
3822   asn1_ctx_t asn1_ctx;
3823   asn1_ctx_init(&asn1_ctx, ASN1_ENC_BER, TRUE, pinfo);
3824
3825   asn1_ctx.private_data = ldap_info;
3826   offset = dissect_ldap_LDAPMessage(FALSE, tvb, offset, &asn1_ctx, tree, hf_ldap_LDAPMessage_PDU);
3827   return offset;
3828 }
3829
3830 static void
3831 dissect_ldap_payload(tvbuff_t *tvb, packet_info *pinfo,
3832                      proto_tree *tree, ldap_conv_info_t *ldap_info,
3833                      gboolean is_mscldap)
3834 {
3835   int offset = 0;
3836   guint length_remaining;
3837   guint msg_len = 0;
3838   int messageOffset = 0;
3839   guint headerLength = 0;
3840   guint length = 0;
3841   tvbuff_t *msg_tvb = NULL;
3842   gint8 ber_class;
3843   gboolean pc, ind = 0;
3844   gint32 ber_tag;
3845
3846   attributedesc_string=NULL;
3847
3848
3849 one_more_pdu:
3850
3851     length_remaining = tvb_ensure_captured_length_remaining(tvb, offset);
3852
3853     if (length_remaining < 6) return;
3854
3855     /*
3856      * OK, try to read the "Sequence Of" header; this gets the total
3857      * length of the LDAP message.
3858      */
3859         messageOffset = get_ber_identifier(tvb, offset, &ber_class, &pc, &ber_tag);
3860         messageOffset = get_ber_length(tvb, messageOffset, &msg_len, &ind);
3861
3862     /* sanity check */
3863     if((msg_len<4) || (msg_len>10000000)) return;
3864
3865     if ( (ber_class==BER_CLASS_UNI) && (ber_tag==BER_UNI_TAG_SEQUENCE) ) {
3866         /*
3867          * Add the length of the "Sequence Of" header to the message
3868          * length.
3869          */
3870         headerLength = messageOffset - offset;
3871         msg_len += headerLength;
3872         if (msg_len < headerLength) {
3873             /*
3874              * The message length was probably so large that the total length
3875              * overflowed.
3876              *
3877              * Report this as an error.
3878              */
3879             show_reported_bounds_error(tvb, pinfo, tree);
3880             return;
3881         }
3882     } else {
3883         /*
3884          * We couldn't parse the header; just make it the amount of data
3885          * remaining in the tvbuff, so we'll give up on this segment
3886          * after attempting to parse the message - there's nothing more
3887          * we can do.  "dissect_ldap_message()" will display the error.
3888          */
3889         msg_len = length_remaining;
3890     }
3891
3892     /*
3893      * Construct a tvbuff containing the amount of the payload we have
3894      * available.  Make its reported length the amount of data in the
3895      * LDAP message.
3896      *
3897      * XXX - if reassembly isn't enabled. the subdissector will throw a
3898      * BoundsError exception, rather than a ReportedBoundsError exception.
3899      * We really want a tvbuff where the length is "length", the reported
3900      * length is "plen", and the "if the snapshot length were infinite"
3901      * length is the minimum of the reported length of the tvbuff handed
3902      * to us and "plen", with a new type of exception thrown if the offset
3903      * is within the reported length but beyond that third length, with
3904      * that exception getting the "Unreassembled Packet" error.
3905      */
3906     length = length_remaining;
3907     if (length > msg_len) length = msg_len;
3908     msg_tvb = tvb_new_subset_length_caplen(tvb, offset, length, msg_len);
3909
3910     /*
3911      * Now dissect the LDAP message.
3912      */
3913     ldap_info->is_mscldap = is_mscldap;
3914     dissect_LDAPMessage_PDU(msg_tvb, pinfo, tree, ldap_info);
3915
3916     offset += msg_len;
3917
3918     /* If this was a sasl blob there might be another PDU following in the
3919      * same blob
3920      */
3921     if(tvb_reported_length_remaining(tvb, offset)>=6){
3922         tvb = tvb_new_subset_remaining(tvb, offset);
3923         offset = 0;
3924
3925         goto one_more_pdu;
3926     }
3927
3928 }
3929
3930 static void
3931 ldap_frame_end(void)
3932 {
3933   ldap_found_in_frame = FALSE;
3934   attr_type = NULL;
3935   ldapvalue_string = NULL;
3936 /* ? */
3937   attributedesc_string = NULL;
3938   Filter_string = NULL;
3939   and_filter_string = NULL;
3940   object_identifier_id = NULL;
3941   or_filter_string = NULL;
3942
3943   substring_item_any = NULL;
3944   substring_item_final = NULL;
3945   substring_item_init = NULL;
3946   substring_value = NULL;
3947
3948   ldm_tree = NULL;
3949
3950   Filter_elements = 0;
3951   Filter_length = 0;
3952   do_protocolop = FALSE;
3953   result = 0;
3954
3955 /* seems to be ok, but reset just in case */
3956   matching_rule_string = NULL;
3957 }
3958
3959 static void
3960   dissect_ldap_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean is_mscldap)
3961 {
3962   int offset = 0;
3963   conversation_t *conversation;
3964   gboolean doing_sasl_security = FALSE;
3965   guint length_remaining;
3966   ldap_conv_info_t *ldap_info = NULL;
3967   proto_item *ldap_item = NULL;
3968   proto_tree *ldap_tree = NULL;
3969
3970   ldm_tree = NULL;
3971
3972   conversation = find_or_create_conversation(pinfo);
3973
3974   /*
3975   * Do we already have a type and mechanism?
3976   */
3977   ldap_info = (ldap_conv_info_t *)conversation_get_proto_data(conversation, proto_ldap);
3978   if (ldap_info == NULL) {
3979     /* No.  Attach that information to the conversation, and add
3980     * it to the list of information structures.
3981     */
3982     ldap_info = wmem_new0(wmem_file_scope(), ldap_conv_info_t);
3983     ldap_info->matched=wmem_map_new(wmem_file_scope(), ldap_info_hash_matched, ldap_info_equal_matched);
3984     ldap_info->unmatched=wmem_map_new(wmem_file_scope(), ldap_info_hash_unmatched, ldap_info_equal_unmatched);
3985
3986     conversation_add_proto_data(conversation, proto_ldap, ldap_info);
3987   }
3988
3989   switch (ldap_info->auth_type) {
3990   case LDAP_AUTH_SASL:
3991     /*
3992     * It's SASL; are we using a security layer?
3993     */
3994     if (ldap_info->first_auth_frame != 0 &&
3995       pinfo->num >= ldap_info->first_auth_frame) {
3996         doing_sasl_security = TRUE; /* yes */
3997     }
3998   }
3999
4000   length_remaining = tvb_ensure_captured_length_remaining(tvb, offset);
4001
4002   /* It might still be a packet containing a SASL security layer
4003   * but it's just that we never saw the BIND packet.
4004   * check if it looks like it could be a SASL blob here
4005   * and in that case just assume it is GSS-SPNEGO
4006   */
4007   if(!doing_sasl_security && (tvb_bytes_exist(tvb, offset, 5))
4008     &&(tvb_get_ntohl(tvb, offset)<=(guint)(tvb_reported_length_remaining(tvb, offset)-4))
4009     &&(tvb_get_guint8(tvb, offset+4)==0x60) ){
4010       ldap_info->auth_type=LDAP_AUTH_SASL;
4011       ldap_info->first_auth_frame=pinfo->num;
4012       ldap_info->auth_mech=wmem_strdup(wmem_file_scope(), "GSS-SPNEGO");
4013       doing_sasl_security=TRUE;
4014   }
4015
4016   /*
4017   * This is the first PDU, set the Protocol column and clear the
4018   * Info column.
4019   */
4020   col_set_str(pinfo->cinfo, COL_PROTOCOL, pinfo->current_proto);
4021
4022   if(ldap_found_in_frame) {
4023     /* we have already dissected an ldap PDU in this frame - add a separator and set a fence */
4024     col_append_str(pinfo->cinfo, COL_INFO, " | ");
4025     col_set_fence(pinfo->cinfo, COL_INFO);
4026   } else {
4027     col_clear(pinfo->cinfo, COL_INFO);
4028     register_frame_end_routine (pinfo, ldap_frame_end);
4029     ldap_found_in_frame = TRUE;
4030   }
4031
4032   ldap_item = proto_tree_add_item(tree, is_mscldap?proto_cldap:proto_ldap, tvb, 0, -1, ENC_NA);
4033   ldap_tree = proto_item_add_subtree(ldap_item, ett_ldap);
4034
4035   /*
4036   * Might we be doing a SASL security layer and, if so, *are* we doing
4037   * one?
4038   *
4039   * Just because we've seen a bind reply for SASL, that doesn't mean
4040   * that we're using a SASL security layer; I've seen captures in
4041   * which some SASL negotiations lead to a security layer being used
4042   * and other negotiations don't, and it's not obvious what's different
4043   * in the two negotiations.  Therefore, we assume that if the first
4044   * byte is 0, it's a length for a SASL security layer (that way, we
4045   * never reassemble more than 16 megabytes, protecting us from
4046   * chewing up *too* much memory), and otherwise that it's an LDAP
4047   * message (actually, if it's an LDAP message it should begin with 0x30,
4048   * but we want to parse garbage as LDAP messages rather than really
4049   * huge lengths).
4050   */
4051
4052   if (doing_sasl_security && tvb_get_guint8(tvb, offset) == 0) {
4053     proto_tree *sasl_tree;
4054     tvbuff_t *sasl_tvb;
4055     guint sasl_len, sasl_msg_len, length;
4056     /*
4057     * Yes.  The frame begins with a 4-byte big-endian length.
4058     * And we know we have at least 6 bytes
4059     */
4060
4061     /*
4062     * Get the SASL length, which is the length of data in the buffer
4063     * following the length (i.e., it's 4 less than the total length).
4064     *
4065     * XXX - do we need to reassemble buffers?  For now, we
4066     * assume that each LDAP message is entirely contained within
4067     * a buffer.
4068     */
4069     sasl_len = tvb_get_ntohl(tvb, offset);
4070     sasl_msg_len = sasl_len + 4;
4071     if (sasl_msg_len < 4) {
4072       /*
4073       * The message length was probably so large that the total length
4074       * overflowed.
4075       *
4076       * Report this as an error.
4077       */
4078       show_reported_bounds_error(tvb, pinfo, tree);
4079       return;
4080     }
4081
4082     /*
4083     * Construct a tvbuff containing the amount of the payload we have
4084     * available.  Make its reported length the amount of data in the PDU.
4085     *
4086     * XXX - if reassembly isn't enabled. the subdissector will throw a
4087     * BoundsError exception, rather than a ReportedBoundsError exception.
4088     * We really want a tvbuff where the length is "length", the reported
4089     * length is "plen", and the "if the snapshot length were infinite"
4090     * length is the minimum of the reported length of the tvbuff handed
4091     * to us and "plen", with a new type of exception thrown if the offset
4092     * is within the reported length but beyond that third length, with
4093     * that exception getting the "Unreassembled Packet" error.
4094     */
4095     length = length_remaining;
4096     if (length > sasl_msg_len) length = sasl_msg_len;
4097     sasl_tvb = tvb_new_subset_length_caplen(tvb, offset, length, sasl_msg_len);
4098
4099     proto_tree_add_uint(ldap_tree, hf_ldap_sasl_buffer_length, sasl_tvb, 0, 4, sasl_len);
4100
4101     sasl_tree = proto_tree_add_subtree(ldap_tree, sasl_tvb, 0, sasl_msg_len, ett_ldap_sasl_blob, NULL, "SASL Buffer");
4102
4103     if (ldap_info->auth_mech != NULL &&
4104       ((strcmp(ldap_info->auth_mech, "GSS-SPNEGO") == 0) ||
4105       /* auth_mech may have been set from the bind */
4106       (strcmp(ldap_info->auth_mech, "GSSAPI") == 0))) {
4107         tvbuff_t *gssapi_tvb, *plain_tvb = NULL, *decr_tvb= NULL;
4108         int ver_len;
4109         int tmp_length;
4110         gssapi_encrypt_info_t gssapi_encrypt;
4111
4112         /*
4113         * This is GSS-API (using SPNEGO, but we should be done with
4114         * the negotiation by now).
4115         *
4116         * Dissect the GSS_Wrap() token; it'll return the length of
4117         * the token, from which we compute the offset in the tvbuff at
4118         * which the plaintext data, i.e. the LDAP message, begins.
4119         */
4120         tmp_length = tvb_reported_length_remaining(sasl_tvb, 4);
4121         if ((guint)tmp_length > sasl_len)
4122           tmp_length = sasl_len;
4123         gssapi_tvb = tvb_new_subset_length_caplen(sasl_tvb, 4, tmp_length, sasl_len);
4124
4125         /* Attempt decryption of the GSSAPI wrapped data if possible */
4126         gssapi_encrypt.gssapi_data_encrypted = FALSE;
4127         gssapi_encrypt.decrypt_gssapi_tvb=DECRYPT_GSSAPI_NORMAL;
4128         gssapi_encrypt.gssapi_wrap_tvb=NULL;
4129         gssapi_encrypt.gssapi_encrypted_tvb=NULL;
4130         gssapi_encrypt.gssapi_decrypted_tvb=NULL;
4131         ver_len = call_dissector_with_data(gssapi_wrap_handle, gssapi_tvb, pinfo, sasl_tree, &gssapi_encrypt);
4132         /* if we could unwrap, do a tvb shuffle */
4133         if(gssapi_encrypt.gssapi_decrypted_tvb){
4134           decr_tvb=gssapi_encrypt.gssapi_decrypted_tvb;
4135         } else if (gssapi_encrypt.gssapi_wrap_tvb) {
4136           plain_tvb=gssapi_encrypt.gssapi_wrap_tvb;
4137         }
4138
4139         /*
4140         * if len is 0 it probably mean that we got a PDU that is not
4141         * aligned to the start of the segment.
4142         */
4143         if(ver_len==0){
4144           return;
4145         }
4146
4147         /*
4148         * if we don't have unwrapped data,
4149         * see if the wrapping involved encryption of the
4150         * data; if not, just use the plaintext data.
4151         */
4152         if (!decr_tvb && !plain_tvb) {
4153           if(!gssapi_encrypt.gssapi_data_encrypted){
4154             plain_tvb = tvb_new_subset_remaining(gssapi_tvb,  ver_len);
4155           }
4156         }
4157
4158         if (decr_tvb) {
4159           proto_tree *enc_tree = NULL;
4160           guint decr_len = tvb_reported_length(decr_tvb);
4161
4162           /*
4163           * The LDAP message was encrypted in the packet, and has
4164           * been decrypted; dissect the decrypted LDAP message.
4165           */
4166           col_set_str(pinfo->cinfo, COL_INFO, "SASL GSS-API Privacy (decrypted): ");
4167
4168           if (sasl_tree) {
4169             enc_tree = proto_tree_add_subtree_format(sasl_tree, decr_tvb, 0, -1,
4170               ett_ldap_payload, NULL, "GSS-API Encrypted payload (%d byte%s)",
4171               decr_len, plurality(decr_len, "", "s"));
4172           }
4173           dissect_ldap_payload(decr_tvb, pinfo, enc_tree, ldap_info, is_mscldap);
4174         } else if (plain_tvb) {
4175           proto_tree *plain_tree = NULL;
4176           guint plain_len = tvb_reported_length(plain_tvb);
4177
4178           /*
4179           * The LDAP message wasn't encrypted in the packet;
4180           * dissect the plain LDAP message.
4181           */
4182           col_set_str(pinfo->cinfo, COL_INFO, "SASL GSS-API Integrity: ");
4183
4184           if (sasl_tree) {
4185             plain_tree = proto_tree_add_subtree_format(sasl_tree, plain_tvb, 0, -1,
4186               ett_ldap_payload, NULL, "GSS-API payload (%d byte%s)",
4187               plain_len, plurality(plain_len, "", "s"));
4188           }
4189
4190           dissect_ldap_payload(plain_tvb, pinfo, plain_tree, ldap_info, is_mscldap);
4191         } else {
4192           /*
4193           * The LDAP message was encrypted in the packet, and was
4194           * not decrypted; just show it as encrypted data.
4195           */
4196           col_add_fstr(pinfo->cinfo, COL_INFO, "SASL GSS-API Privacy: payload (%d byte%s)",
4197             sasl_len - ver_len,
4198             plurality(sasl_len - ver_len, "", "s"));
4199
4200           proto_tree_add_item(sasl_tree, hf_ldap_gssapi_encrypted_payload, gssapi_tvb, ver_len, -1, ENC_NA);
4201         }
4202     }
4203   } else {
4204     /* plain LDAP, so dissect the payload */
4205     dissect_ldap_payload(tvb, pinfo, ldap_tree, ldap_info, is_mscldap);
4206   }
4207 }
4208
4209 /*
4210  * prepend_dot is no longer used, but is being left in place in order to
4211  * maintain ABI compatibility.
4212  */
4213 int dissect_mscldap_string(tvbuff_t *tvb, int offset, char *str, int max_len, gboolean prepend_dot _U_)
4214 {
4215   int compr_len;
4216   const guchar *name;
4217   guint name_len;
4218
4219   /* The name data MUST start at offset 0 of the tvb */
4220   compr_len = get_dns_name(tvb, offset, max_len, 0, &name, &name_len);
4221   g_strlcpy(str, name, max_len);
4222   return offset + compr_len;
4223 }
4224
4225
4226 /* These are the cldap DC flags
4227    http://msdn.microsoft.com/en-us/library/cc201036.aspx
4228  */
4229 static const true_false_string tfs_ads_pdc = {
4230   "This is a PDC",
4231   "This is NOT a pdc"
4232 };
4233 static const true_false_string tfs_ads_gc = {
4234   "This is a GLOBAL CATALOGUE of forest",
4235   "This is NOT a global catalog of forest"
4236 };
4237 static const true_false_string tfs_ads_ldap = {
4238   "This is an LDAP server",
4239   "This is NOT an ldap server"
4240 };
4241 static const true_false_string tfs_ads_ds = {
4242   "This dc supports DS",
4243   "This dc does NOT support ds"
4244 };
4245 static const true_false_string tfs_ads_kdc = {
4246   "This is a KDC (kerberos)",
4247   "This is NOT a kdc (kerberos)"
4248 };
4249 static const true_false_string tfs_ads_timeserv = {
4250   "This dc is running TIME SERVICES (ntp)",
4251   "This dc is NOT running time services (ntp)"
4252 };
4253 static const true_false_string tfs_ads_closest = {
4254   "This server is in the same site as the client",
4255   "This server is NOT in the same site as the client"
4256 };
4257 static const true_false_string tfs_ads_writable = {
4258   "This dc is WRITABLE",
4259   "This dc is NOT writable"
4260 };
4261 static const true_false_string tfs_ads_good_timeserv = {
4262   "This dc has a GOOD TIME SERVICE (i.e. hardware clock)",
4263   "This dc does NOT have a good time service (i.e. no hardware clock)"
4264 };
4265 static const true_false_string tfs_ads_ndnc = {
4266   "Domain is NON-DOMAIN NC serviced by ldap server",
4267   "Domain is NOT non-domain nc serviced by ldap server"
4268 };
4269 static const true_false_string tfs_ads_rodc = {
4270   "Domain controller is a Windows 2008 RODC",
4271   "Domain controller is not a Windows 2008 RODC"
4272 };
4273 static const true_false_string tfs_ads_wdc = {
4274   "Domain controller is a Windows 2008 writable NC",
4275   "Domain controller is not a Windows 2008 writable NC"
4276 };
4277 static const true_false_string tfs_ads_dns = {
4278   "Server name is in DNS format (Windows 2008)",
4279   "Server name is not in DNS format (Windows 2008)"
4280 };
4281 static const true_false_string tfs_ads_dnc = {
4282   "The NC is the default NC (Windows 2008)",
4283   "The NC is not the default NC (Windows 2008)"
4284 };
4285 static const true_false_string tfs_ads_fnc = {
4286   "The NC is the default forest NC(Windows 2008)",
4287   "The NC is not the default forest NC (Windows 2008)"
4288 };
4289 static int dissect_mscldap_netlogon_flags(proto_tree *parent_tree, tvbuff_t *tvb, int offset)
4290 {
4291   static const int * flags[] = {
4292     &hf_mscldap_netlogon_flags_fnc,
4293     &hf_mscldap_netlogon_flags_dnc,
4294     &hf_mscldap_netlogon_flags_dns,
4295     &hf_mscldap_netlogon_flags_wdc,
4296     &hf_mscldap_netlogon_flags_rodc,
4297     &hf_mscldap_netlogon_flags_ndnc,
4298     &hf_mscldap_netlogon_flags_good_timeserv,
4299     &hf_mscldap_netlogon_flags_writable,
4300     &hf_mscldap_netlogon_flags_closest,
4301     &hf_mscldap_netlogon_flags_timeserv,
4302     &hf_mscldap_netlogon_flags_kdc,
4303     &hf_mscldap_netlogon_flags_ds,
4304     &hf_mscldap_netlogon_flags_ldap,
4305     &hf_mscldap_netlogon_flags_gc,
4306     &hf_mscldap_netlogon_flags_pdc,
4307     NULL
4308   };
4309
4310   proto_tree_add_bitmask_with_flags(parent_tree, tvb, offset, hf_mscldap_netlogon_flags,
4311                            ett_mscldap_netlogon_flags, flags, ENC_LITTLE_ENDIAN, BMT_NO_FALSE);
4312   offset += 4;
4313
4314   return offset;
4315 }
4316
4317 static int dissect_NetLogon_PDU(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
4318 {
4319   int old_offset, offset=0;
4320   char str[256];
4321   guint16 itype;
4322   guint16 len;
4323   guint32 version;
4324   const char *fn;
4325   int fn_len;
4326   guint16 bc;
4327   proto_item *item;
4328
4329   ldm_tree = NULL;
4330
4331
4332   /* Get the length of the buffer */
4333   len=tvb_reported_length_remaining(tvb,offset);
4334
4335   /* check the len if it is to small return */
4336   if (len < 10)
4337     return tvb_captured_length(tvb);
4338
4339   /* Type */
4340   proto_tree_add_item(tree, hf_mscldap_netlogon_opcode, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4341   itype = tvb_get_letohs(tvb, offset);
4342   offset += 2;
4343
4344   switch(itype){
4345
4346     case LOGON_SAM_LOGON_RESPONSE:
4347       bc = tvb_reported_length_remaining(tvb, offset);
4348       /* logon server name */
4349       fn = get_unicode_or_ascii_string(tvb,&offset,TRUE,&fn_len,FALSE,FALSE,&bc);
4350       proto_tree_add_string(tree, hf_mscldap_nb_hostname, tvb,offset, fn_len, fn);
4351       offset +=fn_len;
4352
4353       /* username */
4354       fn = get_unicode_or_ascii_string(tvb,&offset,TRUE,&fn_len,FALSE,FALSE,&bc);
4355       proto_tree_add_string(tree, hf_mscldap_username, tvb,offset, fn_len, fn);
4356       offset +=fn_len;
4357
4358       /* domain name */
4359       fn = get_unicode_or_ascii_string(tvb,&offset,TRUE,&fn_len,FALSE,FALSE,&bc);
4360       proto_tree_add_string(tree, hf_mscldap_nb_domain, tvb,offset, fn_len, fn);
4361       offset +=fn_len;
4362
4363       /* get the version number from the end of the buffer, as the
4364          length is variable and the version determines what fields
4365          need to be decoded */
4366       version = tvb_get_letohl(tvb,len-8);
4367
4368       /* include the extra version 5 fields */
4369       if ((version & NETLOGON_NT_VERSION_5) == NETLOGON_NT_VERSION_5){
4370
4371         /* domain guid */
4372         proto_tree_add_item(tree, hf_mscldap_domain_guid, tvb, offset, 16, ENC_LITTLE_ENDIAN);
4373         offset += 16;
4374
4375         /* domain guid part 2
4376            there is another 16 byte guid but this is alway zero, so we will skip it */
4377         offset += 16;
4378
4379         /* Forest */
4380         old_offset=offset;
4381         offset=dissect_mscldap_string(tvb, offset, str, 255, FALSE);
4382         proto_tree_add_string(tree, hf_mscldap_forest, tvb, old_offset, offset-old_offset, str);
4383
4384         /* Domain */
4385         old_offset=offset;
4386         offset=dissect_mscldap_string(tvb, offset, str, 255, FALSE);
4387         proto_tree_add_string(tree, hf_mscldap_domain, tvb, old_offset, offset-old_offset, str);
4388
4389         /* Hostname */
4390         old_offset=offset;
4391         offset=dissect_mscldap_string(tvb, offset, str, 255, FALSE);
4392         proto_tree_add_string(tree, hf_mscldap_hostname, tvb, old_offset, offset-old_offset, str);
4393
4394         /* DC IP Address */
4395         proto_tree_add_item(tree, hf_mscldap_netlogon_ipaddress, tvb, offset, 4, ENC_BIG_ENDIAN);
4396         offset += 4;
4397
4398         /* Flags */
4399         offset = dissect_mscldap_netlogon_flags(tree, tvb, offset);
4400
4401       }
4402
4403       break;
4404
4405     case LOGON_SAM_LOGON_RESPONSE_EX:
4406       /* MS-ADTS 7.3.1.9 */
4407       offset += 2; /* Skip over "Sbz" field (MUST be set to 0) */
4408
4409       /* Flags */
4410       offset = dissect_mscldap_netlogon_flags(tree, tvb, offset);
4411
4412       /* Domain GUID */
4413       proto_tree_add_item(tree, hf_mscldap_domain_guid, tvb, offset, 16, ENC_LITTLE_ENDIAN);
4414       offset += 16;
4415
4416       /* Forest */
4417       old_offset=offset;
4418       offset=dissect_mscldap_string(tvb, offset, str, 255, FALSE);
4419       proto_tree_add_string(tree, hf_mscldap_forest, tvb, old_offset, offset-old_offset, str);
4420
4421       /* Domain */
4422       old_offset=offset;
4423       offset=dissect_mscldap_string(tvb, offset, str, 255, FALSE);
4424       proto_tree_add_string(tree, hf_mscldap_domain, tvb, old_offset, offset-old_offset, str);
4425
4426       /* Hostname */
4427       old_offset=offset;
4428       offset=dissect_mscldap_string(tvb, offset, str, 255, FALSE);
4429       proto_tree_add_string(tree, hf_mscldap_hostname, tvb, old_offset, offset-old_offset, str);
4430
4431       /* NetBIOS Domain */
4432       old_offset=offset;
4433       offset=dissect_mscldap_string(tvb, offset, str, 255, FALSE);
4434       proto_tree_add_string(tree, hf_mscldap_nb_domain, tvb, old_offset, offset-old_offset, str);
4435
4436       /* NetBIOS Hostname */
4437       old_offset=offset;
4438       offset=dissect_mscldap_string(tvb, offset, str, 255, FALSE);
4439       proto_tree_add_string(tree, hf_mscldap_nb_hostname, tvb, old_offset, offset-old_offset, str);
4440
4441       /* User */
4442       old_offset=offset;
4443       offset=dissect_mscldap_string(tvb, offset, str, 255, FALSE);
4444       proto_tree_add_string(tree, hf_mscldap_username, tvb, old_offset, offset-old_offset, str);
4445
4446       /* Server Site */
4447       old_offset=offset;
4448       offset=dissect_mscldap_string(tvb, offset, str, 255, FALSE);
4449       proto_tree_add_string(tree, hf_mscldap_sitename, tvb, old_offset, offset-old_offset, str);
4450
4451       /* Client Site */
4452       old_offset=offset;
4453       offset=dissect_mscldap_string(tvb, offset, str, 255, FALSE);
4454       proto_tree_add_string(tree, hf_mscldap_clientsitename, tvb, old_offset, offset-old_offset, str);
4455
4456       /* get the version number from the end of the buffer, as the
4457          length is variable and the version determines what fields
4458          need to be decoded */
4459       version = tvb_get_letohl(tvb,len-8);
4460
4461       /* include the extra fields for version 5 with IP s */
4462       if ((version & NETLOGON_NT_VERSION_5EX_WITH_IP) == NETLOGON_NT_VERSION_5EX_WITH_IP){
4463         /* The ip address is returned as a sockaddr_in structure
4464          *
4465          *  This section may need to be updated if the base Windows APIs
4466          *  are changed to support ipv6, which currently is not the case.
4467          *
4468          *  The desector assumes the length is based on ipv4 and
4469          *  ignores the length
4470          */
4471
4472         /* skip the length of the sockaddr_in */
4473
4474         offset +=1;
4475
4476         /* add IP address and desect the sockaddr_in structure */
4477
4478         old_offset = offset + 4;
4479         item = proto_tree_add_item(tree, hf_mscldap_netlogon_ipaddress, tvb, old_offset, 4, ENC_BIG_ENDIAN);
4480
4481         if (tree){
4482           proto_tree *subtree;
4483
4484           subtree = proto_item_add_subtree(item, ett_mscldap_ipdetails);
4485
4486           /* get sockaddr family */
4487           proto_tree_add_item(subtree, hf_mscldap_netlogon_ipaddress_family, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4488           offset +=2;
4489
4490           /* get sockaddr port */
4491           proto_tree_add_item(subtree, hf_mscldap_netlogon_ipaddress_port, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4492           offset +=2;
4493
4494           /* get IP address */
4495           proto_tree_add_item(subtree, hf_mscldap_netlogon_ipaddress_ipv4, tvb, offset, 4, ENC_BIG_ENDIAN);
4496           offset +=4;
4497
4498           /* skip the 8 bytes of zeros in the sockaddr structure */
4499           offset += 8;
4500         }
4501
4502       }
4503
4504       break;
4505   }
4506
4507
4508  /* complete the decode with the version and token details */
4509
4510   offset = len-8;
4511
4512   /* NETLOGON_NT_VERISON Options (MS-ADTS 7.3.1.1) */
4513   offset = dissect_mscldap_ntver_flags(tree, tvb, offset);
4514
4515   /* LM Token */
4516   proto_tree_add_item(tree, hf_mscldap_netlogon_lm_token, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4517   offset += 2;
4518
4519   /* NT Token */
4520   proto_tree_add_item(tree, hf_mscldap_netlogon_nt_token, tvb, offset, 2, ENC_LITTLE_ENDIAN);
4521
4522   return tvb_captured_length(tvb);
4523 }
4524
4525
4526 static guint
4527 get_sasl_ldap_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb,
4528                       int offset, void *data _U_)
4529 {
4530   /* sasl encapsulated ldap is 4 bytes plus the length in size */
4531   return tvb_get_ntohl(tvb, offset)+4;
4532 }
4533
4534 static int
4535 dissect_sasl_ldap_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
4536 {
4537   dissect_ldap_pdu(tvb, pinfo, tree, FALSE);
4538   return tvb_captured_length(tvb);
4539 }
4540
4541 static guint
4542 get_normal_ldap_pdu_len(packet_info *pinfo _U_, tvbuff_t *tvb,
4543                         int offset, void *data _U_)
4544 {
4545   guint32 len;
4546   gboolean ind;
4547   int data_offset;
4548
4549   /* normal ldap is tag+len bytes plus the length
4550    * offset is where the tag is
4551    * offset+1 is where length starts
4552    */
4553   data_offset=get_ber_length(tvb, offset+1, &len, &ind);
4554   return len+data_offset-offset;
4555 }
4556
4557 static int
4558 dissect_normal_ldap_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
4559 {
4560   dissect_ldap_pdu(tvb, pinfo, tree, FALSE);
4561   return tvb_captured_length(tvb);
4562 }
4563
4564 static int
4565 dissect_ldap_oid(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
4566 {
4567   char *oid;
4568   const char *oidname;
4569
4570   /* tvb here contains an ascii string that is really an oid */
4571   /* XXX   we should convert the string oid into a real oid so we can use
4572    *       proto_tree_add_oid() instead.
4573    */
4574
4575   oid=tvb_get_string_enc(wmem_packet_scope(), tvb, 0, tvb_reported_length(tvb), ENC_UTF_8|ENC_NA);
4576   if(!oid){
4577     return tvb_captured_length(tvb);
4578   }
4579
4580   oidname=oid_resolved_from_string(wmem_packet_scope(), oid);
4581
4582   if(oidname){
4583     proto_tree_add_string_format_value(tree, hf_ldap_oid, tvb, 0, tvb_reported_length(tvb), oid, "%s (%s)",oid,oidname);
4584   } else {
4585     proto_tree_add_string(tree, hf_ldap_oid, tvb, 0, tvb_captured_length(tvb), oid);
4586   }
4587   return tvb_captured_length(tvb);
4588 }
4589
4590 #define LDAP_ACCESSMASK_ADS_CREATE_CHILD    0x00000001
4591 #define LDAP_ACCESSMASK_ADS_DELETE_CHILD    0x00000002
4592 #define LDAP_ACCESSMASK_ADS_LIST            0x00000004
4593 #define LDAP_ACCESSMASK_ADS_SELF_WRITE      0x00000008
4594 #define LDAP_ACCESSMASK_ADS_READ_PROP       0x00000010
4595 #define LDAP_ACCESSMASK_ADS_WRITE_PROP      0x00000020
4596 #define LDAP_ACCESSMASK_ADS_DELETE_TREE     0x00000040
4597 #define LDAP_ACCESSMASK_ADS_LIST_OBJECT     0x00000080
4598 #define LDAP_ACCESSMASK_ADS_CONTROL_ACCESS  0x00000100
4599
4600 static void
4601 ldap_specific_rights(tvbuff_t *tvb, gint offset, proto_tree *tree, guint32 access)
4602 {
4603   static const int * access_flags[] = {
4604     &hf_ldap_AccessMask_ADS_CONTROL_ACCESS,
4605     &hf_ldap_AccessMask_ADS_LIST_OBJECT,
4606     &hf_ldap_AccessMask_ADS_DELETE_TREE,
4607     &hf_ldap_AccessMask_ADS_WRITE_PROP,
4608     &hf_ldap_AccessMask_ADS_READ_PROP,
4609     &hf_ldap_AccessMask_ADS_SELF_WRITE,
4610     &hf_ldap_AccessMask_ADS_LIST,
4611     &hf_ldap_AccessMask_ADS_DELETE_CHILD,
4612     &hf_ldap_AccessMask_ADS_CREATE_CHILD,
4613     NULL
4614   };
4615
4616   proto_tree_add_bitmask_list_value(tree, tvb, offset, 4, access_flags, access);
4617 }
4618 struct access_mask_info ldap_access_mask_info = {
4619   "LDAP",                 /* Name of specific rights */
4620   ldap_specific_rights,   /* Dissection function */
4621   NULL,                   /* Generic mapping table */
4622   NULL                    /* Standard mapping table */
4623 };
4624
4625 static int
4626 dissect_ldap_nt_sec_desc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
4627 {
4628   dissect_nt_sec_desc(tvb, 0, pinfo, tree, NULL, TRUE, tvb_reported_length(tvb), &ldap_access_mask_info);
4629   return tvb_captured_length(tvb);
4630 }
4631
4632 static int
4633 dissect_ldap_sid(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree, void* data _U_)
4634 {
4635   char *tmpstr;
4636
4637   /* this octet string contains an NT SID */
4638   dissect_nt_sid(tvb, 0, tree, "SID", &tmpstr, hf_ldap_sid);
4639   ldapvalue_string=tmpstr;
4640   return tvb_captured_length(tvb);
4641 }
4642
4643 static int
4644 dissect_ldap_guid(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
4645 {
4646   guint8 drep[4] = { 0x10, 0x00, 0x00, 0x00}; /* fake DREP struct */
4647   e_guid_t uuid;
4648
4649   /* This octet string contained a GUID */
4650   dissect_dcerpc_uuid_t(tvb, 0, pinfo, tree, drep, hf_ldap_guid, &uuid);
4651
4652   ldapvalue_string=(char*)wmem_alloc(wmem_packet_scope(), 1024);
4653   g_snprintf(ldapvalue_string, 1023, "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
4654              uuid.data1, uuid.data2, uuid.data3, uuid.data4[0], uuid.data4[1],
4655              uuid.data4[2], uuid.data4[3], uuid.data4[4], uuid.data4[5],
4656              uuid.data4[6], uuid.data4[7]);
4657   return tvb_captured_length(tvb);
4658 }
4659
4660 static int
4661 dissect_ldap_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data)
4662 {
4663   guint32 sasl_len;
4664   guint32 ldap_len;
4665   gboolean ind;
4666   conversation_t *conversation;
4667   ldap_conv_info_t *ldap_info = NULL;
4668
4669   /*
4670    * Do we have a conversation for this connection?
4671    */
4672   conversation = find_conversation_pinfo(pinfo, 0);
4673   if(conversation){
4674     ldap_info = (ldap_conv_info_t *)conversation_get_proto_data(conversation, proto_ldap);
4675   }
4676
4677   ldm_tree = NULL;
4678
4679   /* This is a bit tricky. We have to find out whether SASL is used
4680    * so that we know how big a header we are supposed to pass
4681    * to tcp_dissect_pdus()
4682    * We must also cope with the case when a client connects to LDAP
4683    * and performs a few unauthenticated searches of LDAP before
4684    * it performs the bind on the same tcp connection.
4685    */
4686   /* check for a SASL header, i.e. assume it is SASL if
4687    * 1, first four bytes (SASL length) is an integer
4688    *    with a value that must be <LDAP_SASL_MAX_BUF and >2
4689    *    (>2 to fight false positives, 0x00000000 is a common
4690    *        "random" tcp payload)
4691    * (SASL ldap PDUs might be >64k in size, which is why
4692    * LDAP_SASL_MAX_BUF is used - defined in packet-ldap.h)
4693    *
4694    * 2, we must have a conversation and the auth type must
4695    *    be LDAP_AUTH_SASL
4696    */
4697   sasl_len=tvb_get_ntohl(tvb, 0);
4698
4699   if( sasl_len<2 ){
4700     goto this_was_not_sasl;
4701   }
4702
4703   if( sasl_len>LDAP_SASL_MAX_BUF ){
4704     goto this_was_not_sasl;
4705   }
4706
4707   if((!ldap_info) || (ldap_info->auth_type!=LDAP_AUTH_SASL) ){
4708     goto this_was_not_sasl;
4709   }
4710
4711   tcp_dissect_pdus(tvb, pinfo, tree, ldap_desegment, 4, get_sasl_ldap_pdu_len, dissect_sasl_ldap_pdu, data);
4712   return tvb_captured_length(tvb);
4713
4714 this_was_not_sasl:
4715   /* check if it is a normal BER encoded LDAP packet
4716    * i.e. first byte is 0x30 followed by a length that is
4717    * <64k
4718    * (no ldap PDUs are ever >64kb? )
4719    */
4720   if(tvb_get_guint8(tvb, 0)!=0x30){
4721     goto this_was_not_normal_ldap;
4722   }
4723
4724   /* check that length makes sense */
4725   get_ber_length(tvb, 1, &ldap_len, &ind);
4726
4727   /* don't check ind since indefinite length is never used for ldap (famous last words)*/
4728   if(ldap_len<2){
4729     goto this_was_not_normal_ldap;
4730   }
4731
4732   /*
4733    * The minimun size of a LDAP pdu is 7 bytes
4734    *
4735    * dumpasn1 -hh ldap-unbind-min.dat
4736    *
4737    *     <30 05 02 01 09 42 00>
4738    *    0    5: SEQUENCE {
4739    *     <02 01 09>
4740    *    2    1:   INTEGER 9
4741    *     <42 00>
4742    *    5    0:   [APPLICATION 2]
4743    *          :     Error: Object has zero length.
4744    *          :   }
4745    *
4746    * dumpasn1 -hh ldap-unbind-windows.dat
4747    *
4748    *     <30 84 00 00 00 05 02 01 09 42 00>
4749    *    0    5: SEQUENCE {
4750    *     <02 01 09>
4751    *    6    1:   INTEGER 9
4752    *     <42 00>
4753    *    9    0:   [APPLICATION 2]
4754    *          :     Error: Object has zero length.
4755    *          :   }
4756    *
4757    * 6 bytes would also be ok to get the full length of
4758    * the pdu, but as the smallest pdu can be 7 bytes
4759    * we can use 7.
4760    */
4761   tcp_dissect_pdus(tvb, pinfo, tree, ldap_desegment, 7, get_normal_ldap_pdu_len, dissect_normal_ldap_pdu, data);
4762
4763   goto end;
4764
4765 this_was_not_normal_ldap:
4766
4767   /* Ok it might be a strange case of SASL still
4768    * It has been seen with Exchange setup to MS AD
4769    * when Exchange pretend that there is SASL but in fact data are still
4770    * in clear*/
4771   if ((sasl_len + 4) == (guint32)tvb_reported_length_remaining(tvb, 0))
4772     tcp_dissect_pdus(tvb, pinfo, tree, ldap_desegment, 4, get_sasl_ldap_pdu_len, dissect_sasl_ldap_pdu, data);
4773  end:
4774   return tvb_captured_length(tvb);
4775 }
4776
4777 static int
4778 dissect_mscldap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
4779 {
4780   dissect_ldap_pdu(tvb, pinfo, tree, TRUE);
4781   return tvb_captured_length(tvb);
4782 }
4783
4784
4785 /*--- proto_register_ldap -------------------------------------------*/
4786 void proto_register_ldap(void) {
4787
4788   /* List of fields */
4789
4790   static hf_register_info hf[] = {
4791
4792     { &hf_ldap_sasl_buffer_length,
4793       { "SASL Buffer Length",   "ldap.sasl_buffer_length",
4794         FT_UINT32, BASE_DEC, NULL, 0x0,
4795         NULL, HFILL }},
4796     { &hf_ldap_response_in,
4797       { "Response In", "ldap.response_in",
4798         FT_FRAMENUM, BASE_NONE, NULL, 0x0,
4799         "The response to this LDAP request is in this frame", HFILL }},
4800     { &hf_ldap_response_to,
4801       { "Response To", "ldap.response_to",
4802         FT_FRAMENUM, BASE_NONE, NULL, 0x0,
4803         "This is a response to the LDAP request in this frame", HFILL }},
4804     { &hf_ldap_time,
4805       { "Time", "ldap.time",
4806         FT_RELATIVE_TIME, BASE_NONE, NULL, 0x0,
4807         "The time between the Call and the Reply", HFILL }},
4808
4809     { &hf_mscldap_netlogon_opcode,
4810       { "Operation code", "mscldap.netlogon.opcode",
4811         FT_UINT16, BASE_DEC, VALS(netlogon_opcode_vals), 0x0,
4812         "LDAP ping operation code", HFILL }},
4813
4814     { &hf_mscldap_netlogon_ipaddress_family,
4815       { "Family", "mscldap.netlogon.ipaddress.family",
4816         FT_UINT16, BASE_DEC, NULL, 0x0,
4817         NULL, HFILL }},
4818
4819     { &hf_mscldap_netlogon_ipaddress_ipv4,
4820       { "IPv4", "mscldap.netlogon.ipaddress.ipv4",
4821         FT_IPv4, BASE_NONE, NULL, 0x0,
4822         "IP Address", HFILL }},
4823
4824     { &hf_mscldap_netlogon_ipaddress_port,
4825       { "Port", "mscldap.netlogon.ipaddress.port",
4826         FT_UINT16, BASE_DEC, NULL, 0x0,
4827         NULL, HFILL }},
4828
4829     { &hf_mscldap_netlogon_ipaddress,
4830       { "IP Address","mscldap.netlogon.ipaddress",
4831         FT_IPv4, BASE_NONE, NULL, 0x0,
4832         "Domain Controller IP Address", HFILL }},
4833
4834     { &hf_mscldap_netlogon_lm_token,
4835       { "LM Token", "mscldap.netlogon.lm_token",
4836         FT_UINT16, BASE_HEX, NULL, 0x0,
4837         "MUST be set to 0xFFFF", HFILL }},
4838
4839     { &hf_mscldap_netlogon_nt_token,
4840       { "NT Token", "mscldap.netlogon.nt_token",
4841         FT_UINT16, BASE_HEX, NULL, 0x0,
4842         "MUST be set to 0xFFFF", HFILL }},
4843
4844     { &hf_mscldap_netlogon_flags,
4845       { "Flags", "mscldap.netlogon.flags",
4846         FT_UINT32, BASE_HEX, NULL, 0x0,
4847         "Netlogon flags describing the DC properties", HFILL }},
4848
4849     { &hf_mscldap_ntver_flags,
4850       { "Version Flags", "mscldap.ntver.flags",
4851         FT_UINT32, BASE_HEX, NULL, 0x0,
4852         "NETLOGON_NT_VERSION Options Bits", HFILL }},
4853
4854     { &hf_mscldap_domain_guid,
4855       { "Domain GUID", "mscldap.domain.guid",
4856         FT_GUID, BASE_NONE, NULL, 0x0,
4857         "Value of the NC's GUID attribute", HFILL }},
4858
4859     { &hf_mscldap_forest,
4860       { "Forest", "mscldap.forest",
4861         FT_STRING, BASE_NONE, NULL, 0x0,
4862         "DNS name of the forest", HFILL }},
4863
4864     { &hf_mscldap_domain,
4865       { "Domain", "mscldap.domain",
4866         FT_STRING, BASE_NONE, NULL, 0x0,
4867         "DNS name of the NC", HFILL }},
4868
4869     { &hf_mscldap_hostname,
4870       { "Hostname", "mscldap.hostname",
4871         FT_STRING, BASE_NONE, NULL, 0x0,
4872         "DNS name of server", HFILL }},
4873
4874     { &hf_mscldap_nb_domain,
4875       { "NetBIOS Domain", "mscldap.nb_domain",
4876         FT_STRING, BASE_NONE, NULL, 0x0,
4877         "NetBIOS name of the NC", HFILL }},
4878
4879     { &hf_mscldap_nb_hostname,
4880       { "NetBIOS Hostname", "mscldap.nb_hostname",
4881         FT_STRING, BASE_NONE, NULL, 0x0,
4882         "NetBIOS name of the server", HFILL }},
4883
4884     { &hf_mscldap_username,
4885       { "Username", "mscldap.username",
4886         FT_STRING, BASE_NONE, NULL, 0x0,
4887         "User specified in client's request", HFILL }},
4888
4889     { &hf_mscldap_sitename,
4890       { "Server Site", "mscldap.sitename",
4891         FT_STRING, BASE_NONE, NULL, 0x0,
4892         "Site name of the server", HFILL }},
4893
4894     { &hf_mscldap_clientsitename,
4895       { "Client Site", "mscldap.clientsitename",
4896         FT_STRING, BASE_NONE, NULL, 0x0,
4897         "Site name of the client", HFILL }},
4898
4899     { &hf_ldap_sid,
4900       { "Sid", "ldap.sid",
4901         FT_STRING, BASE_NONE, NULL, 0x0,
4902         NULL, HFILL }},
4903
4904     { &hf_mscldap_ntver_flags_v1,
4905       { "V1", "mscldap.ntver.searchflags.v1", FT_BOOLEAN, 32,
4906         TFS(&tfs_ntver_v1), 0x00000001, "See section 7.3.1.1 of MS-ADTS specification", HFILL }},
4907
4908     { &hf_mscldap_ntver_flags_v5,
4909       { "V5", "mscldap.ntver.searchflags.v5", FT_BOOLEAN, 32,
4910         TFS(&tfs_ntver_v5), 0x00000002, "See section 7.3.1.1 of MS-ADTS specification", HFILL }},
4911
4912     { &hf_mscldap_ntver_flags_v5ex,
4913       { "V5EX", "mscldap.ntver.searchflags.v5ex", FT_BOOLEAN, 32,
4914         TFS(&tfs_ntver_v5ex), 0x00000004, "See section 7.3.1.1 of MS-ADTS specification", HFILL }},
4915
4916     { &hf_mscldap_ntver_flags_v5ep,
4917       { "V5EP", "mscldap.ntver.searchflags.v5ep", FT_BOOLEAN, 32,
4918         TFS(&tfs_ntver_v5ep), 0x00000008, "See section 7.3.1.1 of MS-ADTS specification", HFILL }},
4919
4920     { &hf_mscldap_ntver_flags_vcs,
4921       { "VCS", "mscldap.ntver.searchflags.vcs", FT_BOOLEAN, 32,
4922         TFS(&tfs_ntver_vcs), 0x00000010, "See section 7.3.1.1 of MS-ADTS specification", HFILL }},
4923
4924     { &hf_mscldap_ntver_flags_vnt4,
4925       { "VNT4", "mscldap.ntver.searchflags.vnt4", FT_BOOLEAN, 32,
4926         TFS(&tfs_ntver_vnt4), 0x01000000, "See section 7.3.1.1 of MS-ADTS specification", HFILL }},
4927
4928     { &hf_mscldap_ntver_flags_vpdc,
4929       { "VPDC", "mscldap.ntver.searchflags.vpdc", FT_BOOLEAN, 32,
4930         TFS(&tfs_ntver_vpdc), 0x10000000, "See section 7.3.1.1 of MS-ADTS specification", HFILL }},
4931
4932     { &hf_mscldap_ntver_flags_vip,
4933       { "VIP", "mscldap.ntver.searchflags.vip", FT_BOOLEAN, 32,
4934         TFS(&tfs_ntver_vip), 0x20000000, "See section 7.3.1.1 of MS-ADTS specification", HFILL }},
4935
4936     { &hf_mscldap_ntver_flags_vl,
4937       { "VL", "mscldap.ntver.searchflags.vl", FT_BOOLEAN, 32,
4938         TFS(&tfs_ntver_vl), 0x40000000, "See section 7.3.1.1 of MS-ADTS specification", HFILL }},
4939
4940     { &hf_mscldap_ntver_flags_vgc,
4941       { "VGC", "mscldap.ntver.searchflags.vgc", FT_BOOLEAN, 32,
4942         TFS(&tfs_ntver_vgc), 0x80000000, "See section 7.3.1.1 of MS-ADTS specification", HFILL }},
4943
4944
4945     { &hf_mscldap_netlogon_flags_pdc,
4946       { "PDC", "mscldap.netlogon.flags.pdc", FT_BOOLEAN, 32,
4947         TFS(&tfs_ads_pdc), 0x00000001, "Is this DC a PDC or not?", HFILL }},
4948
4949     { &hf_mscldap_netlogon_flags_gc,
4950       { "GC", "mscldap.netlogon.flags.gc", FT_BOOLEAN, 32,
4951         TFS(&tfs_ads_gc), 0x00000004, "Does this dc service as a GLOBAL CATALOGUE?", HFILL }},
4952
4953     { &hf_mscldap_netlogon_flags_ldap,
4954       { "LDAP", "mscldap.netlogon.flags.ldap", FT_BOOLEAN, 32,
4955         TFS(&tfs_ads_ldap), 0x00000008, "Does this DC act as an LDAP server?", HFILL }},
4956
4957     { &hf_mscldap_netlogon_flags_ds,
4958       { "DS", "mscldap.netlogon.flags.ds", FT_BOOLEAN, 32,
4959         TFS(&tfs_ads_ds), 0x00000010, "Does this dc provide DS services?", HFILL }},
4960
4961     { &hf_mscldap_netlogon_flags_kdc,
4962       { "KDC", "mscldap.netlogon.flags.kdc", FT_BOOLEAN, 32,
4963         TFS(&tfs_ads_kdc), 0x00000020, "Does this dc act as a KDC?", HFILL }},
4964
4965     { &hf_mscldap_netlogon_flags_timeserv,
4966       { "Time Serv", "mscldap.netlogon.flags.timeserv", FT_BOOLEAN, 32,
4967         TFS(&tfs_ads_timeserv), 0x00000040, "Does this dc provide time services (ntp) ?", HFILL }},
4968
4969     { &hf_mscldap_netlogon_flags_closest,
4970       { "Closest", "mscldap.netlogon.flags.closest", FT_BOOLEAN, 32,
4971         TFS(&tfs_ads_closest), 0x00000080, "Is this the closest dc?", HFILL }},
4972
4973     { &hf_mscldap_netlogon_flags_writable,
4974       { "Writable", "mscldap.netlogon.flags.writable", FT_BOOLEAN, 32,
4975         TFS(&tfs_ads_writable), 0x00000100, "Is this dc writable?", HFILL }},
4976
4977     { &hf_mscldap_netlogon_flags_good_timeserv,
4978       { "Good Time Serv", "mscldap.netlogon.flags.good_timeserv", FT_BOOLEAN, 32,
4979         TFS(&tfs_ads_good_timeserv), 0x00000200, "Is this a Good Time Server? (i.e. does it have a hardware clock)", HFILL }},
4980
4981     { &hf_mscldap_netlogon_flags_ndnc,
4982       { "NDNC", "mscldap.netlogon.flags.ndnc", FT_BOOLEAN, 32,
4983         TFS(&tfs_ads_ndnc), 0x00000400, "Is this an NDNC dc?", HFILL }},
4984
4985     { &hf_mscldap_netlogon_flags_rodc,
4986       { "RODC", "mscldap.netlogon.flags.rodc", FT_BOOLEAN, 32,
4987         TFS(&tfs_ads_rodc), 0x00000800, "Is this an read only dc?", HFILL }},
4988
4989     { &hf_mscldap_netlogon_flags_wdc,
4990       { "WDC", "mscldap.netlogon.flags.writabledc", FT_BOOLEAN, 32,
4991         TFS(&tfs_ads_wdc), 0x00001000, "Is this an writable dc (Windows 2008)?", HFILL }},
4992
4993     { &hf_mscldap_netlogon_flags_dns,
4994       { "DNS", "mscldap.netlogon.flags.dnsname", FT_BOOLEAN, 32,
4995         TFS(&tfs_ads_dns), 0x20000000, "Does the server have a dns name (Windows 2008)?", HFILL }},
4996
4997     { &hf_mscldap_netlogon_flags_dnc,
4998       { "DNC", "mscldap.netlogon.flags.defaultnc", FT_BOOLEAN, 32,
4999         TFS(&tfs_ads_dnc), 0x40000000, "Is this the default NC (Windows 2008)?", HFILL }},
5000
5001     { &hf_mscldap_netlogon_flags_fnc,
5002       { "FDC", "mscldap.netlogon.flags.forestnc", FT_BOOLEAN, 32,
5003         TFS(&tfs_ads_fnc), 0x80000000, "Is the the NC the default forest root(Windows 2008)?", HFILL }},
5004
5005     { &hf_ldap_guid,
5006       { "GUID", "ldap.guid", FT_GUID, BASE_NONE,
5007         NULL, 0, NULL, HFILL }},
5008
5009     { &hf_ldap_AccessMask_ADS_CREATE_CHILD,
5010       { "Ads Create Child", "ldap.AccessMask.ADS_CREATE_CHILD", FT_BOOLEAN, 32, TFS(&tfs_set_notset), LDAP_ACCESSMASK_ADS_CREATE_CHILD, NULL, HFILL }},
5011
5012     { &hf_ldap_AccessMask_ADS_DELETE_CHILD,
5013       { "Ads Delete Child", "ldap.AccessMask.ADS_DELETE_CHILD", FT_BOOLEAN, 32, TFS(&tfs_set_notset), LDAP_ACCESSMASK_ADS_DELETE_CHILD, NULL, HFILL }},
5014
5015     { &hf_ldap_AccessMask_ADS_LIST,
5016       { "Ads List", "ldap.AccessMask.ADS_LIST", FT_BOOLEAN, 32, TFS(&tfs_set_notset), LDAP_ACCESSMASK_ADS_LIST, NULL, HFILL }},
5017
5018     { &hf_ldap_AccessMask_ADS_SELF_WRITE,
5019       { "Ads Self Write", "ldap.AccessMask.ADS_SELF_WRITE", FT_BOOLEAN, 32, TFS(&tfs_set_notset), LDAP_ACCESSMASK_ADS_SELF_WRITE, NULL, HFILL }},
5020
5021     { &hf_ldap_AccessMask_ADS_READ_PROP,
5022       { "Ads Read Prop", "ldap.AccessMask.ADS_READ_PROP", FT_BOOLEAN, 32, TFS(&tfs_set_notset), LDAP_ACCESSMASK_ADS_READ_PROP, NULL, HFILL }},
5023
5024     { &hf_ldap_AccessMask_ADS_WRITE_PROP,
5025       { "Ads Write Prop", "ldap.AccessMask.ADS_WRITE_PROP", FT_BOOLEAN, 32, TFS(&tfs_set_notset), LDAP_ACCESSMASK_ADS_WRITE_PROP, NULL, HFILL }},
5026
5027     { &hf_ldap_AccessMask_ADS_DELETE_TREE,
5028       { "Ads Delete Tree", "ldap.AccessMask.ADS_DELETE_TREE", FT_BOOLEAN, 32, TFS(&tfs_set_notset), LDAP_ACCESSMASK_ADS_DELETE_TREE, NULL, HFILL }},
5029
5030     { &hf_ldap_AccessMask_ADS_LIST_OBJECT,
5031       { "Ads List Object", "ldap.AccessMask.ADS_LIST_OBJECT", FT_BOOLEAN, 32, TFS(&tfs_set_notset), LDAP_ACCESSMASK_ADS_LIST_OBJECT, NULL, HFILL }},
5032
5033     { &hf_ldap_AccessMask_ADS_CONTROL_ACCESS,
5034       { "Ads Control Access", "ldap.AccessMask.ADS_CONTROL_ACCESS", FT_BOOLEAN, 32, TFS(&tfs_set_notset), LDAP_ACCESSMASK_ADS_CONTROL_ACCESS, NULL, HFILL }},
5035
5036     { &hf_ldap_LDAPMessage_PDU,
5037       { "LDAPMessage", "ldap.LDAPMessage_element", FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
5038
5039     { &hf_ldap_object_security_flag,
5040       { "Flag Object_Security", "ldap.object_security_flag", FT_BOOLEAN, 32, NULL, 0x00000001, NULL, HFILL }},
5041
5042     { &hf_ldap_ancestor_first_flag,
5043       { "Flag Ancestor_First", "ldap.ancestor_first_flag", FT_BOOLEAN, 32, NULL, 0x00000800, NULL, HFILL }},
5044
5045     { &hf_ldap_public_data_only_flag,
5046       { "Flag Public_Data_Only", "ldap.public_data_only_flag", FT_BOOLEAN, 32, NULL, 0x00002000, NULL, HFILL }},
5047
5048     { &hf_ldap_incremental_value_flag,
5049       { "Flag Incremental_Value", "ldap.incremental_value_flag", FT_BOOLEAN, 32, NULL, 0x80000000, NULL, HFILL }},
5050
5051     { &hf_ldap_oid,
5052       { "OID", "ldap.oid", FT_STRING, BASE_NONE,
5053         NULL, 0, NULL, HFILL }},
5054
5055     { &hf_ldap_gssapi_encrypted_payload,
5056       { "GSS-API Encrypted payload", "ldap.gssapi_encrypted_payload", FT_BYTES, BASE_NONE,
5057         NULL, 0, NULL, HFILL }},
5058
5059
5060 /*--- Included file: packet-ldap-hfarr.c ---*/
5061 #line 1 "./asn1/ldap/packet-ldap-hfarr.c"
5062     { &hf_ldap_SearchControlValue_PDU,
5063       { "SearchControlValue", "ldap.SearchControlValue_element",
5064         FT_NONE, BASE_NONE, NULL, 0,
5065         NULL, HFILL }},
5066     { &hf_ldap_SortKeyList_PDU,
5067       { "SortKeyList", "ldap.SortKeyList",
5068         FT_UINT32, BASE_DEC, NULL, 0,
5069         NULL, HFILL }},
5070     { &hf_ldap_SortResult_PDU,
5071       { "SortResult", "ldap.SortResult_element",
5072         FT_NONE, BASE_NONE, NULL, 0,
5073         NULL, HFILL }},
5074     { &hf_ldap_DirSyncControlValue_PDU,
5075       { "DirSyncControlValue", "ldap.DirSyncControlValue_element",
5076         FT_NONE, BASE_NONE, NULL, 0,
5077         NULL, HFILL }},
5078     { &hf_ldap_PasswdModifyRequestValue_PDU,
5079       { "PasswdModifyRequestValue", "ldap.PasswdModifyRequestValue_element",
5080         FT_NONE, BASE_NONE, NULL, 0,
5081         NULL, HFILL }},
5082     { &hf_ldap_CancelRequestValue_PDU,
5083       { "CancelRequestValue", "ldap.CancelRequestValue_element",
5084         FT_NONE, BASE_NONE, NULL, 0,
5085         NULL, HFILL }},
5086     { &hf_ldap_SyncRequestValue_PDU,
5087       { "SyncRequestValue", "ldap.SyncRequestValue_element",
5088         FT_NONE, BASE_NONE, NULL, 0,
5089         NULL, HFILL }},
5090     { &hf_ldap_SyncStateValue_PDU,
5091       { "SyncStateValue", "ldap.SyncStateValue_element",
5092         FT_NONE, BASE_NONE, NULL, 0,
5093         NULL, HFILL }},
5094     { &hf_ldap_SyncDoneValue_PDU,
5095       { "SyncDoneValue", "ldap.SyncDoneValue_element",
5096         FT_NONE, BASE_NONE, NULL, 0,
5097         NULL, HFILL }},
5098     { &hf_ldap_SyncInfoValue_PDU,
5099       { "SyncInfoValue", "ldap.SyncInfoValue",
5100         FT_UINT32, BASE_DEC, VALS(ldap_SyncInfoValue_vals), 0,
5101         NULL, HFILL }},
5102     { &hf_ldap_PasswordPolicyResponseValue_PDU,
5103       { "PasswordPolicyResponseValue", "ldap.PasswordPolicyResponseValue_element",
5104         FT_NONE, BASE_NONE, NULL, 0,
5105         NULL, HFILL }},
5106     { &hf_ldap_messageID,
5107       { "messageID", "ldap.messageID",
5108         FT_UINT32, BASE_DEC, NULL, 0,
5109         NULL, HFILL }},
5110     { &hf_ldap_protocolOp,
5111       { "protocolOp", "ldap.protocolOp",
5112         FT_UINT32, BASE_DEC, VALS(ldap_ProtocolOp_vals), 0,
5113         NULL, HFILL }},
5114     { &hf_ldap_controls,
5115       { "controls", "ldap.controls",
5116         FT_UINT32, BASE_DEC, NULL, 0,
5117         NULL, HFILL }},
5118     { &hf_ldap_bindRequest,
5119       { "bindRequest", "ldap.bindRequest_element",
5120         FT_NONE, BASE_NONE, NULL, 0,
5121         NULL, HFILL }},
5122     { &hf_ldap_bindResponse,
5123       { "bindResponse", "ldap.bindResponse_element",
5124         FT_NONE, BASE_NONE, NULL, 0,
5125         NULL, HFILL }},
5126     { &hf_ldap_unbindRequest,
5127       { "unbindRequest", "ldap.unbindRequest_element",
5128         FT_NONE, BASE_NONE, NULL, 0,
5129         NULL, HFILL }},
5130     { &hf_ldap_searchRequest,
5131       { "searchRequest", "ldap.searchRequest_element",
5132         FT_NONE, BASE_NONE, NULL, 0,
5133         NULL, HFILL }},
5134     { &hf_ldap_searchResEntry,
5135       { "searchResEntry", "ldap.searchResEntry_element",
5136         FT_NONE, BASE_NONE, NULL, 0,
5137         "SearchResultEntry", HFILL }},
5138     { &hf_ldap_searchResDone,
5139       { "searchResDone", "ldap.searchResDone_element",
5140         FT_NONE, BASE_NONE, NULL, 0,
5141         "SearchResultDone", HFILL }},
5142     { &hf_ldap_searchResRef,
5143       { "searchResRef", "ldap.searchResRef",
5144         FT_UINT32, BASE_DEC, NULL, 0,
5145         "SearchResultReference", HFILL }},
5146     { &hf_ldap_modifyRequest,
5147       { "modifyRequest", "ldap.modifyRequest_element",
5148         FT_NONE, BASE_NONE, NULL, 0,
5149         NULL, HFILL }},
5150     { &hf_ldap_modifyResponse,
5151       { "modifyResponse", "ldap.modifyResponse_element",
5152         FT_NONE, BASE_NONE, NULL, 0,
5153         NULL, HFILL }},
5154     { &hf_ldap_addRequest,
5155       { "addRequest", "ldap.addRequest_element",
5156         FT_NONE, BASE_NONE, NULL, 0,
5157         NULL, HFILL }},
5158     { &hf_ldap_addResponse,
5159       { "addResponse", "ldap.addResponse_element",
5160         FT_NONE, BASE_NONE, NULL, 0,
5161         NULL, HFILL }},
5162     { &hf_ldap_delRequest,
5163       { "delRequest", "ldap.delRequest",
5164         FT_STRING, BASE_NONE, NULL, 0,
5165         NULL, HFILL }},
5166     { &hf_ldap_delResponse,
5167       { "delResponse", "ldap.delResponse_element",
5168         FT_NONE, BASE_NONE, NULL, 0,
5169         NULL, HFILL }},
5170     { &hf_ldap_modDNRequest,
5171       { "modDNRequest", "ldap.modDNRequest_element",
5172         FT_NONE, BASE_NONE, NULL, 0,
5173         "ModifyDNRequest", HFILL }},
5174     { &hf_ldap_modDNResponse,
5175       { "modDNResponse", "ldap.modDNResponse_element",
5176         FT_NONE, BASE_NONE, NULL, 0,
5177         "ModifyDNResponse", HFILL }},
5178     { &hf_ldap_compareRequest,
5179       { "compareRequest", "ldap.compareRequest_element",
5180         FT_NONE, BASE_NONE, NULL, 0,
5181         NULL, HFILL }},
5182     { &hf_ldap_compareResponse,
5183       { "compareResponse", "ldap.compareResponse_element",
5184         FT_NONE, BASE_NONE, NULL, 0,
5185         NULL, HFILL }},
5186     { &hf_ldap_abandonRequest,
5187       { "abandonRequest", "ldap.abandonRequest",
5188         FT_UINT32, BASE_DEC, NULL, 0,
5189         NULL, HFILL }},
5190     { &hf_ldap_extendedReq,
5191       { "extendedReq", "ldap.extendedReq_element",
5192         FT_NONE, BASE_NONE, NULL, 0,
5193         "ExtendedRequest", HFILL }},
5194     { &hf_ldap_extendedResp,
5195       { "extendedResp", "ldap.extendedResp_element",
5196         FT_NONE, BASE_NONE, NULL, 0,
5197         "ExtendedResponse", HFILL }},
5198     { &hf_ldap_intermediateResponse,
5199       { "intermediateResponse", "ldap.intermediateResponse_element",
5200         FT_NONE, BASE_NONE, NULL, 0,
5201         NULL, HFILL }},
5202     { &hf_ldap_AttributeDescriptionList_item,
5203       { "AttributeDescription", "ldap.AttributeDescription",
5204         FT_STRING, BASE_NONE, NULL, 0,
5205         NULL, HFILL }},
5206     { &hf_ldap_attributeDesc,
5207       { "attributeDesc", "ldap.attributeDesc",
5208         FT_STRING, BASE_NONE, NULL, 0,
5209         "AttributeDescription", HFILL }},
5210     { &hf_ldap_assertionValue,
5211       { "assertionValue", "ldap.assertionValue",
5212         FT_STRING, BASE_NONE, NULL, 0,
5213         NULL, HFILL }},
5214     { &hf_ldap_type,
5215       { "type", "ldap.type",
5216         FT_STRING, BASE_NONE, NULL, 0,
5217         "AttributeDescription", HFILL }},
5218     { &hf_ldap_vals,
5219       { "vals", "ldap.vals",
5220         FT_UINT32, BASE_DEC, NULL, 0,
5221         "SET_OF_AttributeValue", HFILL }},
5222     { &hf_ldap_vals_item,
5223       { "AttributeValue", "ldap.AttributeValue",
5224         FT_BYTES, BASE_NONE, NULL, 0,
5225         NULL, HFILL }},
5226     { &hf_ldap_resultCode,
5227       { "resultCode", "ldap.resultCode",
5228         FT_UINT32, BASE_DEC, VALS(ldap_T_resultCode_vals), 0,
5229         NULL, HFILL }},
5230     { &hf_ldap_matchedDN,
5231       { "matchedDN", "ldap.matchedDN",
5232         FT_STRING, BASE_NONE, NULL, 0,
5233         "LDAPDN", HFILL }},
5234     { &hf_ldap_errorMessage,
5235       { "errorMessage", "ldap.errorMessage",
5236         FT_STRING, BASE_NONE, NULL, 0,
5237         NULL, HFILL }},
5238     { &hf_ldap_referral,
5239       { "referral", "ldap.referral",
5240         FT_UINT32, BASE_DEC, NULL, 0,
5241         NULL, HFILL }},
5242     { &hf_ldap_Referral_item,
5243       { "LDAPURL", "ldap.LDAPURL",
5244         FT_STRING, BASE_NONE, NULL, 0,
5245         NULL, HFILL }},
5246     { &hf_ldap_Controls_item,
5247       { "Control", "ldap.Control_element",
5248         FT_NONE, BASE_NONE, NULL, 0,
5249         NULL, HFILL }},
5250     { &hf_ldap_controlType,
5251       { "controlType", "ldap.controlType",
5252         FT_STRING, BASE_NONE, NULL, 0,
5253         NULL, HFILL }},
5254     { &hf_ldap_criticality,
5255       { "criticality", "ldap.criticality",
5256         FT_BOOLEAN, BASE_NONE, NULL, 0,
5257         "BOOLEAN", HFILL }},
5258     { &hf_ldap_controlValue,
5259       { "controlValue", "ldap.controlValue",
5260         FT_BYTES, BASE_NONE, NULL, 0,
5261         NULL, HFILL }},
5262     { &hf_ldap_version,
5263       { "version", "ldap.version",
5264         FT_UINT32, BASE_DEC, NULL, 0,
5265         "INTEGER_1_127", HFILL }},
5266     { &hf_ldap_name,
5267       { "name", "ldap.name",
5268         FT_STRING, BASE_NONE, NULL, 0,
5269         "LDAPDN", HFILL }},
5270     { &hf_ldap_authentication,
5271       { "authentication", "ldap.authentication",
5272         FT_UINT32, BASE_DEC, VALS(ldap_AuthenticationChoice_vals), 0,
5273         "AuthenticationChoice", HFILL }},
5274     { &hf_ldap_simple,
5275       { "simple", "ldap.simple",
5276         FT_STRING, BASE_NONE, NULL, 0,
5277         NULL, HFILL }},
5278     { &hf_ldap_sasl,
5279       { "sasl", "ldap.sasl_element",
5280         FT_NONE, BASE_NONE, NULL, 0,
5281         "SaslCredentials", HFILL }},
5282     { &hf_ldap_ntlmsspNegotiate,
5283       { "ntlmsspNegotiate", "ldap.ntlmsspNegotiate",
5284         FT_BYTES, BASE_NONE, NULL, 0,
5285         NULL, HFILL }},
5286     { &hf_ldap_ntlmsspAuth,
5287       { "ntlmsspAuth", "ldap.ntlmsspAuth",
5288         FT_BYTES, BASE_NONE, NULL, 0,
5289         NULL, HFILL }},
5290     { &hf_ldap_mechanism,
5291       { "mechanism", "ldap.mechanism",
5292         FT_STRING, BASE_NONE, NULL, 0,
5293         NULL, HFILL }},
5294     { &hf_ldap_credentials,
5295       { "credentials", "ldap.credentials",
5296         FT_BYTES, BASE_NONE, NULL, 0,
5297         NULL, HFILL }},
5298     { &hf_ldap_bindResponse_resultCode,
5299       { "resultCode", "ldap.resultCode",
5300         FT_UINT32, BASE_DEC, VALS(ldap_BindResponse_resultCode_vals), 0,
5301         "BindResponse_resultCode", HFILL }},
5302     { &hf_ldap_bindResponse_matchedDN,
5303       { "matchedDN", "ldap.matchedDN",
5304         FT_STRING, BASE_NONE, NULL, 0,
5305         "T_bindResponse_matchedDN", HFILL }},
5306     { &hf_ldap_serverSaslCreds,
5307       { "serverSaslCreds", "ldap.serverSaslCreds",
5308         FT_BYTES, BASE_NONE, NULL, 0,
5309         NULL, HFILL }},
5310     { &hf_ldap_baseObject,
5311       { "baseObject", "ldap.baseObject",
5312         FT_STRING, BASE_NONE, NULL, 0,
5313         "LDAPDN", HFILL }},
5314     { &hf_ldap_scope,
5315       { "scope", "ldap.scope",
5316         FT_UINT32, BASE_DEC, VALS(ldap_T_scope_vals), 0,
5317         NULL, HFILL }},
5318     { &hf_ldap_derefAliases,
5319       { "derefAliases", "ldap.derefAliases",
5320         FT_UINT32, BASE_DEC, VALS(ldap_T_derefAliases_vals), 0,
5321         NULL, HFILL }},
5322     { &hf_ldap_sizeLimit,
5323       { "sizeLimit", "ldap.sizeLimit",
5324         FT_UINT32, BASE_DEC, NULL, 0,
5325         "INTEGER_0_maxInt", HFILL }},
5326     { &hf_ldap_timeLimit,
5327       { "timeLimit", "ldap.timeLimit",
5328         FT_UINT32, BASE_DEC, NULL, 0,
5329         "INTEGER_0_maxInt", HFILL }},
5330     { &hf_ldap_typesOnly,
5331       { "typesOnly", "ldap.typesOnly",
5332         FT_BOOLEAN, BASE_NONE, NULL, 0,
5333         "BOOLEAN", HFILL }},
5334     { &hf_ldap_filter,
5335       { "filter", "ldap.filter",
5336         FT_UINT32, BASE_DEC, VALS(ldap_Filter_vals), 0,
5337         NULL, HFILL }},
5338     { &hf_ldap_searchRequest_attributes,
5339       { "attributes", "ldap.attributes",
5340         FT_UINT32, BASE_DEC, NULL, 0,
5341         "AttributeDescriptionList", HFILL }},
5342     { &hf_ldap_and,
5343       { "and", "ldap.and",
5344         FT_UINT32, BASE_DEC, NULL, 0,
5345         NULL, HFILL }},
5346     { &hf_ldap_and_item,
5347       { "and item", "ldap.and_item",
5348         FT_UINT32, BASE_DEC, VALS(ldap_Filter_vals), 0,
5349         NULL, HFILL }},
5350     { &hf_ldap_or,
5351       { "or", "ldap.or",
5352         FT_UINT32, BASE_DEC, NULL, 0,
5353         NULL, HFILL }},
5354     { &hf_ldap_or_item,
5355       { "or item", "ldap.or_item",
5356         FT_UINT32, BASE_DEC, VALS(ldap_Filter_vals), 0,
5357         NULL, HFILL }},
5358     { &hf_ldap_not,
5359       { "not", "ldap.not",
5360         FT_UINT32, BASE_DEC, VALS(ldap_Filter_vals), 0,
5361         NULL, HFILL }},
5362     { &hf_ldap_equalityMatch,
5363       { "equalityMatch", "ldap.equalityMatch_element",
5364         FT_NONE, BASE_NONE, NULL, 0,
5365         NULL, HFILL }},
5366     { &hf_ldap_substrings,
5367       { "substrings", "ldap.substrings_element",
5368         FT_NONE, BASE_NONE, NULL, 0,
5369         "SubstringFilter", HFILL }},
5370     { &hf_ldap_greaterOrEqual,
5371       { "greaterOrEqual", "ldap.greaterOrEqual_element",
5372         FT_NONE, BASE_NONE, NULL, 0,
5373         NULL, HFILL }},
5374     { &hf_ldap_lessOrEqual,
5375       { "lessOrEqual", "ldap.lessOrEqual_element",
5376         FT_NONE, BASE_NONE, NULL, 0,
5377         NULL, HFILL }},
5378     { &hf_ldap_present,
5379       { "present", "ldap.present",
5380         FT_STRING, BASE_NONE, NULL, 0,
5381         NULL, HFILL }},
5382     { &hf_ldap_approxMatch,
5383       { "approxMatch", "ldap.approxMatch_element",
5384         FT_NONE, BASE_NONE, NULL, 0,
5385         NULL, HFILL }},
5386     { &hf_ldap_extensibleMatch,
5387       { "extensibleMatch", "ldap.extensibleMatch_element",
5388         FT_NONE, BASE_NONE, NULL, 0,
5389         NULL, HFILL }},
5390     { &hf_ldap_substringFilter_substrings,
5391       { "substrings", "ldap.substrings",
5392         FT_UINT32, BASE_DEC, NULL, 0,
5393         "T_substringFilter_substrings", HFILL }},
5394     { &hf_ldap_substringFilter_substrings_item,
5395       { "substrings item", "ldap.substrings_item",
5396         FT_UINT32, BASE_DEC, VALS(ldap_T_substringFilter_substrings_item_vals), 0,
5397         "T_substringFilter_substrings_item", HFILL }},
5398     { &hf_ldap_initial,
5399       { "initial", "ldap.initial",
5400         FT_STRING, BASE_NONE, NULL, 0,
5401         "LDAPString", HFILL }},
5402     { &hf_ldap_any,
5403       { "any", "ldap.any",
5404         FT_STRING, BASE_NONE, NULL, 0,
5405         "LDAPString", HFILL }},
5406     { &hf_ldap_final,
5407       { "final", "ldap.final",
5408         FT_STRING, BASE_NONE, NULL, 0,
5409         "LDAPString", HFILL }},
5410     { &hf_ldap_matchingRule,
5411       { "matchingRule", "ldap.matchingRule",
5412         FT_STRING, BASE_NONE, NULL, 0,
5413         "MatchingRuleId", HFILL }},
5414     { &hf_ldap_matchValue,
5415       { "matchValue", "ldap.matchValue",
5416         FT_STRING, BASE_NONE, NULL, 0,
5417         "AssertionValue", HFILL }},
5418     { &hf_ldap_dnAttributes,
5419       { "dnAttributes", "ldap.dnAttributes",
5420         FT_BOOLEAN, BASE_NONE, NULL, 0,
5421         NULL, HFILL }},
5422     { &hf_ldap_objectName,
5423       { "objectName", "ldap.objectName",
5424         FT_STRING, BASE_NONE, NULL, 0,
5425         "LDAPDN", HFILL }},
5426     { &hf_ldap_searchResultEntry_attributes,
5427       { "attributes", "ldap.attributes",
5428         FT_UINT32, BASE_DEC, NULL, 0,
5429         "PartialAttributeList", HFILL }},
5430     { &hf_ldap_PartialAttributeList_item,
5431       { "PartialAttributeList item", "ldap.PartialAttributeList_item_element",
5432         FT_NONE, BASE_NONE, NULL, 0,
5433         NULL, HFILL }},
5434     { &hf_ldap__untag_item,
5435       { "LDAPURL", "ldap.LDAPURL",
5436         FT_STRING, BASE_NONE, NULL, 0,
5437         NULL, HFILL }},
5438     { &hf_ldap_object,
5439       { "object", "ldap.object",
5440         FT_STRING, BASE_NONE, NULL, 0,
5441         "LDAPDN", HFILL }},
5442     { &hf_ldap_modifyRequest_modification,
5443       { "modification", "ldap.modification",
5444         FT_UINT32, BASE_DEC, NULL, 0,
5445         "ModifyRequest_modification", HFILL }},
5446     { &hf_ldap_modifyRequest_modification_item,
5447       { "modification item", "ldap.modification_item_element",
5448         FT_NONE, BASE_NONE, NULL, 0,
5449         "T_modifyRequest_modification_item", HFILL }},
5450     { &hf_ldap_operation,
5451       { "operation", "ldap.operation",
5452         FT_UINT32, BASE_DEC, VALS(ldap_T_operation_vals), 0,
5453         NULL, HFILL }},
5454     { &hf_ldap_modification,
5455       { "modification", "ldap.modification_element",
5456         FT_NONE, BASE_NONE, NULL, 0,
5457         "AttributeTypeAndValues", HFILL }},
5458     { &hf_ldap_entry,
5459       { "entry", "ldap.entry",
5460         FT_STRING, BASE_NONE, NULL, 0,
5461         "LDAPDN", HFILL }},
5462     { &hf_ldap_attributes,
5463       { "attributes", "ldap.attributes",
5464         FT_UINT32, BASE_DEC, NULL, 0,
5465         "AttributeList", HFILL }},
5466     { &hf_ldap_AttributeList_item,
5467       { "AttributeList item", "ldap.AttributeList_item_element",
5468         FT_NONE, BASE_NONE, NULL, 0,
5469         NULL, HFILL }},
5470     { &hf_ldap_newrdn,
5471       { "newrdn", "ldap.newrdn",
5472         FT_STRING, BASE_NONE, NULL, 0,
5473         "RelativeLDAPDN", HFILL }},
5474     { &hf_ldap_deleteoldrdn,
5475       { "deleteoldrdn", "ldap.deleteoldrdn",
5476         FT_BOOLEAN, BASE_NONE, NULL, 0,
5477         "BOOLEAN", HFILL }},
5478     { &hf_ldap_newSuperior,
5479       { "newSuperior", "ldap.newSuperior",
5480         FT_STRING, BASE_NONE, NULL, 0,
5481         "LDAPDN", HFILL }},
5482     { &hf_ldap_ava,
5483       { "ava", "ldap.ava_element",
5484         FT_NONE, BASE_NONE, NULL, 0,
5485         "AttributeValueAssertion", HFILL }},
5486     { &hf_ldap_requestName,
5487       { "requestName", "ldap.requestName",
5488         FT_STRING, BASE_NONE, NULL, 0,
5489         "LDAPOID", HFILL }},
5490     { &hf_ldap_requestValue,
5491       { "requestValue", "ldap.requestValue",
5492         FT_BYTES, BASE_NONE, NULL, 0,
5493         NULL, HFILL }},
5494     { &hf_ldap_extendedResponse_resultCode,
5495       { "resultCode", "ldap.resultCode",
5496         FT_UINT32, BASE_DEC, VALS(ldap_ExtendedResponse_resultCode_vals), 0,
5497         "ExtendedResponse_resultCode", HFILL }},
5498     { &hf_ldap_responseName,
5499       { "responseName", "ldap.responseName",
5500         FT_STRING, BASE_NONE, NULL, 0,
5501         NULL, HFILL }},
5502     { &hf_ldap_response,
5503       { "response", "ldap.response",
5504         FT_BYTES, BASE_NONE, NULL, 0,
5505         "OCTET_STRING", HFILL }},
5506     { &hf_ldap_intermediateResponse_responseValue,
5507       { "responseValue", "ldap.responseValue",
5508         FT_BYTES, BASE_NONE, NULL, 0,
5509         "T_intermediateResponse_responseValue", HFILL }},
5510     { &hf_ldap_size,
5511       { "size", "ldap.size",
5512         FT_INT32, BASE_DEC, NULL, 0,
5513         "INTEGER", HFILL }},
5514     { &hf_ldap_cookie,
5515       { "cookie", "ldap.cookie",
5516         FT_BYTES, BASE_NONE, NULL, 0,
5517         "OCTET_STRING", HFILL }},
5518     { &hf_ldap_SortKeyList_item,
5519       { "SortKeyList item", "ldap.SortKeyList_item_element",
5520         FT_NONE, BASE_NONE, NULL, 0,
5521         NULL, HFILL }},
5522     { &hf_ldap_attributeType,
5523       { "attributeType", "ldap.attributeType",
5524         FT_STRING, BASE_NONE, NULL, 0,
5525         "AttributeDescription", HFILL }},
5526     { &hf_ldap_orderingRule,
5527       { "orderingRule", "ldap.orderingRule",
5528         FT_STRING, BASE_NONE, NULL, 0,
5529         "MatchingRuleId", HFILL }},
5530     { &hf_ldap_reverseOrder,
5531       { "reverseOrder", "ldap.reverseOrder",
5532         FT_BOOLEAN, BASE_NONE, NULL, 0,
5533         "BOOLEAN", HFILL }},
5534     { &hf_ldap_sortResult,
5535       { "sortResult", "ldap.sortResult",
5536         FT_UINT32, BASE_DEC, VALS(ldap_T_sortResult_vals), 0,
5537         NULL, HFILL }},
5538     { &hf_ldap_flags,
5539       { "flags", "ldap.flags",
5540         FT_UINT32, BASE_HEX, NULL, 0,
5541         "DirSyncFlags", HFILL }},
5542     { &hf_ldap_maxBytes,
5543       { "maxBytes", "ldap.maxBytes",
5544         FT_INT32, BASE_DEC, NULL, 0,
5545         "INTEGER", HFILL }},
5546     { &hf_ldap_userIdentity,
5547       { "userIdentity", "ldap.userIdentity",
5548         FT_BYTES, BASE_NONE, NULL, 0,
5549         "OCTET_STRING", HFILL }},
5550     { &hf_ldap_oldPasswd,
5551       { "oldPasswd", "ldap.oldPasswd",
5552         FT_BYTES, BASE_NONE, NULL, 0,
5553         "OCTET_STRING", HFILL }},
5554     { &hf_ldap_newPasswd,
5555       { "newPasswd", "ldap.newPasswd",
5556         FT_BYTES, BASE_NONE, NULL, 0,
5557         "OCTET_STRING", HFILL }},
5558     { &hf_ldap_cancelID,
5559       { "cancelID", "ldap.cancelID",
5560         FT_UINT32, BASE_DEC, NULL, 0,
5561         "MessageID", HFILL }},
5562     { &hf_ldap_mode,
5563       { "mode", "ldap.mode",
5564         FT_UINT32, BASE_DEC, VALS(ldap_T_mode_vals), 0,
5565         NULL, HFILL }},
5566     { &hf_ldap_reloadHint,
5567       { "reloadHint", "ldap.reloadHint",
5568         FT_BOOLEAN, BASE_NONE, NULL, 0,
5569         "BOOLEAN", HFILL }},
5570     { &hf_ldap_state,
5571       { "state", "ldap.state",
5572         FT_UINT32, BASE_DEC, VALS(ldap_T_state_vals), 0,
5573         NULL, HFILL }},
5574     { &hf_ldap_entryUUID,
5575       { "entryUUID", "ldap.entryUUID",
5576         FT_BYTES, BASE_NONE, NULL, 0,
5577         "SyncUUID", HFILL }},
5578     { &hf_ldap_refreshDeletes,
5579       { "refreshDeletes", "ldap.refreshDeletes",
5580         FT_BOOLEAN, BASE_NONE, NULL, 0,
5581         "BOOLEAN", HFILL }},
5582     { &hf_ldap_newcookie,
5583       { "newcookie", "ldap.newcookie",
5584         FT_BYTES, BASE_NONE, NULL, 0,
5585         "OCTET_STRING", HFILL }},
5586     { &hf_ldap_refreshDelete,
5587       { "refreshDelete", "ldap.refreshDelete_element",
5588         FT_NONE, BASE_NONE, NULL, 0,
5589         NULL, HFILL }},
5590     { &hf_ldap_refreshDone,
5591       { "refreshDone", "ldap.refreshDone",
5592         FT_BOOLEAN, BASE_NONE, NULL, 0,
5593         "BOOLEAN", HFILL }},
5594     { &hf_ldap_refreshPresent,
5595       { "refreshPresent", "ldap.refreshPresent_element",
5596         FT_NONE, BASE_NONE, NULL, 0,
5597         NULL, HFILL }},
5598     { &hf_ldap_syncIdSet,
5599       { "syncIdSet", "ldap.syncIdSet_element",
5600         FT_NONE, BASE_NONE, NULL, 0,
5601         NULL, HFILL }},
5602     { &hf_ldap_syncUUIDs,
5603       { "syncUUIDs", "ldap.syncUUIDs",
5604         FT_UINT32, BASE_DEC, NULL, 0,
5605         "SET_OF_SyncUUID", HFILL }},
5606     { &hf_ldap_syncUUIDs_item,
5607       { "SyncUUID", "ldap.SyncUUID",
5608         FT_BYTES, BASE_NONE, NULL, 0,
5609         NULL, HFILL }},
5610     { &hf_ldap_warning,
5611       { "warning", "ldap.warning",
5612         FT_UINT32, BASE_DEC, VALS(ldap_T_warning_vals), 0,
5613         NULL, HFILL }},
5614     { &hf_ldap_timeBeforeExpiration,
5615       { "timeBeforeExpiration", "ldap.timeBeforeExpiration",
5616         FT_UINT32, BASE_DEC, NULL, 0,
5617         "INTEGER_0_maxInt", HFILL }},
5618     { &hf_ldap_graceAuthNsRemaining,
5619       { "graceAuthNsRemaining", "ldap.graceAuthNsRemaining",
5620         FT_UINT32, BASE_DEC, NULL, 0,
5621         "INTEGER_0_maxInt", HFILL }},
5622     { &hf_ldap_error,
5623       { "error", "ldap.error",
5624         FT_UINT32, BASE_DEC, VALS(ldap_T_error_vals), 0,
5625         NULL, HFILL }},
5626
5627 /*--- End of included file: packet-ldap-hfarr.c ---*/
5628 #line 2142 "./asn1/ldap/packet-ldap-template.c"
5629   };
5630
5631   /* List of subtrees */
5632   static gint *ett[] = {
5633     &ett_ldap,
5634     &ett_ldap_payload,
5635     &ett_ldap_sasl_blob,
5636     &ett_ldap_msg,
5637     &ett_mscldap_netlogon_flags,
5638     &ett_mscldap_ntver_flags,
5639     &ett_mscldap_ipdetails,
5640     &ett_ldap_DirSyncFlagsSubEntry,
5641
5642
5643 /*--- Included file: packet-ldap-ettarr.c ---*/
5644 #line 1 "./asn1/ldap/packet-ldap-ettarr.c"
5645     &ett_ldap_LDAPMessage,
5646     &ett_ldap_ProtocolOp,
5647     &ett_ldap_AttributeDescriptionList,
5648     &ett_ldap_AttributeValueAssertion,
5649     &ett_ldap_Attribute,
5650     &ett_ldap_SET_OF_AttributeValue,
5651     &ett_ldap_LDAPResult,
5652     &ett_ldap_Referral,
5653     &ett_ldap_Controls,
5654     &ett_ldap_Control,
5655     &ett_ldap_BindRequest_U,
5656     &ett_ldap_AuthenticationChoice,
5657     &ett_ldap_SaslCredentials,
5658     &ett_ldap_BindResponse_U,
5659     &ett_ldap_SearchRequest_U,
5660     &ett_ldap_Filter,
5661     &ett_ldap_T_and,
5662     &ett_ldap_T_or,
5663     &ett_ldap_SubstringFilter,
5664     &ett_ldap_T_substringFilter_substrings,
5665     &ett_ldap_T_substringFilter_substrings_item,
5666     &ett_ldap_MatchingRuleAssertion,
5667     &ett_ldap_SearchResultEntry_U,
5668     &ett_ldap_PartialAttributeList,
5669     &ett_ldap_PartialAttributeList_item,
5670     &ett_ldap_SEQUENCE_OF_LDAPURL,
5671     &ett_ldap_ModifyRequest_U,
5672     &ett_ldap_ModifyRequest_modification,
5673     &ett_ldap_T_modifyRequest_modification_item,
5674     &ett_ldap_AttributeTypeAndValues,
5675     &ett_ldap_AddRequest_U,
5676     &ett_ldap_AttributeList,
5677     &ett_ldap_AttributeList_item,
5678     &ett_ldap_ModifyDNRequest_U,
5679     &ett_ldap_CompareRequest_U,
5680     &ett_ldap_ExtendedRequest_U,
5681     &ett_ldap_ExtendedResponse_U,
5682     &ett_ldap_IntermediateResponse_U,
5683     &ett_ldap_SearchControlValue,
5684     &ett_ldap_SortKeyList,
5685     &ett_ldap_SortKeyList_item,
5686     &ett_ldap_SortResult,
5687     &ett_ldap_DirSyncControlValue,
5688     &ett_ldap_PasswdModifyRequestValue,
5689     &ett_ldap_CancelRequestValue,
5690     &ett_ldap_SyncRequestValue,
5691     &ett_ldap_SyncStateValue,
5692     &ett_ldap_SyncDoneValue,
5693     &ett_ldap_SyncInfoValue,
5694     &ett_ldap_T_refreshDelete,
5695     &ett_ldap_T_refreshPresent,
5696     &ett_ldap_T_syncIdSet,
5697     &ett_ldap_SET_OF_SyncUUID,
5698     &ett_ldap_PasswordPolicyResponseValue,
5699     &ett_ldap_T_warning,
5700
5701 /*--- End of included file: packet-ldap-ettarr.c ---*/
5702 #line 2156 "./asn1/ldap/packet-ldap-template.c"
5703   };
5704   /* UAT for header fields */
5705   static uat_field_t custom_attribute_types_uat_fields[] = {
5706      UAT_FLD_CSTRING(attribute_types, attribute_type, "Attribute type", "Attribute type"),
5707      UAT_FLD_CSTRING(attribute_types, attribute_desc, "Description", "Description of the value matching type"),
5708      UAT_END_FIELDS
5709   };
5710
5711   static ei_register_info ei[] = {
5712      { &ei_ldap_exceeded_filter_length, { "ldap.exceeded_filter_length", PI_UNDECODED, PI_ERROR, "Filter length exceeds number. Giving up", EXPFILL }},
5713      { &ei_ldap_too_many_filter_elements, { "ldap.too_many_filter_elements", PI_UNDECODED, PI_ERROR, "Found more than %%u filter elements. Giving up.", EXPFILL }},
5714   };
5715
5716   expert_module_t* expert_ldap;
5717   module_t *ldap_module;
5718   uat_t *attributes_uat;
5719
5720   /* Register protocol */
5721   proto_ldap = proto_register_protocol(PNAME, PSNAME, PFNAME);
5722   /* Register fields and subtrees */
5723   proto_register_field_array(proto_ldap, hf, array_length(hf));
5724   proto_register_subtree_array(ett, array_length(ett));
5725   expert_ldap = expert_register_protocol(proto_ldap);
5726   expert_register_field_array(expert_ldap, ei, array_length(ei));
5727
5728   ldap_handle = register_dissector("ldap", dissect_ldap_tcp, proto_ldap);
5729
5730   ldap_module = prefs_register_protocol(proto_ldap, prefs_register_ldap);
5731   prefs_register_bool_preference(ldap_module, "desegment_ldap_messages",
5732     "Reassemble LDAP messages spanning multiple TCP segments",
5733     "Whether the LDAP dissector should reassemble messages spanning multiple TCP segments."
5734     " To use this option, you must also enable \"Allow subdissectors to reassemble TCP streams\" in the TCP protocol settings.",
5735     &ldap_desegment);
5736
5737   prefs_register_uint_preference(ldap_module, "ssl.port", "LDAPS TCP Port",
5738                                  "Set the port for LDAP operations over SSL",
5739                                  10, &global_ldaps_tcp_port);
5740   /* UAT */
5741   attributes_uat = uat_new("Custom LDAP AttributeValue types",
5742                            sizeof(attribute_type_t),
5743                            "custom_ldap_attribute_types",
5744                            TRUE,
5745                            &attribute_types,
5746                            &num_attribute_types,
5747                            /* specifies named fields, so affects dissection
5748                               and the set of named fields */
5749                            UAT_AFFECTS_DISSECTION|UAT_AFFECTS_FIELDS,
5750                            NULL,
5751                            attribute_types_copy_cb,
5752                            attribute_types_update_cb,
5753                            attribute_types_free_cb,
5754                            attribute_types_initialize_cb,
5755                            NULL,
5756                            custom_attribute_types_uat_fields);
5757
5758   prefs_register_uat_preference(ldap_module, "custom_ldap_attribute_types",
5759                                 "Custom AttributeValue types",
5760                                 "A table to define custom LDAP attribute type values for which fields can be setup and used for filtering/data extraction etc.",
5761                                 attributes_uat);
5762
5763   prefs_register_obsolete_preference(ldap_module, "max_pdu");
5764
5765   proto_cldap = proto_register_protocol(
5766           "Connectionless Lightweight Directory Access Protocol",
5767           "CLDAP", "cldap");
5768
5769   ldap_tap=register_tap("ldap");
5770
5771   ldap_name_dissector_table = register_dissector_table("ldap.name", "LDAP Attribute Type Dissectors", proto_cldap, FT_STRING, BASE_NONE);
5772
5773   register_srt_table(proto_ldap, NULL, 1, ldapstat_packet, ldapstat_init, NULL);
5774 }
5775
5776
5777 /*--- proto_reg_handoff_ldap ---------------------------------------*/
5778 void
5779 proto_reg_handoff_ldap(void)
5780 {
5781   dissector_handle_t cldap_handle;
5782
5783   cldap_handle = create_dissector_handle(dissect_mscldap, proto_cldap);
5784   dissector_add_uint_with_preference("udp.port", UDP_PORT_CLDAP, cldap_handle);
5785
5786   gssapi_handle = find_dissector_add_dependency("gssapi", proto_ldap);
5787   gssapi_wrap_handle = find_dissector_add_dependency("gssapi_verf", proto_ldap);
5788   spnego_handle = find_dissector_add_dependency("spnego", proto_ldap);
5789
5790   ntlmssp_handle = find_dissector_add_dependency("ntlmssp", proto_ldap);
5791
5792   ssl_handle = find_dissector_add_dependency("ssl", proto_ldap);
5793
5794   prefs_register_ldap();
5795
5796   oid_add_from_string("ISO assigned OIDs, USA",                                                     "1.2.840");
5797
5798 /*  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dsml/dsml/ldap_controls_and_session_support.asp */
5799   oid_add_from_string("LDAP_PAGED_RESULT_OID_STRING","1.2.840.113556.1.4.319");
5800   oid_add_from_string("LDAP_SERVER_SHOW_DELETED_OID","1.2.840.113556.1.4.417");
5801   oid_add_from_string("LDAP_SERVER_SORT_OID","1.2.840.113556.1.4.473");
5802   oid_add_from_string("LDAP_CONTROL_SORT_RESP_OID","1.2.840.113556.1.4.474");
5803   oid_add_from_string("LDAP_SERVER_CROSSDOM_MOVE_TARGET_OID","1.2.840.113556.1.4.521");
5804   oid_add_from_string("LDAP_SERVER_NOTIFICATION_OID","1.2.840.113556.1.4.528");
5805   oid_add_from_string("LDAP_SERVER_EXTENDED_DN_OID","1.2.840.113556.1.4.529");
5806   oid_add_from_string("meetingAdvertiseScope","1.2.840.113556.1.4.582");
5807   oid_add_from_string("LDAP_SERVER_LAZY_COMMIT_OID","1.2.840.113556.1.4.619");
5808   oid_add_from_string("mhsORAddress","1.2.840.113556.1.4.650");
5809   oid_add_from_string("managedObjects","1.2.840.113556.1.4.654");
5810   oid_add_from_string("LDAP_CAP_ACTIVE_DIRECTORY_OID","1.2.840.113556.1.4.800");
5811   oid_add_from_string("LDAP_SERVER_SD_FLAGS_OID","1.2.840.113556.1.4.801");
5812   oid_add_from_string("LDAP_OID_COMPARATOR_OR","1.2.840.113556.1.4.804");
5813   oid_add_from_string("LDAP_SERVER_TREE_DELETE_OID","1.2.840.113556.1.4.805");
5814   oid_add_from_string("LDAP_SERVER_DIRSYNC_OID","1.2.840.113556.1.4.841");
5815   oid_add_from_string("None","1.2.840.113556.1.4.970");
5816   oid_add_from_string("LDAP_SERVER_VERIFY_NAME_OID","1.2.840.113556.1.4.1338");
5817   oid_add_from_string("LDAP_SERVER_DOMAIN_SCOPE_OID","1.2.840.113556.1.4.1339");
5818   oid_add_from_string("LDAP_SERVER_SEARCH_OPTIONS_OID","1.2.840.113556.1.4.1340");
5819   oid_add_from_string("LDAP_SERVER_PERMISSIVE_MODIFY_OID","1.2.840.113556.1.4.1413");
5820   oid_add_from_string("LDAP_SERVER_ASQ_OID","1.2.840.113556.1.4.1504");
5821   oid_add_from_string("LDAP_CAP_ACTIVE_DIRECTORY_V51_OID","1.2.840.113556.1.4.1670");
5822   oid_add_from_string("LDAP_SERVER_FAST_BIND_OID","1.2.840.113556.1.4.1781");
5823   oid_add_from_string("LDAP_CAP_ACTIVE_DIRECTORY_LDAP_INTEG_OID","1.2.840.113556.1.4.1791");
5824   oid_add_from_string("msDS-ObjectReference","1.2.840.113556.1.4.1840");
5825   oid_add_from_string("msDS-QuotaEffective","1.2.840.113556.1.4.1848");
5826   oid_add_from_string("LDAP_CAP_ACTIVE_DIRECTORY_ADAM_OID","1.2.840.113556.1.4.1851");
5827   oid_add_from_string("msDS-PortSSL","1.2.840.113556.1.4.1860");
5828   oid_add_from_string("msDS-isRODC","1.2.840.113556.1.4.1960");
5829   oid_add_from_string("msDS-SDReferenceDomain","1.2.840.113556.1.4.1711");
5830   oid_add_from_string("msDS-AdditionalDnsHostName","1.2.840.113556.1.4.1717");
5831   oid_add_from_string("None","1.3.6.1.4.1.1466.101.119.1");
5832   oid_add_from_string("LDAP_START_TLS_OID","1.3.6.1.4.1.1466.20037");
5833
5834   oid_add_from_string("inetOrgPerson", "2.16.840.1.113730.3.2.2");
5835   /* RFC2798 */
5836   oid_add_from_string("US company arc",                                                             "2.16.840.1");
5837
5838   /* http://www.alvestrand.no/objectid/2.16.840.1.113730.3.4.html */
5839   oid_add_from_string("Manage DSA IT LDAPv3 control",                                               "2.16.840.1.113730.3.4.2");
5840   oid_add_from_string("Persistent Search LDAPv3 control",                                           "2.16.840.1.113730.3.4.3");
5841   oid_add_from_string("Netscape Password Expired LDAPv3 control",                                   "2.16.840.1.113730.3.4.4");
5842   oid_add_from_string("Netscape Password Expiring LDAPv3 control",                                  "2.16.840.1.113730.3.4.5");
5843   oid_add_from_string("Netscape NT Synchronization Client LDAPv3 control",                          "2.16.840.1.113730.3.4.6");
5844   oid_add_from_string("Entry Change Notification LDAPv3 control",                                   "2.16.840.1.113730.3.4.7");
5845   oid_add_from_string("Transaction ID Request Control",                                             "2.16.840.1.113730.3.4.8");
5846   oid_add_from_string("VLV Request LDAPv3 control",                                                 "2.16.840.1.113730.3.4.9");
5847   oid_add_from_string("VLV Response LDAPv3 control",                                                "2.16.840.1.113730.3.4.10");
5848   oid_add_from_string("Transaction ID Response Control",                                            "2.16.840.1.113730.3.4.11");
5849   oid_add_from_string("Proxied Authorization (version 1) control",                                  "2.16.840.1.113730.3.4.12");
5850   oid_add_from_string("iPlanet Directory Server Replication Update Information Control",            "2.16.840.1.113730.3.4.13");
5851   oid_add_from_string("iPlanet Directory Server search on specific backend control",                "2.16.840.1.113730.3.4.14");
5852   oid_add_from_string("Authentication Response Control",                                            "2.16.840.1.113730.3.4.15");
5853   oid_add_from_string("Authentication Request Control",                                             "2.16.840.1.113730.3.4.16");
5854   oid_add_from_string("Real Attributes Only Request Control",                                       "2.16.840.1.113730.3.4.17");
5855   oid_add_from_string("Proxied Authorization (version 2) Control",                                  "2.16.840.1.113730.3.4.18");
5856   oid_add_from_string("Chaining loop detection",                                                    "2.16.840.1.113730.3.4.19");
5857   oid_add_from_string("iPlanet Replication Modrdn Extra Mods Control",                              "2.16.840.1.113730.3.4.999");
5858
5859
5860   oid_add_from_string("LDAP_SERVER_QUOTA_CONTROL_OID",         "1.2.840.113556.1.4.1852");
5861   oid_add_from_string("LDAP_SERVER_RANGE_OPTION_OID",          "1.2.840.113556.1.4.802");
5862   oid_add_from_string("LDAP_SERVER_SHUTDOWN_NOTIFY_OID",       "1.2.840.113556.1.4.1907");
5863   oid_add_from_string("LDAP_SERVER_RANGE_RETRIEVAL_NOERR_OID", "1.2.840.113556.1.4.1948");
5864
5865
5866   dissector_add_string("ldap.name", "netlogon", create_dissector_handle(dissect_NetLogon_PDU, proto_cldap));
5867   dissector_add_string("ldap.name", "objectGUID", create_dissector_handle(dissect_ldap_guid, proto_ldap));
5868   dissector_add_string("ldap.name", "supportedControl", create_dissector_handle(dissect_ldap_oid, proto_ldap));
5869   dissector_add_string("ldap.name", "supportedCapabilities", create_dissector_handle(dissect_ldap_oid, proto_ldap));
5870   dissector_add_string("ldap.name", "objectSid", create_dissector_handle(dissect_ldap_sid, proto_ldap));
5871   dissector_add_string("ldap.name", "nTSecurityDescriptor", create_dissector_handle(dissect_ldap_nt_sec_desc, proto_ldap));
5872
5873
5874 /*--- Included file: packet-ldap-dis-tab.c ---*/
5875 #line 1 "./asn1/ldap/packet-ldap-dis-tab.c"
5876   register_ber_oid_dissector("1.2.840.113556.1.4.319", dissect_SearchControlValue_PDU, proto_ldap, "pagedResultsControl");
5877   register_ber_oid_dissector("1.2.840.113556.1.4.473", dissect_SortKeyList_PDU, proto_ldap, "sortKeyList");
5878   register_ber_oid_dissector("1.2.840.113556.1.4.474", dissect_SortResult_PDU, proto_ldap, "sortResult");
5879   register_ber_oid_dissector("1.2.840.113556.1.4.841", dissect_DirSyncControlValue_PDU, proto_ldap, "dirsync");
5880   register_ber_oid_dissector("1.3.6.1.4.1.4203.1.11.1", dissect_PasswdModifyRequestValue_PDU, proto_ldap, "passwdModifyOID");
5881   register_ber_oid_dissector("1.3.6.1.1.8", dissect_CancelRequestValue_PDU, proto_ldap, "cancelRequestOID");
5882   register_ber_oid_dissector("1.3.6.1.4.1.4203.1.9.1.1", dissect_SyncRequestValue_PDU, proto_ldap, "syncRequestOID");
5883   register_ber_oid_dissector("1.3.6.1.4.1.4203.1.9.1.2", dissect_SyncStateValue_PDU, proto_ldap, "syncStateOID");
5884   register_ber_oid_dissector("1.3.6.1.4.1.4203.1.9.1.3", dissect_SyncDoneValue_PDU, proto_ldap, "syncDoneOID");
5885   register_ber_oid_dissector("1.3.6.1.4.1.4203.1.9.1.4", dissect_SyncInfoValue_PDU, proto_ldap, "syncInfoOID");
5886   register_ber_oid_dissector("1.3.6.1.4.1.42.2.27.8.5.1", dissect_PasswordPolicyResponseValue_PDU, proto_ldap, "passwordPolicy");
5887
5888
5889 /*--- End of included file: packet-ldap-dis-tab.c ---*/
5890 #line 2327 "./asn1/ldap/packet-ldap-template.c"
5891
5892  dissector_add_uint_range_with_preference("tcp.port", TCP_PORT_RANGE_LDAP, ldap_handle);
5893 }
5894
5895 static void
5896 prefs_register_ldap(void)
5897 {
5898   if(ssl_port != global_ldaps_tcp_port) {
5899     if(ssl_port)
5900       ssl_dissector_delete(ssl_port, ldap_handle);
5901
5902     /* Set our port number for future use */
5903     ssl_port = global_ldaps_tcp_port;
5904
5905     if(ssl_port)
5906       ssl_dissector_add(ssl_port, ldap_handle);
5907   }
5908
5909 }
5910
5911 /*
5912  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
5913  *
5914  * Local Variables:
5915  * c-basic-offset: 2
5916  * tab-width: 8
5917  * indent-tabs-mode: nil
5918  * End:
5919  *
5920  * vi: set shiftwidth=2 tabstop=8 expandtab:
5921  * :indentSize=2:tabSize=8:noTabs=true:
5922  */