xref: /titanic_50/usr/src/lib/smbsrv/libsmbns/common/libsmbns.h (revision d4517e84e3ffaa7bc4207a17f694c309904e7c48)
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	SIZE_IP	17
117 
118 typedef struct {
119 	char		ifname[LIFNAMSIZ];
120 	uint32_t	ip;
121 	uint32_t	mask;
122 	uint32_t	broadcast;
123 	uint64_t	flags;
124 	boolean_t	exclude;
125 } net_cfg_t;
126 
127 #define	GATEWAY_FILE	"/etc/defaultrouter"
128 
129 /* NIC Config functions */
130 extern int smb_get_nameservers(struct in_addr *, int);
131 extern void smb_nic_build_info(void);
132 extern net_cfg_t *smb_nic_get_byind(int, net_cfg_t *);
133 extern net_cfg_t *smb_nic_get_bysubnet(uint32_t, net_cfg_t *);
134 extern net_cfg_t *smb_nic_get_byip(uint32_t, net_cfg_t *);
135 extern int smb_nic_get_num(void);
136 extern boolean_t smb_nic_status(char *, uint64_t);
137 
138 #ifdef	__cplusplus
139 }
140 #endif
141 
142 #endif	/* _LIBSMBNS_H */
143