xref: /illumos-gate/usr/src/lib/libadutils/common/addisc.h (revision b3700b074e637f8c6991b70754c88a2cfffb246b)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
25  */
26 
27 #ifndef	_ADINFO_H
28 #define	_ADINFO_H
29 
30 #include <sys/socket.h>
31 #include <sys/uuid.h>
32 #include "libadutils.h"
33 
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 /*
40  * Maximum string SID size. 4 bytes for "S-1-", 15 for 2^48 (max authority),
41  * another '-', and ridcount (max 15) 10-digit RIDs plus '-' in between, plus
42  * a null.
43  */
44 #define	MAXSTRSID		185
45 #define	MAXDOMAINNAME		256
46 #define	AD_DISC_MAXHOSTNAME	256
47 
48 typedef struct ad_disc *ad_disc_t;
49 
50 
51 typedef struct ad_disc_domains_in_forest {
52 	char domain[MAXDOMAINNAME];
53 	char sid[MAXSTRSID];
54 	int trusted;			/* This is not used by auto */
55 					/* discovery. It is provided so that */
56 					/* domains in a forest can be marked */
57 					/* as trusted. */
58 } ad_disc_domainsinforest_t;
59 
60 
61 typedef struct ad_disc_trusted_domains {
62 		char domain[MAXDOMAINNAME];
63 		int direction;
64 } ad_disc_trusteddomains_t;
65 
66 enum ad_disc_req {
67 		AD_DISC_PREFER_SITE = 0, /* Prefer Site specific version */
68 		AD_DISC_SITE_SPECIFIC,	/* Request Site specific version */
69 		AD_DISC_GLOBAL		/* Request global version */
70 };
71 
72 /*
73  * First four members of this are like idmap_ad_disc_ds_t
74  * (for compatiblity) until that can be eliminated.
75  * See PROP_DOMAIN_CONTROLLER in idmapd/server.c
76  */
77 typedef struct ad_disc_ds {
78 	/* Keep these first four in sync with idmap_ad_disc_ds_t */
79 	int port;
80 	int priority;
81 	int weight;
82 	char host[AD_DISC_MAXHOSTNAME];
83 	/* Members after this are private and free to change. */
84 	char site[AD_DISC_MAXHOSTNAME];
85 	struct sockaddr_storage addr;
86 	uint32_t flags;
87 	uint32_t ttl;
88 } ad_disc_ds_t;
89 
90 ad_disc_t ad_disc_init(void);
91 
92 void ad_disc_fini(ad_disc_t);
93 
94 /*
95  * The following routines auto discover the specific item
96  */
97 char *
98 ad_disc_get_DomainName(ad_disc_t ctx, boolean_t *auto_discovered);
99 
100 uchar_t *
101 ad_disc_get_DomainGUID(ad_disc_t ctx, boolean_t *auto_discovered);
102 
103 ad_disc_ds_t *
104 ad_disc_get_DomainController(ad_disc_t ctx,
105 		enum ad_disc_req req, boolean_t *auto_discovered);
106 
107 ad_disc_ds_t *
108 ad_disc_get_PreferredDC(ad_disc_t ctx, boolean_t *auto_discovered);
109 
110 char *
111 ad_disc_get_SiteName(ad_disc_t ctx, boolean_t *auto_discovered);
112 
113 char *
114 ad_disc_get_ForestName(ad_disc_t ctx, boolean_t *auto_discovered);
115 
116 ad_disc_ds_t *
117 ad_disc_get_GlobalCatalog(ad_disc_t ctx, enum ad_disc_req,
118 				boolean_t *auto_discovered);
119 
120 ad_disc_trusteddomains_t *
121 ad_disc_get_TrustedDomains(ad_disc_t ctx,  boolean_t *auto_discovered);
122 
123 ad_disc_domainsinforest_t *
124 ad_disc_get_DomainsInForest(ad_disc_t ctx,  boolean_t *auto_discovered);
125 
126 
127 /*
128  * The following routines over ride auto discovery with the
129  * specified values
130  */
131 int
132 ad_disc_set_DomainName(ad_disc_t ctx, const char *domainName);
133 
134 int
135 ad_disc_set_DomainGUID(ad_disc_t ctx, uchar_t *u);
136 
137 int
138 ad_disc_set_DomainController(ad_disc_t ctx,
139 		const ad_disc_ds_t *domainController);
140 int
141 ad_disc_set_PreferredDC(ad_disc_t ctx, const ad_disc_ds_t *dc);
142 
143 int
144 ad_disc_set_SiteName(ad_disc_t ctx, const char *siteName);
145 
146 int
147 ad_disc_set_ForestName(ad_disc_t ctx, const char *forestName);
148 
149 int
150 ad_disc_set_GlobalCatalog(ad_disc_t ctx,
151 		const ad_disc_ds_t *globalCatalog);
152 
153 /*
154  * This function sets a FILE * on which this library will write
155  * progress information during DC Location.
156  */
157 void
158 ad_disc_set_StatusFP(ad_disc_t ctx, struct __FILE_TAG *);
159 
160 int
161 ad_disc_getnameinfo(char *, int, struct sockaddr_storage *);
162 
163 /*
164  * This routine forces all auto discovery item to be recomputed
165  * on request
166  */
167 void ad_disc_refresh(ad_disc_t);
168 
169 /*
170  * This routine marks the end of a discovery cycle and sets
171  * the sanity limits on the time before the next cycle.
172  */
173 void ad_disc_done(ad_disc_t);
174 
175 /* This routine unsets all overridden values */
176 int ad_disc_unset(ad_disc_t ctx);
177 
178 /* This routine test for subnet changes */
179 boolean_t ad_disc_SubnetChanged(ad_disc_t);
180 
181 /* This routine returns the Time To Live for auto discovered items */
182 int ad_disc_get_TTL(ad_disc_t);
183 
184 int ad_disc_compare_uuid(uuid_t *u1, uuid_t *u2);
185 
186 int ad_disc_compare_ds(ad_disc_ds_t *ds1, ad_disc_ds_t *ds2);
187 
188 int ad_disc_compare_trusteddomains(ad_disc_trusteddomains_t *td1,
189 		ad_disc_trusteddomains_t *td2);
190 
191 int ad_disc_compare_domainsinforest(ad_disc_domainsinforest_t *td1,
192 		ad_disc_domainsinforest_t *td2);
193 
194 #ifdef __cplusplus
195 }
196 #endif
197 
198 #endif	/* _ADINFO_H */
199