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>
45 typedef void (*netisr_fn_t
)(netmsg_t
);
46 typedef void (*netisr_ru_t
)(void);
47 typedef void (*netisr_hashfn_t
)(struct mbuf
**, int);
48 typedef void (*netisr_hashck_t
)(struct mbuf
*, const struct pktinfo
*);
50 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
53 * The base netmsg prefixes all netmsgs and includes an embedded LWKT
58 netisr_fn_t nm_dispatch
;
62 #define MSGF_IGNSOPORT MSGF_USER0 /* don't check so_port */
63 #define MSGF_PROTO1 MSGF_USER1 /* protocol specific */
65 typedef struct netmsg_base
*netmsg_base_t
;
71 * - netmsg_packet is embedded in mbufs.
72 * - netmsg_pru_send is embedded in mbufs.
73 * - netmsg_inarp is embedded in mbufs.
74 * - netmsg_ctlinput is embedded in mbufs.
75 * - netmsg_genpkt is embedded in mbufs.
76 * - netmsg_forward is embedded in mbufs.
78 TAILQ_HEAD(notifymsglist
, netmsg_so_notify
);
80 struct netmsg_packet
{
81 struct netmsg_base base
;
82 struct mbuf
*nm_packet
;
87 struct netmsg_base base
;
94 struct netmsg_ctlinput
{
95 struct netmsg_base base
;
102 struct netmsg_genpkt
{
103 struct netmsg_base base
;
109 struct netmsg_forward
{
110 struct netmsg_base base
;
111 struct mbuf
*nm_packet
;
112 __boolean_t using_srcrt
;
115 struct netmsg_pr_timeout
{
116 struct netmsg_base base
;
119 struct netmsg_so_notify
;
120 typedef __boolean_t (*msg_predicate_fn_t
)(struct netmsg_so_notify
*);
122 struct netmsg_so_notify
{
123 struct netmsg_base base
;
124 msg_predicate_fn_t nm_predicate
;
125 int nm_fflags
; /* flags e.g. FNONBLOCK */
126 int nm_etype
; /* receive or send event */
127 TAILQ_ENTRY(netmsg_so_notify
) nm_list
;
130 struct netmsg_so_notify_abort
{
131 struct netmsg_base base
;
132 struct netmsg_so_notify
*nm_notifymsg
;
135 #define NM_REVENT 0x1 /* event on receive buffer */
136 #define NM_SEVENT 0x2 /* event on send buffer */
139 * User protocol requests messages.
141 struct netmsg_pru_abort
{
142 struct netmsg_base base
;
145 struct netmsg_pru_accept
{
146 struct netmsg_base base
;
147 struct sockaddr
**nm_nam
;
150 struct netmsg_pru_attach
{
151 struct netmsg_base base
;
153 struct pru_attach_info
*nm_ai
;
156 struct netmsg_pru_bind
{
157 struct netmsg_base base
;
158 struct sockaddr
*nm_nam
;
159 struct thread
*nm_td
;
160 int nm_flags
; /* PRUB_ */
163 #define PRUB_RELINK 0x0001
165 struct netmsg_pru_connect
{
166 struct netmsg_base base
;
167 struct sockaddr
*nm_nam
;
168 struct thread
*nm_td
;
169 struct mbuf
*nm_m
; /* connect with send */
170 int nm_sndflags
; /* connect with send, PRUS_ */
171 int nm_flags
; /* message control */
174 #define PRUC_RECONNECT 0x0001 /* thread port change */
175 #define PRUC_PUSH 0x0004 /* call tcp_output */
176 #define PRUC_ASYNC 0x0010
177 #define PRUC_HELDTD 0x0020
178 #define PRUC_HASLADDR 0x0040
180 struct netmsg_pru_connect2
{
181 struct netmsg_base base
;
182 struct socket
*nm_so1
;
183 struct socket
*nm_so2
;
184 struct ucred
*nm_cred
;
187 struct netmsg_pru_control
{
188 struct netmsg_base base
;
191 struct ifnet
*nm_ifp
;
192 struct thread
*nm_td
;
195 struct netmsg_pru_detach
{
196 struct netmsg_base base
;
199 struct netmsg_pru_disconnect
{
200 struct netmsg_base base
;
203 struct netmsg_pru_listen
{
204 struct netmsg_base base
;
205 struct thread
*nm_td
;
206 int nm_flags
; /* PRUL_xxx */
209 #define PRUL_RELINK 0x1
211 struct netmsg_pru_peeraddr
{
212 struct netmsg_base base
;
213 struct sockaddr
**nm_nam
;
216 struct netmsg_pru_rcvd
{
217 struct netmsg_base base
;
219 int nm_pru_flags
; /* PRUR_xxx */
222 #define PRUR_ASYNC 0x1
223 #define PRUR_DEAD 0x2
225 struct netmsg_pru_rcvoob
{
226 struct netmsg_base base
;
231 struct netmsg_pru_send
{
232 struct netmsg_base base
;
233 int nm_flags
; /* PRUS_xxx */
234 int nm_priv
; /* proto priv. */
236 struct sockaddr
*nm_addr
;
237 struct mbuf
*nm_control
;
238 struct thread
*nm_td
;
243 #define PRUS_MORETOCOME 0x4
244 #define PRUS_NAMALLOC 0x8
245 #define PRUS_NOREPLY 0x10
246 #define PRUS_DONTROUTE 0x20
247 #define PRUS_FREEADDR 0x40
248 #define PRUS_HELDTD 0x80
250 struct netmsg_pru_sense
{
251 struct netmsg_base base
;
252 struct stat
*nm_stat
;
255 struct netmsg_pru_shutdown
{
256 struct netmsg_base base
;
259 struct netmsg_pru_sockaddr
{
260 struct netmsg_base base
;
261 struct sockaddr
**nm_nam
;
264 struct netmsg_pru_sosend
{
265 struct netmsg_base base
;
266 struct sockaddr
*nm_addr
;
269 struct mbuf
*nm_control
;
271 struct thread
*nm_td
;
274 struct netmsg_pru_soreceive
{
275 struct netmsg_base base
;
276 struct sockaddr
*nm_addr
;
277 struct sockaddr
**nm_paddr
;
279 struct sockbuf
*nm_sio
;
280 struct mbuf
**nm_controlp
;
284 struct netmsg_pr_ctloutput
{
285 struct netmsg_base base
;
286 int nm_flags
; /* PRCO_xx */
287 struct sockopt
*nm_sopt
;
290 #define PRCO_HELDTD 0x1
292 struct netmsg_pr_ctlinput
{
293 struct netmsg_base base
;
296 struct sockaddr
*nm_arg
;
301 * Union of all possible netmsgs. Note that when a netmsg is sent the
302 * actual allocated storage is likely only the size of the particular
303 * class of message, and not sizeof(union netmsg).
306 struct lwkt_msg lmsg
; /* base embedded */
307 struct netmsg_base base
; /* base embedded */
309 struct netmsg_packet packet
; /* mbuf embedded */
310 struct netmsg_forward forward
; /* mbuf embedded */
311 struct netmsg_pr_timeout timeout
;
312 struct netmsg_so_notify notify
;
313 struct netmsg_so_notify_abort notify_abort
;
315 struct netmsg_pr_ctloutput ctloutput
;
316 struct netmsg_pr_ctlinput ctlinput
;
318 struct netmsg_pru_abort abort
;
319 struct netmsg_pru_accept accept
; /* synchronous */
320 struct netmsg_pru_attach attach
;
321 struct netmsg_pru_bind bind
;
322 struct netmsg_pru_connect connect
;
323 struct netmsg_pru_connect2 connect2
;
324 struct netmsg_pru_control control
; /* synchronous */
325 struct netmsg_pru_detach detach
;
326 struct netmsg_pru_disconnect disconnect
;
327 struct netmsg_pru_listen listen
;
328 struct netmsg_pru_peeraddr peeraddr
;
329 struct netmsg_pru_rcvd rcvd
;
330 struct netmsg_pru_rcvoob rcvoob
;
331 struct netmsg_pru_send send
;
332 struct netmsg_pru_sense sense
;
333 struct netmsg_pru_shutdown shutdown
;
334 struct netmsg_pru_sockaddr sockaddr
;
335 struct netmsg_pru_sosend sosend
; /* synchronous */
336 struct netmsg_pru_soreceive soreceive
; /* synchronous */
339 #endif /* _KERNEL || _KERNEL_STRUCTURES */
341 #endif /* !_NET_NETMSG_H_ */