summaryrefslogtreecommitdiff
path: root/source3/include
diff options
context:
space:
mode:
Diffstat (limited to 'source3/include')
-rw-r--r--source3/include/async_req.h160
-rw-r--r--source3/include/client.h63
-rw-r--r--source3/include/proto.h17
-rw-r--r--source3/include/smb.h7
-rw-r--r--source3/include/smb_macros.h2
-rw-r--r--source3/include/vfs.h4
6 files changed, 76 insertions, 177 deletions
diff --git a/source3/include/async_req.h b/source3/include/async_req.h
deleted file mode 100644
index 3907a08f67..0000000000
--- a/source3/include/async_req.h
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- Unix SMB/CIFS implementation.
- Infrastructure for async requests
- Copyright (C) Volker Lendecke 2008
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
-
-#ifndef __ASYNC_REQ_H__
-#define __ASYNC_REQ_H__
-
-#include "includes.h"
-
-/**
- * An async request moves between the following 4 states:
- */
-
-enum async_req_state {
- /**
- * we are creating the request
- */
- ASYNC_REQ_INIT,
- /**
- * we are waiting the request to complete
- */
- ASYNC_REQ_IN_PROGRESS,
- /**
- * the request is finished
- */
- ASYNC_REQ_DONE,
- /**
- * an error has occured
- */
- ASYNC_REQ_ERROR
-};
-
-/**
- * @brief An async request
- *
- * This represents an async request being processed by callbacks via an event
- * context. A user can issue for example a write request to a socket, giving
- * an implementation function the fd, the buffer and the number of bytes to
- * transfer. The function issuing the request will immediately return without
- * blocking most likely without having sent anything. The API user then fills
- * in req->async.fn and req->async.priv, functions that are called when the
- * request is finished.
- *
- * It is up to the user of the async request to talloc_free it after it has
- * finished. This can happen while the completion function is called.
- */
-
-struct async_req {
- /**
- * @brief The external state - will be queried by the caller
- *
- * While the async request is being processed, state will remain in
- * ASYNC_REQ_IN_PROGRESS. A request is finished if
- * req->state>=ASYNC_REQ_DONE.
- */
- enum async_req_state state;
-
- /**
- * @brief Private pointer for the actual implementation
- *
- * The implementation doing the work for the async request needs a
- * current state like for example a fd event. The user of an async
- * request should not touch this.
- */
- void *private_data;
-
- /**
- * @brief Print yourself, for debugging purposes
- *
- * Async requests are opaque data structures. The implementation of an
- * async request can define a custom function to print more debug
- * info.
- */
- char *(*print)(TALLOC_CTX *mem_ctx, struct async_req *);
-
- /**
- * @brief status code when finished
- *
- * This status can be queried in the async completion function. It
- * will be set to NT_STATUS_OK when everything went fine.
- **/
- NTSTATUS status;
-
- /**
- * @brief What to do on completion
- *
- * This is used for the user of an async request, fn is called when
- * the request completes, either successfully or with an error.
- */
- struct {
- /**
- * @brief Completion function
- * Completion function, to be filled by the API user
- */
- void (*fn)(struct async_req *);
- /**
- * @brief Private data for the completion function
- */
- void *priv;
- } async;
-};
-
-struct async_req *async_req_new(TALLOC_CTX *mem_ctx);
-
-char *async_req_print(TALLOC_CTX *mem_ctx, struct async_req *req);
-
-void async_req_done(struct async_req *req);
-
-void async_req_error(struct async_req *req, NTSTATUS status);
-
-bool async_post_status(struct async_req *req, struct event_context *ev,
- NTSTATUS status);
-
-bool async_req_nomem(const void *p, struct async_req *req);
-
-bool async_req_is_error(struct async_req *req, NTSTATUS *status);
-
-NTSTATUS async_req_simple_recv(struct async_req *req);
-
-bool async_req_set_timeout(struct async_req *req, struct event_context *ev,
- struct timeval to);
-
-struct async_req *async_wait_send(TALLOC_CTX *mem_ctx,
- struct event_context *ev,
- struct timeval to);
-
-NTSTATUS async_wait_recv(struct async_req *req);
-
-struct async_req_queue;
-
-struct async_req_queue *async_req_queue_init(TALLOC_CTX *mem_ctx);
-
-bool async_req_enqueue(struct async_req_queue *queue,
- struct event_context *ev,
- struct async_req *req,
- void (*trigger)(struct async_req *req));
-
-bool _async_req_setup(TALLOC_CTX *mem_ctx, struct async_req **preq,
- void *pstate, size_t state_size, const char *typename);
-
-#define async_req_setup(_mem_ctx, _preq, _pstate, type) \
- _async_req_setup((_mem_ctx), (_preq), (_pstate), sizeof(type), #type)
-
-
-#endif
diff --git a/source3/include/client.h b/source3/include/client.h
index 09fdb81462..d62d1c05d2 100644
--- a/source3/include/client.h
+++ b/source3/include/client.h
@@ -61,21 +61,60 @@ struct cli_pipe_auth_data {
} a_u;
};
+/**
+ * rpc_cli_transport defines a transport mechanism to ship rpc requests
+ * asynchronously to a server and receive replies
+ */
+
+struct rpc_cli_transport {
+
+ /**
+ * Trigger an async read from the server. May return a short read.
+ */
+ struct async_req *(*read_send)(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ uint8_t *data, size_t size,
+ void *priv);
+ /**
+ * Get the result from the read_send operation.
+ */
+ NTSTATUS (*read_recv)(struct async_req *req, ssize_t *preceived);
+
+ /**
+ * Trigger an async write to the server. May return a short write.
+ */
+ struct async_req *(*write_send)(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ const uint8_t *data, size_t size,
+ void *priv);
+ /**
+ * Get the result from the read_send operation.
+ */
+ NTSTATUS (*write_recv)(struct async_req *req, ssize_t *psent);
+
+ /**
+ * This is an optimization for the SMB transport. It models the
+ * TransactNamedPipe API call: Send and receive data in one round
+ * trip. The transport implementation is free to set this to NULL,
+ * cli_pipe.c will fall back to the explicit write/read routines.
+ */
+ struct async_req *(*trans_send)(TALLOC_CTX *mem_ctx,
+ struct event_context *ev,
+ uint8_t *data, size_t data_len,
+ uint32_t max_rdata_len,
+ void *priv);
+ /**
+ * Get the result from the read_send operation.
+ */
+ NTSTATUS (*trans_recv)(struct async_req *req, TALLOC_CTX *mem_ctx,
+ uint8_t **prdata, uint32_t *prdata_len);
+ void *priv;
+};
+
struct rpc_pipe_client {
struct rpc_pipe_client *prev, *next;
- enum dcerpc_transport_t transport_type;
-
- union {
- struct {
- struct cli_state *cli;
- const char *pipe_name;
- uint16 fnum;
- } np;
- struct {
- int fd;
- } sock;
- } trans ;
+ struct rpc_cli_transport *transport;
struct ndr_syntax_id abstract_syntax;
struct ndr_syntax_id transfer_syntax;
diff --git a/source3/include/proto.h b/source3/include/proto.h
index d55546f94c..1414ba89ec 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -5216,7 +5216,6 @@ NTSTATUS rpc_pipe_bind(struct rpc_pipe_client *cli,
unsigned int rpccli_set_timeout(struct rpc_pipe_client *cli,
unsigned int timeout);
bool rpccli_get_pwd_hash(struct rpc_pipe_client *cli, uint8_t nt_hash[16]);
-struct cli_state *rpc_pipe_np_smb_conn(struct rpc_pipe_client *p);
NTSTATUS rpccli_anon_bind_data(TALLOC_CTX *mem_ctx,
struct cli_pipe_auth_data **presult);
NTSTATUS rpccli_ntlmssp_bind_data(TALLOC_CTX *mem_ctx,
@@ -5296,6 +5295,17 @@ NTSTATUS cli_get_session_key(TALLOC_CTX *mem_ctx,
struct rpc_pipe_client *cli,
DATA_BLOB *session_key);
+/* The following definitions come from rpc_client/rpc_transport_np.c */
+
+NTSTATUS rpc_transport_np_init(TALLOC_CTX *mem_ctx, struct cli_state *cli,
+ const struct ndr_syntax_id *abstract_syntax,
+ struct rpc_cli_transport **presult);
+struct cli_state *rpc_pipe_np_smb_conn(struct rpc_pipe_client *p);
+
+/* The following definitions come from rpc_client/rpc_transport_sock.c */
+
+NTSTATUS rpc_transport_sock_init(TALLOC_CTX *mem_ctx, int fd,
+ struct rpc_cli_transport **presult);
/* The following definitions come from rpc_client/cli_reg.c */
@@ -6678,7 +6688,8 @@ int file_set_dosmode(connection_struct *conn, const char *fname,
uint32 dosmode, SMB_STRUCT_STAT *st,
const char *parent_dir,
bool newfile);
-int file_ntimes(connection_struct *conn, const char *fname, const struct timespec ts[2]);
+int file_ntimes(connection_struct *conn, const char *fname,
+ struct smb_file_time *ft);
bool set_sticky_write_time_path(connection_struct *conn, const char *fname,
struct file_id fileid, const struct timespec mtime);
bool set_sticky_write_time_fsp(struct files_struct *fsp, const struct timespec mtime);
@@ -7414,7 +7425,7 @@ NTSTATUS smb_set_file_time(connection_struct *conn,
files_struct *fsp,
const char *fname,
const SMB_STRUCT_STAT *psbuf,
- struct timespec ts[2],
+ struct smb_file_time *ft,
bool setting_write_time);
void reply_findclose(struct smb_request *req);
void reply_findnclose(struct smb_request *req);
diff --git a/source3/include/smb.h b/source3/include/smb.h
index 19d2208ada..aa2db693a3 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -1901,4 +1901,11 @@ struct smb_extended_info {
*/
#define CFF_DOS_PATH 0x00000001
+/* time info */
+struct smb_file_time {
+ struct timespec mtime;
+ struct timespec atime;
+ struct timespec create_time;
+};
+
#endif /* _SMB_H */
diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h
index 5149da0cb3..92c60a7530 100644
--- a/source3/include/smb_macros.h
+++ b/source3/include/smb_macros.h
@@ -256,7 +256,7 @@ NULL returns on zero request. JRA.
#define TALLOC_REALLOC(ctx, ptr, count) _talloc_realloc(ctx, ptr, count, __location__)
#define TALLOC_REALLOC_ARRAY(ctx, ptr, type, count) (type *)_talloc_realloc_array(ctx, ptr, sizeof(type), count, #type)
#define talloc_destroy(ctx) talloc_free(ctx)
-#define TALLOC_FREE(ctx) do { if ((ctx) != NULL) {talloc_free(ctx); ctx=NULL;} } while(0)
+#define TALLOC_FREE(ctx) do { talloc_free(ctx); ctx=NULL; } while(0)
/* only define PARANOID_MALLOC_CHECKER with --enable-developer */
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index d02d14b854..5df71da905 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -111,6 +111,7 @@
/* Changed to version 24 - make security descriptor const in fset_nt_acl. JRA. */
/* Changed to version 25 - Jelmer's change from SMB_BIG_UINT to uint64_t. */
/* Leave at 25 - not yet released. Add create_file call. -- tprouty. */
+/* Leave at 25 - not yet released. Add create time to ntimes. -- tstecher. */
#define SMB_VFS_INTERFACE_VERSION 25
@@ -137,6 +138,7 @@ struct security_descriptor;
struct vfs_statvfs_struct;
struct smb_request;
struct ea_list;
+struct smb_file_time;
/*
Available VFS operations. These values must be in sync with vfs_ops struct
@@ -348,7 +350,7 @@ struct vfs_ops {
int (*lchown)(struct vfs_handle_struct *handle, const char *path, uid_t uid, gid_t gid);
int (*chdir)(struct vfs_handle_struct *handle, const char *path);
char *(*getwd)(struct vfs_handle_struct *handle, char *buf);
- int (*ntimes)(struct vfs_handle_struct *handle, const char *path, const struct timespec ts[2]);
+ int (*ntimes)(struct vfs_handle_struct *handle, const char *path, struct smb_file_time *ft);
int (*ftruncate)(struct vfs_handle_struct *handle, struct files_struct *fsp, SMB_OFF_T offset);
bool (*lock)(struct vfs_handle_struct *handle, struct files_struct *fsp, int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
int (*kernel_flock)(struct vfs_handle_struct *handle, struct files_struct *fsp, uint32 share_mode);