} in;
struct {
uint16_t max_xmit;
- uint16_t cnum;
+ uint16_t tid;
} out;
} tcon;
uint16_t options;
char *dev_type;
char *fs_type;
- uint16_t cnum;
+ uint16_t tid;
} out;
} tconx;
};
status = smb_tree_connect(cli->tree, mem_ctx, &tcon);
- cli->tree->tid = tcon.tconx.out.cnum;
+ cli->tree->tid = tcon.tconx.out.tid;
talloc_free(mem_ctx);
case RAW_TCON_TCON:
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));
+ parms->tcon.out.tid = SVAL(req->in.vwv, VWV(1));
break;
case RAW_TCON_TCONX:
ZERO_STRUCT(parms->tconx.out);
- parms->tconx.out.cnum = SVAL(req->in.hdr, HDR_TID);
+ parms->tconx.out.tid = SVAL(req->in.hdr, HDR_TID);
if (req->in.wct >= 4) {
parms->tconx.out.options = SVAL(req->in.vwv, VWV(3));
}
return status;
}
- tree->tid = tcon.tconx.out.cnum;
+ tree->tid = tcon.tconx.out.tid;
if (tcon.tconx.out.dev_type) {
tree->device = talloc_strdup(tree, tcon.tconx.out.dev_type);
}
talloc_free(lsa);
return status;
}
- lsa->ipc_tree->tid = tcon.tconx.out.cnum;
+ lsa->ipc_tree->tid = tcon.tconx.out.tid;
lsa->pipe = dcerpc_pipe_init(lsa);
if (lsa->pipe == NULL) {
if (!smbcli_transport_process(private->transport)) {
/* the connection to our server is dead */
- close_cnum(tcon);
+ talloc_free(tcon);
}
}
/****************************************************************************
init the tcon structures
****************************************************************************/
-void conn_init(struct smbsrv_connection *smb_conn)
+void smbsrv_tcon_init(struct smbsrv_connection *smb_conn)
{
smb_conn->tree.idtree_tid = idr_init(smb_conn);
}
/****************************************************************************
find a tcon given a cnum
****************************************************************************/
-struct smbsrv_tcon *conn_find(struct smbsrv_connection *smb_conn, uint_t cnum)
+struct smbsrv_tcon *smbsrv_tcon_find(struct smbsrv_connection *smb_conn, uint_t tid)
{
- return idr_find(smb_conn->tree.idtree_tid, cnum);
+ return idr_find(smb_conn->tree.idtree_tid, tid);
}
/*
destroy a connection structure
*/
-static int conn_destructor(void *ptr)
+static int smbsrv_tcon_destructor(void *ptr)
{
struct smbsrv_tcon *tcon = ptr;
- idr_remove(tcon->smb_conn->tree.idtree_tid, tcon->cnum);
+
+
+ DEBUG(3,("%s closed connection to service %s\n",
+ socket_get_peer_addr(tcon->smb_conn->connection->socket, tcon),
+ lp_servicename(SNUM(tcon))));
+
+ /* tell the ntvfs backend that we are disconnecting */
+ ntvfs_disconnect(tcon);
+
+ idr_remove(tcon->smb_conn->tree.idtree_tid, tcon->tid);
DLIST_REMOVE(tcon->smb_conn->tree.tcons, tcon);
return 0;
}
/*
find first available connection slot
*/
-struct smbsrv_tcon *conn_new(struct smbsrv_connection *smb_conn)
+struct smbsrv_tcon *smbsrv_tcon_new(struct smbsrv_connection *smb_conn)
{
struct smbsrv_tcon *tcon;
int i;
return NULL;
}
- tcon->cnum = i;
+ tcon->tid = i;
tcon->smb_conn = smb_conn;
- talloc_set_destructor(tcon, conn_destructor);
+ talloc_set_destructor(tcon, smbsrv_tcon_destructor);
DLIST_ADD(smb_conn->tree.tcons, tcon);
return tcon;
}
-
-/****************************************************************************
-close all tcon structures
-****************************************************************************/
-void conn_close_all(struct smbsrv_connection *smb_conn)
-{
- struct smbsrv_tcon *tcon, *next;
- for (tcon=smb_conn->tree.tcons;tcon;tcon=next) {
- next=tcon->next;
- close_cnum(tcon);
- }
-}
-
-
-/****************************************************************************
- Free a tcon structure.
-****************************************************************************/
-void conn_free(struct smbsrv_connection *smb_conn, struct smbsrv_tcon *tcon)
-{
- talloc_free(tcon);
-}
-
req_setup_reply(req, 2, 0);
SSVAL(req->out.vwv, VWV(0), con.tcon.out.max_xmit);
- SSVAL(req->out.vwv, VWV(1), con.tcon.out.cnum);
- SSVAL(req->out.hdr, HDR_TID, req->tcon->cnum);
+ SSVAL(req->out.vwv, VWV(1), con.tcon.out.tid);
+ SSVAL(req->out.hdr, HDR_TID, req->tcon->tid);
req_send_reply(req);
}
}
/* set the incoming and outgoing tid to the just created one */
- SSVAL(req->in.hdr, HDR_TID, con.tconx.out.cnum);
- SSVAL(req->out.hdr,HDR_TID, con.tconx.out.cnum);
+ SSVAL(req->in.hdr, HDR_TID, con.tconx.out.tid);
+ SSVAL(req->out.hdr,HDR_TID, con.tconx.out.tid);
chain_reply(req);
}
return;
}
- close_cnum(req->tcon);
+ talloc_free(req->tcon);
/* construct reply */
req_setup_reply(req, 0, 0);
return NT_STATUS_ACCESS_DENIED;
}
- tcon = conn_new(req->smb_conn);
+ tcon = smbsrv_tcon_new(req->smb_conn);
if (!tcon) {
DEBUG(0,("Couldn't find free connection.\n"));
return NT_STATUS_INSUFFICIENT_RESOURCES;
status = ntvfs_init_connection(req, type);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0, ("ntvfs_init_connection failed for service %s\n", lp_servicename(SNUM(tcon))));
- conn_free(req->smb_conn, tcon);
return status;
}
-
+
/* Invoke NTVFS connection hook */
status = ntvfs_connect(req, lp_servicename(snum));
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("make_connection: NTVFS make connection failed!\n"));
- conn_free(req->smb_conn, tcon);
return status;
}
-
+
return NT_STATUS_OK;
}
return make_connection_snum(req, snum, type, password, dev);
}
-/****************************************************************************
-close a cnum
-****************************************************************************/
-void close_cnum(struct smbsrv_tcon *tcon)
-{
- DEBUG(3,("%s closed connection to service %s\n",
- socket_get_peer_addr(tcon->smb_conn->connection->socket, tcon),
- lp_servicename(SNUM(tcon))));
-
- /* tell the ntvfs backend that we are disconnecting */
- ntvfs_disconnect(tcon);
-
- conn_free(tcon->smb_conn, tcon);
-}
-
-
-
/*
backend for tree connect call
*/
}
con->tcon.out.max_xmit = req->smb_conn->negotiate.max_recv;
- con->tcon.out.cnum = req->tcon->cnum;
-
+ con->tcon.out.tid = req->tcon->tid;
+
return status;
}
return status;
}
- con->tconx.out.cnum = req->tcon->cnum;
+ con->tconx.out.tid = req->tcon->tid;
con->tconx.out.dev_type = talloc_strdup(req, req->tcon->dev_type);
con->tconx.out.fs_type = talloc_strdup(req, req->tcon->fs_type);
con->tconx.out.options = SMB_SUPPORT_SEARCH_BITS | (lp_csc_policy(req->tcon->service) << 2);
req_setup_reply(req, 8, 0);
SCVAL(req->out.hdr,HDR_COM,SMBlockingX);
- SSVAL(req->out.hdr,HDR_TID,tcon->cnum);
+ SSVAL(req->out.hdr,HDR_TID,tcon->tid);
SSVAL(req->out.hdr,HDR_PID,0xFFFF);
SSVAL(req->out.hdr,HDR_UID,0);
SSVAL(req->out.hdr,HDR_MID,0xFFFF);
flags = smb_messages[type].flags;
- req->tcon = conn_find(smb_conn, SVAL(req->in.hdr,HDR_TID));
+ req->tcon = smbsrv_tcon_find(smb_conn, SVAL(req->in.hdr,HDR_TID));
if (req->session == NULL) {
/* setup the user context for this request if it
DEBUG(5,("smbsrv_close: %s\n",reason));
- conn_close_all(smb_conn);
-
talloc_free(smb_conn);
return;
srv_init_signing(smb_conn);
- conn_init(smb_conn);
+ smbsrv_tcon_init(smb_conn);
smb_conn->connection = conn;
/* the server context that this was created on */
struct smbsrv_connection *smb_conn;
- uint16_t cnum; /* an index passed over the wire (the TID) */
+ uint16_t tid; /* an index passed over the wire (the TID) */
+
int service;
BOOL read_only;
BOOL admin_user;
status = smb_tree_connect(tree, mem_ctx, &tcon);
CHECK_STATUS(status, NT_STATUS_OK);
- tree->tid = tcon.tconx.out.cnum;
+ tree->tid = tcon.tconx.out.tid;
printf("tid1=%d tid2=%d\n", cli->tree->tid, tree->tid);
printf("try a tconx with a bad device type\n");
return NT_STATUS_UNSUCCESSFUL;
}
- tree->tid = tcon.tconx.out.cnum;
+ tree->tid = tcon.tconx.out.tid;
if (tcon.tconx.out.dev_type != NULL)
tree->device = talloc_strdup(tree, tcon.tconx.out.dev_type);