xref: /titanic_52/usr/src/lib/libadutils/common/addisc_impl.h (revision b3700b074e637f8c6991b70754c88a2cfffb246b)
1*b3700b07SGordon Ross /*
2*b3700b07SGordon Ross  * CDDL HEADER START
3*b3700b07SGordon Ross  *
4*b3700b07SGordon Ross  * The contents of this file are subject to the terms of the
5*b3700b07SGordon Ross  * Common Development and Distribution License (the "License").
6*b3700b07SGordon Ross  * You may not use this file except in compliance with the License.
7*b3700b07SGordon Ross  *
8*b3700b07SGordon Ross  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*b3700b07SGordon Ross  * or http://www.opensolaris.org/os/licensing.
10*b3700b07SGordon Ross  * See the License for the specific language governing permissions
11*b3700b07SGordon Ross  * and limitations under the License.
12*b3700b07SGordon Ross  *
13*b3700b07SGordon Ross  * When distributing Covered Code, include this CDDL HEADER in each
14*b3700b07SGordon Ross  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*b3700b07SGordon Ross  * If applicable, add the following below this CDDL HEADER, with the
16*b3700b07SGordon Ross  * fields enclosed by brackets "[]" replaced with your own identifying
17*b3700b07SGordon Ross  * information: Portions Copyright [yyyy] [name of copyright owner]
18*b3700b07SGordon Ross  *
19*b3700b07SGordon Ross  * CDDL HEADER END
20*b3700b07SGordon Ross  */
21*b3700b07SGordon Ross /*
22*b3700b07SGordon Ross  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
23*b3700b07SGordon Ross  * Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
24*b3700b07SGordon Ross  */
25*b3700b07SGordon Ross 
26*b3700b07SGordon Ross #ifndef	_ADDISC_IMPL_H
27*b3700b07SGordon Ross #define	_ADDISC_IMPL_H
28*b3700b07SGordon Ross 
29*b3700b07SGordon Ross #include <stdlib.h>
30*b3700b07SGordon Ross #include <stdio.h>
31*b3700b07SGordon Ross #include <sys/types.h>
32*b3700b07SGordon Ross #include <resolv.h>
33*b3700b07SGordon Ross #include <ldap.h>
34*b3700b07SGordon Ross #include <pthread.h>
35*b3700b07SGordon Ross #include "addisc.h"
36*b3700b07SGordon Ross #include "libadutils.h"
37*b3700b07SGordon Ross 
38*b3700b07SGordon Ross #ifdef	__cplusplus
39*b3700b07SGordon Ross extern "C" {
40*b3700b07SGordon Ross #endif
41*b3700b07SGordon Ross 
42*b3700b07SGordon Ross enum ad_item_state {
43*b3700b07SGordon Ross 		AD_STATE_INVALID = 0,	/* The value is not valid */
44*b3700b07SGordon Ross 		AD_STATE_FIXED,		/* The value was fixed by caller */
45*b3700b07SGordon Ross 		AD_STATE_AUTO		/* The value is auto discovered */
46*b3700b07SGordon Ross 		};
47*b3700b07SGordon Ross 
48*b3700b07SGordon Ross enum ad_data_type {
49*b3700b07SGordon Ross 		AD_STRING = 123,
50*b3700b07SGordon Ross 		AD_UUID,
51*b3700b07SGordon Ross 		AD_DIRECTORY,
52*b3700b07SGordon Ross 		AD_DOMAINS_IN_FOREST,
53*b3700b07SGordon Ross 		AD_TRUSTED_DOMAINS
54*b3700b07SGordon Ross 		};
55*b3700b07SGordon Ross 
56*b3700b07SGordon Ross 
57*b3700b07SGordon Ross typedef struct ad_subnet {
58*b3700b07SGordon Ross 	char subnet[24];
59*b3700b07SGordon Ross } ad_subnet_t;
60*b3700b07SGordon Ross 
61*b3700b07SGordon Ross 
62*b3700b07SGordon Ross typedef struct ad_item {
63*b3700b07SGordon Ross 	enum ad_item_state	state;
64*b3700b07SGordon Ross 	enum ad_data_type	type;
65*b3700b07SGordon Ross 	void 			*value;
66*b3700b07SGordon Ross 	time_t 			expires;
67*b3700b07SGordon Ross 	unsigned int 		version;	/* Version is only changed */
68*b3700b07SGordon Ross 						/* if the value changes */
69*b3700b07SGordon Ross #define	PARAM1		0
70*b3700b07SGordon Ross #define	PARAM2		1
71*b3700b07SGordon Ross 	int 		param_version[2];
72*b3700b07SGordon Ross 					/* These holds the version of */
73*b3700b07SGordon Ross 					/* dependents so that a dependent */
74*b3700b07SGordon Ross 					/* change can be detected */
75*b3700b07SGordon Ross } ad_item_t;
76*b3700b07SGordon Ross 
77*b3700b07SGordon Ross typedef struct ad_disc {
78*b3700b07SGordon Ross 	struct __res_state res_state;
79*b3700b07SGordon Ross 	int		res_ninitted;
80*b3700b07SGordon Ross 	ad_subnet_t	*subnets;
81*b3700b07SGordon Ross 	boolean_t	subnets_changed;
82*b3700b07SGordon Ross 	time_t		subnets_last_check;
83*b3700b07SGordon Ross 	time_t		expires_not_before;
84*b3700b07SGordon Ross 	time_t		expires_not_after;
85*b3700b07SGordon Ross 	ad_item_t	domain_name;		/* DNS hostname string */
86*b3700b07SGordon Ross 	ad_item_t	domain_guid;		/* Domain UUID (binary) */
87*b3700b07SGordon Ross 	ad_item_t	domain_controller;	/* Directory hostname and */
88*b3700b07SGordon Ross 						/* port array */
89*b3700b07SGordon Ross 	ad_item_t	preferred_dc;
90*b3700b07SGordon Ross 	ad_item_t	site_name;		/* String */
91*b3700b07SGordon Ross 	ad_item_t	forest_name;		/* DNS forestname string */
92*b3700b07SGordon Ross 	ad_item_t	global_catalog;		/* Directory hostname and */
93*b3700b07SGordon Ross 						/* port array */
94*b3700b07SGordon Ross 	ad_item_t	domains_in_forest;	/* DNS domainname and SID */
95*b3700b07SGordon Ross 						/* array */
96*b3700b07SGordon Ross 	ad_item_t	trusted_domains;	/* DNS domainname and trust */
97*b3700b07SGordon Ross 						/* direction array */
98*b3700b07SGordon Ross 	/* Site specfic versions */
99*b3700b07SGordon Ross 	ad_item_t	site_domain_controller;	/* Directory hostname and */
100*b3700b07SGordon Ross 						/* port array */
101*b3700b07SGordon Ross 	ad_item_t	site_global_catalog;	/* Directory hostname and */
102*b3700b07SGordon Ross 						/* port array */
103*b3700b07SGordon Ross 	/* Optional FILE * for DC Location status. */
104*b3700b07SGordon Ross 	struct __FILE_TAG *status_fp;
105*b3700b07SGordon Ross 
106*b3700b07SGordon Ross 	int		debug[AD_DEBUG_MAX+1];	/* Debug levels */
107*b3700b07SGordon Ross } ad_disc;
108*b3700b07SGordon Ross 
109*b3700b07SGordon Ross /* Candidate Directory Servers (CDS) */
110*b3700b07SGordon Ross typedef struct ad_disc_cds {
111*b3700b07SGordon Ross 	struct ad_disc_ds cds_ds;
112*b3700b07SGordon Ross 	struct addrinfo *cds_ai;
113*b3700b07SGordon Ross } ad_disc_cds_t;
114*b3700b07SGordon Ross 
115*b3700b07SGordon Ross ad_disc_ds_t *ldap_ping(ad_disc_t, ad_disc_cds_t *, char *, int);
116*b3700b07SGordon Ross 
117*b3700b07SGordon Ross int srv_getdom(res_state, const char *, char **);
118*b3700b07SGordon Ross ad_disc_cds_t *srv_query(res_state, const char *, const char *,
119*b3700b07SGordon Ross     ad_disc_ds_t *);
120*b3700b07SGordon Ross void srv_free(ad_disc_cds_t *);
121*b3700b07SGordon Ross 
122*b3700b07SGordon Ross void auto_set_DomainGUID(ad_disc_t, uchar_t *);
123*b3700b07SGordon Ross void auto_set_ForestName(ad_disc_t, char *);
124*b3700b07SGordon Ross void auto_set_SiteName(ad_disc_t, char *);
125*b3700b07SGordon Ross 
126*b3700b07SGordon Ross #ifdef	__cplusplus
127*b3700b07SGordon Ross }
128*b3700b07SGordon Ross #endif
129*b3700b07SGordon Ross 
130*b3700b07SGordon Ross #endif	/* _ADDISC_IMPL_H */
131