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_INDATA_H_ 36807aad63SMichael Tuexen #define _NETINET_SCTP_INDATA_H_ 37f8829a4aSRandall Stewart 38fc14de76SRandall Stewart #if defined(_KERNEL) || defined(__Userspace__) 39f8829a4aSRandall Stewart 40f8829a4aSRandall Stewart struct sctp_queued_to_read * 41f8829a4aSRandall Stewart sctp_build_readq_entry(struct sctp_tcb *stcb, 42f8829a4aSRandall Stewart struct sctp_nets *net, 43f8829a4aSRandall Stewart uint32_t tsn, uint32_t ppid, 4449656eefSMichael Tuexen uint32_t context, uint16_t sid, 4549656eefSMichael Tuexen uint32_t mid, uint8_t flags, 46f8829a4aSRandall Stewart struct mbuf *dm); 47f8829a4aSRandall Stewart 4849656eefSMichael Tuexen #define sctp_build_readq_entry_mac(_ctl, in_it, context, net, tsn, ppid, sid, flags, dm, tfsn, mid) do { \ 49f8829a4aSRandall Stewart if (_ctl) { \ 5044b7479bSRandall Stewart atomic_add_int(&((net)->ref_count), 1); \ 5144249214SRandall Stewart memset(_ctl, 0, sizeof(struct sctp_queued_to_read)); \ 5249656eefSMichael Tuexen (_ctl)->sinfo_stream = sid; \ 5344249214SRandall Stewart TAILQ_INIT(&_ctl->reasm); \ 5444249214SRandall Stewart (_ctl)->top_fsn = tfsn; \ 5549656eefSMichael Tuexen (_ctl)->mid = mid; \ 56f8829a4aSRandall Stewart (_ctl)->sinfo_flags = (flags << 8); \ 57f8829a4aSRandall Stewart (_ctl)->sinfo_ppid = ppid; \ 5856f778aaSMichael Tuexen (_ctl)->sinfo_context = context; \ 5944249214SRandall Stewart (_ctl)->fsn_included = 0xffffffff; \ 60f8829a4aSRandall Stewart (_ctl)->sinfo_tsn = tsn; \ 61f8829a4aSRandall Stewart (_ctl)->sinfo_cumtsn = tsn; \ 6244b7479bSRandall Stewart (_ctl)->sinfo_assoc_id = sctp_get_associd((in_it)); \ 6344b7479bSRandall Stewart (_ctl)->whoFrom = net; \ 64f8829a4aSRandall Stewart (_ctl)->data = dm; \ 6544b7479bSRandall Stewart (_ctl)->stcb = (in_it); \ 6644b7479bSRandall Stewart (_ctl)->port_from = (in_it)->rport; \ 67*daf14341SMichael Tuexen if ((in_it)->asoc.state & SCTP_STATE_ABOUT_TO_BE_FREED) { \ 68*daf14341SMichael Tuexen (_ctl)->do_not_ref_stcb = 1; \ 69*daf14341SMichael Tuexen }\ 70f8829a4aSRandall Stewart } \ 71f8829a4aSRandall Stewart } while (0) 72f8829a4aSRandall Stewart 73f8829a4aSRandall Stewart struct mbuf * 74f8829a4aSRandall Stewart sctp_build_ctl_nchunk(struct sctp_inpcb *inp, 75f8829a4aSRandall Stewart struct sctp_sndrcvinfo *sinfo); 76f8829a4aSRandall Stewart 77f8829a4aSRandall Stewart void sctp_set_rwnd(struct sctp_tcb *, struct sctp_association *); 78f8829a4aSRandall Stewart 79f8829a4aSRandall Stewart uint32_t 80f8829a4aSRandall Stewart sctp_calc_rwnd(struct sctp_tcb *stcb, struct sctp_association *asoc); 81f8829a4aSRandall Stewart 82f8829a4aSRandall Stewart void 83f8829a4aSRandall Stewart sctp_express_handle_sack(struct sctp_tcb *stcb, uint32_t cumack, 84899288aeSRandall Stewart uint32_t rwnd, int *abort_now, int ecne_seen); 85f8829a4aSRandall Stewart 86f8829a4aSRandall Stewart void 87cd554309SMichael Tuexen sctp_handle_sack(struct mbuf *m, int offset_seg, int offset_dup, 887215cc1bSMichael Tuexen struct sctp_tcb *stcb, 89cd554309SMichael Tuexen uint16_t num_seg, uint16_t num_nr_seg, uint16_t num_dup, 90cd554309SMichael Tuexen int *abort_now, uint8_t flags, 91899288aeSRandall Stewart uint32_t cum_ack, uint32_t rwnd, int ecne_seen); 92830d754dSRandall Stewart 93f8829a4aSRandall Stewart /* draft-ietf-tsvwg-usctp */ 94f8829a4aSRandall Stewart void 95f8829a4aSRandall Stewart sctp_handle_forward_tsn(struct sctp_tcb *, 96671d309cSRandall Stewart struct sctp_forward_tsn_chunk *, int *, struct mbuf *, int); 97f8829a4aSRandall Stewart 980053ed28SMichael Tuexen struct sctp_tmit_chunk *sctp_try_advance_peer_ack_point(struct sctp_tcb *, struct sctp_association *); 99f8829a4aSRandall Stewart 100f8829a4aSRandall Stewart void sctp_service_queues(struct sctp_tcb *, struct sctp_association *); 101f8829a4aSRandall Stewart 102f8829a4aSRandall Stewart void 1037215cc1bSMichael Tuexen sctp_update_acked(struct sctp_tcb *, struct sctp_shutdown_chunk *, int *); 104f8829a4aSRandall Stewart 105f8829a4aSRandall Stewart int 106b1754ad1SMichael Tuexen sctp_process_data(struct mbuf **, int, int *, int, 107d06c82f1SRandall Stewart struct sctp_inpcb *, struct sctp_tcb *, 108e7e71dd7SMichael Tuexen struct sctp_nets *, uint32_t *); 109f8829a4aSRandall Stewart 110b5c16493SMichael Tuexen void sctp_slide_mapping_arrays(struct sctp_tcb *stcb); 111b5c16493SMichael Tuexen 1127215cc1bSMichael Tuexen void sctp_sack_check(struct sctp_tcb *, int); 113f8829a4aSRandall Stewart 114f8829a4aSRandall Stewart #endif 115f8829a4aSRandall Stewart #endif 116