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 /* Display server query info */
29 static char *get_server_type_str(uint32 type)
31 static fstring typestr;
34 if (type == SV_TYPE_ALL) {
35 fstrcpy(typestr, "All");
41 for (i = 0; i < 32; i++) {
42 if (type & (1 << i)) {
44 case SV_TYPE_WORKSTATION:
45 fstrcat(typestr, "Wk ");
48 fstrcat(typestr, "Sv ");
50 case SV_TYPE_SQLSERVER:
51 fstrcat(typestr, "Sql ");
53 case SV_TYPE_DOMAIN_CTRL:
54 fstrcat(typestr, "PDC ");
56 case SV_TYPE_DOMAIN_BAKCTRL:
57 fstrcat(typestr, "BDC ");
59 case SV_TYPE_TIME_SOURCE:
60 fstrcat(typestr, "Tim ");
63 fstrcat(typestr, "AFP ");
66 fstrcat(typestr, "Nov ");
68 case SV_TYPE_DOMAIN_MEMBER:
69 fstrcat(typestr, "Dom ");
71 case SV_TYPE_PRINTQ_SERVER:
72 fstrcat(typestr, "PrQ ");
74 case SV_TYPE_DIALIN_SERVER:
75 fstrcat(typestr, "Din ");
77 case SV_TYPE_SERVER_UNIX:
78 fstrcat(typestr, "Unx ");
81 fstrcat(typestr, "NT ");
84 fstrcat(typestr, "Wfw ");
86 case SV_TYPE_SERVER_MFPN:
87 fstrcat(typestr, "Mfp ");
89 case SV_TYPE_SERVER_NT:
90 fstrcat(typestr, "SNT ");
92 case SV_TYPE_POTENTIAL_BROWSER:
93 fstrcat(typestr, "PtB ");
95 case SV_TYPE_BACKUP_BROWSER:
96 fstrcat(typestr, "BMB ");
98 case SV_TYPE_MASTER_BROWSER:
99 fstrcat(typestr, "LMB ");
101 case SV_TYPE_DOMAIN_MASTER:
102 fstrcat(typestr, "DMB ");
104 case SV_TYPE_SERVER_OSF:
105 fstrcat(typestr, "OSF ");
107 case SV_TYPE_SERVER_VMS:
108 fstrcat(typestr, "VMS ");
110 case SV_TYPE_WIN95_PLUS:
111 fstrcat(typestr, "W95 ");
113 case SV_TYPE_ALTERNATE_XPORT:
114 fstrcat(typestr, "Xpt ");
116 case SV_TYPE_LOCAL_LIST_ONLY:
117 fstrcat(typestr, "Dom ");
119 case SV_TYPE_DOMAIN_ENUM:
120 fstrcat(typestr, "Loc ");
126 i = strlen(typestr) - 1;
128 if (typestr[i] == ' ')
134 static void display_server(char *sname, uint32 type, const char *comment)
136 printf("\t%-15.15s%-20s %s\n", sname, get_server_type_str(type),
140 static void display_srv_info_101(SRV_INFO_101 *sv101)
145 unistr2_to_ascii(name, &sv101->uni_name, sizeof(name) - 1);
146 unistr2_to_ascii(comment, &sv101->uni_comment, sizeof(comment) - 1);
148 display_server(name, sv101->srv_type, comment);
150 printf("\tplatform_id :\t%d\n", sv101->platform_id);
151 printf("\tos version :\t%d.%d\n", sv101->ver_major,
154 printf("\tserver type :\t0x%x\n", sv101->srv_type);
157 static void display_srv_info_102(SRV_INFO_102 *sv102)
163 unistr2_to_ascii(name, &sv102->uni_name, sizeof(name) - 1);
164 unistr2_to_ascii(comment, &sv102->uni_comment, sizeof(comment) - 1);
165 unistr2_to_ascii(usr_path, &sv102->uni_usr_path, sizeof(usr_path) - 1);
167 display_server(name, sv102->srv_type, comment);
169 printf("\tplatform_id :\t%d\n", sv102->platform_id);
170 printf("\tos version :\t%d.%d\n", sv102->ver_major,
173 printf("\tusers :\t%x\n", sv102->users);
174 printf("\tdisc, hidden :\t%x, %x\n", sv102->disc, sv102->hidden);
175 printf("\tannounce, delta :\t%d, %d\n", sv102->announce,
177 printf("\tlicenses :\t%d\n", sv102->licenses);
178 printf("\tuser path :\t%s\n", usr_path);
181 /* Server query info */
183 static NTSTATUS cmd_srvsvc_srv_query_info(struct cli_state *cli, int argc,
186 uint32 info_level = 101;
189 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
192 printf("Usage: %s [infolevel]\n", argv[0]);
197 info_level = atoi(argv[1]);
199 if (!(mem_ctx = talloc_init())) {
200 DEBUG(0,("cmd_srvsvc_srv_query_info: talloc_init failed\n"));
204 /* Initialise RPC connection */
206 if (!cli_nt_session_open (cli, PIPE_SRVSVC)) {
207 DEBUG(0, ("Could not initialize srvsvc pipe!\n"));
211 result = cli_srvsvc_net_srv_get_info(cli, mem_ctx, info_level,
213 if (!NT_STATUS_IS_OK(result)) {
217 /* Display results */
219 switch (info_level) {
221 display_srv_info_101(&ctr.srv.sv101);
224 display_srv_info_102(&ctr.srv.sv102);
227 printf("unsupported info level %d\n", info_level);
232 talloc_destroy(mem_ctx);
237 /* List of commands exported by this module */
239 struct cmd_set srvsvc_commands[] = {
243 { "srvinfo", cmd_srvsvc_srv_query_info, "Server query info", "" },