Merge branch 'master' of ssh://git.samba.org/data/git/samba into selftest
[kai/samba-autobuild/.git] / source4 / libcli / raw / clitransport.c
index 5c14e9f9b8d1f819eed9ff3afcf7ba43f15b0d15..f8ef343e3a3f24b5400418fc5147112c5782ca4d 100644 (file)
 
 #include "includes.h"
 #include "libcli/raw/libcliraw.h"
+#include "libcli/raw/raw_proto.h"
 #include "lib/socket/socket.h"
 #include "lib/util/dlinklist.h"
 #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"
 
 
 /*
@@ -322,7 +324,7 @@ static void idle_handler(struct event_context *ev,
   setup the idle handler for a transport
   the period is in microseconds
 */
-void smbcli_transport_idle_handler(struct smbcli_transport *transport, 
+_PUBLIC_ void smbcli_transport_idle_handler(struct smbcli_transport *transport, 
                                   void (*idle_func)(struct smbcli_transport *, void *),
                                   uint64_t period,
                                   void *private)
@@ -478,8 +480,22 @@ async:
        /* if this request has an async handler then call that to
           notify that the reply has been received. This might destroy
           the request so it must happen last */
-       DLIST_REMOVE(transport->pending_recv, req);
+
        req->state = SMBCLI_REQUEST_DONE;
+
+       if (req->recv_helper.fn) {
+               /*
+                * let the recv helper decide in
+                * what state the request really is
+                */
+               req->state = req->recv_helper.fn(req);
+
+               /* if more parts are needed, wait for them */
+               if (req->state <= SMBCLI_REQUEST_RECV) {
+                       return NT_STATUS_OK;
+               }
+       }
+       DLIST_REMOVE(transport->pending_recv, req);
        if (req->async.fn) {
                req->async.fn(req);
        }
@@ -502,7 +518,7 @@ error:
   process some read/write requests that are pending
   return false if the socket is dead
 */
-bool smbcli_transport_process(struct smbcli_transport *transport)
+_PUBLIC_ bool smbcli_transport_process(struct smbcli_transport *transport)
 {
        NTSTATUS status;
        size_t npending;
@@ -599,7 +615,7 @@ void smbcli_transport_send(struct smbcli_request *req)
 /****************************************************************************
  Send an SMBecho (async send)
 *****************************************************************************/
-struct smbcli_request *smb_raw_echo_send(struct smbcli_transport *transport,
+_PUBLIC_ struct smbcli_request *smb_raw_echo_send(struct smbcli_transport *transport,
                                         struct smb_echo *p)
 {
        struct smbcli_request *req;