| Commit | Line | Data |
|---|---|---|
| 8a113dae JH |
1 | /* |
| 2 | * Copyright (c) 2003 Jeffrey Hsu | |
| 3 | * All rights reserved. | |
| 4 | * | |
| 5 | * Redistribution and use in source and binary forms, with or without | |
| 6 | * modification, are permitted provided that the following conditions | |
| 7 | * are met: | |
| 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. | |
| 18 | * | |
| 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. | |
| 29 | * | |
| e3873585 | 30 | * $DragonFly: src/sys/net/netmsg.h,v 1.10 2008/10/27 02:56:30 sephe Exp $ |
| 8a113dae JH |
31 | */ |
| 32 | ||
| 1bd40720 MD |
33 | #ifndef _NET_NETMSG_H_ |
| 34 | #define _NET_NETMSG_H_ | |
| 35 | ||
| 36 | #ifndef _SYS_THREAD_H_ | |
| 37 | #include <sys/thread.h> | |
| 38 | #endif | |
| 39 | #ifndef _SYS_PROTOSW_H_ | |
| 40 | #include <sys/protosw.h> | |
| 41 | #endif | |
| 8a113dae | 42 | |
| e6f77b88 SZ |
43 | struct pktinfo; |
| 44 | ||
| 002c1265 | 45 | typedef void (*netisr_fn_t)(netmsg_t); |
| c3c96e44 MD |
46 | typedef void (*netisr_ru_t)(void); |
| 47 | typedef void (*netisr_cpufn_t)(struct mbuf **, int); | |
| e6f77b88 | 48 | typedef void (*netisr_hashck_t)(struct mbuf *, const struct pktinfo *); |
| 4599cf19 | 49 | |
| 002c1265 MD |
50 | #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES) |
| 51 | ||
| 4599cf19 | 52 | /* |
| 002c1265 MD |
53 | * The base netmsg prefixes all netmsgs and includes an embedded LWKT |
| 54 | * message. | |
| 4599cf19 | 55 | */ |
| 002c1265 MD |
56 | struct netmsg_base { |
| 57 | struct lwkt_msg lmsg; | |
| c3c96e44 MD |
58 | netisr_fn_t nm_dispatch; |
| 59 | struct socket *nm_so; | |
| 002c1265 | 60 | }; |
| 4599cf19 | 61 | |
| 002c1265 MD |
62 | typedef struct netmsg_base *netmsg_base_t; |
| 63 | ||
| 64 | /* | |
| 65 | * NETISR messages | |
| 66 | * | |
| 67 | * NOTE: netmsg_packet is embedded in mbufs. | |
| 68 | */ | |
| 69 | TAILQ_HEAD(notifymsglist, netmsg_so_notify); | |
| 70 | ||
| 71 | struct netmsg_packet { | |
| 72 | struct netmsg_base base; | |
| 73 | struct mbuf *nm_packet; | |
| 74 | int nm_nxt; | |
| 75 | }; | |
| 76 | ||
| 77 | struct netmsg_pr_timeout { | |
| 78 | struct netmsg_base base; | |
| 79 | }; | |
| 80 | ||
| 81 | struct netmsg_so_notify; | |
| 82 | typedef __boolean_t (*msg_predicate_fn_t)(struct netmsg_so_notify *); | |
| 83 | ||
| 84 | struct netmsg_so_notify { | |
| 85 | struct netmsg_base base; | |
| 86 | msg_predicate_fn_t nm_predicate; | |
| 87 | int nm_fflags; /* flags e.g. FNONBLOCK */ | |
| 88 | int nm_etype; /* receive or send event */ | |
| 89 | TAILQ_ENTRY(netmsg_so_notify) nm_list; | |
| 90 | }; | |
| 91 | ||
| 92 | struct netmsg_so_notify_abort { | |
| 93 | struct netmsg_base base; | |
| 94 | struct netmsg_so_notify *nm_notifymsg; | |
| 95 | }; | |
| 96 | ||
| 97 | #define NM_REVENT 0x1 /* event on receive buffer */ | |
| 98 | #define NM_SEVENT 0x2 /* event on send buffer */ | |
| 8d420ad8 | 99 | |
| 8a113dae JH |
100 | /* |
| 101 | * User protocol requests messages. | |
| 102 | */ | |
| 103 | struct netmsg_pru_abort { | |
| 002c1265 | 104 | struct netmsg_base base; |
| 8a113dae JH |
105 | }; |
| 106 | ||
| 107 | struct netmsg_pru_accept { | |
| 002c1265 | 108 | struct netmsg_base base; |
| c3c96e44 | 109 | struct sockaddr **nm_nam; |
| 8a113dae JH |
110 | }; |
| 111 | ||
| 112 | struct netmsg_pru_attach { | |
| 002c1265 | 113 | struct netmsg_base base; |
| c3c96e44 MD |
114 | int nm_proto; |
| 115 | struct pru_attach_info *nm_ai; | |
| 8a113dae JH |
116 | }; |
| 117 | ||
| 118 | struct netmsg_pru_bind { | |
| 002c1265 | 119 | struct netmsg_base base; |
| c3c96e44 MD |
120 | struct sockaddr *nm_nam; |
| 121 | struct thread *nm_td; | |
| 8a113dae JH |
122 | }; |
| 123 | ||
| 124 | struct netmsg_pru_connect { | |
| 002c1265 | 125 | struct netmsg_base base; |
| c3c96e44 MD |
126 | struct sockaddr *nm_nam; |
| 127 | struct thread *nm_td; | |
| 002c1265 MD |
128 | struct mbuf *nm_m; /* connect with send */ |
| 129 | int nm_flags; /* connect with send */ | |
| 130 | int nm_reconnect; /* message control */ | |
| 8a113dae JH |
131 | }; |
| 132 | ||
| 002c1265 MD |
133 | #define NMSG_RECONNECT_RECONNECT 0x0001 /* thread port change */ |
| 134 | #define NMSG_RECONNECT_NAMALLOC 0x0002 /* nm_nam allocated */ | |
| 135 | #define NMSG_RECONNECT_PUSH 0x0004 /* call tcp_output */ | |
| 136 | #define NMSG_RECONNECT_FALLBACK 0x0008 /* fallback to ipv4 */ | |
| 137 | ||
| 8a113dae | 138 | struct netmsg_pru_connect2 { |
| 002c1265 | 139 | struct netmsg_base base; |
| c3c96e44 MD |
140 | struct socket *nm_so1; |
| 141 | struct socket *nm_so2; | |
| 8a113dae JH |
142 | }; |
| 143 | ||
| 144 | struct netmsg_pru_control { | |
| 002c1265 | 145 | struct netmsg_base base; |
| c3c96e44 MD |
146 | u_long nm_cmd; |
| 147 | caddr_t nm_data; | |
| 148 | struct ifnet *nm_ifp; | |
| 149 | struct thread *nm_td; | |
| 8a113dae JH |
150 | }; |
| 151 | ||
| 152 | struct netmsg_pru_detach { | |
| 002c1265 | 153 | struct netmsg_base base; |
| 8a113dae JH |
154 | }; |
| 155 | ||
| 156 | struct netmsg_pru_disconnect { | |
| 002c1265 | 157 | struct netmsg_base base; |
| 8a113dae JH |
158 | }; |
| 159 | ||
| 160 | struct netmsg_pru_listen { | |
| 002c1265 | 161 | struct netmsg_base base; |
| c3c96e44 | 162 | struct thread *nm_td; |
| 8a113dae JH |
163 | }; |
| 164 | ||
| 165 | struct netmsg_pru_peeraddr { | |
| 002c1265 | 166 | struct netmsg_base base; |
| c3c96e44 | 167 | struct sockaddr **nm_nam; |
| 8a113dae JH |
168 | }; |
| 169 | ||
| 170 | struct netmsg_pru_rcvd { | |
| 002c1265 | 171 | struct netmsg_base base; |
| c3c96e44 | 172 | int nm_flags; |
| 8a113dae JH |
173 | }; |
| 174 | ||
| 175 | struct netmsg_pru_rcvoob { | |
| 002c1265 | 176 | struct netmsg_base base; |
| c3c96e44 MD |
177 | struct mbuf *nm_m; |
| 178 | int nm_flags; | |
| 8a113dae JH |
179 | }; |
| 180 | ||
| 181 | struct netmsg_pru_send { | |
| 002c1265 MD |
182 | struct netmsg_base base; |
| 183 | int nm_flags; /* PRUS_xxx */ | |
| c3c96e44 MD |
184 | struct mbuf *nm_m; |
| 185 | struct sockaddr *nm_addr; | |
| 186 | struct mbuf *nm_control; | |
| 187 | struct thread *nm_td; | |
| 002c1265 MD |
188 | /* |
| 189 | * XXX hack to be 100% certain netmsg_pru_send can be overwritten | |
| 190 | * by netmsg_pru_connect | |
| 191 | */ | |
| 192 | char nm_dummy[sizeof(struct netmsg_pru_connect) - | |
| 193 | sizeof(struct netmsg_base)]; | |
| 8a113dae JH |
194 | }; |
| 195 | ||
| 002c1265 MD |
196 | #define PRUS_OOB 0x1 |
| 197 | #define PRUS_EOF 0x2 | |
| 198 | #define PRUS_MORETOCOME 0x4 | |
| 199 | #define PRUS_NAMALLOC 0x8 | |
| 200 | ||
| 8a113dae | 201 | struct netmsg_pru_sense { |
| 002c1265 | 202 | struct netmsg_base base; |
| c3c96e44 | 203 | struct stat *nm_stat; |
| 8a113dae JH |
204 | }; |
| 205 | ||
| 206 | struct netmsg_pru_shutdown { | |
| 002c1265 | 207 | struct netmsg_base base; |
| 8a113dae JH |
208 | }; |
| 209 | ||
| 210 | struct netmsg_pru_sockaddr { | |
| 002c1265 | 211 | struct netmsg_base base; |
| c3c96e44 | 212 | struct sockaddr **nm_nam; |
| 8a113dae JH |
213 | }; |
| 214 | ||
| 215 | struct netmsg_pru_sosend { | |
| 002c1265 | 216 | struct netmsg_base base; |
| c3c96e44 MD |
217 | struct sockaddr *nm_addr; |
| 218 | struct uio *nm_uio; | |
| 219 | struct mbuf *nm_top; | |
| 220 | struct mbuf *nm_control; | |
| 221 | int nm_flags; | |
| 222 | struct thread *nm_td; | |
| 8a113dae JH |
223 | }; |
| 224 | ||
| 225 | struct netmsg_pru_soreceive { | |
| 002c1265 | 226 | struct netmsg_base base; |
| c3c96e44 MD |
227 | struct sockaddr *nm_addr; |
| 228 | struct sockaddr **nm_paddr; | |
| 229 | struct uio *nm_uio; | |
| 230 | struct sockbuf *nm_sio; | |
| 231 | struct mbuf **nm_controlp; | |
| 232 | int *nm_flagsp; | |
| 8a113dae JH |
233 | }; |
| 234 | ||
| 002c1265 MD |
235 | struct netmsg_pr_ctloutput { |
| 236 | struct netmsg_base base; | |
| c3c96e44 | 237 | struct sockopt *nm_sopt; |
| e71a125f AE |
238 | }; |
| 239 | ||
| e3873585 | 240 | struct netmsg_pru_ctlinput { |
| 002c1265 | 241 | struct netmsg_base base; |
| c3c96e44 MD |
242 | int nm_cmd; |
| 243 | struct sockaddr *nm_arg; | |
| 244 | void *nm_extra; | |
| e3873585 SZ |
245 | }; |
| 246 | ||
| 002c1265 MD |
247 | /* |
| 248 | * Union of all possible netmsgs. Note that when a netmsg is sent the | |
| 249 | * actual allocated storage is likely only the size of the particular | |
| 250 | * class of message, and not sizeof(union netmsg). | |
| 251 | */ | |
| 252 | union netmsg { | |
| 253 | struct lwkt_msg lmsg; /* base embedded */ | |
| 254 | struct netmsg_base base; /* base embedded */ | |
| 255 | ||
| 256 | struct netmsg_packet packet; /* mbuf embedded */ | |
| 257 | struct netmsg_pr_timeout timeout; | |
| 258 | struct netmsg_so_notify notify; | |
| 259 | struct netmsg_so_notify_abort notify_abort; | |
| 260 | ||
| 261 | struct netmsg_pr_ctloutput ctloutput; | |
| 262 | ||
| 263 | struct netmsg_pru_abort abort; | |
| 264 | struct netmsg_pru_accept accept; /* synchronous */ | |
| 265 | struct netmsg_pru_attach attach; | |
| 266 | struct netmsg_pru_bind bind; | |
| 267 | struct netmsg_pru_connect connect; | |
| 268 | struct netmsg_pru_connect2 connect2; | |
| 269 | struct netmsg_pru_control control; /* synchronous */ | |
| 270 | struct netmsg_pru_detach detach; | |
| 271 | struct netmsg_pru_disconnect disconnect; | |
| 272 | struct netmsg_pru_listen listen; | |
| 273 | struct netmsg_pru_peeraddr peeraddr; | |
| 274 | struct netmsg_pru_rcvd rcvd; | |
| 275 | struct netmsg_pru_rcvoob rcvoob; | |
| 276 | struct netmsg_pru_send send; | |
| 277 | struct netmsg_pru_sense sense; | |
| 278 | struct netmsg_pru_shutdown shutdown; | |
| 279 | struct netmsg_pru_sockaddr sockaddr; | |
| 280 | struct netmsg_pru_sosend sosend; /* synchronous */ | |
| 281 | struct netmsg_pru_soreceive soreceive; /* synchronous */ | |
| 282 | struct netmsg_pru_ctlinput ctlinput; | |
| 283 | }; | |
| 284 | ||
| 8d420ad8 SZ |
285 | #endif /* _KERNEL || _KERNEL_STRUCTURES */ |
| 286 | ||
| 287 | #endif /* !_NET_NETMSG_H_ */ |