1613a2f6bSGordon Ross /* 2613a2f6bSGordon Ross * CDDL HEADER START 3613a2f6bSGordon Ross * 4613a2f6bSGordon Ross * The contents of this file are subject to the terms of the 5613a2f6bSGordon Ross * Common Development and Distribution License (the "License"). 6613a2f6bSGordon Ross * You may not use this file except in compliance with the License. 7613a2f6bSGordon Ross * 8613a2f6bSGordon Ross * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9613a2f6bSGordon Ross * or http://www.opensolaris.org/os/licensing. 10613a2f6bSGordon Ross * See the License for the specific language governing permissions 11613a2f6bSGordon Ross * and limitations under the License. 12613a2f6bSGordon Ross * 13613a2f6bSGordon Ross * When distributing Covered Code, include this CDDL HEADER in each 14613a2f6bSGordon Ross * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15613a2f6bSGordon Ross * If applicable, add the following below this CDDL HEADER, with the 16613a2f6bSGordon Ross * fields enclosed by brackets "[]" replaced with your own identifying 17613a2f6bSGordon Ross * information: Portions Copyright [yyyy] [name of copyright owner] 18613a2f6bSGordon Ross * 19613a2f6bSGordon Ross * CDDL HEADER END 20613a2f6bSGordon Ross */ 21613a2f6bSGordon Ross 22613a2f6bSGordon Ross /* 23613a2f6bSGordon Ross * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 24613a2f6bSGordon Ross * Use is subject to license terms. 25*fd75ca8dSGordon Ross * Copyright 2013 Nexenta Systems, Inc. All rights reserved. 26613a2f6bSGordon Ross */ 27613a2f6bSGordon Ross 28613a2f6bSGordon Ross #ifndef _NETSMB_SMBFS_API_H 29613a2f6bSGordon Ross #define _NETSMB_SMBFS_API_H 30613a2f6bSGordon Ross 31613a2f6bSGordon Ross /* 32430b4c46SGordon Ross * Define the API exported to our commands and to 33430b4c46SGordon Ross * libraries doing DCE-RPC over SMB named pipes. 34613a2f6bSGordon Ross */ 35613a2f6bSGordon Ross 36613a2f6bSGordon Ross #include <sys/types.h> 37613a2f6bSGordon Ross 38613a2f6bSGordon Ross #ifdef __cplusplus 39613a2f6bSGordon Ross extern "C" { 40613a2f6bSGordon Ross #endif 41613a2f6bSGordon Ross 42613a2f6bSGordon Ross /* 43613a2f6bSGordon Ross * Some errno values we need to expose in this API. 44613a2f6bSGordon Ross * NB: These two defines are duplicated from the 45613a2f6bSGordon Ross * driver smb_dev.h to avoid exposing that here. 46613a2f6bSGordon Ross * 47613a2f6bSGordon Ross * EBADRPC is used for message decoding errors. 48613a2f6bSGordon Ross * EAUTH is used for CIFS authentication errors. 49613a2f6bSGordon Ross */ 50613a2f6bSGordon Ross #ifndef EBADRPC 51613a2f6bSGordon Ross #define EBADRPC 113 52613a2f6bSGordon Ross #endif 53613a2f6bSGordon Ross #ifndef EAUTH 54613a2f6bSGordon Ross #define EAUTH 114 55613a2f6bSGordon Ross #endif 56613a2f6bSGordon Ross 57613a2f6bSGordon Ross 58613a2f6bSGordon Ross /* 59613a2f6bSGordon Ross * Share type values for smb_ctx_new, _init 60613a2f6bSGordon Ross * Based on NetUseAdd() USE_INFO_[12] _asg_type values 61613a2f6bSGordon Ross * They also happen to match: STYPE_DISKTREE, etc. 62430b4c46SGordon Ross * Note: these values appear on the wire. 63613a2f6bSGordon Ross */ 64613a2f6bSGordon Ross typedef enum { 65430b4c46SGordon Ross USE_DISKDEV = 0, /* also STYPE_DISKTREE */ 66430b4c46SGordon Ross USE_SPOOLDEV, /* also STYPE_PRINTQ */ 67430b4c46SGordon Ross USE_CHARDEV, /* also STYPE_DEVICE */ 68430b4c46SGordon Ross USE_IPC, /* also STYPE_IPC */ 69430b4c46SGordon Ross USE_WILDCARD /* also STYPE_UNKNOWN */ 70613a2f6bSGordon Ross } smb_use_shtype_t; 71613a2f6bSGordon Ross 72613a2f6bSGordon Ross /* 73613a2f6bSGordon Ross * Parse "level" spec. for smb_ctx_parseunc() 74613a2f6bSGordon Ross * i.e. whether we require a share name, etc. 75613a2f6bSGordon Ross */ 76613a2f6bSGordon Ross typedef enum { 77613a2f6bSGordon Ross SMBL_NONE = 0, /* have nothing */ 78613a2f6bSGordon Ross SMBL_SERVER, /* have server */ 79613a2f6bSGordon Ross SMBL_VC = 1, /* alias for _SERVER */ 80613a2f6bSGordon Ross SMBL_SHARE, /* have server share */ 81613a2f6bSGordon Ross SMBL_PATH /* have server share path */ 82613a2f6bSGordon Ross } smb_parse_level_t; 83613a2f6bSGordon Ross 84613a2f6bSGordon Ross /* 85613a2f6bSGordon Ross * Authentication type flags 86613a2f6bSGordon Ross * See: smb_ctx_setauthflags() 87613a2f6bSGordon Ross */ 88613a2f6bSGordon Ross #define SMB_AT_ANON 1 /* anonymous (NULL session) */ 89613a2f6bSGordon Ross #define SMB_AT_LM1 2 /* LM1 (with NTLM) */ 90613a2f6bSGordon Ross #define SMB_AT_NTLM1 4 /* NTLM (v1) */ 91613a2f6bSGordon Ross #define SMB_AT_NTLM2 8 /* NTLMv2 */ 92613a2f6bSGordon Ross #define SMB_AT_KRB5 0x10 /* Kerberos5 (AD) */ 93613a2f6bSGordon Ross 94613a2f6bSGordon Ross struct smb_ctx; /* anonymous here; real one in smb_lib.h */ 95613a2f6bSGordon Ross typedef struct smb_ctx smb_ctx_t; 96613a2f6bSGordon Ross 97613a2f6bSGordon Ross extern int smb_debug, smb_verbose; 98613a2f6bSGordon Ross 99613a2f6bSGordon Ross int smb_lib_init(void); 100613a2f6bSGordon Ross void smb_error(const char *, int, ...); 101613a2f6bSGordon Ross 102613a2f6bSGordon Ross /* 103613a2f6bSGordon Ross * Context management 104613a2f6bSGordon Ross */ 105613a2f6bSGordon Ross int smb_ctx_alloc(struct smb_ctx **); 106613a2f6bSGordon Ross void smb_ctx_free(struct smb_ctx *); 107613a2f6bSGordon Ross int smb_ctx_kill(struct smb_ctx *); 108613a2f6bSGordon Ross 109613a2f6bSGordon Ross int smb_ctx_scan_argv(struct smb_ctx *, int, char **, int, int, int); 110613a2f6bSGordon Ross int smb_ctx_parseunc(struct smb_ctx *, const char *, int, int, int, 111613a2f6bSGordon Ross const char **); 112613a2f6bSGordon Ross int smb_ctx_readrc(struct smb_ctx *); 113613a2f6bSGordon Ross int smb_ctx_opt(struct smb_ctx *, int, const char *); 114613a2f6bSGordon Ross int smb_get_authentication(struct smb_ctx *); 115613a2f6bSGordon Ross 116613a2f6bSGordon Ross int smb_ctx_flags2(struct smb_ctx *); 117613a2f6bSGordon Ross int smb_ctx_resolve(struct smb_ctx *); 118613a2f6bSGordon Ross int smb_ctx_get_ssn(struct smb_ctx *); 119613a2f6bSGordon Ross int smb_ctx_get_tree(struct smb_ctx *); 120613a2f6bSGordon Ross 121613a2f6bSGordon Ross int smb_ctx_setauthflags(struct smb_ctx *, int); 122613a2f6bSGordon Ross int smb_ctx_setcharset(struct smb_ctx *, const char *); 123613a2f6bSGordon Ross int smb_ctx_setfullserver(struct smb_ctx *, const char *); 1248eb99b82SGordon Ross int smb_ctx_setsigning(struct smb_ctx *, int ena, int req); 1258eb99b82SGordon Ross 1268eb99b82SGordon Ross int smb_ctx_setnbflags(struct smb_ctx *, int ena, int bcast); 127613a2f6bSGordon Ross int smb_ctx_setscope(struct smb_ctx *, const char *); 128613a2f6bSGordon Ross int smb_ctx_setwins(struct smb_ctx *, const char *, const char *); 129613a2f6bSGordon Ross 130613a2f6bSGordon Ross int smb_ctx_setsrvaddr(struct smb_ctx *, const char *); 131613a2f6bSGordon Ross int smb_ctx_setserver(struct smb_ctx *, const char *); 132613a2f6bSGordon Ross int smb_ctx_setshare(struct smb_ctx *, const char *, int); 133613a2f6bSGordon Ross 134613a2f6bSGordon Ross int smb_ctx_setdomain(struct smb_ctx *, const char *, int); 135613a2f6bSGordon Ross int smb_ctx_setuser(struct smb_ctx *, const char *, int); 136613a2f6bSGordon Ross int smb_ctx_setpassword(struct smb_ctx *, const char *, int); 137613a2f6bSGordon Ross int smb_ctx_setpwhash(struct smb_ctx *, const uchar_t *, const uchar_t *); 138613a2f6bSGordon Ross 139613a2f6bSGordon Ross typedef void (*smb_ctx_close_hook_t)(struct smb_ctx *); 140613a2f6bSGordon Ross void smb_ctx_set_close_hook(smb_ctx_close_hook_t); 141430b4c46SGordon Ross int smb_fh_close(int); 142430b4c46SGordon Ross int smb_fh_open(struct smb_ctx *ctx, const char *, int); 143430b4c46SGordon Ross int smb_fh_read(int, off_t, size_t, char *); 144430b4c46SGordon Ross int smb_fh_write(int, off_t, size_t, const char *); 145430b4c46SGordon Ross int smb_fh_xactnp(int, int, const char *, 146613a2f6bSGordon Ross int *, char *, int *); 147430b4c46SGordon Ross int smb_fh_getssnkey(int, uchar_t *, size_t); 148613a2f6bSGordon Ross 149430b4c46SGordon Ross int smb_open_printer(struct smb_ctx *, const char *, int, int); 1506b2bcd8eSGordon Ross 151430b4c46SGordon Ross void smbfs_set_default_domain(const char *); 152430b4c46SGordon Ross void smbfs_set_default_user(const char *); 153613a2f6bSGordon Ross 154613a2f6bSGordon Ross char *smb_strerror(int); 155613a2f6bSGordon Ross 156613a2f6bSGordon Ross #ifdef __cplusplus 157613a2f6bSGordon Ross } 158613a2f6bSGordon Ross #endif 159613a2f6bSGordon Ross 160613a2f6bSGordon Ross #endif /* _NETSMB_SMBFS_API_H */ 161