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 (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. 23 * Copyright 2019 Nexenta by DDN, Inc. All rights reserved. 24 * Copyright 2024 RackTop Systems, Inc. 25 */ 26 27 #ifndef _LIBSMBNS_H 28 #define _LIBSMBNS_H 29 30 #include <ldap.h> 31 #include <smbsrv/libsmb.h> 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 /* ADS typedef/data structures and functions */ 38 39 40 typedef struct smb_ads_handle { 41 char *domain; /* ADS domain (in lower case) */ 42 char *domain_dn; /* domain in Distinquish Name format */ 43 char *ip_addr; /* ip addr in string format */ 44 char *hostname; /* fully qualified hostname */ 45 char *site; /* local ADS site */ 46 LDAP *ld; /* LDAP handle */ 47 } smb_ads_handle_t; 48 49 typedef struct smb_ads_host_info { 50 char name[MAXHOSTNAMELEN]; /* fully qualified hostname */ 51 int port; /* ldap port */ 52 int priority; /* DNS SRV record priority */ 53 int weight; /* DNS SRV record weight */ 54 uint32_t flags; /* DC flags */ 55 smb_inaddr_t ipaddr; /* network byte order */ 56 } smb_ads_host_info_t; 57 58 /* 59 * Return status codes for the ads functions. 60 */ 61 typedef enum smb_ads_status { 62 SMB_ADS_SUCCESS = 0, 63 /* errno values... */ 64 SMB_ADS_ERRNO_GAP = 200, 65 SMB_ADS_KRB5_INIT_CTX, 66 SMB_ADS_KRB5_CC_DEFAULT, 67 SMB_ADS_KRB5_PARSE_PRINCIPAL, 68 SMB_ADS_KRB5_GET_INIT_CREDS_OTHER, 69 SMB_ADS_KRB5_GET_INIT_CREDS_PW, 70 SMB_ADS_KRB5_GET_INIT_CREDS_SKEW, 71 SMB_ADS_KRB5_CC_INITIALIZE, 72 SMB_ADS_KRB5_CC_STORE_CRED, 73 SMB_ADS_CANT_LOCATE_DC, 74 SMB_ADS_LDAP_INIT, 75 SMB_ADS_LDAP_SETOPT, 76 SMB_ADS_LDAP_SET_DOM, 77 SMB_ADS_LDAP_SASL_BIND, 78 79 SMB_ADJOIN_ERR_GEN_PWD, 80 SMB_ADJOIN_ERR_GET_DCLEVEL, 81 SMB_ADJOIN_ERR_ADD_TRUST_ACCT, 82 SMB_ADJOIN_ERR_MOD_TRUST_ACCT, 83 SMB_ADJOIN_ERR_DUP_TRUST_ACCT, 84 SMB_ADJOIN_ERR_TRUST_ACCT, 85 SMB_ADJOIN_ERR_INIT_KRB_CTX, 86 SMB_ADJOIN_ERR_GET_SPNS, 87 SMB_ADJOIN_ERR_KSETPWD, 88 SMB_ADJOIN_ERR_UPDATE_CNTRL_ATTR, 89 SMB_ADJOIN_ERR_WRITE_KEYTAB, 90 SMB_ADJOIN_ERR_IDMAP_SET_DOMAIN, 91 SMB_ADJOIN_ERR_IDMAP_REFRESH, 92 SMB_ADJOIN_ERR_COMMIT_KEYTAB, 93 SMB_ADJOIN_ERR_AUTH_NETLOGON, 94 SMB_ADJOIN_ERR_STORE_PROPS, 95 SMB_ADJOIN_ERR_ALREADY_JOINED, 96 } smb_ads_status_t; 97 98 /* ADS functions */ 99 extern void smb_ads_init(void); 100 extern void smb_ads_fini(void); 101 extern void smb_ads_refresh(boolean_t); 102 extern smb_ads_handle_t *smb_ads_open(void); 103 extern void smb_ads_close(smb_ads_handle_t *); 104 extern int smb_ads_publish_share(smb_ads_handle_t *, const char *, const char *, 105 const char *, const char *); 106 extern int smb_ads_remove_share(smb_ads_handle_t *, const char *, const char *, 107 const char *, const char *); 108 extern int smb_ads_build_unc_name(char *, int, const char *, const char *); 109 extern int smb_ads_lookup_share(smb_ads_handle_t *, const char *, const char *, 110 char *); 111 extern int smb_ads_add_share(smb_ads_handle_t *, const char *, const char *, 112 const char *); 113 extern smb_ads_status_t smb_ads_join(char *, char *, char *, char *, char *); 114 extern void smb_ads_log_errmsg(smb_ads_status_t); 115 extern const char *smb_ads_strerror(int); 116 extern uint32_t smb_ads_lookup_msdcs(char *, smb_dcinfo_t *); 117 extern smb_ads_host_info_t *smb_ads_find_host(char *); 118 119 /* DYNDNS functions */ 120 extern void *dyndns_publisher(void *); 121 extern void dyndns_start(void); 122 extern void dyndns_stop(void); 123 extern int dyndns_update(char *); 124 extern void dyndns_update_zones(void); 125 extern void dyndns_clear_zones(void); 126 127 /* Kerberos cache management function */ 128 extern int smb_ccache_init(char *, char *); 129 extern void smb_ccache_remove(char *); 130 131 /* NETBIOS Functions */ 132 extern int smb_netbios_start(void); 133 extern void smb_netbios_stop(void); 134 extern void smb_netbios_name_reconfig(void); 135 136 /* Browser Functions */ 137 extern void smb_browser_reconfig(void); 138 extern boolean_t smb_browser_netlogon(char *, char *, uint32_t); 139 140 141 #ifdef __cplusplus 142 } 143 #endif 144 145 #endif /* _LIBSMBNS_H */ 146