diff options
author | Andrew Tridgell <tridge@samba.org> | 2003-12-04 02:03:06 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2003-12-04 02:03:06 +0000 |
commit | 926240428c0646aabb13539745940b61a7cf44a9 (patch) | |
tree | 102988d47fab4a56b59161409dddc9c9dfa86ed5 /source4/libcli/raw | |
parent | b8cbd9181efabbc360ef335e214a696011839b41 (diff) | |
download | samba-926240428c0646aabb13539745940b61a7cf44a9.tar.gz samba-926240428c0646aabb13539745940b61a7cf44a9.tar.bz2 samba-926240428c0646aabb13539745940b61a7cf44a9.zip |
* patch based on work by Jim Myers to unify the ioctl handling to be
more like the other major SMB functions
* added SMBntrename code
(This used to be commit f2d3dc9893fa0e089c407fa16ce9ff13587e70cd)
Diffstat (limited to 'source4/libcli/raw')
-rw-r--r-- | source4/libcli/raw/rawioctl.c | 105 |
1 files changed, 71 insertions, 34 deletions
diff --git a/source4/libcli/raw/rawioctl.c b/source4/libcli/raw/rawioctl.c index 506bddd497..2ea2cabb89 100644 --- a/source4/libcli/raw/rawioctl.c +++ b/source4/libcli/raw/rawioctl.c @@ -2,6 +2,7 @@ Unix SMB/CIFS implementation. client file operations Copyright (C) Andrew Tridgell 2003 + Copyright (C) James J Myers 2003 <myersjj@samba.org> 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 @@ -26,16 +27,17 @@ } while (0) /* - send a raw ioctl - async send + send a raw smb ioctl - async send */ -struct cli_request *smb_raw_ioctl_send(struct cli_tree *tree, struct smb_ioctl *parms) +static struct cli_request *smb_raw_smbioctl_send(struct cli_tree *tree, + union smb_ioctl *parms) { struct cli_request *req; SETUP_REQUEST(SMBioctl, 3, 0); - SSVAL(req->out.vwv, VWV(0), parms->in.fnum); - SIVAL(req->out.vwv, VWV(1), parms->in.request); + SSVAL(req->out.vwv, VWV(0), parms->ioctl.in.fnum); + SIVAL(req->out.vwv, VWV(1), parms->ioctl.in.request); if (!cli_request_send(req)) { cli_request_destroy(req); @@ -46,36 +48,28 @@ struct cli_request *smb_raw_ioctl_send(struct cli_tree *tree, struct smb_ioctl * } /* - send a raw ioctl - async recv + send a raw smb ioctl - async recv */ -NTSTATUS smb_raw_ioctl_recv(struct cli_request *req, TALLOC_CTX *mem_ctx, struct smb_ioctl *parms) +static NTSTATUS smb_raw_smbioctl_recv(struct cli_request *req, + TALLOC_CTX *mem_ctx, + union smb_ioctl *parms) { if (!cli_request_receive(req) || cli_request_is_error(req)) { return cli_request_destroy(req); } - parms->out.blob = cli_req_pull_blob(req, mem_ctx, req->in.data, -1); + parms->ioctl.out.blob = cli_req_pull_blob(req, mem_ctx, req->in.data, -1); return cli_request_destroy(req); } -/* - send a raw ioctl - sync interface -*/ -NTSTATUS smb_raw_ioctl(struct cli_tree *tree, TALLOC_CTX *mem_ctx, struct smb_ioctl *parms) -{ - struct cli_request *req = smb_raw_ioctl_send(tree, parms); - return smb_raw_ioctl_recv(req, mem_ctx, parms); -} - - /**************************************************************************** NT ioctl (async send) ****************************************************************************/ -struct cli_request *smb_raw_ntioctl_send(struct cli_tree *tree, - struct smb_ntioctl *parms) +static struct cli_request *smb_raw_ntioctl_send(struct cli_tree *tree, + union smb_ioctl *parms) { struct smb_nttrans nt; uint16 setup[4]; @@ -85,10 +79,10 @@ struct cli_request *smb_raw_ntioctl_send(struct cli_tree *tree, nt.in.max_data = 0; nt.in.setup_count = 4; nt.in.setup = setup; - SIVAL(setup, 0, parms->in.function); - SSVAL(setup, 4, parms->in.fnum); - SCVAL(setup, 6, parms->in.fsctl); - SCVAL(setup, 7, parms->in.filter); + SIVAL(setup, 0, parms->ntioctl.in.function); + SSVAL(setup, 4, parms->ntioctl.in.fnum); + SCVAL(setup, 6, parms->ntioctl.in.fsctl); + SCVAL(setup, 7, parms->ntioctl.in.filter); nt.in.function = NT_TRANSACT_IOCTL; nt.in.params = data_blob(NULL, 0); nt.in.data = data_blob(NULL, 0); @@ -99,20 +93,63 @@ struct cli_request *smb_raw_ntioctl_send(struct cli_tree *tree, /**************************************************************************** NT ioctl (async recv) ****************************************************************************/ -NTSTATUS smb_raw_ntioctl_recv(struct cli_request *req, - struct smb_ntioctl *parms) +static NTSTATUS smb_raw_ntioctl_recv(struct cli_request *req, + TALLOC_CTX *mem_ctx, + union smb_ioctl *parms) { - struct smb_nttrans nt; + if (!cli_request_receive(req) || + cli_request_is_error(req)) { + return cli_request_destroy(req); + } - return smb_raw_nttrans_recv(req, req->mem_ctx, &nt); + parms->ntioctl.out.blob = cli_req_pull_blob(req, mem_ctx, req->in.data, -1); + return cli_request_destroy(req); } -/**************************************************************************** -NT ioctl (sync interface) -****************************************************************************/ -NTSTATUS smb_raw_ntioctl(struct cli_tree *tree, - struct smb_ntioctl *parms) + +/* + send a raw ioctl - async send +*/ +struct cli_request *smb_raw_ioctl_send(struct cli_tree *tree, union smb_ioctl *parms) +{ + struct cli_request *req = NULL; + + switch (parms->generic.level) { + case RAW_IOCTL_IOCTL: + req = smb_raw_smbioctl_send(tree, parms); + break; + + case RAW_IOCTL_NTIOCTL: + req = smb_raw_ntioctl_send(tree, parms); + break; + } + + return req; +} + +/* + recv a raw ioctl - async recv +*/ +NTSTATUS smb_raw_ioctl_recv(struct cli_request *req, + TALLOC_CTX *mem_ctx, union smb_ioctl *parms) { - struct cli_request *req = smb_raw_ntioctl_send(tree, parms); - return smb_raw_ntioctl_recv(req, parms); + switch (parms->generic.level) { + case RAW_IOCTL_IOCTL: + return smb_raw_smbioctl_recv(req, mem_ctx, parms); + + case RAW_IOCTL_NTIOCTL: + return smb_raw_ntioctl_recv(req, mem_ctx, parms); + } + return NT_STATUS_INVALID_LEVEL; +} + +/* + send a raw ioctl - sync interface +*/ +NTSTATUS smb_raw_ioctl(struct cli_tree *tree, + TALLOC_CTX *mem_ctx, union smb_ioctl *parms) +{ + struct cli_request *req; + req = smb_raw_ioctl_send(tree, parms); + return smb_raw_ioctl_recv(req, mem_ctx, parms); } |