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 */
64 typedef struct netmsg_base *netmsg_base_t;
70 * - netmsg_packet is embedded in mbufs.
71 * - netmsg_pru_send is embedded in mbufs.
72 * - netmsg_inarp is embedded in mbufs.
74 TAILQ_HEAD(notifymsglist, netmsg_so_notify);
76 struct netmsg_packet {
77 struct netmsg_base base;
78 struct mbuf *nm_packet;
83 struct netmsg_base base;
90 struct netmsg_pr_timeout {
91 struct netmsg_base base;
94 struct netmsg_so_notify;
95 typedef __boolean_t (*msg_predicate_fn_t)(struct netmsg_so_notify *);
97 struct netmsg_so_notify {
98 struct netmsg_base base;
99 msg_predicate_fn_t nm_predicate;
100 int nm_fflags; /* flags e.g. FNONBLOCK */
101 int nm_etype; /* receive or send event */
102 TAILQ_ENTRY(netmsg_so_notify) nm_list;
105 struct netmsg_so_notify_abort {
106 struct netmsg_base base;
107 struct netmsg_so_notify *nm_notifymsg;
110 #define NM_REVENT 0x1 /* event on receive buffer */
111 #define NM_SEVENT 0x2 /* event on send buffer */
114 * User protocol requests messages.
116 struct netmsg_pru_abort {
117 struct netmsg_base base;
120 struct netmsg_pru_accept {
121 struct netmsg_base base;
122 struct sockaddr **nm_nam;
125 struct netmsg_pru_attach {
126 struct netmsg_base base;
128 struct pru_attach_info *nm_ai;
131 struct netmsg_pru_bind {
132 struct netmsg_base base;
133 struct sockaddr *nm_nam;
134 struct thread *nm_td;
137 struct netmsg_pru_connect {
138 struct netmsg_base base;
139 struct sockaddr *nm_nam;
140 struct thread *nm_td;
141 struct mbuf *nm_m; /* connect with send */
142 int nm_sndflags; /* connect with send, PRUS_ */
143 int nm_flags; /* message control */
146 #define PRUC_RECONNECT 0x0001 /* thread port change */
147 #define PRUC_NAMALLOC 0x0002 /* nm_nam allocated */
148 #define PRUC_PUSH 0x0004 /* call tcp_output */
149 #define PRUC_FALLBACK 0x0008 /* fallback to ipv4 */
150 #define PRUC_ASYNC 0x0010
151 #define PRUC_HELDTD 0x0020
152 #define PRUC_HASLADDR 0x0040
154 struct netmsg_pru_connect2 {
155 struct netmsg_base base;
156 struct socket *nm_so1;
157 struct socket *nm_so2;
160 struct netmsg_pru_control {
161 struct netmsg_base base;
164 struct ifnet *nm_ifp;
165 struct thread *nm_td;
168 struct netmsg_pru_detach {
169 struct netmsg_base base;
172 struct netmsg_pru_disconnect {
173 struct netmsg_base base;
176 struct netmsg_pru_listen {
177 struct netmsg_base base;
178 struct thread *nm_td;
179 int nm_flags; /* PRUL_xxx */
182 #define PRUL_RELINK 0x1
184 struct netmsg_pru_peeraddr {
185 struct netmsg_base base;
186 struct sockaddr **nm_nam;
189 struct netmsg_pru_rcvd {
190 struct netmsg_base base;
192 int nm_pru_flags; /* PRUR_xxx */
195 #define PRUR_ASYNC 0x1
196 #define PRUR_DEAD 0x2
198 struct netmsg_pru_rcvoob {
199 struct netmsg_base base;
204 struct netmsg_pru_send {
205 struct netmsg_base base;
206 int nm_flags; /* PRUS_xxx */
207 int nm_priv; /* proto priv. */
209 struct sockaddr *nm_addr;
210 struct mbuf *nm_control;
211 struct thread *nm_td;
216 #define PRUS_MORETOCOME 0x4
217 #define PRUS_NAMALLOC 0x8
218 #define PRUS_NOREPLY 0x10
219 #define PRUS_DONTROUTE 0x20
220 #define PRUS_FREEADDR 0x40
221 #define PRUS_HELDTD 0x80
223 struct netmsg_pru_sense {
224 struct netmsg_base base;
225 struct stat *nm_stat;
228 struct netmsg_pru_shutdown {
229 struct netmsg_base base;
232 struct netmsg_pru_sockaddr {
233 struct netmsg_base base;
234 struct sockaddr **nm_nam;
237 struct netmsg_pru_sosend {
238 struct netmsg_base base;
239 struct sockaddr *nm_addr;
242 struct mbuf *nm_control;
244 struct thread *nm_td;
247 struct netmsg_pru_soreceive {
248 struct netmsg_base base;
249 struct sockaddr *nm_addr;
250 struct sockaddr **nm_paddr;
252 struct sockbuf *nm_sio;
253 struct mbuf **nm_controlp;
257 struct netmsg_pr_ctloutput {
258 struct netmsg_base base;
259 struct sockopt *nm_sopt;
262 struct netmsg_pru_ctlinput {
263 struct netmsg_base base;
265 struct sockaddr *nm_arg;
270 * Union of all possible netmsgs. Note that when a netmsg is sent the
271 * actual allocated storage is likely only the size of the particular
272 * class of message, and not sizeof(union netmsg).
275 struct lwkt_msg lmsg; /* base embedded */
276 struct netmsg_base base; /* base embedded */
278 struct netmsg_packet packet; /* mbuf embedded */
279 struct netmsg_pr_timeout timeout;
280 struct netmsg_so_notify notify;
281 struct netmsg_so_notify_abort notify_abort;
283 struct netmsg_pr_ctloutput ctloutput;
285 struct netmsg_pru_abort abort;
286 struct netmsg_pru_accept accept; /* synchronous */
287 struct netmsg_pru_attach attach;
288 struct netmsg_pru_bind bind;
289 struct netmsg_pru_connect connect;
290 struct netmsg_pru_connect2 connect2;
291 struct netmsg_pru_control control; /* synchronous */
292 struct netmsg_pru_detach detach;
293 struct netmsg_pru_disconnect disconnect;
294 struct netmsg_pru_listen listen;
295 struct netmsg_pru_peeraddr peeraddr;
296 struct netmsg_pru_rcvd rcvd;
297 struct netmsg_pru_rcvoob rcvoob;
298 struct netmsg_pru_send send;
299 struct netmsg_pru_sense sense;
300 struct netmsg_pru_shutdown shutdown;
301 struct netmsg_pru_sockaddr sockaddr;
302 struct netmsg_pru_sosend sosend; /* synchronous */
303 struct netmsg_pru_soreceive soreceive; /* synchronous */
304 struct netmsg_pru_ctlinput ctlinput;
307 #endif /* _KERNEL || _KERNEL_STRUCTURES */
309 #endif /* !_NET_NETMSG_H_ */