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.
71 TAILQ_HEAD(notifymsglist, netmsg_so_notify);
73 struct netmsg_packet {
74 struct netmsg_base base;
75 struct mbuf *nm_packet;
79 struct netmsg_pr_timeout {
80 struct netmsg_base base;
83 struct netmsg_so_notify;
84 typedef __boolean_t (*msg_predicate_fn_t)(struct netmsg_so_notify *);
86 struct netmsg_so_notify {
87 struct netmsg_base base;
88 msg_predicate_fn_t nm_predicate;
89 int nm_fflags; /* flags e.g. FNONBLOCK */
90 int nm_etype; /* receive or send event */
91 TAILQ_ENTRY(netmsg_so_notify) nm_list;
94 struct netmsg_so_notify_abort {
95 struct netmsg_base base;
96 struct netmsg_so_notify *nm_notifymsg;
99 #define NM_REVENT 0x1 /* event on receive buffer */
100 #define NM_SEVENT 0x2 /* event on send buffer */
103 * User protocol requests messages.
105 struct netmsg_pru_abort {
106 struct netmsg_base base;
109 struct netmsg_pru_accept {
110 struct netmsg_base base;
111 struct sockaddr **nm_nam;
114 struct netmsg_pru_attach {
115 struct netmsg_base base;
117 struct pru_attach_info *nm_ai;
120 struct netmsg_pru_bind {
121 struct netmsg_base base;
122 struct sockaddr *nm_nam;
123 struct thread *nm_td;
126 struct netmsg_pru_connect {
127 struct netmsg_base base;
128 struct sockaddr *nm_nam;
129 struct thread *nm_td;
130 struct mbuf *nm_m; /* connect with send */
131 int nm_flags; /* connect with send */
132 int nm_reconnect; /* message control */
135 #define NMSG_RECONNECT_RECONNECT 0x0001 /* thread port change */
136 #define NMSG_RECONNECT_NAMALLOC 0x0002 /* nm_nam allocated */
137 #define NMSG_RECONNECT_PUSH 0x0004 /* call tcp_output */
138 #define NMSG_RECONNECT_FALLBACK 0x0008 /* fallback to ipv4 */
140 struct netmsg_pru_connect2 {
141 struct netmsg_base base;
142 struct socket *nm_so1;
143 struct socket *nm_so2;
146 struct netmsg_pru_control {
147 struct netmsg_base base;
150 struct ifnet *nm_ifp;
151 struct thread *nm_td;
154 struct netmsg_pru_detach {
155 struct netmsg_base base;
158 struct netmsg_pru_disconnect {
159 struct netmsg_base base;
162 struct netmsg_pru_listen {
163 struct netmsg_base base;
164 struct thread *nm_td;
167 struct netmsg_pru_peeraddr {
168 struct netmsg_base base;
169 struct sockaddr **nm_nam;
172 struct netmsg_pru_rcvd {
173 struct netmsg_base base;
175 int nm_pru_flags; /* PRUR_xxx */
178 #define PRUR_ASYNC 0x1
179 #define PRUR_DEAD 0x2
181 struct netmsg_pru_rcvoob {
182 struct netmsg_base base;
187 struct netmsg_pru_send {
188 struct netmsg_base base;
189 int nm_flags; /* PRUS_xxx */
191 struct sockaddr *nm_addr;
192 struct mbuf *nm_control;
193 struct thread *nm_td;
198 #define PRUS_MORETOCOME 0x4
199 #define PRUS_NAMALLOC 0x8
200 #define PRUS_NOREPLY 0x10
201 #define PRUS_DONTROUTE 0x20
202 #define PRUS_FREEADDR 0x40
204 struct netmsg_pru_sense {
205 struct netmsg_base base;
206 struct stat *nm_stat;
209 struct netmsg_pru_shutdown {
210 struct netmsg_base base;
213 struct netmsg_pru_sockaddr {
214 struct netmsg_base base;
215 struct sockaddr **nm_nam;
218 struct netmsg_pru_sosend {
219 struct netmsg_base base;
220 struct sockaddr *nm_addr;
223 struct mbuf *nm_control;
225 struct thread *nm_td;
228 struct netmsg_pru_soreceive {
229 struct netmsg_base base;
230 struct sockaddr *nm_addr;
231 struct sockaddr **nm_paddr;
233 struct sockbuf *nm_sio;
234 struct mbuf **nm_controlp;
238 struct netmsg_pr_ctloutput {
239 struct netmsg_base base;
240 struct sockopt *nm_sopt;
243 struct netmsg_pru_ctlinput {
244 struct netmsg_base base;
246 struct sockaddr *nm_arg;
251 * Union of all possible netmsgs. Note that when a netmsg is sent the
252 * actual allocated storage is likely only the size of the particular
253 * class of message, and not sizeof(union netmsg).
256 struct lwkt_msg lmsg; /* base embedded */
257 struct netmsg_base base; /* base embedded */
259 struct netmsg_packet packet; /* mbuf embedded */
260 struct netmsg_pr_timeout timeout;
261 struct netmsg_so_notify notify;
262 struct netmsg_so_notify_abort notify_abort;
264 struct netmsg_pr_ctloutput ctloutput;
266 struct netmsg_pru_abort abort;
267 struct netmsg_pru_accept accept; /* synchronous */
268 struct netmsg_pru_attach attach;
269 struct netmsg_pru_bind bind;
270 struct netmsg_pru_connect connect;
271 struct netmsg_pru_connect2 connect2;
272 struct netmsg_pru_control control; /* synchronous */
273 struct netmsg_pru_detach detach;
274 struct netmsg_pru_disconnect disconnect;
275 struct netmsg_pru_listen listen;
276 struct netmsg_pru_peeraddr peeraddr;
277 struct netmsg_pru_rcvd rcvd;
278 struct netmsg_pru_rcvoob rcvoob;
279 struct netmsg_pru_send send;
280 struct netmsg_pru_sense sense;
281 struct netmsg_pru_shutdown shutdown;
282 struct netmsg_pru_sockaddr sockaddr;
283 struct netmsg_pru_sosend sosend; /* synchronous */
284 struct netmsg_pru_soreceive soreceive; /* synchronous */
285 struct netmsg_pru_ctlinput ctlinput;
288 #endif /* _KERNEL || _KERNEL_STRUCTURES */
290 #endif /* !_NET_NETMSG_H_ */