lib/param move source4 param code to the top level
[sfrench/samba-autobuild/.git] / source4 / libcli / raw / libcliraw.h
index 6c97e61f047325834e275079621d3e474c1d6944..b7b02c668eaee6a83ea1b6efe660fab9698932e1 100644 (file)
@@ -22,6 +22,7 @@
 #ifndef __LIBCLI_RAW_H__
 #define __LIBCLI_RAW_H__
 
+#include "../libcli/smb/smb_common.h"
 #include "libcli/raw/request.h"
 #include "librpc/gen_ndr/nbt.h"
 
@@ -32,6 +33,7 @@ struct smbcli_transport;  /* forward declare */
 
 struct resolve_context;
 struct cli_credentials;
+struct gensec_settings;
 
 /* default timeout for all smb requests */
 #define SMB_REQUEST_TIMEOUT 60
@@ -62,8 +64,9 @@ struct smbcli_negotiate {
        
        int server_zone;
        time_t server_time;
-       uint_t readbraw_supported:1;
-       uint_t writebraw_supported:1;
+       unsigned int readbraw_supported:1;
+       unsigned int writebraw_supported:1;
+       unsigned int lockread_supported:1;
 
        char *server_domain;
 };
@@ -80,9 +83,9 @@ struct smbcli_socket {
 
        /* the event handle for waiting for socket IO */
        struct {
-               struct event_context *ctx;
-               struct fd_event *fde;
-               struct timed_event *te;
+               struct tevent_context *ctx;
+               struct tevent_fd *fde;
+               struct tevent_timer *te;
        } event;
 };
 
@@ -91,12 +94,16 @@ struct smbcli_socket {
   client library
 */
 struct smbcli_options {
-       uint_t use_oplocks:1;
-       uint_t use_level2_oplocks:1;
-       uint_t use_spnego:1;
+       unsigned int use_oplocks:1;
+       unsigned int use_level2_oplocks:1;
+       unsigned int use_spnego:1;
+       unsigned int unicode:1;
+       unsigned int ntstatus_support:1;
+       int max_protocol;
        uint32_t max_xmit;
        uint16_t max_mux;
        int request_timeout;
+       enum smb_signing_setting signing;
 };
 
 /* this is the context for the client transport layer */
@@ -116,15 +123,15 @@ struct smbcli_transport {
 
        /* is a readbraw pending? we need to handle that case
           specially on receiving packets */
-       uint_t readbraw_pending:1;
+       unsigned int readbraw_pending:1;
        
        /* an idle function - if this is defined then it will be
           called once every period microseconds while we are waiting
           for a packet */
        struct {
                void (*func)(struct smbcli_transport *, void *);
-               void *private;
-               uint_t period;
+               void *private_data;
+               unsigned int period;
        } idle;
 
        /* the error fields from the last message */
@@ -137,16 +144,16 @@ struct smbcli_transport {
                              SOCKET_READ_ERROR,
                              SOCKET_WRITE_ERROR,
                              SOCKET_READ_BAD_SIG} socket_error;
-                       uint_t nbt_error;
+                       unsigned int nbt_error;
                } e;
        } error;
 
        struct {
                /* a oplock break request handler */
                bool (*handler)(struct smbcli_transport *transport, 
-                               uint16_t tid, uint16_t fnum, uint8_t level, void *private);
+                               uint16_t tid, uint16_t fnum, uint8_t level, void *private_data);
                /* private data passed to the oplock handler */
-               void *private;
+               void *private_data;
        } oplock;
 
        /* a list of async requests that are pending for receive on this connection */
@@ -182,6 +189,15 @@ struct smbcli_session {
 
        /* the spnego context if we use extented security */
        struct gensec_security *gensec;
+
+       struct smbcli_session_options {
+               unsigned int lanman_auth:1;
+               unsigned int ntlmv2_auth:1;
+               unsigned int plaintext_auth:1;
+       } options;
+
+       const char *os;
+       const char *lanman;
 };
 
 /* 
@@ -221,6 +237,14 @@ struct smbcli_request {
        struct smbcli_session *session;
        struct smbcli_tree *tree;
 
+       /* a receive helper, smbcli_transport_finish_recv will not call
+          req->async.fn callback handler unless the recv_helper returns
+          a value > SMBCLI_REQUEST_RECV. */
+       struct {
+               enum smbcli_request_state (*fn)(struct smbcli_request *);
+               void *private_data;
+       } recv_helper;
+
        /* the flags2 from the SMB request, in raw form (host byte
           order). Used to parse strings */
        uint16_t flags2;
@@ -230,24 +254,30 @@ struct smbcli_request {
        NTSTATUS status;
        
        /* the sequence number of this packet - used for signing */
-       uint_t seq_num;
+       unsigned int seq_num;
 
        /* list of ntcancel request for this requests */
        struct smbcli_request *ntcancel;
 
        /* set if this is a one-way request, meaning we are not
           expecting a reply from the server. */
-       uint_t one_way_request:1;
+       unsigned int one_way_request:1;
 
        /* set this when the request should only increment the signing
           counter by one */
-       uint_t sign_single_increment:1;
+       unsigned int sign_single_increment:1;
+
+       /* the caller wants to do the signing check */
+       bool sign_caller_checks;
+
+       /* give the caller a chance to prevent the talloc_free() in the _recv() function */
+       bool do_not_free;
 
        /* the mid of this packet - used to match replies */
        uint16_t mid;
 
-       struct request_buffer in;
-       struct request_buffer out;
+       struct smb_request_buffer in;
+       struct smb_request_buffer out;
 
        /* information on what to do with a reply when it is received
           asyncronously. If this is not setup when a reply is received then
@@ -258,7 +288,7 @@ struct smbcli_request {
        */
        struct {
                void (*fn)(struct smbcli_request *);
-               void *private;
+               void *private_data;
        } async;
 };
 
@@ -275,7 +305,83 @@ struct smbcli_request {
       goto failed; \
 }
 
-#include "libcli/raw/interfaces.h" 
-#include "libcli/raw/raw_proto.h"
+#include "libcli/raw/interfaces.h"
+
+NTSTATUS smb_raw_read_recv(struct smbcli_request *req, union smb_read *parms);
+struct smbcli_request *smb_raw_read_send(struct smbcli_tree *tree, union smb_read *parms);
+NTSTATUS smb_raw_trans_recv(struct smbcli_request *req,
+                            TALLOC_CTX *mem_ctx,
+                            struct smb_trans2 *parms);
+size_t smb_raw_max_trans_data(struct smbcli_tree *tree, size_t param_size);
+struct smbcli_request *smb_raw_trans_send(struct smbcli_tree *tree, struct smb_trans2 *parms);
+NTSTATUS smbcli_request_destroy(struct smbcli_request *req);
+struct smbcli_request *smb_raw_write_send(struct smbcli_tree *tree, union smb_write *parms);
+NTSTATUS smb_raw_write_recv(struct smbcli_request *req, union smb_write *parms);
+struct smbcli_request *smb_raw_close_send(struct smbcli_tree *tree, union smb_close *parms);
+NTSTATUS smb_raw_open_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, union smb_open *parms);
+struct smbcli_request *smb_raw_open_send(struct smbcli_tree *tree, union smb_open *parms);
+
+bool smbcli_transport_process(struct smbcli_transport *transport);
+const char *smbcli_errstr(struct smbcli_tree *tree);
+NTSTATUS smb_raw_fsinfo(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_fsinfo *fsinfo);
+NTSTATUS smb_raw_pathinfo(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_fileinfo *parms);
+NTSTATUS smb_raw_shadow_data(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, struct smb_shadow_copy *info);
+NTSTATUS smb_raw_fileinfo(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_fileinfo *parms);
+struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session, TALLOC_CTX *parent_ctx, bool primary);
+NTSTATUS smb_raw_tcon(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_tcon *parms);
+void smbcli_oplock_handler(struct smbcli_transport *transport, 
+                       bool (*handler)(struct smbcli_transport *, uint16_t, uint16_t, uint8_t, void *),
+                       void *private_data);
+void smbcli_transport_idle_handler(struct smbcli_transport *transport, 
+                                  void (*idle_func)(struct smbcli_transport *, void *),
+                                  uint64_t period,
+                                  void *private_data);
+NTSTATUS smbcli_request_simple_recv(struct smbcli_request *req);
+bool smbcli_oplock_ack(struct smbcli_tree *tree, uint16_t fnum, uint16_t ack_level);
+NTSTATUS smb_raw_open(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_open *parms);
+NTSTATUS smb_raw_close(struct smbcli_tree *tree, union smb_close *parms);
+NTSTATUS smb_raw_unlink(struct smbcli_tree *tree, union smb_unlink *parms);
+NTSTATUS smb_raw_chkpath(struct smbcli_tree *tree, union smb_chkpath *parms);
+NTSTATUS smb_raw_mkdir(struct smbcli_tree *tree, union smb_mkdir *parms);
+NTSTATUS smb_raw_rmdir(struct smbcli_tree *tree, struct smb_rmdir *parms);
+NTSTATUS smb_raw_rename(struct smbcli_tree *tree, union smb_rename *parms);
+NTSTATUS smb_raw_seek(struct smbcli_tree *tree, union smb_seek *parms);
+NTSTATUS smb_raw_read(struct smbcli_tree *tree, union smb_read *parms);
+NTSTATUS smb_raw_write(struct smbcli_tree *tree, union smb_write *parms);
+NTSTATUS smb_raw_lock(struct smbcli_tree *tree, union smb_lock *parms);
+NTSTATUS smb_raw_setpathinfo(struct smbcli_tree *tree, union smb_setfileinfo *parms);
+NTSTATUS smb_raw_setfileinfo(struct smbcli_tree *tree, union smb_setfileinfo *parms);
+
+struct smbcli_request *smb_raw_changenotify_send(struct smbcli_tree *tree, union smb_notify *parms);
+NTSTATUS smb_raw_changenotify_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, union smb_notify *parms);
+
+NTSTATUS smb_tree_disconnect(struct smbcli_tree *tree);
+NTSTATUS smbcli_nt_error(struct smbcli_tree *tree);
+NTSTATUS smb_raw_exit(struct smbcli_session *session);
+NTSTATUS smb_raw_pathinfo_recv(struct smbcli_request *req,
+                              TALLOC_CTX *mem_ctx,
+                              union smb_fileinfo *parms);
+struct smbcli_request *smb_raw_pathinfo_send(struct smbcli_tree *tree,
+                                            union smb_fileinfo *parms);
+struct smbcli_request *smb_raw_setpathinfo_send(struct smbcli_tree *tree,
+                                            union smb_setfileinfo *parms);
+struct smbcli_request *smb_raw_echo_send(struct smbcli_transport *transport,
+                                        struct smb_echo *p);
+NTSTATUS smb_raw_search_first(struct smbcli_tree *tree,
+                             TALLOC_CTX *mem_ctx,
+                             union smb_search_first *io, void *private_data,
+                             smbcli_search_callback callback);
+NTSTATUS smb_raw_flush(struct smbcli_tree *tree, union smb_flush *parms);
+
+NTSTATUS smb_raw_trans(struct smbcli_tree *tree,
+                      TALLOC_CTX *mem_ctx,
+                      struct smb_trans2 *parms);
+
+struct smbcli_socket *smbcli_sock_connect_byname(const char *host, const char **ports,
+                                                TALLOC_CTX *mem_ctx,
+                                                struct resolve_context *resolve_ctx,
+                                                struct tevent_context *event_ctx,
+                                                const char *socket_options);
+void smbcli_sock_dead(struct smbcli_socket *sock);
 
 #endif /* __LIBCLI_RAW__H__ */