xref: /illumos-gate/usr/src/lib/libsmbfs/smb/private.h (revision 40c0e231)
1 /*
2  * Copyright (c) 2000-2001 Boris Popov
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  * 3. All advertising materials mentioning features or use of this software
14  *    must display the following acknowledgement:
15  *    This product includes software developed by Boris Popov.
16  * 4. Neither the name of the author nor the names of any co-contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  */
32 
33 /*
34  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
35  * Use is subject to license terms.
36  *
37  * Copyright 2018 Nexenta Systems, Inc.  All rights reserved.
38  */
39 
40 #ifndef _PRIVATE_H
41 #define	_PRIVATE_H
42 
43 /*
44  * Private declarations for this library.
45  * Moved from smb_lib.h
46  */
47 
48 #include <inttypes.h>
49 #include <sys/byteorder.h>
50 #include <sys/ccompile.h>
51 
52 #include <netsmb/mchain.h>
53 #include <netsmb/netbios.h>
54 
55 extern void dprint(const char *, const char *, ...)
56 	__PRINTFLIKE(2);
57 
58 #if defined(DEBUG) || defined(__lint)
59 #define	DPRINT(...) dprint(__func__, __VA_ARGS__)
60 #else
61 #define	DPRINT(...) ((void)0)
62 #endif
63 
64 /*
65  * This library extends the mchain.h function set a little.
66  */
67 int  m_getm(struct mbuf *, int, struct mbuf **);
68 int  m_lineup(struct mbuf *, struct mbuf **);
69 size_t m_totlen(struct mbuf *);
70 
71 int  mb_init_sz(struct mbdata *, int);
72 int  mb_fit(struct mbdata *mbp, int size, char **pp);
73 
74 int  mb_put_string(struct mbdata *mbp, const char *s, int);
75 int  mb_put_astring(struct mbdata *mbp, const char *s);
76 int  mb_put_ustring(struct mbdata *mbp, const char *s);
77 
78 int  md_get_string(struct mbdata *, char **, int);
79 int  md_get_astring(struct mbdata *, char **);
80 int  md_get_ustring(struct mbdata *, char **);
81 
82 /*
83  * Network stuff (NetBIOS and otherwise)
84  */
85 struct nb_name;
86 struct sockaddr_nb;
87 
88 extern int smb_recv_timeout; /* seconds */
89 
90 void dump_ctx(char *, struct smb_ctx *);
91 void dump_addrinfo(struct addrinfo *);
92 void dump_sockaddr(struct sockaddr *);
93 int nb_ssn_request(struct smb_ctx *, char *);
94 
95 int nb_name_len(struct nb_name *);
96 int nb_name_encode(struct mbdata *, struct nb_name *);
97 int nb_encname_len(const uchar_t *);
98 
99 int  nb_snballoc(struct sockaddr_nb **);
100 void nb_snbfree(struct sockaddr *);
101 int  nb_sockaddr(struct sockaddr *, struct nb_name *, struct sockaddr_nb **);
102 
103 int nbns_getaddrinfo(const char *name, struct nb_ctx *nbc,
104 	struct addrinfo **res);
105 int  nbns_resolvename(const char *, struct nb_ctx *, struct sockaddr **);
106 int  get_xti_err(int);
107 
108 
109 /*
110  * Private SMB stuff
111  */
112 
113 struct smb_bitname {
114 	uint_t	bn_bit;
115 	char	*bn_name;
116 };
117 typedef struct smb_bitname smb_bitname_t;
118 char *smb_printb(char *, int, const struct smb_bitname *);
119 
120 int smb_ctx_getaddr(struct smb_ctx *ctx);
121 int smb_ctx_gethandle(struct smb_ctx *ctx);
122 
123 int  smb_iod_start(struct smb_ctx *);
124 const char *smb_iod_state_name(enum smbiod_state st);
125 
126 void smb_time_local2server(struct timeval *, int, long *);
127 void smb_time_server2local(ulong_t, int, struct timeval *);
128 void smb_time_NT2local(uint64_t, int, struct timeval *);
129 void smb_time_local2NT(struct timeval *, int, uint64_t *);
130 
131 int smb_getlocalname(char **);
132 int smb_get_authentication(struct smb_ctx *);
133 int smb_get_keychain(struct smb_ctx *ctx);
134 void smb_hexdump(const void *buf, int len);
135 
136 /* See ssp.c */
137 int ssp_ctx_create_client(struct smb_ctx *, struct mbdata *);
138 int ssp_ctx_next_token(struct smb_ctx *, struct mbdata *, struct mbdata *);
139 void ssp_ctx_destroy(struct smb_ctx *);
140 
141 #ifdef KICONV_SUPPORT
142 /* See nls.c (get rid of this?) */
143 extern uchar_t nls_lower[256], nls_upper[256];
144 #endif	/* KICONV_SUPPORT */
145 
146 #endif /* _PRIVATE_H */
147