r23792: convert Samba4 to GPLv3
[amitay/samba.git] / source4 / torture / nbt / browse.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    Browse service
5
6    (C) Jelmer Vernooij 2005
7    
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
12    
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
17    
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #include "includes.h"
23 #include "librpc/gen_ndr/nbt.h"
24 #include "libcli/resolve/resolve.h"
25 #include "torture/torture.h"
26
27 /*
28   test nbt dgram operations
29 */
30 BOOL torture_nbt_browse(struct torture_context *torture)
31 {
32         const char *address;
33         struct nbt_name name;
34         TALLOC_CTX *mem_ctx = talloc_new(NULL);
35         NTSTATUS status;
36         BOOL ret = True;
37         
38         name.name = lp_workgroup();
39         name.type = NBT_NAME_BROWSER;
40         name.scope = NULL;
41
42         /* do an initial name resolution to find its IP */
43         status = resolve_name(&name, mem_ctx, &address, NULL);
44         if (!NT_STATUS_IS_OK(status)) {
45                 printf("Failed to resolve %s - %s\n",
46                        name.name, nt_errstr(status));
47                 talloc_free(mem_ctx);
48                 return False;
49         }
50
51         talloc_free(mem_ctx);
52
53         return ret;
54 }