xref: /onnv-gate/usr/src/lib/libsmbfs/smb/private.h (revision 8271:792589b3384f)
1*8271SGordon.Ross@Sun.COM /*
2*8271SGordon.Ross@Sun.COM  * Copyright (c) 2000-2001 Boris Popov
3*8271SGordon.Ross@Sun.COM  * All rights reserved.
4*8271SGordon.Ross@Sun.COM  *
5*8271SGordon.Ross@Sun.COM  * Redistribution and use in source and binary forms, with or without
6*8271SGordon.Ross@Sun.COM  * modification, are permitted provided that the following conditions
7*8271SGordon.Ross@Sun.COM  * are met:
8*8271SGordon.Ross@Sun.COM  * 1. Redistributions of source code must retain the above copyright
9*8271SGordon.Ross@Sun.COM  *    notice, this list of conditions and the following disclaimer.
10*8271SGordon.Ross@Sun.COM  * 2. Redistributions in binary form must reproduce the above copyright
11*8271SGordon.Ross@Sun.COM  *    notice, this list of conditions and the following disclaimer in the
12*8271SGordon.Ross@Sun.COM  *    documentation and/or other materials provided with the distribution.
13*8271SGordon.Ross@Sun.COM  * 3. All advertising materials mentioning features or use of this software
14*8271SGordon.Ross@Sun.COM  *    must display the following acknowledgement:
15*8271SGordon.Ross@Sun.COM  *    This product includes software developed by Boris Popov.
16*8271SGordon.Ross@Sun.COM  * 4. Neither the name of the author nor the names of any co-contributors
17*8271SGordon.Ross@Sun.COM  *    may be used to endorse or promote products derived from this software
18*8271SGordon.Ross@Sun.COM  *    without specific prior written permission.
19*8271SGordon.Ross@Sun.COM  *
20*8271SGordon.Ross@Sun.COM  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21*8271SGordon.Ross@Sun.COM  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22*8271SGordon.Ross@Sun.COM  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23*8271SGordon.Ross@Sun.COM  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24*8271SGordon.Ross@Sun.COM  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25*8271SGordon.Ross@Sun.COM  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26*8271SGordon.Ross@Sun.COM  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27*8271SGordon.Ross@Sun.COM  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28*8271SGordon.Ross@Sun.COM  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29*8271SGordon.Ross@Sun.COM  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30*8271SGordon.Ross@Sun.COM  * SUCH DAMAGE.
31*8271SGordon.Ross@Sun.COM  */
32*8271SGordon.Ross@Sun.COM 
33*8271SGordon.Ross@Sun.COM /*
34*8271SGordon.Ross@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
35*8271SGordon.Ross@Sun.COM  * Use is subject to license terms.
36*8271SGordon.Ross@Sun.COM  */
37*8271SGordon.Ross@Sun.COM 
38*8271SGordon.Ross@Sun.COM #ifndef _PRIVATE_H
39*8271SGordon.Ross@Sun.COM #define	_PRIVATE_H
40*8271SGordon.Ross@Sun.COM 
41*8271SGordon.Ross@Sun.COM /*
42*8271SGordon.Ross@Sun.COM  * Private declarations for this library.
43*8271SGordon.Ross@Sun.COM  * Moved from smb_lib.h
44*8271SGordon.Ross@Sun.COM  */
45*8271SGordon.Ross@Sun.COM 
46*8271SGordon.Ross@Sun.COM #include <inttypes.h>
47*8271SGordon.Ross@Sun.COM 
48*8271SGordon.Ross@Sun.COM /*
49*8271SGordon.Ross@Sun.COM  * BSD-style mbuf simulation
50*8271SGordon.Ross@Sun.COM  */
51*8271SGordon.Ross@Sun.COM struct mbuf {
52*8271SGordon.Ross@Sun.COM 	int		m_len;
53*8271SGordon.Ross@Sun.COM 	int		m_maxlen;
54*8271SGordon.Ross@Sun.COM 	char		*m_data;
55*8271SGordon.Ross@Sun.COM 	struct mbuf	*m_next;
56*8271SGordon.Ross@Sun.COM };
57*8271SGordon.Ross@Sun.COM typedef struct mbuf mbuf_t;
58*8271SGordon.Ross@Sun.COM 
59*8271SGordon.Ross@Sun.COM #if 0 /* in smb_lib.h */
60*8271SGordon.Ross@Sun.COM struct mbdata {
61*8271SGordon.Ross@Sun.COM 	struct mbuf	*mb_top;
62*8271SGordon.Ross@Sun.COM 	struct mbuf	*mb_cur;
63*8271SGordon.Ross@Sun.COM 	char		*mb_pos;
64*8271SGordon.Ross@Sun.COM 	int		mb_count;
65*8271SGordon.Ross@Sun.COM };
66*8271SGordon.Ross@Sun.COM typedef struct mbdata mbdata_t;
67*8271SGordon.Ross@Sun.COM #endif
68*8271SGordon.Ross@Sun.COM 
69*8271SGordon.Ross@Sun.COM #define	M_ALIGNFACTOR	(sizeof (long))
70*8271SGordon.Ross@Sun.COM #define	M_ALIGN(len)	(((len) + M_ALIGNFACTOR - 1) & ~(M_ALIGNFACTOR - 1))
71*8271SGordon.Ross@Sun.COM #define	M_BASESIZE	(sizeof (struct mbuf))
72*8271SGordon.Ross@Sun.COM #define	M_MINSIZE	(256 - M_BASESIZE)
73*8271SGordon.Ross@Sun.COM #define	M_TOP(m)	((char *)(m) + M_BASESIZE)
74*8271SGordon.Ross@Sun.COM #define	M_TRAILINGSPACE(m) ((m)->m_maxlen - (m)->m_len)
75*8271SGordon.Ross@Sun.COM #define	mtod(m, t)	((t)(m)->m_data)
76*8271SGordon.Ross@Sun.COM 
77*8271SGordon.Ross@Sun.COM /*
78*8271SGordon.Ross@Sun.COM  * request handling structures
79*8271SGordon.Ross@Sun.COM  */
80*8271SGordon.Ross@Sun.COM struct smb_rq {
81*8271SGordon.Ross@Sun.COM 	uchar_t		rq_cmd;
82*8271SGordon.Ross@Sun.COM 	struct mbdata	rq_rq;
83*8271SGordon.Ross@Sun.COM 	struct mbdata	rq_rp;
84*8271SGordon.Ross@Sun.COM 	struct smb_ctx *rq_ctx;
85*8271SGordon.Ross@Sun.COM 	int		rq_wcount;
86*8271SGordon.Ross@Sun.COM 	int		rq_bcount;
87*8271SGordon.Ross@Sun.COM };
88*8271SGordon.Ross@Sun.COM typedef struct smb_rq smb_rq_t;
89*8271SGordon.Ross@Sun.COM 
90*8271SGordon.Ross@Sun.COM #define	smb_rq_getrequest(rqp)	(&(rqp)->rq_rq)
91*8271SGordon.Ross@Sun.COM #define	smb_rq_getreply(rqp)	(&(rqp)->rq_rp)
92*8271SGordon.Ross@Sun.COM 
93*8271SGordon.Ross@Sun.COM int  smb_rq_init(struct smb_ctx *, uchar_t, size_t, struct smb_rq **);
94*8271SGordon.Ross@Sun.COM void smb_rq_done(struct smb_rq *);
95*8271SGordon.Ross@Sun.COM void smb_rq_wend(struct smb_rq *);
96*8271SGordon.Ross@Sun.COM int  smb_rq_simple(struct smb_rq *);
97*8271SGordon.Ross@Sun.COM int  smb_rq_dmem(struct mbdata *, const char *, size_t);
98*8271SGordon.Ross@Sun.COM int  smb_rq_dstring(struct mbdata *, const char *);
99*8271SGordon.Ross@Sun.COM 
100*8271SGordon.Ross@Sun.COM 
101*8271SGordon.Ross@Sun.COM /*
102*8271SGordon.Ross@Sun.COM  * Message compose/parse
103*8271SGordon.Ross@Sun.COM  */
104*8271SGordon.Ross@Sun.COM 
105*8271SGordon.Ross@Sun.COM int  m_getm(struct mbuf *, size_t, struct mbuf **);
106*8271SGordon.Ross@Sun.COM int  m_lineup(struct mbuf *, struct mbuf **);
107*8271SGordon.Ross@Sun.COM int  mb_init(struct mbdata *, size_t);
108*8271SGordon.Ross@Sun.COM int  mb_initm(struct mbdata *, struct mbuf *);
109*8271SGordon.Ross@Sun.COM int  mb_done(struct mbdata *);
110*8271SGordon.Ross@Sun.COM int  mb_fit(struct mbdata *mbp, size_t size, char **pp);
111*8271SGordon.Ross@Sun.COM int  mb_put_uint8(struct mbdata *, uint8_t);
112*8271SGordon.Ross@Sun.COM int  mb_put_uint16be(struct mbdata *, uint16_t);
113*8271SGordon.Ross@Sun.COM int  mb_put_uint16le(struct mbdata *, uint16_t);
114*8271SGordon.Ross@Sun.COM int  mb_put_uint32be(struct mbdata *, uint32_t);
115*8271SGordon.Ross@Sun.COM int  mb_put_uint32le(struct mbdata *, uint32_t);
116*8271SGordon.Ross@Sun.COM int  mb_put_uint64be(struct mbdata *, uint64_t);
117*8271SGordon.Ross@Sun.COM int  mb_put_uint64le(struct mbdata *, uint64_t);
118*8271SGordon.Ross@Sun.COM int  mb_put_mem(struct mbdata *, const char *, size_t);
119*8271SGordon.Ross@Sun.COM int  mb_put_pstring(struct mbdata *mbp, const char *s);
120*8271SGordon.Ross@Sun.COM int  mb_put_mbuf(struct mbdata *, struct mbuf *);
121*8271SGordon.Ross@Sun.COM 
122*8271SGordon.Ross@Sun.COM int  mb_get_uint8(struct mbdata *, uint8_t *);
123*8271SGordon.Ross@Sun.COM int  mb_get_uint16(struct mbdata *, uint16_t *);
124*8271SGordon.Ross@Sun.COM int  mb_get_uint16le(struct mbdata *, uint16_t *);
125*8271SGordon.Ross@Sun.COM int  mb_get_uint16be(struct mbdata *, uint16_t *);
126*8271SGordon.Ross@Sun.COM int  mb_get_uint32(struct mbdata *, uint32_t *);
127*8271SGordon.Ross@Sun.COM int  mb_get_uint32be(struct mbdata *, uint32_t *);
128*8271SGordon.Ross@Sun.COM int  mb_get_uint32le(struct mbdata *, uint32_t *);
129*8271SGordon.Ross@Sun.COM int  mb_get_uint64(struct mbdata *, uint64_t *);
130*8271SGordon.Ross@Sun.COM int  mb_get_uint64be(struct mbdata *, uint64_t *);
131*8271SGordon.Ross@Sun.COM int  mb_get_uint64le(struct mbdata *, uint64_t *);
132*8271SGordon.Ross@Sun.COM int  mb_get_mem(struct mbdata *, char *, size_t);
133*8271SGordon.Ross@Sun.COM 
134*8271SGordon.Ross@Sun.COM /*
135*8271SGordon.Ross@Sun.COM  * Network stuff (NetBIOS and otherwise)
136*8271SGordon.Ross@Sun.COM  */
137*8271SGordon.Ross@Sun.COM 
138*8271SGordon.Ross@Sun.COM int nb_name_len(struct nb_name *);
139*8271SGordon.Ross@Sun.COM /* new flag UCflag. 1=uppercase,0=don't */
140*8271SGordon.Ross@Sun.COM int nb_name_encode(struct nb_name *, uchar_t *);
141*8271SGordon.Ross@Sun.COM int nb_encname_len(const uchar_t *);
142*8271SGordon.Ross@Sun.COM 
143*8271SGordon.Ross@Sun.COM int  nb_snballoc(int namelen, struct sockaddr_nb **);
144*8271SGordon.Ross@Sun.COM void nb_snbfree(struct sockaddr *);
145*8271SGordon.Ross@Sun.COM int  nb_sockaddr(struct sockaddr *, struct nb_name *, struct sockaddr_nb **);
146*8271SGordon.Ross@Sun.COM 
147*8271SGordon.Ross@Sun.COM int  nbns_resolvename(const char *, struct nb_ctx *, struct sockaddr **);
148*8271SGordon.Ross@Sun.COM int  nbns_getnodestatus(struct sockaddr *targethost,
149*8271SGordon.Ross@Sun.COM     struct nb_ctx *ctx, char *system, char *workgroup);
150*8271SGordon.Ross@Sun.COM int  nb_getlocalname(char *name, size_t maxlen);
151*8271SGordon.Ross@Sun.COM 
152*8271SGordon.Ross@Sun.COM extern uchar_t nls_lower[256], nls_upper[256];
153*8271SGordon.Ross@Sun.COM 
154*8271SGordon.Ross@Sun.COM #endif /* _PRIVATE_H */
155