2
* Unix SMB/CIFS implementation.
3
* NetServerGetInfo query
4
* Copyright (C) Guenther Deschner 2008
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 3 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, see <http://www.gnu.org/licenses/>.
20
#include <sys/types.h>
30
int main(int argc, const char **argv)
32
NET_API_STATUS status;
33
struct libnetapi_ctx *ctx = NULL;
34
const char *hostname = NULL;
35
uint8_t *buffer = NULL;
38
struct SERVER_INFO_100 *i100;
39
struct SERVER_INFO_101 *i101;
40
struct SERVER_INFO_102 *i102;
41
struct SERVER_INFO_402 *i402;
42
struct SERVER_INFO_403 *i403;
43
struct SERVER_INFO_502 *i502;
44
struct SERVER_INFO_503 *i503;
45
struct SERVER_INFO_1005 *i1005;
50
struct poptOption long_options[] = {
52
POPT_COMMON_LIBNETAPI_EXAMPLES
56
status = libnetapi_init(&ctx);
61
pc = poptGetContext("server_getinfo", argc, argv, long_options, 0);
63
poptSetOtherOptionHelp(pc, "hostname level");
64
while((opt = poptGetNextOpt(pc)) != -1) {
67
if (!poptPeekArg(pc)) {
68
poptPrintHelp(pc, stderr, 0);
71
hostname = poptGetArg(pc);
73
if (poptPeekArg(pc)) {
74
level = atoi(poptGetArg(pc));
77
/* NetServerGetInfo */
79
status = NetServerGetInfo(hostname,
83
printf("NetServerGetInfo failed with: %s\n",
84
libnetapi_get_error_string(ctx, status));
90
i100 = (struct SERVER_INFO_100 *)buffer;
91
printf("platform id: %d\n", i100->sv100_platform_id);
92
printf("name: %s\n", i100->sv100_name);
95
i101 = (struct SERVER_INFO_101 *)buffer;
96
printf("platform id: %d\n", i101->sv101_platform_id);
97
printf("name: %s\n", i101->sv101_name);
98
printf("version major: %d\n", i101->sv101_version_major);
99
printf("version minor: %d\n", i101->sv101_version_minor);
100
printf("type: 0x%08x\n", i101->sv101_type);
101
printf("comment: %s\n", i101->sv101_comment);
104
i102 = (struct SERVER_INFO_102 *)buffer;
105
printf("platform id: %d\n", i102->sv102_platform_id);
106
printf("name: %s\n", i102->sv102_name);
107
printf("version major: %d\n", i102->sv102_version_major);
108
printf("version minor: %d\n", i102->sv102_version_minor);
109
printf("type: 0x%08x\n", i102->sv102_type);
110
printf("comment: %s\n", i102->sv102_comment);
111
printf("users: %d\n", i102->sv102_users);
112
printf("disc: %d\n", i102->sv102_disc);
113
printf("hidden: %d\n", i102->sv102_hidden);
114
printf("announce: %d\n", i102->sv102_announce);
115
printf("anndelta: %d\n", i102->sv102_anndelta);
116
printf("licenses: %d\n", i102->sv102_licenses);
117
printf("userpath: %s\n", i102->sv102_userpath);
120
i402 = (struct SERVER_INFO_402 *)buffer;
123
i403 = (struct SERVER_INFO_403 *)buffer;
126
i502 = (struct SERVER_INFO_502 *)buffer;
129
i503 = (struct SERVER_INFO_503 *)buffer;
132
i1005 = (struct SERVER_INFO_1005 *)buffer;
133
printf("comment: %s\n", i1005->sv1005_comment);