diff options
author | Stefan Metzmacher <metze@samba.org> | 2004-08-04 13:23:35 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:57:47 -0500 |
commit | c5fbb6f23c2d399c7510bc552cdb1a27b1ef66a8 (patch) | |
tree | 6fccf75601681c68afca5dd9c6b840de44f7f31c /source4/libcli | |
parent | a0cb701b6fac6e75da691e239cd0407b9269533a (diff) | |
download | samba-c5fbb6f23c2d399c7510bc552cdb1a27b1ef66a8.tar.gz samba-c5fbb6f23c2d399c7510bc552cdb1a27b1ef66a8.tar.bz2 samba-c5fbb6f23c2d399c7510bc552cdb1a27b1ef66a8.zip |
r1654: rename cli_ -> smbcli_
rename CLI_ -> SMBCLI_
metze
(This used to be commit 8441750fd9427dd6fe477f27e603821b4026f038)
Diffstat (limited to 'source4/libcli')
32 files changed, 1016 insertions, 1016 deletions
diff --git a/source4/libcli/cliconnect.c b/source4/libcli/cliconnect.c index 8b064f161e..8753f26b5f 100644 --- a/source4/libcli/cliconnect.c +++ b/source4/libcli/cliconnect.c @@ -21,45 +21,45 @@ #include "includes.h" /* - wrapper around cli_sock_connect() + wrapper around smbcli_sock_connect() */ -BOOL cli_socket_connect(struct cli_state *cli, const char *server, struct in_addr *ip) +BOOL smbcli_socket_connect(struct smbcli_state *cli, const char *server, struct in_addr *ip) { - struct cli_socket *sock; + struct smbcli_socket *sock; - sock = cli_sock_init(); + sock = smbcli_sock_init(); if (!sock) return False; - if (!cli_sock_connect_byname(sock, server, 0)) { - cli_sock_close(sock); + if (!smbcli_sock_connect_byname(sock, server, 0)) { + smbcli_sock_close(sock); return False; } - cli->transport = cli_transport_init(sock); + cli->transport = smbcli_transport_init(sock); if (!cli->transport) { - cli_sock_close(sock); + smbcli_sock_close(sock); return False; } return True; } -/* wrapper around cli_transport_connect() */ -BOOL cli_transport_establish(struct cli_state *cli, +/* wrapper around smbcli_transport_connect() */ +BOOL smbcli_transport_establish(struct smbcli_state *cli, struct nmb_name *calling, struct nmb_name *called) { - return cli_transport_connect(cli->transport, calling, called); + return smbcli_transport_connect(cli->transport, calling, called); } /* wrapper around smb_raw_negotiate() */ -NTSTATUS cli_negprot(struct cli_state *cli) +NTSTATUS smbcli_negprot(struct smbcli_state *cli) { return smb_raw_negotiate(cli->transport); } /* wrapper around smb_raw_session_setup() */ -NTSTATUS cli_session_setup(struct cli_state *cli, +NTSTATUS smbcli_session_setup(struct smbcli_state *cli, const char *user, const char *password, const char *domain) @@ -68,10 +68,10 @@ NTSTATUS cli_session_setup(struct cli_state *cli, NTSTATUS status; TALLOC_CTX *mem_ctx; - cli->session = cli_session_init(cli->transport); + cli->session = smbcli_session_init(cli->transport); if (!cli->session) return NT_STATUS_UNSUCCESSFUL; - mem_ctx = talloc_init("cli_session_setup"); + mem_ctx = talloc_init("smbcli_session_setup"); if (!mem_ctx) return NT_STATUS_NO_MEMORY; setup.generic.level = RAW_SESSSETUP_GENERIC; @@ -98,14 +98,14 @@ NTSTATUS cli_session_setup(struct cli_state *cli, } /* wrapper around smb_tree_connect() */ -NTSTATUS cli_send_tconX(struct cli_state *cli, const char *sharename, +NTSTATUS smbcli_send_tconX(struct smbcli_state *cli, const char *sharename, const char *devtype, const char *password) { union smb_tcon tcon; TALLOC_CTX *mem_ctx; NTSTATUS status; - cli->tree = cli_tree_init(cli->session); + cli->tree = smbcli_tree_init(cli->session); if (!cli->tree) return NT_STATUS_UNSUCCESSFUL; cli->tree->reference_count++; @@ -132,9 +132,9 @@ NTSTATUS cli_send_tconX(struct cli_state *cli, const char *sharename, /* - easy way to get to a fully connected cli_state in one call + easy way to get to a fully connected smbcli_state in one call */ -NTSTATUS cli_full_connection(struct cli_state **ret_cli, +NTSTATUS smbcli_full_connection(struct smbcli_state **ret_cli, const char *myname, const char *host, struct in_addr *ip, @@ -146,12 +146,12 @@ NTSTATUS cli_full_connection(struct cli_state **ret_cli, uint_t flags, BOOL *retry) { - struct cli_tree *tree; + struct smbcli_tree *tree; NTSTATUS status; char *p; TALLOC_CTX *mem_ctx; - mem_ctx = talloc_init("cli_full_connection"); + mem_ctx = talloc_init("smbcli_full_connection"); *ret_cli = NULL; @@ -162,13 +162,13 @@ NTSTATUS cli_full_connection(struct cli_state **ret_cli, username = talloc_strdup(mem_ctx, p+1); } - status = cli_tree_full_connection(&tree, myname, host, 0, sharename, devtype, + status = smbcli_tree_full_connection(&tree, myname, host, 0, sharename, devtype, username, domain, password); if (!NT_STATUS_IS_OK(status)) { goto done; } - (*ret_cli) = cli_state_init(); + (*ret_cli) = smbcli_state_init(); (*ret_cli)->tree = tree; (*ret_cli)->session = tree->session; @@ -184,7 +184,7 @@ done: /* disconnect the tree */ -NTSTATUS cli_tdis(struct cli_state *cli) +NTSTATUS smbcli_tdis(struct smbcli_state *cli) { return smb_tree_disconnect(cli->tree); } @@ -192,12 +192,12 @@ NTSTATUS cli_tdis(struct cli_state *cli) /**************************************************************************** Initialise a client state structure. ****************************************************************************/ -struct cli_state *cli_state_init(void) +struct smbcli_state *smbcli_state_init(void) { - struct cli_state *cli; + struct smbcli_state *cli; TALLOC_CTX *mem_ctx; - mem_ctx = talloc_init("cli_state"); + mem_ctx = talloc_init("smbcli_state"); if (!mem_ctx) return NULL; cli = talloc_zero(mem_ctx, sizeof(*cli)); @@ -209,12 +209,12 @@ struct cli_state *cli_state_init(void) /**************************************************************************** Shutdown a client structure. ****************************************************************************/ -void cli_shutdown(struct cli_state *cli) +void smbcli_shutdown(struct smbcli_state *cli) { if (!cli) return; if (cli->tree) { cli->tree->reference_count++; - cli_tree_close(cli->tree); + smbcli_tree_close(cli->tree); } if (cli->mem_ctx) { talloc_destroy(cli->mem_ctx); diff --git a/source4/libcli/clideltree.c b/source4/libcli/clideltree.c index 2bbfd9bd22..aa73f5b90b 100644 --- a/source4/libcli/clideltree.c +++ b/source4/libcli/clideltree.c @@ -21,7 +21,7 @@ #include "includes.h" struct delete_state { - struct cli_tree *tree; + struct smbcli_tree *tree; int total_deleted; BOOL failed; }; @@ -41,30 +41,30 @@ static void delete_fn(file_info *finfo, const char *name, void *state) asprintf(&s, "%s%s", n, finfo->name); if (finfo->mode & FILE_ATTRIBUTE_READONLY) { - if (NT_STATUS_IS_ERR(cli_setatr(dstate->tree, s, 0, 0))) { + if (NT_STATUS_IS_ERR(smbcli_setatr(dstate->tree, s, 0, 0))) { DEBUG(2,("Failed to remove READONLY on %s - %s\n", - s, cli_errstr(dstate->tree))); + s, smbcli_errstr(dstate->tree))); } } if (finfo->mode & FILE_ATTRIBUTE_DIRECTORY) { char *s2; asprintf(&s2, "%s\\*", s); - cli_unlink(dstate->tree, s2); - cli_list(dstate->tree, s2, + smbcli_unlink(dstate->tree, s2); + smbcli_list(dstate->tree, s2, FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM, delete_fn, state); free(s2); - if (NT_STATUS_IS_ERR(cli_rmdir(dstate->tree, s))) { + if (NT_STATUS_IS_ERR(smbcli_rmdir(dstate->tree, s))) { DEBUG(2,("Failed to delete %s - %s\n", - s, cli_errstr(dstate->tree))); + s, smbcli_errstr(dstate->tree))); dstate->failed = True; } dstate->total_deleted++; } else { - if (NT_STATUS_IS_ERR(cli_unlink(dstate->tree, s))) { + if (NT_STATUS_IS_ERR(smbcli_unlink(dstate->tree, s))) { DEBUG(2,("Failed to delete %s - %s\n", - s, cli_errstr(dstate->tree))); + s, smbcli_errstr(dstate->tree))); dstate->failed = True; } dstate->total_deleted++; @@ -77,7 +77,7 @@ static void delete_fn(file_info *finfo, const char *name, void *state) recursively descend a tree deleting all files returns the number of files deleted, or -1 on error */ -int cli_deltree(struct cli_tree *tree, const char *dname) +int smbcli_deltree(struct smbcli_tree *tree, const char *dname) { char *mask; struct delete_state dstate; @@ -87,24 +87,24 @@ int cli_deltree(struct cli_tree *tree, const char *dname) dstate.failed = False; /* it might be a file */ - if (NT_STATUS_IS_OK(cli_unlink(tree, dname))) { + if (NT_STATUS_IS_OK(smbcli_unlink(tree, dname))) { return 1; } - if (NT_STATUS_EQUAL(cli_nt_error(tree), NT_STATUS_OBJECT_NAME_NOT_FOUND) || - NT_STATUS_EQUAL(cli_nt_error(tree), NT_STATUS_OBJECT_PATH_NOT_FOUND) || - NT_STATUS_EQUAL(cli_nt_error(tree), NT_STATUS_NO_SUCH_FILE)) { + if (NT_STATUS_EQUAL(smbcli_nt_error(tree), NT_STATUS_OBJECT_NAME_NOT_FOUND) || + NT_STATUS_EQUAL(smbcli_nt_error(tree), NT_STATUS_OBJECT_PATH_NOT_FOUND) || + NT_STATUS_EQUAL(smbcli_nt_error(tree), NT_STATUS_NO_SUCH_FILE)) { return 0; } asprintf(&mask, "%s\\*", dname); - cli_unlink(dstate.tree, mask); - cli_list(dstate.tree, mask, + smbcli_unlink(dstate.tree, mask); + smbcli_list(dstate.tree, mask, FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_SYSTEM, delete_fn, &dstate); free(mask); - if (NT_STATUS_IS_ERR(cli_rmdir(dstate.tree, dname))) { + if (NT_STATUS_IS_ERR(smbcli_rmdir(dstate.tree, dname))) { DEBUG(2,("Failed to delete %s - %s\n", - dname, cli_errstr(dstate.tree))); + dname, smbcli_errstr(dstate.tree))); return -1; } dstate.total_deleted++; diff --git a/source4/libcli/clidfs.c b/source4/libcli/clidfs.c index ae7a8dc6eb..674666a60a 100644 --- a/source4/libcli/clidfs.c +++ b/source4/libcli/clidfs.c @@ -20,21 +20,21 @@ #include "includes.h" -BOOL cli_client_initialize(struct cli_client* context, +BOOL smbcli_client_initialize(struct smbcli_client* context, const char* sockops, char* username, char* password, char* workgroup, int flags) { int i; for (i=0; i < DFS_MAX_CLUSTER_SIZE ; i++) { - context->cli[i] = cli_raw_initialise(); + context->cli[i] = smbcli_raw_initialise(); } context->sockops = sockops; context->username = username; context->password = password; context->workgroup = workgroup; context->connection_flags = flags; - if (flags & CLI_FULL_CONNECTION_USE_DFS) + if (flags & SMBCLI_FULL_CONNECTION_USE_DFS) context->use_dfs = True; context->number_members = DFS_MAX_CLUSTER_SIZE; return True; @@ -46,7 +46,7 @@ BOOL cli_client_initialize(struct cli_client* context, The structure of a Dfs referral depends on the info level. ****************************************************************************/ -static int interpret_referral(struct cli_state *cli, +static int interpret_referral(struct smbcli_state *cli, int level,char *p,referral_info *rinfo) { char* q; @@ -99,12 +99,12 @@ static int interpret_referral(struct cli_state *cli, } #if 0 -int cli_select_dfs_referral(struct cli_state *cli, dfs_info* dinfo) +int smbcli_select_dfs_referral(struct smbcli_state *cli, dfs_info* dinfo) { return (int)sys_random()%dinfo->number_referrals; } -int cli_get_dfs_referral(struct cli_state *cli,const char *Fname, dfs_info* dinfo) +int smbcli_get_dfs_referral(struct smbcli_state *cli,const char *Fname, dfs_info* dinfo) { struct smb_trans2 parms; int info_level; @@ -123,20 +123,20 @@ int cli_get_dfs_referral(struct cli_state *cli,const char *Fname, dfs_info* dinf pstrcpy(fname,Fname); setup = TRANSACT2_GET_DFS_REFERRAL ; - SSVAL(param,0,CLI_DFS_MAX_REFERRAL_LEVEL); /* attribute */ + SSVAL(param,0,SMBCLI_DFS_MAX_REFERRAL_LEVEL); /* attribute */ p = param+2; p += clistr_push(cli, param+2, fname, -1, STR_TERMINATE); param_len = PTR_DIFF(p, param); - DEBUG(3,("cli_get_dfs_referral: sending request\n")); + DEBUG(3,("smbcli_get_dfs_referral: sending request\n")); trans_param.length = param_len; trans_param.data = param; trans_data.length = 0; trans_data.data = NULL; - if (!cli_send_trans(cli, SMBtrans2, + if (!smbcli_send_trans(cli, SMBtrans2, NULL, /* Name */ -1, 0, /* fid, flags */ &setup, 1, 0, /* setup, length, max */ @@ -147,25 +147,25 @@ int cli_get_dfs_referral(struct cli_state *cli,const char *Fname, dfs_info* dinf return 0; } - if (!cli_receive_trans(cli, SMBtrans2, + if (!smbcli_receive_trans(cli, SMBtrans2, &rparam, ¶m_len, &rdata, &data_len) && - cli_is_dos_error(cli)) { + smbcli_is_dos_error(cli)) { return 0; } - //printf("cli_get_dfs_referral: received response, rdata=%p, rparam=%p\n", + //printf("smbcli_get_dfs_referral: received response, rdata=%p, rparam=%p\n", // rdata, rparam); - if (cli_is_error(cli) || !rdata) + if (smbcli_is_error(cli) || !rdata) return 0; /* parse out some important return info */ - //printf("cli_get_dfs_referral: valid response\n"); + //printf("smbcli_get_dfs_referral: valid response\n"); p = rdata; dinfo->path_consumed = SVAL(p,0); dinfo->number_referrals = SVAL(p,2); dinfo->referral_flags = SVAL(p,4); - DEBUG(3,("cli_get_dfs_referral: path_consumed=%d, # referrals=%d, flags=0x%x\n", + DEBUG(3,("smbcli_get_dfs_referral: path_consumed=%d, # referrals=%d, flags=0x%x\n", dinfo->path_consumed, dinfo->number_referrals, dinfo->referral_flags)); @@ -181,7 +181,7 @@ int cli_get_dfs_referral(struct cli_state *cli,const char *Fname, dfs_info* dinf DEBUG(3,("received %d Dfs referrals\n", dinfo->number_referrals)); - dinfo->selected_referral = cli_select_dfs_referral(cli, dinfo); + dinfo->selected_referral = smbcli_select_dfs_referral(cli, dinfo); DEBUG(3, ("selected Dfs referral %d %s\n", dinfo->selected_referral, dinfo->referrals[dinfo->selected_referral].node)); @@ -190,12 +190,12 @@ int cli_get_dfs_referral(struct cli_state *cli,const char *Fname, dfs_info* dinf #endif /* check if the server produced Dfs redirect */ -BOOL cli_check_dfs_redirect(struct cli_state* c, char* fname, +BOOL smbcli_check_dfs_redirect(struct smbcli_state* c, char* fname, dfs_info* dinfo) { //printf("check_dfs_redirect: error %s\n", - // cli_errstr(c)); - if (cli_is_dos_error(c)) { + // smbcli_errstr(c)); + if (smbcli_is_dos_error(c)) { printf("got dos error\n"); return False; @@ -204,7 +204,7 @@ BOOL cli_check_dfs_redirect(struct cli_state* c, char* fname, /* Check NT error */ - status = cli_nt_error(c); + status = smbcli_nt_error(c); //printf("got nt error 0x%x\n", status); if (NT_STATUS_V(NT_STATUS_PATH_NOT_COVERED) != NT_STATUS_V(status)) { @@ -213,27 +213,27 @@ BOOL cli_check_dfs_redirect(struct cli_state* c, char* fname, } /* execute trans2 getdfsreferral */ //printf("check_dfs_redirect: process referral\n"); - //cli_get_dfs_referral(c, fname, dinfo); + //smbcli_get_dfs_referral(c, fname, dinfo); return True; } -int cli_dfs_open_connection(struct cli_client* cluster, +int smbcli_dfs_open_connection(struct smbcli_client* cluster, char* host, char* share, int flags) { int i; BOOL retry; - struct cli_state* c; + struct smbcli_state* c; // check if already connected for (i=0; i < DFS_MAX_CLUSTER_SIZE; i++) { - if (cluster->cli[i]->in_use && strequal(host, cli_state_get_host(cluster->cli[i])) - && strequal(share, cli_state_get_share(cluster->cli[i]))) { - DEBUG(3,("cli_dfs_open_connection: already connected to \\\\%s\\%s\n", host, share)); + if (cluster->cli[i]->in_use && strequal(host, smbcli_state_get_host(cluster->cli[i])) + && strequal(share, smbcli_state_get_share(cluster->cli[i]))) { + DEBUG(3,("smbcli_dfs_open_connection: already connected to \\\\%s\\%s\n", host, share)); return i; } } // open connection - DEBUG(3,("cli_dfs_open_connection: opening \\\\%s\\%s %s@%s\n", + DEBUG(3,("smbcli_dfs_open_connection: opening \\\\%s\\%s %s@%s\n", host, share, cluster->username, cluster->workgroup)); for (i=0; i < DFS_MAX_CLUSTER_SIZE; i++) { if (!cluster->cli[i]->in_use) { @@ -244,19 +244,19 @@ int cli_dfs_open_connection(struct cli_client* cluster, return -1; c = cluster->cli[i]; - if (NT_STATUS_IS_ERR(cli_full_connection(&c, + if (NT_STATUS_IS_ERR(smbcli_full_connection(&c, NULL, host, NULL, 0, share, "?????", cluster->username, cluster->workgroup, cluster->password, flags, &retry))) return -1; - cli_state_set_sockopt(cluster->cli[i], cluster->sockops); - cli_state_set_host(cluster->cli[i], host); - cli_state_set_share(cluster->cli[i], share); + smbcli_state_set_sockopt(cluster->cli[i], cluster->sockops); + smbcli_state_set_host(cluster->cli[i], host); + smbcli_state_set_share(cluster->cli[i], share); cluster->cli[i]->in_use = True; - DEBUG(3,("cli_dfs_open_connection: connected \\\\%s\\%s (%d) %s@%s\n", - cli_state_get_host(cluster->cli[i]), cli_state_get_share(cluster->cli[i]), i, + DEBUG(3,("smbcli_dfs_open_connection: connected \\\\%s\\%s (%d) %s@%s\n", + smbcli_state_get_host(cluster->cli[i]), smbcli_state_get_share(cluster->cli[i]), i, cluster->username, cluster->workgroup)); return i; @@ -267,7 +267,7 @@ int cli_dfs_open_connection(struct cli_client* cluster, into the dfs_path structure **********************************************************************/ -BOOL cli_parse_dfs_path(char* pathname, struct dfs_path* pdp) +BOOL smbcli_parse_dfs_path(char* pathname, struct dfs_path* pdp) { pstring pathname_local; char* p,*temp; @@ -278,7 +278,7 @@ BOOL cli_parse_dfs_path(char* pathname, struct dfs_path* pdp) ZERO_STRUCTP(pdp); trim_string(temp,"\\","\\"); - DEBUG(10,("temp in cli_parse_dfs_path: .%s. after trimming \\'s\n",temp)); + DEBUG(10,("temp in smbcli_parse_dfs_path: .%s. after trimming \\'s\n",temp)); /* now tokenize */ /* parse out hostname */ @@ -308,7 +308,7 @@ BOOL cli_parse_dfs_path(char* pathname, struct dfs_path* pdp) return True; } -char* rebuild_filename(char *referral_fname, struct cli_state* c, +char* rebuild_filename(char *referral_fname, struct smbcli_state* c, char* fname, int path_consumed) { const char *template = "\\\\%s\\%s\\%s"; @@ -317,12 +317,12 @@ char* rebuild_filename(char *referral_fname, struct cli_state* c, // TODO: handle consumed length DEBUG(3,("rebuild_filename: %s, %d consumed of %d\n", fname, path_consumed, strlen(fname))); - if (cli_parse_dfs_path(fname, &dp)) { + if (smbcli_parse_dfs_path(fname, &dp)) { DEBUG(3,("rebuild_filename: reqpath=%s\n", dp.reqpath)); asprintf(&referral_fname, - template, cli_state_get_host(c), - cli_state_get_share(c), dp.reqpath); + template, smbcli_state_get_host(c), + smbcli_state_get_share(c), dp.reqpath); } else return NULL; @@ -334,7 +334,7 @@ char* rebuild_filename(char *referral_fname, struct cli_state* c, Open a file (allowing for Dfs referral). ****************************************************************************/ -int cli_dfs_open(struct cli_client* cluster, int *server, +int smbcli_dfs_open(struct smbcli_client* cluster, int *server, char *fname_src, int flags, int share_mode) { int referral_number; @@ -342,15 +342,15 @@ int cli_dfs_open(struct cli_client* cluster, int *server, char *referral_fname; int fnum; - DEBUG(3,("cli_dfs_open: open %s on server %s(%d)\n", - fname_src, cli_state_get_host(cluster->cli[*server]), *server)); + DEBUG(3,("smbcli_dfs_open: open %s on server %s(%d)\n", + fname_src, smbcli_state_get_host(cluster->cli[*server]), *server)); cluster->cli[*server]->dfs_referral = *server; - if ((fnum = cli_open(cluster->cli[*server], fname_src, flags, share_mode)) < 0) { - if (cli_check_dfs_redirect(cluster->cli[*server], fname_src, &dinfo)) { + if ((fnum = smbcli_open(cluster->cli[*server], fname_src, flags, share_mode)) < 0) { + if (smbcli_check_dfs_redirect(cluster->cli[*server], fname_src, &dinfo)) { // choose referral, check if already connected, open if not referral_number = dinfo.selected_referral; - DEBUG(3,("cli_dfs_open: redirecting to %s\n", dinfo.referrals[referral_number].node)); - cluster->cli[*server]->dfs_referral = cli_dfs_open_connection(cluster, + DEBUG(3,("smbcli_dfs_open: redirecting to %s\n", dinfo.referrals[referral_number].node)); + cluster->cli[*server]->dfs_referral = smbcli_dfs_open_connection(cluster, dinfo.referrals[referral_number].host, dinfo.referrals[referral_number].share, cluster->connection_flags); @@ -361,17 +361,17 @@ int cli_dfs_open(struct cli_client* cluster, int *server, if (rebuild_filename(referral_fname, cluster->cli[*server], fname_src, dinfo.path_consumed) == NULL) return False; fname_src = referral_fname; - DEBUG(3,("cli_dfs_open: Dfs open %s on server %s(%d)\n", - fname_src, cli_state_get_host(cluster->cli[*server]), *server)); - fnum = cli_open(cluster->cli[*server], fname_src, flags, share_mode); + DEBUG(3,("smbcli_dfs_open: Dfs open %s on server %s(%d)\n", + fname_src, smbcli_state_get_host(cluster->cli[*server]), *server)); + fnum = smbcli_open(cluster->cli[*server], fname_src, flags, share_mode); } - if (cli_is_error(cluster->cli[*server])) { - printf("cli_dfs_open: open of %s failed (%s)\n", - fname_src, cli_errstr(cluster->cli[*server])); + if (smbcli_is_error(cluster->cli[*server])) { + printf("smbcli_dfs_open: open of %s failed (%s)\n", + fname_src, smbcli_errstr(cluster->cli[*server])); return -1; } } - DEBUG(3,("cli_dfs_open: open %s fnum=%d\n", + DEBUG(3,("smbcli_dfs_open: open %s fnum=%d\n", fname_src, fnum)); return fnum; } @@ -380,7 +380,7 @@ int cli_dfs_open(struct cli_client* cluster, int *server, Delete a file (allowing for Dfs referral). ****************************************************************************/ -NTSTATUS cli_nt_unlink(struct cli_client* cluster, int *server, +NTSTATUS smbcli_nt_unlink(struct smbcli_client* cluster, int *server, char *fname_src, uint16_t FileAttributes) { int referral_number; @@ -388,20 +388,20 @@ NTSTATUS cli_nt_unlink(struct cli_client* cluster, int *server, char *referral_fname; struct smb_unlink parms; - DEBUG(3,("cli_nt_unlink: delete %s on server %s(%d), attributes=0x%x\n", - fname_src, cli_state_get_host(cluster->cli[*server]), *server, + DEBUG(3,("smbcli_nt_unlink: delete %s on server %s(%d), attributes=0x%x\n", + fname_src, smbcli_state_get_host(cluster->cli[*server]), *server, FileAttributes)); cluster->cli[*server]->dfs_referral = *server; parms.in.pattern = fname_src; parms.in.dirtype = FileAttributes; - if (NT_STATUS_IS_ERR(cli_raw_unlink(cluster->cli[*server], &parms))) { - printf("cli_nt_unlink: delete of %s failed (%s)\n", - fname_src, cli_errstr(cluster->cli[*server])); - if (cli_check_dfs_redirect(cluster->cli[*server], fname_src, &dinfo)) { + if (NT_STATUS_IS_ERR(smbcli_raw_unlink(cluster->cli[*server], &parms))) { + printf("smbcli_nt_unlink: delete of %s failed (%s)\n", + fname_src, smbcli_errstr(cluster->cli[*server])); + if (smbcli_check_dfs_redirect(cluster->cli[*server], fname_src, &dinfo)) { // choose referral, check if already connected, open if not referral_number = dinfo.selected_referral; - DEBUG(3,("cli_nt_unlink: redirecting to %s\n", dinfo.referrals[referral_number].node)); - cluster->cli[*server]->dfs_referral = cli_dfs_open_connection(cluster, + DEBUG(3,("smbcli_nt_unlink: redirecting to %s\n", dinfo.referrals[referral_number].node)); + cluster->cli[*server]->dfs_referral = smbcli_dfs_open_connection(cluster, dinfo.referrals[referral_number].host, dinfo.referrals[referral_number].share, cluster->connection_flags); @@ -412,38 +412,38 @@ NTSTATUS cli_nt_unlink(struct cli_client* cluster, int *server, if (rebuild_filename(referral_fname, cluster->cli[*server], fname_src, dinfo.path_consumed) == NULL) return NT_STATUS_INTERNAL_ERROR; fname_src = referral_fname; - DEBUG(3,("cli_nt_unlink: Dfs delete %s on server %s(%d)\n", - fname_src, cli_state_get_host(cluster->cli[*server]), *server)); - cli_raw_unlink(cluster->cli[*server], &parms); + DEBUG(3,("smbcli_nt_unlink: Dfs delete %s on server %s(%d)\n", + fname_src, smbcli_state_get_host(cluster->cli[*server]), *server)); + smbcli_raw_unlink(cluster->cli[*server], &parms); } - if (cli_is_error(cluster->cli[*server])) { - printf("cli_nt_unlink: delete of %s failed (%s)\n", - fname_src, cli_errstr(cluster->cli[*server])); + if (smbcli_is_error(cluster->cli[*server])) { + printf("smbcli_nt_unlink: delete of %s failed (%s)\n", + fname_src, smbcli_errstr(cluster->cli[*server])); } } - return cli_nt_error(cluster->cli[*server]); + return smbcli_nt_error(cluster->cli[*server]); } /**************************************************************************** Rename a file (allowing for Dfs referral). ****************************************************************************/ -BOOL cli_dfs_rename(struct cli_client* cluster, int *server, +BOOL smbcli_dfs_rename(struct smbcli_client* cluster, int *server, char *fname_src, char *fname_dst) { int referral_number; dfs_info dinfo; char *referral_fname; - DEBUG(3,("cli_dfs_rename: rename %s to %s on server %s(%d)\n", - fname_src, fname_dst, cli_state_get_host(cluster->cli[*server]), *server)); + DEBUG(3,("smbcli_dfs_rename: rename %s to %s on server %s(%d)\n", + fname_src, fname_dst, smbcli_state_get_host(cluster->cli[*server]), *server)); cluster->cli[*server]->dfs_referral = *server; - if (!cli_rename(cluster->cli[*server], fname_src, fname_dst)) { - if (cli_check_dfs_redirect(cluster->cli[*server], fname_src, &dinfo)) { + if (!smbcli_rename(cluster->cli[*server], fname_src, fname_dst)) { + if (smbcli_check_dfs_redirect(cluster->cli[*server], fname_src, &dinfo)) { // choose referral, check if already connected, open if not referral_number = dinfo.selected_referral; - DEBUG(3,("cli_dfs_rename: redirecting to %s\n", dinfo.referrals[referral_number].node)); - cluster->cli[*server]->dfs_referral = cli_dfs_open_connection(cluster, + DEBUG(3,("smbcli_dfs_rename: redirecting to %s\n", dinfo.referrals[referral_number].node)); + cluster->cli[*server]->dfs_referral = smbcli_dfs_open_connection(cluster, dinfo.referrals[referral_number].host, dinfo.referrals[referral_number].share, cluster->connection_flags); @@ -454,13 +454,13 @@ BOOL cli_dfs_rename(struct cli_client* cluster, int *server, if (rebuild_filename(referral_fname, cluster->cli[*server], fname_src, dinfo.path_consumed) == NULL) return False; fname_src = referral_fname; - DEBUG(3,("cli_dfs_rename: Dfs rename %s to %s on server %s(%d)\n", - fname_src, fname_dst, cli_state_get_host(cluster->cli[*server]), *server)); - cli_rename(cluster->cli[*server], fname_src, fname_dst); + DEBUG(3,("smbcli_dfs_rename: Dfs rename %s to %s on server %s(%d)\n", + fname_src, fname_dst, smbcli_state_get_host(cluster->cli[*server]), *server)); + smbcli_rename(cluster->cli[*server], fname_src, fname_dst); } - if (cli_is_error(cluster->cli[*server])) { - printf("cli_dfs_rename: rename of %s to %s failed (%s)\n", - fname_src, fname_dst, cli_errstr(cluster->cli[*server])); + if (smbcli_is_error(cluster->cli[*server])) { + printf("smbcli_dfs_rename: rename of %s to %s failed (%s)\n", + fname_src, fname_dst, smbcli_errstr(cluster->cli[*server])); return False; } } @@ -471,24 +471,24 @@ BOOL cli_dfs_rename(struct cli_client* cluster, int *server, Make directory (allowing for Dfs referral). ****************************************************************************/ -BOOL cli_dfs_mkdir(struct cli_client* cluster, int *server, +BOOL smbcli_dfs_mkdir(struct smbcli_client* cluster, int *server, char *fname_src) { int referral_number; dfs_info dinfo; char *referral_fname; - DEBUG(3,("cli_dfs_mkdir: mkdir %s on server %s(%d)\n", - fname_src, cli_state_get_host(cluster->cli[*server]), *server)); + DEBUG(3,("smbcli_dfs_mkdir: mkdir %s on server %s(%d)\n", + fname_src, smbcli_state_get_host(cluster->cli[*server]), *server)); cluster->cli[*server]->dfs_referral = *server; - if (!cli_mkdir(cluster->cli[*server], fname_src)) { - printf("cli_dfs_mkdir: mkdir of %s failed (%s)\n", - fname_src, cli_errstr(cluster->cli[*server])); - if (cli_check_dfs_redirect(cluster->cli[*server], fname_src, &dinfo)) { + if (!smbcli_mkdir(cluster->cli[*server], fname_src)) { + printf("smbcli_dfs_mkdir: mkdir of %s failed (%s)\n", + fname_src, smbcli_errstr(cluster->cli[*server])); + if (smbcli_check_dfs_redirect(cluster->cli[*server], fname_src, &dinfo)) { // choose referral, check if already connected, open if not referral_number = dinfo.selected_referral; - DEBUG(3,("cli_dfs_mkdir: redirecting to %s\n", dinfo.referrals[referral_number].node)); - cluster->cli[*server]->dfs_referral = cli_dfs_open_connection(cluster, + DEBUG(3,("smbcli_dfs_mkdir: redirecting to %s\n", dinfo.referrals[referral_number].node)); + cluster->cli[*server]->dfs_referral = smbcli_dfs_open_connection(cluster, dinfo.referrals[referral_number].host, dinfo.referrals[referral_number].share, cluster->connection_flags); @@ -499,13 +499,13 @@ BOOL cli_dfs_mkdir(struct cli_client* cluster, int *server, if (rebuild_filename(referral_fname, cluster->cli[*server], fname_src, dinfo.path_consumed) == NULL) return False; fname_src = referral_fname; - DEBUG(3,("cli_dfs_mkdir: Dfs mkdir %s on server %s(%d)\n", - fname_src, cli_state_get_host(cluster->cli[*server]), *server)); - cli_mkdir(cluster->cli[*server], fname_src); + DEBUG(3,("smbcli_dfs_mkdir: Dfs mkdir %s on server %s(%d)\n", + fname_src, smbcli_state_get_host(cluster->cli[*server]), *server)); + smbcli_mkdir(cluster->cli[*server], fname_src); } - if (cli_is_error(cluster->cli[*server])) { - printf("cli_dfs_mkdir: mkdir of %s failed (%s)\n", - fname_src, cli_errstr(cluster->cli[*server])); + if (smbcli_is_error(cluster->cli[*server])) { + printf("smbcli_dfs_mkdir: mkdir of %s failed (%s)\n", + fname_src, smbcli_errstr(cluster->cli[*server])); return False; } } @@ -516,24 +516,24 @@ BOOL cli_dfs_mkdir(struct cli_client* cluster, int *server, Remove directory (allowing for Dfs referral). ****************************************************************************/ -BOOL cli_dfs_rmdir(struct cli_client* cluster, int *server, +BOOL smbcli_dfs_rmdir(struct smbcli_client* cluster, int *server, char *fname_src) { int referral_number; dfs_info dinfo; char *referral_fname; - DEBUG(3,("cli_dfs_rmdir: rmdir %s on server %s(%d)\n", - fname_src, cli_state_get_host(cluster->cli[*server]), *server)); + DEBUG(3,("smbcli_dfs_rmdir: rmdir %s on server %s(%d)\n", + fname_src, smbcli_state_get_host(cluster->cli[*server]), *server)); cluster->cli[*server]->dfs_referral = *server; - if (!cli_rmdir(cluster->cli[*server], fname_src)) { - printf("cli_dfs_rmdir: rmdir of %s failed (%s)\n", - fname_src, cli_errstr(cluster->cli[*server])); - if (cli_check_dfs_redirect(cluster->cli[*server], fname_src, &dinfo)) { + if (!smbcli_rmdir(cluster->cli[*server], fname_src)) { + printf("smbcli_dfs_rmdir: rmdir of %s failed (%s)\n", + fname_src, smbcli_errstr(cluster->cli[*server])); + if (smbcli_check_dfs_redirect(cluster->cli[*server], fname_src, &dinfo)) { // choose referral, check if already connected, open if not referral_number = dinfo.selected_referral; - DEBUG(3,("cli_dfs_rmdir: redirecting to %s\n", dinfo.referrals[referral_number].node)); - cluster->cli[*server]->dfs_referral = cli_dfs_open_connection(cluster, + DEBUG(3,("smbcli_dfs_rmdir: redirecting to %s\n", dinfo.referrals[referral_number].node)); + cluster->cli[*server]->dfs_referral = smbcli_dfs_open_connection(cluster, dinfo.referrals[referral_number].host, dinfo.referrals[referral_number].share, cluster->connection_flags); @@ -544,13 +544,13 @@ BOOL cli_dfs_rmdir(struct cli_client* cluster, int *server, if (rebuild_filename(referral_fname, cluster->cli[*server], fname_src, dinfo.path_consumed) == NULL) return False; fname_src = referral_fname; - DEBUG(3,("cli_dfs_rmdir: Dfs rmdir %s on server %s(%d)\n", - fname_src, cli_state_get_host(cluster->cli[*server]), *server)); - cli_rmdir(cluster->cli[*server], fname_src); + DEBUG(3,("smbcli_dfs_rmdir: Dfs rmdir %s on server %s(%d)\n", + fname_src, smbcli_state_get_host(cluster->cli[*server]), *server)); + smbcli_rmdir(cluster->cli[*server], fname_src); } - if (cli_is_error(cluster->cli[*server])) { - printf("cli_dfs_rmdir: rmdir of %s failed (%s)\n", - fname_src, cli_errstr(cluster->cli[*server])); + if (smbcli_is_error(cluster->cli[*server])) { + printf("smbcli_dfs_rmdir: rmdir of %s failed (%s)\n", + fname_src, smbcli_errstr(cluster->cli[*server])); return False; } } diff --git a/source4/libcli/clifile.c b/source4/libcli/clifile.c index b3acb9136a..d3ebe0bf72 100644 --- a/source4/libcli/clifile.c +++ b/source4/libcli/clifile.c @@ -26,7 +26,7 @@ Hard/Symlink a file (UNIX extensions). ****************************************************************************/ -static NTSTATUS cli_link_internal(struct cli_tree *tree, +static NTSTATUS smbcli_link_internal(struct smbcli_tree *tree, const char *fname_src, const char *fname_dst, BOOL hard_link) { @@ -79,26 +79,26 @@ static uint32_t unix_perms_to_wire(mode_t perms) /**************************************************************************** Symlink a file (UNIX extensions). ****************************************************************************/ -NTSTATUS cli_unix_symlink(struct cli_tree *tree, const char *fname_src, +NTSTATUS smbcli_unix_symlink(struct smbcli_tree *tree, const char *fname_src, const char *fname_dst) { - return cli_link_internal(tree, fname_src, fname_dst, False); + return smbcli_link_internal(tree, fname_src, fname_dst, False); } /**************************************************************************** Hard a file (UNIX extensions). ****************************************************************************/ -NTSTATUS cli_unix_hardlink(struct cli_tree *tree, const char *fname_src, +NTSTATUS smbcli_unix_hardlink(struct smbcli_tree *tree, const char *fname_src, const char *fname_dst) { - return cli_link_internal(tree, fname_src, fname_dst, True); + return smbcli_link_internal(tree, fname_src, fname_dst, True); } /**************************************************************************** Chmod or chown a file internal (UNIX extensions). ****************************************************************************/ -static NTSTATUS cli_unix_chmod_chown_internal(struct cli_tree *tree, +static NTSTATUS smbcli_unix_chmod_chown_internal(struct smbcli_tree *tree, const char *fname, uint32_t mode, uint32_t uid, uint32_t gid) @@ -121,9 +121,9 @@ static NTSTATUS cli_unix_chmod_chown_internal(struct cli_tree *tree, chmod a file (UNIX extensions). ****************************************************************************/ -NTSTATUS cli_unix_chmod(struct cli_tree *tree, const char *fname, mode_t mode) +NTSTATUS smbcli_unix_chmod(struct smbcli_tree *tree, const char *fname, mode_t mode) { - return cli_unix_chmod_chown_internal(tree, fname, + return smbcli_unix_chmod_chown_internal(tree, fname, unix_perms_to_wire(mode), SMB_UID_NO_CHANGE, SMB_GID_NO_CHANGE); @@ -132,10 +132,10 @@ NTSTATUS cli_unix_chmod(struct cli_tree *tree, const char *fname, mode_t mode) /**************************************************************************** chown a file (UNIX extensions). ****************************************************************************/ -NTSTATUS cli_unix_chown(struct cli_tree *tree, const char *fname, uid_t uid, +NTSTATUS smbcli_unix_chown(struct smbcli_tree *tree, const char *fname, uid_t uid, gid_t gid) { - return cli_unix_chmod_chown_internal(tree, fname, SMB_MODE_NO_CHANGE, + return smbcli_unix_chmod_chown_internal(tree, fname, SMB_MODE_NO_CHANGE, (uint32_t)uid, (uint32_t)gid); } @@ -143,7 +143,7 @@ NTSTATUS cli_unix_chown(struct cli_tree *tree, const char *fname, uid_t uid, /**************************************************************************** Rename a file. ****************************************************************************/ -NTSTATUS cli_rename(struct cli_tree *tree, const char *fname_src, +NTSTATUS smbcli_rename(struct smbcli_tree *tree, const char *fname_src, const char *fname_dst) { union smb_rename parms; @@ -160,7 +160,7 @@ NTSTATUS cli_rename(struct cli_tree *tree, const char *fname_src, /**************************************************************************** Delete a file. ****************************************************************************/ -NTSTATUS cli_unlink(struct cli_tree *tree, const char *fname) +NTSTATUS smbcli_unlink(struct smbcli_tree *tree, const char *fname) { struct smb_unlink parms; @@ -177,7 +177,7 @@ NTSTATUS cli_unlink(struct cli_tree *tree, const char *fname) /**************************************************************************** Create a directory. ****************************************************************************/ -NTSTATUS cli_mkdir(struct cli_tree *tree, const char *dname) +NTSTATUS smbcli_mkdir(struct smbcli_tree *tree, const char *dname) { union smb_mkdir parms; @@ -191,7 +191,7 @@ NTSTATUS cli_mkdir(struct cli_tree *tree, const char *dname) /**************************************************************************** Remove a directory. ****************************************************************************/ -NTSTATUS cli_rmdir(struct cli_tree *tree, const char *dname) +NTSTATUS smbcli_rmdir(struct smbcli_tree *tree, const char *dname) { struct smb_rmdir parms; @@ -204,7 +204,7 @@ NTSTATUS cli_rmdir(struct cli_tree *tree, const char *dname) /**************************************************************************** Set or clear the delete on close flag. ****************************************************************************/ -NTSTATUS cli_nt_delete_on_close(struct cli_tree *tree, int fnum, BOOL flag) +NTSTATUS smbcli_nt_delete_on_close(struct smbcli_tree *tree, int fnum, BOOL flag) { union smb_setfileinfo parms; NTSTATUS status; @@ -223,7 +223,7 @@ NTSTATUS cli_nt_delete_on_close(struct cli_tree *tree, int fnum, BOOL flag) Create/open a file - exposing the full horror of the NT API :-). Used in CIFS-on-CIFS NTVFS. ****************************************************************************/ -int cli_nt_create_full(struct cli_tree *tree, const char *fname, +int smbcli_nt_create_full(struct smbcli_tree *tree, const char *fname, uint32_t CreatFlags, uint32_t DesiredAccess, uint32_t FileAttributes, uint32_t ShareAccess, uint32_t CreateDisposition, uint32_t CreateOptions, @@ -264,7 +264,7 @@ int cli_nt_create_full(struct cli_tree *tree, const char *fname, Open a file (using SMBopenx) WARNING: if you open with O_WRONLY then getattrE won't work! ****************************************************************************/ -int cli_open(struct cli_tree *tree, const char *fname, int flags, +int smbcli_open(struct smbcli_tree *tree, const char *fname, int flags, int share_mode) { union smb_open open_parms; @@ -330,7 +330,7 @@ int cli_open(struct cli_tree *tree, const char *fname, int flags, /**************************************************************************** Close a file. ****************************************************************************/ -NTSTATUS cli_close(struct cli_tree *tree, int fnum) +NTSTATUS smbcli_close(struct smbcli_tree *tree, int fnum) { union smb_close close_parms; NTSTATUS status; @@ -346,7 +346,7 @@ NTSTATUS cli_close(struct cli_tree *tree, int fnum) send a lock with a specified locktype this is used for testing LOCKING_ANDX_CANCEL_LOCK ****************************************************************************/ -NTSTATUS cli_locktype(struct cli_tree *tree, int fnum, +NTSTATUS smbcli_locktype(struct smbcli_tree *tree, int fnum, uint32_t offset, uint32_t len, int timeout, uint8_t locktype) { @@ -374,7 +374,7 @@ NTSTATUS cli_locktype(struct cli_tree *tree, int fnum, /**************************************************************************** Lock a file. ****************************************************************************/ -NTSTATUS cli_lock(struct cli_tree *tree, int fnum, +NTSTATUS smbcli_lock(struct smbcli_tree *tree, int fnum, uint32_t offset, uint32_t len, int timeout, enum brl_type lock_type) { @@ -402,7 +402,7 @@ NTSTATUS cli_lock(struct cli_tree *tree, int fnum, /**************************************************************************** Unlock a file. ****************************************************************************/ -NTSTATUS cli_unlock(struct cli_tree *tree, int fnum, uint32_t offset, uint32_t len) +NTSTATUS smbcli_unlock(struct smbcli_tree *tree, int fnum, uint32_t offset, uint32_t len) { union smb_lock parms; struct smb_lock_entry lock[1]; @@ -427,7 +427,7 @@ NTSTATUS cli_unlock(struct cli_tree *tree, int fnum, uint32_t offset, uint32_t l /**************************************************************************** Lock a file with 64 bit offsets. ****************************************************************************/ -NTSTATUS cli_lock64(struct cli_tree *tree, int fnum, +NTSTATUS smbcli_lock64(struct smbcli_tree *tree, int fnum, SMB_OFF_T offset, SMB_OFF_T len, int timeout, enum brl_type lock_type) { @@ -437,7 +437,7 @@ NTSTATUS cli_lock64(struct cli_tree *tree, int fnum, NTSTATUS status; if (!(tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES)) { - return cli_lock(tree, fnum, offset, len, timeout, lock_type); + return smbcli_lock(tree, fnum, offset, len, timeout, lock_type); } parms.lockx.level = RAW_LOCK_LOCKX; @@ -463,7 +463,7 @@ NTSTATUS cli_lock64(struct cli_tree *tree, int fnum, /**************************************************************************** Unlock a file with 64 bit offsets. ****************************************************************************/ -NTSTATUS cli_unlock64(struct cli_tree *tree, int fnum, SMB_OFF_T offset, +NTSTATUS smbcli_unlock64(struct smbcli_tree *tree, int fnum, SMB_OFF_T offset, SMB_OFF_T len) { union smb_lock parms; @@ -471,7 +471,7 @@ NTSTATUS cli_unlock64(struct cli_tree *tree, int fnum, SMB_OFF_T offset, NTSTATUS status; if (!(tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES)) { - return cli_unlock(tree, fnum, offset, len); + return smbcli_unlock(tree, fnum, offset, len); } parms.lockx.level = RAW_LOCK_LOCKX; @@ -494,7 +494,7 @@ NTSTATUS cli_unlock64(struct cli_tree *tree, int fnum, SMB_OFF_T offset, /**************************************************************************** Do a SMBgetattrE call. ****************************************************************************/ -NTSTATUS cli_getattrE(struct cli_tree *tree, int fnum, +NTSTATUS smbcli_getattrE(struct smbcli_tree *tree, int fnum, uint16_t *attr, size_t *size, time_t *c_time, time_t *a_time, time_t *m_time) { @@ -535,7 +535,7 @@ NTSTATUS cli_getattrE(struct cli_tree *tree, int fnum, /**************************************************************************** Do a SMBgetatr call ****************************************************************************/ -NTSTATUS cli_getatr(struct cli_tree *tree, const char *fname, +NTSTATUS smbcli_getatr(struct smbcli_tree *tree, const char *fname, uint16_t *attr, size_t *size, time_t *t) { union smb_fileinfo parms; @@ -569,7 +569,7 @@ NTSTATUS cli_getatr(struct cli_tree *tree, const char *fname, /**************************************************************************** Do a SMBsetatr call. ****************************************************************************/ -NTSTATUS cli_setatr(struct cli_tree *tree, const char *fname, uint16_t mode, +NTSTATUS smbcli_setatr(struct smbcli_tree *tree, const char *fname, uint16_t mode, time_t t) { union smb_setfileinfo parms; @@ -589,7 +589,7 @@ NTSTATUS cli_setatr(struct cli_tree *tree, const char *fname, uint16_t mode, /**************************************************************************** Check for existence of a dir. ****************************************************************************/ -NTSTATUS cli_chkpath(struct cli_tree *tree, const char *path) +NTSTATUS smbcli_chkpath(struct smbcli_tree *tree, const char *path) { struct smb_chkpath parms; char *path2; @@ -615,13 +615,13 @@ NTSTATUS cli_chkpath(struct cli_tree *tree, const char *path) /**************************************************************************** Query disk space. ****************************************************************************/ -NTSTATUS cli_dskattr(struct cli_tree *tree, int *bsize, int *total, int *avail) +NTSTATUS smbcli_dskattr(struct smbcli_tree *tree, int *bsize, int *total, int *avail) { union smb_fsinfo fsinfo_parms; TALLOC_CTX *mem_ctx; NTSTATUS status; - mem_ctx = talloc_init("cli_dskattr"); + mem_ctx = talloc_init("smbcli_dskattr"); fsinfo_parms.dskattr.level = RAW_QFS_DSKATTR; status = smb_raw_fsinfo(tree, mem_ctx, &fsinfo_parms); @@ -640,7 +640,7 @@ NTSTATUS cli_dskattr(struct cli_tree *tree, int *bsize, int *total, int *avail) /**************************************************************************** Create and open a temporary file. ****************************************************************************/ -int cli_ctemp(struct cli_tree *tree, const char *path, char **tmp_path) +int smbcli_ctemp(struct smbcli_tree *tree, const char *path, char **tmp_path) { union smb_open open_parms; TALLOC_CTX *mem_ctx; diff --git a/source4/libcli/clilist.c b/source4/libcli/clilist.c index 7dac7399a7..e2c267cc96 100644 --- a/source4/libcli/clilist.c +++ b/source4/libcli/clilist.c @@ -77,7 +77,7 @@ static BOOL interpret_long_filename(enum smb_search_level level, } /* callback function used for trans2 search */ -static BOOL cli_list_new_callback(void *private, union smb_search_data *file) +static BOOL smbcli_list_new_callback(void *private, union smb_search_data *file) { struct search_private *state = (struct search_private*) private; file_info *tdl; @@ -101,7 +101,7 @@ static BOOL cli_list_new_callback(void *private, union smb_search_data *file) return True; } -int cli_list_new(struct cli_tree *tree, const char *Mask, uint16_t attribute, +int smbcli_list_new(struct smbcli_tree *tree, const char *Mask, uint16_t attribute, void (*fn)(file_info *, const char *, void *), void *caller_state) { @@ -118,7 +118,7 @@ int cli_list_new(struct cli_tree *tree, const char *Mask, uint16_t attribute, /* initialize state for search */ state.dirlist = NULL; - state.mem_ctx = talloc_init("cli_list_new"); + state.mem_ctx = talloc_init("smbcli_list_new"); state.dirlist_len = 0; state.total_received = 0; @@ -144,7 +144,7 @@ int cli_list_new(struct cli_tree *tree, const char *Mask, uint16_t attribute, status = smb_raw_search_first(tree, state.mem_ctx, &first_parms, - (void*)&state, cli_list_new_callback); + (void*)&state, smbcli_list_new_callback); if (!NT_STATUS_IS_OK(status)) { talloc_destroy(state.mem_ctx); return -1; @@ -172,7 +172,7 @@ int cli_list_new(struct cli_tree *tree, const char *Mask, uint16_t attribute, state.mem_ctx, &next_parms, (void*)&state, - cli_list_new_callback); + smbcli_list_new_callback); if (!NT_STATUS_IS_OK(status)) { return -1; @@ -219,7 +219,7 @@ static BOOL interpret_short_filename(int level, } /* callback function used for smb_search */ -static BOOL cli_list_old_callback(void *private, union smb_search_data *file) +static BOOL smbcli_list_old_callback(void *private, union smb_search_data *file) { struct search_private *state = (struct search_private*) private; file_info *tdl; @@ -243,7 +243,7 @@ static BOOL cli_list_old_callback(void *private, union smb_search_data *file) return True; } -int cli_list_old(struct cli_tree *tree, const char *Mask, uint16_t attribute, +int smbcli_list_old(struct smbcli_tree *tree, const char *Mask, uint16_t attribute, void (*fn)(file_info *, const char *, void *), void *caller_state) { @@ -259,7 +259,7 @@ int cli_list_old(struct cli_tree *tree, const char *Mask, uint16_t attribute, /* initialize state for search */ state.dirlist = NULL; - state.mem_ctx = talloc_init("cli_list_old"); + state.mem_ctx = talloc_init("smbcli_list_old"); state.dirlist_len = 0; state.total_received = 0; @@ -278,7 +278,7 @@ int cli_list_old(struct cli_tree *tree, const char *Mask, uint16_t attribute, status = smb_raw_search_first(tree, state.mem_ctx, &first_parms, (void*)&state, - cli_list_old_callback); + smbcli_list_old_callback); if (!NT_STATUS_IS_OK(status)) { talloc_destroy(state.mem_ctx); @@ -299,7 +299,7 @@ int cli_list_old(struct cli_tree *tree, const char *Mask, uint16_t attribute, status = smb_raw_search_next(tree, state.mem_ctx, &next_parms, (void*)&state, - cli_list_old_callback); + smbcli_list_old_callback); if (!NT_STATUS_IS_OK(status)) { talloc_destroy(state.mem_ctx); @@ -326,10 +326,10 @@ int cli_list_old(struct cli_tree *tree, const char *Mask, uint16_t attribute, This auto-switches between old and new style. ****************************************************************************/ -int cli_list(struct cli_tree *tree, const char *Mask,uint16_t attribute, +int smbcli_list(struct smbcli_tree *tree, const char *Mask,uint16_t attribute, void (*fn)(file_info *, const char *, void *), void *state) { if (tree->session->transport->negotiate.protocol <= PROTOCOL_LANMAN1) - return cli_list_old(tree, Mask, attribute, fn, state); - return cli_list_new(tree, Mask, attribute, fn, state); + return smbcli_list_old(tree, Mask, attribute, fn, state); + return smbcli_list_new(tree, Mask, attribute, fn, state); } diff --git a/source4/libcli/climessage.c b/source4/libcli/climessage.c index 6470f4c154..dde512159e 100644 --- a/source4/libcli/climessage.c +++ b/source4/libcli/climessage.c @@ -25,23 +25,23 @@ /**************************************************************************** start a message sequence ****************************************************************************/ -BOOL cli_message_start(struct cli_tree *tree, char *host, char *username, +BOOL smbcli_message_start(struct smbcli_tree *tree, char *host, char *username, int *grp) { - struct cli_request *req; + struct smbcli_request *req; - req = cli_request_setup(tree, SMBsendstrt, 0, 0); - cli_req_append_string(req, username, STR_TERMINATE); - cli_req_append_string(req, host, STR_TERMINATE); - if (!cli_request_send(req) || - !cli_request_receive(req) || - cli_is_error(tree)) { - cli_request_destroy(req); + req = smbcli_request_setup(tree, SMBsendstrt, 0, 0); + smbcli_req_append_string(req, username, STR_TERMINATE); + smbcli_req_append_string(req, host, STR_TERMINATE); + if (!smbcli_request_send(req) || + !smbcli_request_receive(req) || + smbcli_is_error(tree)) { + smbcli_request_destroy(req); return False; } *grp = SVAL(req->in.vwv, VWV(0)); - cli_request_destroy(req); + smbcli_request_destroy(req); return True; } @@ -50,44 +50,44 @@ BOOL cli_message_start(struct cli_tree *tree, char *host, char *username, /**************************************************************************** send a message ****************************************************************************/ -BOOL cli_message_text(struct cli_tree *tree, char *msg, int len, int grp) +BOOL smbcli_message_text(struct smbcli_tree *tree, char *msg, int len, int grp) { - struct cli_request *req; + struct smbcli_request *req; - req = cli_request_setup(tree, SMBsendtxt, 1, 0); + req = smbcli_request_setup(tree, SMBsendtxt, 1, 0); SSVAL(req->out.vwv, VWV(0), grp); - cli_req_append_bytes(req, msg, len); + smbcli_req_append_bytes(req, msg, len); - if (!cli_request_send(req) || - !cli_request_receive(req) || - cli_is_error(tree)) { - cli_request_destroy(req); + if (!smbcli_request_send(req) || + !smbcli_request_receive(req) || + smbcli_is_error(tree)) { + smbcli_request_destroy(req); return False; } - cli_request_destroy(req); + smbcli_request_destroy(req); return True; } /**************************************************************************** end a message ****************************************************************************/ -BOOL cli_message_end(struct cli_tree *tree, int grp) +BOOL smbcli_message_end(struct smbcli_tree *tree, int grp) { - struct cli_request *req; + struct smbcli_request *req; - req = cli_request_setup(tree, SMBsendend, 1, 0); + req = smbcli_request_setup(tree, SMBsendend, 1, 0); SSVAL(req->out.vwv, VWV(0), grp); - if (!cli_request_send(req) || - !cli_request_receive(req) || - cli_is_error(tree)) { - cli_request_destroy(req); + if (!smbcli_request_send(req) || + !smbcli_request_receive(req) || + smbcli_is_error(tree)) { + smbcli_request_destroy(req); return False; } - cli_request_destroy(req); + smbcli_request_destroy(req); return True; } diff --git a/source4/libcli/clireadwrite.c b/source4/libcli/clireadwrite.c index e9c8b80c4f..dd9f8d44cc 100644 --- a/source4/libcli/clireadwrite.c +++ b/source4/libcli/clireadwrite.c @@ -24,7 +24,7 @@ /**************************************************************************** Read size bytes at offset offset using SMBreadX. ****************************************************************************/ -ssize_t cli_read(struct cli_tree *tree, int fnum, char *buf, off_t offset, +ssize_t smbcli_read(struct smbcli_tree *tree, int fnum, char *buf, off_t offset, size_t size) { union smb_read parms; @@ -82,7 +82,7 @@ ssize_t cli_read(struct cli_tree *tree, int fnum, char *buf, off_t offset, 0x0004 use raw named pipe protocol 0x0008 start of message mode named pipe protocol ****************************************************************************/ -ssize_t cli_write(struct cli_tree *tree, +ssize_t smbcli_write(struct smbcli_tree *tree, int fnum, uint16_t write_mode, const char *buf, off_t offset, size_t size) { @@ -128,7 +128,7 @@ ssize_t cli_write(struct cli_tree *tree, /**************************************************************************** write to a file using a SMBwrite and not bypassing 0 byte writes ****************************************************************************/ -ssize_t cli_smbwrite(struct cli_tree *tree, +ssize_t smbcli_smbwrite(struct smbcli_tree *tree, int fnum, char *buf, off_t offset, size_t size1) { union smb_write parms; diff --git a/source4/libcli/clisecdesc.c b/source4/libcli/clisecdesc.c index 7f3ec0f6bf..4c8b49fc67 100644 --- a/source4/libcli/clisecdesc.c +++ b/source4/libcli/clisecdesc.c @@ -24,7 +24,7 @@ /**************************************************************************** query the security descriptor for a open file ****************************************************************************/ -SEC_DESC *cli_query_secdesc(struct cli_tree *tree, int fnum, +SEC_DESC *smbcli_query_secdesc(struct smbcli_tree *tree, int fnum, TALLOC_CTX *mem_ctx) { struct smb_nttrans parms; @@ -72,7 +72,7 @@ SEC_DESC *cli_query_secdesc(struct cli_tree *tree, int fnum, /**************************************************************************** set the security descriptor for a open file ****************************************************************************/ -BOOL cli_set_secdesc(struct cli_tree *tree, int fnum, SEC_DESC *sd) +BOOL smbcli_set_secdesc(struct smbcli_tree *tree, int fnum, SEC_DESC *sd) { struct smb_nttrans parms; char param[8]; @@ -82,7 +82,7 @@ BOOL cli_set_secdesc(struct cli_tree *tree, int fnum, SEC_DESC *sd) TALLOC_CTX *mem_ctx; NTSTATUS status; - mem_ctx = talloc_init("cli_set_secdesc"); + mem_ctx = talloc_init("smbcli_set_secdesc"); prs_init(&pd, 0, mem_ctx, MARSHALL); prs_give_memory(&pd, NULL, 0, True); diff --git a/source4/libcli/clitrans2.c b/source4/libcli/clitrans2.c index a83660685b..7a37df6e1f 100644 --- a/source4/libcli/clitrans2.c +++ b/source4/libcli/clitrans2.c @@ -23,7 +23,7 @@ /**************************************************************************** send a qpathinfo call ****************************************************************************/ -NTSTATUS cli_qpathinfo(struct cli_tree *tree, const char *fname, +NTSTATUS smbcli_qpathinfo(struct smbcli_tree *tree, const char *fname, time_t *c_time, time_t *a_time, time_t *m_time, size_t *size, uint16_t *mode) { @@ -31,7 +31,7 @@ NTSTATUS cli_qpathinfo(struct cli_tree *tree, const char *fname, TALLOC_CTX *mem_ctx; NTSTATUS status; - mem_ctx = talloc_init("cli_qpathinfo"); + mem_ctx = talloc_init("smbcli_qpathinfo"); if (!mem_ctx) return NT_STATUS_NO_MEMORY; parms.standard.level = RAW_FILEINFO_STANDARD; @@ -64,7 +64,7 @@ NTSTATUS cli_qpathinfo(struct cli_tree *tree, const char *fname, /**************************************************************************** send a qpathinfo call with the SMB_QUERY_FILE_ALL_INFO info level ****************************************************************************/ -NTSTATUS cli_qpathinfo2(struct cli_tree *tree, const char *fname, +NTSTATUS smbcli_qpathinfo2(struct smbcli_tree *tree, const char *fname, time_t *c_time, time_t *a_time, time_t *m_time, time_t *w_time, size_t *size, uint16_t *mode, SMB_INO_T *ino) @@ -73,7 +73,7 @@ NTSTATUS cli_qpathinfo2(struct cli_tree *tree, const char *fname, TALLOC_CTX *mem_ctx; NTSTATUS status; - mem_ctx = talloc_init("cli_qfilename"); + mem_ctx = talloc_init("smbcli_qfilename"); if (!mem_ctx) return NT_STATUS_NO_MEMORY; parms.all_info.level = RAW_FILEINFO_ALL_INFO; @@ -110,13 +110,13 @@ NTSTATUS cli_qpathinfo2(struct cli_tree *tree, const char *fname, /**************************************************************************** send a qfileinfo QUERY_FILE_NAME_INFO call ****************************************************************************/ -NTSTATUS cli_qfilename(struct cli_tree *tree, int fnum, const char **name) +NTSTATUS smbcli_qfilename(struct smbcli_tree *tree, int fnum, const char **name) { union smb_fileinfo parms; TALLOC_CTX *mem_ctx; NTSTATUS status; - mem_ctx = talloc_init("cli_qfilename"); + mem_ctx = talloc_init("smbcli_qfilename"); if (!mem_ctx) return NT_STATUS_NO_MEMORY; parms.name_info.level = RAW_FILEINFO_NAME_INFO; @@ -140,7 +140,7 @@ NTSTATUS cli_qfilename(struct cli_tree *tree, int fnum, const char **name) /**************************************************************************** send a qfileinfo call ****************************************************************************/ -NTSTATUS cli_qfileinfo(struct cli_tree *tree, int fnum, +NTSTATUS smbcli_qfileinfo(struct smbcli_tree *tree, int fnum, uint16_t *mode, size_t *size, time_t *c_time, time_t *a_time, time_t *m_time, time_t *w_time, SMB_INO_T *ino) @@ -149,7 +149,7 @@ NTSTATUS cli_qfileinfo(struct cli_tree *tree, int fnum, TALLOC_CTX *mem_ctx; NTSTATUS status; - mem_ctx = talloc_init("cli_qfileinfo"); + mem_ctx = talloc_init("smbcli_qfileinfo"); if (!mem_ctx) return NT_STATUS_NO_MEMORY; @@ -191,7 +191,7 @@ NTSTATUS cli_qfileinfo(struct cli_tree *tree, int fnum, /**************************************************************************** send a qpathinfo SMB_QUERY_FILE_ALT_NAME_INFO call ****************************************************************************/ -NTSTATUS cli_qpathinfo_alt_name(struct cli_tree *tree, const char *fname, +NTSTATUS smbcli_qpathinfo_alt_name(struct smbcli_tree *tree, const char *fname, const char **alt_name) { union smb_fileinfo parms; @@ -201,14 +201,14 @@ NTSTATUS cli_qpathinfo_alt_name(struct cli_tree *tree, const char *fname, parms.alt_name_info.level = RAW_FILEINFO_ALT_NAME_INFO; parms.alt_name_info.in.fname = fname; - mem_ctx = talloc_init("cli_qpathinfo_alt_name"); + mem_ctx = talloc_init("smbcli_qpathinfo_alt_name"); if (!mem_ctx) return NT_STATUS_NO_MEMORY; status = smb_raw_pathinfo(tree, mem_ctx, &parms); if (!NT_STATUS_IS_OK(status)) { talloc_destroy(mem_ctx); *alt_name = NULL; - return cli_nt_error(tree); + return smbcli_nt_error(tree); } if (!parms.alt_name_info.out.fname.s) { diff --git a/source4/libcli/namequery_dc.c b/source4/libcli/namequery_dc.c index ffc64139e9..16e5282497 100644 --- a/source4/libcli/namequery_dc.c +++ b/source4/libcli/namequery_dc.c @@ -90,7 +90,7 @@ done: /* We have the netbios name and IP address of a domain controller. Ideally we should sent a SAMLOGON request to determine whether the DC is alive and kicking. If we can catch a dead DC before - performing a cli_connect() we can avoid a 30-second timeout. */ + performing a smbcli_connect() we can avoid a 30-second timeout. */ DEBUG(3, ("rpc_find_dc: Returning DC %s (%s) for domain %s\n", srv_name, inet_ntoa(dc_ip), domain)); diff --git a/source4/libcli/raw/clioplock.c b/source4/libcli/raw/clioplock.c index 29e44fc940..6ae21a08f4 100644 --- a/source4/libcli/raw/clioplock.c +++ b/source4/libcli/raw/clioplock.c @@ -23,12 +23,12 @@ /**************************************************************************** send an ack for an oplock break request ****************************************************************************/ -BOOL cli_oplock_ack(struct cli_tree *tree, uint16_t fnum, uint16_t ack_level) +BOOL smbcli_oplock_ack(struct smbcli_tree *tree, uint16_t fnum, uint16_t ack_level) { BOOL ret; - struct cli_request *req; + struct smbcli_request *req; - req = cli_request_setup(tree, SMBlockingX, 8, 0); + req = smbcli_request_setup(tree, SMBlockingX, 8, 0); SSVAL(req->out.vwv,VWV(0),0xFF); SSVAL(req->out.vwv,VWV(1),0); @@ -43,7 +43,7 @@ BOOL cli_oplock_ack(struct cli_tree *tree, uint16_t fnum, uint16_t ack_level) subsystem not to allocate an id for a reply */ req->one_way_request = 1; - ret = cli_request_send(req); + ret = smbcli_request_send(req); return ret; } @@ -52,8 +52,8 @@ BOOL cli_oplock_ack(struct cli_tree *tree, uint16_t fnum, uint16_t ack_level) /**************************************************************************** set the oplock handler for a connection ****************************************************************************/ -void cli_oplock_handler(struct cli_transport *transport, - BOOL (*handler)(struct cli_transport *, uint16_t, uint16_t, uint8_t, void *), +void smbcli_oplock_handler(struct smbcli_transport *transport, + BOOL (*handler)(struct smbcli_transport *, uint16_t, uint16_t, uint8_t, void *), void *private) { transport->oplock.handler = handler; diff --git a/source4/libcli/raw/clisession.c b/source4/libcli/raw/clisession.c index d5373bc76f..b32d59f340 100644 --- a/source4/libcli/raw/clisession.c +++ b/source4/libcli/raw/clisession.c @@ -22,17 +22,17 @@ #include "includes.h" #define SETUP_REQUEST_SESSION(cmd, wct, buflen) do { \ - req = cli_request_setup_session(session, cmd, wct, buflen); \ + req = smbcli_request_setup_session(session, cmd, wct, buflen); \ if (!req) return NULL; \ } while (0) /**************************************************************************** Initialize the session context ****************************************************************************/ -struct cli_session *cli_session_init(struct cli_transport *transport) +struct smbcli_session *smbcli_session_init(struct smbcli_transport *transport) { - struct cli_session *session; - TALLOC_CTX *mem_ctx = talloc_init("cli_session"); + struct smbcli_session *session; + TALLOC_CTX *mem_ctx = talloc_init("smbcli_session"); if (mem_ctx == NULL) { return NULL; } @@ -55,11 +55,11 @@ struct cli_session *cli_session_init(struct cli_transport *transport) /**************************************************************************** reduce reference_count and destroy is <= 0 ****************************************************************************/ -void cli_session_close(struct cli_session *session) +void smbcli_session_close(struct smbcli_session *session) { session->reference_count--; if (session->reference_count <= 0) { - cli_transport_close(session->transport); + smbcli_transport_close(session->transport); talloc_destroy(session->mem_ctx); } } @@ -67,9 +67,9 @@ void cli_session_close(struct cli_session *session) /**************************************************************************** Perform a session setup (async send) ****************************************************************************/ -struct cli_request *smb_raw_session_setup_send(struct cli_session *session, union smb_sesssetup *parms) +struct smbcli_request *smb_raw_session_setup_send(struct smbcli_session *session, union smb_sesssetup *parms) { - struct cli_request *req; + struct smbcli_request *req; switch (parms->generic.level) { case RAW_SESSSETUP_GENERIC: @@ -85,11 +85,11 @@ struct cli_request *smb_raw_session_setup_send(struct cli_session *session, unio SSVAL(req->out.vwv,VWV(4),parms->old.in.vc_num); SIVAL(req->out.vwv,VWV(5),parms->old.in.sesskey); SSVAL(req->out.vwv,VWV(7),parms->old.in.password.length); - cli_req_append_blob(req, &parms->old.in.password); - cli_req_append_string(req, parms->old.in.user, STR_TERMINATE); - cli_req_append_string(req, parms->old.in.domain, STR_TERMINATE|STR_UPPER); - cli_req_append_string(req, parms->old.in.os, STR_TERMINATE); - cli_req_append_string(req, parms->old.in.lanman, STR_TERMINATE); + smbcli_req_append_blob(req, &parms->old.in.password); + smbcli_req_append_string(req, parms->old.in.user, STR_TERMINATE); + smbcli_req_append_string(req, parms->old.in.domain, STR_TERMINATE|STR_UPPER); + smbcli_req_append_string(req, parms->old.in.os, STR_TERMINATE); + smbcli_req_append_string(req, parms->old.in.lanman, STR_TERMINATE); break; case RAW_SESSSETUP_NT1: @@ -104,12 +104,12 @@ struct cli_request *smb_raw_session_setup_send(struct cli_session *session, unio SSVAL(req->out.vwv, VWV(8), parms->nt1.in.password2.length); SIVAL(req->out.vwv, VWV(9), 0); /* reserved */ SIVAL(req->out.vwv, VWV(11), parms->nt1.in.capabilities); - cli_req_append_blob(req, &parms->nt1.in.password1); - cli_req_append_blob(req, &parms->nt1.in.password2); - cli_req_append_string(req, parms->nt1.in.user, STR_TERMINATE); - cli_req_append_string(req, parms->nt1.in.domain, STR_TERMINATE|STR_UPPER); - cli_req_append_string(req, parms->nt1.in.os, STR_TERMINATE); - cli_req_append_string(req, parms->nt1.in.lanman, STR_TERMINATE); + smbcli_req_append_blob(req, &parms->nt1.in.password1); + smbcli_req_append_blob(req, &parms->nt1.in.password2); + smbcli_req_append_string(req, parms->nt1.in.user, STR_TERMINATE); + smbcli_req_append_string(req, parms->nt1.in.domain, STR_TERMINATE|STR_UPPER); + smbcli_req_append_string(req, parms->nt1.in.os, STR_TERMINATE); + smbcli_req_append_string(req, parms->nt1.in.lanman, STR_TERMINATE); break; case RAW_SESSSETUP_SPNEGO: @@ -123,15 +123,15 @@ struct cli_request *smb_raw_session_setup_send(struct cli_session *session, unio SSVAL(req->out.vwv, VWV(7), parms->spnego.in.secblob.length); SIVAL(req->out.vwv, VWV(8), 0); /* reserved */ SIVAL(req->out.vwv, VWV(10), parms->spnego.in.capabilities); - cli_req_append_blob(req, &parms->spnego.in.secblob); - cli_req_append_string(req, parms->spnego.in.os, STR_TERMINATE); - cli_req_append_string(req, parms->spnego.in.lanman, STR_TERMINATE); - cli_req_append_string(req, parms->spnego.in.domain, STR_TERMINATE); + smbcli_req_append_blob(req, &parms->spnego.in.secblob); + smbcli_req_append_string(req, parms->spnego.in.os, STR_TERMINATE); + smbcli_req_append_string(req, parms->spnego.in.lanman, STR_TERMINATE); + smbcli_req_append_string(req, parms->spnego.in.domain, STR_TERMINATE); break; } - if (!cli_request_send(req)) { - cli_request_destroy(req); + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); return NULL; } @@ -142,20 +142,20 @@ struct cli_request *smb_raw_session_setup_send(struct cli_session *session, unio /**************************************************************************** Perform a session setup (async recv) ****************************************************************************/ -NTSTATUS smb_raw_session_setup_recv(struct cli_request *req, +NTSTATUS smb_raw_session_setup_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, union smb_sesssetup *parms) { uint16_t len; char *p; - if (!cli_request_receive(req)) { - return cli_request_destroy(req); + if (!smbcli_request_receive(req)) { + return smbcli_request_destroy(req); } if (!NT_STATUS_IS_OK(req->status) && !NT_STATUS_EQUAL(req->status,NT_STATUS_MORE_PROCESSING_REQUIRED)) { - return cli_request_destroy(req); + return smbcli_request_destroy(req); } switch (parms->generic.level) { @@ -164,35 +164,35 @@ NTSTATUS smb_raw_session_setup_recv(struct cli_request *req, return NT_STATUS_INVALID_LEVEL; case RAW_SESSSETUP_OLD: - CLI_CHECK_WCT(req, 3); + SMBCLI_CHECK_WCT(req, 3); ZERO_STRUCT(parms->old.out); parms->old.out.vuid = SVAL(req->in.hdr, HDR_UID); parms->old.out.action = SVAL(req->in.vwv, VWV(2)); p = req->in.data; if (p) { - p += cli_req_pull_string(req, mem_ctx, &parms->old.out.os, p, -1, STR_TERMINATE); - p += cli_req_pull_string(req, mem_ctx, &parms->old.out.lanman, p, -1, STR_TERMINATE); - p += cli_req_pull_string(req, mem_ctx, &parms->old.out.domain, p, -1, STR_TERMINATE); + p += smbcli_req_pull_string(req, mem_ctx, &parms->old.out.os, p, -1, STR_TERMINATE); + p += smbcli_req_pull_string(req, mem_ctx, &parms->old.out.lanman, p, -1, STR_TERMINATE); + p += smbcli_req_pull_string(req, mem_ctx, &parms->old.out.domain, p, -1, STR_TERMINATE); } break; case RAW_SESSSETUP_NT1: - CLI_CHECK_WCT(req, 3); + SMBCLI_CHECK_WCT(req, 3); ZERO_STRUCT(parms->nt1.out); parms->nt1.out.vuid = SVAL(req->in.hdr, HDR_UID); parms->nt1.out.action = SVAL(req->in.vwv, VWV(2)); p = req->in.data; if (p) { - p += cli_req_pull_string(req, mem_ctx, &parms->nt1.out.os, p, -1, STR_TERMINATE); - p += cli_req_pull_string(req, mem_ctx, &parms->nt1.out.lanman, p, -1, STR_TERMINATE); + p += smbcli_req_pull_string(req, mem_ctx, &parms->nt1.out.os, p, -1, STR_TERMINATE); + p += smbcli_req_pull_string(req, mem_ctx, &parms->nt1.out.lanman, p, -1, STR_TERMINATE); if (p < (req->in.data + req->in.data_size)) { - p += cli_req_pull_string(req, mem_ctx, &parms->nt1.out.domain, p, -1, STR_TERMINATE); + p += smbcli_req_pull_string(req, mem_ctx, &parms->nt1.out.domain, p, -1, STR_TERMINATE); } } break; case RAW_SESSSETUP_SPNEGO: - CLI_CHECK_WCT(req, 4); + SMBCLI_CHECK_WCT(req, 4); ZERO_STRUCT(parms->spnego.out); parms->spnego.out.vuid = SVAL(req->in.hdr, HDR_UID); parms->spnego.out.action = SVAL(req->in.vwv, VWV(2)); @@ -202,16 +202,16 @@ NTSTATUS smb_raw_session_setup_recv(struct cli_request *req, break; } - parms->spnego.out.secblob = cli_req_pull_blob(req, mem_ctx, p, len); + parms->spnego.out.secblob = smbcli_req_pull_blob(req, mem_ctx, p, len); p += parms->spnego.out.secblob.length; - p += cli_req_pull_string(req, mem_ctx, &parms->spnego.out.os, p, -1, STR_TERMINATE); - p += cli_req_pull_string(req, mem_ctx, &parms->spnego.out.lanman, p, -1, STR_TERMINATE); - p += cli_req_pull_string(req, mem_ctx, &parms->spnego.out.domain, p, -1, STR_TERMINATE); + p += smbcli_req_pull_string(req, mem_ctx, &parms->spnego.out.os, p, -1, STR_TERMINATE); + p += smbcli_req_pull_string(req, mem_ctx, &parms->spnego.out.lanman, p, -1, STR_TERMINATE); + p += smbcli_req_pull_string(req, mem_ctx, &parms->spnego.out.domain, p, -1, STR_TERMINATE); break; } failed: - return cli_request_destroy(req); + return smbcli_request_destroy(req); } /* @@ -239,7 +239,7 @@ static DATA_BLOB nt_blob(const char *pass, DATA_BLOB challenge) /* store the user session key for a transport */ -void cli_session_set_user_session_key(struct cli_session *session, +void smbcli_session_set_user_session_key(struct smbcli_session *session, const DATA_BLOB *session_key) { session->user_session_key = data_blob_talloc(session->mem_ctx, @@ -250,19 +250,19 @@ void cli_session_set_user_session_key(struct cli_session *session, /* setup signing for a NT1 style session setup */ -static void use_nt1_session_keys(struct cli_session *session, +static void use_nt1_session_keys(struct smbcli_session *session, const char *password, const DATA_BLOB *nt_response) { - struct cli_transport *transport = session->transport; + struct smbcli_transport *transport = session->transport; uint8_t nt_hash[16]; DATA_BLOB session_key = data_blob(NULL, 16); E_md4hash(password, nt_hash); SMBsesskeygen_ntv1(nt_hash, session_key.data); - cli_transport_simple_set_signing(transport, session_key, *nt_response); + smbcli_transport_simple_set_signing(transport, session_key, *nt_response); - cli_session_set_user_session_key(session, &session_key); + smbcli_session_set_user_session_key(session, &session_key); data_blob_free(&session_key); } @@ -270,7 +270,7 @@ static void use_nt1_session_keys(struct cli_session *session, Perform a session setup (sync interface) using generic interface and the old style sesssetup call ****************************************************************************/ -static NTSTATUS smb_raw_session_setup_generic_old(struct cli_session *session, +static NTSTATUS smb_raw_session_setup_generic_old(struct smbcli_session *session, TALLOC_CTX *mem_ctx, union smb_sesssetup *parms) { @@ -319,7 +319,7 @@ static NTSTATUS smb_raw_session_setup_generic_old(struct cli_session *session, Perform a session setup (sync interface) using generic interface and the NT1 style sesssetup call ****************************************************************************/ -static NTSTATUS smb_raw_session_setup_generic_nt1(struct cli_session *session, +static NTSTATUS smb_raw_session_setup_generic_nt1(struct smbcli_session *session, TALLOC_CTX *mem_ctx, union smb_sesssetup *parms) { @@ -375,7 +375,7 @@ static NTSTATUS smb_raw_session_setup_generic_nt1(struct cli_session *session, Perform a session setup (sync interface) using generic interface and the SPNEGO style sesssetup call ****************************************************************************/ -static NTSTATUS smb_raw_session_setup_generic_spnego(struct cli_session *session, +static NTSTATUS smb_raw_session_setup_generic_spnego(struct smbcli_session *session, TALLOC_CTX *mem_ctx, union smb_sesssetup *parms) { @@ -396,7 +396,7 @@ static NTSTATUS smb_raw_session_setup_generic_spnego(struct cli_session *session s2.spnego.in.lanman = "Samba"; s2.spnego.out.vuid = UID_FIELD_INVALID; - cli_temp_set_signing(session->transport); + smbcli_temp_set_signing(session->transport); status = gensec_client_start(&session->gensec); if (!NT_STATUS_IS_OK(status)) { @@ -455,7 +455,7 @@ static NTSTATUS smb_raw_session_setup_generic_spnego(struct cli_session *session session_key_err = gensec_session_key(session->gensec, &session_key); } if (NT_STATUS_IS_OK(session_key_err)) { - cli_transport_simple_set_signing(session->transport, session_key, null_data_blob); + smbcli_transport_simple_set_signing(session->transport, session_key, null_data_blob); } session->vuid = s2.spnego.out.vuid; @@ -479,7 +479,7 @@ done: return session_key_err; } - cli_session_set_user_session_key(session, &session_key); + smbcli_session_set_user_session_key(session, &session_key); parms->generic.out.vuid = s2.spnego.out.vuid; parms->generic.out.os = s2.spnego.out.os; @@ -496,7 +496,7 @@ done: /**************************************************************************** Perform a session setup (sync interface) using generic interface ****************************************************************************/ -static NTSTATUS smb_raw_session_setup_generic(struct cli_session *session, +static NTSTATUS smb_raw_session_setup_generic(struct smbcli_session *session, TALLOC_CTX *mem_ctx, union smb_sesssetup *parms) { @@ -527,10 +527,10 @@ static NTSTATUS smb_raw_session_setup_generic(struct cli_session *session, this interface allows for RAW_SESSSETUP_GENERIC to auto-select session setup variant based on negotiated protocol options ****************************************************************************/ -NTSTATUS smb_raw_session_setup(struct cli_session *session, TALLOC_CTX *mem_ctx, +NTSTATUS smb_raw_session_setup(struct smbcli_session *session, TALLOC_CTX *mem_ctx, union smb_sesssetup *parms) { - struct cli_request *req; + struct smbcli_request *req; if (parms->generic.level == RAW_SESSSETUP_GENERIC) { NTSTATUS ret = smb_raw_session_setup_generic(session, mem_ctx, parms); @@ -555,17 +555,17 @@ NTSTATUS smb_raw_session_setup(struct cli_session *session, TALLOC_CTX *mem_ctx, /**************************************************************************** Send a uloggoff (async send) *****************************************************************************/ -struct cli_request *smb_raw_ulogoff_send(struct cli_session *session) +struct smbcli_request *smb_raw_ulogoff_send(struct smbcli_session *session) { - struct cli_request *req; + struct smbcli_request *req; SETUP_REQUEST_SESSION(SMBulogoffX, 2, 0); SSVAL(req->out.vwv, VWV(0), SMB_CHAIN_NONE); SSVAL(req->out.vwv, VWV(1), 0); - if (!cli_request_send(req)) { - cli_request_destroy(req); + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); return NULL; } @@ -575,24 +575,24 @@ struct cli_request *smb_raw_ulogoff_send(struct cli_session *session) /**************************************************************************** Send a uloggoff (sync interface) *****************************************************************************/ -NTSTATUS smb_raw_ulogoff(struct cli_session *session) +NTSTATUS smb_raw_ulogoff(struct smbcli_session *session) { - struct cli_request *req = smb_raw_ulogoff_send(session); - return cli_request_simple_recv(req); + struct smbcli_request *req = smb_raw_ulogoff_send(session); + return smbcli_request_simple_recv(req); } /**************************************************************************** Send a SMBexit ****************************************************************************/ -NTSTATUS smb_raw_exit(struct cli_session *session) +NTSTATUS smb_raw_exit(struct smbcli_session *session) { - struct cli_request *req; + struct smbcli_request *req; - req = cli_request_setup_session(session, SMBexit, 0, 0); + req = smbcli_request_setup_session(session, SMBexit, 0, 0); - if (cli_request_send(req)) { - cli_request_receive(req); + if (smbcli_request_send(req)) { + smbcli_request_receive(req); } - return cli_request_destroy(req); + return smbcli_request_destroy(req); } diff --git a/source4/libcli/raw/clisocket.c b/source4/libcli/raw/clisocket.c index eb5d3c0342..78d37b9be1 100644 --- a/source4/libcli/raw/clisocket.c +++ b/source4/libcli/raw/clisocket.c @@ -23,14 +23,14 @@ /* - create a cli_socket context + create a smbcli_socket context */ -struct cli_socket *cli_sock_init(void) +struct smbcli_socket *smbcli_sock_init(void) { - struct cli_socket *sock; + struct smbcli_socket *sock; TALLOC_CTX *mem_ctx; - mem_ctx = talloc_init("cli_socket"); + mem_ctx = talloc_init("smbcli_socket"); if (!mem_ctx) return NULL; sock = talloc_zero(mem_ctx, sizeof(*sock)); @@ -51,10 +51,10 @@ struct cli_socket *cli_sock_init(void) } /* - connect a cli_socket context to an IP/port pair + connect a smbcli_socket context to an IP/port pair if port is 0 then choose 445 then 139 */ -BOOL cli_sock_connect(struct cli_socket *sock, struct in_addr *ip, int port) +BOOL smbcli_sock_connect(struct smbcli_socket *sock, struct in_addr *ip, int port) { if (getenv("LIBSMB_PROG")) { sock->fd = sock_exec(getenv("LIBSMB_PROG")); @@ -62,8 +62,8 @@ BOOL cli_sock_connect(struct cli_socket *sock, struct in_addr *ip, int port) } if (port == 0) { - return cli_sock_connect(sock, ip, 445) || - cli_sock_connect(sock, ip, 139); + return smbcli_sock_connect(sock, ip, 445) || + smbcli_sock_connect(sock, ip, 139); } sock->dest_ip = *ip; @@ -85,7 +85,7 @@ BOOL cli_sock_connect(struct cli_socket *sock, struct in_addr *ip, int port) /**************************************************************************** mark the socket as dead ****************************************************************************/ -void cli_sock_dead(struct cli_socket *sock) +void smbcli_sock_dead(struct smbcli_socket *sock) { if (sock->fd != -1) { close(sock->fd); @@ -96,18 +96,18 @@ void cli_sock_dead(struct cli_socket *sock) /**************************************************************************** reduce socket reference count - if it becomes zero then close ****************************************************************************/ -void cli_sock_close(struct cli_socket *sock) +void smbcli_sock_close(struct smbcli_socket *sock) { sock->reference_count--; if (sock->reference_count <= 0) { - cli_sock_dead(sock); + smbcli_sock_dead(sock); } } /**************************************************************************** Set socket options on a open connection. ****************************************************************************/ -void cli_sock_set_options(struct cli_socket *sock, const char *options) +void smbcli_sock_set_options(struct smbcli_socket *sock, const char *options) { set_socket_options(sock->fd, options); } @@ -115,7 +115,7 @@ void cli_sock_set_options(struct cli_socket *sock, const char *options) /**************************************************************************** Write to socket. Return amount written. ****************************************************************************/ -ssize_t cli_sock_write(struct cli_socket *sock, const char *data, size_t len) +ssize_t smbcli_sock_write(struct smbcli_socket *sock, const char *data, size_t len) { if (sock->fd == -1) { errno = EIO; @@ -129,7 +129,7 @@ ssize_t cli_sock_write(struct cli_socket *sock, const char *data, size_t len) /**************************************************************************** Read from socket. return amount read ****************************************************************************/ -ssize_t cli_sock_read(struct cli_socket *sock, char *data, size_t len) +ssize_t smbcli_sock_read(struct smbcli_socket *sock, char *data, size_t len) { if (sock->fd == -1) { errno = EIO; @@ -142,7 +142,7 @@ ssize_t cli_sock_read(struct cli_socket *sock, char *data, size_t len) /**************************************************************************** resolve a hostname and connect ****************************************************************************/ -BOOL cli_sock_connect_byname(struct cli_socket *sock, const char *host, int port) +BOOL smbcli_sock_connect_byname(struct smbcli_socket *sock, const char *host, int port) { int name_type = 0x20; struct in_addr ip; @@ -155,7 +155,7 @@ BOOL cli_sock_connect_byname(struct cli_socket *sock, const char *host, int port return sock->fd != -1; } - mem_ctx = talloc_init("cli_sock_connect_byname"); + mem_ctx = talloc_init("smbcli_sock_connect_byname"); if (!mem_ctx) return False; name = talloc_strdup(mem_ctx, host); @@ -171,7 +171,7 @@ BOOL cli_sock_connect_byname(struct cli_socket *sock, const char *host, int port return False; } - ret = cli_sock_connect(sock, &ip, port); + ret = smbcli_sock_connect(sock, &ip, port); if (ret) { sock->hostname = talloc_steal(mem_ctx, sock->mem_ctx, name); diff --git a/source4/libcli/raw/clitransport.c b/source4/libcli/raw/clitransport.c index 3b3c10ed01..5290dd953d 100644 --- a/source4/libcli/raw/clitransport.c +++ b/source4/libcli/raw/clitransport.c @@ -24,24 +24,24 @@ /* an event has happened on the socket */ -static void cli_transport_event_handler(struct event_context *ev, struct fd_event *fde, +static void smbcli_transport_event_handler(struct event_context *ev, struct fd_event *fde, time_t t, uint16_t flags) { - struct cli_transport *transport = fde->private; + struct smbcli_transport *transport = fde->private; - cli_transport_process(transport); + smbcli_transport_process(transport); } /* create a transport structure based on an established socket */ -struct cli_transport *cli_transport_init(struct cli_socket *sock) +struct smbcli_transport *smbcli_transport_init(struct smbcli_socket *sock) { TALLOC_CTX *mem_ctx; - struct cli_transport *transport; + struct smbcli_transport *transport; struct fd_event fde; - mem_ctx = talloc_init("cli_transport"); + mem_ctx = talloc_init("smbcli_transport"); if (!mem_ctx) return NULL; transport = talloc_zero(mem_ctx, sizeof(*transport)); @@ -59,7 +59,7 @@ struct cli_transport *cli_transport_init(struct cli_socket *sock) transport->options.use_spnego = lp_use_spnego(); transport->negotiate.max_xmit = ~0; - cli_init_signing(transport); + smbcli_init_signing(transport); transport->socket->reference_count++; @@ -67,7 +67,7 @@ struct cli_transport *cli_transport_init(struct cli_socket *sock) fde.fd = sock->fd; fde.flags = EVENT_FD_READ; - fde.handler = cli_transport_event_handler; + fde.handler = smbcli_transport_event_handler; fde.private = transport; fde.ref_count = 1; @@ -80,11 +80,11 @@ struct cli_transport *cli_transport_init(struct cli_socket *sock) decrease reference count on a transport, and destroy if it becomes zero */ -void cli_transport_close(struct cli_transport *transport) +void smbcli_transport_close(struct smbcli_transport *transport) { transport->reference_count--; if (transport->reference_count <= 0) { - cli_sock_close(transport->socket); + smbcli_sock_close(transport->socket); event_remove_fd(transport->event.ctx, transport->event.fde); event_remove_timed(transport->event.ctx, transport->event.te); event_context_destroy(transport->event.ctx); @@ -95,14 +95,14 @@ void cli_transport_close(struct cli_transport *transport) /* mark the transport as dead */ -void cli_transport_dead(struct cli_transport *transport) +void smbcli_transport_dead(struct smbcli_transport *transport) { - cli_sock_dead(transport->socket); + smbcli_sock_dead(transport->socket); /* all pending sends become errors */ while (transport->pending_send) { - struct cli_request *req = transport->pending_send; - req->state = CLI_REQUEST_ERROR; + struct smbcli_request *req = transport->pending_send; + req->state = SMBCLI_REQUEST_ERROR; req->status = NT_STATUS_NET_WRITE_FAULT; DLIST_REMOVE(transport->pending_send, req); if (req->async.fn) { @@ -112,8 +112,8 @@ void cli_transport_dead(struct cli_transport *transport) /* as do all pending receives */ while (transport->pending_recv) { - struct cli_request *req = transport->pending_recv; - req->state = CLI_REQUEST_ERROR; + struct smbcli_request *req = transport->pending_recv; + req->state = SMBCLI_REQUEST_ERROR; req->status = NT_STATUS_NET_WRITE_FAULT; DLIST_REMOVE(transport->pending_recv, req); if (req->async.fn) { @@ -126,7 +126,7 @@ void cli_transport_dead(struct cli_transport *transport) /* enable select for write on a transport */ -static void cli_transport_write_enable(struct cli_transport *transport) +static void smbcli_transport_write_enable(struct smbcli_transport *transport) { transport->event.fde->flags |= EVENT_FD_WRITE; } @@ -134,7 +134,7 @@ static void cli_transport_write_enable(struct cli_transport *transport) /* disable select for write on a transport */ -static void cli_transport_write_disable(struct cli_transport *transport) +static void smbcli_transport_write_disable(struct smbcli_transport *transport) { transport->event.fde->flags &= ~EVENT_FD_WRITE; } @@ -142,13 +142,13 @@ static void cli_transport_write_disable(struct cli_transport *transport) /**************************************************************************** send a session request (if appropriate) ****************************************************************************/ -BOOL cli_transport_connect(struct cli_transport *transport, +BOOL smbcli_transport_connect(struct smbcli_transport *transport, struct nmb_name *calling, struct nmb_name *called) { char *p; int len = NBT_HDR_SIZE; - struct cli_request *req; + struct smbcli_request *req; if (called) { transport->called = *called; @@ -160,7 +160,7 @@ BOOL cli_transport_connect(struct cli_transport *transport, } /* allocate output buffer */ - req = cli_request_setup_nonsmb(transport, NBT_HDR_SIZE + 2*nbt_mangled_name_len()); + req = smbcli_request_setup_nonsmb(transport, NBT_HDR_SIZE + 2*nbt_mangled_name_len()); /* put in the destination name */ p = req->out.buffer + NBT_HDR_SIZE; @@ -175,20 +175,20 @@ BOOL cli_transport_connect(struct cli_transport *transport, _smb_setlen(req->out.buffer,len-4); SCVAL(req->out.buffer,0,0x81); - if (!cli_request_send(req) || - !cli_request_receive(req)) { - cli_request_destroy(req); + if (!smbcli_request_send(req) || + !smbcli_request_receive(req)) { + smbcli_request_destroy(req); return False; } if (CVAL(req->in.buffer,0) != 0x82) { transport->error.etype = ETYPE_NBT; transport->error.e.nbt_error = CVAL(req->in.buffer,4); - cli_request_destroy(req); + smbcli_request_destroy(req); return False; } - cli_request_destroy(req); + smbcli_request_destroy(req); return True; } @@ -196,10 +196,10 @@ BOOL cli_transport_connect(struct cli_transport *transport, /**************************************************************************** get next mid in sequence ****************************************************************************/ -uint16_t cli_transport_next_mid(struct cli_transport *transport) +uint16_t smbcli_transport_next_mid(struct smbcli_transport *transport) { uint16_t mid; - struct cli_request *req; + struct smbcli_request *req; mid = transport->next_mid; @@ -225,7 +225,7 @@ again: static void idle_handler(struct event_context *ev, struct timed_event *te, time_t t) { - struct cli_transport *transport = te->private; + struct smbcli_transport *transport = te->private; te->next_event = t + transport->idle.period; transport->idle.func(transport, transport->idle.private); } @@ -234,8 +234,8 @@ static void idle_handler(struct event_context *ev, setup the idle handler for a transport the period is in seconds */ -void cli_transport_idle_handler(struct cli_transport *transport, - void (*idle_func)(struct cli_transport *, void *), +void smbcli_transport_idle_handler(struct smbcli_transport *transport, + void (*idle_func)(struct smbcli_transport *, void *), uint_t period, void *private) { @@ -257,27 +257,27 @@ void cli_transport_idle_handler(struct cli_transport *transport, /* process some pending sends */ -static void cli_transport_process_send(struct cli_transport *transport) +static void smbcli_transport_process_send(struct smbcli_transport *transport) { while (transport->pending_send) { - struct cli_request *req = transport->pending_send; + struct smbcli_request *req = transport->pending_send; ssize_t ret; - ret = cli_sock_write(transport->socket, req->out.buffer, req->out.size); + ret = smbcli_sock_write(transport->socket, req->out.buffer, req->out.size); if (ret == -1) { if (errno == EAGAIN || errno == EINTR) { return; } - cli_transport_dead(transport); + smbcli_transport_dead(transport); } req->out.buffer += ret; req->out.size -= ret; if (req->out.size == 0) { DLIST_REMOVE(transport->pending_send, req); if (req->one_way_request) { - req->state = CLI_REQUEST_DONE; - cli_request_destroy(req); + req->state = SMBCLI_REQUEST_DONE; + smbcli_request_destroy(req); } else { - req->state = CLI_REQUEST_RECV; + req->state = SMBCLI_REQUEST_RECV; DLIST_ADD(transport->pending_recv, req); } } @@ -285,19 +285,19 @@ static void cli_transport_process_send(struct cli_transport *transport) /* we're out of requests to send, so don't wait for write events any more */ - cli_transport_write_disable(transport); + smbcli_transport_write_disable(transport); } /* we have a full request in our receive buffer - match it to a pending request and process */ -static void cli_transport_finish_recv(struct cli_transport *transport) +static void smbcli_transport_finish_recv(struct smbcli_transport *transport) { uint8_t *buffer, *hdr, *vwv; int len; uint16_t wct, mid = 0; - struct cli_request *req; + struct smbcli_request *req; buffer = transport->recv_buffer.buffer; len = transport->recv_buffer.req_size; @@ -355,14 +355,14 @@ static void cli_transport_finish_recv(struct cli_transport *transport) /* handle non-SMB replies */ if (req->in.size < NBT_HDR_SIZE + MIN_SMB_SIZE) { - req->state = CLI_REQUEST_ERROR; + req->state = SMBCLI_REQUEST_ERROR; goto error; } if (req->in.size < NBT_HDR_SIZE + MIN_SMB_SIZE + VWV(wct)) { DEBUG(2,("bad reply size for mid %d\n", mid)); req->status = NT_STATUS_UNSUCCESSFUL; - req->state = CLI_REQUEST_ERROR; + req->state = SMBCLI_REQUEST_ERROR; goto error; } @@ -394,10 +394,10 @@ static void cli_transport_finish_recv(struct cli_transport *transport) req->status = transport->error.e.nt_status; } - if (!cli_request_check_sign_mac(req)) { + if (!smbcli_request_check_sign_mac(req)) { transport->error.etype = ETYPE_SOCKET; transport->error.e.socket_error = SOCKET_READ_BAD_SIG; - req->state = CLI_REQUEST_ERROR; + req->state = SMBCLI_REQUEST_ERROR; goto error; }; @@ -406,7 +406,7 @@ async: 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 = CLI_REQUEST_DONE; + req->state = SMBCLI_REQUEST_DONE; if (req->async.fn) { req->async.fn(req); } @@ -415,21 +415,21 @@ async: error: if (req) { DLIST_REMOVE(transport->pending_recv, req); - req->state = CLI_REQUEST_ERROR; + req->state = SMBCLI_REQUEST_ERROR; } } /* process some pending receives */ -static void cli_transport_process_recv(struct cli_transport *transport) +static void smbcli_transport_process_recv(struct smbcli_transport *transport) { /* a incoming packet goes through 2 stages - first we read the 4 byte header, which tells us how much more is coming. Then we read the rest */ if (transport->recv_buffer.received < NBT_HDR_SIZE) { ssize_t ret; - ret = cli_sock_read(transport->socket, + ret = smbcli_sock_read(transport->socket, transport->recv_buffer.header + transport->recv_buffer.received, NBT_HDR_SIZE - transport->recv_buffer.received); @@ -437,7 +437,7 @@ static void cli_transport_process_recv(struct cli_transport *transport) if (errno == EINTR || errno == EAGAIN) { return; } - cli_transport_dead(transport); + smbcli_transport_dead(transport); return; } @@ -449,7 +449,7 @@ static void cli_transport_process_recv(struct cli_transport *transport) transport->recv_buffer.buffer = talloc(transport->mem_ctx, NBT_HDR_SIZE+transport->recv_buffer.req_size); if (transport->recv_buffer.buffer == NULL) { - cli_transport_dead(transport); + smbcli_transport_dead(transport); return; } memcpy(transport->recv_buffer.buffer, transport->recv_buffer.header, NBT_HDR_SIZE); @@ -458,7 +458,7 @@ static void cli_transport_process_recv(struct cli_transport *transport) if (transport->recv_buffer.received < transport->recv_buffer.req_size) { ssize_t ret; - ret = cli_sock_read(transport->socket, + ret = smbcli_sock_read(transport->socket, transport->recv_buffer.buffer + transport->recv_buffer.received, transport->recv_buffer.req_size - @@ -467,7 +467,7 @@ static void cli_transport_process_recv(struct cli_transport *transport) if (errno == EINTR || errno == EAGAIN) { return; } - cli_transport_dead(transport); + smbcli_transport_dead(transport); return; } transport->recv_buffer.received += ret; @@ -475,7 +475,7 @@ static void cli_transport_process_recv(struct cli_transport *transport) if (transport->recv_buffer.received != 0 && transport->recv_buffer.received == transport->recv_buffer.req_size) { - cli_transport_finish_recv(transport); + smbcli_transport_finish_recv(transport); } } @@ -483,10 +483,10 @@ static void cli_transport_process_recv(struct cli_transport *transport) process some read/write requests that are pending return False if the socket is dead */ -BOOL cli_transport_process(struct cli_transport *transport) +BOOL smbcli_transport_process(struct smbcli_transport *transport) { - cli_transport_process_send(transport); - cli_transport_process_recv(transport); + smbcli_transport_process_send(transport); + smbcli_transport_process_recv(transport); if (transport->socket->fd == -1) { return False; } @@ -498,19 +498,19 @@ BOOL cli_transport_process(struct cli_transport *transport) /* put a request into the send queue */ -void cli_transport_send(struct cli_request *req) +void smbcli_transport_send(struct smbcli_request *req) { /* check if the transport is dead */ if (req->transport->socket->fd == -1) { - req->state = CLI_REQUEST_ERROR; + req->state = SMBCLI_REQUEST_ERROR; req->status = NT_STATUS_NET_WRITE_FAULT; return; } /* put it on the outgoing socket queue */ - req->state = CLI_REQUEST_SEND; - DLIST_ADD_END(req->transport->pending_send, req, struct cli_request *); + req->state = SMBCLI_REQUEST_SEND; + DLIST_ADD_END(req->transport->pending_send, req, struct smbcli_request *); /* make sure we look for write events */ - cli_transport_write_enable(req->transport); + smbcli_transport_write_enable(req->transport); } diff --git a/source4/libcli/raw/clitree.c b/source4/libcli/raw/clitree.c index a580ded010..b9d572fd56 100644 --- a/source4/libcli/raw/clitree.c +++ b/source4/libcli/raw/clitree.c @@ -22,7 +22,7 @@ #include "includes.h" #define SETUP_REQUEST_TREE(cmd, wct, buflen) do { \ - req = cli_request_setup(tree, cmd, wct, buflen); \ + req = smbcli_request_setup(tree, cmd, wct, buflen); \ if (!req) return NULL; \ } while (0) @@ -30,10 +30,10 @@ /**************************************************************************** Initialize the tree context ****************************************************************************/ -struct cli_tree *cli_tree_init(struct cli_session *session) +struct smbcli_tree *smbcli_tree_init(struct smbcli_session *session) { - struct cli_tree *tree; - TALLOC_CTX *mem_ctx = talloc_init("cli_tree"); + struct smbcli_tree *tree; + TALLOC_CTX *mem_ctx = talloc_init("smbcli_tree"); if (mem_ctx == NULL) { return NULL; } @@ -54,12 +54,12 @@ struct cli_tree *cli_tree_init(struct cli_session *session) /**************************************************************************** reduce reference count on a tree and destroy if <= 0 ****************************************************************************/ -void cli_tree_close(struct cli_tree *tree) +void smbcli_tree_close(struct smbcli_tree *tree) { if (!tree) return; tree->reference_count--; if (tree->reference_count <= 0) { - cli_session_close(tree->session); + smbcli_session_close(tree->session); talloc_destroy(tree->mem_ctx); } } @@ -68,16 +68,16 @@ void cli_tree_close(struct cli_tree *tree) /**************************************************************************** Send a tconX (async send) ****************************************************************************/ -struct cli_request *smb_tree_connect_send(struct cli_tree *tree, union smb_tcon *parms) +struct smbcli_request *smb_tree_connect_send(struct smbcli_tree *tree, union smb_tcon *parms) { - struct cli_request *req; + struct smbcli_request *req; switch (parms->tcon.level) { case RAW_TCON_TCON: SETUP_REQUEST_TREE(SMBtcon, 0, 0); - cli_req_append_ascii4(req, parms->tcon.in.service, STR_ASCII); - cli_req_append_ascii4(req, parms->tcon.in.password,STR_ASCII); - cli_req_append_ascii4(req, parms->tcon.in.dev, STR_ASCII); + smbcli_req_append_ascii4(req, parms->tcon.in.service, STR_ASCII); + smbcli_req_append_ascii4(req, parms->tcon.in.password,STR_ASCII); + smbcli_req_append_ascii4(req, parms->tcon.in.dev, STR_ASCII); break; case RAW_TCON_TCONX: @@ -86,14 +86,14 @@ struct cli_request *smb_tree_connect_send(struct cli_tree *tree, union smb_tcon SSVAL(req->out.vwv, VWV(1), 0); SSVAL(req->out.vwv, VWV(2), parms->tconx.in.flags); SSVAL(req->out.vwv, VWV(3), parms->tconx.in.password.length); - cli_req_append_blob(req, &parms->tconx.in.password); - cli_req_append_string(req, parms->tconx.in.path, STR_TERMINATE | STR_UPPER); - cli_req_append_string(req, parms->tconx.in.device, STR_TERMINATE | STR_ASCII); + smbcli_req_append_blob(req, &parms->tconx.in.password); + smbcli_req_append_string(req, parms->tconx.in.path, STR_TERMINATE | STR_UPPER); + smbcli_req_append_string(req, parms->tconx.in.device, STR_TERMINATE | STR_ASCII); break; } - if (!cli_request_send(req)) { - cli_request_destroy(req); + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); return NULL; } @@ -103,18 +103,18 @@ struct cli_request *smb_tree_connect_send(struct cli_tree *tree, union smb_tcon /**************************************************************************** Send a tconX (async recv) ****************************************************************************/ -NTSTATUS smb_tree_connect_recv(struct cli_request *req, TALLOC_CTX *mem_ctx, union smb_tcon *parms) +NTSTATUS smb_tree_connect_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, union smb_tcon *parms) { char *p; - if (!cli_request_receive(req) || - cli_request_is_error(req)) { + if (!smbcli_request_receive(req) || + smbcli_request_is_error(req)) { goto failed; } switch (parms->tcon.level) { case RAW_TCON_TCON: - CLI_CHECK_WCT(req, 2); + SMBCLI_CHECK_WCT(req, 2); parms->tcon.out.max_xmit = SVAL(req->in.vwv, VWV(0)); parms->tcon.out.cnum = SVAL(req->in.vwv, VWV(1)); break; @@ -130,23 +130,23 @@ NTSTATUS smb_tree_connect_recv(struct cli_request *req, TALLOC_CTX *mem_ctx, uni p = req->in.data; if (!p) break; - p += cli_req_pull_string(req, mem_ctx, &parms->tconx.out.dev_type, + p += smbcli_req_pull_string(req, mem_ctx, &parms->tconx.out.dev_type, p, -1, STR_ASCII | STR_TERMINATE); - p += cli_req_pull_string(req, mem_ctx, &parms->tconx.out.fs_type, + p += smbcli_req_pull_string(req, mem_ctx, &parms->tconx.out.fs_type, p, -1, STR_TERMINATE); break; } failed: - return cli_request_destroy(req); + return smbcli_request_destroy(req); } /**************************************************************************** Send a tconX (sync interface) ****************************************************************************/ -NTSTATUS smb_tree_connect(struct cli_tree *tree, TALLOC_CTX *mem_ctx, union smb_tcon *parms) +NTSTATUS smb_tree_connect(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_tcon *parms) { - struct cli_request *req = smb_tree_connect_send(tree, parms); + struct smbcli_request *req = smb_tree_connect_send(tree, parms); return smb_tree_connect_recv(req, mem_ctx, parms); } @@ -154,35 +154,35 @@ NTSTATUS smb_tree_connect(struct cli_tree *tree, TALLOC_CTX *mem_ctx, union smb_ /**************************************************************************** Send a tree disconnect. ****************************************************************************/ -NTSTATUS smb_tree_disconnect(struct cli_tree *tree) +NTSTATUS smb_tree_disconnect(struct smbcli_tree *tree) { - struct cli_request *req; + struct smbcli_request *req; if (!tree) return NT_STATUS_OK; - req = cli_request_setup(tree, SMBtdis, 0, 0); + req = smbcli_request_setup(tree, SMBtdis, 0, 0); - if (cli_request_send(req)) { - cli_request_receive(req); + if (smbcli_request_send(req)) { + smbcli_request_receive(req); } - return cli_request_destroy(req); + return smbcli_request_destroy(req); } /* - a convenient function to establish a cli_tree from scratch, using reasonable default + a convenient function to establish a smbcli_tree from scratch, using reasonable default parameters */ -NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, +NTSTATUS smbcli_tree_full_connection(struct smbcli_tree **ret_tree, const char *my_name, const char *dest_host, int port, const char *service, const char *service_type, const char *user, const char *domain, const char *password) { - struct cli_socket *sock; - struct cli_transport *transport; - struct cli_session *session; - struct cli_tree *tree; + struct smbcli_socket *sock; + struct smbcli_transport *transport; + struct smbcli_session *session; + struct smbcli_tree *tree; NTSTATUS status; struct nmb_name calling; struct nmb_name called; @@ -193,20 +193,20 @@ NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, *ret_tree = NULL; - sock = cli_sock_init(); + sock = smbcli_sock_init(); if (!sock) { return NT_STATUS_NO_MEMORY; } /* open a TCP socket to the server */ - if (!cli_sock_connect_byname(sock, dest_host, port)) { + if (!smbcli_sock_connect_byname(sock, dest_host, port)) { DEBUG(2,("Failed to establish socket connection - %s\n", strerror(errno))); return NT_STATUS_UNSUCCESSFUL; } - transport = cli_transport_init(sock); + transport = smbcli_transport_init(sock); if (!transport) { - cli_sock_close(sock); + smbcli_sock_close(sock); return NT_STATUS_NO_MEMORY; } @@ -214,8 +214,8 @@ NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, make_nmb_name(&calling, my_name, 0x0); make_nmb_name(&called, dest_host, 0x20); - if (!cli_transport_connect(transport, &calling, &called)) { - cli_transport_close(transport); + if (!smbcli_transport_connect(transport, &calling, &called)) { + smbcli_transport_close(transport); return NT_STATUS_UNSUCCESSFUL; } @@ -223,13 +223,13 @@ NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, /* negotiate protocol options with the server */ status = smb_raw_negotiate(transport); if (!NT_STATUS_IS_OK(status)) { - cli_transport_close(transport); + smbcli_transport_close(transport); return status; } - session = cli_session_init(transport); + session = smbcli_session_init(transport); if (!session) { - cli_transport_close(transport); + smbcli_transport_close(transport); return NT_STATUS_NO_MEMORY; } @@ -255,16 +255,16 @@ NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, status = smb_raw_session_setup(session, mem_ctx, &setup); if (!NT_STATUS_IS_OK(status)) { - cli_session_close(session); + smbcli_session_close(session); talloc_destroy(mem_ctx); return status; } session->vuid = setup.generic.out.vuid; - tree = cli_tree_init(session); + tree = smbcli_tree_init(session); if (!tree) { - cli_session_close(session); + smbcli_session_close(session); talloc_destroy(mem_ctx); return NT_STATUS_NO_MEMORY; } @@ -288,7 +288,7 @@ NTSTATUS cli_tree_full_connection(struct cli_tree **ret_tree, SAFE_FREE(in_path); if (!NT_STATUS_IS_OK(status)) { - cli_tree_close(tree); + smbcli_tree_close(tree); talloc_destroy(mem_ctx); return status; } diff --git a/source4/libcli/raw/rawacl.c b/source4/libcli/raw/rawacl.c index ca93591597..77374ae8b9 100644 --- a/source4/libcli/raw/rawacl.c +++ b/source4/libcli/raw/rawacl.c @@ -23,7 +23,7 @@ /**************************************************************************** fetch file ACL (async send) ****************************************************************************/ -struct cli_request *smb_raw_query_secdesc_send(struct cli_tree *tree, +struct smbcli_request *smb_raw_query_secdesc_send(struct smbcli_tree *tree, struct smb_query_secdesc *query) { struct smb_nttrans nt; @@ -52,7 +52,7 @@ struct cli_request *smb_raw_query_secdesc_send(struct cli_tree *tree, /**************************************************************************** fetch file ACL (async recv) ****************************************************************************/ -NTSTATUS smb_raw_query_secdesc_recv(struct cli_request *req, +NTSTATUS smb_raw_query_secdesc_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, struct smb_query_secdesc *query) { @@ -91,11 +91,11 @@ NTSTATUS smb_raw_query_secdesc_recv(struct cli_request *req, /**************************************************************************** fetch file ACL (sync interface) ****************************************************************************/ -NTSTATUS smb_raw_query_secdesc(struct cli_tree *tree, +NTSTATUS smb_raw_query_secdesc(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, struct smb_query_secdesc *query) { - struct cli_request *req = smb_raw_query_secdesc_send(tree, query); + struct smbcli_request *req = smb_raw_query_secdesc_send(tree, query); return smb_raw_query_secdesc_recv(req, mem_ctx, query); } @@ -104,13 +104,13 @@ NTSTATUS smb_raw_query_secdesc(struct cli_tree *tree, /**************************************************************************** set file ACL (async send) ****************************************************************************/ -struct cli_request *smb_raw_set_secdesc_send(struct cli_tree *tree, +struct smbcli_request *smb_raw_set_secdesc_send(struct smbcli_tree *tree, struct smb_set_secdesc *set) { struct smb_nttrans nt; uint8_t params[8]; struct ndr_push *ndr; - struct cli_request *req; + struct smbcli_request *req; NTSTATUS status; nt.in.max_setup = 0; diff --git a/source4/libcli/raw/rawdate.c b/source4/libcli/raw/rawdate.c index 3b731d653b..bfb7465bd5 100644 --- a/source4/libcli/raw/rawdate.c +++ b/source4/libcli/raw/rawdate.c @@ -26,7 +26,7 @@ put a dos date into a buffer (time/date format) This takes GMT time and puts local time for zone_offset in the buffer ********************************************************************/ -void raw_push_dos_date(struct cli_transport *transport, +void raw_push_dos_date(struct smbcli_transport *transport, uint8_t *buf, int offset, time_t unixdate) { push_dos_date(buf, offset, unixdate, transport->negotiate.server_zone); @@ -36,7 +36,7 @@ void raw_push_dos_date(struct cli_transport *transport, put a dos date into a buffer (date/time format) This takes GMT time and puts local time in the buffer ********************************************************************/ -void raw_push_dos_date2(struct cli_transport *transport, +void raw_push_dos_date2(struct smbcli_transport *transport, char *buf, int offset, time_t unixdate) { push_dos_date2(buf, offset, unixdate, transport->negotiate.server_zone); @@ -46,7 +46,7 @@ void raw_push_dos_date2(struct cli_transport *transport, put a dos 32 bit "unix like" date into a buffer. This routine takes GMT and converts it to LOCAL time in zone_offset before putting it ********************************************************************/ -void raw_push_dos_date3(struct cli_transport *transport, +void raw_push_dos_date3(struct smbcli_transport *transport, char *buf, int offset, time_t unixdate) { push_dos_date3(buf, offset, unixdate, transport->negotiate.server_zone); @@ -55,7 +55,7 @@ void raw_push_dos_date3(struct cli_transport *transport, /******************************************************************* convert a dos date ********************************************************************/ -time_t raw_pull_dos_date(struct cli_transport *transport, +time_t raw_pull_dos_date(struct smbcli_transport *transport, const uint8_t *date_ptr) { return pull_dos_date(date_ptr, transport->negotiate.server_zone); @@ -64,7 +64,7 @@ time_t raw_pull_dos_date(struct cli_transport *transport, /******************************************************************* like raw_pull_dos_date() but the words are reversed ********************************************************************/ -time_t raw_pull_dos_date2(struct cli_transport *transport, +time_t raw_pull_dos_date2(struct smbcli_transport *transport, const uint8_t *date_ptr) { return pull_dos_date2(date_ptr, transport->negotiate.server_zone); @@ -74,7 +74,7 @@ time_t raw_pull_dos_date2(struct cli_transport *transport, create a unix GMT date from a dos date in 32 bit "unix like" format these arrive in server zone, with corresponding DST ******************************************************************/ -time_t raw_pull_dos_date3(struct cli_transport *transport, +time_t raw_pull_dos_date3(struct smbcli_transport *transport, const uint8_t *date_ptr) { return pull_dos_date3(date_ptr, transport->negotiate.server_zone); diff --git a/source4/libcli/raw/rawfile.c b/source4/libcli/raw/rawfile.c index 0d00ffcca6..8bd8e5d8af 100644 --- a/source4/libcli/raw/rawfile.c +++ b/source4/libcli/raw/rawfile.c @@ -23,7 +23,7 @@ #include "includes.h" #define SETUP_REQUEST(cmd, wct, buflen) do { \ - req = cli_request_setup(tree, cmd, wct, buflen); \ + req = smbcli_request_setup(tree, cmd, wct, buflen); \ if (!req) return NULL; \ } while (0) @@ -31,17 +31,17 @@ /**************************************************************************** Rename a file - async interface ****************************************************************************/ -struct cli_request *smb_raw_rename_send(struct cli_tree *tree, +struct smbcli_request *smb_raw_rename_send(struct smbcli_tree *tree, union smb_rename *parms) { - struct cli_request *req; + struct smbcli_request *req; switch (parms->generic.level) { case RAW_RENAME_RENAME: SETUP_REQUEST(SMBmv, 1, 0); SSVAL(req->out.vwv, VWV(0), parms->rename.in.attrib); - cli_req_append_ascii4(req, parms->rename.in.pattern1, STR_TERMINATE); - cli_req_append_ascii4(req, parms->rename.in.pattern2, STR_TERMINATE); + smbcli_req_append_ascii4(req, parms->rename.in.pattern1, STR_TERMINATE); + smbcli_req_append_ascii4(req, parms->rename.in.pattern2, STR_TERMINATE); break; case RAW_RENAME_NTRENAME: @@ -49,13 +49,13 @@ struct cli_request *smb_raw_rename_send(struct cli_tree *tree, SSVAL(req->out.vwv, VWV(0), parms->ntrename.in.attrib); SSVAL(req->out.vwv, VWV(1), parms->ntrename.in.flags); SIVAL(req->out.vwv, VWV(2), parms->ntrename.in.cluster_size); - cli_req_append_ascii4(req, parms->ntrename.in.old_name, STR_TERMINATE); - cli_req_append_ascii4(req, parms->ntrename.in.new_name, STR_TERMINATE); + smbcli_req_append_ascii4(req, parms->ntrename.in.old_name, STR_TERMINATE); + smbcli_req_append_ascii4(req, parms->ntrename.in.new_name, STR_TERMINATE); break; } - if (!cli_request_send(req)) { - cli_request_destroy(req); + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); return NULL; } @@ -65,29 +65,29 @@ struct cli_request *smb_raw_rename_send(struct cli_tree *tree, /**************************************************************************** Rename a file - sync interface ****************************************************************************/ -NTSTATUS smb_raw_rename(struct cli_tree *tree, +NTSTATUS smb_raw_rename(struct smbcli_tree *tree, union smb_rename *parms) { - struct cli_request *req = smb_raw_rename_send(tree, parms); - return cli_request_simple_recv(req); + struct smbcli_request *req = smb_raw_rename_send(tree, parms); + return smbcli_request_simple_recv(req); } /**************************************************************************** Delete a file - async interface ****************************************************************************/ -struct cli_request *smb_raw_unlink_send(struct cli_tree *tree, +struct smbcli_request *smb_raw_unlink_send(struct smbcli_tree *tree, struct smb_unlink *parms) { - struct cli_request *req; + struct smbcli_request *req; SETUP_REQUEST(SMBunlink, 1, 0); SSVAL(req->out.vwv, VWV(0), parms->in.attrib); - cli_req_append_ascii4(req, parms->in.pattern, STR_TERMINATE); + smbcli_req_append_ascii4(req, parms->in.pattern, STR_TERMINATE); - if (!cli_request_send(req)) { - cli_request_destroy(req); + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); return NULL; } return req; @@ -96,24 +96,24 @@ struct cli_request *smb_raw_unlink_send(struct cli_tree *tree, /* delete a file - sync interface */ -NTSTATUS smb_raw_unlink(struct cli_tree *tree, +NTSTATUS smb_raw_unlink(struct smbcli_tree *tree, struct smb_unlink *parms) { - struct cli_request *req = smb_raw_unlink_send(tree, parms); - return cli_request_simple_recv(req); + struct smbcli_request *req = smb_raw_unlink_send(tree, parms); + return smbcli_request_simple_recv(req); } /**************************************************************************** create a directory using TRANSACT2_MKDIR - async interface ****************************************************************************/ -static struct cli_request *smb_raw_t2mkdir_send(struct cli_tree *tree, +static struct smbcli_request *smb_raw_t2mkdir_send(struct smbcli_tree *tree, union smb_mkdir *parms) { struct smb_trans2 t2; uint16_t setup = TRANSACT2_MKDIR; TALLOC_CTX *mem_ctx; - struct cli_request *req; + struct smbcli_request *req; uint16_t data_total; mem_ctx = talloc_init("t2mkdir"); @@ -132,7 +132,7 @@ static struct cli_request *smb_raw_t2mkdir_send(struct cli_tree *tree, SIVAL(t2.in.params.data, VWV(0), 0); /* reserved */ - cli_blob_append_string(tree->session, mem_ctx, + smbcli_blob_append_string(tree->session, mem_ctx, &t2.in.params, parms->t2mkdir.in.path, 0); ea_put_list(t2.in.data.data, parms->t2mkdir.in.num_eas, parms->t2mkdir.in.eas); @@ -147,10 +147,10 @@ static struct cli_request *smb_raw_t2mkdir_send(struct cli_tree *tree, /**************************************************************************** Create a directory - async interface ****************************************************************************/ -struct cli_request *smb_raw_mkdir_send(struct cli_tree *tree, +struct smbcli_request *smb_raw_mkdir_send(struct smbcli_tree *tree, union smb_mkdir *parms) { - struct cli_request *req; + struct smbcli_request *req; if (parms->generic.level == RAW_MKDIR_T2MKDIR) { return smb_raw_t2mkdir_send(tree, parms); @@ -162,9 +162,9 @@ struct cli_request *smb_raw_mkdir_send(struct cli_tree *tree, SETUP_REQUEST(SMBmkdir, 0, 0); - cli_req_append_ascii4(req, parms->mkdir.in.path, STR_TERMINATE); + smbcli_req_append_ascii4(req, parms->mkdir.in.path, STR_TERMINATE); - if (!cli_request_send(req)) { + if (!smbcli_request_send(req)) { return NULL; } @@ -174,27 +174,27 @@ struct cli_request *smb_raw_mkdir_send(struct cli_tree *tree, /**************************************************************************** Create a directory - sync interface ****************************************************************************/ -NTSTATUS smb_raw_mkdir(struct cli_tree *tree, +NTSTATUS smb_raw_mkdir(struct smbcli_tree *tree, union smb_mkdir *parms) { - struct cli_request *req = smb_raw_mkdir_send(tree, parms); - return cli_request_simple_recv(req); + struct smbcli_request *req = smb_raw_mkdir_send(tree, parms); + return smbcli_request_simple_recv(req); } /**************************************************************************** Remove a directory - async interface ****************************************************************************/ -struct cli_request *smb_raw_rmdir_send(struct cli_tree *tree, +struct smbcli_request *smb_raw_rmdir_send(struct smbcli_tree *tree, struct smb_rmdir *parms) { - struct cli_request *req; + struct smbcli_request *req; SETUP_REQUEST(SMBrmdir, 0, 0); - cli_req_append_ascii4(req, parms->in.path, STR_TERMINATE); + smbcli_req_append_ascii4(req, parms->in.path, STR_TERMINATE); - if (!cli_request_send(req)) { - cli_request_destroy(req); + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); return NULL; } @@ -204,24 +204,24 @@ struct cli_request *smb_raw_rmdir_send(struct cli_tree *tree, /**************************************************************************** Remove a directory - sync interface ****************************************************************************/ -NTSTATUS smb_raw_rmdir(struct cli_tree *tree, +NTSTATUS smb_raw_rmdir(struct smbcli_tree *tree, struct smb_rmdir *parms) { - struct cli_request *req = smb_raw_rmdir_send(tree, parms); - return cli_request_simple_recv(req); + struct smbcli_request *req = smb_raw_rmdir_send(tree, parms); + return smbcli_request_simple_recv(req); } /**************************************************************************** Open a file using TRANSACT2_OPEN - async send ****************************************************************************/ -static struct cli_request *smb_raw_t2open_send(struct cli_tree *tree, +static struct smbcli_request *smb_raw_t2open_send(struct smbcli_tree *tree, union smb_open *parms) { struct smb_trans2 t2; uint16_t setup = TRANSACT2_OPEN; TALLOC_CTX *mem_ctx = talloc_init("smb_raw_t2open"); - struct cli_request *req; + struct smbcli_request *req; uint16_t list_size; list_size = ea_list_size(parms->t2open.in.num_eas, parms->t2open.in.eas); @@ -248,7 +248,7 @@ static struct cli_request *smb_raw_t2open_send(struct cli_tree *tree, SIVAL(t2.in.params.data, VWV(11), 0); SSVAL(t2.in.params.data, VWV(13), 0); - cli_blob_append_string(tree->session, mem_ctx, + smbcli_blob_append_string(tree->session, mem_ctx, &t2.in.params, parms->t2open.in.fname, STR_TERMINATE); @@ -265,9 +265,9 @@ static struct cli_request *smb_raw_t2open_send(struct cli_tree *tree, /**************************************************************************** Open a file using TRANSACT2_OPEN - async recv ****************************************************************************/ -static NTSTATUS smb_raw_t2open_recv(struct cli_request *req, TALLOC_CTX *mem_ctx, union smb_open *parms) +static NTSTATUS smb_raw_t2open_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, union smb_open *parms) { - struct cli_transport *transport = req?req->transport:NULL; + struct smbcli_transport *transport = req?req->transport:NULL; struct smb_trans2 t2; NTSTATUS status; @@ -294,10 +294,10 @@ static NTSTATUS smb_raw_t2open_recv(struct cli_request *req, TALLOC_CTX *mem_ctx /**************************************************************************** Open a file - async send ****************************************************************************/ -struct cli_request *smb_raw_open_send(struct cli_tree *tree, union smb_open *parms) +struct smbcli_request *smb_raw_open_send(struct smbcli_tree *tree, union smb_open *parms) { int len; - struct cli_request *req = NULL; + struct smbcli_request *req = NULL; switch (parms->open.level) { case RAW_OPEN_T2OPEN: @@ -307,7 +307,7 @@ struct cli_request *smb_raw_open_send(struct cli_tree *tree, union smb_open *par SETUP_REQUEST(SMBopen, 2, 0); SSVAL(req->out.vwv, VWV(0), parms->open.in.flags); SSVAL(req->out.vwv, VWV(1), parms->open.in.search_attrs); - cli_req_append_ascii4(req, parms->open.in.fname, STR_TERMINATE); + smbcli_req_append_ascii4(req, parms->open.in.fname, STR_TERMINATE); break; case RAW_OPEN_OPENX: @@ -324,7 +324,7 @@ struct cli_request *smb_raw_open_send(struct cli_tree *tree, union smb_open *par SIVAL(req->out.vwv, VWV(9), parms->openx.in.size); SIVAL(req->out.vwv, VWV(11),parms->openx.in.timeout); SIVAL(req->out.vwv, VWV(13),0); /* reserved */ - cli_req_append_string(req, parms->openx.in.fname, STR_TERMINATE); + smbcli_req_append_string(req, parms->openx.in.fname, STR_TERMINATE); break; case RAW_OPEN_MKNEW: @@ -332,7 +332,7 @@ struct cli_request *smb_raw_open_send(struct cli_tree *tree, union smb_open *par SSVAL(req->out.vwv, VWV(0), parms->mknew.in.attrib); raw_push_dos_date3(tree->session->transport, req->out.vwv, VWV(1), parms->mknew.in.write_time); - cli_req_append_ascii4(req, parms->mknew.in.fname, STR_TERMINATE); + smbcli_req_append_ascii4(req, parms->mknew.in.fname, STR_TERMINATE); break; case RAW_OPEN_CREATE: @@ -340,7 +340,7 @@ struct cli_request *smb_raw_open_send(struct cli_tree *tree, union smb_open *par SSVAL(req->out.vwv, VWV(0), parms->create.in.attrib); raw_push_dos_date3(tree->session->transport, req->out.vwv, VWV(1), parms->create.in.write_time); - cli_req_append_ascii4(req, parms->create.in.fname, STR_TERMINATE); + smbcli_req_append_ascii4(req, parms->create.in.fname, STR_TERMINATE); break; case RAW_OPEN_CTEMP: @@ -348,7 +348,7 @@ struct cli_request *smb_raw_open_send(struct cli_tree *tree, union smb_open *par SSVAL(req->out.vwv, VWV(0), parms->ctemp.in.attrib); raw_push_dos_date3(tree->session->transport, req->out.vwv, VWV(1), parms->ctemp.in.write_time); - cli_req_append_ascii4(req, parms->ctemp.in.directory, STR_TERMINATE); + smbcli_req_append_ascii4(req, parms->ctemp.in.directory, STR_TERMINATE); break; case RAW_OPEN_SPLOPEN: @@ -373,13 +373,13 @@ struct cli_request *smb_raw_open_send(struct cli_tree *tree, union smb_open *par SIVAL(req->out.vwv, 43, parms->ntcreatex.in.impersonation); SCVAL(req->out.vwv, 47, parms->ntcreatex.in.security_flags); - cli_req_append_string_len(req, parms->ntcreatex.in.fname, STR_TERMINATE, &len); + smbcli_req_append_string_len(req, parms->ntcreatex.in.fname, STR_TERMINATE, &len); SSVAL(req->out.vwv, 5, len); break; } - if (!cli_request_send(req)) { - cli_request_destroy(req); + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); return NULL; } @@ -389,10 +389,10 @@ struct cli_request *smb_raw_open_send(struct cli_tree *tree, union smb_open *par /**************************************************************************** Open a file - async recv ****************************************************************************/ -NTSTATUS smb_raw_open_recv(struct cli_request *req, TALLOC_CTX *mem_ctx, union smb_open *parms) +NTSTATUS smb_raw_open_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, union smb_open *parms) { - if (!cli_request_receive(req) || - cli_request_is_error(req)) { + if (!smbcli_request_receive(req) || + smbcli_request_is_error(req)) { goto failed; } @@ -401,7 +401,7 @@ NTSTATUS smb_raw_open_recv(struct cli_request *req, TALLOC_CTX *mem_ctx, union s return smb_raw_t2open_recv(req, mem_ctx, parms); case RAW_OPEN_OPEN: - CLI_CHECK_WCT(req, 7); + SMBCLI_CHECK_WCT(req, 7); parms->open.out.fnum = SVAL(req->in.vwv, VWV(0)); parms->open.out.attrib = SVAL(req->in.vwv, VWV(1)); parms->open.out.write_time = raw_pull_dos_date3(req->transport, @@ -411,7 +411,7 @@ NTSTATUS smb_raw_open_recv(struct cli_request *req, TALLOC_CTX *mem_ctx, union s break; case RAW_OPEN_OPENX: - CLI_CHECK_MIN_WCT(req, 15); + SMBCLI_CHECK_MIN_WCT(req, 15); parms->openx.out.fnum = SVAL(req->in.vwv, VWV(2)); parms->openx.out.attrib = SVAL(req->in.vwv, VWV(3)); parms->openx.out.write_time = raw_pull_dos_date3(req->transport, @@ -432,35 +432,35 @@ NTSTATUS smb_raw_open_recv(struct cli_request *req, TALLOC_CTX *mem_ctx, union s break; case RAW_OPEN_MKNEW: - CLI_CHECK_WCT(req, 1); + SMBCLI_CHECK_WCT(req, 1); parms->mknew.out.fnum = SVAL(req->in.vwv, VWV(0)); break; case RAW_OPEN_CREATE: - CLI_CHECK_WCT(req, 1); + SMBCLI_CHECK_WCT(req, 1); parms->create.out.fnum = SVAL(req->in.vwv, VWV(0)); break; case RAW_OPEN_CTEMP: - CLI_CHECK_WCT(req, 1); + SMBCLI_CHECK_WCT(req, 1); parms->ctemp.out.fnum = SVAL(req->in.vwv, VWV(0)); - cli_req_pull_string(req, mem_ctx, &parms->ctemp.out.name, req->in.data, -1, STR_TERMINATE | STR_ASCII); + smbcli_req_pull_string(req, mem_ctx, &parms->ctemp.out.name, req->in.data, -1, STR_TERMINATE | STR_ASCII); break; case RAW_OPEN_SPLOPEN: - CLI_CHECK_WCT(req, 1); + SMBCLI_CHECK_WCT(req, 1); parms->splopen.out.fnum = SVAL(req->in.vwv, VWV(0)); break; case RAW_OPEN_NTCREATEX: - CLI_CHECK_MIN_WCT(req, 34); + SMBCLI_CHECK_MIN_WCT(req, 34); parms->ntcreatex.out.oplock_level = CVAL(req->in.vwv, 4); parms->ntcreatex.out.fnum = SVAL(req->in.vwv, 5); parms->ntcreatex.out.create_action = IVAL(req->in.vwv, 7); - parms->ntcreatex.out.create_time = cli_pull_nttime(req->in.vwv, 11); - parms->ntcreatex.out.access_time = cli_pull_nttime(req->in.vwv, 19); - parms->ntcreatex.out.write_time = cli_pull_nttime(req->in.vwv, 27); - parms->ntcreatex.out.change_time = cli_pull_nttime(req->in.vwv, 35); + parms->ntcreatex.out.create_time = smbcli_pull_nttime(req->in.vwv, 11); + parms->ntcreatex.out.access_time = smbcli_pull_nttime(req->in.vwv, 19); + parms->ntcreatex.out.write_time = smbcli_pull_nttime(req->in.vwv, 27); + parms->ntcreatex.out.change_time = smbcli_pull_nttime(req->in.vwv, 35); parms->ntcreatex.out.attrib = IVAL(req->in.vwv, 43); parms->ntcreatex.out.alloc_size = BVAL(req->in.vwv, 47); parms->ntcreatex.out.size = BVAL(req->in.vwv, 55); @@ -471,16 +471,16 @@ NTSTATUS smb_raw_open_recv(struct cli_request *req, TALLOC_CTX *mem_ctx, union s } failed: - return cli_request_destroy(req); + return smbcli_request_destroy(req); } /**************************************************************************** Open a file - sync interface ****************************************************************************/ -NTSTATUS smb_raw_open(struct cli_tree *tree, TALLOC_CTX *mem_ctx, union smb_open *parms) +NTSTATUS smb_raw_open(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_open *parms) { - struct cli_request *req = smb_raw_open_send(tree, parms); + struct smbcli_request *req = smb_raw_open_send(tree, parms); return smb_raw_open_recv(req, mem_ctx, parms); } @@ -488,9 +488,9 @@ NTSTATUS smb_raw_open(struct cli_tree *tree, TALLOC_CTX *mem_ctx, union smb_open /**************************************************************************** Close a file - async send ****************************************************************************/ -struct cli_request *smb_raw_close_send(struct cli_tree *tree, union smb_close *parms) +struct smbcli_request *smb_raw_close_send(struct smbcli_tree *tree, union smb_close *parms) { - struct cli_request *req; + struct smbcli_request *req; switch (parms->generic.level) { case RAW_CLOSE_GENERIC: @@ -512,8 +512,8 @@ struct cli_request *smb_raw_close_send(struct cli_tree *tree, union smb_close *p if (!req) return NULL; - if (!cli_request_send(req)) { - cli_request_destroy(req); + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); return NULL; } @@ -524,19 +524,19 @@ struct cli_request *smb_raw_close_send(struct cli_tree *tree, union smb_close *p /**************************************************************************** Close a file - sync interface ****************************************************************************/ -NTSTATUS smb_raw_close(struct cli_tree *tree, union smb_close *parms) +NTSTATUS smb_raw_close(struct smbcli_tree *tree, union smb_close *parms) { - struct cli_request *req = smb_raw_close_send(tree, parms); - return cli_request_simple_recv(req); + struct smbcli_request *req = smb_raw_close_send(tree, parms); + return smbcli_request_simple_recv(req); } /**************************************************************************** Locking calls - async interface ****************************************************************************/ -struct cli_request *smb_raw_lock_send(struct cli_tree *tree, union smb_lock *parms) +struct smbcli_request *smb_raw_lock_send(struct smbcli_tree *tree, union smb_lock *parms) { - struct cli_request *req; + struct smbcli_request *req; switch (parms->generic.level) { case RAW_LOCK_GENERIC: @@ -590,8 +590,8 @@ struct cli_request *smb_raw_lock_send(struct cli_tree *tree, union smb_lock *par } } - if (!cli_request_send(req)) { - cli_request_destroy(req); + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); return NULL; } @@ -601,26 +601,26 @@ struct cli_request *smb_raw_lock_send(struct cli_tree *tree, union smb_lock *par /**************************************************************************** Locking calls - sync interface ****************************************************************************/ -NTSTATUS smb_raw_lock(struct cli_tree *tree, union smb_lock *parms) +NTSTATUS smb_raw_lock(struct smbcli_tree *tree, union smb_lock *parms) { - struct cli_request *req = smb_raw_lock_send(tree, parms); - return cli_request_simple_recv(req); + struct smbcli_request *req = smb_raw_lock_send(tree, parms); + return smbcli_request_simple_recv(req); } /**************************************************************************** Check for existence of a dir - async send ****************************************************************************/ -struct cli_request *smb_raw_chkpath_send(struct cli_tree *tree, struct smb_chkpath *parms) +struct smbcli_request *smb_raw_chkpath_send(struct smbcli_tree *tree, struct smb_chkpath *parms) { - struct cli_request *req; + struct smbcli_request *req; SETUP_REQUEST(SMBchkpth, 0, 0); - cli_req_append_ascii4(req, parms->in.path, STR_TERMINATE); + smbcli_req_append_ascii4(req, parms->in.path, STR_TERMINATE); - if (!cli_request_send(req)) { - cli_request_destroy(req); + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); return NULL; } @@ -630,10 +630,10 @@ struct cli_request *smb_raw_chkpath_send(struct cli_tree *tree, struct smb_chkpa /**************************************************************************** Check for existence of a dir - sync interface ****************************************************************************/ -NTSTATUS smb_raw_chkpath(struct cli_tree *tree, struct smb_chkpath *parms) +NTSTATUS smb_raw_chkpath(struct smbcli_tree *tree, struct smb_chkpath *parms) { - struct cli_request *req = smb_raw_chkpath_send(tree, parms); - return cli_request_simple_recv(req); + struct smbcli_request *req = smb_raw_chkpath_send(tree, parms); + return smbcli_request_simple_recv(req); } @@ -643,15 +643,15 @@ NTSTATUS smb_raw_chkpath(struct cli_tree *tree, struct smb_chkpath *parms) flush a file - async send a flush to fnum 0xFFFF will flush all files ****************************************************************************/ -struct cli_request *smb_raw_flush_send(struct cli_tree *tree, struct smb_flush *parms) +struct smbcli_request *smb_raw_flush_send(struct smbcli_tree *tree, struct smb_flush *parms) { - struct cli_request *req; + struct smbcli_request *req; SETUP_REQUEST(SMBflush, 1, 0); SSVAL(req->out.vwv, VWV(0), parms->in.fnum); - if (!cli_request_send(req)) { - cli_request_destroy(req); + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); return NULL; } @@ -662,20 +662,20 @@ struct cli_request *smb_raw_flush_send(struct cli_tree *tree, struct smb_flush * /**************************************************************************** flush a file - sync interface ****************************************************************************/ -NTSTATUS smb_raw_flush(struct cli_tree *tree, struct smb_flush *parms) +NTSTATUS smb_raw_flush(struct smbcli_tree *tree, struct smb_flush *parms) { - struct cli_request *req = smb_raw_flush_send(tree, parms); - return cli_request_simple_recv(req); + struct smbcli_request *req = smb_raw_flush_send(tree, parms); + return smbcli_request_simple_recv(req); } /**************************************************************************** seek a file - async send ****************************************************************************/ -struct cli_request *smb_raw_seek_send(struct cli_tree *tree, +struct smbcli_request *smb_raw_seek_send(struct smbcli_tree *tree, struct smb_seek *parms) { - struct cli_request *req; + struct smbcli_request *req; SETUP_REQUEST(SMBlseek, 4, 0); @@ -683,8 +683,8 @@ struct cli_request *smb_raw_seek_send(struct cli_tree *tree, SSVAL(req->out.vwv, VWV(1), parms->in.mode); SIVALS(req->out.vwv, VWV(2), parms->in.offset); - if (!cli_request_send(req)) { - cli_request_destroy(req); + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); return NULL; } return req; @@ -693,27 +693,27 @@ struct cli_request *smb_raw_seek_send(struct cli_tree *tree, /**************************************************************************** seek a file - async receive ****************************************************************************/ -NTSTATUS smb_raw_seek_recv(struct cli_request *req, +NTSTATUS smb_raw_seek_recv(struct smbcli_request *req, struct smb_seek *parms) { - if (!cli_request_receive(req) || - cli_request_is_error(req)) { - return cli_request_destroy(req); + if (!smbcli_request_receive(req) || + smbcli_request_is_error(req)) { + return smbcli_request_destroy(req); } - CLI_CHECK_WCT(req, 2); + SMBCLI_CHECK_WCT(req, 2); parms->out.offset = IVAL(req->in.vwv, VWV(0)); failed: - return cli_request_destroy(req); + return smbcli_request_destroy(req); } /* seek a file - sync interface */ -NTSTATUS smb_raw_seek(struct cli_tree *tree, +NTSTATUS smb_raw_seek(struct smbcli_tree *tree, struct smb_seek *parms) { - struct cli_request *req = smb_raw_seek_send(tree, parms); + struct smbcli_request *req = smb_raw_seek_send(tree, parms); return smb_raw_seek_recv(req, parms); } diff --git a/source4/libcli/raw/rawfileinfo.c b/source4/libcli/raw/rawfileinfo.c index f27a0d7281..8dc220b0b4 100644 --- a/source4/libcli/raw/rawfileinfo.c +++ b/source4/libcli/raw/rawfileinfo.c @@ -36,7 +36,7 @@ /**************************************************************************** Handle qfileinfo/qpathinfo trans2 backend. ****************************************************************************/ -static NTSTATUS smb_raw_info_backend(struct cli_session *session, +static NTSTATUS smb_raw_info_backend(struct smbcli_session *session, TALLOC_CTX *mem_ctx, union smb_fileinfo *parms, DATA_BLOB *blob) @@ -95,10 +95,10 @@ static NTSTATUS smb_raw_info_backend(struct cli_session *session, if (blob->length != 36) { FINFO_CHECK_SIZE(40); } - parms->basic_info.out.create_time = cli_pull_nttime(blob->data, 0); - parms->basic_info.out.access_time = cli_pull_nttime(blob->data, 8); - parms->basic_info.out.write_time = cli_pull_nttime(blob->data, 16); - parms->basic_info.out.change_time = cli_pull_nttime(blob->data, 24); + parms->basic_info.out.create_time = smbcli_pull_nttime(blob->data, 0); + parms->basic_info.out.access_time = smbcli_pull_nttime(blob->data, 8); + parms->basic_info.out.write_time = smbcli_pull_nttime(blob->data, 16); + parms->basic_info.out.change_time = smbcli_pull_nttime(blob->data, 24); parms->basic_info.out.attrib = IVAL(blob->data, 32); return NT_STATUS_OK; @@ -121,17 +121,17 @@ static NTSTATUS smb_raw_info_backend(struct cli_session *session, case RAW_FILEINFO_NAME_INFO: case RAW_FILEINFO_NAME_INFORMATION: FINFO_CHECK_MIN_SIZE(4); - cli_blob_pull_string(session, mem_ctx, blob, + smbcli_blob_pull_string(session, mem_ctx, blob, &parms->name_info.out.fname, 0, 4, STR_UNICODE); return NT_STATUS_OK; case RAW_FILEINFO_ALL_INFO: case RAW_FILEINFO_ALL_INFORMATION: FINFO_CHECK_MIN_SIZE(72); - parms->all_info.out.create_time = cli_pull_nttime(blob->data, 0); - parms->all_info.out.access_time = cli_pull_nttime(blob->data, 8); - parms->all_info.out.write_time = cli_pull_nttime(blob->data, 16); - parms->all_info.out.change_time = cli_pull_nttime(blob->data, 24); + parms->all_info.out.create_time = smbcli_pull_nttime(blob->data, 0); + parms->all_info.out.access_time = smbcli_pull_nttime(blob->data, 8); + parms->all_info.out.write_time = smbcli_pull_nttime(blob->data, 16); + parms->all_info.out.change_time = smbcli_pull_nttime(blob->data, 24); parms->all_info.out.attrib = IVAL(blob->data, 32); parms->all_info.out.alloc_size = BVAL(blob->data, 40); parms->all_info.out.size = BVAL(blob->data, 48); @@ -139,14 +139,14 @@ static NTSTATUS smb_raw_info_backend(struct cli_session *session, parms->all_info.out.delete_pending = CVAL(blob->data, 60); parms->all_info.out.directory = CVAL(blob->data, 61); parms->all_info.out.ea_size = IVAL(blob->data, 64); - cli_blob_pull_string(session, mem_ctx, blob, + smbcli_blob_pull_string(session, mem_ctx, blob, &parms->all_info.out.fname, 68, 72, STR_UNICODE); return NT_STATUS_OK; case RAW_FILEINFO_ALT_NAME_INFO: case RAW_FILEINFO_ALT_NAME_INFORMATION: FINFO_CHECK_MIN_SIZE(4); - cli_blob_pull_string(session, mem_ctx, blob, + smbcli_blob_pull_string(session, mem_ctx, blob, &parms->alt_name_info.out.fname, 0, 4, STR_UNICODE); return NT_STATUS_OK; @@ -166,7 +166,7 @@ static NTSTATUS smb_raw_info_backend(struct cli_session *session, } parms->stream_info.out.streams[n].size = BVAL(blob->data, ofs + 8); parms->stream_info.out.streams[n].alloc_size = BVAL(blob->data, ofs + 16); - cli_blob_pull_string(session, mem_ctx, blob, + smbcli_blob_pull_string(session, mem_ctx, blob, &parms->stream_info.out.streams[n].stream_name, ofs+4, ofs+24, STR_UNICODE); parms->stream_info.out.num_streams++; @@ -218,9 +218,9 @@ static NTSTATUS smb_raw_info_backend(struct cli_session *session, FINFO_CHECK_SIZE(100); parms->unix_basic_info.out.end_of_file = BVAL(blob->data, 0); parms->unix_basic_info.out.num_bytes = BVAL(blob->data, 8); - parms->unix_basic_info.out.status_change_time = cli_pull_nttime(blob->data, 16); - parms->unix_basic_info.out.access_time = cli_pull_nttime(blob->data, 24); - parms->unix_basic_info.out.change_time = cli_pull_nttime(blob->data, 32); + parms->unix_basic_info.out.status_change_time = smbcli_pull_nttime(blob->data, 16); + parms->unix_basic_info.out.access_time = smbcli_pull_nttime(blob->data, 24); + parms->unix_basic_info.out.change_time = smbcli_pull_nttime(blob->data, 32); parms->unix_basic_info.out.uid = BVAL(blob->data, 40); parms->unix_basic_info.out.gid = BVAL(blob->data, 48); parms->unix_basic_info.out.file_type = IVAL(blob->data, 52); @@ -232,16 +232,16 @@ static NTSTATUS smb_raw_info_backend(struct cli_session *session, return NT_STATUS_OK; case RAW_FILEINFO_UNIX_LINK: - cli_blob_pull_string(session, mem_ctx, blob, + smbcli_blob_pull_string(session, mem_ctx, blob, &parms->unix_link_info.out.link_dest, 0, 4, STR_UNICODE); return NT_STATUS_OK; case RAW_FILEINFO_NETWORK_OPEN_INFORMATION: FINFO_CHECK_SIZE(56); - parms->network_open_information.out.create_time = cli_pull_nttime(blob->data, 0); - parms->network_open_information.out.access_time = cli_pull_nttime(blob->data, 8); - parms->network_open_information.out.write_time = cli_pull_nttime(blob->data, 16); - parms->network_open_information.out.change_time = cli_pull_nttime(blob->data, 24); + parms->network_open_information.out.create_time = smbcli_pull_nttime(blob->data, 0); + parms->network_open_information.out.access_time = smbcli_pull_nttime(blob->data, 8); + parms->network_open_information.out.write_time = smbcli_pull_nttime(blob->data, 16); + parms->network_open_information.out.change_time = smbcli_pull_nttime(blob->data, 24); parms->network_open_information.out.alloc_size = BVAL(blob->data, 32); parms->network_open_information.out.size = BVAL(blob->data, 40); parms->network_open_information.out.attrib = IVAL(blob->data, 48); @@ -260,12 +260,12 @@ static NTSTATUS smb_raw_info_backend(struct cli_session *session, /**************************************************************************** Very raw query file info - returns param/data blobs - (async send) ****************************************************************************/ -static struct cli_request *smb_raw_fileinfo_blob_send(struct cli_tree *tree, +static struct smbcli_request *smb_raw_fileinfo_blob_send(struct smbcli_tree *tree, uint16_t fnum, uint16_t info_level) { struct smb_trans2 tp; uint16_t setup = TRANSACT2_QFILEINFO; - struct cli_request *req; + struct smbcli_request *req; TALLOC_CTX *mem_ctx = talloc_init("raw_fileinfo"); tp.in.max_setup = 0; @@ -297,7 +297,7 @@ static struct cli_request *smb_raw_fileinfo_blob_send(struct cli_tree *tree, /**************************************************************************** Very raw query file info - returns param/data blobs - (async recv) ****************************************************************************/ -static NTSTATUS smb_raw_fileinfo_blob_recv(struct cli_request *req, +static NTSTATUS smb_raw_fileinfo_blob_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, DATA_BLOB *blob) { @@ -312,13 +312,13 @@ static NTSTATUS smb_raw_fileinfo_blob_recv(struct cli_request *req, /**************************************************************************** Very raw query path info - returns param/data blobs (async send) ****************************************************************************/ -static struct cli_request *smb_raw_pathinfo_blob_send(struct cli_tree *tree, +static struct smbcli_request *smb_raw_pathinfo_blob_send(struct smbcli_tree *tree, const char *fname, uint16_t info_level) { struct smb_trans2 tp; uint16_t setup = TRANSACT2_QPATHINFO; - struct cli_request *req; + struct smbcli_request *req; TALLOC_CTX *mem_ctx = talloc_init("raw_pathinfo"); tp.in.max_setup = 0; @@ -338,7 +338,7 @@ static struct cli_request *smb_raw_pathinfo_blob_send(struct cli_tree *tree, SSVAL(tp.in.params.data, 0, info_level); SIVAL(tp.in.params.data, 2, 0); - cli_blob_append_string(tree->session, mem_ctx, &tp.in.params, + smbcli_blob_append_string(tree->session, mem_ctx, &tp.in.params, fname, STR_TERMINATE); req = smb_raw_trans2_send(tree, &tp); @@ -351,18 +351,18 @@ static struct cli_request *smb_raw_pathinfo_blob_send(struct cli_tree *tree, /**************************************************************************** send a SMBgetatr (async send) ****************************************************************************/ -static struct cli_request *smb_raw_getattr_send(struct cli_tree *tree, +static struct smbcli_request *smb_raw_getattr_send(struct smbcli_tree *tree, union smb_fileinfo *parms) { - struct cli_request *req; + struct smbcli_request *req; - req = cli_request_setup(tree, SMBgetatr, 0, 0); + req = smbcli_request_setup(tree, SMBgetatr, 0, 0); if (!req) return NULL; - cli_req_append_ascii4(req, parms->getattr.in.fname, STR_TERMINATE); + smbcli_req_append_ascii4(req, parms->getattr.in.fname, STR_TERMINATE); - if (!cli_request_send(req)) { - cli_request_destroy(req); + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); return NULL; } @@ -372,39 +372,39 @@ static struct cli_request *smb_raw_getattr_send(struct cli_tree *tree, /**************************************************************************** send a SMBgetatr (async recv) ****************************************************************************/ -static NTSTATUS smb_raw_getattr_recv(struct cli_request *req, +static NTSTATUS smb_raw_getattr_recv(struct smbcli_request *req, union smb_fileinfo *parms) { - if (!cli_request_receive(req) || - cli_request_is_error(req)) { - return cli_request_destroy(req); + if (!smbcli_request_receive(req) || + smbcli_request_is_error(req)) { + return smbcli_request_destroy(req); } - CLI_CHECK_WCT(req, 10); + SMBCLI_CHECK_WCT(req, 10); parms->getattr.out.attrib = SVAL(req->in.vwv, VWV(0)); parms->getattr.out.write_time = raw_pull_dos_date3(req->transport, req->in.vwv + VWV(1)); parms->getattr.out.size = IVAL(req->in.vwv, VWV(3)); failed: - return cli_request_destroy(req); + return smbcli_request_destroy(req); } /**************************************************************************** Handle SMBgetattrE (async send) ****************************************************************************/ -static struct cli_request *smb_raw_getattrE_send(struct cli_tree *tree, +static struct smbcli_request *smb_raw_getattrE_send(struct smbcli_tree *tree, union smb_fileinfo *parms) { - struct cli_request *req; + struct smbcli_request *req; - req = cli_request_setup(tree, SMBgetattrE, 1, 0); + req = smbcli_request_setup(tree, SMBgetattrE, 1, 0); if (!req) return NULL; SSVAL(req->out.vwv, VWV(0), parms->getattre.in.fnum); - if (!cli_request_send(req)) { - cli_request_destroy(req); + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); return NULL; } @@ -414,15 +414,15 @@ static struct cli_request *smb_raw_getattrE_send(struct cli_tree *tree, /**************************************************************************** Handle SMBgetattrE (async send) ****************************************************************************/ -static NTSTATUS smb_raw_getattrE_recv(struct cli_request *req, +static NTSTATUS smb_raw_getattrE_recv(struct smbcli_request *req, union smb_fileinfo *parms) { - if (!cli_request_receive(req) || - cli_request_is_error(req)) { - return cli_request_destroy(req); + if (!smbcli_request_receive(req) || + smbcli_request_is_error(req)) { + return smbcli_request_destroy(req); } - CLI_CHECK_WCT(req, 11); + SMBCLI_CHECK_WCT(req, 11); parms->getattre.out.create_time = raw_pull_dos_date2(req->transport, req->in.vwv + VWV(0)); parms->getattre.out.access_time = raw_pull_dos_date2(req->transport, @@ -434,14 +434,14 @@ static NTSTATUS smb_raw_getattrE_recv(struct cli_request *req, parms->getattre.out.attrib = SVAL(req->in.vwv, VWV(10)); failed: - return cli_request_destroy(req); + return smbcli_request_destroy(req); } /**************************************************************************** Query file info (async send) ****************************************************************************/ -struct cli_request *smb_raw_fileinfo_send(struct cli_tree *tree, +struct smbcli_request *smb_raw_fileinfo_send(struct smbcli_tree *tree, union smb_fileinfo *parms) { /* pass off the non-trans2 level to specialised functions */ @@ -460,13 +460,13 @@ struct cli_request *smb_raw_fileinfo_send(struct cli_tree *tree, /**************************************************************************** Query file info (async recv) ****************************************************************************/ -NTSTATUS smb_raw_fileinfo_recv(struct cli_request *req, +NTSTATUS smb_raw_fileinfo_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, union smb_fileinfo *parms) { DATA_BLOB blob; NTSTATUS status; - struct cli_session *session = req?req->session:NULL; + struct smbcli_session *session = req?req->session:NULL; if (parms->generic.level == RAW_FILEINFO_GETATTRE) { return smb_raw_getattrE_recv(req, parms); @@ -486,18 +486,18 @@ NTSTATUS smb_raw_fileinfo_recv(struct cli_request *req, /**************************************************************************** Query file info (sync interface) ****************************************************************************/ -NTSTATUS smb_raw_fileinfo(struct cli_tree *tree, +NTSTATUS smb_raw_fileinfo(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_fileinfo *parms) { - struct cli_request *req = smb_raw_fileinfo_send(tree, parms); + struct smbcli_request *req = smb_raw_fileinfo_send(tree, parms); return smb_raw_fileinfo_recv(req, mem_ctx, parms); } /**************************************************************************** Query path info (async send) ****************************************************************************/ -struct cli_request *smb_raw_pathinfo_send(struct cli_tree *tree, +struct smbcli_request *smb_raw_pathinfo_send(struct smbcli_tree *tree, union smb_fileinfo *parms) { if (parms->generic.level == RAW_FILEINFO_GETATTR) { @@ -514,7 +514,7 @@ struct cli_request *smb_raw_pathinfo_send(struct cli_tree *tree, /**************************************************************************** Query path info (async recv) ****************************************************************************/ -NTSTATUS smb_raw_pathinfo_recv(struct cli_request *req, +NTSTATUS smb_raw_pathinfo_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, union smb_fileinfo *parms) { @@ -525,10 +525,10 @@ NTSTATUS smb_raw_pathinfo_recv(struct cli_request *req, /**************************************************************************** Query path info (sync interface) ****************************************************************************/ -NTSTATUS smb_raw_pathinfo(struct cli_tree *tree, +NTSTATUS smb_raw_pathinfo(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_fileinfo *parms) { - struct cli_request *req = smb_raw_pathinfo_send(tree, parms); + struct smbcli_request *req = smb_raw_pathinfo_send(tree, parms); return smb_raw_pathinfo_recv(req, mem_ctx, parms); } diff --git a/source4/libcli/raw/rawfsinfo.c b/source4/libcli/raw/rawfsinfo.c index faf375deb0..aefe8e3085 100644 --- a/source4/libcli/raw/rawfsinfo.c +++ b/source4/libcli/raw/rawfsinfo.c @@ -25,15 +25,15 @@ /**************************************************************************** Query FS Info - SMBdskattr call (async send) ****************************************************************************/ -static struct cli_request *smb_raw_dskattr_send(struct cli_tree *tree, +static struct smbcli_request *smb_raw_dskattr_send(struct smbcli_tree *tree, union smb_fsinfo *fsinfo) { - struct cli_request *req; + struct smbcli_request *req; - req = cli_request_setup(tree, SMBdskattr, 0, 0); + req = smbcli_request_setup(tree, SMBdskattr, 0, 0); - if (!cli_request_send(req)) { - cli_request_destroy(req); + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); return NULL; } @@ -43,29 +43,29 @@ static struct cli_request *smb_raw_dskattr_send(struct cli_tree *tree, /**************************************************************************** Query FS Info - SMBdskattr call (async recv) ****************************************************************************/ -static NTSTATUS smb_raw_dskattr_recv(struct cli_request *req, +static NTSTATUS smb_raw_dskattr_recv(struct smbcli_request *req, union smb_fsinfo *fsinfo) { - if (!cli_request_receive(req) || - cli_request_is_error(req)) { + if (!smbcli_request_receive(req) || + smbcli_request_is_error(req)) { goto failed; } - CLI_CHECK_WCT(req, 5); + SMBCLI_CHECK_WCT(req, 5); fsinfo->dskattr.out.units_total = SVAL(req->in.vwv, VWV(0)); fsinfo->dskattr.out.blocks_per_unit = SVAL(req->in.vwv, VWV(1)); fsinfo->dskattr.out.block_size = SVAL(req->in.vwv, VWV(2)); fsinfo->dskattr.out.units_free = SVAL(req->in.vwv, VWV(3)); failed: - return cli_request_destroy(req); + return smbcli_request_destroy(req); } /**************************************************************************** RAW_QFS_ trans2 interface via blobs (async send) ****************************************************************************/ -static struct cli_request *smb_raw_qfsinfo_send(struct cli_tree *tree, +static struct smbcli_request *smb_raw_qfsinfo_send(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, uint16_t info_level) { @@ -94,7 +94,7 @@ static struct cli_request *smb_raw_qfsinfo_send(struct cli_tree *tree, /**************************************************************************** RAW_QFS_ trans2 interface via blobs (async recv) ****************************************************************************/ -static NTSTATUS smb_raw_qfsinfo_blob_recv(struct cli_request *req, +static NTSTATUS smb_raw_qfsinfo_blob_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, DATA_BLOB *blob) { @@ -129,7 +129,7 @@ static NTSTATUS smb_raw_qfsinfo_blob_recv(struct cli_request *req, /**************************************************************************** Query FSInfo raw interface (async send) ****************************************************************************/ -struct cli_request *smb_raw_fsinfo_send(struct cli_tree *tree, +struct smbcli_request *smb_raw_fsinfo_send(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_fsinfo *fsinfo) { @@ -153,14 +153,14 @@ struct cli_request *smb_raw_fsinfo_send(struct cli_tree *tree, /**************************************************************************** Query FSInfo raw interface (async recv) ****************************************************************************/ -NTSTATUS smb_raw_fsinfo_recv(struct cli_request *req, +NTSTATUS smb_raw_fsinfo_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, union smb_fsinfo *fsinfo) { DATA_BLOB blob; NTSTATUS status; int i; - struct cli_session *session = req?req->session:NULL; + struct smbcli_session *session = req?req->session:NULL; if (fsinfo->generic.level == RAW_QFS_DSKATTR) { return smb_raw_dskattr_recv(req, fsinfo); @@ -190,7 +190,7 @@ NTSTATUS smb_raw_fsinfo_recv(struct cli_request *req, case RAW_QFS_VOLUME: QFS_CHECK_MIN_SIZE(5); fsinfo->volume.out.serial_number = IVAL(blob.data, 0); - cli_blob_pull_string(session, mem_ctx, &blob, + smbcli_blob_pull_string(session, mem_ctx, &blob, &fsinfo->volume.out.volume_name, 4, 5, STR_LEN8BIT | STR_NOALIGN); break; @@ -198,9 +198,9 @@ NTSTATUS smb_raw_fsinfo_recv(struct cli_request *req, case RAW_QFS_VOLUME_INFO: case RAW_QFS_VOLUME_INFORMATION: QFS_CHECK_MIN_SIZE(18); - fsinfo->volume_info.out.create_time = cli_pull_nttime(blob.data, 0); + fsinfo->volume_info.out.create_time = smbcli_pull_nttime(blob.data, 0); fsinfo->volume_info.out.serial_number = IVAL(blob.data, 8); - cli_blob_pull_string(session, mem_ctx, &blob, + smbcli_blob_pull_string(session, mem_ctx, &blob, &fsinfo->volume_info.out.volume_name, 12, 18, STR_UNICODE); break; @@ -226,7 +226,7 @@ NTSTATUS smb_raw_fsinfo_recv(struct cli_request *req, QFS_CHECK_MIN_SIZE(12); fsinfo->attribute_info.out.fs_attr = IVAL(blob.data, 0); fsinfo->attribute_info.out.max_file_component_length = IVAL(blob.data, 4); - cli_blob_pull_string(session, mem_ctx, &blob, + smbcli_blob_pull_string(session, mem_ctx, &blob, &fsinfo->attribute_info.out.fs_type, 8, 12, STR_UNICODE); break; @@ -274,10 +274,10 @@ failed: /**************************************************************************** Query FSInfo raw interface (sync interface) ****************************************************************************/ -NTSTATUS smb_raw_fsinfo(struct cli_tree *tree, +NTSTATUS smb_raw_fsinfo(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_fsinfo *fsinfo) { - struct cli_request *req = smb_raw_fsinfo_send(tree, mem_ctx, fsinfo); + struct smbcli_request *req = smb_raw_fsinfo_send(tree, mem_ctx, fsinfo); return smb_raw_fsinfo_recv(req, mem_ctx, fsinfo); } diff --git a/source4/libcli/raw/rawioctl.c b/source4/libcli/raw/rawioctl.c index 271758c65c..798300451b 100644 --- a/source4/libcli/raw/rawioctl.c +++ b/source4/libcli/raw/rawioctl.c @@ -22,25 +22,25 @@ #include "includes.h" #define SETUP_REQUEST(cmd, wct, buflen) do { \ - req = cli_request_setup(tree, cmd, wct, buflen); \ + req = smbcli_request_setup(tree, cmd, wct, buflen); \ if (!req) return NULL; \ } while (0) /* send a raw smb ioctl - async send */ -static struct cli_request *smb_raw_smbioctl_send(struct cli_tree *tree, +static struct smbcli_request *smb_raw_smbioctl_send(struct smbcli_tree *tree, union smb_ioctl *parms) { - struct cli_request *req; + struct smbcli_request *req; SETUP_REQUEST(SMBioctl, 3, 0); 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); + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); return NULL; } @@ -50,17 +50,17 @@ static struct cli_request *smb_raw_smbioctl_send(struct cli_tree *tree, /* send a raw smb ioctl - async recv */ -static NTSTATUS smb_raw_smbioctl_recv(struct cli_request *req, +static NTSTATUS smb_raw_smbioctl_recv(struct smbcli_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); + if (!smbcli_request_receive(req) || + smbcli_request_is_error(req)) { + return smbcli_request_destroy(req); } - parms->ioctl.out.blob = cli_req_pull_blob(req, mem_ctx, req->in.data, -1); - return cli_request_destroy(req); + parms->ioctl.out.blob = smbcli_req_pull_blob(req, mem_ctx, req->in.data, -1); + return smbcli_request_destroy(req); } @@ -68,7 +68,7 @@ static NTSTATUS smb_raw_smbioctl_recv(struct cli_request *req, /**************************************************************************** NT ioctl (async send) ****************************************************************************/ -static struct cli_request *smb_raw_ntioctl_send(struct cli_tree *tree, +static struct smbcli_request *smb_raw_ntioctl_send(struct smbcli_tree *tree, union smb_ioctl *parms) { struct smb_nttrans nt; @@ -93,26 +93,26 @@ static struct cli_request *smb_raw_ntioctl_send(struct cli_tree *tree, /**************************************************************************** NT ioctl (async recv) ****************************************************************************/ -static NTSTATUS smb_raw_ntioctl_recv(struct cli_request *req, +static NTSTATUS smb_raw_ntioctl_recv(struct smbcli_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); + if (!smbcli_request_receive(req) || + smbcli_request_is_error(req)) { + return smbcli_request_destroy(req); } - parms->ntioctl.out.blob = cli_req_pull_blob(req, mem_ctx, req->in.data, -1); - return cli_request_destroy(req); + parms->ntioctl.out.blob = smbcli_req_pull_blob(req, mem_ctx, req->in.data, -1); + return smbcli_request_destroy(req); } /* send a raw ioctl - async send */ -struct cli_request *smb_raw_ioctl_send(struct cli_tree *tree, union smb_ioctl *parms) +struct smbcli_request *smb_raw_ioctl_send(struct smbcli_tree *tree, union smb_ioctl *parms) { - struct cli_request *req = NULL; + struct smbcli_request *req = NULL; switch (parms->generic.level) { case RAW_IOCTL_IOCTL: @@ -130,7 +130,7 @@ struct cli_request *smb_raw_ioctl_send(struct cli_tree *tree, union smb_ioctl *p /* recv a raw ioctl - async recv */ -NTSTATUS smb_raw_ioctl_recv(struct cli_request *req, +NTSTATUS smb_raw_ioctl_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, union smb_ioctl *parms) { switch (parms->generic.level) { @@ -146,10 +146,10 @@ NTSTATUS smb_raw_ioctl_recv(struct cli_request *req, /* send a raw ioctl - sync interface */ -NTSTATUS smb_raw_ioctl(struct cli_tree *tree, +NTSTATUS smb_raw_ioctl(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_ioctl *parms) { - struct cli_request *req; + struct smbcli_request *req; req = smb_raw_ioctl_send(tree, parms); return smb_raw_ioctl_recv(req, mem_ctx, parms); } diff --git a/source4/libcli/raw/rawnegotiate.c b/source4/libcli/raw/rawnegotiate.c index 6bf35fb26d..9b00aa6121 100644 --- a/source4/libcli/raw/rawnegotiate.c +++ b/source4/libcli/raw/rawnegotiate.c @@ -41,13 +41,13 @@ static const struct { /**************************************************************************** Send a negprot command. ****************************************************************************/ -struct cli_request *smb_negprot_send(struct cli_transport *transport, int maxprotocol) +struct smbcli_request *smb_negprot_send(struct smbcli_transport *transport, int maxprotocol) { - struct cli_request *req; + struct smbcli_request *req; int i; uint16_t flags2 = 0; - req = cli_request_setup_transport(transport, SMBnegprot, 0, 0); + req = smbcli_request_setup_transport(transport, SMBnegprot, 0, 0); if (!req) { return NULL; } @@ -66,12 +66,12 @@ struct cli_request *smb_negprot_send(struct cli_transport *transport, int maxpro /* setup the protocol strings */ for (i=0; i < ARRAY_SIZE(prots) && prots[i].prot <= maxprotocol; i++) { - cli_req_append_bytes(req, "\2", 1); - cli_req_append_string(req, prots[i].name, STR_TERMINATE | STR_ASCII); + smbcli_req_append_bytes(req, "\2", 1); + smbcli_req_append_string(req, prots[i].name, STR_TERMINATE | STR_ASCII); } - if (!cli_request_send(req)) { - cli_request_destroy(req); + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); return NULL; } @@ -81,9 +81,9 @@ struct cli_request *smb_negprot_send(struct cli_transport *transport, int maxpro /**************************************************************************** Send a negprot command. ****************************************************************************/ -NTSTATUS smb_raw_negotiate(struct cli_transport *transport) +NTSTATUS smb_raw_negotiate(struct smbcli_transport *transport) { - struct cli_request *req; + struct smbcli_request *req; int protocol; req = smb_negprot_send(transport, PROTOCOL_NT1); @@ -91,18 +91,18 @@ NTSTATUS smb_raw_negotiate(struct cli_transport *transport) return NT_STATUS_UNSUCCESSFUL; } - if (!cli_request_receive(req) || - cli_request_is_error(req)) { - return cli_request_destroy(req); + if (!smbcli_request_receive(req) || + smbcli_request_is_error(req)) { + return smbcli_request_destroy(req); } - CLI_CHECK_MIN_WCT(req, 1); + SMBCLI_CHECK_MIN_WCT(req, 1); protocol = SVALS(req->in.vwv, VWV(0)); if (protocol >= ARRAY_SIZE(prots) || protocol < 0) { req->status = NT_STATUS_UNSUCCESSFUL; - return cli_request_destroy(req); + return smbcli_request_destroy(req); } transport->negotiate.protocol = prots[protocol].prot; @@ -111,7 +111,7 @@ NTSTATUS smb_raw_negotiate(struct cli_transport *transport) NTTIME ntt; /* NT protocol */ - CLI_CHECK_WCT(req, 17); + SMBCLI_CHECK_WCT(req, 17); transport->negotiate.sec_mode = CVAL(req->in.vwv,VWV(1)); transport->negotiate.max_mux = SVAL(req->in.vwv,VWV(1)+1); transport->negotiate.max_xmit = IVAL(req->in.vwv,VWV(3)+1); @@ -119,7 +119,7 @@ NTSTATUS smb_raw_negotiate(struct cli_transport *transport) transport->negotiate.capabilities = IVAL(req->in.vwv,VWV(9)+1); /* this time arrives in real GMT */ - ntt = cli_pull_nttime(req->in.vwv, VWV(11)+1); + ntt = smbcli_pull_nttime(req->in.vwv, VWV(11)+1); transport->negotiate.server_time = nt_time_to_unix(ntt); transport->negotiate.server_zone = SVALS(req->in.vwv,VWV(15)+1) * 60; transport->negotiate.key_len = CVAL(req->in.vwv,VWV(16)+1); @@ -128,14 +128,14 @@ NTSTATUS smb_raw_negotiate(struct cli_transport *transport) if (req->in.data_size < 16) { goto failed; } - transport->negotiate.server_guid = cli_req_pull_blob(req, transport->mem_ctx, req->in.data, 16); - transport->negotiate.secblob = cli_req_pull_blob(req, transport->mem_ctx, req->in.data + 16, req->in.data_size - 16); + transport->negotiate.server_guid = smbcli_req_pull_blob(req, transport->mem_ctx, req->in.data, 16); + transport->negotiate.secblob = smbcli_req_pull_blob(req, transport->mem_ctx, req->in.data + 16, req->in.data_size - 16); } else { if (req->in.data_size < (transport->negotiate.key_len)) { goto failed; } - transport->negotiate.secblob = cli_req_pull_blob(req, transport->mem_ctx, req->in.data, transport->negotiate.key_len); - cli_req_pull_string(req, transport->mem_ctx, &transport->negotiate.server_domain, + transport->negotiate.secblob = smbcli_req_pull_blob(req, transport->mem_ctx, req->in.data, transport->negotiate.key_len); + smbcli_req_pull_string(req, transport->mem_ctx, &transport->negotiate.server_domain, req->in.data+transport->negotiate.key_len, req->in.data_size-transport->negotiate.key_len, STR_UNICODE|STR_NOALIGN); /* here comes the server name */ @@ -146,7 +146,7 @@ NTSTATUS smb_raw_negotiate(struct cli_transport *transport) transport->negotiate.writebraw_supported = True; } } else if (transport->negotiate.protocol >= PROTOCOL_LANMAN1) { - CLI_CHECK_WCT(req, 13); + SMBCLI_CHECK_WCT(req, 13); transport->negotiate.sec_mode = SVAL(req->in.vwv,VWV(1)); transport->negotiate.max_xmit = SVAL(req->in.vwv,VWV(2)); transport->negotiate.sesskey = IVAL(req->in.vwv,VWV(6)); @@ -161,7 +161,7 @@ NTSTATUS smb_raw_negotiate(struct cli_transport *transport) if ((SVAL(req->in.vwv,VWV(5)) & 0x2)) { transport->negotiate.writebraw_supported = 1; } - transport->negotiate.secblob = cli_req_pull_blob(req, transport->mem_ctx, + transport->negotiate.secblob = smbcli_req_pull_blob(req, transport->mem_ctx, req->in.data, req->in.data_size); } else { /* the old core protocol */ @@ -172,10 +172,10 @@ NTSTATUS smb_raw_negotiate(struct cli_transport *transport) } /* a way to force ascii SMB */ - if (getenv("CLI_FORCE_ASCII")) { + if (getenv("SMBCLI_FORCE_ASCII")) { transport->negotiate.capabilities &= ~CAP_UNICODE; } failed: - return cli_request_destroy(req); + return smbcli_request_destroy(req); } diff --git a/source4/libcli/raw/rawnotify.c b/source4/libcli/raw/rawnotify.c index a9215fee10..47553e735e 100644 --- a/source4/libcli/raw/rawnotify.c +++ b/source4/libcli/raw/rawnotify.c @@ -23,7 +23,7 @@ /**************************************************************************** change notify (async send) ****************************************************************************/ -struct cli_request *smb_raw_changenotify_send(struct cli_tree *tree, struct smb_notify *parms) +struct smbcli_request *smb_raw_changenotify_send(struct smbcli_tree *tree, struct smb_notify *parms) { struct smb_nttrans nt; uint16_t setup[4]; @@ -46,13 +46,13 @@ struct cli_request *smb_raw_changenotify_send(struct cli_tree *tree, struct smb_ /**************************************************************************** change notify (async recv) ****************************************************************************/ -NTSTATUS smb_raw_changenotify_recv(struct cli_request *req, +NTSTATUS smb_raw_changenotify_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, struct smb_notify *parms) { struct smb_nttrans nt; NTSTATUS status; uint32_t ofs, i; - struct cli_session *session = req?req->session:NULL; + struct smbcli_session *session = req?req->session:NULL; status = smb_raw_nttrans_recv(req, mem_ctx, &nt); if (!NT_STATUS_IS_OK(status)) { @@ -80,7 +80,7 @@ NTSTATUS smb_raw_changenotify_recv(struct cli_request *req, for (i=ofs=0; i<parms->out.num_changes; i++) { parms->out.changes[i].action = IVAL(nt.out.params.data, ofs+4); - cli_blob_pull_string(session, mem_ctx, &nt.out.params, + smbcli_blob_pull_string(session, mem_ctx, &nt.out.params, &parms->out.changes[i].name, ofs+8, ofs+12, STR_UNICODE); ofs += IVAL(nt.out.params.data, ofs); @@ -95,11 +95,11 @@ NTSTATUS smb_raw_changenotify_recv(struct cli_request *req, used to cancel a pending change notify request note that this request does not expect a response! ****************************************************************************/ -NTSTATUS smb_raw_ntcancel(struct cli_request *oldreq) +NTSTATUS smb_raw_ntcancel(struct smbcli_request *oldreq) { - struct cli_request *req; + struct smbcli_request *req; - req = cli_request_setup_transport(oldreq->transport, SMBntcancel, 0, 0); + req = smbcli_request_setup_transport(oldreq->transport, SMBntcancel, 0, 0); SSVAL(req->out.hdr, HDR_MID, SVAL(oldreq->out.hdr, HDR_MID)); SSVAL(req->out.hdr, HDR_PID, SVAL(oldreq->out.hdr, HDR_PID)); @@ -111,7 +111,7 @@ NTSTATUS smb_raw_ntcancel(struct cli_request *oldreq) req->sign_single_increment = 1; req->one_way_request = 1; - cli_request_send(req); + smbcli_request_send(req); return NT_STATUS_OK; } diff --git a/source4/libcli/raw/rawreadwrite.c b/source4/libcli/raw/rawreadwrite.c index 3e3b29d252..f0a9a063ed 100644 --- a/source4/libcli/raw/rawreadwrite.c +++ b/source4/libcli/raw/rawreadwrite.c @@ -22,7 +22,7 @@ #include "includes.h" #define SETUP_REQUEST(cmd, wct, buflen) do { \ - req = cli_request_setup(tree, cmd, wct, buflen); \ + req = smbcli_request_setup(tree, cmd, wct, buflen); \ if (!req) return NULL; \ } while (0) @@ -30,10 +30,10 @@ /**************************************************************************** low level read operation (async send) ****************************************************************************/ -struct cli_request *smb_raw_read_send(struct cli_tree *tree, union smb_read *parms) +struct smbcli_request *smb_raw_read_send(struct smbcli_tree *tree, union smb_read *parms) { BOOL bigoffset = False; - struct cli_request *req; + struct smbcli_request *req; switch (parms->generic.level) { case RAW_READ_GENERIC: @@ -90,8 +90,8 @@ struct cli_request *smb_raw_read_send(struct cli_tree *tree, union smb_read *par break; } - if (!cli_request_send(req)) { - cli_request_destroy(req); + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); return NULL; } @@ -107,10 +107,10 @@ struct cli_request *smb_raw_read_send(struct cli_tree *tree, union smb_read *par /**************************************************************************** low level read operation (async recv) ****************************************************************************/ -NTSTATUS smb_raw_read_recv(struct cli_request *req, union smb_read *parms) +NTSTATUS smb_raw_read_recv(struct smbcli_request *req, union smb_read *parms) { - if (!cli_request_receive(req) || - cli_request_is_error(req)) { + if (!smbcli_request_receive(req) || + smbcli_request_is_error(req)) { goto failed; } @@ -130,10 +130,10 @@ NTSTATUS smb_raw_read_recv(struct cli_request *req, union smb_read *parms) break; case RAW_READ_LOCKREAD: - CLI_CHECK_WCT(req, 5); + SMBCLI_CHECK_WCT(req, 5); parms->lockread.out.nread = SVAL(req->in.vwv, VWV(0)); if (parms->lockread.out.nread > parms->lockread.in.count || - !cli_raw_pull_data(req, req->in.data+3, + !smbcli_raw_pull_data(req, req->in.data+3, parms->lockread.out.nread, parms->lockread.out.data)) { req->status = NT_STATUS_BUFFER_TOO_SMALL; } @@ -141,10 +141,10 @@ NTSTATUS smb_raw_read_recv(struct cli_request *req, union smb_read *parms) case RAW_READ_READ: /* there are 4 reserved words in the reply */ - CLI_CHECK_WCT(req, 5); + SMBCLI_CHECK_WCT(req, 5); parms->read.out.nread = SVAL(req->in.vwv, VWV(0)); if (parms->read.out.nread > parms->read.in.count || - !cli_raw_pull_data(req, req->in.data+3, + !smbcli_raw_pull_data(req, req->in.data+3, parms->read.out.nread, parms->read.out.data)) { req->status = NT_STATUS_BUFFER_TOO_SMALL; } @@ -152,12 +152,12 @@ NTSTATUS smb_raw_read_recv(struct cli_request *req, union smb_read *parms) case RAW_READ_READX: /* there are 5 reserved words in the reply */ - CLI_CHECK_WCT(req, 12); + SMBCLI_CHECK_WCT(req, 12); parms->readx.out.remaining = SVAL(req->in.vwv, VWV(2)); parms->readx.out.compaction_mode = SVAL(req->in.vwv, VWV(3)); parms->readx.out.nread = SVAL(req->in.vwv, VWV(5)); if (parms->readx.out.nread > MAX(parms->readx.in.mincnt, parms->readx.in.maxcnt) || - !cli_raw_pull_data(req, req->in.hdr + SVAL(req->in.vwv, VWV(6)), + !smbcli_raw_pull_data(req, req->in.hdr + SVAL(req->in.vwv, VWV(6)), parms->readx.out.nread, parms->readx.out.data)) { req->status = NT_STATUS_BUFFER_TOO_SMALL; @@ -166,15 +166,15 @@ NTSTATUS smb_raw_read_recv(struct cli_request *req, union smb_read *parms) } failed: - return cli_request_destroy(req); + return smbcli_request_destroy(req); } /**************************************************************************** low level read operation (sync interface) ****************************************************************************/ -NTSTATUS smb_raw_read(struct cli_tree *tree, union smb_read *parms) +NTSTATUS smb_raw_read(struct smbcli_tree *tree, union smb_read *parms) { - struct cli_request *req = smb_raw_read_send(tree, parms); + struct smbcli_request *req = smb_raw_read_send(tree, parms); return smb_raw_read_recv(req, parms); } @@ -182,10 +182,10 @@ NTSTATUS smb_raw_read(struct cli_tree *tree, union smb_read *parms) /**************************************************************************** raw write interface (async send) ****************************************************************************/ -struct cli_request *smb_raw_write_send(struct cli_tree *tree, union smb_write *parms) +struct smbcli_request *smb_raw_write_send(struct smbcli_tree *tree, union smb_write *parms) { BOOL bigoffset = False; - struct cli_request *req; + struct smbcli_request *req; switch (parms->generic.level) { case RAW_WRITE_GENERIC: @@ -264,8 +264,8 @@ struct cli_request *smb_raw_write_send(struct cli_tree *tree, union smb_write *p break; } - if (!cli_request_send(req)) { -cli_request_destroy(req); + if (!smbcli_request_send(req)) { +smbcli_request_destroy(req); return NULL; } @@ -276,10 +276,10 @@ cli_request_destroy(req); /**************************************************************************** raw write interface (async recv) ****************************************************************************/ -NTSTATUS smb_raw_write_recv(struct cli_request *req, union smb_write *parms) +NTSTATUS smb_raw_write_recv(struct smbcli_request *req, union smb_write *parms) { - if (!cli_request_receive(req) || - cli_request_is_error(req)) { + if (!smbcli_request_receive(req) || + smbcli_request_is_error(req)) { goto failed; } @@ -287,19 +287,19 @@ NTSTATUS smb_raw_write_recv(struct cli_request *req, union smb_write *parms) case RAW_WRITE_GENERIC: break; case RAW_WRITE_WRITEUNLOCK: - CLI_CHECK_WCT(req, 1); + SMBCLI_CHECK_WCT(req, 1); parms->writeunlock.out.nwritten = SVAL(req->in.vwv, VWV(0)); break; case RAW_WRITE_WRITE: - CLI_CHECK_WCT(req, 1); + SMBCLI_CHECK_WCT(req, 1); parms->write.out.nwritten = SVAL(req->in.vwv, VWV(0)); break; case RAW_WRITE_WRITECLOSE: - CLI_CHECK_WCT(req, 1); + SMBCLI_CHECK_WCT(req, 1); parms->writeclose.out.nwritten = SVAL(req->in.vwv, VWV(0)); break; case RAW_WRITE_WRITEX: - CLI_CHECK_WCT(req, 6); + SMBCLI_CHECK_WCT(req, 6); parms->writex.out.nwritten = SVAL(req->in.vwv, VWV(2)); parms->writex.out.nwritten += (CVAL(req->in.vwv, VWV(4)) << 16); parms->writex.out.remaining = SVAL(req->in.vwv, VWV(3)); @@ -309,14 +309,14 @@ NTSTATUS smb_raw_write_recv(struct cli_request *req, union smb_write *parms) } failed: - return cli_request_destroy(req); + return smbcli_request_destroy(req); } /**************************************************************************** raw write interface (sync interface) ****************************************************************************/ -NTSTATUS smb_raw_write(struct cli_tree *tree, union smb_write *parms) +NTSTATUS smb_raw_write(struct smbcli_tree *tree, union smb_write *parms) { - struct cli_request *req = smb_raw_write_send(tree, parms); + struct smbcli_request *req = smb_raw_write_send(tree, parms); return smb_raw_write_recv(req, parms); } diff --git a/source4/libcli/raw/rawrequest.c b/source4/libcli/raw/rawrequest.c index 38b8f71f57..4143cb12ca 100644 --- a/source4/libcli/raw/rawrequest.c +++ b/source4/libcli/raw/rawrequest.c @@ -20,7 +20,7 @@ */ /* - this file implements functions for manipulating the 'struct cli_request' structure in libsmb + this file implements functions for manipulating the 'struct smbcli_request' structure in libsmb */ #include "includes.h" @@ -32,7 +32,7 @@ #define MAX_BYTES_PER_CHAR 3 /* destroy a request structure and return final status */ -NTSTATUS cli_request_destroy(struct cli_request *req) +NTSTATUS smbcli_request_destroy(struct smbcli_request *req) { NTSTATUS status; @@ -58,28 +58,28 @@ NTSTATUS cli_request_destroy(struct cli_request *req) low-level function to setup a request buffer for a non-SMB packet at the transport level */ -struct cli_request *cli_request_setup_nonsmb(struct cli_transport *transport, uint_t size) +struct smbcli_request *smbcli_request_setup_nonsmb(struct smbcli_transport *transport, uint_t size) { - struct cli_request *req; + struct smbcli_request *req; TALLOC_CTX *mem_ctx; /* each request gets its own talloc context. The request structure itself is also allocated inside this context, so we need to allocate it before we construct the request */ - mem_ctx = talloc_init("cli_request"); + mem_ctx = talloc_init("smbcli_request"); if (!mem_ctx) { return NULL; } - req = talloc(mem_ctx, sizeof(struct cli_request)); + req = talloc(mem_ctx, sizeof(struct smbcli_request)); if (!req) { return NULL; } ZERO_STRUCTP(req); /* setup the request context */ - req->state = CLI_REQUEST_INIT; + req->state = SMBCLI_REQUEST_INIT; req->mem_ctx = mem_ctx; req->transport = transport; req->session = NULL; @@ -103,12 +103,12 @@ struct cli_request *cli_request_setup_nonsmb(struct cli_transport *transport, ui /* setup a SMB packet at transport level */ -struct cli_request *cli_request_setup_transport(struct cli_transport *transport, +struct smbcli_request *smbcli_request_setup_transport(struct smbcli_transport *transport, uint8_t command, uint_t wct, uint_t buflen) { - struct cli_request *req; + struct smbcli_request *req; - req = cli_request_setup_nonsmb(transport, NBT_HDR_SIZE + MIN_SMB_SIZE + wct*2 + buflen); + req = smbcli_request_setup_nonsmb(transport, NBT_HDR_SIZE + MIN_SMB_SIZE + wct*2 + buflen); if (!req) return NULL; @@ -129,7 +129,7 @@ struct cli_request *cli_request_setup_transport(struct cli_transport *transport, SSVAL(req->out.hdr,HDR_FLG2, 0); /* assign a mid */ - req->mid = cli_transport_next_mid(transport); + req->mid = smbcli_transport_next_mid(transport); /* copy the pid, uid and mid to the request */ SSVAL(req->out.hdr, HDR_PID, 0); @@ -146,17 +146,17 @@ struct cli_request *cli_request_setup_transport(struct cli_transport *transport, /* setup a reply in req->out with the given word count and initial data buffer size. the caller will then fill in the command words and - data before calling cli_request_send() to send the reply on its + data before calling smbcli_request_send() to send the reply on its way. This interface is used before a session is setup. */ -struct cli_request *cli_request_setup_session(struct cli_session *session, +struct smbcli_request *smbcli_request_setup_session(struct smbcli_session *session, uint8_t command, uint_t wct, uint_t buflen) { - struct cli_request *req; + struct smbcli_request *req; uint16_t flags2; uint32_t capabilities; - req = cli_request_setup_transport(session->transport, command, wct, buflen); + req = smbcli_request_setup_transport(session->transport, command, wct, buflen); if (!req) return NULL; @@ -189,13 +189,13 @@ struct cli_request *cli_request_setup_session(struct cli_session *session, /* setup a request for tree based commands */ -struct cli_request *cli_request_setup(struct cli_tree *tree, +struct smbcli_request *smbcli_request_setup(struct smbcli_tree *tree, uint8_t command, uint_t wct, uint_t buflen) { - struct cli_request *req; + struct smbcli_request *req; - req = cli_request_setup_session(tree->session, command, wct, buflen); + req = smbcli_request_setup_session(tree->session, command, wct, buflen); if (req) { req->tree = tree; SSVAL(req->out.hdr,HDR_TID,tree->tid); @@ -211,7 +211,7 @@ struct cli_request *cli_request_setup(struct cli_tree *tree, To cope with this req->out.ptr is supplied. This will be updated to point at the same offset into the packet as before this call */ -static void cli_req_grow_allocation(struct cli_request *req, uint_t new_size) +static void smbcli_req_grow_allocation(struct smbcli_request *req, uint_t new_size) { int delta; char *buf2; @@ -252,11 +252,11 @@ static void cli_req_grow_allocation(struct cli_request *req, uint_t new_size) To cope with this req->out.ptr is supplied. This will be updated to point at the same offset into the packet as before this call */ -static void cli_req_grow_data(struct cli_request *req, uint_t new_size) +static void smbcli_req_grow_data(struct smbcli_request *req, uint_t new_size) { int delta; - cli_req_grow_allocation(req, new_size); + smbcli_req_grow_allocation(req, new_size); delta = new_size - req->out.data_size; @@ -271,15 +271,15 @@ static void cli_req_grow_data(struct cli_request *req, uint_t new_size) /* send a message */ -BOOL cli_request_send(struct cli_request *req) +BOOL smbcli_request_send(struct smbcli_request *req) { if (IVAL(req->out.buffer, 0) == 0) { _smb_setlen(req->out.buffer, req->out.size - NBT_HDR_SIZE); } - cli_request_calculate_sign_mac(req); + smbcli_request_calculate_sign_mac(req); - cli_transport_send(req); + smbcli_transport_send(req); return True; } @@ -288,14 +288,14 @@ BOOL cli_request_send(struct cli_request *req) /* receive a response to a packet */ -BOOL cli_request_receive(struct cli_request *req) +BOOL smbcli_request_receive(struct smbcli_request *req) { /* req can be NULL when a send has failed. This eliminates lots of NULL checks in each module */ if (!req) return False; /* keep receiving packets until this one is replied to */ - while (req->state <= CLI_REQUEST_RECV) { + while (req->state <= SMBCLI_REQUEST_RECV) { event_loop_once(req->transport->event.ctx); } @@ -307,12 +307,12 @@ BOOL cli_request_receive(struct cli_request *req) receive another reply to a request - this is used for requests that have multi-part replies (such as SMBtrans2) */ -BOOL cli_request_receive_more(struct cli_request *req) +BOOL smbcli_request_receive_more(struct smbcli_request *req) { - req->state = CLI_REQUEST_RECV; + req->state = SMBCLI_REQUEST_RECV; DLIST_ADD(req->transport->pending_recv, req); - return cli_request_receive(req); + return smbcli_request_receive(req); } @@ -320,7 +320,7 @@ BOOL cli_request_receive_more(struct cli_request *req) handle oplock break requests from the server - return True if the request was an oplock break */ -BOOL handle_oplock_break(struct cli_transport *transport, uint_t len, const char *hdr, const char *vwv) +BOOL handle_oplock_break(struct smbcli_transport *transport, uint_t len, const char *hdr, const char *vwv) { /* we must be very fussy about what we consider an oplock break to avoid matching readbraw replies */ @@ -347,15 +347,15 @@ BOOL handle_oplock_break(struct cli_transport *transport, uint_t len, const char wait for a reply to be received for a packet that just returns an error code and nothing more */ -NTSTATUS cli_request_simple_recv(struct cli_request *req) +NTSTATUS smbcli_request_simple_recv(struct smbcli_request *req) { - cli_request_receive(req); - return cli_request_destroy(req); + smbcli_request_receive(req); + return smbcli_request_destroy(req); } /* Return true if the last packet was in error */ -BOOL cli_request_is_error(struct cli_request *req) +BOOL smbcli_request_is_error(struct smbcli_request *req) { return NT_STATUS_IS_ERR(req->status); } @@ -365,7 +365,7 @@ BOOL cli_request_is_error(struct cli_request *req) return the number of bytes added to the packet */ -size_t cli_req_append_string(struct cli_request *req, const char *str, uint_t flags) +size_t smbcli_req_append_string(struct smbcli_request *req, const char *str, uint_t flags) { size_t len; @@ -376,17 +376,17 @@ size_t cli_req_append_string(struct cli_request *req, const char *str, uint_t fl len = (strlen(str)+2) * MAX_BYTES_PER_CHAR; - cli_req_grow_allocation(req, len + req->out.data_size); + smbcli_req_grow_allocation(req, len + req->out.data_size); len = push_string(NULL, req->out.data + req->out.data_size, str, len, flags); - cli_req_grow_data(req, len + req->out.data_size); + smbcli_req_grow_data(req, len + req->out.data_size); return len; } /* - this is like cli_req_append_string but it also return the + this is like smbcli_req_append_string but it also return the non-terminated string byte length, which can be less than the number of bytes consumed in the packet for 2 reasons: @@ -396,7 +396,7 @@ size_t cli_req_append_string(struct cli_request *req, const char *str, uint_t fl this is used in places where the non-terminated string byte length is placed in the packet as a separate field */ -size_t cli_req_append_string_len(struct cli_request *req, const char *str, uint_t flags, int *len) +size_t smbcli_req_append_string_len(struct smbcli_request *req, const char *str, uint_t flags, int *len) { int diff = 0; size_t ret; @@ -412,7 +412,7 @@ size_t cli_req_append_string_len(struct cli_request *req, const char *str, uint_ } /* do the hard work */ - ret = cli_req_append_string(req, str, flags); + ret = smbcli_req_append_string(req, str, flags); /* see if we need to subtract the termination */ if (flags & STR_TERMINATE) { @@ -437,11 +437,11 @@ size_t cli_req_append_string_len(struct cli_request *req, const char *str, uint_ if dest_len is -1 then no limit applies */ -size_t cli_req_append_ascii4(struct cli_request *req, const char *str, uint_t flags) +size_t smbcli_req_append_ascii4(struct smbcli_request *req, const char *str, uint_t flags) { size_t size; - cli_req_append_bytes(req, (const uint8_t *)"\4", 1); - size = cli_req_append_string(req, str, flags); + smbcli_req_append_bytes(req, (const uint8_t *)"\4", 1); + size = smbcli_req_append_string(req, str, flags); return size + 1; } @@ -452,11 +452,11 @@ size_t cli_req_append_ascii4(struct cli_request *req, const char *str, uint_t fl if dest is NULL, then put the blob at the end of the data portion of the packet */ -size_t cli_req_append_blob(struct cli_request *req, const DATA_BLOB *blob) +size_t smbcli_req_append_blob(struct smbcli_request *req, const DATA_BLOB *blob) { - cli_req_grow_allocation(req, req->out.data_size + blob->length); + smbcli_req_grow_allocation(req, req->out.data_size + blob->length); memcpy(req->out.data + req->out.data_size, blob->data, blob->length); - cli_req_grow_data(req, req->out.data_size + blob->length); + smbcli_req_grow_data(req, req->out.data_size + blob->length); return blob->length; } @@ -464,11 +464,11 @@ size_t cli_req_append_blob(struct cli_request *req, const DATA_BLOB *blob) append raw bytes into the data portion of the request packet return the number of bytes added */ -size_t cli_req_append_bytes(struct cli_request *req, const uint8_t *bytes, size_t byte_len) +size_t smbcli_req_append_bytes(struct smbcli_request *req, const uint8_t *bytes, size_t byte_len) { - cli_req_grow_allocation(req, byte_len + req->out.data_size); + smbcli_req_grow_allocation(req, byte_len + req->out.data_size); memcpy(req->out.data + req->out.data_size, bytes, byte_len); - cli_req_grow_data(req, byte_len + req->out.data_size); + smbcli_req_grow_data(req, byte_len + req->out.data_size); return byte_len; } @@ -476,15 +476,15 @@ size_t cli_req_append_bytes(struct cli_request *req, const uint8_t *bytes, size_ append variable block (type 5 buffer) into the data portion of the request packet return the number of bytes added */ -size_t cli_req_append_var_block(struct cli_request *req, const uint8_t *bytes, uint16_t byte_len) +size_t smbcli_req_append_var_block(struct smbcli_request *req, const uint8_t *bytes, uint16_t byte_len) { - cli_req_grow_allocation(req, byte_len + 3 + req->out.data_size); + smbcli_req_grow_allocation(req, byte_len + 3 + req->out.data_size); SCVAL(req->out.data + req->out.data_size, 0, 5); SSVAL(req->out.data + req->out.data_size, 1, byte_len); /* add field length */ if (byte_len > 0) { memcpy(req->out.data + req->out.data_size + 3, bytes, byte_len); } - cli_req_grow_data(req, byte_len + 3 + req->out.data_size); + smbcli_req_grow_data(req, byte_len + 3 + req->out.data_size); return byte_len + 3; } @@ -502,7 +502,7 @@ size_t cli_req_append_var_block(struct cli_request *req, const uint8_t *bytes, u on failure zero is returned and *dest is set to NULL, otherwise the number of bytes consumed in the packet is returned */ -static size_t cli_req_pull_ucs2(struct cli_request *req, TALLOC_CTX *mem_ctx, +static size_t smbcli_req_pull_ucs2(struct smbcli_request *req, TALLOC_CTX *mem_ctx, char **dest, const char *src, int byte_len, uint_t flags) { int src_len, src_len2, alignment=0; @@ -559,7 +559,7 @@ static size_t cli_req_pull_ucs2(struct cli_request *req, TALLOC_CTX *mem_ctx, on failure zero is returned and *dest is set to NULL, otherwise the number of bytes consumed in the packet is returned */ -size_t cli_req_pull_ascii(struct cli_request *req, TALLOC_CTX *mem_ctx, +size_t smbcli_req_pull_ascii(struct smbcli_request *req, TALLOC_CTX *mem_ctx, char **dest, const char *src, int byte_len, uint_t flags) { int src_len, src_len2; @@ -602,15 +602,15 @@ size_t cli_req_pull_ascii(struct cli_request *req, TALLOC_CTX *mem_ctx, on failure zero is returned and *dest is set to NULL, otherwise the number of bytes consumed in the packet is returned */ -size_t cli_req_pull_string(struct cli_request *req, TALLOC_CTX *mem_ctx, +size_t smbcli_req_pull_string(struct smbcli_request *req, TALLOC_CTX *mem_ctx, char **dest, const char *src, int byte_len, uint_t flags) { if (!(flags & STR_ASCII) && (((flags & STR_UNICODE) || (req->flags2 & FLAGS2_UNICODE_STRINGS)))) { - return cli_req_pull_ucs2(req, mem_ctx, dest, src, byte_len, flags); + return smbcli_req_pull_ucs2(req, mem_ctx, dest, src, byte_len, flags); } - return cli_req_pull_ascii(req, mem_ctx, dest, src, byte_len, flags); + return smbcli_req_pull_ascii(req, mem_ctx, dest, src, byte_len, flags); } @@ -620,7 +620,7 @@ size_t cli_req_pull_string(struct cli_request *req, TALLOC_CTX *mem_ctx, if byte_len is -1 then limit the blob only by packet size */ -DATA_BLOB cli_req_pull_blob(struct cli_request *req, TALLOC_CTX *mem_ctx, const char *src, int byte_len) +DATA_BLOB smbcli_req_pull_blob(struct smbcli_request *req, TALLOC_CTX *mem_ctx, const char *src, int byte_len) { int src_len; @@ -639,7 +639,7 @@ DATA_BLOB cli_req_pull_blob(struct cli_request *req, TALLOC_CTX *mem_ctx, const /* check that a lump of data in a request is within the bounds of the data section of the packet */ -static BOOL cli_req_data_oob(struct cli_request *req, const char *ptr, uint32_t count) +static BOOL smbcli_req_data_oob(struct smbcli_request *req, const char *ptr, uint32_t count) { /* be careful with wraparound! */ if (ptr < req->in.data || @@ -656,11 +656,11 @@ static BOOL cli_req_data_oob(struct cli_request *req, const char *ptr, uint32_t return False if any part is outside the data portion of the packet */ -BOOL cli_raw_pull_data(struct cli_request *req, const char *src, int len, char *dest) +BOOL smbcli_raw_pull_data(struct smbcli_request *req, const char *src, int len, char *dest) { if (len == 0) return True; - if (cli_req_data_oob(req, src, len)) { + if (smbcli_req_data_oob(req, src, len)) { return False; } @@ -672,7 +672,7 @@ BOOL cli_raw_pull_data(struct cli_request *req, const char *src, int len, char * /* put a NTTIME into a packet */ -void cli_push_nttime(void *base, uint16_t offset, NTTIME t) +void smbcli_push_nttime(void *base, uint16_t offset, NTTIME t) { SBVAL(base, offset, t); } @@ -680,7 +680,7 @@ void cli_push_nttime(void *base, uint16_t offset, NTTIME t) /* pull a NTTIME from a packet */ -NTTIME cli_pull_nttime(void *base, uint16_t offset) +NTTIME smbcli_pull_nttime(void *base, uint16_t offset) { NTTIME ret = BVAL(base, offset); return ret; @@ -699,7 +699,7 @@ NTTIME cli_pull_nttime(void *base, uint16_t offset) on failure zero is returned and *dest is set to NULL, otherwise the number of bytes consumed in the blob is returned */ -static size_t cli_blob_pull_ucs2(TALLOC_CTX* mem_ctx, +static size_t smbcli_blob_pull_ucs2(TALLOC_CTX* mem_ctx, DATA_BLOB *blob, const char **dest, const char *src, int byte_len, uint_t flags) { @@ -758,7 +758,7 @@ static size_t cli_blob_pull_ucs2(TALLOC_CTX* mem_ctx, on failure zero is returned and *dest is set to NULL, otherwise the number of bytes consumed in the blob is returned */ -static size_t cli_blob_pull_ascii(TALLOC_CTX *mem_ctx, +static size_t smbcli_blob_pull_ascii(TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const char **dest, const char *src, int byte_len, uint_t flags) { @@ -804,7 +804,7 @@ static size_t cli_blob_pull_ascii(TALLOC_CTX *mem_ctx, on failure zero is returned and dest->s is set to NULL, otherwise the number of bytes consumed in the blob is returned */ -size_t cli_blob_pull_string(struct cli_session *session, +size_t smbcli_blob_pull_string(struct smbcli_session *session, TALLOC_CTX *mem_ctx, DATA_BLOB *blob, WIRE_STRING *dest, @@ -834,7 +834,7 @@ size_t cli_blob_pull_string(struct cli_session *session, if (flags & STR_LEN_NOTERM) { extra = 2; } - return align + extra + cli_blob_pull_ucs2(mem_ctx, blob, &dest->s, + return align + extra + smbcli_blob_pull_ucs2(mem_ctx, blob, &dest->s, blob->data+str_offset+align, dest->private_length, flags); } @@ -843,7 +843,7 @@ size_t cli_blob_pull_string(struct cli_session *session, extra = 1; } - return extra + cli_blob_pull_ascii(mem_ctx, blob, &dest->s, + return extra + smbcli_blob_pull_ascii(mem_ctx, blob, &dest->s, blob->data+str_offset, dest->private_length, flags); } @@ -859,7 +859,7 @@ size_t cli_blob_pull_string(struct cli_session *session, on failure zero is returned and dest->s is set to NULL, otherwise the number of bytes consumed in the blob is returned */ -size_t cli_blob_pull_unix_string(struct cli_session *session, +size_t smbcli_blob_pull_unix_string(struct smbcli_session *session, TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const char **dest, @@ -879,7 +879,7 @@ size_t cli_blob_pull_unix_string(struct cli_session *session, if (flags & STR_LEN_NOTERM) { extra = 2; } - return align + extra + cli_blob_pull_ucs2(mem_ctx, blob, dest, + return align + extra + smbcli_blob_pull_ucs2(mem_ctx, blob, dest, blob->data+str_offset+align, -1, flags); } @@ -888,7 +888,7 @@ size_t cli_blob_pull_unix_string(struct cli_session *session, extra = 1; } - return extra + cli_blob_pull_ascii(mem_ctx, blob, dest, + return extra + smbcli_blob_pull_ascii(mem_ctx, blob, dest, blob->data+str_offset, -1, flags); } @@ -896,7 +896,7 @@ size_t cli_blob_pull_unix_string(struct cli_session *session, /* append a string into a blob */ -size_t cli_blob_append_string(struct cli_session *session, +size_t smbcli_blob_append_string(struct smbcli_session *session, TALLOC_CTX *mem_ctx, DATA_BLOB *blob, const char *str, uint_t flags) { diff --git a/source4/libcli/raw/rawsearch.c b/source4/libcli/raw/rawsearch.c index a4ba8e8696..67410283ed 100644 --- a/source4/libcli/raw/rawsearch.c +++ b/source4/libcli/raw/rawsearch.c @@ -23,7 +23,7 @@ /**************************************************************************** Old style search backend - process output. ****************************************************************************/ -static void smb_raw_search_backend(struct cli_request *req, +static void smb_raw_search_backend(struct smbcli_request *req, TALLOC_CTX *mem_ctx, uint16_t count, void *private, @@ -42,12 +42,12 @@ static void smb_raw_search_backend(struct cli_request *req, p = req->in.data + 3; for (i=0; i < count; i++) { - search_data.search.search_id = cli_req_pull_blob(req, mem_ctx, p, 21); + search_data.search.search_id = smbcli_req_pull_blob(req, mem_ctx, p, 21); search_data.search.attrib = CVAL(p, 21); search_data.search.write_time = raw_pull_dos_date(req->transport, p + 22); search_data.search.size = IVAL(p, 26); - cli_req_pull_ascii(req, mem_ctx, &search_data.search.name, p+30, 13, STR_ASCII); + smbcli_req_pull_ascii(req, mem_ctx, &search_data.search.name, p+30, 13, STR_ASCII); if (!callback(private, &search_data)) { break; } @@ -58,27 +58,27 @@ static void smb_raw_search_backend(struct cli_request *req, /**************************************************************************** Old style search first. ****************************************************************************/ -static NTSTATUS smb_raw_search_first_old(struct cli_tree *tree, +static NTSTATUS smb_raw_search_first_old(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_search_first *io, void *private, BOOL (*callback)(void *private, union smb_search_data *file)) { - struct cli_request *req; + struct smbcli_request *req; - req = cli_request_setup(tree, SMBsearch, 2, 0); + req = smbcli_request_setup(tree, SMBsearch, 2, 0); if (!req) { return NT_STATUS_NO_MEMORY; } SSVAL(req->out.vwv, VWV(0), io->search_first.in.max_count); SSVAL(req->out.vwv, VWV(1), io->search_first.in.search_attrib); - cli_req_append_ascii4(req, io->search_first.in.pattern, STR_TERMINATE); - cli_req_append_var_block(req, NULL, 0); + smbcli_req_append_ascii4(req, io->search_first.in.pattern, STR_TERMINATE); + smbcli_req_append_var_block(req, NULL, 0); - if (!cli_request_send(req) || - !cli_request_receive(req)) { - return cli_request_destroy(req); + if (!smbcli_request_send(req) || + !smbcli_request_receive(req)) { + return smbcli_request_destroy(req); } if (NT_STATUS_IS_OK(req->status)) { @@ -86,33 +86,33 @@ static NTSTATUS smb_raw_search_first_old(struct cli_tree *tree, smb_raw_search_backend(req, mem_ctx, io->search_first.out.count, private, callback); } - return cli_request_destroy(req); + return smbcli_request_destroy(req); } /**************************************************************************** Old style search next. ****************************************************************************/ -static NTSTATUS smb_raw_search_next_old(struct cli_tree *tree, +static NTSTATUS smb_raw_search_next_old(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_search_next *io, void *private, BOOL (*callback)(void *private, union smb_search_data *file)) { - struct cli_request *req; + struct smbcli_request *req; - req = cli_request_setup(tree, SMBsearch, 2, 0); + req = smbcli_request_setup(tree, SMBsearch, 2, 0); if (!req) { return NT_STATUS_NO_MEMORY; } SSVAL(req->out.vwv, VWV(0), io->search_next.in.max_count); SSVAL(req->out.vwv, VWV(1), io->search_next.in.search_attrib); - cli_req_append_ascii4(req, "", STR_TERMINATE); - cli_req_append_var_block(req, io->search_next.in.search_id.data, 21); + smbcli_req_append_ascii4(req, "", STR_TERMINATE); + smbcli_req_append_var_block(req, io->search_next.in.search_id.data, 21); - if (!cli_request_send(req) || - !cli_request_receive(req)) { - return cli_request_destroy(req); + if (!smbcli_request_send(req) || + !smbcli_request_receive(req)) { + return smbcli_request_destroy(req); } if (NT_STATUS_IS_OK(req->status)) { @@ -120,13 +120,13 @@ static NTSTATUS smb_raw_search_next_old(struct cli_tree *tree, smb_raw_search_backend(req, mem_ctx, io->search_next.out.count, private, callback); } - return cli_request_destroy(req); + return smbcli_request_destroy(req); } /**************************************************************************** Very raw search first - returns param/data blobs. ****************************************************************************/ -static NTSTATUS smb_raw_search_first_blob(struct cli_tree *tree, +static NTSTATUS smb_raw_search_first_blob(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, /* used to allocate output blobs */ union smb_search_first *io, uint16_t info_level, @@ -157,7 +157,7 @@ static NTSTATUS smb_raw_search_first_blob(struct cli_tree *tree, SSVAL(tp.in.params.data, 6, info_level); SIVAL(tp.in.params.data, 8, io->t2ffirst.in.storage_type); - cli_blob_append_string(tree->session, mem_ctx, &tp.in.params, + smbcli_blob_append_string(tree->session, mem_ctx, &tp.in.params, io->t2ffirst.in.pattern, STR_TERMINATE); status = smb_raw_trans2(tree, mem_ctx, &tp); @@ -178,7 +178,7 @@ static NTSTATUS smb_raw_search_first_blob(struct cli_tree *tree, Very raw search first - returns param/data blobs. Used in CIFS-on-CIFS NTVFS. ****************************************************************************/ -static NTSTATUS smb_raw_search_next_blob(struct cli_tree *tree, +static NTSTATUS smb_raw_search_next_blob(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_search_next *io, uint16_t info_level, @@ -209,7 +209,7 @@ static NTSTATUS smb_raw_search_next_blob(struct cli_tree *tree, SIVAL(tp.in.params.data, 6, io->t2fnext.in.resume_key); SSVAL(tp.in.params.data, 10, io->t2fnext.in.flags); - cli_blob_append_string(tree->session, mem_ctx, &tp.in.params, + smbcli_blob_append_string(tree->session, mem_ctx, &tp.in.params, io->t2fnext.in.last_name, STR_TERMINATE); @@ -233,7 +233,7 @@ static NTSTATUS smb_raw_search_next_blob(struct cli_tree *tree, return 0 for success with end of list return -1 for a parse error */ -static int parse_trans2_search(struct cli_tree *tree, +static int parse_trans2_search(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, enum smb_search_level level, uint16_t flags, @@ -265,7 +265,7 @@ static int parse_trans2_search(struct cli_tree *tree, data->standard.size = IVAL(blob->data, 12); data->standard.alloc_size = IVAL(blob->data, 16); data->standard.attrib = SVAL(blob->data, 20); - len = cli_blob_pull_string(tree->session, mem_ctx, blob, + len = smbcli_blob_pull_string(tree->session, mem_ctx, blob, &data->standard.name, 22, 23, STR_LEN8BIT | STR_TERMINATE | STR_LEN_NOTERM); return len + 23; @@ -288,7 +288,7 @@ static int parse_trans2_search(struct cli_tree *tree, data->ea_size.alloc_size = IVAL(blob->data, 16); data->ea_size.attrib = SVAL(blob->data, 20); data->ea_size.ea_size = IVAL(blob->data, 22); - len = cli_blob_pull_string(tree->session, mem_ctx, blob, + len = smbcli_blob_pull_string(tree->session, mem_ctx, blob, &data->ea_size.name, 26, 27, STR_LEN8BIT | STR_TERMINATE | STR_NOALIGN); return len + 27 + 1; @@ -297,14 +297,14 @@ static int parse_trans2_search(struct cli_tree *tree, if (blob->length < 65) return -1; ofs = IVAL(blob->data, 0); data->directory_info.file_index = IVAL(blob->data, 4); - data->directory_info.create_time = cli_pull_nttime(blob->data, 8); - data->directory_info.access_time = cli_pull_nttime(blob->data, 16); - data->directory_info.write_time = cli_pull_nttime(blob->data, 24); - data->directory_info.change_time = cli_pull_nttime(blob->data, 32); + data->directory_info.create_time = smbcli_pull_nttime(blob->data, 8); + data->directory_info.access_time = smbcli_pull_nttime(blob->data, 16); + data->directory_info.write_time = smbcli_pull_nttime(blob->data, 24); + data->directory_info.change_time = smbcli_pull_nttime(blob->data, 32); data->directory_info.size = BVAL(blob->data, 40); data->directory_info.alloc_size = BVAL(blob->data, 48); data->directory_info.attrib = IVAL(blob->data, 56); - len = cli_blob_pull_string(tree->session, mem_ctx, blob, + len = smbcli_blob_pull_string(tree->session, mem_ctx, blob, &data->directory_info.name, 60, 64, 0); if (ofs != 0 && ofs < 64+len) { @@ -316,15 +316,15 @@ static int parse_trans2_search(struct cli_tree *tree, if (blob->length < 69) return -1; ofs = IVAL(blob->data, 0); data->full_directory_info.file_index = IVAL(blob->data, 4); - data->full_directory_info.create_time = cli_pull_nttime(blob->data, 8); - data->full_directory_info.access_time = cli_pull_nttime(blob->data, 16); - data->full_directory_info.write_time = cli_pull_nttime(blob->data, 24); - data->full_directory_info.change_time = cli_pull_nttime(blob->data, 32); + data->full_directory_info.create_time = smbcli_pull_nttime(blob->data, 8); + data->full_directory_info.access_time = smbcli_pull_nttime(blob->data, 16); + data->full_directory_info.write_time = smbcli_pull_nttime(blob->data, 24); + data->full_directory_info.change_time = smbcli_pull_nttime(blob->data, 32); data->full_directory_info.size = BVAL(blob->data, 40); data->full_directory_info.alloc_size = BVAL(blob->data, 48); data->full_directory_info.attrib = IVAL(blob->data, 56); data->full_directory_info.ea_size = IVAL(blob->data, 64); - len = cli_blob_pull_string(tree->session, mem_ctx, blob, + len = smbcli_blob_pull_string(tree->session, mem_ctx, blob, &data->full_directory_info.name, 60, 68, 0); if (ofs != 0 && ofs < 68+len) { @@ -336,7 +336,7 @@ static int parse_trans2_search(struct cli_tree *tree, if (blob->length < 13) return -1; ofs = IVAL(blob->data, 0); data->name_info.file_index = IVAL(blob->data, 4); - len = cli_blob_pull_string(tree->session, mem_ctx, blob, + len = smbcli_blob_pull_string(tree->session, mem_ctx, blob, &data->name_info.name, 8, 12, 0); if (ofs != 0 && ofs < 12+len) { @@ -349,18 +349,18 @@ static int parse_trans2_search(struct cli_tree *tree, if (blob->length < 95) return -1; ofs = IVAL(blob->data, 0); data->both_directory_info.file_index = IVAL(blob->data, 4); - data->both_directory_info.create_time = cli_pull_nttime(blob->data, 8); - data->both_directory_info.access_time = cli_pull_nttime(blob->data, 16); - data->both_directory_info.write_time = cli_pull_nttime(blob->data, 24); - data->both_directory_info.change_time = cli_pull_nttime(blob->data, 32); + data->both_directory_info.create_time = smbcli_pull_nttime(blob->data, 8); + data->both_directory_info.access_time = smbcli_pull_nttime(blob->data, 16); + data->both_directory_info.write_time = smbcli_pull_nttime(blob->data, 24); + data->both_directory_info.change_time = smbcli_pull_nttime(blob->data, 32); data->both_directory_info.size = BVAL(blob->data, 40); data->both_directory_info.alloc_size = BVAL(blob->data, 48); data->both_directory_info.attrib = IVAL(blob->data, 56); data->both_directory_info.ea_size = IVAL(blob->data, 64); - cli_blob_pull_string(tree->session, mem_ctx, blob, + smbcli_blob_pull_string(tree->session, mem_ctx, blob, &data->both_directory_info.short_name, 68, 70, STR_LEN8BIT | STR_UNICODE); - len = cli_blob_pull_string(tree->session, mem_ctx, blob, + len = smbcli_blob_pull_string(tree->session, mem_ctx, blob, &data->both_directory_info.name, 60, 94, 0); if (ofs != 0 && ofs < 94+len) { @@ -373,16 +373,16 @@ static int parse_trans2_search(struct cli_tree *tree, if (blob->length < 81) return -1; ofs = IVAL(blob->data, 0); data->id_full_directory_info.file_index = IVAL(blob->data, 4); - data->id_full_directory_info.create_time = cli_pull_nttime(blob->data, 8); - data->id_full_directory_info.access_time = cli_pull_nttime(blob->data, 16); - data->id_full_directory_info.write_time = cli_pull_nttime(blob->data, 24); - data->id_full_directory_info.change_time = cli_pull_nttime(blob->data, 32); + data->id_full_directory_info.create_time = smbcli_pull_nttime(blob->data, 8); + data->id_full_directory_info.access_time = smbcli_pull_nttime(blob->data, 16); + data->id_full_directory_info.write_time = smbcli_pull_nttime(blob->data, 24); + data->id_full_directory_info.change_time = smbcli_pull_nttime(blob->data, 32); data->id_full_directory_info.size = BVAL(blob->data, 40); data->id_full_directory_info.alloc_size = BVAL(blob->data, 48); data->id_full_directory_info.attrib = IVAL(blob->data, 56); data->id_full_directory_info.ea_size = IVAL(blob->data, 64); data->id_full_directory_info.file_id = BVAL(blob->data, 72); - len = cli_blob_pull_string(tree->session, mem_ctx, blob, + len = smbcli_blob_pull_string(tree->session, mem_ctx, blob, &data->id_full_directory_info.name, 60, 80, 0); if (ofs != 0 && ofs < 80+len) { @@ -394,19 +394,19 @@ static int parse_trans2_search(struct cli_tree *tree, if (blob->length < 105) return -1; ofs = IVAL(blob->data, 0); data->id_both_directory_info.file_index = IVAL(blob->data, 4); - data->id_both_directory_info.create_time = cli_pull_nttime(blob->data, 8); - data->id_both_directory_info.access_time = cli_pull_nttime(blob->data, 16); - data->id_both_directory_info.write_time = cli_pull_nttime(blob->data, 24); - data->id_both_directory_info.change_time = cli_pull_nttime(blob->data, 32); + data->id_both_directory_info.create_time = smbcli_pull_nttime(blob->data, 8); + data->id_both_directory_info.access_time = smbcli_pull_nttime(blob->data, 16); + data->id_both_directory_info.write_time = smbcli_pull_nttime(blob->data, 24); + data->id_both_directory_info.change_time = smbcli_pull_nttime(blob->data, 32); data->id_both_directory_info.size = BVAL(blob->data, 40); data->id_both_directory_info.alloc_size = BVAL(blob->data, 48); data->id_both_directory_info.attrib = SVAL(blob->data, 56); data->id_both_directory_info.ea_size = IVAL(blob->data, 64); - cli_blob_pull_string(tree->session, mem_ctx, blob, + smbcli_blob_pull_string(tree->session, mem_ctx, blob, &data->id_both_directory_info.short_name, 68, 70, STR_LEN8BIT | STR_UNICODE); data->id_both_directory_info.file_id = BVAL(blob->data, 96); - len = cli_blob_pull_string(tree->session, mem_ctx, blob, + len = smbcli_blob_pull_string(tree->session, mem_ctx, blob, &data->id_both_directory_info.name, 60, 104, 0); if (ofs != 0 && ofs < 104+len) { @@ -420,9 +420,9 @@ static int parse_trans2_search(struct cli_tree *tree, data->unix_info.file_index = IVAL(blob->data, 4); data->unix_info.size = BVAL(blob->data, 8); data->unix_info.alloc_size = BVAL(blob->data, 16); - data->unix_info.status_change_time = cli_pull_nttime(blob->data, 24); - data->unix_info.access_time = cli_pull_nttime(blob->data, 32); - data->unix_info.change_time = cli_pull_nttime(blob->data, 40); + data->unix_info.status_change_time = smbcli_pull_nttime(blob->data, 24); + data->unix_info.access_time = smbcli_pull_nttime(blob->data, 32); + data->unix_info.change_time = smbcli_pull_nttime(blob->data, 40); data->unix_info.uid = IVAL(blob->data, 48); data->unix_info.gid = IVAL(blob->data, 56); data->unix_info.file_type = IVAL(blob->data, 64); @@ -432,7 +432,7 @@ static int parse_trans2_search(struct cli_tree *tree, data->unix_info.permissions = IVAL(blob->data, 92); data->unix_info.nlink = IVAL(blob->data, 100); /* There is no length field for this name but we know it's null terminated. */ - len = cli_blob_pull_unix_string(tree->session, mem_ctx, blob, + len = smbcli_blob_pull_unix_string(tree->session, mem_ctx, blob, &data->unix_info.name, 108, 0); if (ofs != 0 && ofs < 108+len) { return -1; @@ -447,7 +447,7 @@ static int parse_trans2_search(struct cli_tree *tree, /**************************************************************************** Trans2 search backend - process output. ****************************************************************************/ -static NTSTATUS smb_raw_t2search_backend(struct cli_tree *tree, +static NTSTATUS smb_raw_t2search_backend(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, enum smb_search_level level, uint16_t flags, @@ -490,7 +490,7 @@ static NTSTATUS smb_raw_t2search_backend(struct cli_tree *tree, /* Implements trans2findfirst2 and old search */ -NTSTATUS smb_raw_search_first(struct cli_tree *tree, +NTSTATUS smb_raw_search_first(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_search_first *io, void *private, BOOL (*callback)(void *private, union smb_search_data *file)) @@ -534,7 +534,7 @@ NTSTATUS smb_raw_search_first(struct cli_tree *tree, /* Implements trans2findnext2 and old smbsearch */ -NTSTATUS smb_raw_search_next(struct cli_tree *tree, +NTSTATUS smb_raw_search_next(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_search_next *io, void *private, BOOL (*callback)(void *private, union smb_search_data *file)) @@ -578,21 +578,21 @@ NTSTATUS smb_raw_search_next(struct cli_tree *tree, /* Implements trans2findclose2 */ -NTSTATUS smb_raw_search_close(struct cli_tree *tree, +NTSTATUS smb_raw_search_close(struct smbcli_tree *tree, union smb_search_close *io) { - struct cli_request *req; + struct smbcli_request *req; - req = cli_request_setup(tree, SMBfindclose, 1, 0); + req = smbcli_request_setup(tree, SMBfindclose, 1, 0); if (!req) { return NT_STATUS_NO_MEMORY; } SSVAL(req->out.vwv, VWV(0), io->findclose.in.handle); - if (cli_request_send(req)) { - cli_request_receive(req); + if (smbcli_request_send(req)) { + smbcli_request_receive(req); } - return cli_request_destroy(req); + return smbcli_request_destroy(req); } diff --git a/source4/libcli/raw/rawsetfileinfo.c b/source4/libcli/raw/rawsetfileinfo.c index 3dcda401f5..b1667db50f 100644 --- a/source4/libcli/raw/rawsetfileinfo.c +++ b/source4/libcli/raw/rawsetfileinfo.c @@ -24,7 +24,7 @@ /**************************************************************************** Handle setfileinfo/setpathinfo trans2 backend. ****************************************************************************/ -static BOOL smb_raw_setinfo_backend(struct cli_tree *tree, +static BOOL smb_raw_setinfo_backend(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, union smb_setfileinfo *parms, DATA_BLOB *blob) @@ -61,10 +61,10 @@ static BOOL smb_raw_setinfo_backend(struct cli_tree *tree, case RAW_SFILEINFO_BASIC_INFO: case RAW_SFILEINFO_BASIC_INFORMATION: NEED_BLOB(40); - cli_push_nttime(blob->data, 0, parms->basic_info.in.create_time); - cli_push_nttime(blob->data, 8, parms->basic_info.in.access_time); - cli_push_nttime(blob->data, 16, parms->basic_info.in.write_time); - cli_push_nttime(blob->data, 24, parms->basic_info.in.change_time); + smbcli_push_nttime(blob->data, 0, parms->basic_info.in.create_time); + smbcli_push_nttime(blob->data, 8, parms->basic_info.in.access_time); + smbcli_push_nttime(blob->data, 16, parms->basic_info.in.write_time); + smbcli_push_nttime(blob->data, 24, parms->basic_info.in.change_time); SIVAL(blob->data, 32, parms->basic_info.in.attrib); SIVAL(blob->data, 36, 0); /* padding */ return True; @@ -73,9 +73,9 @@ static BOOL smb_raw_setinfo_backend(struct cli_tree *tree, NEED_BLOB(92); SBVAL(blob->data, 0, parms->unix_basic.in.end_of_file); SBVAL(blob->data, 8, parms->unix_basic.in.num_bytes); - cli_push_nttime(blob->data, 16, parms->unix_basic.in.status_change_time); - cli_push_nttime(blob->data, 24, parms->unix_basic.in.access_time); - cli_push_nttime(blob->data, 32, parms->unix_basic.in.change_time); + smbcli_push_nttime(blob->data, 16, parms->unix_basic.in.status_change_time); + smbcli_push_nttime(blob->data, 24, parms->unix_basic.in.access_time); + smbcli_push_nttime(blob->data, 32, parms->unix_basic.in.change_time); SBVAL(blob->data, 40, parms->unix_basic.in.uid); SBVAL(blob->data, 48, parms->unix_basic.in.gid); SIVAL(blob->data, 56, parms->unix_basic.in.file_type); @@ -107,7 +107,7 @@ static BOOL smb_raw_setinfo_backend(struct cli_tree *tree, NEED_BLOB(12); SIVAL(blob->data, 0, parms->rename_information.in.overwrite); SIVAL(blob->data, 4, parms->rename_information.in.root_fid); - len = cli_blob_append_string(tree->session, mem_ctx, blob, + len = smbcli_blob_append_string(tree->session, mem_ctx, blob, parms->rename_information.in.new_name, STR_UNICODE|STR_TERMINATE); SIVAL(blob->data, 8, len - 2); @@ -130,7 +130,7 @@ static BOOL smb_raw_setinfo_backend(struct cli_tree *tree, /**************************************************************************** Very raw set file info - takes data blob (async send) ****************************************************************************/ -static struct cli_request *smb_raw_setfileinfo_blob_send(struct cli_tree *tree, +static struct smbcli_request *smb_raw_setfileinfo_blob_send(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, uint16_t fnum, uint16_t info_level, @@ -163,7 +163,7 @@ static struct cli_request *smb_raw_setfileinfo_blob_send(struct cli_tree *tree, /**************************************************************************** Very raw set path info - takes data blob ****************************************************************************/ -static struct cli_request *smb_raw_setpathinfo_blob_send(struct cli_tree *tree, +static struct smbcli_request *smb_raw_setpathinfo_blob_send(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, const char *fname, uint16_t info_level, @@ -186,7 +186,7 @@ static struct cli_request *smb_raw_setpathinfo_blob_send(struct cli_tree *tree, } SSVAL(tp.in.params.data, 0, info_level); SSVAL(tp.in.params.data, 2, 0); - cli_blob_append_string(tree->session, mem_ctx, + smbcli_blob_append_string(tree->session, mem_ctx, &tp.in.params, fname, STR_TERMINATE); @@ -198,23 +198,23 @@ static struct cli_request *smb_raw_setpathinfo_blob_send(struct cli_tree *tree, /**************************************************************************** Handle setattr (async send) ****************************************************************************/ -static struct cli_request *smb_raw_setattr_send(struct cli_tree *tree, +static struct smbcli_request *smb_raw_setattr_send(struct smbcli_tree *tree, union smb_setfileinfo *parms) { - struct cli_request *req; + struct smbcli_request *req; - req = cli_request_setup(tree, SMBsetatr, 8, 0); + req = smbcli_request_setup(tree, SMBsetatr, 8, 0); if (!req) return NULL; SSVAL(req->out.vwv, VWV(0), parms->setattr.in.attrib); raw_push_dos_date3(tree->session->transport, req->out.vwv, VWV(1), parms->setattr.in.write_time); memset(req->out.vwv + VWV(3), 0, 10); /* reserved */ - cli_req_append_ascii4(req, parms->setattr.file.fname, STR_TERMINATE); - cli_req_append_ascii4(req, "", STR_TERMINATE); + smbcli_req_append_ascii4(req, parms->setattr.file.fname, STR_TERMINATE); + smbcli_req_append_ascii4(req, "", STR_TERMINATE); - if (!cli_request_send(req)) { - cli_request_destroy(req); + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); return NULL; } @@ -224,12 +224,12 @@ static struct cli_request *smb_raw_setattr_send(struct cli_tree *tree, /**************************************************************************** Handle setattrE. (async send) ****************************************************************************/ -static struct cli_request *smb_raw_setattrE_send(struct cli_tree *tree, +static struct smbcli_request *smb_raw_setattrE_send(struct smbcli_tree *tree, union smb_setfileinfo *parms) { - struct cli_request *req; + struct smbcli_request *req; - req = cli_request_setup(tree, SMBsetattrE, 7, 0); + req = smbcli_request_setup(tree, SMBsetattrE, 7, 0); if (!req) return NULL; SSVAL(req->out.vwv, VWV(0), parms->setattre.file.fnum); @@ -240,8 +240,8 @@ static struct cli_request *smb_raw_setattrE_send(struct cli_tree *tree, raw_push_dos_date2(tree->session->transport, req->out.vwv, VWV(5), parms->setattre.in.write_time); - if (!cli_request_send(req)) { - cli_request_destroy(req); + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); return NULL; } @@ -251,12 +251,12 @@ static struct cli_request *smb_raw_setattrE_send(struct cli_tree *tree, /**************************************************************************** Set file info (async send) ****************************************************************************/ -struct cli_request *smb_raw_setfileinfo_send(struct cli_tree *tree, +struct smbcli_request *smb_raw_setfileinfo_send(struct smbcli_tree *tree, union smb_setfileinfo *parms) { DATA_BLOB blob; TALLOC_CTX *mem_ctx; - struct cli_request *req; + struct smbcli_request *req; if (parms->generic.level == RAW_SFILEINFO_SETATTRE) { return smb_raw_setattrE_send(tree, parms); @@ -287,23 +287,23 @@ struct cli_request *smb_raw_setfileinfo_send(struct cli_tree *tree, /**************************************************************************** Set file info (async send) ****************************************************************************/ -NTSTATUS smb_raw_setfileinfo(struct cli_tree *tree, +NTSTATUS smb_raw_setfileinfo(struct smbcli_tree *tree, union smb_setfileinfo *parms) { - struct cli_request *req = smb_raw_setfileinfo_send(tree, parms); - return cli_request_simple_recv(req); + struct smbcli_request *req = smb_raw_setfileinfo_send(tree, parms); + return smbcli_request_simple_recv(req); } /**************************************************************************** Set path info (async send) ****************************************************************************/ -struct cli_request *smb_raw_setpathinfo_send(struct cli_tree *tree, +struct smbcli_request *smb_raw_setpathinfo_send(struct smbcli_tree *tree, union smb_setfileinfo *parms) { DATA_BLOB blob; TALLOC_CTX *mem_ctx; - struct cli_request *req; + struct smbcli_request *req; if (parms->generic.level == RAW_SFILEINFO_SETATTR) { return smb_raw_setattr_send(tree, parms); @@ -334,9 +334,9 @@ struct cli_request *smb_raw_setpathinfo_send(struct cli_tree *tree, /**************************************************************************** Set path info (sync interface) ****************************************************************************/ -NTSTATUS smb_raw_setpathinfo(struct cli_tree *tree, +NTSTATUS smb_raw_setpathinfo(struct smbcli_tree *tree, union smb_setfileinfo *parms) { - struct cli_request *req = smb_raw_setpathinfo_send(tree, parms); - return cli_request_simple_recv(req); + struct smbcli_request *req = smb_raw_setpathinfo_send(tree, parms); + return smbcli_request_simple_recv(req); } diff --git a/source4/libcli/raw/rawtrans.c b/source4/libcli/raw/rawtrans.c index 5dde753368..0c39abe880 100644 --- a/source4/libcli/raw/rawtrans.c +++ b/source4/libcli/raw/rawtrans.c @@ -25,7 +25,7 @@ /* check out of bounds for incoming data */ -static BOOL raw_trans_oob(struct cli_request *req, +static BOOL raw_trans_oob(struct smbcli_request *req, uint_t offset, uint_t count) { char *ptr; @@ -49,7 +49,7 @@ static BOOL raw_trans_oob(struct cli_request *req, /**************************************************************************** receive a SMB trans or trans2 response allocating the necessary memory ****************************************************************************/ -NTSTATUS smb_raw_trans2_recv(struct cli_request *req, +NTSTATUS smb_raw_trans2_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, struct smb_trans2 *parms) { @@ -63,8 +63,8 @@ NTSTATUS smb_raw_trans2_recv(struct cli_request *req, parms->out.params.length = 0; parms->out.params.data = NULL; - if (!cli_request_receive(req)) { - return cli_request_destroy(req); + if (!smbcli_request_receive(req)) { + return smbcli_request_destroy(req); } /* @@ -73,10 +73,10 @@ NTSTATUS smb_raw_trans2_recv(struct cli_request *req, * be treated as such. */ if (NT_STATUS_IS_ERR(req->status)) { - return cli_request_destroy(req); + return smbcli_request_destroy(req); } - CLI_CHECK_MIN_WCT(req, 10); + SMBCLI_CHECK_MIN_WCT(req, 10); /* parse out the lengths */ total_data = SVAL(req->in.vwv, VWV(1)); @@ -88,7 +88,7 @@ NTSTATUS smb_raw_trans2_recv(struct cli_request *req, if (!tdata) { DEBUG(0,("smb_raw_receive_trans: failed to enlarge data buffer to %d bytes\n", total_data)); req->status = NT_STATUS_NO_MEMORY; - return cli_request_destroy(req); + return smbcli_request_destroy(req); } parms->out.data.data = tdata; } @@ -98,20 +98,20 @@ NTSTATUS smb_raw_trans2_recv(struct cli_request *req, if (!tparam) { DEBUG(0,("smb_raw_receive_trans: failed to enlarge param buffer to %d bytes\n", total_param)); req->status = NT_STATUS_NO_MEMORY; - return cli_request_destroy(req); + return smbcli_request_destroy(req); } parms->out.params.data = tparam; } parms->out.setup_count = SVAL(req->in.vwv, VWV(9)); - CLI_CHECK_WCT(req, 10 + parms->out.setup_count); + SMBCLI_CHECK_WCT(req, 10 + parms->out.setup_count); if (parms->out.setup_count > 0) { int i; parms->out.setup = talloc(mem_ctx, 2 * parms->out.setup_count); if (!parms->out.setup) { req->status = NT_STATUS_NO_MEMORY; - return cli_request_destroy(req); + return smbcli_request_destroy(req); } for (i=0;i<parms->out.setup_count;i++) { parms->out.setup[i] = SVAL(req->in.vwv, VWV(10+i)); @@ -132,7 +132,7 @@ NTSTATUS smb_raw_trans2_recv(struct cli_request *req, /* they must *only* shrink */ DEBUG(1,("smb_raw_receive_trans: data/params expanded!\n")); req->status = NT_STATUS_BUFFER_TOO_SMALL; - return cli_request_destroy(req); + return smbcli_request_destroy(req); } total_data = total_data2; @@ -151,7 +151,7 @@ NTSTATUS smb_raw_trans2_recv(struct cli_request *req, param_count + param_disp > total_param) { DEBUG(1,("smb_raw_receive_trans: Buffer overflow\n")); req->status = NT_STATUS_BUFFER_TOO_SMALL; - return cli_request_destroy(req); + return smbcli_request_destroy(req); } /* check the server isn't being nasty */ @@ -159,7 +159,7 @@ NTSTATUS smb_raw_trans2_recv(struct cli_request *req, raw_trans_oob(req, data_ofs, data_count)) { DEBUG(1,("smb_raw_receive_trans: out of bounds parameters!\n")); req->status = NT_STATUS_BUFFER_TOO_SMALL; - return cli_request_destroy(req); + return smbcli_request_destroy(req); } if (data_count) { @@ -180,17 +180,17 @@ NTSTATUS smb_raw_trans2_recv(struct cli_request *req, if (total_data <= parms->out.data.length && total_param <= parms->out.params.length) break; - if (!cli_request_receive_more(req)) { + if (!smbcli_request_receive_more(req)) { req->status = NT_STATUS_UNSUCCESSFUL; - return cli_request_destroy(req); + return smbcli_request_destroy(req); } } failed: - return cli_request_destroy(req); + return smbcli_request_destroy(req); } -NTSTATUS smb_raw_trans_recv(struct cli_request *req, +NTSTATUS smb_raw_trans_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, struct smb_trans2 *parms) { @@ -201,12 +201,12 @@ NTSTATUS smb_raw_trans_recv(struct cli_request *req, trans/trans2 raw async interface - only BLOBs used in this interface. note that this doesn't yet support multi-part requests ****************************************************************************/ -struct cli_request *smb_raw_trans_send_backend(struct cli_tree *tree, +struct smbcli_request *smb_raw_trans_send_backend(struct smbcli_tree *tree, struct smb_trans2 *parms, uint8_t command) { int wct = 14 + parms->in.setup_count; - struct cli_request *req; + struct smbcli_request *req; char *outdata,*outparam; int i; int padding; @@ -217,7 +217,7 @@ struct cli_request *smb_raw_trans_send_backend(struct cli_tree *tree, else padding = 3; - req = cli_request_setup(tree, command, wct, padding); + req = smbcli_request_setup(tree, command, wct, padding); if (!req) { return NULL; } @@ -230,7 +230,7 @@ struct cli_request *smb_raw_trans_send_backend(struct cli_tree *tree, memset(req->out.data, 0, padding); if (command == SMBtrans && parms->in.trans_name) { - namelen = cli_req_append_string(req, parms->in.trans_name, + namelen = smbcli_req_append_string(req, parms->in.trans_name, STR_TERMINATE); } @@ -252,14 +252,14 @@ struct cli_request *smb_raw_trans_send_backend(struct cli_tree *tree, SSVAL(req->out.vwv,VWV(14)+i*2,parms->in.setup[i]); } if (parms->in.params.data) { - cli_req_append_blob(req, &parms->in.params); + smbcli_req_append_blob(req, &parms->in.params); } if (parms->in.data.data) { - cli_req_append_blob(req, &parms->in.data); + smbcli_req_append_blob(req, &parms->in.data); } - if (!cli_request_send(req)) { - cli_request_destroy(req); + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); return NULL; } @@ -271,13 +271,13 @@ struct cli_request *smb_raw_trans_send_backend(struct cli_tree *tree, note that this doesn't yet support multi-part requests ****************************************************************************/ -struct cli_request *smb_raw_trans_send(struct cli_tree *tree, +struct smbcli_request *smb_raw_trans_send(struct smbcli_tree *tree, struct smb_trans2 *parms) { return smb_raw_trans_send_backend(tree, parms, SMBtrans); } -struct cli_request *smb_raw_trans2_send(struct cli_tree *tree, +struct smbcli_request *smb_raw_trans2_send(struct smbcli_tree *tree, struct smb_trans2 *parms) { return smb_raw_trans_send_backend(tree, parms, SMBtrans2); @@ -286,11 +286,11 @@ struct cli_request *smb_raw_trans2_send(struct cli_tree *tree, /* trans2 synchronous blob interface */ -NTSTATUS smb_raw_trans2(struct cli_tree *tree, +NTSTATUS smb_raw_trans2(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, struct smb_trans2 *parms) { - struct cli_request *req; + struct smbcli_request *req; req = smb_raw_trans2_send(tree, parms); if (!req) return NT_STATUS_UNSUCCESSFUL; return smb_raw_trans2_recv(req, mem_ctx, parms); @@ -300,11 +300,11 @@ NTSTATUS smb_raw_trans2(struct cli_tree *tree, /* trans synchronous blob interface */ -NTSTATUS smb_raw_trans(struct cli_tree *tree, +NTSTATUS smb_raw_trans(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, struct smb_trans2 *parms) { - struct cli_request *req; + struct smbcli_request *req; req = smb_raw_trans_send(tree, parms); if (!req) return NT_STATUS_UNSUCCESSFUL; return smb_raw_trans_recv(req, mem_ctx, parms); @@ -313,16 +313,16 @@ NTSTATUS smb_raw_trans(struct cli_tree *tree, /**************************************************************************** receive a SMB nttrans response allocating the necessary memory ****************************************************************************/ -NTSTATUS smb_raw_nttrans_recv(struct cli_request *req, +NTSTATUS smb_raw_nttrans_recv(struct smbcli_request *req, TALLOC_CTX *mem_ctx, struct smb_nttrans *parms) { uint32_t total_data, recvd_data=0; uint32_t total_param, recvd_param=0; - if (!cli_request_receive(req) || - cli_request_is_error(req)) { - return cli_request_destroy(req); + if (!smbcli_request_receive(req) || + smbcli_request_is_error(req)) { + return smbcli_request_destroy(req); } /* sanity check */ @@ -331,10 +331,10 @@ NTSTATUS smb_raw_nttrans_recv(struct cli_request *req, "SMBnttrans", CVAL(req->in.hdr,HDR_COM))); req->status = NT_STATUS_UNSUCCESSFUL; - return cli_request_destroy(req); + return smbcli_request_destroy(req); } - CLI_CHECK_MIN_WCT(req, 18); + SMBCLI_CHECK_MIN_WCT(req, 18); /* parse out the lengths */ total_param = IVAL(req->in.vwv, 3); @@ -346,18 +346,18 @@ NTSTATUS smb_raw_nttrans_recv(struct cli_request *req, if (parms->out.data.length != total_data || parms->out.params.length != total_param) { req->status = NT_STATUS_NO_MEMORY; - return cli_request_destroy(req); + return smbcli_request_destroy(req); } parms->out.setup_count = CVAL(req->in.vwv, 35); - CLI_CHECK_WCT(req, 18 + parms->out.setup_count); + SMBCLI_CHECK_WCT(req, 18 + parms->out.setup_count); if (parms->out.setup_count > 0) { int i; parms->out.setup = talloc(mem_ctx, 2 * parms->out.setup_count); if (!parms->out.setup) { req->status = NT_STATUS_NO_MEMORY; - return cli_request_destroy(req); + return smbcli_request_destroy(req); } for (i=0;i<parms->out.setup_count;i++) { parms->out.setup[i] = SVAL(req->in.vwv, VWV(18+i)); @@ -379,7 +379,7 @@ NTSTATUS smb_raw_nttrans_recv(struct cli_request *req, /* they must *only* shrink */ DEBUG(1,("smb_raw_receive_nttrans: data/params expanded!\n")); req->status = NT_STATUS_BUFFER_TOO_SMALL; - return cli_request_destroy(req); + return smbcli_request_destroy(req); } total_data = total_data2; @@ -400,7 +400,7 @@ NTSTATUS smb_raw_nttrans_recv(struct cli_request *req, param_count + param_disp > total_param) { DEBUG(1,("smb_raw_receive_nttrans: Buffer overflow\n")); req->status = NT_STATUS_BUFFER_TOO_SMALL; - return cli_request_destroy(req); + return smbcli_request_destroy(req); } /* check the server isn't being nasty */ @@ -408,7 +408,7 @@ NTSTATUS smb_raw_nttrans_recv(struct cli_request *req, raw_trans_oob(req, data_ofs, data_count)) { DEBUG(1,("smb_raw_receive_nttrans: out of bounds parameters!\n")); req->status = NT_STATUS_BUFFER_TOO_SMALL; - return cli_request_destroy(req); + return smbcli_request_destroy(req); } if (data_count) { @@ -431,9 +431,9 @@ NTSTATUS smb_raw_nttrans_recv(struct cli_request *req, break; } - if (!cli_request_receive(req) || - cli_request_is_error(req)) { - return cli_request_destroy(req); + if (!smbcli_request_receive(req) || + smbcli_request_is_error(req)) { + return smbcli_request_destroy(req); } /* sanity check */ @@ -441,12 +441,12 @@ NTSTATUS smb_raw_nttrans_recv(struct cli_request *req, DEBUG(0,("smb_raw_receive_nttrans: Expected nttranss, got command 0x%02x\n", CVAL(req->in.hdr, HDR_COM))); req->status = NT_STATUS_UNSUCCESSFUL; - return cli_request_destroy(req); + return smbcli_request_destroy(req); } } failed: - return cli_request_destroy(req); + return smbcli_request_destroy(req); } @@ -454,10 +454,10 @@ failed: nttrans raw - only BLOBs used in this interface. at the moment we only handle a single primary request ****************************************************************************/ -struct cli_request *smb_raw_nttrans_send(struct cli_tree *tree, +struct smbcli_request *smb_raw_nttrans_send(struct smbcli_tree *tree, struct smb_nttrans *parms) { - struct cli_request *req; + struct smbcli_request *req; char *outdata, *outparam; int i; int align = 0; @@ -467,7 +467,7 @@ struct cli_request *smb_raw_nttrans_send(struct cli_tree *tree, align = 3; } - req = cli_request_setup(tree, SMBnttrans, + req = smbcli_request_setup(tree, SMBnttrans, 19 + parms->in.setup_count, align + parms->in.params.length + @@ -502,8 +502,8 @@ struct cli_request *smb_raw_nttrans_send(struct cli_tree *tree, memcpy(outparam, parms->in.data.data, parms->in.data.length); } - if (!cli_request_send(req)) { - cli_request_destroy(req); + if (!smbcli_request_send(req)) { + smbcli_request_destroy(req); return NULL; } @@ -514,11 +514,11 @@ struct cli_request *smb_raw_nttrans_send(struct cli_tree *tree, /**************************************************************************** receive a SMB nttrans response allocating the necessary memory ****************************************************************************/ -NTSTATUS smb_raw_nttrans(struct cli_tree *tree, +NTSTATUS smb_raw_nttrans(struct smbcli_tree *tree, TALLOC_CTX *mem_ctx, struct smb_nttrans *parms) { - struct cli_request *req; + struct smbcli_request *req; req = smb_raw_nttrans_send(tree, parms); if (!req) { diff --git a/source4/libcli/raw/smb_signing.c b/source4/libcli/raw/smb_signing.c index 9c02fe50ec..ddde58fd88 100644 --- a/source4/libcli/raw/smb_signing.c +++ b/source4/libcli/raw/smb_signing.c @@ -30,7 +30,7 @@ struct smb_basic_signing_context { /*********************************************************** SMB signing - Common code before we set a new signing implementation ************************************************************/ -static BOOL set_smb_signing_common(struct cli_transport *transport) +static BOOL set_smb_signing_common(struct smbcli_transport *transport) { if (!(transport->negotiate.sec_mode & (NEGOTIATE_SECURITY_SIGNATURES_REQUIRED|NEGOTIATE_SECURITY_SIGNATURES_ENABLED))) { @@ -58,7 +58,7 @@ static BOOL set_smb_signing_common(struct cli_transport *transport) /*********************************************************** SMB signing - Common code for 'real' implementations ************************************************************/ -static BOOL set_smb_signing_real_common(struct cli_transport *transport) +static BOOL set_smb_signing_real_common(struct smbcli_transport *transport) { if (transport->negotiate.sign_info.mandatory_signing) { DEBUG(5, ("Mandatory SMB signing enabled!\n")); @@ -77,7 +77,7 @@ static void mark_packet_signed(struct request_buffer *out) SSVAL(out->hdr, HDR_FLG2, flags2); } -static BOOL signing_good(struct cli_request *req, unsigned int seq, BOOL good) +static BOOL signing_good(struct smbcli_request *req, unsigned int seq, BOOL good) { if (good) { if (!req->transport->negotiate.sign_info.doing_signing) { @@ -96,7 +96,7 @@ static BOOL signing_good(struct cli_request *req, unsigned int seq, BOOL good) req->transport->negotiate.sign_info.doing_signing = False; if (req->transport->negotiate.sign_info.free_signing_context) req->transport->negotiate.sign_info.free_signing_context(req->transport); - cli_null_set_signing(req->transport); + smbcli_null_set_signing(req->transport); return True; } else { /* bad packet after signing started - fail and disconnect. */ @@ -206,7 +206,7 @@ BOOL check_signed_incoming_message(struct request_buffer *in, DATA_BLOB *mac_key /*********************************************************** SMB signing - Simple implementation - calculate a MAC to send. ************************************************************/ -static void cli_request_simple_sign_outgoing_message(struct cli_request *req) +static void smbcli_request_simple_sign_outgoing_message(struct smbcli_request *req) { struct smb_basic_signing_context *data = req->transport->negotiate.sign_info.signing_context; @@ -233,7 +233,7 @@ static void cli_request_simple_sign_outgoing_message(struct cli_request *req) /*********************************************************** SMB signing - Simple implementation - check a MAC sent by server. ************************************************************/ -static BOOL cli_request_simple_check_incoming_message(struct cli_request *req) +static BOOL smbcli_request_simple_check_incoming_message(struct smbcli_request *req) { struct smb_basic_signing_context *data = req->transport->negotiate.sign_info.signing_context; @@ -249,7 +249,7 @@ static BOOL cli_request_simple_check_incoming_message(struct cli_request *req) /*********************************************************** SMB signing - Simple implementation - free signing context ************************************************************/ -static void cli_transport_simple_free_signing_context(struct cli_transport *transport) +static void smbcli_transport_simple_free_signing_context(struct smbcli_transport *transport) { struct smb_basic_signing_context *data = transport->negotiate.sign_info.signing_context; @@ -263,7 +263,7 @@ static void cli_transport_simple_free_signing_context(struct cli_transport *tran /*********************************************************** SMB signing - Simple implementation - setup the MAC key. ************************************************************/ -BOOL cli_transport_simple_set_signing(struct cli_transport *transport, +BOOL smbcli_transport_simple_set_signing(struct smbcli_transport *transport, const DATA_BLOB user_session_key, const DATA_BLOB response) { @@ -293,9 +293,9 @@ BOOL cli_transport_simple_set_signing(struct cli_transport *transport, /* Initialise the sequence number */ data->next_seq_num = 0; - transport->negotiate.sign_info.sign_outgoing_message = cli_request_simple_sign_outgoing_message; - transport->negotiate.sign_info.check_incoming_message = cli_request_simple_check_incoming_message; - transport->negotiate.sign_info.free_signing_context = cli_transport_simple_free_signing_context; + transport->negotiate.sign_info.sign_outgoing_message = smbcli_request_simple_sign_outgoing_message; + transport->negotiate.sign_info.check_incoming_message = smbcli_request_simple_check_incoming_message; + transport->negotiate.sign_info.free_signing_context = smbcli_transport_simple_free_signing_context; return True; } @@ -304,7 +304,7 @@ BOOL cli_transport_simple_set_signing(struct cli_transport *transport, /*********************************************************** SMB signing - NULL implementation - calculate a MAC to send. ************************************************************/ -static void cli_request_null_sign_outgoing_message(struct cli_request *req) +static void smbcli_request_null_sign_outgoing_message(struct smbcli_request *req) { /* we can't zero out the sig, as we might be trying to send a transport request - which is NBT-level, not SMB level and doesn't @@ -315,7 +315,7 @@ static void cli_request_null_sign_outgoing_message(struct cli_request *req) /*********************************************************** SMB signing - NULL implementation - check a MAC sent by server. ************************************************************/ -static BOOL cli_request_null_check_incoming_message(struct cli_request *req) +static BOOL smbcli_request_null_check_incoming_message(struct smbcli_request *req) { return True; } @@ -324,7 +324,7 @@ static BOOL cli_request_null_check_incoming_message(struct cli_request *req) /*********************************************************** SMB signing - NULL implementation - free signing context ************************************************************/ -static void cli_null_free_signing_context(struct cli_transport *transport) +static void smbcli_null_free_signing_context(struct smbcli_transport *transport) { } @@ -334,13 +334,13 @@ static void cli_null_free_signing_context(struct cli_transport *transport) @note Used as an initialisation only - it will not correctly shut down a real signing mechanism */ -BOOL cli_null_set_signing(struct cli_transport *transport) +BOOL smbcli_null_set_signing(struct smbcli_transport *transport) { transport->negotiate.sign_info.signing_context = NULL; - transport->negotiate.sign_info.sign_outgoing_message = cli_request_null_sign_outgoing_message; - transport->negotiate.sign_info.check_incoming_message = cli_request_null_check_incoming_message; - transport->negotiate.sign_info.free_signing_context = cli_null_free_signing_context; + transport->negotiate.sign_info.sign_outgoing_message = smbcli_request_null_sign_outgoing_message; + transport->negotiate.sign_info.check_incoming_message = smbcli_request_null_check_incoming_message; + transport->negotiate.sign_info.free_signing_context = smbcli_null_free_signing_context; return True; } @@ -348,7 +348,7 @@ BOOL cli_null_set_signing(struct cli_transport *transport) /*********************************************************** SMB signing - TEMP implementation - calculate a MAC to send. ************************************************************/ -static void cli_request_temp_sign_outgoing_message(struct cli_request *req) +static void smbcli_request_temp_sign_outgoing_message(struct smbcli_request *req) { /* mark the packet as signed - BEFORE we sign it...*/ mark_packet_signed(&req->out); @@ -363,7 +363,7 @@ static void cli_request_temp_sign_outgoing_message(struct cli_request *req) /*********************************************************** SMB signing - TEMP implementation - check a MAC sent by server. ************************************************************/ -static BOOL cli_request_temp_check_incoming_message(struct cli_request *req) +static BOOL smbcli_request_temp_check_incoming_message(struct smbcli_request *req) { return True; } @@ -371,7 +371,7 @@ static BOOL cli_request_temp_check_incoming_message(struct cli_request *req) /*********************************************************** SMB signing - NULL implementation - free signing context ************************************************************/ -static void cli_temp_free_signing_context(struct cli_transport *transport) +static void smbcli_temp_free_signing_context(struct smbcli_transport *transport) { return; } @@ -382,7 +382,7 @@ static void cli_temp_free_signing_context(struct cli_transport *transport) @note Used as an initialisation only - it will not correctly shut down a real signing mechanism */ -BOOL cli_temp_set_signing(struct cli_transport *transport) +BOOL smbcli_temp_set_signing(struct smbcli_transport *transport) { if (!set_smb_signing_common(transport)) { return False; @@ -390,9 +390,9 @@ BOOL cli_temp_set_signing(struct cli_transport *transport) transport->negotiate.sign_info.signing_context = NULL; - transport->negotiate.sign_info.sign_outgoing_message = cli_request_temp_sign_outgoing_message; - transport->negotiate.sign_info.check_incoming_message = cli_request_temp_check_incoming_message; - transport->negotiate.sign_info.free_signing_context = cli_temp_free_signing_context; + transport->negotiate.sign_info.sign_outgoing_message = smbcli_request_temp_sign_outgoing_message; + transport->negotiate.sign_info.check_incoming_message = smbcli_request_temp_check_incoming_message; + transport->negotiate.sign_info.free_signing_context = smbcli_temp_free_signing_context; return True; } @@ -400,20 +400,20 @@ BOOL cli_temp_set_signing(struct cli_transport *transport) /** * Free the signing context */ -void cli_transport_free_signing_context(struct cli_transport *transport) +void smbcli_transport_free_signing_context(struct smbcli_transport *transport) { if (transport->negotiate.sign_info.free_signing_context) { transport->negotiate.sign_info.free_signing_context(transport); } - cli_null_set_signing(transport); + smbcli_null_set_signing(transport); } /** * Sign a packet with the current mechanism */ -void cli_request_calculate_sign_mac(struct cli_request *req) +void smbcli_request_calculate_sign_mac(struct smbcli_request *req) { req->transport->negotiate.sign_info.sign_outgoing_message(req); } @@ -424,7 +424,7 @@ void cli_request_calculate_sign_mac(struct cli_request *req) * @return False if we had an established signing connection * which had a back checksum, True otherwise */ -BOOL cli_request_check_sign_mac(struct cli_request *req) +BOOL smbcli_request_check_sign_mac(struct smbcli_request *req) { BOOL good; @@ -442,9 +442,9 @@ BOOL cli_request_check_sign_mac(struct cli_request *req) } -BOOL cli_init_signing(struct cli_transport *transport) +BOOL smbcli_init_signing(struct smbcli_transport *transport) { - if (!cli_null_set_signing(transport)) { + if (!smbcli_null_set_signing(transport)) { return False; } diff --git a/source4/libcli/util/clierror.c b/source4/libcli/util/clierror.c index d852cd0d21..e7e413bbcb 100644 --- a/source4/libcli/util/clierror.c +++ b/source4/libcli/util/clierror.c @@ -25,7 +25,7 @@ /*************************************************************************** Return an error message from the last response ****************************************************************************/ -const char *cli_errstr(struct cli_tree *tree) +const char *smbcli_errstr(struct smbcli_tree *tree) { switch (tree->session->transport->error.etype) { case ETYPE_DOS: @@ -49,7 +49,7 @@ const char *cli_errstr(struct cli_tree *tree) /* Return the 32-bit NT status code from the last packet */ -NTSTATUS cli_nt_error(struct cli_tree *tree) +NTSTATUS smbcli_nt_error(struct smbcli_tree *tree) { switch (tree->session->transport->error.etype) { case ETYPE_NT: @@ -75,7 +75,7 @@ NTSTATUS cli_nt_error(struct cli_tree *tree) /* Return the DOS error from the last packet - an error class and an error code. */ -void cli_dos_error(struct cli_state *cli, uint8_t *eclass, uint32_t *ecode) +void smbcli_dos_error(struct smbcli_state *cli, uint8_t *eclass, uint32_t *ecode) { if (cli->transport->error.etype == ETYPE_DOS) { ntstatus_to_dos(cli->transport->error.e.nt_status, @@ -89,13 +89,13 @@ void cli_dos_error(struct cli_state *cli, uint8_t *eclass, uint32_t *ecode) /* Return true if the last packet was an error */ -BOOL cli_is_error(struct cli_tree *tree) +BOOL smbcli_is_error(struct smbcli_tree *tree) { - return NT_STATUS_IS_ERR(cli_nt_error(tree)); + return NT_STATUS_IS_ERR(smbcli_nt_error(tree)); } /* Return true if the last error was a DOS error */ -BOOL cli_is_dos_error(struct cli_tree *tree) +BOOL smbcli_is_dos_error(struct smbcli_tree *tree) { return tree->session->transport->error.etype == ETYPE_DOS; } diff --git a/source4/libcli/util/cliutil.c b/source4/libcli/util/cliutil.c index 56dee7381a..3efa1dbbc9 100644 --- a/source4/libcli/util/cliutil.c +++ b/source4/libcli/util/cliutil.c @@ -29,7 +29,7 @@ of the ".." name. *******************************************************************/ -BOOL mask_match(struct cli_state *cli, const char *string, char *pattern, BOOL is_case_sensitive) +BOOL mask_match(struct smbcli_state *cli, const char *string, char *pattern, BOOL is_case_sensitive) { fstring p2, s2; diff --git a/source4/libcli/util/smbencrypt.c b/source4/libcli/util/smbencrypt.c index a02fdaa38b..a50b4edc88 100644 --- a/source4/libcli/util/smbencrypt.c +++ b/source4/libcli/util/smbencrypt.c @@ -190,20 +190,20 @@ void SMBNTencrypt(const char *passwd, uint8_t *c8, uint8_t *p24) /* Does the md5 encryption from the Key Response for NTLMv2. */ void SMBOWFencrypt_ntv2(const uint8_t kr[16], const DATA_BLOB *srv_chal, - const DATA_BLOB *cli_chal, + const DATA_BLOB *smbcli_chal, uint8_t resp_buf[16]) { HMACMD5Context ctx; hmac_md5_init_limK_to_64(kr, 16, &ctx); hmac_md5_update(srv_chal->data, srv_chal->length, &ctx); - hmac_md5_update(cli_chal->data, cli_chal->length, &ctx); + hmac_md5_update(smbcli_chal->data, smbcli_chal->length, &ctx); hmac_md5_final(resp_buf, &ctx); #ifdef DEBUG_PASSWORD - DEBUG(100, ("SMBOWFencrypt_ntv2: srv_chal, cli_chal, resp_buf\n")); + DEBUG(100, ("SMBOWFencrypt_ntv2: srv_chal, smbcli_chal, resp_buf\n")); dump_data(100, srv_chal->data, srv_chal->length); - dump_data(100, cli_chal->data, cli_chal->length); + dump_data(100, smbcli_chal->data, smbcli_chal->length); dump_data(100, resp_buf, 16); #endif } |