Remove macro definitions for BPF_MTAP
[dragonfly.git] / sys / sys / socketops.h
1 /*
2  * Copyright (c) 2003, 2004 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/sys/socketops.h,v 1.3 2004/03/06 01:58:57 hsu Exp $
31  */
32
33 #ifndef _SOCKETOPS_H_
34 #define _SOCKETOPS_H_
35
36 #include <sys/protosw.h>
37 #include <sys/socket.h>
38 #include <sys/socketvar.h>
39
40 /*
41  * sosend() and soreceive() can block and also calls other pru_usrreq functions.
42  * They should not really be usrreq functions.  Always call them directly from
43  * the process context rather than passing a message to the protocol thread.
44  */
45 static __inline int
46 so_pru_sosend(struct socket *so, struct sockaddr *addr, struct uio *uio,
47     struct mbuf *top, struct mbuf *control, int flags, struct thread *td)
48 {
49         return ((*so->so_proto->pr_usrreqs->pru_sosend)(so, addr, uio, top,
50             control, flags, td));
51 }
52
53 static __inline int
54 so_pru_soreceive(struct socket *so, struct sockaddr **paddr, struct uio *uio,
55     struct mbuf **mp0, struct mbuf **controlp, int *flagsp)
56 {
57         return ((*so->so_proto->pr_usrreqs->pru_soreceive)(so, paddr, uio, mp0,
58             controlp, flagsp));
59 }
60
61 #if defined(SMP) || defined(ALWAYS_MSG)
62
63 int so_pru_abort (struct socket *so);
64 int so_pru_accept (struct socket *so, struct sockaddr **nam);
65 int so_pru_attach (struct socket *so, int proto, struct pru_attach_info *ai);
66 int so_pru_bind (struct socket *so, struct sockaddr *nam, struct thread *td);
67 int so_pru_connect (struct socket *so, struct sockaddr *nam, struct thread *td);
68 int so_pru_connect2 (struct socket *so1, struct socket *so2);
69 int so_pru_control (struct socket *so, u_long cmd, caddr_t data,
70                     struct ifnet *ifp, struct thread *td);
71 int so_pru_detach (struct socket *so);
72 int so_pru_disconnect (struct socket *so);
73 int so_pru_listen (struct socket *so, struct thread *td);
74 int so_pru_peeraddr (struct socket *so, struct sockaddr **nam);
75 int so_pru_rcvd (struct socket *so, int flags);
76 int so_pru_rcvoob (struct socket *so, struct mbuf *m, int flags);
77 int so_pru_send (struct socket *so, int flags, struct mbuf *m,
78                  struct sockaddr *addr, struct mbuf *control,
79                  struct thread *td);
80 int so_pru_sense (struct socket *so, struct stat *sb);
81 int so_pru_shutdown (struct socket *so);
82 int so_pru_sockaddr (struct socket *so, struct sockaddr **nam);
83 int so_pru_sopoll (struct socket *so, int events, struct ucred *cred,
84                    struct thread *td);
85 int so_pr_ctloutput(struct socket *so, struct sockopt *sopt);
86
87 #else
88
89 #include <sys/protosw.h>
90
91 static __inline int
92 so_pru_abort(struct socket *so)
93 {
94         return ((*so->so_proto->pr_usrreqs->pru_abort)(so));
95 }
96
97 static __inline int
98 so_pru_accept(struct socket *so,
99     struct sockaddr **nam)
100 {
101         return ((*so->so_proto->pr_usrreqs->pru_accept)(so, nam));
102 }
103
104 static __inline int
105 so_pru_attach(struct socket *so, int proto, struct pru_attach_info *ai)
106 {
107         return ((*so->so_proto->pr_usrreqs->pru_attach)(so, proto, ai));
108 }
109
110 static __inline int
111 so_pru_bind(struct socket *so, struct sockaddr *nam, struct thread *td)
112 {
113         return ((*so->so_proto->pr_usrreqs->pru_bind)(so, nam, td));
114 }
115
116 static __inline int
117 so_pru_connect(struct socket *so, struct sockaddr *nam, struct thread *td)
118 {
119         return ((*so->so_proto->pr_usrreqs->pru_connect)(so, nam, td));
120 }
121
122 static __inline int
123 so_pru_connect2(struct socket *so1, struct socket *so2)
124 {
125         return ((*so1->so_proto->pr_usrreqs->pru_connect2)(so1, so2));
126 }
127
128 static __inline int
129 so_pru_control(struct socket *so, u_long cmd, caddr_t data, struct ifnet *ifp,
130     struct thread *td)
131 {
132         return ((*so->so_proto->pr_usrreqs->pru_control)(so, cmd, data, ifp,
133             td));
134 }
135
136 static __inline int
137 so_pru_detach(struct socket *so)
138 {
139         return ((*so->so_proto->pr_usrreqs->pru_detach)(so));
140 }
141
142 static __inline int
143 so_pru_disconnect(struct socket *so)
144 {
145         return ((*so->so_proto->pr_usrreqs->pru_disconnect)(so));
146 }
147
148 static __inline int
149 so_pru_listen(struct socket *so, struct thread *td)
150 {
151         return ((*so->so_proto->pr_usrreqs->pru_listen)(so, td));
152 }
153
154 static __inline int
155 so_pru_peeraddr(struct socket *so,
156     struct sockaddr **nam)
157 {
158         return ((*so->so_proto->pr_usrreqs->pru_peeraddr)(so, nam));
159 }
160
161 static __inline int
162 so_pru_rcvd(struct socket *so, int flags)
163 {
164         return ((*so->so_proto->pr_usrreqs->pru_rcvd)(so, flags));
165 }
166
167 static __inline int
168 so_pru_rcvoob(struct socket *so, struct mbuf *m, int flags)
169 {
170         return ((*so->so_proto->pr_usrreqs->pru_rcvoob)(so, m, flags));
171 }
172
173 static __inline int
174 so_pru_send(struct socket *so, int flags, struct mbuf *m,
175     struct sockaddr *addr, struct mbuf *control, struct thread *td)
176 {
177         return ((*so->so_proto->pr_usrreqs->pru_send)(so, flags, m, addr,
178             control, td));
179 }
180
181 static __inline int
182 so_pru_sense(struct socket *so, struct stat *sb)
183 {
184         return ((*so->so_proto->pr_usrreqs->pru_sense)(so, sb));
185 }
186
187 static __inline int
188 so_pru_shutdown(struct socket *so)
189 {
190         return ((*so->so_proto->pr_usrreqs->pru_shutdown)(so));
191 }
192
193 static __inline int
194 so_pru_sockaddr(struct socket *so, struct sockaddr **nam)
195 {
196         return ((*so->so_proto->pr_usrreqs->pru_sockaddr)(so, nam));
197 }
198
199 static __inline int
200 so_pru_sopoll(struct socket *so, int events, struct ucred *cred,
201     struct thread *td)
202 {
203         return ((*so->so_proto->pr_usrreqs->pru_sopoll)(so, events, cred, td));
204 }
205
206 static __inline int
207 so_pr_ctloutput(struct socket *so, struct sockopt *sopt)
208 {
209         return ((*so->so_proto->pr_ctloutput)(so, sopt));
210 }
211
212 #endif  /* defined(SMP) || defined(ALWAYS_MSG) */
213
214 #endif