FEATURES: document various missed changes
[unleashed/lotheac.git] / include / sys / socket_proto.h
blob07295ba88683adf1400b5aad707d92a619203793
1 /*
2 * CDDL HEADER START
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.
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.
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]
19 * CDDL HEADER END
22 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
25 #ifndef _SYS_SOCKET_PROTO_H_
26 #define _SYS_SOCKET_PROTO_H_
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
32 #include <sys/socket.h>
33 #include <sys/cred.h>
34 #include <sys/stream.h>
37 * Generation count
39 typedef uint64_t sock_connid_t;
41 #define SOCK_CONNID_INIT(id) { \
42 (id) = 0; \
44 #define SOCK_CONNID_BUMP(id) (++(id))
45 #define SOCK_CONNID_LT(id1, id2) ((int64_t)((id1)-(id2)) < 0)
47 /* Socket protocol properties */
48 struct sock_proto_props {
49 uint_t sopp_flags; /* options to set */
50 ushort_t sopp_wroff; /* write offset */
51 ssize_t sopp_txhiwat; /* tx hi water mark */
52 ssize_t sopp_txlowat; /* tx lo water mark */
53 ssize_t sopp_rxhiwat; /* recv high water mark */
54 ssize_t sopp_rxlowat; /* recv low water mark */
55 ssize_t sopp_maxblk; /* maximum message block size */
56 ssize_t sopp_maxpsz; /* maximum packet size */
57 ssize_t sopp_minpsz; /* minimum packet size */
58 ushort_t sopp_tail; /* space available at the end */
59 uint_t sopp_zcopyflag; /* zero copy flag */
60 boolean_t sopp_oobinline; /* OOB inline */
61 uint_t sopp_rcvtimer; /* delayed recv notification (time) */
62 uint32_t sopp_rcvthresh; /* delayed recv notification (bytes) */
63 socklen_t sopp_maxaddrlen; /* maximum size of protocol address */
64 boolean_t sopp_loopback; /* loopback connection */
67 /* flags to determine which socket options are set */
68 #define SOCKOPT_WROFF 0x0001 /* set write offset */
69 #define SOCKOPT_RCVHIWAT 0x0002 /* set read side high water */
70 #define SOCKOPT_RCVLOWAT 0x0004 /* set read side high water */
71 #define SOCKOPT_MAXBLK 0x0008 /* set maximum message block size */
72 #define SOCKOPT_TAIL 0x0010 /* set the extra allocated space */
73 #define SOCKOPT_ZCOPY 0x0020 /* set/unset zero copy for sendfile */
74 #define SOCKOPT_MAXPSZ 0x0040 /* set maxpsz for protocols */
75 #define SOCKOPT_OOBINLINE 0x0080 /* set oob inline processing */
76 #define SOCKOPT_RCVTIMER 0x0100
77 #define SOCKOPT_RCVTHRESH 0x0200
78 #define SOCKOPT_MAXADDRLEN 0x0400 /* set max address length */
79 #define SOCKOPT_MINPSZ 0x0800 /* set minpsz for protocols */
80 #define SOCKOPT_LOOPBACK 0x1000 /* set loopback */
82 #define IS_SO_OOB_INLINE(so) ((so)->so_proto_props.sopp_oobinline)
84 #ifdef _KERNEL
86 struct T_capability_ack;
88 typedef struct sock_upcalls_s sock_upcalls_t;
89 typedef struct sock_downcalls_s sock_downcalls_t;
92 * Upcall and downcall handle for sockfs and transport layer.
94 typedef struct __sock_upper_handle *sock_upper_handle_t;
95 typedef struct __sock_lower_handle *sock_lower_handle_t;
97 struct sock_downcalls_s {
98 void (*sd_activate)(sock_lower_handle_t, sock_upper_handle_t,
99 sock_upcalls_t *, int, cred_t *);
100 int (*sd_accept)(sock_lower_handle_t, sock_lower_handle_t,
101 sock_upper_handle_t, cred_t *);
102 int (*sd_bind)(sock_lower_handle_t, struct sockaddr *, socklen_t,
103 cred_t *);
104 int (*sd_listen)(sock_lower_handle_t, int, cred_t *);
105 int (*sd_connect)(sock_lower_handle_t, const struct sockaddr *,
106 socklen_t, sock_connid_t *, cred_t *);
107 int (*sd_getpeername)(sock_lower_handle_t, struct sockaddr *,
108 socklen_t *, cred_t *);
109 int (*sd_getsockname)(sock_lower_handle_t, struct sockaddr *,
110 socklen_t *, cred_t *);
111 int (*sd_getsockopt)(sock_lower_handle_t, int, int, void *,
112 socklen_t *, cred_t *);
113 int (*sd_setsockopt)(sock_lower_handle_t, int, int, const void *,
114 socklen_t, cred_t *);
115 int (*sd_send)(sock_lower_handle_t, mblk_t *, struct msghdr *,
116 cred_t *);
117 int (*sd_send_uio)(sock_lower_handle_t, uio_t *, struct msghdr *,
118 cred_t *);
119 int (*sd_recv_uio)(sock_lower_handle_t, uio_t *, struct msghdr *,
120 cred_t *);
121 short (*sd_poll)(sock_lower_handle_t, short, int, cred_t *);
122 int (*sd_shutdown)(sock_lower_handle_t, int, cred_t *);
123 void (*sd_clr_flowctrl)(sock_lower_handle_t);
124 int (*sd_ioctl)(sock_lower_handle_t, int, intptr_t, int,
125 int32_t *, cred_t *);
126 int (*sd_close)(sock_lower_handle_t, int, cred_t *);
129 typedef sock_lower_handle_t (*so_proto_create_func_t)(int, int, int,
130 sock_downcalls_t **, uint_t *, int *, int, cred_t *);
132 typedef struct sock_quiesce_arg {
133 mblk_t *soqa_exdata_mp;
134 mblk_t *soqa_urgmark_mp;
135 } sock_quiesce_arg_t;
136 typedef mblk_t *(*so_proto_quiesced_cb_t)(sock_upper_handle_t,
137 sock_quiesce_arg_t *, struct T_capability_ack *, struct sockaddr *,
138 socklen_t, struct sockaddr *, socklen_t, short);
139 typedef int (*so_proto_fallback_func_t)(sock_lower_handle_t, queue_t *,
140 boolean_t, so_proto_quiesced_cb_t, sock_quiesce_arg_t *);
143 * These functions return EOPNOTSUPP and are intended for the sockfs
144 * developer that doesn't wish to supply stubs for every function themselves.
146 extern int sock_accept_notsupp(sock_lower_handle_t, sock_lower_handle_t,
147 sock_upper_handle_t, cred_t *);
148 extern int sock_bind_notsupp(sock_lower_handle_t, struct sockaddr *,
149 socklen_t, cred_t *);
150 extern int sock_listen_notsupp(sock_lower_handle_t, int, cred_t *);
151 extern int sock_connect_notsupp(sock_lower_handle_t,
152 const struct sockaddr *, socklen_t, sock_connid_t *, cred_t *);
153 extern int sock_getpeername_notsupp(sock_lower_handle_t, struct sockaddr *,
154 socklen_t *, cred_t *);
155 extern int sock_getsockname_notsupp(sock_lower_handle_t, struct sockaddr *,
156 socklen_t *, cred_t *);
157 extern int sock_getsockopt_notsupp(sock_lower_handle_t, int, int, void *,
158 socklen_t *, cred_t *);
159 extern int sock_setsockopt_notsupp(sock_lower_handle_t, int, int,
160 const void *, socklen_t, cred_t *);
161 extern int sock_send_notsupp(sock_lower_handle_t, mblk_t *,
162 struct msghdr *, cred_t *);
163 extern int sock_send_uio_notsupp(sock_lower_handle_t, uio_t *,
164 struct msghdr *, cred_t *);
165 extern int sock_recv_uio_notsupp(sock_lower_handle_t, uio_t *,
166 struct msghdr *, cred_t *);
167 extern short sock_poll_notsupp(sock_lower_handle_t, short, int, cred_t *);
168 extern int sock_shutdown_notsupp(sock_lower_handle_t, int, cred_t *);
169 extern void sock_clr_flowctrl_notsupp(sock_lower_handle_t);
170 extern int sock_ioctl_notsupp(sock_lower_handle_t, int, intptr_t, int,
171 int32_t *, cred_t *);
172 extern int sock_close_notsupp(sock_lower_handle_t, int, cred_t *);
175 * Upcalls and related information
179 * su_opctl() actions
181 typedef enum sock_opctl_action {
182 SOCK_OPCTL_ENAB_ACCEPT = 0,
183 SOCK_OPCTL_SHUT_SEND,
184 SOCK_OPCTL_SHUT_RECV
185 } sock_opctl_action_t;
187 struct sock_upcalls_s {
188 sock_upper_handle_t (*su_newconn)(sock_upper_handle_t,
189 sock_lower_handle_t, sock_downcalls_t *, cred_t *, pid_t,
190 sock_upcalls_t **);
191 void (*su_connected)(sock_upper_handle_t, sock_connid_t, cred_t *,
192 pid_t);
193 int (*su_disconnected)(sock_upper_handle_t, sock_connid_t, int);
194 void (*su_opctl)(sock_upper_handle_t, sock_opctl_action_t,
195 uintptr_t);
196 ssize_t (*su_recv)(sock_upper_handle_t, mblk_t *, size_t, int,
197 int *, boolean_t *);
198 void (*su_set_proto_props)(sock_upper_handle_t,
199 struct sock_proto_props *);
200 void (*su_txq_full)(sock_upper_handle_t, boolean_t);
201 void (*su_signal_oob)(sock_upper_handle_t, ssize_t);
202 void (*su_zcopy_notify)(sock_upper_handle_t);
203 void (*su_set_error)(sock_upper_handle_t, int);
204 void (*su_closed)(sock_upper_handle_t);
207 #define SOCK_UC_VERSION sizeof (sock_upcalls_t)
208 #define SOCK_DC_VERSION sizeof (sock_downcalls_t)
210 #define SOCKET_RECVHIWATER (48 * 1024)
211 #define SOCKET_RECVLOWATER 1024
213 #define SOCKET_NO_RCVTIMER 0
214 #define SOCKET_TIMER_INTERVAL 50
216 #endif /* _KERNEL */
218 #ifdef __cplusplus
220 #endif
222 #endif /* _SYS_SOCKET_PROTO_H_ */