Merge branch 'master' of ssh://git.samba.org/data/git/samba
[ira/wip.git] / source4 / libcli / raw / clitransport.c
index db43c9e20c911a987702008572ef8585bde8b360..5cf0272e88469b774a898c25ba43127aaf42db4a 100644 (file)
 #include "lib/events/events.h"
 #include "lib/stream/packet.h"
 #include "librpc/gen_ndr/ndr_nbt.h"
-#include "param/param.h"
 #include "../libcli/nbt/libnbt.h"
 
 
 /*
   an event has happened on the socket
 */
-static void smbcli_transport_event_handler(struct event_context *ev, 
-                                          struct fd_event *fde, 
-                                          uint16_t flags, void *private)
+static void smbcli_transport_event_handler(struct tevent_context *ev, 
+                                          struct tevent_fd *fde, 
+                                          uint16_t flags, void *private_data)
 {
-       struct smbcli_transport *transport = talloc_get_type(private,
+       struct smbcli_transport *transport = talloc_get_type(private_data,
                                                             struct smbcli_transport);
        if (flags & EVENT_FD_READ) {
                packet_recv(transport->packet);
@@ -62,13 +61,13 @@ static int transport_destructor(struct smbcli_transport *transport)
 /*
   handle receive errors
 */
-static void smbcli_transport_error(void *private, NTSTATUS status)
+static void smbcli_transport_error(void *private_data, NTSTATUS status)
 {
-       struct smbcli_transport *transport = talloc_get_type(private, struct smbcli_transport);
+       struct smbcli_transport *transport = talloc_get_type(private_data, struct smbcli_transport);
        smbcli_transport_dead(transport, status);
 }
 
-static NTSTATUS smbcli_transport_finish_recv(void *private, DATA_BLOB blob);
+static NTSTATUS smbcli_transport_finish_recv(void *private_data, DATA_BLOB blob);
 
 /*
   create a transport structure based on an established socket
@@ -76,7 +75,8 @@ static NTSTATUS smbcli_transport_finish_recv(void *private, DATA_BLOB blob);
 struct smbcli_transport *smbcli_transport_init(struct smbcli_socket *sock,
                                               TALLOC_CTX *parent_ctx, 
                                               bool primary, 
-                                              struct smbcli_options *options)
+                                              struct smbcli_options *options,
+                                                  struct smb_iconv_convenience *iconv_convenience)
 {
        struct smbcli_transport *transport;
 
@@ -91,6 +91,7 @@ struct smbcli_transport *smbcli_transport_init(struct smbcli_socket *sock,
        transport->negotiate.protocol = PROTOCOL_NT1;
        transport->options = *options;
        transport->negotiate.max_xmit = transport->options.max_xmit;
+       transport->iconv_convenience = iconv_convenience;
 
        /* setup the stream -> packet parser */
        transport->packet = packet_init(transport);
@@ -166,15 +167,14 @@ struct smbcli_request *smbcli_transport_connect_send(struct smbcli_transport *tr
        DATA_BLOB calling_blob, called_blob;
        TALLOC_CTX *tmp_ctx = talloc_new(transport);
        NTSTATUS status;
-       struct smb_iconv_convenience *iconv_convenience = lp_iconv_convenience(global_loadparm);
 
        status = nbt_name_dup(transport, called, &transport->called);
        if (!NT_STATUS_IS_OK(status)) goto failed;
        
-       status = nbt_name_to_blob(tmp_ctx, iconv_convenience, &calling_blob, calling);
+       status = nbt_name_to_blob(tmp_ctx, transport->iconv_convenience, &calling_blob, calling);
        if (!NT_STATUS_IS_OK(status)) goto failed;
 
-       status = nbt_name_to_blob(tmp_ctx, iconv_convenience, &called_blob, called);
+       status = nbt_name_to_blob(tmp_ctx, transport->iconv_convenience, &called_blob, called);
        if (!NT_STATUS_IS_OK(status)) goto failed;
 
        /* allocate output buffer */
@@ -307,17 +307,17 @@ again:
        return mid;
 }
 
-static void idle_handler(struct event_context *ev, 
-                        struct timed_event *te, struct timeval t, void *private)
+static void idle_handler(struct tevent_context *ev, 
+                        struct tevent_timer *te, struct timeval t, void *private_data)
 {
-       struct smbcli_transport *transport = talloc_get_type(private,
+       struct smbcli_transport *transport = talloc_get_type(private_data,
                                                             struct smbcli_transport);
        struct timeval next = timeval_add(&t, 0, transport->idle.period);
        transport->socket->event.te = event_add_timed(transport->socket->event.ctx, 
                                                      transport,
                                                      next,
                                                      idle_handler, transport);
-       transport->idle.func(transport, transport->idle.private);
+       transport->idle.func(transport, transport->idle.private_data);
 }
 
 /*
@@ -327,10 +327,10 @@ static void idle_handler(struct event_context *ev,
 _PUBLIC_ void smbcli_transport_idle_handler(struct smbcli_transport *transport, 
                                   void (*idle_func)(struct smbcli_transport *, void *),
                                   uint64_t period,
-                                  void *private)
+                                  void *private_data)
 {
        transport->idle.func = idle_func;
-       transport->idle.private = private;
+       transport->idle.private_data = private_data;
        transport->idle.period = period;
 
        if (transport->socket->event.te != NULL) {
@@ -347,9 +347,9 @@ _PUBLIC_ void smbcli_transport_idle_handler(struct smbcli_transport *transport,
   we have a full request in our receive buffer - match it to a pending request
   and process
  */
-static NTSTATUS smbcli_transport_finish_recv(void *private, DATA_BLOB blob)
+static NTSTATUS smbcli_transport_finish_recv(void *private_data, DATA_BLOB blob)
 {
-       struct smbcli_transport *transport = talloc_get_type(private
+       struct smbcli_transport *transport = talloc_get_type(private_data,
                                                             struct smbcli_transport);
        uint8_t *buffer, *hdr, *vwv;
        int len;
@@ -450,12 +450,12 @@ static NTSTATUS smbcli_transport_finish_recv(void *private, DATA_BLOB blob)
        smb_setup_bufinfo(req);
 
        if (!(req->flags2 & FLAGS2_32_BIT_ERROR_CODES)) {
-               int class = CVAL(req->in.hdr,HDR_RCLS);
+               int eclass = CVAL(req->in.hdr,HDR_RCLS);
                int code = SVAL(req->in.hdr,HDR_ERR);
-               if (class == 0 && code == 0) {
+               if (eclass == 0 && code == 0) {
                        transport->error.e.nt_status = NT_STATUS_OK;
                } else {
-                       transport->error.e.nt_status = NT_STATUS_DOS(class, code);
+                       transport->error.e.nt_status = NT_STATUS_DOS(eclass, code);
                }
        } else {
                transport->error.e.nt_status = NT_STATUS(IVAL(req->in.hdr, HDR_RCLS));
@@ -541,10 +541,10 @@ _PUBLIC_ bool smbcli_transport_process(struct smbcli_transport *transport)
 /*
   handle timeouts of individual smb requests
 */
-static void smbcli_timeout_handler(struct event_context *ev, struct timed_event *te, 
-                                  struct timeval t, void *private)
+static void smbcli_timeout_handler(struct tevent_context *ev, struct tevent_timer *te, 
+                                  struct timeval t, void *private_data)
 {
-       struct smbcli_request *req = talloc_get_type(private, struct smbcli_request);
+       struct smbcli_request *req = talloc_get_type(private_data, struct smbcli_request);
 
        if (req->state == SMBCLI_REQUEST_RECV) {
                DLIST_REMOVE(req->transport->pending_recv, req);