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