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_cpufn_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 typedef struct netmsg_base *netmsg_base_t;
68 * - netmsg_packet is embedded in mbufs.
69 * - netmsg_pru_send is embedded in mbufs.
70 * - netmsg_inarp is embedded in mbufs.
72 TAILQ_HEAD(notifymsglist, netmsg_so_notify);
74 struct netmsg_packet {
75 struct netmsg_base base;
76 struct mbuf *nm_packet;
81 struct netmsg_base base;
88 struct netmsg_pr_timeout {
89 struct netmsg_base base;
92 struct netmsg_so_notify;
93 typedef __boolean_t (*msg_predicate_fn_t)(struct netmsg_so_notify *);
95 struct netmsg_so_notify {
96 struct netmsg_base base;
97 msg_predicate_fn_t nm_predicate;
98 int nm_fflags; /* flags e.g. FNONBLOCK */
99 int nm_etype; /* receive or send event */
100 TAILQ_ENTRY(netmsg_so_notify) nm_list;
103 struct netmsg_so_notify_abort {
104 struct netmsg_base base;
105 struct netmsg_so_notify *nm_notifymsg;
108 #define NM_REVENT 0x1 /* event on receive buffer */
109 #define NM_SEVENT 0x2 /* event on send buffer */
112 * User protocol requests messages.
114 struct netmsg_pru_abort {
115 struct netmsg_base base;
118 struct netmsg_pru_accept {
119 struct netmsg_base base;
120 struct sockaddr **nm_nam;
123 struct netmsg_pru_attach {
124 struct netmsg_base base;
126 struct pru_attach_info *nm_ai;
129 struct netmsg_pru_bind {
130 struct netmsg_base base;
131 struct sockaddr *nm_nam;
132 struct thread *nm_td;
135 struct netmsg_pru_connect {
136 struct netmsg_base base;
137 struct sockaddr *nm_nam;
138 struct thread *nm_td;
139 struct mbuf *nm_m; /* connect with send */
140 int nm_flags; /* connect with send */
141 int nm_reconnect; /* message control */
144 #define NMSG_RECONNECT_RECONNECT 0x0001 /* thread port change */
145 #define NMSG_RECONNECT_NAMALLOC 0x0002 /* nm_nam allocated */
146 #define NMSG_RECONNECT_PUSH 0x0004 /* call tcp_output */
147 #define NMSG_RECONNECT_FALLBACK 0x0008 /* fallback to ipv4 */
149 struct netmsg_pru_connect2 {
150 struct netmsg_base base;
151 struct socket *nm_so1;
152 struct socket *nm_so2;
155 struct netmsg_pru_control {
156 struct netmsg_base base;
159 struct ifnet *nm_ifp;
160 struct thread *nm_td;
163 struct netmsg_pru_detach {
164 struct netmsg_base base;
167 struct netmsg_pru_disconnect {
168 struct netmsg_base base;
171 struct netmsg_pru_listen {
172 struct netmsg_base base;
173 struct thread *nm_td;
176 struct netmsg_pru_peeraddr {
177 struct netmsg_base base;
178 struct sockaddr **nm_nam;
181 struct netmsg_pru_rcvd {
182 struct netmsg_base base;
184 int nm_pru_flags; /* PRUR_xxx */
187 #define PRUR_ASYNC 0x1
188 #define PRUR_DEAD 0x2
190 struct netmsg_pru_rcvoob {
191 struct netmsg_base base;
196 struct netmsg_pru_send {
197 struct netmsg_base base;
198 int nm_flags; /* PRUS_xxx */
200 struct sockaddr *nm_addr;
201 struct mbuf *nm_control;
202 struct thread *nm_td;
207 #define PRUS_MORETOCOME 0x4
208 #define PRUS_NAMALLOC 0x8
209 #define PRUS_NOREPLY 0x10
210 #define PRUS_DONTROUTE 0x20
211 #define PRUS_FREEADDR 0x40
213 struct netmsg_pru_sense {
214 struct netmsg_base base;
215 struct stat *nm_stat;
218 struct netmsg_pru_shutdown {
219 struct netmsg_base base;
222 struct netmsg_pru_sockaddr {
223 struct netmsg_base base;
224 struct sockaddr **nm_nam;
227 struct netmsg_pru_sosend {
228 struct netmsg_base base;
229 struct sockaddr *nm_addr;
232 struct mbuf *nm_control;
234 struct thread *nm_td;
237 struct netmsg_pru_soreceive {
238 struct netmsg_base base;
239 struct sockaddr *nm_addr;
240 struct sockaddr **nm_paddr;
242 struct sockbuf *nm_sio;
243 struct mbuf **nm_controlp;
247 struct netmsg_pr_ctloutput {
248 struct netmsg_base base;
249 struct sockopt *nm_sopt;
252 struct netmsg_pru_ctlinput {
253 struct netmsg_base base;
255 struct sockaddr *nm_arg;
260 * Union of all possible netmsgs. Note that when a netmsg is sent the
261 * actual allocated storage is likely only the size of the particular
262 * class of message, and not sizeof(union netmsg).
265 struct lwkt_msg lmsg; /* base embedded */
266 struct netmsg_base base; /* base embedded */
268 struct netmsg_packet packet; /* mbuf embedded */
269 struct netmsg_pr_timeout timeout;
270 struct netmsg_so_notify notify;
271 struct netmsg_so_notify_abort notify_abort;
273 struct netmsg_pr_ctloutput ctloutput;
275 struct netmsg_pru_abort abort;
276 struct netmsg_pru_accept accept; /* synchronous */
277 struct netmsg_pru_attach attach;
278 struct netmsg_pru_bind bind;
279 struct netmsg_pru_connect connect;
280 struct netmsg_pru_connect2 connect2;
281 struct netmsg_pru_control control; /* synchronous */
282 struct netmsg_pru_detach detach;
283 struct netmsg_pru_disconnect disconnect;
284 struct netmsg_pru_listen listen;
285 struct netmsg_pru_peeraddr peeraddr;
286 struct netmsg_pru_rcvd rcvd;
287 struct netmsg_pru_rcvoob rcvoob;
288 struct netmsg_pru_send send;
289 struct netmsg_pru_sense sense;
290 struct netmsg_pru_shutdown shutdown;
291 struct netmsg_pru_sockaddr sockaddr;
292 struct netmsg_pru_sosend sosend; /* synchronous */
293 struct netmsg_pru_soreceive soreceive; /* synchronous */
294 struct netmsg_pru_ctlinput ctlinput;
297 #endif /* _KERNEL || _KERNEL_STRUCTURES */
299 #endif /* !_NET_NETMSG_H_ */