| Commit | Line | Data |
|---|---|---|
| 6b6e0885 | 1 | /* |
| 66d6c637 JH |
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 | * | |
| 6b6e0885 JH |
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. | |
| 66d6c637 JH |
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. | |
| 6b6e0885 | 19 | * |
| 66d6c637 JH |
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 | * | |
| e3873585 | 33 | * $DragonFly: src/sys/sys/socketops.h,v 1.14 2008/10/27 02:56:30 sephe Exp $ |
| 6b6e0885 JH |
34 | */ |
| 35 | ||
| 36 | #ifndef _SOCKETOPS_H_ | |
| 37 | #define _SOCKETOPS_H_ | |
| 38 | ||
| d9f3f6fa | 39 | #ifndef _KERNEL |
| 03d6a592 | 40 | |
| d9f3f6fa | 41 | #error "This file should not be included by userland programs." |
| d9f3f6fa | 42 | |
| 03d6a592 MD |
43 | #else |
| 44 | ||
| 45 | #ifndef _SYS_PROTOSW_H_ | |
| 6b6e0885 | 46 | #include <sys/protosw.h> |
| 03d6a592 MD |
47 | #endif |
| 48 | #ifndef _SYS_SOCKET_H_ | |
| 6b6e0885 | 49 | #include <sys/socket.h> |
| 03d6a592 MD |
50 | #endif |
| 51 | #ifndef _SYS_SOCKETVAR_H_ | |
| 6b6e0885 | 52 | #include <sys/socketvar.h> |
| 03d6a592 | 53 | #endif |
| 6b6e0885 | 54 | |
| 9eeaa8a9 JH |
55 | /* |
| 56 | * sosend() and soreceive() can block and also calls other pru_usrreq functions. | |
| 57 | * They should not really be usrreq functions. Always call them directly from | |
| 58 | * the process context rather than passing a message to the protocol thread. | |
| 59 | */ | |
| 6b6e0885 JH |
60 | static __inline int |
| 61 | so_pru_sosend(struct socket *so, struct sockaddr *addr, struct uio *uio, | |
| 002c1265 MD |
62 | struct mbuf *top, struct mbuf *control, int flags, |
| 63 | struct thread *td) | |
| 6b6e0885 JH |
64 | { |
| 65 | return ((*so->so_proto->pr_usrreqs->pru_sosend)(so, addr, uio, top, | |
| 002c1265 | 66 | control, flags, td)); |
| 6b6e0885 JH |
67 | } |
| 68 | ||
| 69 | static __inline int | |
| 70 | so_pru_soreceive(struct socket *so, struct sockaddr **paddr, struct uio *uio, | |
| 002c1265 | 71 | struct sockbuf *sio, struct mbuf **controlp, int *flagsp) |
| 6b6e0885 | 72 | { |
| d8a9a23b MD |
73 | return ((*so->so_proto->pr_usrreqs->pru_soreceive)(so, paddr, uio, sio, |
| 74 | controlp, flagsp)); | |
| 6b6e0885 JH |
75 | } |
| 76 | ||
| 4402d8a2 MD |
77 | void so_pru_abort (struct socket *so); |
| 78 | void so_pru_aborta (struct socket *so); | |
| fd86a41c | 79 | void so_pru_abort_oncpu (struct socket *so); |
| 002c1265 | 80 | int so_pru_accept_direct(struct socket *so, struct sockaddr **nam); |
| 9eeaa8a9 | 81 | int so_pru_attach (struct socket *so, int proto, struct pru_attach_info *ai); |
| 002c1265 MD |
82 | int so_pru_attach_direct(struct socket *so, int proto, |
| 83 | struct pru_attach_info *ai); | |
| 9eeaa8a9 JH |
84 | int so_pru_bind (struct socket *so, struct sockaddr *nam, struct thread *td); |
| 85 | int so_pru_connect (struct socket *so, struct sockaddr *nam, struct thread *td); | |
| 86 | int so_pru_connect2 (struct socket *so1, struct socket *so2); | |
| 002c1265 | 87 | int so_pru_control_direct(struct socket *so, u_long cmd, caddr_t data, |
| 48e7b118 | 88 | struct ifnet *ifp); |
| 9eeaa8a9 | 89 | int so_pru_detach (struct socket *so); |
| acd31a69 | 90 | void so_pru_detach_direct (struct socket *so); |
| 9eeaa8a9 | 91 | int so_pru_disconnect (struct socket *so); |
| acd31a69 | 92 | void so_pru_disconnect_direct (struct socket *so); |
| 9eeaa8a9 JH |
93 | int so_pru_listen (struct socket *so, struct thread *td); |
| 94 | int so_pru_peeraddr (struct socket *so, struct sockaddr **nam); | |
| 95 | int so_pru_rcvd (struct socket *so, int flags); | |
| 96 | int so_pru_rcvoob (struct socket *so, struct mbuf *m, int flags); | |
| f2a3782e | 97 | void so_pru_sync (struct socket *so); |
| 9eeaa8a9 | 98 | int so_pru_send (struct socket *so, int flags, struct mbuf *m, |
| 48e7b118 MD |
99 | struct sockaddr *addr, struct mbuf *control, |
| 100 | struct thread *td); | |
| 0ad8e15e SZ |
101 | void so_pru_send_async (struct socket *so, int flags, struct mbuf *m, |
| 102 | struct sockaddr *addr, struct mbuf *control, | |
| 103 | struct thread *td); | |
| 9eeaa8a9 JH |
104 | int so_pru_sense (struct socket *so, struct stat *sb); |
| 105 | int so_pru_shutdown (struct socket *so); | |
| 106 | int so_pru_sockaddr (struct socket *so, struct sockaddr **nam); | |
| 002c1265 | 107 | int so_pr_ctloutput(struct socket *so, struct sockopt *sopt); |
| e3873585 | 108 | void so_pru_ctlinput(struct protosw *pr, int cmd, |
| 48e7b118 | 109 | struct sockaddr *arg, void *extra); |
| 9eeaa8a9 | 110 | |
| 084009e2 SZ |
111 | static __inline int |
| 112 | so_pru_senda(struct socket *so, int flags, struct mbuf *m, | |
| 113 | struct sockaddr *addr, struct mbuf *control, struct thread *td) | |
| 114 | { | |
| 115 | if (so->so_proto->pr_flags & PR_ASYNC_SEND) { | |
| 116 | so_pru_send_async(so, flags, m, addr, control, td); | |
| 117 | return 0; | |
| 118 | } else { | |
| 119 | return so_pru_send(so, flags, m, addr, control, td); | |
| 120 | } | |
| 121 | } | |
| 122 | ||
| 03d6a592 MD |
123 | #endif /* _KERNEL */ |
| 124 | #endif /* _SYS_SOCKETOPS_H_ */ |