s4:lib/tevent: rename structs
[kai/samba.git] / source4 / libcli / cldap / cldap.c
index 614bd51d2af928085d7505402c0b4a77efb56fdd..556f9bcec3f987e5fdf8921704d61ad444d656ab 100644 (file)
 
 #include "includes.h"
 #include "lib/events/events.h"
-#include "lib/util/dlinklist.h"
+#include "../lib/util/dlinklist.h"
 #include "libcli/ldap/ldap.h"
 #include "libcli/ldap/ldap_ndr.h"
 #include "libcli/cldap/cldap.h"
 #include "lib/socket/socket.h"
 #include "libcli/security/security.h"
 #include "librpc/gen_ndr/ndr_nbt.h"
-#include "param/param.h"
 
 /*
   destroy a pending request
@@ -145,8 +144,8 @@ static void cldap_socket_recv(struct cldap_socket *cldap)
 /*
   handle request timeouts
 */
-static void cldap_request_timeout(struct event_context *event_ctx, 
-                                 struct timed_event *te, struct timeval t,
+static void cldap_request_timeout(struct tevent_context *event_ctx, 
+                                 struct tevent_timer *te, struct timeval t,
                                  void *private)
 {
        struct cldap_request *req = talloc_get_type(private, struct cldap_request);
@@ -224,7 +223,7 @@ static void cldap_socket_send(struct cldap_socket *cldap)
 /*
   handle fd events on a cldap_socket
 */
-static void cldap_socket_handler(struct event_context *ev, struct fd_event *fde,
+static void cldap_socket_handler(struct tevent_context *ev, struct tevent_fd *fde,
                                 uint16_t flags, void *private)
 {
        struct cldap_socket *cldap = talloc_get_type(private, struct cldap_socket);
@@ -241,7 +240,7 @@ static void cldap_socket_handler(struct event_context *ev, struct fd_event *fde,
   then operations will use that event context
 */
 struct cldap_socket *cldap_socket_init(TALLOC_CTX *mem_ctx, 
-                                      struct event_context *event_ctx,
+                                      struct tevent_context *event_ctx,
                                       struct smb_iconv_convenience *iconv_convenience)
 {
        struct cldap_socket *cldap;
@@ -595,7 +594,6 @@ NTSTATUS cldap_netlogon_recv(struct cldap_request *req,
                             struct cldap_netlogon *io)
 {
        NTSTATUS status;
-       enum ndr_err_code ndr_err;
        struct cldap_search search;
        struct cldap_socket *cldap;
        DATA_BLOB *data;
@@ -618,18 +616,15 @@ NTSTATUS cldap_netlogon_recv(struct cldap_request *req,
        }
        data = search.out.response->attributes[0].values;
 
-       ndr_err = ndr_pull_union_blob_all(data, mem_ctx, 
-                                         cldap->iconv_convenience,
-                                         &io->out.netlogon,
-                                         io->in.version & 0xF,
-                                         (ndr_pull_flags_fn_t)ndr_pull_nbt_cldap_netlogon);
-       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
-               DEBUG(2,("cldap failed to parse netlogon response of type 0x%02x\n",
-                        SVAL(data->data, 0)));
-               dump_data(10, data->data, data->length);
-               return ndr_map_error2ntstatus(ndr_err);
+       status = pull_netlogon_samlogon_response(data, mem_ctx, req->cldap->iconv_convenience,
+                                                &io->out.netlogon);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+       
+       if (io->in.map_response) {
+               map_netlogon_samlogon_response(&io->out.netlogon);
        }
-
        return NT_STATUS_OK;
 }
 
@@ -704,25 +699,20 @@ NTSTATUS cldap_netlogon_reply(struct cldap_socket *cldap,
                              uint32_t message_id,
                              struct socket_address *src,
                              uint32_t version,
-                             union nbt_cldap_netlogon *netlogon)
+                             struct netlogon_samlogon_response *netlogon)
 {
        NTSTATUS status;
-       enum ndr_err_code ndr_err;
        struct cldap_reply reply;
        struct ldap_SearchResEntry response;
        struct ldap_Result result;
        TALLOC_CTX *tmp_ctx = talloc_new(cldap);
        DATA_BLOB blob;
 
-       ndr_err = ndr_push_union_blob(&blob, tmp_ctx, 
-                                     cldap->iconv_convenience,
-                                     netlogon, version & 0xF,
-                                    (ndr_push_flags_fn_t)ndr_push_nbt_cldap_netlogon);
-       if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
-               talloc_free(tmp_ctx);
-               return ndr_map_error2ntstatus(ndr_err);
+       status = push_netlogon_samlogon_response(&blob, tmp_ctx, cldap->iconv_convenience,
+                                                netlogon);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
        }
-
        reply.messageid    = message_id;
        reply.dest         = src;
        reply.response     = &response;