svn commit: samba r8577 - in branches/SAMBA_4_0/source: librpc/idl
scripting/bin scripting/libjs smb_server
tridge at samba.org
tridge at samba.org
Tue Jul 19 04:26:58 GMT 2005
Author: tridge
Date: 2005-07-19 04:26:58 +0000 (Tue, 19 Jul 2005)
New Revision: 8577
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=8577
Log:
added management calls to list current tree connects
Modified:
branches/SAMBA_4_0/source/librpc/idl/irpc.idl
branches/SAMBA_4_0/source/scripting/bin/smbstatus
branches/SAMBA_4_0/source/scripting/libjs/management.js
branches/SAMBA_4_0/source/smb_server/conn.c
branches/SAMBA_4_0/source/smb_server/management.c
branches/SAMBA_4_0/source/smb_server/smb_server.h
Changeset:
Modified: branches/SAMBA_4_0/source/librpc/idl/irpc.idl
===================================================================
--- branches/SAMBA_4_0/source/librpc/idl/irpc.idl 2005-07-19 04:02:59 UTC (rev 8576)
+++ branches/SAMBA_4_0/source/librpc/idl/irpc.idl 2005-07-19 04:26:58 UTC (rev 8577)
@@ -52,7 +52,8 @@
management calls for the smb server
******************************************************/
typedef [v1_enum] enum {
- SMBSRV_INFO_SESSIONS
+ SMBSRV_INFO_SESSIONS,
+ SMBSRV_INFO_TREES
} smbsrv_info_level;
typedef struct {
@@ -68,8 +69,21 @@
[size_is(num_sessions)] smbsrv_session_info *sessions;
} smbsrv_sessions;
+ typedef struct {
+ uint16 tid;
+ astring share_name;
+ astring client_ip;
+ NTTIME connect_time;
+ } smbsrv_tree_info;
+
+ typedef struct {
+ uint32 num_trees;
+ [size_is(num_trees)] smbsrv_tree_info *trees;
+ } smbsrv_trees;
+
typedef union {
[case(SMBSRV_INFO_SESSIONS)] smbsrv_sessions sessions;
+ [case(SMBSRV_INFO_TREES)] smbsrv_trees trees;
} smbsrv_info;
void smbsrv_information(
Modified: branches/SAMBA_4_0/source/scripting/bin/smbstatus
===================================================================
--- branches/SAMBA_4_0/source/scripting/bin/smbstatus 2005-07-19 04:02:59 UTC (rev 8576)
+++ branches/SAMBA_4_0/source/scripting/bin/smbstatus 2005-07-19 04:26:58 UTC (rev 8577)
@@ -21,6 +21,17 @@
var sessions = smbsrv_sessions();
+if (sessions == undefined) {
+ println("No sessions");
+ exit(0);
+}
printVars(sessions);
+var trees = smbsrv_trees();
+if (trees == undefined) {
+ println("No trees");
+ exit(0);
+}
+printVars(trees);
+
return 0;
Modified: branches/SAMBA_4_0/source/scripting/libjs/management.js
===================================================================
--- branches/SAMBA_4_0/source/scripting/libjs/management.js 2005-07-19 04:02:59 UTC (rev 8576)
+++ branches/SAMBA_4_0/source/scripting/libjs/management.js 2005-07-19 04:26:58 UTC (rev 8577)
@@ -4,6 +4,7 @@
Released under the GNU GPL v2 or later
*/
+
/*
return a list of current sessions
*/
@@ -12,11 +13,16 @@
var conn = new Object();
var irpc = irpc_init();
status = irpc_connect(conn, "smb_server");
- assert(status.is_ok == true);
+ if (status.is_ok != true) {
+ return undefined;
+ }
var io = irpcObj();
io.input.level = irpc.SMBSRV_INFO_SESSIONS;
status = irpc.smbsrv_information(conn, io);
+ if (status.is_ok != true) {
+ return undefined;
+ }
/* gather the results into a single array */
var i, count=0, ret = new Object();
@@ -31,3 +37,36 @@
ret.length = count;
return ret;
}
+
+/*
+ return a list of current tree connects
+*/
+function smbsrv_trees()
+{
+ var conn = new Object();
+ var irpc = irpc_init();
+ status = irpc_connect(conn, "smb_server");
+ if (status.is_ok != true) {
+ return undefined;
+ }
+
+ var io = irpcObj();
+ io.input.level = irpc.SMBSRV_INFO_TREES;
+ status = irpc.smbsrv_information(conn, io);
+ if (status.is_ok != true) {
+ return undefined;
+ }
+
+ /* gather the results into a single array */
+ var i, count=0, ret = new Object();
+ for (i=0;i<io.results.length;i++) {
+ var trees = io.results[i].info.trees.trees;
+ var j;
+ for (j=0;j<trees.length;j++) {
+ ret[count] = trees[j];
+ count++;
+ }
+ }
+ ret.length = count;
+ return ret;
+}
Modified: branches/SAMBA_4_0/source/smb_server/conn.c
===================================================================
--- branches/SAMBA_4_0/source/smb_server/conn.c 2005-07-19 04:02:59 UTC (rev 8576)
+++ branches/SAMBA_4_0/source/smb_server/conn.c 2005-07-19 04:26:58 UTC (rev 8577)
@@ -81,6 +81,7 @@
tcon->tid = i;
tcon->smb_conn = smb_conn;
+ tcon->connect_time = timeval_current();
talloc_set_destructor(tcon, smbsrv_tcon_destructor);
Modified: branches/SAMBA_4_0/source/smb_server/management.c
===================================================================
--- branches/SAMBA_4_0/source/smb_server/management.c 2005-07-19 04:02:59 UTC (rev 8576)
+++ branches/SAMBA_4_0/source/smb_server/management.c 2005-07-19 04:26:58 UTC (rev 8577)
@@ -60,6 +60,37 @@
}
/*
+ return a list of tree connects
+*/
+static NTSTATUS smbsrv_tree_information(struct irpc_message *msg,
+ struct smbsrv_information *r)
+{
+ struct smbsrv_connection *smb_conn = talloc_get_type(msg->private, struct smbsrv_connection);
+ int i=0, count=0;
+ struct smbsrv_tcon *tcon;
+
+ /* count the number of tcons */
+ for (tcon=smb_conn->tree.tcons; tcon; tcon=tcon->next) {
+ count++;
+ }
+
+ r->out.info.trees.num_trees = count;
+ r->out.info.trees.trees = talloc_array(r, struct smbsrv_tree_info, count);
+ NT_STATUS_HAVE_NO_MEMORY(r->out.info.trees.trees);
+
+ for (tcon=smb_conn->tree.tcons; tcon; tcon=tcon->next) {
+ struct smbsrv_tree_info *info = &r->out.info.trees.trees[i];
+ info->tid = tcon->tid;
+ info->share_name = lp_servicename(tcon->service);
+ info->connect_time = timeval_to_nttime(&tcon->connect_time);
+ info->client_ip = socket_get_peer_addr(smb_conn->connection->socket, r);
+ i++;
+ }
+
+ return NT_STATUS_OK;
+}
+
+/*
serve smbserver information via irpc
*/
static NTSTATUS smbsrv_information(struct irpc_message *msg,
@@ -68,6 +99,8 @@
switch (r->in.level) {
case SMBSRV_INFO_SESSIONS:
return smbsrv_session_information(msg, r);
+ case SMBSRV_INFO_TREES:
+ return smbsrv_tree_information(msg, r);
}
return NT_STATUS_OK;
Modified: branches/SAMBA_4_0/source/smb_server/smb_server.h
===================================================================
--- branches/SAMBA_4_0/source/smb_server/smb_server.h 2005-07-19 04:02:59 UTC (rev 8576)
+++ branches/SAMBA_4_0/source/smb_server/smb_server.h 2005-07-19 04:26:58 UTC (rev 8577)
@@ -79,6 +79,8 @@
/* the reported device type */
char *dev_type;
+
+ struct timeval connect_time;
};
/* a set of flags to control handling of request structures */
More information about the samba-cvs
mailing list