| 6 |
| * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. |
| 7 | * |
| 8 | * Redistribution and use in source and binary forms, with or without |
| 9 | * modification, are permitted provided that the following conditions are met: |
| 10 | * |
| 11 | * a) Redistributions of source code must retain the above copyright notice, |
| 12 | * this list of conditions and the following disclaimer. |
| 13 | * |
| 14 | * b) Redistributions in binary form must reproduce the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer in |
| 16 | * the documentation and/or other materials provided with the distribution. |
| 17 | * |
| 18 | * c) Neither the name of Cisco Systems, Inc. nor the names of its |
| 19 | * contributors may be used to endorse or promote products derived |
| 20 | * from this software without specific prior written permission. |
| 21 | * |
| 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
| 24 | * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 26 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 27 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 28 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 29 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 30 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 31 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
| 32 | * THE POSSIBILITY OF SUCH DAMAGE. |
| 33 | */ |
| 34 |
| 35 | #if defined(__FreeBSD__) && !defined(__Userspace__) |
| 36 | #include <sys/cdefs.h> |
| 37 | __FBSDID("$FreeBSD: head/sys/netinet/sctp_output.h 366114 2020-09-24 12:26:06Z tuexen $"); |
| 38 | #endif |
| 39 |
| 40 | #ifndef _NETINET_SCTP_OUTPUT_H_ |
| 41 | #define _NETINET_SCTP_OUTPUT_H_ |
| 42 |
| 43 | #include <netinet/sctp_header.h> |
| 44 |
| 45 | #if defined(_KERNEL) || defined(__Userspace__) |
| 46 |
| 47 | struct mbuf * |
| 48 | sctp_add_addresses_to_i_ia(struct sctp_inpcb *inp, |
| 49 | struct sctp_tcb *stcb, |
| 50 | struct sctp_scoping *scope, |
| 51 | struct mbuf *m_at, |
| 52 | int cnt_inits_to, |
| 53 | uint16_t *padding_len, uint16_t *chunk_len); |
| 54 |
| 55 | int sctp_is_addr_restricted(struct sctp_tcb *, struct sctp_ifa *); |
| 56 |
| 57 | int |
| 58 | sctp_is_address_in_scope(struct sctp_ifa *ifa, |
| 59 | struct sctp_scoping *scope, |
| 60 | int do_update); |
| 61 |
| 62 | int |
| 63 | sctp_is_addr_in_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa); |
| 64 |
| 65 | struct sctp_ifa * |
| 66 | sctp_source_address_selection(struct sctp_inpcb *inp, |
| 67 | struct sctp_tcb *stcb, |
| 68 | sctp_route_t *ro, struct sctp_nets *net, |
| 69 | int non_asoc_addr_ok, uint32_t vrf_id); |
| 70 |
| 71 | #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Userspace__) |
| 72 | int sctp_v6src_match_nexthop(struct sockaddr_in6 *src6, sctp_route_t *ro); |
| 73 |
| 74 | int sctp_v4src_match_nexthop(struct sctp_ifa *sifa, sctp_route_t *ro); |
| 75 | #endif |
| 76 |
| 77 | void sctp_send_initiate(struct sctp_inpcb *, struct sctp_tcb *, int); |
| 78 |
| 79 | void |
| 80 | sctp_send_initiate_ack(struct sctp_inpcb *, struct sctp_tcb *, |
| 81 | struct sctp_nets *, struct mbuf *, |
| 82 | int, int, |
| 83 | struct sockaddr *, struct sockaddr *, |
| 84 | struct sctphdr *, struct sctp_init_chunk *, |
| 85 | #if defined(__FreeBSD__) && !defined(__Userspace__) |
| 86 | uint8_t, uint32_t, |
| 87 | #endif |
| 88 | uint32_t, uint16_t); |
| 89 |
| 90 | struct mbuf * |
| 91 | sctp_arethere_unrecognized_parameters(struct mbuf *, int, int *, |
| 92 | struct sctp_chunkhdr *, int *, int *); |
| 93 | void sctp_queue_op_err(struct sctp_tcb *, struct mbuf *); |
| 94 |
| 95 | int |
| 96 | sctp_send_cookie_echo(struct mbuf *, int, int, struct sctp_tcb *, |
| 97 | struct sctp_nets *); |
| 98 |
| 99 | void sctp_send_cookie_ack(struct sctp_tcb *); |
| 100 |
| 101 | void |
| 102 | sctp_send_heartbeat_ack(struct sctp_tcb *, struct mbuf *, int, int, |
| 103 | struct sctp_nets *); |
| 104 |
| 105 | void |
| 106 | sctp_remove_from_wheel(struct sctp_tcb *stcb, |
| 107 | struct sctp_association *asoc, |
| 108 | struct sctp_stream_out *strq, int holds_lock); |
| 109 |
| 110 | void sctp_send_shutdown(struct sctp_tcb *, struct sctp_nets *); |
| 111 |
| 112 | void sctp_send_shutdown_ack(struct sctp_tcb *, struct sctp_nets *); |
| 113 |
| 114 | void sctp_send_shutdown_complete(struct sctp_tcb *, struct sctp_nets *, int); |
| 115 |
| 116 | void sctp_send_shutdown_complete2(struct sockaddr *, struct sockaddr *, |
| 117 | struct sctphdr *, |
| 118 | #if defined(__FreeBSD__) && !defined(__Userspace__) |
| 119 | uint8_t, uint32_t, uint16_t, |
| 120 | #endif |
| 121 | uint32_t, uint16_t); |
| 122 |
| 123 | void sctp_send_asconf(struct sctp_tcb *, struct sctp_nets *, int addr_locked); |
| 124 |
| 125 | void sctp_send_asconf_ack(struct sctp_tcb *); |
| 126 |
| 127 | int sctp_get_frag_point(struct sctp_tcb *, struct sctp_association *); |
| 128 |
| 129 | void sctp_toss_old_cookies(struct sctp_tcb *, struct sctp_association *); |
| 130 |
| 131 | void sctp_toss_old_asconf(struct sctp_tcb *); |
| 132 |
| 133 | void sctp_fix_ecn_echo(struct sctp_association *); |
| 134 |
| 135 | void sctp_move_chunks_from_net(struct sctp_tcb *stcb, struct sctp_nets *net); |
| 136 |
| 137 | #define SCTP_DATA_CHUNK_OVERHEAD(stcb) ((stcb)->asoc.idata_supported ? \ |
| 138 | sizeof(struct sctp_idata_chunk) : \ |
| 139 | sizeof(struct sctp_data_chunk)) |
| 140 |
| 141 | #if defined(__FreeBSD__) && !defined(__Userspace__) |
| 142 | int |
| 143 | sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *, |
| 144 | struct mbuf *, struct thread *, int); |
| 145 | #elif defined(_WIN32) && !defined(__Userspace__) |
| 146 | sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *, |
| 147 | struct mbuf *, PKTHREAD, int); |
| 148 | #else |
| 149 | #if defined(__Userspace__) |
| 150 | /* sctp_output is called bu sctp_sendm. Not using sctp_sendm for __Userspace__ */ |
| 151 | #endif |
| 152 | int |
| 153 | sctp_output(struct sctp_inpcb *, |
| 154 | struct mbuf *, |
| 155 | struct sockaddr *, |
| 156 | struct mbuf *, |
| 157 | struct proc *, int); |
| 158 | #endif |
| 159 |
| 160 | void sctp_chunk_output(struct sctp_inpcb *, struct sctp_tcb *, int, int); |
| 161 |
| 162 | void sctp_send_abort_tcb(struct sctp_tcb *, struct mbuf *, int); |
| 163 |
| 164 | void send_forward_tsn(struct sctp_tcb *, struct sctp_association *); |
| 165 |
| 166 | void sctp_send_sack(struct sctp_tcb *, int); |
| 167 |
| 168 | void sctp_send_hb(struct sctp_tcb *, struct sctp_nets *, int); |
| 169 |
| 170 | void sctp_send_ecn_echo(struct sctp_tcb *, struct sctp_nets *, uint32_t); |
| 171 |
| 172 | void |
| 173 | sctp_send_packet_dropped(struct sctp_tcb *, struct sctp_nets *, struct mbuf *, |
| 174 | int, int, int); |
| 175 |
| 176 | void sctp_send_cwr(struct sctp_tcb *, struct sctp_nets *, uint32_t, uint8_t); |
| 177 |
| 178 | void |
| 179 | sctp_add_stream_reset_result(struct sctp_tmit_chunk *, uint32_t, uint32_t); |
| 180 |
| 181 | void |
| 182 | sctp_send_deferred_reset_response(struct sctp_tcb *, |
| 183 | struct sctp_stream_reset_list *, |
| 184 | int); |
| 185 |
| 186 | void |
| 187 | sctp_add_stream_reset_result_tsn(struct sctp_tmit_chunk *, |
| 188 | uint32_t, uint32_t, uint32_t, uint32_t); |
| 189 | int |
| 190 | sctp_send_stream_reset_out_if_possible(struct sctp_tcb *, int); |
| 191 |
| 192 | int |
| 193 | sctp_send_str_reset_req(struct sctp_tcb *, uint16_t , uint16_t *, |
| 194 | uint8_t, uint8_t, uint8_t, uint16_t, uint16_t, uint8_t); |
| 195 |
| 196 | void |
| 197 | sctp_send_abort(struct mbuf *, int, struct sockaddr *, struct sockaddr *, |
| 198 | struct sctphdr *, uint32_t, struct mbuf *, |
| 199 | #if defined(__FreeBSD__) && !defined(__Userspace__) |
| 200 | uint8_t, uint32_t, uint16_t, |
| 201 | #endif |
| 202 | uint32_t, uint16_t); |
| 203 |
| 204 | void |
| 205 | sctp_send_operr_to(struct sockaddr *, struct sockaddr *, |
| 206 | struct sctphdr *, uint32_t, struct mbuf *, |
| 207 | #if defined(__FreeBSD__) && !defined(__Userspace__) |
| 208 | uint8_t, uint32_t, uint16_t, |
| 209 | #endif |
| 210 | uint32_t, uint16_t); |
| 211 |
| 212 | #endif /* _KERNEL || __Userspace__ */ |
| 213 |
| 214 | #if defined(_KERNEL) || defined(__Userspace__) |
| 215 | int |
| 216 | sctp_sosend(struct socket *so, |
| 217 | struct sockaddr *addr, |
| 218 | struct uio *uio, |
| 219 | struct mbuf *top, |
| 220 | struct mbuf *control, |
| 221 | #if defined(__APPLE__) && !defined(__Userspace__) |
| 222 | int flags |
| 223 | #else |
| 224 | int flags, |
| 225 | #if defined(__FreeBSD__) && !defined(__Userspace__) |
| 226 | struct thread *p |
| 227 | #elif defined(_WIN32) && !defined(__Userspace__) |
| 228 | PKTHREAD p |
| 229 | #else |
| 230 | #if defined(__Userspace__) |
| 231 | /* proc is a dummy in __Userspace__ and will not be passed to sctp_lower_sosend */ |
| 232 | #endif |
| 233 | struct proc *p |
| 234 | #endif |
| 235 | #endif |
| 236 | ); |
| 237 |
| 238 | #endif |
| 239 | #endif |
| 240 |
| 241 |