summaryrefslogtreecommitdiff
path: root/source3/libsmb
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2006-10-09 07:17:37 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:15:20 -0500
commitcfed7a5a71aab48b1d5b758df318b991a95592a5 (patch)
tree5ebaab4d9b2dd20067b8194b9102bf54c4cb255d /source3/libsmb
parentd63a3e05a23ffb016578c3daa8b48d6fc32e1e8c (diff)
downloadsamba-cfed7a5a71aab48b1d5b758df318b991a95592a5.tar.gz
samba-cfed7a5a71aab48b1d5b758df318b991a95592a5.tar.bz2
samba-cfed7a5a71aab48b1d5b758df318b991a95592a5.zip
r19184: W2k3 returns its name for the GetServerInfo RAP call. Do the same.
Implement 'net rap server name'. Volker (This used to be commit 919385ed2a2a07e848bc0baaac9ed3d1964d4386)
Diffstat (limited to 'source3/libsmb')
-rw-r--r--source3/libsmb/clirap2.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/source3/libsmb/clirap2.c b/source3/libsmb/clirap2.c
index 3c23310f66..d6a44f4ea2 100644
--- a/source3/libsmb/clirap2.c
+++ b/source3/libsmb/clirap2.c
@@ -1414,6 +1414,62 @@ BOOL cli_get_server_type(struct cli_state *cli, uint32 *pstype)
return(res == 0 || res == ERRmoredata);
}
+BOOL cli_get_server_name(TALLOC_CTX *mem_ctx, struct cli_state *cli,
+ char **servername)
+{
+ char *rparam = NULL;
+ char *rdata = NULL;
+ unsigned int rdrcnt,rprcnt;
+ char *p;
+ char param[WORDSIZE /* api number */
+ +sizeof(RAP_WserverGetInfo_REQ) /* req string */
+ +sizeof(RAP_SERVER_INFO_L1) /* return string */
+ +WORDSIZE /* info level */
+ +WORDSIZE]; /* buffer size */
+ BOOL res = False;
+ fstring tmp;
+
+ /* send a SMBtrans command with api NetServerGetInfo */
+ p = make_header(param, RAP_WserverGetInfo,
+ RAP_WserverGetInfo_REQ, RAP_SERVER_INFO_L1);
+ PUTWORD(p, 1); /* info level */
+ PUTWORD(p, CLI_BUFFER_SIZE);
+
+ if (!cli_api(cli,
+ param, PTR_DIFF(p,param), 8, /* params, length, max */
+ NULL, 0, CLI_BUFFER_SIZE, /* data, length, max */
+ &rparam, &rprcnt, /* return params, return size */
+ &rdata, &rdrcnt /* return data, return size */
+ )) {
+ goto failed;
+ }
+
+ if (GETRES(rparam) != 0) {
+ goto failed;
+ }
+
+ if (rdrcnt < 16) {
+ DEBUG(10, ("invalid data count %d, expected >= 16\n", rdrcnt));
+ goto failed;
+ }
+
+ if (pull_ascii(tmp, rdata, sizeof(tmp)-1, 16, STR_TERMINATE) == -1) {
+ DEBUG(10, ("pull_ascii failed\n"));
+ goto failed;
+ }
+
+ if (!(*servername = talloc_strdup(mem_ctx, tmp))) {
+ DEBUG(1, ("talloc_strdup failed\n"));
+ goto failed;
+ }
+
+ res = True;
+
+ failed:
+ SAFE_FREE(rparam);
+ SAFE_FREE(rdata);
+ return res;
+}
/*************************************************************************
*