xref: /titanic_50/usr/src/lib/smbsrv/libsmbns/common/libsmbns.h (revision e38a713ad4e0a9c42f8cccd9350412b2c6ccccdb)
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 2008 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 void ads_init(void);
78 extern void ads_refresh(void);
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 extern adjoin_status_t ads_join(char *, char *, char *, char *, int);
90 extern char *adjoin_report_err(adjoin_status_t status);
91 extern int ads_domain_change_cleanup(char *);
92 
93 /* DYNDNS functions */
94 extern int dns_msgid_init(void);
95 extern int dyndns_update(void);
96 extern int dyndns_clear_rev_zone(void);
97 
98 /* Kerberos initialization function */
99 extern int smb_kinit(char *user, char *passwd);
100 
101 
102 /* NETBIOS Functions */
103 extern int msdcs_lookup_ads(char *);
104 extern int smb_netbios_start(void);
105 extern void smb_netbios_shutdown(void);
106 extern void smb_netbios_name_reconfig(void);
107 
108 /* Browser Configure */
109 extern void smb_browser_config(void);
110 
111 extern void smb_netlogon_request(int, int, char *);
112 
113 /*
114  * NIC listing and config
115  */
116 #define	MAXIFS	256
117 #define	SIZE_IP	17
118 
119 typedef struct {
120 	char		ifname[LIFNAMSIZ];
121 	uint32_t	ip;
122 	uint32_t	mask;
123 	uint32_t	broadcast;
124 	boolean_t	exclude;
125 	uint64_t	flags;
126 	char		groupname[LIFGRNAMSIZ];
127 	char		**aliases;
128 	int		naliases;
129 } net_cfg_t;
130 typedef struct {
131 	net_cfg_t	*net_cfg_list;
132 	int		net_cfg_cnt;
133 } net_cfg_list_t;
134 
135 struct if_list {
136 	char		name[IFNAMSIZ+1];
137 	struct if_list	*next;
138 };
139 
140 struct ip_alias {
141 	char		name[SIZE_IP];
142 	struct ip_alias	*next;
143 };
144 
145 #define	GATEWAY_FILE	"/etc/defaultrouter"
146 
147 /* NIC Config functions */
148 extern int smb_get_nameservers(struct in_addr *, int);
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