WARNS6 cleanups
[dragonfly.git] / sys / sys / socketops.h
1 /*
2  * Copyright (c) 2003, 2004 Jeffrey M. Hsu.  All rights reserved.
3  * Copyright (c) 2003, 2004 The DragonFly Project.  All rights reserved.
4  * 
5  * This code is derived from software contributed to The DragonFly Project
6  * by Jeffrey M. Hsu.
7  * 
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. Neither the name of The DragonFly Project nor the names of its
17  *    contributors may be used to endorse or promote products derived
18  *    from this software without specific, prior written permission.
19  * 
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
24  * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25  * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
26  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31  * SUCH DAMAGE.
32  *
33  * $DragonFly: src/sys/sys/socketops.h,v 1.8 2006/05/21 03:43:47 dillon Exp $
34  */
35
36 /*
37  * Copyright (c) 2003, 2004 Jeffrey M. Hsu.  All rights reserved.
38  *
39  * License terms: all terms for the DragonFly license above plus the following:
40  *
41  * 4. All advertising materials mentioning features or use of this software
42  *    must display the following acknowledgement:
43  *
44  *      This product includes software developed by Jeffrey M. Hsu
45  *      for the DragonFly Project.
46  *
47  *    This requirement may be waived with permission from Jeffrey Hsu.
48  *    This requirement will sunset and may be removed on July 8 2005,
49  *    after which the standard DragonFly license (as shown above) will
50  *    apply.
51  */
52
53 #ifndef _SOCKETOPS_H_
54 #define _SOCKETOPS_H_
55
56 #ifndef _KERNEL
57
58 #error "This file should not be included by userland programs."
59
60 #else
61
62 #ifndef _SYS_PROTOSW_H_
63 #include <sys/protosw.h>
64 #endif
65 #ifndef _SYS_SOCKET_H_
66 #include <sys/socket.h>
67 #endif
68 #ifndef _SYS_SOCKETVAR_H_
69 #include <sys/socketvar.h>
70 #endif
71
72 /*
73  * sosend() and soreceive() can block and also calls other pru_usrreq functions.
74  * They should not really be usrreq functions.  Always call them directly from
75  * the process context rather than passing a message to the protocol thread.
76  */
77 static __inline int
78 so_pru_sosend(struct socket *so, struct sockaddr *addr, struct uio *uio,
79     struct mbuf *top, struct mbuf *control, int flags, struct thread *td)
80 {
81         return ((*so->so_proto->pr_usrreqs->pru_sosend)(so, addr, uio, top,
82             control, flags, td));
83 }
84
85 static __inline int
86 so_pru_soreceive(struct socket *so, struct sockaddr **paddr, struct uio *uio,
87     struct mbuf **mp0, struct mbuf **controlp, int *flagsp)
88 {
89         return ((*so->so_proto->pr_usrreqs->pru_soreceive)(so, paddr, uio, mp0,
90             controlp, flagsp));
91 }
92
93 int so_pru_abort (struct socket *so);
94 int so_pru_accept (struct socket *so, struct sockaddr **nam);
95 int so_pru_attach (struct socket *so, int proto, struct pru_attach_info *ai);
96 int so_pru_bind (struct socket *so, struct sockaddr *nam, struct thread *td);
97 int so_pru_connect (struct socket *so, struct sockaddr *nam, struct thread *td);
98 int so_pru_connect2 (struct socket *so1, struct socket *so2);
99 int so_pru_control (struct socket *so, u_long cmd, caddr_t data,
100                     struct ifnet *ifp);
101 int so_pru_detach (struct socket *so);
102 int so_pru_disconnect (struct socket *so);
103 int so_pru_listen (struct socket *so, struct thread *td);
104 int so_pru_peeraddr (struct socket *so, struct sockaddr **nam);
105 int so_pru_rcvd (struct socket *so, int flags);
106 int so_pru_rcvoob (struct socket *so, struct mbuf *m, int flags);
107 int so_pru_send (struct socket *so, int flags, struct mbuf *m,
108                  struct sockaddr *addr, struct mbuf *control,
109                  struct thread *td);
110 int so_pru_sense (struct socket *so, struct stat *sb);
111 int so_pru_shutdown (struct socket *so);
112 int so_pru_sockaddr (struct socket *so, struct sockaddr **nam);
113 int so_pru_sopoll (struct socket *so, int events, struct ucred *cred);
114 int so_pr_ctloutput(struct socket *so, struct sockopt *sopt);
115
116 #endif  /* _KERNEL */
117 #endif  /* _SYS_SOCKETOPS_H_ */