summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-07-19 16:25:52 +0200
committerStefan Metzmacher <metze@samba.org>2011-07-20 15:56:27 +0200
commit8f41e54d538896a929ef8ebf224ddcfea7982ba8 (patch)
tree2df4093c3c5fac9a11291ad01e21c71ab53c3f32 /source3/libsmb
parent1e3822115c3b466632044fe64c908b6f2de5803a (diff)
downloadsamba-8f41e54d538896a929ef8ebf224ddcfea7982ba8.tar.gz
samba-8f41e54d538896a929ef8ebf224ddcfea7982ba8.tar.bz2
samba-8f41e54d538896a929ef8ebf224ddcfea7982ba8.zip
s3:libsmb: move cli->cnum to cli->smb1.tid and hide it behind cli_state_[g|s]et_tid()
metze
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/async_smb.c2
-rw-r--r--source3/libsmb/cliconnect.c9
-rw-r--r--source3/libsmb/clidfs.c4
-rw-r--r--source3/libsmb/clientgen.c25
-rw-r--r--source3/libsmb/libsmb_server.c2
-rw-r--r--source3/libsmb/proto.h3
6 files changed, 32 insertions, 13 deletions
diff --git a/source3/libsmb/async_smb.c b/source3/libsmb/async_smb.c
index 2c42cec6b9..b621919dbd 100644
--- a/source3/libsmb/async_smb.c
+++ b/source3/libsmb/async_smb.c
@@ -317,7 +317,7 @@ struct tevent_req *cli_smb_req_create(TALLOC_CTX *mem_ctx,
cli_setup_packet_buf(cli, (char *)state->header);
SCVAL(state->header, smb_com, smb_command);
- SSVAL(state->header, smb_tid, cli->cnum);
+ SSVAL(state->header, smb_tid, cli->smb1.tid);
SCVAL(state->header, smb_wct, wct);
state->vwv = vwv;
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 03251f965b..4e3e47f512 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -2405,7 +2405,7 @@ static void cli_tcon_andx_done(struct tevent_req *subreq)
cli->dfsroot = ((SVAL(vwv+2, 0) & SMB_SHARE_IN_DFS) != 0);
}
- cli->cnum = SVAL(inbuf,smb_tid);
+ cli->smb1.tid = SVAL(inbuf,smb_tid);
tevent_req_done(req);
}
@@ -2498,7 +2498,7 @@ static void cli_tdis_done(struct tevent_req *subreq)
tevent_req_nterror(req, status);
return;
}
- state->cli->cnum = -1;
+ state->cli->smb1.tid = UINT16_MAX;
tevent_req_done(req);
}
@@ -2551,7 +2551,6 @@ struct tevent_req *cli_negprot_send(TALLOC_CTX *mem_ctx,
struct cli_negprot_state *state;
uint8_t *bytes = NULL;
int numprots;
- uint16_t cnum;
req = tevent_req_create(mem_ctx, &state, struct cli_negprot_state);
if (req == NULL) {
@@ -2582,12 +2581,8 @@ struct tevent_req *cli_negprot_send(TALLOC_CTX *mem_ctx,
}
}
- cnum = cli->cnum;
-
- cli->cnum = 0;
subreq = cli_smb_send(state, ev, cli, SMBnegprot, 0, 0, NULL,
talloc_get_size(bytes), bytes);
- cli->cnum = cnum;
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
diff --git a/source3/libsmb/clidfs.c b/source3/libsmb/clidfs.c
index a0d503a802..d677f9e0ac 100644
--- a/source3/libsmb/clidfs.c
+++ b/source3/libsmb/clidfs.c
@@ -1031,7 +1031,7 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
return false;
}
- cnum = cli->cnum;
+ cnum = cli_state_get_tid(cli);
/* special case. never check for a referral on the IPC$ share */
@@ -1072,7 +1072,7 @@ bool cli_check_msdfs_proxy(TALLOC_CTX *ctx,
return false;
}
- cli->cnum = cnum;
+ cli_state_set_tid(cli, cnum);
if (!res || !num_refs) {
return false;
diff --git a/source3/libsmb/clientgen.c b/source3/libsmb/clientgen.c
index 67e8e06d1a..0ee361f862 100644
--- a/source3/libsmb/clientgen.c
+++ b/source3/libsmb/clientgen.c
@@ -184,7 +184,6 @@ struct cli_state *cli_initialise_ex(int signing_state)
}
cli->fd = -1;
cli->raw_status = NT_STATUS_INTERNAL_ERROR;
- cli->cnum = -1;
cli->vuid = UID_FIELD_INVALID;
cli->protocol = PROTOCOL_NT1;
cli->timeout = 20000; /* Timeout is in milliseconds. */
@@ -241,6 +240,7 @@ struct cli_state *cli_initialise_ex(int signing_state)
cli->smb1.mid = 1;
cli->smb1.pid = (uint16_t)sys_getpid();
cli->smb1.vc_num = cli->smb1.pid;
+ cli->smb1.tid = UINT16_MAX;
return cli;
@@ -287,7 +287,7 @@ static void _cli_shutdown(struct cli_state *cli)
* later. This tree disconnect forces the peer to clean up, since the
* connection will be going away.
*/
- if (cli->cnum != (uint16)-1) {
+ if (cli_state_has_tcon(cli)) {
cli_tdis(cli);
}
@@ -364,6 +364,27 @@ uint16_t cli_getpid(struct cli_state *cli)
return cli->smb1.pid;
}
+bool cli_state_has_tcon(struct cli_state *cli)
+{
+ if (cli->smb1.tid == UINT16_MAX) {
+ return false;
+ }
+
+ return true;
+}
+
+uint16_t cli_state_get_tid(struct cli_state *cli)
+{
+ return cli->smb1.tid;
+}
+
+uint16_t cli_state_set_tid(struct cli_state *cli, uint16_t tid)
+{
+ uint16_t ret = cli->smb1.tid;
+ cli->smb1.tid = tid;
+ return ret;
+}
+
/****************************************************************************
Set the case sensitivity flag on the packets. Returns old state.
****************************************************************************/
diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c
index 49018a8320..760bd9a8d3 100644
--- a/source3/libsmb/libsmb_server.c
+++ b/source3/libsmb/libsmb_server.c
@@ -289,7 +289,7 @@ SMBC_server_internal(TALLOC_CTX *ctx,
* i.e., a normal share or a referred share from
* 'msdfs proxy' share.
*/
- if (srv->cli->cnum == (uint16) -1) {
+ if (!cli_state_has_tcon(srv->cli)) {
/* Ensure we have accurate auth info */
SMBC_call_auth_fn(ctx, context,
srv->cli->desthost,
diff --git a/source3/libsmb/proto.h b/source3/libsmb/proto.h
index 9775bd775d..fe30509bb6 100644
--- a/source3/libsmb/proto.h
+++ b/source3/libsmb/proto.h
@@ -167,6 +167,9 @@ void cli_sockopt(struct cli_state *cli, const char *options);
uint16_t cli_state_get_vc_num(struct cli_state *cli);
uint16 cli_setpid(struct cli_state *cli, uint16 pid);
uint16_t cli_getpid(struct cli_state *cli);
+bool cli_state_has_tcon(struct cli_state *cli);
+uint16_t cli_state_get_tid(struct cli_state *cli);
+uint16_t cli_state_set_tid(struct cli_state *cli, uint16_t tid);
bool cli_set_case_sensitive(struct cli_state *cli, bool case_sensitive);
struct tevent_req *cli_echo_send(TALLOC_CTX *mem_ctx, struct event_context *ev,
struct cli_state *cli, uint16_t num_echos,