xref: /freebsd/sys/netsmb/smb_trantcp.h (revision c398230b64aea809cb7c5cea8db580af7097920c)
1c398230bSWarner Losh /*-
2681a5bbeSBoris Popov  * Copyright (c) 2000-2001, Boris Popov
3681a5bbeSBoris Popov  * All rights reserved.
4681a5bbeSBoris Popov  *
5681a5bbeSBoris Popov  * Redistribution and use in source and binary forms, with or without
6681a5bbeSBoris Popov  * modification, are permitted provided that the following conditions
7681a5bbeSBoris Popov  * are met:
8681a5bbeSBoris Popov  * 1. Redistributions of source code must retain the above copyright
9681a5bbeSBoris Popov  *    notice, this list of conditions and the following disclaimer.
10681a5bbeSBoris Popov  * 2. Redistributions in binary form must reproduce the above copyright
11681a5bbeSBoris Popov  *    notice, this list of conditions and the following disclaimer in the
12681a5bbeSBoris Popov  *    documentation and/or other materials provided with the distribution.
13681a5bbeSBoris Popov  * 3. All advertising materials mentioning features or use of this software
14681a5bbeSBoris Popov  *    must display the following acknowledgement:
15681a5bbeSBoris Popov  *    This product includes software developed by Boris Popov.
16681a5bbeSBoris Popov  * 4. Neither the name of the author nor the names of any co-contributors
17681a5bbeSBoris Popov  *    may be used to endorse or promote products derived from this software
18681a5bbeSBoris Popov  *    without specific prior written permission.
19681a5bbeSBoris Popov  *
20681a5bbeSBoris Popov  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21681a5bbeSBoris Popov  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22681a5bbeSBoris Popov  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23681a5bbeSBoris Popov  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24681a5bbeSBoris Popov  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25681a5bbeSBoris Popov  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26681a5bbeSBoris Popov  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27681a5bbeSBoris Popov  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28681a5bbeSBoris Popov  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29681a5bbeSBoris Popov  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30681a5bbeSBoris Popov  * SUCH DAMAGE.
31681a5bbeSBoris Popov  *
32681a5bbeSBoris Popov  * $FreeBSD$
33681a5bbeSBoris Popov  */
34681a5bbeSBoris Popov #ifndef _NETSMB_SMB_TRANTCP_H_
35681a5bbeSBoris Popov #define	_NETSMB_SMB_TRANTCP_H_
36681a5bbeSBoris Popov 
37681a5bbeSBoris Popov #ifdef _KERNEL
38681a5bbeSBoris Popov 
39681a5bbeSBoris Popov #ifdef NB_DEBUG
40681a5bbeSBoris Popov #define NBDEBUG(format, args...)	 printf("%s(%d): "format,	\
416e551fb6SDavid E. O'Brien 					    __func__ , __LINE__ ,## args)
42681a5bbeSBoris Popov #else
43681a5bbeSBoris Popov #define NBDEBUG(format, args...)
44681a5bbeSBoris Popov #endif
45681a5bbeSBoris Popov 
46681a5bbeSBoris Popov enum nbstate {
47681a5bbeSBoris Popov 	NBST_CLOSED,
48681a5bbeSBoris Popov 	NBST_RQSENT,
49681a5bbeSBoris Popov 	NBST_SESSION,
50681a5bbeSBoris Popov 	NBST_RETARGET,
51681a5bbeSBoris Popov 	NBST_REFUSED
52681a5bbeSBoris Popov };
53681a5bbeSBoris Popov 
54681a5bbeSBoris Popov 
55681a5bbeSBoris Popov /*
56681a5bbeSBoris Popov  * socket specific data
57681a5bbeSBoris Popov  */
58681a5bbeSBoris Popov struct nbpcb {
59681a5bbeSBoris Popov 	struct smb_vc *	nbp_vc;
60681a5bbeSBoris Popov 	struct socket *	nbp_tso;	/* transport socket */
61681a5bbeSBoris Popov 	struct sockaddr_nb *nbp_laddr;	/* local address */
62681a5bbeSBoris Popov 	struct sockaddr_nb *nbp_paddr;	/* peer address */
63681a5bbeSBoris Popov 
64681a5bbeSBoris Popov 	int		nbp_flags;
65681a5bbeSBoris Popov #define	NBF_LOCADDR	0x0001		/* has local addr */
66681a5bbeSBoris Popov #define	NBF_CONNECTED	0x0002
67681a5bbeSBoris Popov #define	NBF_RECVLOCK	0x0004
68681a5bbeSBoris Popov 
69681a5bbeSBoris Popov 	enum nbstate	nbp_state;
70681a5bbeSBoris Popov 	struct timespec	nbp_timo;
71681a5bbeSBoris Popov 	int		nbp_sndbuf;
72681a5bbeSBoris Popov 	int		nbp_rcvbuf;
73681a5bbeSBoris Popov 	void *		nbp_selectid;
74681a5bbeSBoris Popov 
75681a5bbeSBoris Popov /*	LIST_ENTRY(nbpcb) nbp_link;*/
76681a5bbeSBoris Popov };
77681a5bbeSBoris Popov 
78681a5bbeSBoris Popov /*
79681a5bbeSBoris Popov  * Nominal space allocated per a NETBIOS socket.
80681a5bbeSBoris Popov  */
813c304004SBoris Popov #define	NB_SNDQ		(64 * 1024)
823c304004SBoris Popov #define	NB_RCVQ		(64 * 1024)
833c304004SBoris Popov 
843c304004SBoris Popov /*
853c304004SBoris Popov  * TCP slowstart presents a problem in conjunction with large
863c304004SBoris Popov  * reads.  To ensure a steady stream of ACKs while reading using
873c304004SBoris Popov  * large transaction sizes, we call soreceive() with a smaller
883c304004SBoris Popov  * buffer size.  See nbssn_recv().
893c304004SBoris Popov  */
903c304004SBoris Popov #define NB_SORECEIVE_CHUNK	(8 * 1024)
91681a5bbeSBoris Popov 
92681a5bbeSBoris Popov extern struct smb_tran_desc smb_tran_nbtcp_desc;
93681a5bbeSBoris Popov 
94681a5bbeSBoris Popov #endif /* _KERNEL */
95681a5bbeSBoris Popov 
96681a5bbeSBoris Popov #endif /* !_NETSMB_SMB_TRANTCP_H_ */
97