xref: /freebsd/sys/netinet/sctp_output.h (revision e4456411a8c2d4a9bfbccd60f2cf914fd402f817)
1 /*-
2  * SPDX-License-Identifier: BSD-3-Clause
3  *
4  * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
5  * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
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 #include <sys/cdefs.h>
36 __FBSDID("$FreeBSD$");
37 
38 #ifndef _NETINET_SCTP_OUTPUT_H_
39 #define _NETINET_SCTP_OUTPUT_H_
40 
41 #include <netinet/sctp_header.h>
42 
43 #if defined(_KERNEL) || defined(__Userspace__)
44 
45 
46 struct mbuf *
47 sctp_add_addresses_to_i_ia(struct sctp_inpcb *inp,
48     struct sctp_tcb *stcb,
49     struct sctp_scoping *scope,
50     struct mbuf *m_at,
51     int cnt_inits_to,
52     uint16_t *padding_len, uint16_t *chunk_len);
53 
54 
55 int sctp_is_addr_restricted(struct sctp_tcb *, struct sctp_ifa *);
56 
57 
58 int
59 sctp_is_address_in_scope(struct sctp_ifa *ifa,
60     struct sctp_scoping *scope,
61     int do_update);
62 
63 int
64     sctp_is_addr_in_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa);
65 
66 struct sctp_ifa *
67 sctp_source_address_selection(struct sctp_inpcb *inp,
68     struct sctp_tcb *stcb,
69     sctp_route_t *ro, struct sctp_nets *net,
70     int non_asoc_addr_ok, uint32_t vrf_id);
71 
72 int
73     sctp_v6src_match_nexthop(struct sockaddr_in6 *src6, sctp_route_t *ro);
74 int
75     sctp_v4src_match_nexthop(struct sctp_ifa *sifa, sctp_route_t *ro);
76 
77 void
78 sctp_send_initiate(struct sctp_inpcb *, struct sctp_tcb *, int
79 #if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
80     SCTP_UNUSED
81 #endif
82 );
83 
84 void
85 sctp_send_initiate_ack(struct sctp_inpcb *, struct sctp_tcb *,
86     struct sctp_nets *, struct mbuf *,
87     int, int,
88     struct sockaddr *, struct sockaddr *,
89     struct sctphdr *, struct sctp_init_chunk *,
90     uint8_t, uint32_t,
91     uint32_t, uint16_t);
92 
93 struct mbuf *
94 sctp_arethere_unrecognized_parameters(struct mbuf *, int, int *,
95     struct sctp_chunkhdr *, int *);
96 void sctp_queue_op_err(struct sctp_tcb *, struct mbuf *);
97 
98 int
99 sctp_send_cookie_echo(struct mbuf *, int, struct sctp_tcb *,
100     struct sctp_nets *);
101 
102 void sctp_send_cookie_ack(struct sctp_tcb *);
103 
104 void
105 sctp_send_heartbeat_ack(struct sctp_tcb *, struct mbuf *, int, int,
106     struct sctp_nets *);
107 
108 void
109 sctp_remove_from_wheel(struct sctp_tcb *stcb,
110     struct sctp_association *asoc,
111     struct sctp_stream_out *strq, int holds_lock);
112 
113 
114 void sctp_send_shutdown(struct sctp_tcb *, struct sctp_nets *);
115 
116 void sctp_send_shutdown_ack(struct sctp_tcb *, struct sctp_nets *);
117 
118 void sctp_send_shutdown_complete(struct sctp_tcb *, struct sctp_nets *, int);
119 
120 void
121 sctp_send_shutdown_complete2(struct sockaddr *, struct sockaddr *,
122     struct sctphdr *,
123     uint8_t, uint32_t, uint16_t,
124     uint32_t, uint16_t);
125 
126 void sctp_send_asconf(struct sctp_tcb *, struct sctp_nets *, int addr_locked);
127 
128 void sctp_send_asconf_ack(struct sctp_tcb *);
129 
130 int sctp_get_frag_point(struct sctp_tcb *, struct sctp_association *);
131 
132 void sctp_toss_old_cookies(struct sctp_tcb *, struct sctp_association *);
133 
134 void sctp_toss_old_asconf(struct sctp_tcb *);
135 
136 void sctp_fix_ecn_echo(struct sctp_association *);
137 
138 void sctp_move_chunks_from_net(struct sctp_tcb *stcb, struct sctp_nets *net);
139 
140 
141 #define SCTP_DATA_CHUNK_OVERHEAD(stcb) ((stcb)->asoc.idata_supported ? \
142 					sizeof(struct sctp_idata_chunk) : \
143 					sizeof(struct sctp_data_chunk))
144 
145 int
146 sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *,
147     struct mbuf *, struct thread *, int);
148 
149 void
150 sctp_chunk_output(struct sctp_inpcb *, struct sctp_tcb *, int, int
151 #if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
152     SCTP_UNUSED
153 #endif
154 );
155 void
156 sctp_send_abort_tcb(struct sctp_tcb *, struct mbuf *, int
157 #if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
158     SCTP_UNUSED
159 #endif
160 );
161 
162 void send_forward_tsn(struct sctp_tcb *, struct sctp_association *);
163 
164 void sctp_send_sack(struct sctp_tcb *, int);
165 
166 void sctp_send_hb(struct sctp_tcb *, struct sctp_nets *, int);
167 
168 void sctp_send_ecn_echo(struct sctp_tcb *, struct sctp_nets *, uint32_t);
169 
170 
171 void
172 sctp_send_packet_dropped(struct sctp_tcb *, struct sctp_nets *, struct mbuf *,
173     int, int, int);
174 
175 
176 
177 void sctp_send_cwr(struct sctp_tcb *, struct sctp_nets *, uint32_t, uint8_t);
178 
179 
180 void
181      sctp_add_stream_reset_result(struct sctp_tmit_chunk *, uint32_t, uint32_t);
182 
183 void
184 sctp_send_deferred_reset_response(struct sctp_tcb *,
185     struct sctp_stream_reset_list *,
186     int);
187 
188 void
189 sctp_add_stream_reset_result_tsn(struct sctp_tmit_chunk *,
190     uint32_t, uint32_t, uint32_t, uint32_t);
191 int
192     sctp_send_stream_reset_out_if_possible(struct sctp_tcb *, int);
193 
194 int
195 sctp_send_str_reset_req(struct sctp_tcb *, uint16_t, uint16_t *,
196     uint8_t, uint8_t, uint8_t, uint16_t, uint16_t, uint8_t);
197 
198 void
199 sctp_send_abort(struct mbuf *, int, struct sockaddr *, struct sockaddr *,
200     struct sctphdr *, uint32_t, struct mbuf *,
201     uint8_t, uint32_t, uint16_t,
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     uint8_t, uint32_t, uint16_t,
208     uint32_t, uint16_t);
209 
210 #endif				/* _KERNEL || __Userspace__ */
211 
212 #if defined(_KERNEL) || defined(__Userspace__)
213 int
214 sctp_sosend(struct socket *so,
215     struct sockaddr *addr,
216     struct uio *uio,
217     struct mbuf *top,
218     struct mbuf *control,
219     int flags,
220     struct thread *p
221 );
222 
223 #endif
224 #endif
225