1 /*
2  * Unix SMB/CIFS implementation.
3  * Copyright (C) Volker Lendecke 2018
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef __LIBSMB_NAMEQUERY_H__
20 #define __LIBSMB_NAMEQUERY_H__
21 
22 #include "includes.h"
23 #include <tevent.h>
24 
25 /* The following definitions come from libsmb/namequery.c  */
26 
27 bool saf_store( const char *domain, const char *servername );
28 bool saf_join_store( const char *domain, const char *servername );
29 bool saf_delete( const char *domain );
30 char *saf_fetch(TALLOC_CTX *mem_ctx, const char *domain );
31 struct tevent_req *node_status_query_send(TALLOC_CTX *mem_ctx,
32 					  struct tevent_context *ev,
33 					  struct nmb_name *name,
34 					  const struct sockaddr_storage *addr);
35 NTSTATUS node_status_query_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
36 				struct node_status **pnode_status,
37 				int *pnum_names,
38 				struct node_status_extra *extra);
39 NTSTATUS node_status_query(TALLOC_CTX *mem_ctx, struct nmb_name *name,
40 			   const struct sockaddr_storage *addr,
41 			   struct node_status **pnode_status,
42 			   int *pnum_names,
43 			   struct node_status_extra *extra);
44 bool name_status_find(const char *q_name,
45 			int q_type,
46 			int type,
47 			const struct sockaddr_storage *to_ss,
48 			fstring name);
49 int remove_duplicate_addrs2(struct ip_service *iplist, int count );
50 struct tevent_req *name_query_send(TALLOC_CTX *mem_ctx,
51 				   struct tevent_context *ev,
52 				   const char *name, int name_type,
53 				   bool bcast, bool recurse,
54 				   const struct sockaddr_storage *addr);
55 NTSTATUS name_query_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
56 			 struct sockaddr_storage **addrs, int *num_addrs,
57 			 uint8_t *flags);
58 NTSTATUS name_query(const char *name, int name_type,
59 		    bool bcast, bool recurse,
60 		    const struct sockaddr_storage *to_ss,
61 		    TALLOC_CTX *mem_ctx,
62 		    struct sockaddr_storage **addrs,
63 		    int *num_addrs, uint8_t *flags);
64 struct tevent_req *name_resolve_bcast_send(TALLOC_CTX *mem_ctx,
65 					   struct tevent_context *ev,
66 					   const char *name,
67 					   int name_type);
68 NTSTATUS name_resolve_bcast_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
69 				 struct sockaddr_storage **addrs,
70 				 int *num_addrs);
71 NTSTATUS name_resolve_bcast(const char *name,
72 			int name_type,
73 			TALLOC_CTX *mem_ctx,
74 			struct sockaddr_storage **return_iplist,
75 			int *return_count);
76 struct tevent_req *resolve_wins_send(TALLOC_CTX *mem_ctx,
77 				     struct tevent_context *ev,
78 				     const char *name,
79 				     int name_type);
80 NTSTATUS resolve_wins_recv(struct tevent_req *req, TALLOC_CTX *mem_ctx,
81 			   struct sockaddr_storage **addrs,
82 			   int *num_addrs, uint8_t *flags);
83 NTSTATUS resolve_wins(const char *name,
84 		int name_type,
85 		TALLOC_CTX *mem_ctx,
86 		struct sockaddr_storage **return_iplist,
87 		int *return_count);
88 NTSTATUS internal_resolve_name(const char *name,
89 			        int name_type,
90 				const char *sitename,
91 				struct ip_service **return_iplist,
92 				int *return_count,
93 				const char **resolve_order);
94 bool resolve_name(const char *name,
95 		struct sockaddr_storage *return_ss,
96 		int name_type,
97 		bool prefer_ipv4);
98 NTSTATUS resolve_name_list(TALLOC_CTX *ctx,
99 		const char *name,
100 		int name_type,
101 		struct sockaddr_storage **return_ss_arr,
102 		unsigned int *p_num_entries);
103 bool find_master_ip(const char *group, struct sockaddr_storage *master_ss);
104 bool get_pdc_ip(const char *domain, struct sockaddr_storage *pss);
105 NTSTATUS get_sorted_dc_list( const char *domain,
106 			const char *sitename,
107 			struct ip_service **ip_list,
108 			int *count,
109 			bool ads_only );
110 NTSTATUS get_kdc_list( const char *realm,
111 			const char *sitename,
112 			struct ip_service **ip_list,
113 			int *count);
114 
115 #endif
116