1f8829a4aSRandall Stewart /*- 251369649SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause 351369649SPedro F. Giffuni * 4b1006367SRandall Stewart * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. 5807aad63SMichael Tuexen * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. 6807aad63SMichael Tuexen * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. 7f8829a4aSRandall Stewart * 8f8829a4aSRandall Stewart * Redistribution and use in source and binary forms, with or without 9f8829a4aSRandall Stewart * modification, are permitted provided that the following conditions are met: 10f8829a4aSRandall Stewart * 11f8829a4aSRandall Stewart * a) Redistributions of source code must retain the above copyright notice, 12f8829a4aSRandall Stewart * this list of conditions and the following disclaimer. 13f8829a4aSRandall Stewart * 14f8829a4aSRandall Stewart * b) Redistributions in binary form must reproduce the above copyright 15f8829a4aSRandall Stewart * notice, this list of conditions and the following disclaimer in 16f8829a4aSRandall Stewart * the documentation and/or other materials provided with the distribution. 17f8829a4aSRandall Stewart * 18f8829a4aSRandall Stewart * c) Neither the name of Cisco Systems, Inc. nor the names of its 19f8829a4aSRandall Stewart * contributors may be used to endorse or promote products derived 20f8829a4aSRandall Stewart * from this software without specific prior written permission. 21f8829a4aSRandall Stewart * 22f8829a4aSRandall Stewart * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23f8829a4aSRandall Stewart * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24f8829a4aSRandall Stewart * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25f8829a4aSRandall Stewart * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 26f8829a4aSRandall Stewart * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27f8829a4aSRandall Stewart * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28f8829a4aSRandall Stewart * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29f8829a4aSRandall Stewart * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30f8829a4aSRandall Stewart * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31f8829a4aSRandall Stewart * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32f8829a4aSRandall Stewart * THE POSSIBILITY OF SUCH DAMAGE. 33f8829a4aSRandall Stewart */ 34f8829a4aSRandall Stewart 35807aad63SMichael Tuexen #ifndef _NETINET_SCTP_OUTPUT_H_ 36807aad63SMichael Tuexen #define _NETINET_SCTP_OUTPUT_H_ 37f8829a4aSRandall Stewart 38f8829a4aSRandall Stewart #include <netinet/sctp_header.h> 39f8829a4aSRandall Stewart 40fc14de76SRandall Stewart #if defined(_KERNEL) || defined(__Userspace__) 4142551e99SRandall Stewart 4242551e99SRandall Stewart struct mbuf * 4342551e99SRandall Stewart sctp_add_addresses_to_i_ia(struct sctp_inpcb *inp, 4496f4bcffSMichael Tuexen struct sctp_tcb *stcb, 4542551e99SRandall Stewart struct sctp_scoping *scope, 4642551e99SRandall Stewart struct mbuf *m_at, 473fb78276SMichael Tuexen int cnt_inits_to, 483fb78276SMichael Tuexen uint16_t *padding_len, uint16_t *chunk_len); 4942551e99SRandall Stewart 5042551e99SRandall Stewart int sctp_is_addr_restricted(struct sctp_tcb *, struct sctp_ifa *); 5142551e99SRandall Stewart 5242551e99SRandall Stewart int 5342551e99SRandall Stewart sctp_is_address_in_scope(struct sctp_ifa *ifa, 54a1cb341bSMichael Tuexen struct sctp_scoping *scope, 5542551e99SRandall Stewart int do_update); 56a1cb341bSMichael Tuexen 5742551e99SRandall Stewart int 5842551e99SRandall Stewart sctp_is_addr_in_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa); 5942551e99SRandall Stewart 6042551e99SRandall Stewart struct sctp_ifa * 6142551e99SRandall Stewart sctp_source_address_selection(struct sctp_inpcb *inp, 6242551e99SRandall Stewart struct sctp_tcb *stcb, 63bff64a4dSRandall Stewart sctp_route_t *ro, struct sctp_nets *net, 6442551e99SRandall Stewart int non_asoc_addr_ok, uint32_t vrf_id); 6542551e99SRandall Stewart 66b6db274dSMichael Tuexen int sctp_v6src_match_nexthop(struct sockaddr_in6 *src6, sctp_route_t *ro); 67b6db274dSMichael Tuexen 68b6db274dSMichael Tuexen int sctp_v4src_match_nexthop(struct sctp_ifa *sifa, sctp_route_t *ro); 6942551e99SRandall Stewart 7028397ac1SMichael Tuexen void sctp_send_initiate(struct sctp_inpcb *, struct sctp_tcb *, int); 71f8829a4aSRandall Stewart 72f8829a4aSRandall Stewart void 73ca83f93cSMichael Tuexen sctp_send_initiate_ack(struct sctp_inpcb *, struct sctp_tcb *, 74ca83f93cSMichael Tuexen struct sctp_nets *, struct mbuf *, 75b1754ad1SMichael Tuexen int, int, 76b1754ad1SMichael Tuexen struct sockaddr *, struct sockaddr *, 77b1754ad1SMichael Tuexen struct sctphdr *, struct sctp_init_chunk *, 78f30ac432SMichael Tuexen uint8_t, uint32_t, 79cdd2d7d4SMichael Tuexen uint32_t, uint16_t); 80f8829a4aSRandall Stewart 81f8829a4aSRandall Stewart struct mbuf * 82f8829a4aSRandall Stewart sctp_arethere_unrecognized_parameters(struct mbuf *, int, int *, 83*644cffe6SMichael Tuexen struct sctp_chunkhdr *, int *, int *, 84*644cffe6SMichael Tuexen uint32_t *); 85*644cffe6SMichael Tuexen 86f8829a4aSRandall Stewart void sctp_queue_op_err(struct sctp_tcb *, struct mbuf *); 87f8829a4aSRandall Stewart 88f8829a4aSRandall Stewart int 896182677fSMichael Tuexen sctp_send_cookie_echo(struct mbuf *, int, int, struct sctp_tcb *, 90f8829a4aSRandall Stewart struct sctp_nets *); 916e55db54SRandall Stewart 926e55db54SRandall Stewart void sctp_send_cookie_ack(struct sctp_tcb *); 93f8829a4aSRandall Stewart 94f8829a4aSRandall Stewart void 95f8829a4aSRandall Stewart sctp_send_heartbeat_ack(struct sctp_tcb *, struct mbuf *, int, int, 96f8829a4aSRandall Stewart struct sctp_nets *); 97f8829a4aSRandall Stewart 988aae9493SRandall Stewart void 998aae9493SRandall Stewart sctp_remove_from_wheel(struct sctp_tcb *stcb, 1008aae9493SRandall Stewart struct sctp_association *asoc, 1018aae9493SRandall Stewart struct sctp_stream_out *strq, int holds_lock); 1028aae9493SRandall Stewart 1036e55db54SRandall Stewart void sctp_send_shutdown(struct sctp_tcb *, struct sctp_nets *); 104f8829a4aSRandall Stewart 1056e55db54SRandall Stewart void sctp_send_shutdown_ack(struct sctp_tcb *, struct sctp_nets *); 106f8829a4aSRandall Stewart 1077b470fc3SMichael Tuexen void sctp_send_shutdown_complete(struct sctp_tcb *, struct sctp_nets *, int); 108f8829a4aSRandall Stewart 1096e55db54SRandall Stewart void 110b1754ad1SMichael Tuexen sctp_send_shutdown_complete2(struct sockaddr *, struct sockaddr *, 111b1754ad1SMichael Tuexen struct sctphdr *, 112d089f9b9SMichael Tuexen uint8_t, uint32_t, uint16_t, 113c54a18d2SRandall Stewart uint32_t, uint16_t); 114f8829a4aSRandall Stewart 1153232788eSRandall Stewart void sctp_send_asconf(struct sctp_tcb *, struct sctp_nets *, int addr_locked); 116f8829a4aSRandall Stewart 1172afb3e84SRandall Stewart void sctp_send_asconf_ack(struct sctp_tcb *); 118f8829a4aSRandall Stewart 119989453daSMichael Tuexen uint32_t sctp_get_frag_point(struct sctp_tcb *); 120f8829a4aSRandall Stewart 121f8829a4aSRandall Stewart void sctp_toss_old_cookies(struct sctp_tcb *, struct sctp_association *); 122f8829a4aSRandall Stewart 123f8829a4aSRandall Stewart void sctp_toss_old_asconf(struct sctp_tcb *); 124f8829a4aSRandall Stewart 125f8829a4aSRandall Stewart void sctp_fix_ecn_echo(struct sctp_association *); 126f8829a4aSRandall Stewart 1279eea4a2dSMichael Tuexen void sctp_move_chunks_from_net(struct sctp_tcb *stcb, struct sctp_nets *net); 1289eea4a2dSMichael Tuexen 129d32ed2c7SMichael Tuexen #define SCTP_DATA_CHUNK_OVERHEAD(stcb) ((stcb)->asoc.idata_supported ? \ 130d32ed2c7SMichael Tuexen sizeof(struct sctp_idata_chunk) : \ 131d32ed2c7SMichael Tuexen sizeof(struct sctp_data_chunk)) 132d32ed2c7SMichael Tuexen 133f8829a4aSRandall Stewart int 134f8829a4aSRandall Stewart sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *, 135f8829a4aSRandall Stewart struct mbuf *, struct thread *, int); 136f8829a4aSRandall Stewart 13728397ac1SMichael Tuexen void sctp_chunk_output(struct sctp_inpcb *, struct sctp_tcb *, int, int); 13828397ac1SMichael Tuexen 13928397ac1SMichael Tuexen void sctp_send_abort_tcb(struct sctp_tcb *, struct mbuf *, int); 140f8829a4aSRandall Stewart 141f8829a4aSRandall Stewart void send_forward_tsn(struct sctp_tcb *, struct sctp_association *); 142f8829a4aSRandall Stewart 143689e6a5fSMichael Tuexen void sctp_send_sack(struct sctp_tcb *, int); 144f8829a4aSRandall Stewart 145ca85e948SMichael Tuexen void sctp_send_hb(struct sctp_tcb *, struct sctp_nets *, int); 146f8829a4aSRandall Stewart 147f8829a4aSRandall Stewart void sctp_send_ecn_echo(struct sctp_tcb *, struct sctp_nets *, uint32_t); 148f8829a4aSRandall Stewart 149f8829a4aSRandall Stewart void 150f8829a4aSRandall Stewart sctp_send_packet_dropped(struct sctp_tcb *, struct sctp_nets *, struct mbuf *, 15120cc2188SMichael Tuexen int, int, int); 152f8829a4aSRandall Stewart 153a21779f0SRandall Stewart void sctp_send_cwr(struct sctp_tcb *, struct sctp_nets *, uint32_t, uint8_t); 154f8829a4aSRandall Stewart 155f8829a4aSRandall Stewart void 1567cca1775SRandall Stewart sctp_add_stream_reset_result(struct sctp_tmit_chunk *, uint32_t, uint32_t); 157f8829a4aSRandall Stewart 158f8829a4aSRandall Stewart void 1597cca1775SRandall Stewart sctp_send_deferred_reset_response(struct sctp_tcb *, 1607cca1775SRandall Stewart struct sctp_stream_reset_list *, 1617cca1775SRandall Stewart int); 162f8829a4aSRandall Stewart 163f8829a4aSRandall Stewart void 16420897500SMichael Tuexen sctp_add_stream_reset_result_tsn(struct sctp_tmit_chunk *, 16520897500SMichael Tuexen uint32_t, uint32_t, uint32_t, uint32_t); 1667cca1775SRandall Stewart int 167c6168599SRandall Stewart sctp_send_stream_reset_out_if_possible(struct sctp_tcb *, int); 168f8829a4aSRandall Stewart 169f8829a4aSRandall Stewart int 1707cca1775SRandall Stewart sctp_send_str_reset_req(struct sctp_tcb *, uint16_t, uint16_t *, 1719ba61060SMichael Tuexen uint8_t, uint8_t, uint8_t, uint16_t, uint16_t, uint8_t); 172f8829a4aSRandall Stewart 173f8829a4aSRandall Stewart void 174b1754ad1SMichael Tuexen sctp_send_abort(struct mbuf *, int, struct sockaddr *, struct sockaddr *, 175b1754ad1SMichael Tuexen struct sctphdr *, uint32_t, struct mbuf *, 176d089f9b9SMichael Tuexen uint8_t, uint32_t, uint16_t, 177f30ac432SMichael Tuexen uint32_t, uint16_t); 178f8829a4aSRandall Stewart 179c9e08958SMichael Tuexen void 180b1754ad1SMichael Tuexen sctp_send_operr_to(struct sockaddr *, struct sockaddr *, 181b1754ad1SMichael Tuexen struct sctphdr *, uint32_t, struct mbuf *, 182d089f9b9SMichael Tuexen uint8_t, uint32_t, uint16_t, 183f30ac432SMichael Tuexen uint32_t, uint16_t); 184f8829a4aSRandall Stewart 185fc14de76SRandall Stewart #endif /* _KERNEL || __Userspace__ */ 186fc14de76SRandall Stewart 187fc14de76SRandall Stewart #if defined(_KERNEL) || defined(__Userspace__) 188f8829a4aSRandall Stewart int 189f8829a4aSRandall Stewart sctp_sosend(struct socket *so, 190f8829a4aSRandall Stewart struct sockaddr *addr, 191f8829a4aSRandall Stewart struct uio *uio, 192f8829a4aSRandall Stewart struct mbuf *top, 193f8829a4aSRandall Stewart struct mbuf *control, 194f8829a4aSRandall Stewart int flags, 195f8829a4aSRandall Stewart struct thread *p 196f8829a4aSRandall Stewart ); 197f8829a4aSRandall Stewart 198f8829a4aSRandall Stewart #endif 199f8829a4aSRandall Stewart #endif 200