xref: /titanic_41/usr/src/lib/libsmbfs/netsmb/smbfs_api.h (revision 26fd77009b17f8c8fb32eb362584cfd635e87ad9)
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 /*
23  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _NETSMB_SMBFS_API_H
28 #define	_NETSMB_SMBFS_API_H
29 
30 /*
31  * Define the API exported to our commands and to the
32  * MS-style RPC-over-named-pipes library (mlrpc).
33  */
34 
35 #include <sys/types.h>
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 /*
42  * Some errno values we need to expose in this API.
43  * NB: These two defines are duplicated from the
44  * driver smb_dev.h to avoid exposing that here.
45  *
46  * EBADRPC is used for message decoding errors.
47  * EAUTH is used for CIFS authentication errors.
48  */
49 #ifndef EBADRPC
50 #define	EBADRPC 	113
51 #endif
52 #ifndef EAUTH
53 #define	EAUTH		114
54 #endif
55 
56 
57 /*
58  * Share type values for smb_ctx_new, _init
59  * Based on NetUseAdd() USE_INFO_[12] _asg_type values
60  * They also happen to match: STYPE_DISKTREE, etc.
61  */
62 typedef enum {
63 	USE_WILDCARD = -1,
64 	USE_DISKDEV,
65 	USE_SPOOLDEV,
66 	USE_CHARDEV,
67 	USE_IPC
68 } smb_use_shtype_t;
69 
70 /*
71  * Parse "level" spec. for smb_ctx_parseunc()
72  * i.e. whether we require a share name, etc.
73  */
74 typedef enum {
75 	SMBL_NONE = 0,	/* have nothing */
76 	SMBL_SERVER,	/* have server */
77 	SMBL_VC = 1,	/* alias for _SERVER */
78 	SMBL_SHARE,	/* have server share */
79 	SMBL_PATH	/* have server share path */
80 } smb_parse_level_t;
81 
82 /*
83  * Authentication type flags
84  * See: smb_ctx_setauthflags()
85  */
86 #define	SMB_AT_ANON	1	/* anonymous (NULL session) */
87 #define	SMB_AT_LM1	2	/* LM1 (with NTLM) */
88 #define	SMB_AT_NTLM1	4	/* NTLM (v1) */
89 #define	SMB_AT_NTLM2	8	/* NTLMv2 */
90 #define	SMB_AT_KRB5	0x10	/* Kerberos5 (AD) */
91 #define	SMB_AT_DEFAULT	(SMB_AT_KRB5 | SMB_AT_NTLM2 | SMB_AT_NTLM1)
92 
93 struct smb_ctx;	/* anonymous here; real one in smb_lib.h */
94 typedef struct smb_ctx smb_ctx_t;
95 
96 extern int smb_debug, smb_verbose;
97 
98 int  smb_lib_init(void);
99 void smb_error(const char *, int, ...);
100 
101 /*
102  * Context management
103  */
104 int  smb_ctx_alloc(struct smb_ctx **);
105 void smb_ctx_free(struct smb_ctx *);
106 int  smb_ctx_kill(struct smb_ctx *);
107 
108 int  smb_ctx_scan_argv(struct smb_ctx *, int, char **, int, int, int);
109 int  smb_ctx_parseunc(struct smb_ctx *, const char *, int, int, int,
110 	const char **);
111 int  smb_ctx_readrc(struct smb_ctx *);
112 int  smb_ctx_opt(struct smb_ctx *, int, const char *);
113 int  smb_get_authentication(struct smb_ctx *);
114 
115 int  smb_ctx_flags2(struct smb_ctx *);
116 int  smb_ctx_resolve(struct smb_ctx *);
117 int  smb_ctx_get_ssn(struct smb_ctx *);
118 int  smb_ctx_get_ssnkey(struct smb_ctx *, uchar_t *, size_t);
119 int  smb_ctx_get_tree(struct smb_ctx *);
120 
121 int  smb_ctx_setauthflags(struct smb_ctx *, int);
122 int  smb_ctx_setcharset(struct smb_ctx *, const char *);
123 int  smb_ctx_setflags(struct smb_ctx *, int, int, int);
124 int  smb_ctx_setfullserver(struct smb_ctx *, const char *);
125 int  smb_ctx_setscope(struct smb_ctx *, const char *);
126 int  smb_ctx_setwins(struct smb_ctx *, const char *, const char *);
127 
128 int  smb_ctx_setsrvaddr(struct smb_ctx *, const char *);
129 int  smb_ctx_setserver(struct smb_ctx *, const char *);
130 int  smb_ctx_setshare(struct smb_ctx *, const char *, int);
131 
132 int  smb_ctx_setdomain(struct smb_ctx *, const char *, int);
133 int  smb_ctx_setuser(struct smb_ctx *, const char *, int);
134 int  smb_ctx_setpassword(struct smb_ctx *, const char *, int);
135 int  smb_ctx_setpwhash(struct smb_ctx *, const uchar_t *, const uchar_t *);
136 
137 typedef void (*smb_ctx_close_hook_t)(struct smb_ctx *);
138 void smb_ctx_set_close_hook(smb_ctx_close_hook_t);
139 int  smb_fh_close(struct smb_ctx *ctx, int);
140 int  smb_fh_open(struct smb_ctx *ctx, const char *, int, int *);
141 int  smb_fh_read(struct smb_ctx *, int, off_t, size_t, char *);
142 int  smb_fh_write(struct smb_ctx *, int, off_t, size_t, const char *);
143 int  smb_fh_xactnp(struct smb_ctx *, int, int, const char *,
144 	int *, char *, int *);
145 
146 int  smb_t2_request(struct smb_ctx *, int, uint16_t *, const char *,
147 	int, void *, int, void *, int *, void *, int *, void *, int *);
148 
149 int  smb_printer_open(struct smb_ctx *, int, int, const char *, int *);
150 int  smb_printer_close(struct smb_ctx *, int);
151 
152 char *smb_strerror(int);
153 
154 #ifdef	__cplusplus
155 }
156 #endif
157 
158 #endif /* _NETSMB_SMBFS_API_H */
159