[SCM] Samba Shared Repository - branch master updated - release-4-0-0alpha7-880-g1c40276

Volker Lendecke vlendec at samba.org
Mon Apr 6 19:33:36 GMT 2009


The branch, master has been updated
       via  1c4027678e7300580cdb4122f19261afedcbad6c (commit)
       via  3084d49cc000dbfeb01d931d737c695dcd392e4a (commit)
       via  0c353b57113b02bccaaa3ec09ff9fb1fd8542bd4 (commit)
       via  64ce0e4645727be7b493fca54fdf6af91f3f7927 (commit)
       via  cb120b4df69d3997e02e0dd2ee4be150c3ce8c8b (commit)
       via  64067f920405143895b1e39790e9bd2a6e176d00 (commit)
       via  86b09e84aefefdb9c06b66f46886f1bad70797a3 (commit)
       via  025eb40fbc9db7de9c2497390c3d7449a0169cac (commit)
       via  31910810cf03a463e3728db9e0298ad9f73900f7 (commit)
       via  ad695b2525e192a75b54b614a17b662070c904ca (commit)
       via  097db28c5d2d1014ffe63430dbe6f944807faa5c (commit)
       via  17b8d05b624bd87dfe3c996cd10be5a981007bac (commit)
       via  c23ccff13a6e92b37a104845736e5e8cecd27f35 (commit)
       via  ca7cd350a6ac47b981d6c9a8b671f4c18642a9f2 (commit)
       via  807328ce6d9dea481995a9f6e86f2b60f4ca4c00 (commit)
       via  03becb506613b4ec1d365ff2bbd63e53b0847805 (commit)
       via  95c792b6afe1e4a3176d95eb451b67ba1ce4a380 (commit)
       via  7ef78bd7b5b5d1b2c5c06d1170f80ea77f036353 (commit)
       via  dec928e884f492c7a5e5e8c87e2ff0c1944da5f1 (commit)
       via  0a4cdad324291d6c91b569c4fc8362a8383965fe (commit)
       via  8bdac3615a255f65665939bda070c1b4ba93b908 (commit)
       via  ad29104d3df85faa946f10c0d8626cfc993010e5 (commit)
      from  522bdea1f32c85d01fcd2ca360927de8acf92596 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 1c4027678e7300580cdb4122f19261afedcbad6c
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Apr 6 20:52:04 2009 +0200

    Correct sync wrappers in cli_pipe.c

commit 3084d49cc000dbfeb01d931d737c695dcd392e4a
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Apr 6 20:45:08 2009 +0200

    Add a bad hack to enable level 2 oplocks in torture_open_connection_share

commit 0c353b57113b02bccaaa3ec09ff9fb1fd8542bd4
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Apr 6 20:41:48 2009 +0200

    Make cli_oplock_ack async

commit 64ce0e4645727be7b493fca54fdf6af91f3f7927
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Apr 6 16:06:04 2009 +0200

    Add async oplock waiter

commit cb120b4df69d3997e02e0dd2ee4be150c3ce8c8b
Author: Volker Lendecke <vl at samba.org>
Date:   Mon Apr 6 14:51:34 2009 +0200

    Never hand out 0xffff as a mid
    
    This is used for oplock replies

commit 64067f920405143895b1e39790e9bd2a6e176d00
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Apr 5 23:28:01 2009 +0200

    Remove async_req based async libsmb infrastructure

commit 86b09e84aefefdb9c06b66f46886f1bad70797a3
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Apr 5 23:20:45 2009 +0200

    Re-add the CHAIN1 test

commit 025eb40fbc9db7de9c2497390c3d7449a0169cac
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Apr 5 23:17:55 2009 +0200

    Convert cli_open to tevent_req

commit 31910810cf03a463e3728db9e0298ad9f73900f7
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Mar 29 13:46:24 2009 +0200

    Convert cli_close to tevent_req

commit ad695b2525e192a75b54b614a17b662070c904ca
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Apr 5 06:33:24 2009 +0200

    Streamline cli_push sync wrapper

commit 097db28c5d2d1014ffe63430dbe6f944807faa5c
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Mar 29 13:28:18 2009 +0200

    Convert cli_write_andx to tevent_req

commit 17b8d05b624bd87dfe3c996cd10be5a981007bac
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Apr 5 06:33:17 2009 +0200

    Streamline cli_pull sync wrapper

commit c23ccff13a6e92b37a104845736e5e8cecd27f35
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Mar 15 09:54:23 2009 +0100

    Convert cli_read_andx to tevent_req

commit ca7cd350a6ac47b981d6c9a8b671f4c18642a9f2
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Mar 29 20:00:58 2009 +0200

    Convert cli_ntcreate to tevent_req

commit 807328ce6d9dea481995a9f6e86f2b60f4ca4c00
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Mar 29 19:47:18 2009 +0200

    Convert cli_tcon_andx to tevent_req

commit 03becb506613b4ec1d365ff2bbd63e53b0847805
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Mar 29 18:59:56 2009 +0200

    Convert cli_negprot to tevent_req

commit 95c792b6afe1e4a3176d95eb451b67ba1ce4a380
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Mar 29 17:42:13 2009 +0200

    Convert cli_session_setup_guest to tevent_req

commit 7ef78bd7b5b5d1b2c5c06d1170f80ea77f036353
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Apr 5 20:51:52 2009 +0200

    Convert cli_trans to tevent_req

commit dec928e884f492c7a5e5e8c87e2ff0c1944da5f1
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Apr 5 20:48:16 2009 +0200

    Convert cli_echo to tevent_req

commit 0a4cdad324291d6c91b569c4fc8362a8383965fe
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Mar 29 23:16:34 2009 +0200

    Remove the CHAIN1 test -- will come back later

commit 8bdac3615a255f65665939bda070c1b4ba93b908
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Apr 5 20:18:45 2009 +0200

    Add new async libsmb infrastructure
    
    I know this is just yet another iteration, but I like this one much better than
    the one that exists right now :-)
    
    It will do trans and echo requests without a _recv helper and without
    unnecessary memcpy().

commit ad29104d3df85faa946f10c0d8626cfc993010e5
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Apr 5 19:58:20 2009 +0200

    Add read_smb_send/recv, dumping keepalives

-----------------------------------------------------------------------

Summary of changes:
 source3/include/async_smb.h             |  146 +---
 source3/include/client.h                |   30 +-
 source3/include/proto.h                 |  135 ++--
 source3/lib/util_sock.c                 |   87 ++
 source3/libsmb/async_smb.c              | 1388 +++++++++++++++----------------
 source3/libsmb/cliconnect.c             |  339 +++++---
 source3/libsmb/clientgen.c              |  157 ++--
 source3/libsmb/clifile.c                |  340 ++++++---
 source3/libsmb/clioplock.c              |  123 +++-
 source3/libsmb/clireadwrite.c           |  437 ++++++----
 source3/libsmb/clitrans.c               |  654 ++++++---------
 source3/rpc_client/cli_pipe.c           |   18 +-
 source3/rpc_client/rpc_transport_np.c   |   64 +-
 source3/rpc_client/rpc_transport_smbd.c |   36 +-
 source3/torture/torture.c               |  101 +--
 15 files changed, 2161 insertions(+), 1894 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/async_smb.h b/source3/include/async_smb.h
index 2ac1101..87ddca6 100644
--- a/source3/include/async_smb.h
+++ b/source3/include/async_smb.h
@@ -22,123 +22,11 @@
 
 #include "includes.h"
 
-/**
- * struct cli_request is the state holder for an async client request we sent
- * to the server. It can consist of more than one struct async_req that we
- * have to server if the application did a cli_chain_cork() and
- * cli_chain_uncork()
- */
-
-struct cli_request {
-	/**
-	 * "prev" and "next" form the doubly linked list in
-	 * cli_state->outstanding_requests
-	 */
-	struct cli_request *prev, *next;
-
-	/**
-	 * num_async: How many chained requests do we serve?
-	 */
-	int num_async;
-
-	/**
-	 * async: This is the list of chained requests that were queued up by
-	 * cli_request_chain before we sent out this request
-	 */
-	struct async_req **async;
-
-	/**
-	 * The client connection for this request
-	 */
-	struct cli_state *cli;
-
-	/**
-	 * The enc_state to decrypt the reply
-	 */
-	struct smb_trans_enc_state *enc_state;
-
-	/**
-	 * The mid we used for this request. Mainly used to demultiplex on
-	 * receiving replies.
-	 */
-	uint16_t mid;
-
-	uint32_t seqnum;
-
-	/**
-	 * The bytes we have to ship to the server
-	 */
-	uint8_t *outbuf;
-
-	/**
-	 * How much from "outbuf" did we already send
-	 */
-	size_t sent;
-
-	/**
-	 * The reply comes in here. Its intended size is implicit by
-	 * smb_len(), its current size can be read via talloc_get_size()
-	 */
-	char *inbuf;
-
-	/**
-	 * Specific requests might add stuff here. Maybe convert this to a
-	 * private_pointer at some point.
-	 */
-	union {
-		struct {
-			off_t ofs;
-			size_t size;
-			ssize_t received;
-			uint8_t *rcvbuf;
-		} read;
-		struct {
-			DATA_BLOB data;
-			uint16_t num_echos;
-		} echo;
-	} data;
-
-	/**
-	 * For requests that don't follow the strict request/reply pattern
-	 * such as the transaction request family and echo requests it is
-	 * necessary to break the standard procedure in
-	 * handle_incoming_pdu(). For a simple example look at
-	 * cli_echo_recv_helper().
-	 */
-	struct {
-		void (*fn)(struct async_req *req);
-		void *priv;
-	} recv_helper;
-};
-
-/*
- * Ship a new smb request to the server
- */
-
-struct async_req *cli_request_send(TALLOC_CTX *mem_ctx,
-				   struct event_context *ev,
-				   struct cli_state *cli,
-				   uint8_t smb_command,
-				   uint8_t additional_flags,
-				   uint8_t wct, const uint16_t *vwv,
-				   size_t bytes_alignment,
-				   uint32_t num_bytes, const uint8_t *bytes);
-
-uint16_t cli_wct_ofs(const struct cli_state *cli);
-
-bool cli_chain_cork(struct cli_state *cli, struct event_context *ev,
-		    size_t size_hint);
-void cli_chain_uncork(struct cli_state *cli);
-bool cli_in_chain(struct cli_state *cli);
 bool smb_splice_chain(uint8_t **poutbuf, uint8_t smb_command,
 		      uint8_t wct, const uint16_t *vwv,
 		      size_t bytes_alignment,
 		      uint32_t num_bytes, const uint8_t *bytes);
 
-NTSTATUS cli_pull_reply(struct async_req *req,
-			uint8_t *pwct, uint16_t **pvwv,
-			uint16_t *pnum_bytes, uint8_t **pbytes);
-
 /*
  * Fetch an error out of a NBT packet
  */
@@ -151,4 +39,38 @@ NTSTATUS cli_pull_error(char *buf);
 
 void cli_set_error(struct cli_state *cli, NTSTATUS status);
 
+struct tevent_req *cli_smb_req_create(TALLOC_CTX *mem_ctx,
+				      struct event_context *ev,
+				      struct cli_state *cli,
+				      uint8_t smb_command,
+				      uint8_t additional_flags,
+				      uint8_t wct, uint16_t *vwv,
+				      int iov_count,
+				      struct iovec *bytes_iov);
+bool cli_smb_req_send(struct tevent_req *req);
+size_t cli_smb_wct_ofs(struct tevent_req **reqs, int num_reqs);
+bool cli_smb_chain_send(struct tevent_req **reqs, int num_reqs);
+uint8_t *cli_smb_inbuf(struct tevent_req *req);
+bool cli_has_async_calls(struct cli_state *cli);
+void cli_smb_req_unset_pending(struct tevent_req *req);
+bool cli_smb_req_set_pending(struct tevent_req *req);
+uint16_t cli_smb_req_mid(struct tevent_req *req);
+void cli_smb_req_set_mid(struct tevent_req *req, uint16_t mid);
+struct tevent_req *cli_smb_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
+				struct cli_state *cli,
+				uint8_t smb_command, uint8_t additional_flags,
+				uint8_t wct, uint16_t *vwv,
+				uint32_t num_bytes,
+				const uint8_t *bytes);
+NTSTATUS cli_smb_recv(struct tevent_req *req, uint8_t min_wct,
+		      uint8_t *pwct, uint16_t **pvwv,
+		      uint32_t *pnum_bytes, uint8_t **pbytes);
+
+struct tevent_req *cli_smb_oplock_break_waiter_send(TALLOC_CTX *mem_ctx,
+						    struct event_context *ev,
+						    struct cli_state *cli);
+NTSTATUS cli_smb_oplock_break_waiter_recv(struct tevent_req *req,
+					  uint16_t *pfnum,
+					  uint8_t *plevel);
+
 #endif
diff --git a/source3/include/client.h b/source3/include/client.h
index 73a1d7b..c314c9c 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -264,33 +264,11 @@ struct cli_state {
 	bool force_dos_errors;
 	bool case_sensitive; /* False by default. */
 
-	/**
-	 * fd_event is around while we have async requests outstanding or are
-	 * building a chained request.
-	 *
-	 * (fd_event!=NULL) &&
-	 *  ((outstanding_request!=NULL)||(chain_accumulator!=NULL))
-	 *
-	 * should always be true, as well as the reverse: If both cli_request
-	 * pointers are NULL, no fd_event is around.
-	 */
-	struct fd_event *fd_event;
-	char *evt_inbuf;
-
-	/**
-	 * A linked list of requests that are waiting for a reply
-	 */
-	struct cli_request *outstanding_requests;
-
-	/**
-	 * The place to build up the list of chained requests. In CIFS, a
-	 * single cli_request corresponds to a MID and can serve more than one
-	 * chained async_req.
-	 */
-	struct cli_request *chain_accumulator;
-
 	/* Where (if anywhere) this is mounted under DFS. */
 	char *dfs_mountpoint;
+
+	struct tevent_queue *outgoing;
+	struct tevent_req **pending;
 };
 
 typedef struct file_info {
@@ -311,5 +289,7 @@ typedef struct file_info {
 #define CLI_FULL_CONNECTION_USE_KERBEROS 0x0002
 #define CLI_FULL_CONNECTION_ANONYMOUS_FALLBACK 0x0004
 #define CLI_FULL_CONNECTION_FALLBACK_AFTER_KERBEROS 0x0008
+#define CLI_FULL_CONNECTION_OPLOCKS 0x0010
+#define CLI_FULL_CONNECTION_LEVEL_II_OPLOCKS 0x0020
 
 #endif /* _CLIENT_H */
diff --git a/source3/include/proto.h b/source3/include/proto.h
index c46e7a5..d76ee08 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1420,6 +1420,11 @@ int create_pipe_sock(const char *socket_dir,
 		     mode_t dir_perms);
 const char *get_mydnsfullname(void);
 bool is_myname_or_ipaddr(const char *s);
+struct tevent_req *read_smb_send(TALLOC_CTX *mem_ctx,
+				 struct tevent_context *ev,
+				 int fd);
+ssize_t read_smb_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
+		      uint8_t **pbuf, int *perrno);
 
 /* The following definitions come from lib/util_str.c  */
 
@@ -2298,26 +2303,26 @@ NTSTATUS cli_session_setup(struct cli_state *cli,
 			   const char *pass, int passlen,
 			   const char *ntpass, int ntpasslen,
 			   const char *workgroup);
-struct async_req *cli_session_setup_guest_send(TALLOC_CTX *mem_ctx,
-					       struct event_context *ev,
-					       struct cli_state *cli);
-NTSTATUS cli_session_setup_guest_recv(struct async_req *req);
+struct tevent_req *cli_session_setup_guest_send(TALLOC_CTX *mem_ctx,
+						struct event_context *ev,
+						struct cli_state *cli);
+NTSTATUS cli_session_setup_guest_recv(struct tevent_req *req);
 bool cli_ulogoff(struct cli_state *cli);
-struct async_req *cli_tcon_andx_send(TALLOC_CTX *mem_ctx,
-				     struct event_context *ev,
-				     struct cli_state *cli,
-				     const char *share, const char *dev,
-				     const char *pass, int passlen);
-NTSTATUS cli_tcon_andx_recv(struct async_req *req);
+struct tevent_req *cli_tcon_andx_send(TALLOC_CTX *mem_ctx,
+				      struct event_context *ev,
+				      struct cli_state *cli,
+				      const char *share, const char *dev,
+				      const char *pass, int passlen);
+NTSTATUS cli_tcon_andx_recv(struct tevent_req *req);
 NTSTATUS cli_tcon_andx(struct cli_state *cli, const char *share,
 		       const char *dev, const char *pass, int passlen);
 bool cli_tdis(struct cli_state *cli);
 void cli_negprot_sendsync(struct cli_state *cli);
 NTSTATUS cli_negprot(struct cli_state *cli);
-struct async_req *cli_negprot_send(TALLOC_CTX *mem_ctx,
-				   struct event_context *ev,
-				   struct cli_state *cli);
-NTSTATUS cli_negprot_recv(struct async_req *req);
+struct tevent_req *cli_negprot_send(TALLOC_CTX *mem_ctx,
+				    struct event_context *ev,
+				    struct cli_state *cli);
+NTSTATUS cli_negprot_recv(struct tevent_req *req);
 bool cli_session_request(struct cli_state *cli,
 			 struct nmb_name *calling, struct nmb_name *called);
 NTSTATUS cli_connect(struct cli_state *cli,
@@ -2439,10 +2444,10 @@ void cli_sockopt(struct cli_state *cli, const char *options);
 uint16 cli_setpid(struct cli_state *cli, uint16 pid);
 bool cli_set_case_sensitive(struct cli_state *cli, bool case_sensitive);
 bool cli_send_keepalive(struct cli_state *cli);
-struct async_req *cli_echo_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
-				struct cli_state *cli, uint16_t num_echos,
-				DATA_BLOB data);
-NTSTATUS cli_echo_recv(struct async_req *req);
+struct tevent_req *cli_echo_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
+				 struct cli_state *cli, uint16_t num_echos,
+				 DATA_BLOB data);
+NTSTATUS cli_echo_recv(struct tevent_req *req);
 NTSTATUS cli_echo(struct cli_state *cli, uint16_t num_echos, DATA_BLOB data);
 bool cli_ucs2(struct cli_state *cli);
 bool is_andx_req(uint8_t cmd);
@@ -2483,18 +2488,18 @@ int cli_nt_create_full(struct cli_state *cli, const char *fname,
 		 uint32 FileAttributes, uint32 ShareAccess,
 		 uint32 CreateDisposition, uint32 CreateOptions,
 		 uint8 SecuityFlags);
-struct async_req *cli_ntcreate_send(TALLOC_CTX *mem_ctx,
-				    struct event_context *ev,
-				    struct cli_state *cli,
-				    const char *fname,
-				    uint32_t CreatFlags,
-				    uint32_t DesiredAccess,
-				    uint32_t FileAttributes,
-				    uint32_t ShareAccess,
-				    uint32_t CreateDisposition,
-				    uint32_t CreateOptions,
-				    uint8_t SecurityFlags);
-NTSTATUS cli_ntcreate_recv(struct async_req *req, uint16_t *pfnum);
+struct tevent_req *cli_ntcreate_send(TALLOC_CTX *mem_ctx,
+				     struct event_context *ev,
+				     struct cli_state *cli,
+				     const char *fname,
+				     uint32_t CreatFlags,
+				     uint32_t DesiredAccess,
+				     uint32_t FileAttributes,
+				     uint32_t ShareAccess,
+				     uint32_t CreateDisposition,
+				     uint32_t CreateOptions,
+				     uint8_t SecurityFlags);
+NTSTATUS cli_ntcreate_recv(struct tevent_req *req, uint16_t *pfnum);
 NTSTATUS cli_ntcreate(struct cli_state *cli,
 		      const char *fname,
 		      uint32_t CreatFlags,
@@ -2508,14 +2513,24 @@ NTSTATUS cli_ntcreate(struct cli_state *cli,
 int cli_nt_create(struct cli_state *cli, const char *fname, uint32 DesiredAccess);
 uint8_t *smb_bytes_push_str(uint8_t *buf, bool ucs2, const char *str,
 			    size_t str_len, size_t *pconverted_size);
-struct async_req *cli_open_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
-				struct cli_state *cli,
-				const char *fname, int flags, int share_mode);
-NTSTATUS cli_open_recv(struct async_req *req, int *fnum);
+struct tevent_req *cli_open_create(TALLOC_CTX *mem_ctx,
+				   struct event_context *ev,
+				   struct cli_state *cli, const char *fname,
+				   int flags, int share_mode,
+				   struct tevent_req **psmbreq);
+struct tevent_req *cli_open_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
+				 struct cli_state *cli, const char *fname,
+				 int flags, int share_mode);
+NTSTATUS cli_open_recv(struct tevent_req *req, int *fnum);
 int cli_open(struct cli_state *cli, const char *fname, int flags, int share_mode);
-struct async_req *cli_close_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
-				 struct cli_state *cli, int fnum);
-NTSTATUS cli_close_recv(struct async_req *req);
+struct tevent_req *cli_close_create(TALLOC_CTX *mem_ctx,
+				    struct event_context *ev,
+				    struct cli_state *cli, int fnum,
+				    struct tevent_req **psubreq);
+struct tevent_req *cli_close_send(TALLOC_CTX *mem_ctx,
+				  struct event_context *ev,
+				  struct cli_state *cli, int fnum);
+NTSTATUS cli_close_recv(struct tevent_req *req);
 bool cli_close(struct cli_state *cli, int fnum);
 bool cli_ftruncate(struct cli_state *cli, int fnum, uint64_t size);
 NTSTATUS cli_locktype(struct cli_state *cli, int fnum,
@@ -2629,6 +2644,11 @@ bool cli_message_end(struct cli_state *cli, int grp);
 
 /* The following definitions come from libsmb/clioplock.c  */
 
+struct tevent_req *cli_oplock_ack_send(TALLOC_CTX *mem_ctx,
+				       struct tevent_context *ev,
+				       struct cli_state *cli,
+				       uint16_t fnum, uint8_t level);
+NTSTATUS cli_oplock_ack_recv(struct tevent_req *req);
 bool cli_oplock_ack(struct cli_state *cli, int fnum, unsigned char level);
 void cli_oplock_handler(struct cli_state *cli, 
 			bool (*handler)(struct cli_state *, int, unsigned char));
@@ -2756,11 +2776,16 @@ int cli_NetConnectionEnum(struct cli_state *cli, const char *qualifier,
 
 /* The following definitions come from libsmb/clireadwrite.c  */
 
-struct async_req *cli_read_andx_send(TALLOC_CTX *mem_ctx,
-				     struct event_context *ev,
-				     struct cli_state *cli, int fnum,
-				     off_t offset, size_t size);
-NTSTATUS cli_read_andx_recv(struct async_req *req, ssize_t *received,
+struct tevent_req *cli_read_andx_create(TALLOC_CTX *mem_ctx,
+					struct event_context *ev,
+					struct cli_state *cli, int fnum,
+					off_t offset, size_t size,
+					struct tevent_req **psmbreq);
+struct tevent_req *cli_read_andx_send(TALLOC_CTX *mem_ctx,
+				      struct event_context *ev,
+				      struct cli_state *cli, int fnum,
+				      off_t offset, size_t size);
+NTSTATUS cli_read_andx_recv(struct tevent_req *req, ssize_t *received,
 			    uint8_t **rcvbuf);
 struct async_req *cli_pull_send(TALLOC_CTX *mem_ctx,
 				struct event_context *ev,
@@ -2783,12 +2808,20 @@ ssize_t cli_write(struct cli_state *cli,
 		 const char *buf, off_t offset, size_t size);
 ssize_t cli_smbwrite(struct cli_state *cli,
 		     int fnum, char *buf, off_t offset, size_t size1);
-struct async_req *cli_write_andx_send(TALLOC_CTX *mem_ctx,
-				      struct event_context *ev,
-				      struct cli_state *cli, uint16_t fnum,
-				      uint16_t mode, const uint8_t *buf,
-				      off_t offset, size_t size);
-NTSTATUS cli_write_andx_recv(struct async_req *req, size_t *pwritten);
+struct tevent_req *cli_write_andx_create(TALLOC_CTX *mem_ctx,
+					 struct event_context *ev,
+					 struct cli_state *cli, uint16_t fnum,
+					 uint16_t mode, const uint8_t *buf,
+					 off_t offset, size_t size,
+					 struct tevent_req **reqs_before,
+					 int num_reqs_before,
+					 struct tevent_req **psmbreq);
+struct tevent_req *cli_write_andx_send(TALLOC_CTX *mem_ctx,
+				       struct event_context *ev,
+				       struct cli_state *cli, uint16_t fnum,
+				       uint16_t mode, const uint8_t *buf,
+				       off_t offset, size_t size);
+NTSTATUS cli_write_andx_recv(struct tevent_req *req, size_t *pwritten);
 
 struct async_req *cli_push_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
 				struct cli_state *cli,
@@ -2884,14 +2917,14 @@ bool cli_send_nt_trans(struct cli_state *cli,
 bool cli_receive_nt_trans(struct cli_state *cli,
 			  char **param, unsigned int *param_len,
 			  char **data, unsigned int *data_len);
-struct async_req *cli_trans_send(
+struct tevent_req *cli_trans_send(
 	TALLOC_CTX *mem_ctx, struct event_context *ev,
-	struct cli_state *cli, uint8_t trans_cmd,
+	struct cli_state *cli, uint8_t cmd,
 	const char *pipe_name, uint16_t fid, uint16_t function, int flags,
 	uint16_t *setup, uint8_t num_setup, uint8_t max_setup,
 	uint8_t *param, uint32_t num_param, uint32_t max_param,
 	uint8_t *data, uint32_t num_data, uint32_t max_data);
-NTSTATUS cli_trans_recv(struct async_req *req, TALLOC_CTX *mem_ctx,
+NTSTATUS cli_trans_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
 			uint16_t **setup, uint8_t *num_setup,
 			uint8_t **param, uint32_t *num_param,
 			uint8_t **data, uint32_t *num_data);
diff --git a/source3/lib/util_sock.c b/source3/lib/util_sock.c
index a0dbca1..21dd624 100644
--- a/source3/lib/util_sock.c
+++ b/source3/lib/util_sock.c
@@ -1965,3 +1965,90 @@ bool is_myname_or_ipaddr(const char *s)
 	/* No match */
 	return false;
 }
+
+/*
+ * Read an smb packet asynchronously, discard keepalives
+ */
+
+struct read_smb_state {
+	struct tevent_context *ev;
+	int fd;
+	uint8_t *buf;
+};
+
+static ssize_t read_smb_more(uint8_t *buf, size_t buflen, void *private_data);
+static void read_smb_done(struct tevent_req *subreq);
+
+struct tevent_req *read_smb_send(TALLOC_CTX *mem_ctx,
+				 struct tevent_context *ev,
+				 int fd)
+{
+	struct tevent_req *result, *subreq;
+	struct read_smb_state *state;
+
+	result = tevent_req_create(mem_ctx, &state, struct read_smb_state);
+	if (result == NULL) {
+		return NULL;
+	}
+	state->ev = ev;
+	state->fd = fd;
+
+	subreq = read_packet_send(state, ev, fd, 4, read_smb_more, NULL);
+	if (subreq == NULL) {
+		goto fail;
+	}
+	tevent_req_set_callback(subreq, read_smb_done, result);
+	return result;
+ fail:
+	TALLOC_FREE(result);
+	return NULL;
+}
+
+static ssize_t read_smb_more(uint8_t *buf, size_t buflen, void *private_data)
+{
+	if (buflen > 4) {
+		return 0;	/* We've been here, we're done */
+	}
+	return smb_len_large(buf);
+}
+
+static void read_smb_done(struct tevent_req *subreq)
+{
+	struct tevent_req *req = tevent_req_callback_data(
+		subreq, struct tevent_req);
+	struct read_smb_state *state = tevent_req_data(
+		req, struct read_smb_state);
+	ssize_t len;
+	int err;
+
+	len = read_packet_recv(subreq, state, &state->buf, &err);
+	TALLOC_FREE(subreq);
+	if (len == -1) {
+		tevent_req_error(req, err);
+		return;
+	}


-- 
Samba Shared Repository


More information about the samba-cvs mailing list