2 Unix SMB/Netbios implementation.
4 NT Domain Authentication SMB / MSRPC client
5 Copyright (C) Andrew Tridgell 1994-1999
6 Copyright (C) Luke Kenneth Casson Leighton 1996-1999
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
30 #include "rpc_parse.h"
31 #include "rpcclient.h"
33 extern int DEBUGLEVEL
;
40 /****************************************************************************
42 ****************************************************************************/
43 BOOL
net_srv_get_info(struct client_info
*info
,
51 fstrcpy(dest_srv
, "\\\\");
52 fstrcat(dest_srv
, info
->dest_host
);
55 DEBUG(4,("net_srv_get_info: server:%s info level: %d\n",
56 dest_srv
, (int)info_level
));
58 /* send info level: receive requested info. hopefully. */
59 res
= res
? srv_net_srv_get_info(dest_srv
, info_level
, ctr
) : False
;
64 /****************************************************************************
66 ****************************************************************************/
67 void cmd_srv_query_info(struct client_info
*info
, int argc
, char *argv
[])
69 uint32 info_level
= 101;
76 info_level
= (uint32
)strtol(argv
[1], (char**)NULL
, 10);
79 if (net_srv_get_info(info
, info_level
, &ctr
))
81 DEBUG(5,("cmd_srv_query_info: query succeeded\n"));
83 display_srv_info_ctr(out_hnd
, ACTION_HEADER
, &ctr
);
84 display_srv_info_ctr(out_hnd
, ACTION_ENUMERATE
, &ctr
);
85 display_srv_info_ctr(out_hnd
, ACTION_FOOTER
, &ctr
);
89 DEBUG(5,("cmd_srv_query_info: query failed\n"));
93 /****************************************************************************
94 server enum transports
95 ****************************************************************************/
96 BOOL
msrpc_srv_enum_tprt( const char* dest_srv
,
98 SRV_TPRT_INFO_CTR
*ctr
,
99 TPRT_INFO_FN(tprt_fn
))
109 /* enumerate transports on server */
110 res1
= res
? srv_net_srv_tprt_enum(dest_srv
,
111 info_level
, ctr
, 0xffffffff, &hnd
) : False
;
115 free_srv_tprt_ctr(ctr
);
120 static void srv_display_tprt_ctr(const SRV_TPRT_INFO_CTR
*ctr
)
122 display_srv_tprt_info_ctr(out_hnd
, ACTION_HEADER
, ctr
);
123 display_srv_tprt_info_ctr(out_hnd
, ACTION_ENUMERATE
, ctr
);
124 display_srv_tprt_info_ctr(out_hnd
, ACTION_FOOTER
, ctr
);
127 /****************************************************************************
128 server enum transports
129 ****************************************************************************/
130 void cmd_srv_enum_tprt(struct client_info
*info
, int argc
, char *argv
[])
133 SRV_TPRT_INFO_CTR ctr
;
134 uint32 info_level
= 0;
138 fstrcpy(dest_srv
, "\\\\");
139 fstrcat(dest_srv
, info
->dest_host
);
144 info_level
= (uint32
)strtol(argv
[1], (char**)NULL
, 10);
147 DEBUG(4,("cmd_srv_enum_tprt: server:%s info level: %d\n",
148 dest_srv
, (int)info_level
));
150 /* enumerate transports on server */
151 msrpc_srv_enum_tprt(dest_srv
,
153 srv_display_tprt_ctr
);
156 /****************************************************************************
157 server enum connections
158 ****************************************************************************/
159 void cmd_srv_enum_conn(struct client_info
*info
, int argc
, char *argv
[])
163 SRV_CONN_INFO_CTR ctr
;
165 uint32 info_level
= 0;
171 fstrcpy(qual_srv
, "\\\\");
172 fstrcat(qual_srv
, info
->myhostname
);
175 fstrcpy(dest_srv
, "\\\\");
176 fstrcat(dest_srv
, info
->dest_host
);
181 info_level
= (uint32
)strtol(argv
[1], (char**)NULL
, 10);
184 DEBUG(4,("cmd_srv_enum_conn: server:%s info level: %d\n",
185 dest_srv
, (int)info_level
));
190 /* enumerate connections on server */
191 res
= res
? srv_net_srv_conn_enum(dest_srv
, qual_srv
,
192 info_level
, &ctr
, 0xffffffff, &hnd
) : False
;
196 display_srv_conn_info_ctr(out_hnd
, ACTION_HEADER
, &ctr
);
197 display_srv_conn_info_ctr(out_hnd
, ACTION_ENUMERATE
, &ctr
);
198 display_srv_conn_info_ctr(out_hnd
, ACTION_FOOTER
, &ctr
);
203 DEBUG(5,("cmd_srv_enum_conn: query succeeded\n"));
207 DEBUG(5,("cmd_srv_enum_conn: query failed\n"));
211 /****************************************************************************
213 ****************************************************************************/
214 void cmd_srv_enum_shares(struct client_info
*info
, int argc
, char *argv
[])
217 SRV_SHARE_INFO_CTR ctr
;
219 uint32 info_level
= 1;
225 fstrcpy(dest_srv
, "\\\\");
226 fstrcat(dest_srv
, info
->dest_host
);
231 info_level
= (uint32
)strtol(argv
[1], (char**)NULL
, 10);
234 DEBUG(4,("cmd_srv_enum_shares: server:%s info level: %d\n",
235 dest_srv
, (int)info_level
));
240 /* enumerate shares_files on server */
241 res
= res
? srv_net_srv_share_enum(dest_srv
,
242 info_level
, &ctr
, 0xffffffff, &hnd
) : False
;
246 display_srv_share_info_ctr(out_hnd
, ACTION_HEADER
, &ctr
);
247 display_srv_share_info_ctr(out_hnd
, ACTION_ENUMERATE
, &ctr
);
248 display_srv_share_info_ctr(out_hnd
, ACTION_FOOTER
, &ctr
);
251 srv_free_srv_share_ctr(&ctr
);
255 DEBUG(5,("cmd_srv_enum_shares: query succeeded\n"));
259 DEBUG(5,("cmd_srv_enum_shares: query failed\n"));
263 /****************************************************************************
265 ****************************************************************************/
266 void cmd_srv_enum_sess(struct client_info
*info
, int argc
, char *argv
[])
269 SRV_SESS_INFO_CTR ctr
;
271 uint32 info_level
= 0;
277 fstrcpy(dest_srv
, "\\\\");
278 fstrcat(dest_srv
, info
->dest_host
);
283 info_level
= (uint32
)strtol(argv
[1], (char**)NULL
, 10);
286 DEBUG(4,("cmd_srv_enum_sess: server:%s info level: %d\n",
287 dest_srv
, (int)info_level
));
292 /* enumerate sessions on server */
293 res
= res
? srv_net_srv_sess_enum(dest_srv
, NULL
, NULL
,
294 info_level
, &ctr
, 0x1000, &hnd
) : False
;
298 display_srv_sess_info_ctr(out_hnd
, ACTION_HEADER
, &ctr
);
299 display_srv_sess_info_ctr(out_hnd
, ACTION_ENUMERATE
, &ctr
);
300 display_srv_sess_info_ctr(out_hnd
, ACTION_FOOTER
, &ctr
);
305 DEBUG(5,("cmd_srv_enum_sess: query succeeded\n"));
309 DEBUG(5,("cmd_srv_enum_sess: query failed\n"));
313 /****************************************************************************
315 ****************************************************************************/
316 void cmd_srv_enum_files(struct client_info
*info
, int argc
, char *argv
[])
319 SRV_FILE_INFO_CTR ctr
;
321 uint32 info_level
= 3;
327 fstrcpy(dest_srv
, "\\\\");
328 fstrcat(dest_srv
, info
->dest_host
);
333 info_level
= (uint32
)strtol(argv
[1], (char**)NULL
, 10);
336 DEBUG(4,("cmd_srv_enum_files: server:%s info level: %d\n",
337 dest_srv
, (int)info_level
));
342 /* enumerate files on server */
343 res
= res
? srv_net_srv_file_enum(dest_srv
, NULL
, 0,
344 info_level
, &ctr
, 0x1000, &hnd
) : False
;
348 display_srv_file_info_ctr(out_hnd
, ACTION_HEADER
, &ctr
);
349 display_srv_file_info_ctr(out_hnd
, ACTION_ENUMERATE
, &ctr
);
350 display_srv_file_info_ctr(out_hnd
, ACTION_FOOTER
, &ctr
);
353 srv_free_srv_file_ctr(&ctr
);
357 DEBUG(5,("cmd_srv_enum_files: query succeeded\n"));
361 DEBUG(5,("cmd_srv_enum_files: query failed\n"));
365 /****************************************************************************
367 ****************************************************************************/
368 void cmd_time(struct client_info
*info
, int argc
, char *argv
[])
371 TIME_OF_DAY_INFO tod
;
374 fstrcpy(dest_srv
, "\\\\");
375 fstrcat(dest_srv
, info
->dest_host
);
378 DEBUG(4,("cmd_time: server:%s\n", dest_srv
));
380 /* enumerate files on server */
381 res
= res
? srv_net_remote_tod(dest_srv
, &tod
) : False
;
385 fprintf(out_hnd
, "\tRemote Time:\t%s\n\n",
386 http_timestring(tod
.elapsedt
));
391 DEBUG(5,("cmd_srv_enum_files: query succeeded\n"));
395 DEBUG(5,("cmd_srv_enum_files: query failed\n"));