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.
26 #include "rpcclient.h"
28 /* Display server query info */
30 static char *get_server_type_str(uint32 type)
32 static fstring typestr;
35 if (type == SV_TYPE_ALL) {
36 fstrcpy(typestr, "All");
42 for (i = 0; i < 32; i++) {
43 if (type & (1 << i)) {
45 case SV_TYPE_WORKSTATION:
46 fstrcat(typestr, "Wk ");
49 fstrcat(typestr, "Sv ");
51 case SV_TYPE_SQLSERVER:
52 fstrcat(typestr, "Sql ");
54 case SV_TYPE_DOMAIN_CTRL:
55 fstrcat(typestr, "PDC ");
57 case SV_TYPE_DOMAIN_BAKCTRL:
58 fstrcat(typestr, "BDC ");
60 case SV_TYPE_TIME_SOURCE:
61 fstrcat(typestr, "Tim ");
64 fstrcat(typestr, "AFP ");
67 fstrcat(typestr, "Nov ");
69 case SV_TYPE_DOMAIN_MEMBER:
70 fstrcat(typestr, "Dom ");
72 case SV_TYPE_PRINTQ_SERVER:
73 fstrcat(typestr, "PrQ ");
75 case SV_TYPE_DIALIN_SERVER:
76 fstrcat(typestr, "Din ");
78 case SV_TYPE_SERVER_UNIX:
79 fstrcat(typestr, "Unx ");
82 fstrcat(typestr, "NT ");
85 fstrcat(typestr, "Wfw ");
87 case SV_TYPE_SERVER_MFPN:
88 fstrcat(typestr, "Mfp ");
90 case SV_TYPE_SERVER_NT:
91 fstrcat(typestr, "SNT ");
93 case SV_TYPE_POTENTIAL_BROWSER:
94 fstrcat(typestr, "PtB ");
96 case SV_TYPE_BACKUP_BROWSER:
97 fstrcat(typestr, "BMB ");
99 case SV_TYPE_MASTER_BROWSER:
100 fstrcat(typestr, "LMB ");
102 case SV_TYPE_DOMAIN_MASTER:
103 fstrcat(typestr, "DMB ");
105 case SV_TYPE_SERVER_OSF:
106 fstrcat(typestr, "OSF ");
108 case SV_TYPE_SERVER_VMS:
109 fstrcat(typestr, "VMS ");
111 case SV_TYPE_WIN95_PLUS:
112 fstrcat(typestr, "W95 ");
114 case SV_TYPE_ALTERNATE_XPORT:
115 fstrcat(typestr, "Xpt ");
117 case SV_TYPE_LOCAL_LIST_ONLY:
118 fstrcat(typestr, "Dom ");
120 case SV_TYPE_DOMAIN_ENUM:
121 fstrcat(typestr, "Loc ");
127 i = strlen(typestr) - 1;
129 if (typestr[i] == ' ')
135 static void display_server(char *sname, uint32 type, const char *comment)
137 printf("\t%-15.15s%-20s %s\n", sname, get_server_type_str(type),
141 static void display_srv_info_101(SRV_INFO_101 *sv101)
146 unistr2_to_ascii(name, &sv101->uni_name, sizeof(name) - 1);
147 unistr2_to_ascii(comment, &sv101->uni_comment, sizeof(comment) - 1);
149 display_server(name, sv101->srv_type, comment);
151 printf("\tplatform_id :\t%d\n", sv101->platform_id);
152 printf("\tos version :\t%d.%d\n", sv101->ver_major,
155 printf("\tserver type :\t0x%x\n", sv101->srv_type);
158 static void display_srv_info_102(SRV_INFO_102 *sv102)
164 unistr2_to_ascii(name, &sv102->uni_name, sizeof(name) - 1);
165 unistr2_to_ascii(comment, &sv102->uni_comment, sizeof(comment) - 1);
166 unistr2_to_ascii(usr_path, &sv102->uni_usr_path, sizeof(usr_path) - 1);
168 display_server(name, sv102->srv_type, comment);
170 printf("\tplatform_id :\t%d\n", sv102->platform_id);
171 printf("\tos version :\t%d.%d\n", sv102->ver_major,
174 printf("\tusers :\t%x\n", sv102->users);
175 printf("\tdisc, hidden :\t%x, %x\n", sv102->disc, sv102->hidden);
176 printf("\tannounce, delta :\t%d, %d\n", sv102->announce,
178 printf("\tlicenses :\t%d\n", sv102->licenses);
179 printf("\tuser path :\t%s\n", usr_path);
182 /* Server query info */
184 static NTSTATUS cmd_srvsvc_srv_query_info(struct cli_state *cli,
186 int argc, char **argv)
188 uint32 info_level = 101;
190 NTSTATUS result = NT_STATUS_UNSUCCESSFUL;
193 printf("Usage: %s [infolevel]\n", argv[0]);
198 info_level = atoi(argv[1]);
200 result = cli_srvsvc_net_srv_get_info(cli, mem_ctx, info_level,
203 if (!NT_STATUS_IS_OK(result)) {
207 /* Display results */
209 switch (info_level) {
211 display_srv_info_101(&ctr.srv.sv101);
214 display_srv_info_102(&ctr.srv.sv102);
217 printf("unsupported info level %d\n", info_level);
225 /* List of commands exported by this module */
227 struct cmd_set srvsvc_commands[] = {
231 { "srvinfo", cmd_srvsvc_srv_query_info, PIPE_SRVSVC, "Server query info", "" },