• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifdef __FreeBSD__
36 #include <sys/cdefs.h>
37 __FBSDID("$FreeBSD: head/sys/netinet/sctp_output.h 351654 2019-09-01 10:09:53Z tuexen $");
38 #endif
39 
40 #ifndef _NETINET_SCTP_OUTPUT_H_
41 #define _NETINET_SCTP_OUTPUT_H_
42 
43 #include <netinet/sctp_header.h>
44 
45 #if defined(_KERNEL) || defined(__Userspace__)
46 
47 
48 struct mbuf *
49 sctp_add_addresses_to_i_ia(struct sctp_inpcb *inp,
50                            struct sctp_tcb *stcb,
51 			   struct sctp_scoping *scope,
52 			   struct mbuf *m_at,
53 			   int cnt_inits_to,
54 			   uint16_t *padding_len, uint16_t *chunk_len);
55 
56 
57 int sctp_is_addr_restricted(struct sctp_tcb *, struct sctp_ifa *);
58 
59 
60 int
61 sctp_is_address_in_scope(struct sctp_ifa *ifa,
62                          struct sctp_scoping *scope,
63 			 int do_update);
64 
65 int
66 sctp_is_addr_in_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa);
67 
68 struct sctp_ifa *
69 sctp_source_address_selection(struct sctp_inpcb *inp,
70 			      struct sctp_tcb *stcb,
71 			      sctp_route_t *ro, struct sctp_nets *net,
72 			      int non_asoc_addr_ok, uint32_t vrf_id);
73 
74 #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Userspace__)
75 int
76 sctp_v6src_match_nexthop(struct sockaddr_in6 *src6, sctp_route_t *ro);
77 int
78 sctp_v4src_match_nexthop(struct sctp_ifa *sifa, sctp_route_t *ro);
79 #endif
80 
81 void sctp_send_initiate(struct sctp_inpcb *, struct sctp_tcb *, int
82 #if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
83     SCTP_UNUSED
84 #endif
85     );
86 
87 void
88 sctp_send_initiate_ack(struct sctp_inpcb *, struct sctp_tcb *,
89                        struct sctp_nets *, struct mbuf *,
90                        int, int,
91                        struct sockaddr *, struct sockaddr *,
92                        struct sctphdr *, struct sctp_init_chunk *,
93 #if defined(__FreeBSD__)
94                        uint8_t, uint32_t,
95 #endif
96                        uint32_t, uint16_t);
97 
98 struct mbuf *
99 sctp_arethere_unrecognized_parameters(struct mbuf *, int, int *,
100 				      struct sctp_chunkhdr *, int *, int *);
101 void sctp_queue_op_err(struct sctp_tcb *, struct mbuf *);
102 
103 int
104 sctp_send_cookie_echo(struct mbuf *, int, int, struct sctp_tcb *,
105     struct sctp_nets *);
106 
107 void sctp_send_cookie_ack(struct sctp_tcb *);
108 
109 void
110 sctp_send_heartbeat_ack(struct sctp_tcb *, struct mbuf *, int, int,
111     struct sctp_nets *);
112 
113 void
114 sctp_remove_from_wheel(struct sctp_tcb *stcb,
115 					   struct sctp_association *asoc,
116 					   struct sctp_stream_out *strq, int holds_lock);
117 
118 
119 void sctp_send_shutdown(struct sctp_tcb *, struct sctp_nets *);
120 
121 void sctp_send_shutdown_ack(struct sctp_tcb *, struct sctp_nets *);
122 
123 void sctp_send_shutdown_complete(struct sctp_tcb *, struct sctp_nets *, int);
124 
125 void sctp_send_shutdown_complete2(struct sockaddr *, struct sockaddr *,
126                                   struct sctphdr *,
127 #if defined(__FreeBSD__)
128                                   uint8_t, uint32_t, uint16_t,
129 #endif
130                                   uint32_t, uint16_t);
131 
132 void sctp_send_asconf(struct sctp_tcb *, struct sctp_nets *, int addr_locked);
133 
134 void sctp_send_asconf_ack(struct sctp_tcb *);
135 
136 int sctp_get_frag_point(struct sctp_tcb *, struct sctp_association *);
137 
138 void sctp_toss_old_cookies(struct sctp_tcb *, struct sctp_association *);
139 
140 void sctp_toss_old_asconf(struct sctp_tcb *);
141 
142 void sctp_fix_ecn_echo(struct sctp_association *);
143 
144 void sctp_move_chunks_from_net(struct sctp_tcb *stcb, struct sctp_nets *net);
145 
146 
147 #define SCTP_DATA_CHUNK_OVERHEAD(stcb) ((stcb)->asoc.idata_supported ? \
148 					sizeof(struct sctp_idata_chunk) : \
149 					sizeof(struct sctp_data_chunk))
150 
151 #if defined(__FreeBSD__) && __FreeBSD_version >= 500000
152 int
153 sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *,
154     struct mbuf *, struct thread *, int);
155 #elif defined(__Windows__)
156 sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *,
157     struct mbuf *, PKTHREAD, int);
158 #else
159 #if defined(__Userspace__)
160 /* sctp_output is called bu sctp_sendm. Not using sctp_sendm for __Userspace__ */
161 #endif
162 int
163 sctp_output(struct sctp_inpcb *,
164 #if defined(__Panda__)
165     pakhandle_type,
166 #else
167     struct mbuf *,
168 #endif
169     struct sockaddr *,
170 #if defined(__Panda__)
171     pakhandle_type,
172 #else
173     struct mbuf *,
174 #endif
175     struct proc *, int);
176 #endif
177 
178 void sctp_chunk_output(struct sctp_inpcb *, struct sctp_tcb *, int, int
179 #if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
180     SCTP_UNUSED
181 #endif
182     );
183 void sctp_send_abort_tcb(struct sctp_tcb *, struct mbuf *, int
184 #if !defined(__APPLE__) && !defined(SCTP_SO_LOCK_TESTING)
185     SCTP_UNUSED
186 #endif
187     );
188 
189 void send_forward_tsn(struct sctp_tcb *, struct sctp_association *);
190 
191 void sctp_send_sack(struct sctp_tcb *, int);
192 
193 void sctp_send_hb(struct sctp_tcb *, struct sctp_nets *, int);
194 
195 void sctp_send_ecn_echo(struct sctp_tcb *, struct sctp_nets *, uint32_t);
196 
197 
198 void
199 sctp_send_packet_dropped(struct sctp_tcb *, struct sctp_nets *, struct mbuf *,
200     int, int, int);
201 
202 
203 
204 void sctp_send_cwr(struct sctp_tcb *, struct sctp_nets *, uint32_t, uint8_t);
205 
206 
207 void
208 sctp_add_stream_reset_result(struct sctp_tmit_chunk *, uint32_t, uint32_t);
209 
210 void
211 sctp_send_deferred_reset_response(struct sctp_tcb *,
212 				  struct sctp_stream_reset_list *,
213 				  int);
214 
215 void
216 sctp_add_stream_reset_result_tsn(struct sctp_tmit_chunk *,
217                                  uint32_t, uint32_t, uint32_t, uint32_t);
218 int
219 sctp_send_stream_reset_out_if_possible(struct sctp_tcb *, int);
220 
221 int
222 sctp_send_str_reset_req(struct sctp_tcb *, uint16_t , uint16_t *,
223                         uint8_t, uint8_t, uint8_t, uint16_t, uint16_t, uint8_t);
224 
225 void
226 sctp_send_abort(struct mbuf *, int, struct sockaddr *, struct sockaddr *,
227                 struct sctphdr *, uint32_t, struct mbuf *,
228 #if defined(__FreeBSD__)
229                 uint8_t, uint32_t, uint16_t,
230 #endif
231                 uint32_t, uint16_t);
232 
233 void sctp_send_operr_to(struct sockaddr *, struct sockaddr *,
234                         struct sctphdr *, uint32_t, struct mbuf *,
235 #if defined(__FreeBSD__)
236                         uint8_t, uint32_t, uint16_t,
237 #endif
238                         uint32_t, uint16_t);
239 
240 #endif /* _KERNEL || __Userspace__ */
241 
242 #if defined(_KERNEL) || defined(__Userspace__)
243 int
244 sctp_sosend(struct socket *so,
245     struct sockaddr *addr,
246     struct uio *uio,
247 #ifdef __Panda__
248     pakhandle_type top,
249     pakhandle_type control,
250 #else
251     struct mbuf *top,
252     struct mbuf *control,
253 #endif
254 #if defined(__APPLE__) || defined(__Panda__)
255     int flags
256 #else
257     int flags,
258 #if defined(__FreeBSD__) && __FreeBSD_version >= 500000
259     struct thread *p
260 #elif defined(__Windows__)
261     PKTHREAD p
262 #else
263 #if defined(__Userspace__)
264     /* proc is a dummy in __Userspace__ and will not be passed to sctp_lower_sosend */
265 #endif
266     struct proc *p
267 #endif
268 #endif
269 );
270 
271 #endif
272 #endif
273 
274