2 Unix SMB/Netbios implementation.
6 Copyright (C) Andrew Tridgell 1992-1999
7 Copyright (C) Luke Kenneth Casson Leighton 1996 - 1999
8 Copyright (C) Tim Potter 2000
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 extern int DEBUGLEVEL;
29 /* Display server query info */
31 static char *get_server_type_str(uint32 type)
33 static fstring typestr;
36 if (type == SV_TYPE_ALL) {
37 fstrcpy(typestr, "All");
43 for (i = 0; i < 32; i++) {
44 if (type & (1 << i)) {
46 case SV_TYPE_WORKSTATION:
47 fstrcat(typestr, "Wk ");
50 fstrcat(typestr, "Sv ");
52 case SV_TYPE_SQLSERVER:
53 fstrcat(typestr, "Sql ");
55 case SV_TYPE_DOMAIN_CTRL:
56 fstrcat(typestr, "PDC ");
58 case SV_TYPE_DOMAIN_BAKCTRL:
59 fstrcat(typestr, "BDC ");
61 case SV_TYPE_TIME_SOURCE:
62 fstrcat(typestr, "Tim ");
65 fstrcat(typestr, "AFP ");
68 fstrcat(typestr, "Nov ");
70 case SV_TYPE_DOMAIN_MEMBER:
71 fstrcat(typestr, "Dom ");
73 case SV_TYPE_PRINTQ_SERVER:
74 fstrcat(typestr, "PrQ ");
76 case SV_TYPE_DIALIN_SERVER:
77 fstrcat(typestr, "Din ");
79 case SV_TYPE_SERVER_UNIX:
80 fstrcat(typestr, "Unx ");
83 fstrcat(typestr, "NT ");
86 fstrcat(typestr, "Wfw ");
88 case SV_TYPE_SERVER_MFPN:
89 fstrcat(typestr, "Mfp ");
91 case SV_TYPE_SERVER_NT:
92 fstrcat(typestr, "SNT ");
94 case SV_TYPE_POTENTIAL_BROWSER:
95 fstrcat(typestr, "PtB ");
97 case SV_TYPE_BACKUP_BROWSER:
98 fstrcat(typestr, "BMB ");
100 case SV_TYPE_MASTER_BROWSER:
101 fstrcat(typestr, "LMB ");
103 case SV_TYPE_DOMAIN_MASTER:
104 fstrcat(typestr, "DMB ");
106 case SV_TYPE_SERVER_OSF:
107 fstrcat(typestr, "OSF ");
109 case SV_TYPE_SERVER_VMS:
110 fstrcat(typestr, "VMS ");
112 case SV_TYPE_WIN95_PLUS:
113 fstrcat(typestr, "W95 ");
115 case SV_TYPE_ALTERNATE_XPORT:
116 fstrcat(typestr, "Xpt ");
118 case SV_TYPE_LOCAL_LIST_ONLY:
119 fstrcat(typestr, "Dom ");
121 case SV_TYPE_DOMAIN_ENUM:
122 fstrcat(typestr, "Loc ");
128 i = strlen(typestr) - 1;
130 if (typestr[i] == ' ')
136 static void display_server(char *sname, uint32 type, const char *comment)
138 printf("\t%-15.15s%-20s %s\n", sname, get_server_type_str(type),
142 static void display_srv_info_101(SRV_INFO_101 *sv101)
147 unistr2_to_ascii(name, &sv101->uni_name, sizeof(name) - 1);
148 unistr2_to_ascii(comment, &sv101->uni_comment, sizeof(comment) - 1);
150 display_server(name, sv101->srv_type, comment);
152 printf("\tplatform_id :\t%d\n", sv101->platform_id);
153 printf("\tos version :\t%d.%d\n", sv101->ver_major,
156 printf("\tserver type :\t0x%x\n", sv101->srv_type);
159 static void display_srv_info_102(SRV_INFO_102 *sv102)
165 unistr2_to_ascii(name, &sv102->uni_name, sizeof(name) - 1);
166 unistr2_to_ascii(comment, &sv102->uni_comment, sizeof(comment) - 1);
167 unistr2_to_ascii(usr_path, &sv102->uni_usr_path, sizeof(usr_path) - 1);
169 display_server(name, sv102->srv_type, comment);
171 printf("\tplatform_id :\t%d\n", sv102->platform_id);
172 printf("\tos version :\t%d.%d\n", sv102->ver_major,
175 printf("\tusers :\t%x\n", sv102->users);
176 printf("\tdisc, hidden :\t%x, %x\n", sv102->disc, sv102->hidden);
177 printf("\tannounce, delta :\t%d, %d\n", sv102->announce,
179 printf("\tlicenses :\t%d\n", sv102->licenses);
180 printf("\tuser path :\t%s\n", usr_path);
183 /* Server query info */
185 static NTSTATUS cmd_srvsvc_srv_query_info(struct cli_state *cli, int argc,
188 uint32 info_level = 101;
191 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
194 printf("Usage: %s [infolevel]\n", argv[0]);
199 info_level = atoi(argv[1]);
201 if (!(mem_ctx = talloc_init())) {
202 DEBUG(0,("cmd_srvsvc_srv_query_info: talloc_init failed\n"));
206 /* Initialise RPC connection */
208 if (!cli_nt_session_open (cli, PIPE_SRVSVC)) {
209 DEBUG(0, ("Could not initialize srvsvc pipe!\n"));
213 result = cli_srvsvc_net_srv_get_info(cli, mem_ctx, info_level,
215 if (!NT_STATUS_IS_OK(result)) {
219 /* Display results */
221 switch (info_level) {
223 display_srv_info_101(&ctr.srv.sv101);
226 display_srv_info_102(&ctr.srv.sv102);
229 printf("unsupported info level %d\n", info_level);
234 talloc_destroy(mem_ctx);
239 /* List of commands exported by this module */
241 struct cmd_set srvsvc_commands[] = {
245 { "srvinfo", cmd_srvsvc_srv_query_info, "Server query info", "" },