xref: /titanic_50/usr/src/lib/smbsrv/libsmbns/common/libsmbns.h (revision 582271e8d649568c83e9a016cc0d54265389c5d9)
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  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_LIBSMBNS_H
27 #define	_LIBSMBNS_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <ldap.h>
32 #include <net/if.h>
33 
34 #include <smbsrv/libsmb.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 /* ADS typedef/data structures and functions */
41 #define	ADS_MAXBUFLEN 100
42 
43 typedef struct ads_handle_s {
44 	char *user;		/* admin user to create share in ADS */
45 	char *pwd;		/* user password */
46 	char *container;	/* user container in ADS */
47 	char *domain;		/* ADS domain */
48 	char *domain_dn;	/* domain in Distinquish Name format */
49 	char *ip_addr;		/* ip addr in string format */
50 	char *hostname;		/* fully qualified hostname */
51 	char *site;		/* local ADS site */
52 	LDAP *ld;		/* LDAP handle */
53 } ADS_HANDLE;
54 
55 /*
56  * The possible return status of the adjoin routine.
57  */
58 typedef enum adjoin_status {
59 	ADJOIN_SUCCESS = 0,
60 	ADJOIN_ERR_GET_HANDLE,
61 	ADJOIN_ERR_GEN_PASSWD,
62 	ADJOIN_ERR_ADD_TRUST_ACCT,
63 	ADJOIN_ERR_GET_ENCTYPES,
64 	ADJOIN_ERR_GET_HOST_PRINC,
65 	ADJOIN_ERR_INIT_KRB_CTX,
66 	ADJOIN_ERR_GET_KRB_PRINC,
67 	ADJOIN_ERR_KSETPWD,
68 	ADJOIN_ERR_MOD_TRUST_ACCT,
69 	ADJOIN_ERR_WRITE_KEYTAB,
70 	ADJOIN_ERR_IDMAP_SET_DOMAIN,
71 	ADJOIN_ERR_IDMAP_SET_GC,
72 	ADJOIN_ERR_IDMAP_REFRESH,
73 	ADJOIN_ERR_IDMAP_CCACHE,
74 
75 	ADJOIN_NUM_STATUS
76 } adjoin_status_t;
77 
78 /* ADS functions */
79 extern ADS_HANDLE *ads_open(void);
80 extern void ads_close(ADS_HANDLE *);
81 extern int ads_publish_share(ADS_HANDLE *, const char *, const char *,
82     const char *, const char *);
83 extern int ads_remove_share(ADS_HANDLE *, const char *, const char *,
84     const char *, const char *);
85 extern int ads_build_unc_name(char *, int, const char *, const char *);
86 extern int ads_lookup_share(ADS_HANDLE *, const char *, const char *, char *);
87 extern int ads_add_share(ADS_HANDLE *, const char *, const char *,
88     const char *);
89 
90 extern adjoin_status_t adjoin(char *, int);
91 extern char *adjoin_report_err(adjoin_status_t status);
92 
93 /* DYNDNS functions */
94 extern int dyndns_update(void);
95 extern int dyndns_clear_rev_zone(void);
96 
97 /* Kerberos initialization function */
98 extern int smb_kinit(char *user, char *passwd);
99 
100 
101 /* NETBIOS Functions */
102 extern int msdcs_lookup_ads(void);
103 extern void smb_netbios_start(void);
104 extern void smb_netbios_shutdown(void);
105 extern void smb_netbios_name_reconfig(void);
106 
107 /* Browser Configure */
108 extern void smb_browser_config(void);
109 
110 extern void smb_netlogon_request(int, int, char *);
111 
112 /*
113  * NIC listing and config
114  */
115 #define	MAXIFS	256
116 #define	SIZE_IP	17
117 
118 typedef struct {
119 	char		ifname[LIFNAMSIZ];
120 	uint32_t	ip;
121 	uint32_t	mask;
122 	uint32_t	broadcast;
123 	boolean_t	exclude;
124 	uint64_t	flags;
125 	char		groupname[LIFGRNAMSIZ];
126 	char		**aliases;
127 	int		naliases;
128 } net_cfg_t;
129 typedef struct {
130 	net_cfg_t	*net_cfg_list;
131 	int		net_cfg_cnt;
132 } net_cfg_list_t;
133 
134 struct if_list {
135 	char		name[IFNAMSIZ+1];
136 	struct if_list	*next;
137 };
138 
139 struct ip_alias {
140 	char		name[SIZE_IP];
141 	struct ip_alias	*next;
142 };
143 
144 #define	GATEWAY_FILE	"/etc/defaultrouter"
145 
146 /* NIC Config functions */
147 extern void smb_resolver_init(void);
148 extern void smb_resolver_close(void);
149 extern int smb_get_nameservers(struct in_addr *, int);
150 extern uint16_t smb_get_next_resid(void);
151 extern void smb_nic_lock(void);
152 extern void smb_nic_unlock(void);
153 extern int smb_nic_init(void);
154 extern void smb_nic_build_info(void);
155 extern net_cfg_t *smb_nic_get_byind(int, net_cfg_t *);
156 extern net_cfg_t *smb_nic_get_bysubnet(uint32_t, net_cfg_t *);
157 extern net_cfg_t *smb_nic_get_byip(uint32_t, net_cfg_t *);
158 extern int smb_nic_get_num(void);
159 extern int smb_nic_get_IP(char *, uint32_t *uip);
160 extern int smb_nic_get_broadcast(char *, uint32_t *uip);
161 extern int smb_nic_get_netmask(char *, uint32_t *uip);
162 extern int smb_nic_get_IP_aliases(char *, struct ip_alias **);
163 extern int smb_nic_get_number(void);
164 extern int smb_nic_get_num_physical(void);
165 extern int smb_nic_get_num_logical(void);
166 extern int smb_nic_get_num_aliases(char *);
167 extern int smb_nic_get_default_gateway(char *, unsigned int);
168 extern int smb_nic_flags(char *, uint64_t *);
169 extern int smb_nic_build_if_name(char ***);
170 extern int smb_nic_build_network_structures(net_cfg_t **, int *);
171 extern char *smb_nic_get_ifnames(int, int);
172 extern int smb_nic_validate_ip_address(char *);
173 extern int smb_nic_status(char *, uint64_t);
174 extern int smb_nic_get_group(char *lifname, char *grname);
175 extern int smb_nic_set_group(char *lifname, char *grname);
176 extern int smb_nic_clear_niclist(net_cfg_t *, int);
177 extern int smb_nic_clear_name_list(char **, int);
178 extern int smb_nic_clear_ip_alias(struct ip_alias *);
179 
180 #ifdef	__cplusplus
181 }
182 #endif
183 
184 #endif	/* _LIBSMBNS_H */
185