xref: /titanic_44/usr/src/lib/smbsrv/libsmbns/common/libsmbns.h (revision 986fd29a0dc13f7608ef7f508f6e700bd7bc2720)
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 *domain;		/* ADS domain */
47 	char *domain_dn;	/* domain in Distinquish Name format */
48 	char *ip_addr;		/* ip addr in string format */
49 	char *hostname;		/* fully qualified hostname */
50 	char *site;		/* local ADS site */
51 	LDAP *ld;		/* LDAP handle */
52 } ADS_HANDLE;
53 
54 /*
55  * The possible return status of the adjoin routine.
56  */
57 typedef enum adjoin_status {
58 	ADJOIN_SUCCESS = 0,
59 	ADJOIN_ERR_GET_HANDLE,
60 	ADJOIN_ERR_GEN_PASSWD,
61 	ADJOIN_ERR_ADD_TRUST_ACCT,
62 	ADJOIN_ERR_MOD_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_UPDATE_CNTRL_ATTR,
69 	ADJOIN_ERR_WRITE_KEYTAB,
70 	ADJOIN_ERR_IDMAP_SET_DOMAIN,
71 	ADJOIN_ERR_IDMAP_REFRESH,
72 	ADJOIN_ERR_SMB_REFRESH,
73 	ADJOIN_NUM_STATUS
74 } adjoin_status_t;
75 
76 /* ADS functions */
77 extern ADS_HANDLE *ads_open(void);
78 extern void ads_close(ADS_HANDLE *);
79 extern int ads_publish_share(ADS_HANDLE *, const char *, const char *,
80     const char *, const char *);
81 extern int ads_remove_share(ADS_HANDLE *, const char *, const char *,
82     const char *, const char *);
83 extern int ads_build_unc_name(char *, int, const char *, const char *);
84 extern int ads_lookup_share(ADS_HANDLE *, const char *, const char *, char *);
85 extern int ads_add_share(ADS_HANDLE *, const char *, const char *,
86     const char *);
87 extern int ads_domain_change_notify_handler(char *);
88 extern adjoin_status_t ads_join(char *, char *, char *, int);
89 extern char *adjoin_report_err(adjoin_status_t status);
90 
91 /* DYNDNS functions */
92 extern int dyndns_update(void);
93 extern int dyndns_clear_rev_zone(void);
94 
95 /* Kerberos initialization function */
96 extern int smb_kinit(char *user, char *passwd);
97 
98 
99 /* NETBIOS Functions */
100 extern int msdcs_lookup_ads(void);
101 extern void smb_netbios_start(void);
102 extern void smb_netbios_shutdown(void);
103 extern void smb_netbios_name_reconfig(void);
104 
105 /* Browser Configure */
106 extern void smb_browser_config(void);
107 
108 extern void smb_netlogon_request(int, int, char *);
109 
110 /*
111  * NIC listing and config
112  */
113 #define	MAXIFS	256
114 #define	SIZE_IP	17
115 
116 typedef struct {
117 	char		ifname[LIFNAMSIZ];
118 	uint32_t	ip;
119 	uint32_t	mask;
120 	uint32_t	broadcast;
121 	boolean_t	exclude;
122 	uint64_t	flags;
123 	char		groupname[LIFGRNAMSIZ];
124 	char		**aliases;
125 	int		naliases;
126 } net_cfg_t;
127 typedef struct {
128 	net_cfg_t	*net_cfg_list;
129 	int		net_cfg_cnt;
130 } net_cfg_list_t;
131 
132 struct if_list {
133 	char		name[IFNAMSIZ+1];
134 	struct if_list	*next;
135 };
136 
137 struct ip_alias {
138 	char		name[SIZE_IP];
139 	struct ip_alias	*next;
140 };
141 
142 #define	GATEWAY_FILE	"/etc/defaultrouter"
143 
144 /* NIC Config functions */
145 extern void smb_resolver_init(void);
146 extern void smb_resolver_close(void);
147 extern int smb_get_nameservers(struct in_addr *, int);
148 extern uint16_t smb_get_next_resid(void);
149 extern void smb_nic_lock(void);
150 extern void smb_nic_unlock(void);
151 extern int smb_nic_init(void);
152 extern void smb_nic_build_info(void);
153 extern net_cfg_t *smb_nic_get_byind(int, net_cfg_t *);
154 extern net_cfg_t *smb_nic_get_bysubnet(uint32_t, net_cfg_t *);
155 extern net_cfg_t *smb_nic_get_byip(uint32_t, net_cfg_t *);
156 extern int smb_nic_get_num(void);
157 extern int smb_nic_get_IP(char *, uint32_t *uip);
158 extern int smb_nic_get_broadcast(char *, uint32_t *uip);
159 extern int smb_nic_get_netmask(char *, uint32_t *uip);
160 extern int smb_nic_get_IP_aliases(char *, struct ip_alias **);
161 extern int smb_nic_get_number(void);
162 extern int smb_nic_get_num_physical(void);
163 extern int smb_nic_get_num_logical(void);
164 extern int smb_nic_get_num_aliases(char *);
165 extern int smb_nic_get_default_gateway(char *, unsigned int);
166 extern int smb_nic_flags(char *, uint64_t *);
167 extern int smb_nic_build_if_name(char ***);
168 extern int smb_nic_build_network_structures(net_cfg_t **, int *);
169 extern char *smb_nic_get_ifnames(int, int);
170 extern int smb_nic_validate_ip_address(char *);
171 extern int smb_nic_status(char *, uint64_t);
172 extern int smb_nic_get_group(char *lifname, char *grname);
173 extern int smb_nic_set_group(char *lifname, char *grname);
174 extern int smb_nic_clear_niclist(net_cfg_t *, int);
175 extern int smb_nic_clear_name_list(char **, int);
176 extern int smb_nic_clear_ip_alias(struct ip_alias *);
177 
178 #ifdef	__cplusplus
179 }
180 #endif
181 
182 #endif	/* _LIBSMBNS_H */
183