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