110023SGordon.Ross@Sun.COM /* 210023SGordon.Ross@Sun.COM * CDDL HEADER START 310023SGordon.Ross@Sun.COM * 410023SGordon.Ross@Sun.COM * The contents of this file are subject to the terms of the 510023SGordon.Ross@Sun.COM * Common Development and Distribution License (the "License"). 610023SGordon.Ross@Sun.COM * You may not use this file except in compliance with the License. 710023SGordon.Ross@Sun.COM * 810023SGordon.Ross@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 910023SGordon.Ross@Sun.COM * or http://www.opensolaris.org/os/licensing. 1010023SGordon.Ross@Sun.COM * See the License for the specific language governing permissions 1110023SGordon.Ross@Sun.COM * and limitations under the License. 1210023SGordon.Ross@Sun.COM * 1310023SGordon.Ross@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each 1410023SGordon.Ross@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1510023SGordon.Ross@Sun.COM * If applicable, add the following below this CDDL HEADER, with the 1610023SGordon.Ross@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying 1710023SGordon.Ross@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner] 1810023SGordon.Ross@Sun.COM * 1910023SGordon.Ross@Sun.COM * CDDL HEADER END 2010023SGordon.Ross@Sun.COM */ 2110023SGordon.Ross@Sun.COM 2210023SGordon.Ross@Sun.COM /* 2310023SGordon.Ross@Sun.COM * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 2410023SGordon.Ross@Sun.COM * Use is subject to license terms. 2510023SGordon.Ross@Sun.COM */ 2610023SGordon.Ross@Sun.COM 2710023SGordon.Ross@Sun.COM #ifndef _NETSMB_SMBFS_API_H 2810023SGordon.Ross@Sun.COM #define _NETSMB_SMBFS_API_H 2910023SGordon.Ross@Sun.COM 3010023SGordon.Ross@Sun.COM /* 3110023SGordon.Ross@Sun.COM * Define the API exported to our commands and to the 3210023SGordon.Ross@Sun.COM * MS-style RPC-over-named-pipes library (mlrpc). 3310023SGordon.Ross@Sun.COM */ 3410023SGordon.Ross@Sun.COM 3510023SGordon.Ross@Sun.COM #include <sys/types.h> 3610023SGordon.Ross@Sun.COM 3710023SGordon.Ross@Sun.COM #ifdef __cplusplus 3810023SGordon.Ross@Sun.COM extern "C" { 3910023SGordon.Ross@Sun.COM #endif 4010023SGordon.Ross@Sun.COM 4110023SGordon.Ross@Sun.COM /* 4210023SGordon.Ross@Sun.COM * Some errno values we need to expose in this API. 4310023SGordon.Ross@Sun.COM * NB: These two defines are duplicated from the 4410023SGordon.Ross@Sun.COM * driver smb_dev.h to avoid exposing that here. 4510023SGordon.Ross@Sun.COM * 4610023SGordon.Ross@Sun.COM * EBADRPC is used for message decoding errors. 4710023SGordon.Ross@Sun.COM * EAUTH is used for CIFS authentication errors. 4810023SGordon.Ross@Sun.COM */ 4910023SGordon.Ross@Sun.COM #ifndef EBADRPC 5010023SGordon.Ross@Sun.COM #define EBADRPC 113 5110023SGordon.Ross@Sun.COM #endif 5210023SGordon.Ross@Sun.COM #ifndef EAUTH 5310023SGordon.Ross@Sun.COM #define EAUTH 114 5410023SGordon.Ross@Sun.COM #endif 5510023SGordon.Ross@Sun.COM 5610023SGordon.Ross@Sun.COM 5710023SGordon.Ross@Sun.COM /* 5810023SGordon.Ross@Sun.COM * Share type values for smb_ctx_new, _init 5910023SGordon.Ross@Sun.COM * Based on NetUseAdd() USE_INFO_[12] _asg_type values 6010023SGordon.Ross@Sun.COM * They also happen to match: STYPE_DISKTREE, etc. 6110023SGordon.Ross@Sun.COM */ 6210023SGordon.Ross@Sun.COM typedef enum { 6310023SGordon.Ross@Sun.COM USE_WILDCARD = -1, 6410023SGordon.Ross@Sun.COM USE_DISKDEV, 6510023SGordon.Ross@Sun.COM USE_SPOOLDEV, 6610023SGordon.Ross@Sun.COM USE_CHARDEV, 6710023SGordon.Ross@Sun.COM USE_IPC 6810023SGordon.Ross@Sun.COM } smb_use_shtype_t; 6910023SGordon.Ross@Sun.COM 7010023SGordon.Ross@Sun.COM /* 7110023SGordon.Ross@Sun.COM * Parse "level" spec. for smb_ctx_parseunc() 7210023SGordon.Ross@Sun.COM * i.e. whether we require a share name, etc. 7310023SGordon.Ross@Sun.COM */ 7410023SGordon.Ross@Sun.COM typedef enum { 7510023SGordon.Ross@Sun.COM SMBL_NONE = 0, /* have nothing */ 7610023SGordon.Ross@Sun.COM SMBL_SERVER, /* have server */ 7710023SGordon.Ross@Sun.COM SMBL_VC = 1, /* alias for _SERVER */ 7810023SGordon.Ross@Sun.COM SMBL_SHARE, /* have server share */ 7910023SGordon.Ross@Sun.COM SMBL_PATH /* have server share path */ 8010023SGordon.Ross@Sun.COM } smb_parse_level_t; 8110023SGordon.Ross@Sun.COM 8210023SGordon.Ross@Sun.COM /* 8310023SGordon.Ross@Sun.COM * Authentication type flags 8410023SGordon.Ross@Sun.COM * See: smb_ctx_setauthflags() 8510023SGordon.Ross@Sun.COM */ 8610023SGordon.Ross@Sun.COM #define SMB_AT_ANON 1 /* anonymous (NULL session) */ 8710023SGordon.Ross@Sun.COM #define SMB_AT_LM1 2 /* LM1 (with NTLM) */ 8810023SGordon.Ross@Sun.COM #define SMB_AT_NTLM1 4 /* NTLM (v1) */ 8910023SGordon.Ross@Sun.COM #define SMB_AT_NTLM2 8 /* NTLMv2 */ 9010023SGordon.Ross@Sun.COM #define SMB_AT_KRB5 0x10 /* Kerberos5 (AD) */ 9110023SGordon.Ross@Sun.COM #define SMB_AT_DEFAULT (SMB_AT_KRB5 | SMB_AT_NTLM2 | SMB_AT_NTLM1) 9210023SGordon.Ross@Sun.COM 9310023SGordon.Ross@Sun.COM struct smb_ctx; /* anonymous here; real one in smb_lib.h */ 9410023SGordon.Ross@Sun.COM typedef struct smb_ctx smb_ctx_t; 9510023SGordon.Ross@Sun.COM 9610023SGordon.Ross@Sun.COM extern int smb_debug, smb_verbose; 9710023SGordon.Ross@Sun.COM 9810023SGordon.Ross@Sun.COM int smb_lib_init(void); 9910023SGordon.Ross@Sun.COM void smb_error(const char *, int, ...); 10010023SGordon.Ross@Sun.COM 10110023SGordon.Ross@Sun.COM /* 10210023SGordon.Ross@Sun.COM * Context management 10310023SGordon.Ross@Sun.COM */ 10410023SGordon.Ross@Sun.COM int smb_ctx_alloc(struct smb_ctx **); 10510023SGordon.Ross@Sun.COM void smb_ctx_free(struct smb_ctx *); 10610023SGordon.Ross@Sun.COM int smb_ctx_kill(struct smb_ctx *); 10710023SGordon.Ross@Sun.COM 10810023SGordon.Ross@Sun.COM int smb_ctx_scan_argv(struct smb_ctx *, int, char **, int, int, int); 10910023SGordon.Ross@Sun.COM int smb_ctx_parseunc(struct smb_ctx *, const char *, int, int, int, 11010023SGordon.Ross@Sun.COM const char **); 11110023SGordon.Ross@Sun.COM int smb_ctx_readrc(struct smb_ctx *); 11210023SGordon.Ross@Sun.COM int smb_ctx_opt(struct smb_ctx *, int, const char *); 11310023SGordon.Ross@Sun.COM int smb_get_authentication(struct smb_ctx *); 11410023SGordon.Ross@Sun.COM 11510023SGordon.Ross@Sun.COM int smb_ctx_flags2(struct smb_ctx *); 11610023SGordon.Ross@Sun.COM int smb_ctx_resolve(struct smb_ctx *); 11710023SGordon.Ross@Sun.COM int smb_ctx_get_ssn(struct smb_ctx *); 11810023SGordon.Ross@Sun.COM int smb_ctx_get_ssnkey(struct smb_ctx *, uchar_t *, size_t); 11910023SGordon.Ross@Sun.COM int smb_ctx_get_tree(struct smb_ctx *); 12010023SGordon.Ross@Sun.COM 12110023SGordon.Ross@Sun.COM int smb_ctx_setauthflags(struct smb_ctx *, int); 12210023SGordon.Ross@Sun.COM int smb_ctx_setcharset(struct smb_ctx *, const char *); 12310023SGordon.Ross@Sun.COM int smb_ctx_setflags(struct smb_ctx *, int, int, int); 12410023SGordon.Ross@Sun.COM int smb_ctx_setfullserver(struct smb_ctx *, const char *); 12510023SGordon.Ross@Sun.COM int smb_ctx_setscope(struct smb_ctx *, const char *); 12610023SGordon.Ross@Sun.COM int smb_ctx_setwins(struct smb_ctx *, const char *, const char *); 12710023SGordon.Ross@Sun.COM 12810023SGordon.Ross@Sun.COM int smb_ctx_setsrvaddr(struct smb_ctx *, const char *); 12910023SGordon.Ross@Sun.COM int smb_ctx_setserver(struct smb_ctx *, const char *); 13010023SGordon.Ross@Sun.COM int smb_ctx_setshare(struct smb_ctx *, const char *, int); 13110023SGordon.Ross@Sun.COM 13210023SGordon.Ross@Sun.COM int smb_ctx_setdomain(struct smb_ctx *, const char *, int); 13310023SGordon.Ross@Sun.COM int smb_ctx_setuser(struct smb_ctx *, const char *, int); 13410023SGordon.Ross@Sun.COM int smb_ctx_setpassword(struct smb_ctx *, const char *, int); 13510023SGordon.Ross@Sun.COM int smb_ctx_setpwhash(struct smb_ctx *, const uchar_t *, const uchar_t *); 13610023SGordon.Ross@Sun.COM 13710023SGordon.Ross@Sun.COM typedef void (*smb_ctx_close_hook_t)(struct smb_ctx *); 13810023SGordon.Ross@Sun.COM void smb_ctx_set_close_hook(smb_ctx_close_hook_t); 13910023SGordon.Ross@Sun.COM int smb_fh_close(struct smb_ctx *ctx, int); 14010023SGordon.Ross@Sun.COM int smb_fh_open(struct smb_ctx *ctx, const char *, int, int *); 14110023SGordon.Ross@Sun.COM int smb_fh_read(struct smb_ctx *, int, off_t, size_t, char *); 14210023SGordon.Ross@Sun.COM int smb_fh_write(struct smb_ctx *, int, off_t, size_t, const char *); 14310023SGordon.Ross@Sun.COM int smb_fh_xactnp(struct smb_ctx *, int, int, const char *, 14410023SGordon.Ross@Sun.COM int *, char *, int *); 14510023SGordon.Ross@Sun.COM 146*10367SGordon.Ross@Sun.COM int smb_iod_start(struct smb_ctx *); 147*10367SGordon.Ross@Sun.COM 14810023SGordon.Ross@Sun.COM int smb_t2_request(struct smb_ctx *, int, uint16_t *, const char *, 14910023SGordon.Ross@Sun.COM int, void *, int, void *, int *, void *, int *, void *, int *); 15010023SGordon.Ross@Sun.COM 15110023SGordon.Ross@Sun.COM int smb_printer_open(struct smb_ctx *, int, int, const char *, int *); 15210023SGordon.Ross@Sun.COM int smb_printer_close(struct smb_ctx *, int); 15310023SGordon.Ross@Sun.COM 15410023SGordon.Ross@Sun.COM char *smb_strerror(int); 15510023SGordon.Ross@Sun.COM 15610023SGordon.Ross@Sun.COM #ifdef __cplusplus 15710023SGordon.Ross@Sun.COM } 15810023SGordon.Ross@Sun.COM #endif 15910023SGordon.Ross@Sun.COM 16010023SGordon.Ross@Sun.COM #endif /* _NETSMB_SMBFS_API_H */ 161