diff options
author | Jelmer Vernooij <jelmer@samba.org> | 2008-01-03 17:22:12 -0600 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2008-01-03 12:33:36 -0600 |
commit | dcc282590b34537fc1ead61c3300172528273b44 (patch) | |
tree | 9890dda1e9f3001c23828caf1e8da1afbc3feb45 /source4/client | |
parent | dc8ccffed40ed5a5978961c632a9e28331a0fd4f (diff) | |
download | samba-dcc282590b34537fc1ead61c3300172528273b44.tar.gz samba-dcc282590b34537fc1ead61c3300172528273b44.tar.bz2 samba-dcc282590b34537fc1ead61c3300172528273b44.zip |
r26654: libcli/smb_composite: Rather than specifying each of the gazillion options for SMB individually, just specify the smbcli_options struct.
(This used to be commit 8a97886e24a4b969aa91409c06f423b71a45f6eb)
Diffstat (limited to 'source4/client')
-rw-r--r-- | source4/client/cifsdd.c | 32 | ||||
-rw-r--r-- | source4/client/cifsdd.h | 5 | ||||
-rw-r--r-- | source4/client/cifsddio.c | 16 | ||||
-rw-r--r-- | source4/client/client.c | 19 | ||||
-rw-r--r-- | source4/client/smbspool.c | 4 |
5 files changed, 45 insertions, 31 deletions
diff --git a/source4/client/cifsdd.c b/source4/client/cifsdd.c index 8749a82573..8e25dab927 100644 --- a/source4/client/cifsdd.c +++ b/source4/client/cifsdd.c @@ -23,6 +23,7 @@ #include "auth/gensec/gensec.h" #include "lib/cmdline/popt_common.h" #include "libcli/resolve/resolve.h" +#include "libcli/raw/libcliraw.h" #include "cifsdd.h" #include "param/param.h" @@ -353,7 +354,8 @@ static void print_transfer_stats(void) } static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx, - const char * which, const char **ports) + const char * which, const char **ports, + struct smbcli_options *smb_options) { int options = 0; const char * path = NULL; @@ -374,12 +376,14 @@ static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx, if (strcmp(which, "if") == 0) { path = check_arg_pathname("if"); handle = dd_open_path(resolve_ctx, path, ports, - check_arg_numeric("ibs"), options); + check_arg_numeric("ibs"), options, + smb_options); } else if (strcmp(which, "of") == 0) { options |= DD_WRITE; path = check_arg_pathname("of"); handle = dd_open_path(resolve_ctx, path, ports, - check_arg_numeric("obs"), options); + check_arg_numeric("obs"), options, + smb_options); } else { SMB_ASSERT(0); return(NULL); @@ -392,14 +396,6 @@ static struct dd_iohandle * open_file(struct resolve_context *resolve_ctx, return(handle); } -static void set_max_xmit(struct loadparm_context *lp_ctx, uint64_t iomax) -{ - char buf[64]; - - snprintf(buf, sizeof(buf), "%llu", (unsigned long long)iomax); - lp_set_cmdline(lp_ctx, "max xmit", buf); -} - static int copy_files(struct loadparm_context *lp_ctx) { uint8_t * iobuf; /* IO buffer. */ @@ -413,10 +409,14 @@ static int copy_files(struct loadparm_context *lp_ctx) struct dd_iohandle * ifile; struct dd_iohandle * ofile; + struct smbcli_options options; + ibs = check_arg_numeric("ibs"); obs = check_arg_numeric("obs"); count = check_arg_numeric("count"); + lp_smbcli_options(lp_ctx, &options); + /* Allocate IO buffer. We need more than the max IO size because we * could accumulate a remainder if ibs and obs don't match. */ @@ -428,18 +428,18 @@ static int copy_files(struct loadparm_context *lp_ctx) return(EOM_EXIT_CODE); } - set_max_xmit(lp_ctx, MAX(ibs, obs)); + options.max_xmit = MAX(ibs, obs); DEBUG(4, ("IO buffer size is %llu, max xmit is %d\n", - (unsigned long long)iomax, lp_max_xmit(lp_ctx))); + (unsigned long long)iomax, options.max_xmit)); if (!(ifile = open_file(lp_resolve_context(lp_ctx), "if", - lp_smb_ports(lp_ctx)))) { + lp_smb_ports(lp_ctx), &options))) { return(FILESYS_EXIT_CODE); } if (!(ofile = open_file(lp_resolve_context(lp_ctx), "of", - lp_smb_ports(lp_ctx)))) { + lp_smb_ports(lp_ctx), &options))) { return(FILESYS_EXIT_CODE); } @@ -447,7 +447,7 @@ static int copy_files(struct loadparm_context *lp_ctx) ifile->io_seek(ifile, check_arg_numeric("skip") * ibs); ofile->io_seek(ofile, check_arg_numeric("seek") * obs); - DEBUG(4, ("max xmit was negotiated to be %d\n", lp_max_xmit(lp_ctx))); + DEBUG(4, ("max xmit was negotiated to be %d\n", options.max_xmit)); for (data_size = 0;;) { diff --git a/source4/client/cifsdd.h b/source4/client/cifsdd.h index 0c44b91581..810c882ea9 100644 --- a/source4/client/cifsdd.h +++ b/source4/client/cifsdd.h @@ -88,10 +88,13 @@ struct dd_iohandle #define DD_WRITE 0x00000004 #define DD_OPLOCK 0x00000008 +struct smbcli_options; + struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx, const char * path, const char **ports, - uint64_t io_size, int options); + uint64_t io_size, int options, + struct smbcli_options *smb_options); bool dd_fill_block(struct dd_iohandle * h, uint8_t * buf, uint64_t * buf_size, uint64_t need_size, uint64_t block_size); bool dd_flush_block(struct dd_iohandle * h, uint8_t * buf, diff --git a/source4/client/cifsddio.c b/source4/client/cifsddio.c index 2e5aedc4f9..7028e85078 100644 --- a/source4/client/cifsddio.c +++ b/source4/client/cifsddio.c @@ -223,7 +223,8 @@ static bool smb_write_func(void * handle, uint8_t * buf, uint64_t wanted, static struct smbcli_state * init_smb_session(struct resolve_context *resolve_ctx, const char * host, const char **ports, - const char * share) + const char * share, + struct smbcli_options *options) { NTSTATUS ret; struct smbcli_state * cli = NULL; @@ -233,7 +234,7 @@ static struct smbcli_state * init_smb_session(struct resolve_context *resolve_ct */ ret = smbcli_full_connection(NULL, &cli, host, ports, share, NULL /* devtype */, cmdline_credentials, resolve_ctx, - NULL /* events */); + NULL /* events */, options); if (!NT_STATUS_IS_OK(ret)) { fprintf(stderr, "%s: connecting to //%s/%s: %s\n", @@ -297,7 +298,8 @@ static struct dd_iohandle * open_cifs_handle(struct resolve_context *resolve_ctx const char * share, const char * path, uint64_t io_size, - int options) + int options, + struct smbcli_options *smb_options) { struct cifs_handle * smbh; @@ -317,7 +319,8 @@ static struct dd_iohandle * open_cifs_handle(struct resolve_context *resolve_ctx smbh->h.io_write = smb_write_func; smbh->h.io_seek = smb_seek_func; - if ((smbh->cli = init_smb_session(resolve_ctx, host, ports, share)) == NULL) { + if ((smbh->cli = init_smb_session(resolve_ctx, host, ports, share, + smb_options)) == NULL) { return(NULL); } @@ -336,7 +339,8 @@ struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx, const char * path, const char **ports, uint64_t io_size, - int options) + int options, + struct smbcli_options *smb_options) { if (file_exist(path)) { return(open_fd_handle(path, io_size, options)); @@ -353,7 +357,7 @@ struct dd_iohandle * dd_open_path(struct resolve_context *resolve_ctx, return(open_cifs_handle(resolve_ctx, host, ports, share, remain, - io_size, options)); + io_size, options, smb_options)); } return(open_fd_handle(path, io_size, options)); diff --git a/source4/client/client.c b/source4/client/client.c index 259966ddaa..d9478a3a8a 100644 --- a/source4/client/client.c +++ b/source4/client/client.c @@ -3021,7 +3021,10 @@ return a connection to a server *******************************************************/ static bool do_connect(struct smbclient_context *ctx, struct resolve_context *resolve_ctx, - const char *specified_server, const char **ports, const char *specified_share, struct cli_credentials *cred) + const char *specified_server, const char **ports, + const char *specified_share, + struct cli_credentials *cred, + struct smbcli_options *options) { NTSTATUS status; char *server, *share; @@ -3040,7 +3043,8 @@ static bool do_connect(struct smbclient_context *ctx, status = smbcli_full_connection(ctx, &ctx->cli, server, ports, share, NULL, cred, resolve_ctx, - cli_credentials_get_event_context(cred)); + cli_credentials_get_event_context(cred), + options); if (!NT_STATUS_IS_OK(status)) { d_printf("Connection to \\\\%s\\%s failed - %s\n", server, share, nt_errstr(status)); @@ -3065,7 +3069,7 @@ static int do_host_query(struct loadparm_context *lp_ctx, const char *query_host /**************************************************************************** handle a message operation ****************************************************************************/ -static int do_message_op(const char *netbios_name, const char *desthost, const char **destports, const char *destip, int name_type, struct resolve_context *resolve_ctx, int max_xmit, int max_mux, bool use_spnego, enum smb_signing_state signing) +static int do_message_op(const char *netbios_name, const char *desthost, const char **destports, const char *destip, int name_type, struct resolve_context *resolve_ctx, struct smbcli_options *options) { struct nbt_name called, calling; const char *server_name; @@ -3077,7 +3081,7 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c server_name = destip ? destip : desthost; - if (!(cli=smbcli_state_init(NULL)) || !smbcli_socket_connect(cli, server_name, destports, resolve_ctx, max_xmit, max_mux, use_spnego, signing)) { + if (!(cli=smbcli_state_init(NULL)) || !smbcli_socket_connect(cli, server_name, destports, resolve_ctx, options)) { d_printf("Connection to %s failed\n", server_name); return 1; } @@ -3120,6 +3124,7 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c TALLOC_CTX *mem_ctx; struct smbclient_context *ctx; const char *cmdstr = NULL; + struct smbcli_options smb_options; struct poptOption long_options[] = { POPT_AUTOHELP @@ -3212,6 +3217,8 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c poptFreeContext(pc); + lp_smbcli_options(cmdline_lp_ctx, &smb_options); + DEBUG( 3, ( "Client started (version %s).\n", SAMBA_VERSION_STRING ) ); if (query_host && (p=strchr_m(query_host,'#'))) { @@ -3225,10 +3232,10 @@ static int do_message_op(const char *netbios_name, const char *desthost, const c } if (message) { - return do_message_op(lp_netbios_name(cmdline_lp_ctx), desthost, lp_smb_ports(cmdline_lp_ctx), dest_ip, name_type, lp_resolve_context(cmdline_lp_ctx), lp_max_xmit(cmdline_lp_ctx), lp_maxmux(cmdline_lp_ctx), lp_nt_status_support(cmdline_lp_ctx) && lp_use_spnego(cmdline_lp_ctx), lp_client_signing(cmdline_lp_ctx)); + return do_message_op(lp_netbios_name(cmdline_lp_ctx), desthost, lp_smb_ports(cmdline_lp_ctx), dest_ip, name_type, lp_resolve_context(cmdline_lp_ctx), &smb_options); } - if (!do_connect(ctx, lp_resolve_context(cmdline_lp_ctx), desthost, lp_smb_ports(cmdline_lp_ctx), service, cmdline_credentials)) + if (!do_connect(ctx, lp_resolve_context(cmdline_lp_ctx), desthost, lp_smb_ports(cmdline_lp_ctx), service, cmdline_credentials, &smb_options)) return 1; if (base_directory) diff --git a/source4/client/smbspool.c b/source4/client/smbspool.c index 614e50bb0b..df867d5fef 100644 --- a/source4/client/smbspool.c +++ b/source4/client/smbspool.c @@ -270,8 +270,8 @@ smb_connect(const char *workgroup, /* I - Workgroup */ myname = get_myname(); - nt_status = smbcli_full_connection(NULL, &c, myname, server, ports, share, NULL, - username, workgroup, password, NULL); + nt_status = smbcli_full_connection(NULL, &c, myname, server, ports, share, + NULL, username, workgroup, password, NULL); free(myname); if (!NT_STATUS_IS_OK(nt_status)) { |