1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  *  linux/include/linux/sunrpc/xprtsock.h
4  *
5  *  Declarations for the RPC transport socket provider.
6  */
7 
8 #ifndef _LINUX_SUNRPC_XPRTSOCK_H
9 #define _LINUX_SUNRPC_XPRTSOCK_H
10 
11 #ifdef __KERNEL__
12 
13 int		init_socket_xprt(void);
14 void		cleanup_socket_xprt(void);
15 
16 #define RPC_MIN_RESVPORT	(1U)
17 #define RPC_MAX_RESVPORT	(65535U)
18 #define RPC_DEF_MIN_RESVPORT	(665U)
19 #define RPC_DEF_MAX_RESVPORT	(1023U)
20 
21 struct sock_xprt {
22 	struct rpc_xprt		xprt;
23 
24 	/*
25 	 * Network layer
26 	 */
27 	struct socket *		sock;
28 	struct sock *		inet;
29 
30 	/*
31 	 * State of TCP reply receive
32 	 */
33 	__be32			tcp_fraghdr,
34 				tcp_xid,
35 				tcp_calldir;
36 
37 	u32			tcp_offset,
38 				tcp_reclen;
39 
40 	unsigned long		tcp_copied,
41 				tcp_flags;
42 
43 	/*
44 	 * Connection of transports
45 	 */
46 	unsigned long		sock_state;
47 	struct delayed_work	connect_worker;
48 	struct work_struct	recv_worker;
49 	struct mutex		recv_mutex;
50 	struct sockaddr_storage	srcaddr;
51 	unsigned short		srcport;
52 
53 	/*
54 	 * UDP socket buffer size parameters
55 	 */
56 	size_t			rcvsize,
57 				sndsize;
58 
59 	struct rpc_timeout	tcp_timeout;
60 
61 	/*
62 	 * Saved socket callback addresses
63 	 */
64 	void			(*old_data_ready)(struct sock *);
65 	void			(*old_state_change)(struct sock *);
66 	void			(*old_write_space)(struct sock *);
67 	void			(*old_error_report)(struct sock *);
68 };
69 
70 /*
71  * TCP receive state flags
72  */
73 #define TCP_RCV_LAST_FRAG	(1UL << 0)
74 #define TCP_RCV_COPY_FRAGHDR	(1UL << 1)
75 #define TCP_RCV_COPY_XID	(1UL << 2)
76 #define TCP_RCV_COPY_DATA	(1UL << 3)
77 #define TCP_RCV_READ_CALLDIR	(1UL << 4)
78 #define TCP_RCV_COPY_CALLDIR	(1UL << 5)
79 
80 /*
81  * TCP RPC flags
82  */
83 #define TCP_RPC_REPLY		(1UL << 6)
84 
85 #define XPRT_SOCK_CONNECTING	1U
86 #define XPRT_SOCK_DATA_READY	(2)
87 #define XPRT_SOCK_UPD_TIMEOUT	(3)
88 
89 #endif /* __KERNEL__ */
90 
91 #endif /* _LINUX_SUNRPC_XPRTSOCK_H */
92