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