xref: /freebsd/sys/netinet/sctp_output.h (revision 20cc2188f3ae034a542c923d224c14b6b188c84a)
1f8829a4aSRandall Stewart /*-
2b1006367SRandall Stewart  * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved.
3807aad63SMichael Tuexen  * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved.
4807aad63SMichael Tuexen  * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved.
5f8829a4aSRandall Stewart  *
6f8829a4aSRandall Stewart  * Redistribution and use in source and binary forms, with or without
7f8829a4aSRandall Stewart  * modification, are permitted provided that the following conditions are met:
8f8829a4aSRandall Stewart  *
9f8829a4aSRandall Stewart  * a) Redistributions of source code must retain the above copyright notice,
10f8829a4aSRandall Stewart  *    this list of conditions and the following disclaimer.
11f8829a4aSRandall Stewart  *
12f8829a4aSRandall Stewart  * b) Redistributions in binary form must reproduce the above copyright
13f8829a4aSRandall Stewart  *    notice, this list of conditions and the following disclaimer in
14f8829a4aSRandall Stewart  *    the documentation and/or other materials provided with the distribution.
15f8829a4aSRandall Stewart  *
16f8829a4aSRandall Stewart  * c) Neither the name of Cisco Systems, Inc. nor the names of its
17f8829a4aSRandall Stewart  *    contributors may be used to endorse or promote products derived
18f8829a4aSRandall Stewart  *    from this software without specific prior written permission.
19f8829a4aSRandall Stewart  *
20f8829a4aSRandall Stewart  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21f8829a4aSRandall Stewart  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22f8829a4aSRandall Stewart  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23f8829a4aSRandall Stewart  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
24f8829a4aSRandall Stewart  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25f8829a4aSRandall Stewart  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26f8829a4aSRandall Stewart  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27f8829a4aSRandall Stewart  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28f8829a4aSRandall Stewart  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29f8829a4aSRandall Stewart  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30f8829a4aSRandall Stewart  * THE POSSIBILITY OF SUCH DAMAGE.
31f8829a4aSRandall Stewart  */
32f8829a4aSRandall Stewart 
33f8829a4aSRandall Stewart #include <sys/cdefs.h>
34f8829a4aSRandall Stewart __FBSDID("$FreeBSD$");
35f8829a4aSRandall Stewart 
36807aad63SMichael Tuexen #ifndef _NETINET_SCTP_OUTPUT_H_
37807aad63SMichael Tuexen #define _NETINET_SCTP_OUTPUT_H_
38f8829a4aSRandall Stewart 
39f8829a4aSRandall Stewart #include <netinet/sctp_header.h>
40f8829a4aSRandall Stewart 
41fc14de76SRandall Stewart #if defined(_KERNEL) || defined(__Userspace__)
4242551e99SRandall Stewart 
4342551e99SRandall Stewart 
4442551e99SRandall Stewart struct mbuf *
4542551e99SRandall Stewart sctp_add_addresses_to_i_ia(struct sctp_inpcb *inp,
4696f4bcffSMichael Tuexen     struct sctp_tcb *stcb,
4742551e99SRandall Stewart     struct sctp_scoping *scope,
4842551e99SRandall Stewart     struct mbuf *m_at,
4942551e99SRandall Stewart     int cnt_inits_to);
5042551e99SRandall Stewart 
5142551e99SRandall Stewart 
5242551e99SRandall Stewart int sctp_is_addr_restricted(struct sctp_tcb *, struct sctp_ifa *);
5342551e99SRandall Stewart 
5442551e99SRandall Stewart 
5542551e99SRandall Stewart int
5642551e99SRandall Stewart sctp_is_address_in_scope(struct sctp_ifa *ifa,
5742551e99SRandall Stewart     int ipv4_addr_legal,
5842551e99SRandall Stewart     int ipv6_addr_legal,
5942551e99SRandall Stewart     int loopback_scope,
6042551e99SRandall Stewart     int ipv4_local_scope,
6142551e99SRandall Stewart     int local_scope,
6242551e99SRandall Stewart     int site_scope,
6342551e99SRandall Stewart     int do_update);
6442551e99SRandall Stewart int
6542551e99SRandall Stewart     sctp_is_addr_in_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa);
6642551e99SRandall Stewart 
6742551e99SRandall Stewart struct sctp_ifa *
6842551e99SRandall Stewart sctp_source_address_selection(struct sctp_inpcb *inp,
6942551e99SRandall Stewart     struct sctp_tcb *stcb,
70bff64a4dSRandall Stewart     sctp_route_t * ro, struct sctp_nets *net,
7142551e99SRandall Stewart     int non_asoc_addr_ok, uint32_t vrf_id);
7242551e99SRandall Stewart 
732afb3e84SRandall Stewart int
742afb3e84SRandall Stewart     sctp_v6src_match_nexthop(struct sockaddr_in6 *src6, sctp_route_t * ro);
752afb3e84SRandall Stewart int
762afb3e84SRandall Stewart     sctp_v4src_match_nexthop(struct sctp_ifa *sifa, sctp_route_t * ro);
7742551e99SRandall Stewart 
78ceaad40aSRandall Stewart void
79ceaad40aSRandall Stewart sctp_send_initiate(struct sctp_inpcb *, struct sctp_tcb *, int
80ceaad40aSRandall Stewart #if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
81ceaad40aSRandall Stewart     SCTP_UNUSED
82ceaad40aSRandall Stewart #endif
83ceaad40aSRandall Stewart );
84f8829a4aSRandall Stewart 
85f8829a4aSRandall Stewart void
86f30ac432SMichael Tuexen sctp_send_initiate_ack(struct sctp_inpcb *, struct sctp_tcb *, struct mbuf *,
87f30ac432SMichael Tuexen     int, int, struct sctphdr *, struct sctp_init_chunk *,
88f30ac432SMichael Tuexen     uint8_t, uint32_t,
89c54a18d2SRandall Stewart     uint32_t, uint16_t, int);
90f8829a4aSRandall Stewart 
91f8829a4aSRandall Stewart struct mbuf *
92f8829a4aSRandall Stewart sctp_arethere_unrecognized_parameters(struct mbuf *, int, int *,
93830d754dSRandall Stewart     struct sctp_chunkhdr *, int *);
94f8829a4aSRandall Stewart void sctp_queue_op_err(struct sctp_tcb *, struct mbuf *);
95f8829a4aSRandall Stewart 
96f8829a4aSRandall Stewart int
97f8829a4aSRandall Stewart sctp_send_cookie_echo(struct mbuf *, int, struct sctp_tcb *,
98f8829a4aSRandall Stewart     struct sctp_nets *);
996e55db54SRandall Stewart 
1006e55db54SRandall Stewart void sctp_send_cookie_ack(struct sctp_tcb *);
101f8829a4aSRandall Stewart 
102f8829a4aSRandall Stewart void
103f8829a4aSRandall Stewart sctp_send_heartbeat_ack(struct sctp_tcb *, struct mbuf *, int, int,
104f8829a4aSRandall Stewart     struct sctp_nets *);
105f8829a4aSRandall Stewart 
1068aae9493SRandall Stewart void
1078aae9493SRandall Stewart sctp_remove_from_wheel(struct sctp_tcb *stcb,
1088aae9493SRandall Stewart     struct sctp_association *asoc,
1098aae9493SRandall Stewart     struct sctp_stream_out *strq, int holds_lock);
1108aae9493SRandall Stewart 
111f8829a4aSRandall Stewart 
1126e55db54SRandall Stewart void sctp_send_shutdown(struct sctp_tcb *, struct sctp_nets *);
113f8829a4aSRandall Stewart 
1146e55db54SRandall Stewart void sctp_send_shutdown_ack(struct sctp_tcb *, struct sctp_nets *);
115f8829a4aSRandall Stewart 
1167b470fc3SMichael Tuexen void sctp_send_shutdown_complete(struct sctp_tcb *, struct sctp_nets *, int);
117f8829a4aSRandall Stewart 
1186e55db54SRandall Stewart void
1197215cc1bSMichael Tuexen sctp_send_shutdown_complete2(struct mbuf *, struct sctphdr *,
120f30ac432SMichael Tuexen     uint8_t, uint32_t,
121c54a18d2SRandall Stewart     uint32_t, uint16_t);
122f8829a4aSRandall Stewart 
1233232788eSRandall Stewart void sctp_send_asconf(struct sctp_tcb *, struct sctp_nets *, int addr_locked);
124f8829a4aSRandall Stewart 
1252afb3e84SRandall Stewart void sctp_send_asconf_ack(struct sctp_tcb *);
126f8829a4aSRandall Stewart 
127f8829a4aSRandall Stewart int sctp_get_frag_point(struct sctp_tcb *, struct sctp_association *);
128f8829a4aSRandall Stewart 
129f8829a4aSRandall Stewart void sctp_toss_old_cookies(struct sctp_tcb *, struct sctp_association *);
130f8829a4aSRandall Stewart 
131f8829a4aSRandall Stewart void sctp_toss_old_asconf(struct sctp_tcb *);
132f8829a4aSRandall Stewart 
133f8829a4aSRandall Stewart void sctp_fix_ecn_echo(struct sctp_association *);
134f8829a4aSRandall Stewart 
1359eea4a2dSMichael Tuexen void sctp_move_chunks_from_net(struct sctp_tcb *stcb, struct sctp_nets *net);
1369eea4a2dSMichael Tuexen 
137f8829a4aSRandall Stewart int
138f8829a4aSRandall Stewart sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *,
139f8829a4aSRandall Stewart     struct mbuf *, struct thread *, int);
140f8829a4aSRandall Stewart 
141f8829a4aSRandall Stewart void
142ceaad40aSRandall Stewart sctp_chunk_output(struct sctp_inpcb *, struct sctp_tcb *, int, int
143ceaad40aSRandall Stewart #if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
144ceaad40aSRandall Stewart     SCTP_UNUSED
145ceaad40aSRandall Stewart #endif
146ceaad40aSRandall Stewart );
147ceaad40aSRandall Stewart void
148ceaad40aSRandall Stewart sctp_send_abort_tcb(struct sctp_tcb *, struct mbuf *, int
149ceaad40aSRandall Stewart #if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
150ceaad40aSRandall Stewart     SCTP_UNUSED
151ceaad40aSRandall Stewart #endif
152ceaad40aSRandall Stewart );
153f8829a4aSRandall Stewart 
154f8829a4aSRandall Stewart void send_forward_tsn(struct sctp_tcb *, struct sctp_association *);
155f8829a4aSRandall Stewart 
156689e6a5fSMichael Tuexen void sctp_send_sack(struct sctp_tcb *, int);
157f8829a4aSRandall Stewart 
158ca85e948SMichael Tuexen void sctp_send_hb(struct sctp_tcb *, struct sctp_nets *, int);
159f8829a4aSRandall Stewart 
160f8829a4aSRandall Stewart void sctp_send_ecn_echo(struct sctp_tcb *, struct sctp_nets *, uint32_t);
161f8829a4aSRandall Stewart 
162f8829a4aSRandall Stewart 
163f8829a4aSRandall Stewart void
164f8829a4aSRandall Stewart sctp_send_packet_dropped(struct sctp_tcb *, struct sctp_nets *, struct mbuf *,
165*20cc2188SMichael Tuexen     int, int, int);
166f8829a4aSRandall Stewart 
167f8829a4aSRandall Stewart 
168f8829a4aSRandall Stewart 
169a21779f0SRandall Stewart void sctp_send_cwr(struct sctp_tcb *, struct sctp_nets *, uint32_t, uint8_t);
170f8829a4aSRandall Stewart 
171f8829a4aSRandall Stewart 
172f8829a4aSRandall Stewart void
173f8829a4aSRandall Stewart sctp_add_stream_reset_out(struct sctp_tmit_chunk *chk,
174f8829a4aSRandall Stewart     int number_entries, uint16_t * list,
175f8829a4aSRandall Stewart     uint32_t seq, uint32_t resp_seq, uint32_t last_sent);
176f8829a4aSRandall Stewart 
177f8829a4aSRandall Stewart void
178f8829a4aSRandall Stewart sctp_add_stream_reset_in(struct sctp_tmit_chunk *chk,
179f8829a4aSRandall Stewart     int number_entries, uint16_t * list,
180f8829a4aSRandall Stewart     uint32_t seq);
181f8829a4aSRandall Stewart 
182f8829a4aSRandall Stewart void
183f8829a4aSRandall Stewart sctp_add_stream_reset_tsn(struct sctp_tmit_chunk *chk,
184f8829a4aSRandall Stewart     uint32_t seq);
185f8829a4aSRandall Stewart 
186f8829a4aSRandall Stewart void
187f8829a4aSRandall Stewart sctp_add_stream_reset_result(struct sctp_tmit_chunk *chk,
188f8829a4aSRandall Stewart     uint32_t resp_seq, uint32_t result);
189f8829a4aSRandall Stewart 
190f8829a4aSRandall Stewart void
191f8829a4aSRandall Stewart sctp_add_stream_reset_result_tsn(struct sctp_tmit_chunk *chk,
192f8829a4aSRandall Stewart     uint32_t resp_seq, uint32_t result,
193f8829a4aSRandall Stewart     uint32_t send_una, uint32_t recv_next);
194f8829a4aSRandall Stewart 
195f8829a4aSRandall Stewart int
196f8829a4aSRandall Stewart sctp_send_str_reset_req(struct sctp_tcb *stcb,
197c4e848b7SRandall Stewart     int number_entries, uint16_t * list,
198ea44232bSRandall Stewart     uint8_t send_out_req,
199f8829a4aSRandall Stewart     uint8_t send_in_req,
200ea44232bSRandall Stewart     uint8_t send_tsn_req,
201c4e848b7SRandall Stewart     uint8_t add_stream,
202c4e848b7SRandall Stewart     uint16_t adding_o,
203c4e848b7SRandall Stewart     uint16_t adding_i, uint8_t from_peer);
204f8829a4aSRandall Stewart 
205f8829a4aSRandall Stewart void
206f8829a4aSRandall Stewart sctp_send_abort(struct mbuf *, int, struct sctphdr *, uint32_t,
207f30ac432SMichael Tuexen     struct mbuf *,
208f30ac432SMichael Tuexen     uint8_t, uint32_t,
209f30ac432SMichael Tuexen     uint32_t, uint16_t);
210f8829a4aSRandall Stewart 
211c9e08958SMichael Tuexen void
212c9e08958SMichael Tuexen sctp_send_operr_to(struct mbuf *, struct sctphdr *, uint32_t,
213f30ac432SMichael Tuexen     struct mbuf *,
214f30ac432SMichael Tuexen     uint8_t, uint32_t,
215f30ac432SMichael Tuexen     uint32_t, uint16_t);
216f8829a4aSRandall Stewart 
217fc14de76SRandall Stewart #endif				/* _KERNEL || __Userspace__ */
218fc14de76SRandall Stewart 
219fc14de76SRandall Stewart #if defined(_KERNEL) || defined(__Userspace__)
220f8829a4aSRandall Stewart int
221f8829a4aSRandall Stewart sctp_sosend(struct socket *so,
222f8829a4aSRandall Stewart     struct sockaddr *addr,
223f8829a4aSRandall Stewart     struct uio *uio,
224f8829a4aSRandall Stewart     struct mbuf *top,
225f8829a4aSRandall Stewart     struct mbuf *control,
226f8829a4aSRandall Stewart     int flags,
227f8829a4aSRandall Stewart     struct thread *p
228f8829a4aSRandall Stewart );
229f8829a4aSRandall Stewart 
230f8829a4aSRandall Stewart #endif
231f8829a4aSRandall Stewart #endif
232