e279feb50f40474a3e7ad20255337ffeb0d2f1e3
[dragonfly.git] / sys / net / netmsg.h
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  *
30  * $DragonFly: src/sys/net/netmsg.h,v 1.8 2008/09/17 11:22:13 sephe Exp $
31  */
32
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
42
43 struct netmsg;
44
45 typedef void (*netisr_fn_t)(struct netmsg *);
46
47 /*
48  * Base netmsg
49  */
50 typedef struct netmsg {
51     struct lwkt_msg     nm_lmsg;
52     netisr_fn_t         nm_dispatch;
53 } *netmsg_t;
54
55 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
56
57 /*
58  * User protocol requests messages.
59  */
60 struct netmsg_pru_abort {
61     struct netmsg       nm_netmsg;
62     pru_abort_fn_t      nm_prufn;
63     struct socket       *nm_so;
64 };
65
66 struct netmsg_pru_accept {
67     struct netmsg       nm_netmsg;
68     pru_accept_fn_t     nm_prufn;
69     struct socket       *nm_so;
70     struct sockaddr     **nm_nam;
71 };
72
73 struct netmsg_pru_attach {
74     struct netmsg       nm_netmsg;
75     pru_attach_fn_t     nm_prufn;
76     struct socket       *nm_so;
77     int                 nm_proto;
78     struct pru_attach_info *nm_ai;
79 };
80
81 struct netmsg_pru_bind {
82     struct netmsg       nm_netmsg;
83     pru_bind_fn_t       nm_prufn;
84     struct socket       *nm_so;
85     struct sockaddr     *nm_nam;
86     struct thread       *nm_td;
87 };
88
89 struct netmsg_pru_connect {
90     struct netmsg       nm_netmsg;
91     pru_connect_fn_t    nm_prufn;
92     struct socket       *nm_so;
93     struct sockaddr     *nm_nam;
94     struct thread       *nm_td;
95 };
96
97 struct netmsg_pru_connect2 {
98     struct netmsg       nm_netmsg;
99     pru_connect2_fn_t   nm_prufn;
100     struct socket       *nm_so1;
101     struct socket       *nm_so2;
102 };
103
104 struct netmsg_pru_control {
105     struct netmsg       nm_netmsg;
106     pru_control_fn_t    nm_prufn;
107     struct socket       *nm_so;
108     u_long              nm_cmd;
109     caddr_t             nm_data;
110     struct ifnet        *nm_ifp;
111     struct thread       *nm_td;
112 };
113
114 struct netmsg_pru_detach {
115     struct netmsg       nm_netmsg;
116     pru_detach_fn_t     nm_prufn;
117     struct socket       *nm_so;
118 };
119
120 struct netmsg_pru_disconnect {
121     struct netmsg       nm_netmsg;
122     pru_disconnect_fn_t nm_prufn;
123     struct socket       *nm_so;
124 };
125
126 struct netmsg_pru_listen {
127     struct netmsg       nm_netmsg;
128     pru_listen_fn_t     nm_prufn;
129     struct socket       *nm_so;
130     struct thread       *nm_td;
131 };
132
133 struct netmsg_pru_peeraddr {
134     struct netmsg       nm_netmsg;
135     pru_peeraddr_fn_t   nm_prufn;
136     struct socket       *nm_so;
137     struct sockaddr     **nm_nam;
138 };
139
140 struct netmsg_pru_rcvd {
141     struct netmsg       nm_netmsg;
142     pru_rcvd_fn_t       nm_prufn;
143     struct socket       *nm_so;
144     int                 nm_flags;
145 };
146
147 struct netmsg_pru_rcvoob {
148     struct netmsg       nm_netmsg;
149     pru_rcvoob_fn_t     nm_prufn;
150     struct socket       *nm_so;
151     struct mbuf         *nm_m;
152     int                 nm_flags;
153 };
154
155 struct netmsg_pru_send {
156     struct netmsg       nm_netmsg;
157     pru_send_fn_t       nm_prufn;
158     struct socket       *nm_so;
159     int                 nm_flags;
160     struct mbuf         *nm_m;
161     struct sockaddr     *nm_addr;
162     struct mbuf         *nm_control;
163     struct thread       *nm_td;
164 };
165
166 struct netmsg_pru_sense {
167     struct netmsg       nm_netmsg;
168     pru_sense_fn_t      nm_prufn;
169     struct socket       *nm_so;
170     struct stat         *nm_stat;
171 };
172
173 struct netmsg_pru_shutdown {
174     struct netmsg       nm_netmsg;
175     pru_shutdown_fn_t   nm_prufn;
176     struct socket       *nm_so;
177 };
178
179 struct netmsg_pru_sockaddr {
180     struct netmsg       nm_netmsg;
181     pru_sockaddr_fn_t   nm_prufn;
182     struct socket       *nm_so;
183     struct sockaddr     **nm_nam;
184 };
185
186 struct netmsg_pru_sosend {
187     struct netmsg       nm_netmsg;
188     pru_sosend_fn_t     nm_prufn;
189     struct socket       *nm_so;
190     struct sockaddr     *nm_addr;
191     struct uio          *nm_uio;
192     struct mbuf         *nm_top;
193     struct mbuf         *nm_control;
194     int                 nm_flags;
195     struct thread       *nm_td;
196 };
197
198 struct netmsg_pru_soreceive {
199     struct netmsg       nm_netmsg;
200     struct sockaddr     *nm_addr;
201     struct socket       *nm_so;
202     struct sockaddr     **nm_paddr;
203     struct uio          *nm_uio;
204     struct sockbuf      *nm_sio;
205     struct mbuf         **nm_controlp;
206     int                 *nm_flagsp;
207 };
208
209 struct netmsg_pru_sopoll {
210     struct netmsg       nm_netmsg;
211     pru_sopoll_fn_t     nm_prufn;
212     struct socket       *nm_so;
213     int                 nm_events;
214     struct ucred        *nm_cred;
215     struct thread       *nm_td;
216 };
217
218 struct netmsg_pru_ctloutput {
219     struct netmsg       nm_netmsg;
220     pru_ctloutput_fn_t  nm_prufn;
221     struct socket       *nm_so;
222     struct sockopt      *nm_sopt;
223 };
224
225 #endif  /* _KERNEL || _KERNEL_STRUCTURES */
226
227 #endif  /* !_NET_NETMSG_H_ */