2 * Copyright (c) 2003 Jeffrey Hsu
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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 Jeffrey M. Hsu.
16 * 4. The name of the author may not be used to endorse or promote products
17 * derived from this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
21 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
23 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
24 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 * $DragonFly: src/sys/net/netmsg.h,v 1.10 2008/10/27 02:56:30 sephe Exp $
33 #ifndef _NET_NETMSG_H_
34 #define _NET_NETMSG_H_
36 #ifndef _SYS_THREAD_H_
37 #include <sys/thread.h>
39 #ifndef _SYS_PROTOSW_H_
40 #include <sys/protosw.h>
43 typedef void (*netisr_fn_t)(netmsg_t);
44 typedef void (*netisr_ru_t)(void);
45 typedef void (*netisr_cpufn_t)(struct mbuf **, int);
47 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
50 * The base netmsg prefixes all netmsgs and includes an embedded LWKT
55 netisr_fn_t nm_dispatch;
59 typedef struct netmsg_base *netmsg_base_t;
64 * NOTE: netmsg_packet is embedded in mbufs.
66 TAILQ_HEAD(notifymsglist, netmsg_so_notify);
68 struct netmsg_packet {
69 struct netmsg_base base;
70 struct mbuf *nm_packet;
74 struct netmsg_pr_timeout {
75 struct netmsg_base base;
78 struct netmsg_so_notify;
79 typedef __boolean_t (*msg_predicate_fn_t)(struct netmsg_so_notify *);
81 struct netmsg_so_notify {
82 struct netmsg_base base;
83 msg_predicate_fn_t nm_predicate;
84 int nm_fflags; /* flags e.g. FNONBLOCK */
85 int nm_etype; /* receive or send event */
86 TAILQ_ENTRY(netmsg_so_notify) nm_list;
89 struct netmsg_so_notify_abort {
90 struct netmsg_base base;
91 struct netmsg_so_notify *nm_notifymsg;
94 #define NM_REVENT 0x1 /* event on receive buffer */
95 #define NM_SEVENT 0x2 /* event on send buffer */
98 * User protocol requests messages.
100 struct netmsg_pru_abort {
101 struct netmsg_base base;
104 struct netmsg_pru_accept {
105 struct netmsg_base base;
106 struct sockaddr **nm_nam;
109 struct netmsg_pru_attach {
110 struct netmsg_base base;
112 struct pru_attach_info *nm_ai;
115 struct netmsg_pru_bind {
116 struct netmsg_base base;
117 struct sockaddr *nm_nam;
118 struct thread *nm_td;
121 struct netmsg_pru_connect {
122 struct netmsg_base base;
123 struct sockaddr *nm_nam;
124 struct thread *nm_td;
125 struct mbuf *nm_m; /* connect with send */
126 int nm_flags; /* connect with send */
127 int nm_reconnect; /* message control */
130 #define NMSG_RECONNECT_RECONNECT 0x0001 /* thread port change */
131 #define NMSG_RECONNECT_NAMALLOC 0x0002 /* nm_nam allocated */
132 #define NMSG_RECONNECT_PUSH 0x0004 /* call tcp_output */
133 #define NMSG_RECONNECT_FALLBACK 0x0008 /* fallback to ipv4 */
135 struct netmsg_pru_connect2 {
136 struct netmsg_base base;
137 struct socket *nm_so1;
138 struct socket *nm_so2;
141 struct netmsg_pru_control {
142 struct netmsg_base base;
145 struct ifnet *nm_ifp;
146 struct thread *nm_td;
149 struct netmsg_pru_detach {
150 struct netmsg_base base;
153 struct netmsg_pru_disconnect {
154 struct netmsg_base base;
157 struct netmsg_pru_listen {
158 struct netmsg_base base;
159 struct thread *nm_td;
162 struct netmsg_pru_peeraddr {
163 struct netmsg_base base;
164 struct sockaddr **nm_nam;
167 struct netmsg_pru_rcvd {
168 struct netmsg_base base;
172 struct netmsg_pru_rcvoob {
173 struct netmsg_base base;
178 struct netmsg_pru_send {
179 struct netmsg_base base;
180 int nm_flags; /* PRUS_xxx */
182 struct sockaddr *nm_addr;
183 struct mbuf *nm_control;
184 struct thread *nm_td;
186 * XXX hack to be 100% certain netmsg_pru_send can be overwritten
187 * by netmsg_pru_connect
189 char nm_dummy[sizeof(struct netmsg_pru_connect) -
190 sizeof(struct netmsg_base)];
195 #define PRUS_MORETOCOME 0x4
196 #define PRUS_NAMALLOC 0x8
198 struct netmsg_pru_sense {
199 struct netmsg_base base;
200 struct stat *nm_stat;
203 struct netmsg_pru_shutdown {
204 struct netmsg_base base;
207 struct netmsg_pru_sockaddr {
208 struct netmsg_base base;
209 struct sockaddr **nm_nam;
212 struct netmsg_pru_sosend {
213 struct netmsg_base base;
214 struct sockaddr *nm_addr;
217 struct mbuf *nm_control;
219 struct thread *nm_td;
222 struct netmsg_pru_soreceive {
223 struct netmsg_base base;
224 struct sockaddr *nm_addr;
225 struct sockaddr **nm_paddr;
227 struct sockbuf *nm_sio;
228 struct mbuf **nm_controlp;
232 struct netmsg_pr_ctloutput {
233 struct netmsg_base base;
234 struct sockopt *nm_sopt;
237 struct netmsg_pru_ctlinput {
238 struct netmsg_base base;
240 struct sockaddr *nm_arg;
245 * Union of all possible netmsgs. Note that when a netmsg is sent the
246 * actual allocated storage is likely only the size of the particular
247 * class of message, and not sizeof(union netmsg).
250 struct lwkt_msg lmsg; /* base embedded */
251 struct netmsg_base base; /* base embedded */
253 struct netmsg_packet packet; /* mbuf embedded */
254 struct netmsg_pr_timeout timeout;
255 struct netmsg_so_notify notify;
256 struct netmsg_so_notify_abort notify_abort;
258 struct netmsg_pr_ctloutput ctloutput;
260 struct netmsg_pru_abort abort;
261 struct netmsg_pru_accept accept; /* synchronous */
262 struct netmsg_pru_attach attach;
263 struct netmsg_pru_bind bind;
264 struct netmsg_pru_connect connect;
265 struct netmsg_pru_connect2 connect2;
266 struct netmsg_pru_control control; /* synchronous */
267 struct netmsg_pru_detach detach;
268 struct netmsg_pru_disconnect disconnect;
269 struct netmsg_pru_listen listen;
270 struct netmsg_pru_peeraddr peeraddr;
271 struct netmsg_pru_rcvd rcvd;
272 struct netmsg_pru_rcvoob rcvoob;
273 struct netmsg_pru_send send;
274 struct netmsg_pru_sense sense;
275 struct netmsg_pru_shutdown shutdown;
276 struct netmsg_pru_sockaddr sockaddr;
277 struct netmsg_pru_sosend sosend; /* synchronous */
278 struct netmsg_pru_soreceive soreceive; /* synchronous */
279 struct netmsg_pru_ctlinput ctlinput;
282 #endif /* _KERNEL || _KERNEL_STRUCTURES */
284 #endif /* !_NET_NETMSG_H_ */