sctp_output.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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. #if defined(__FreeBSD__) && !defined(__Userspace__)
  35. #include <sys/cdefs.h>
  36. __FBSDID("$FreeBSD$");
  37. #endif
  38. #ifndef _NETINET_SCTP_OUTPUT_H_
  39. #define _NETINET_SCTP_OUTPUT_H_
  40. #include <netinet/sctp_header.h>
  41. #if defined(_KERNEL) || defined(__Userspace__)
  42. struct mbuf *
  43. sctp_add_addresses_to_i_ia(struct sctp_inpcb *inp,
  44. struct sctp_tcb *stcb,
  45. struct sctp_scoping *scope,
  46. struct mbuf *m_at,
  47. int cnt_inits_to,
  48. uint16_t *padding_len, uint16_t *chunk_len);
  49. int sctp_is_addr_restricted(struct sctp_tcb *, struct sctp_ifa *);
  50. int
  51. sctp_is_address_in_scope(struct sctp_ifa *ifa,
  52. struct sctp_scoping *scope,
  53. int do_update);
  54. int
  55. sctp_is_addr_in_ep(struct sctp_inpcb *inp, struct sctp_ifa *ifa);
  56. struct sctp_ifa *
  57. sctp_source_address_selection(struct sctp_inpcb *inp,
  58. struct sctp_tcb *stcb,
  59. sctp_route_t *ro, struct sctp_nets *net,
  60. int non_asoc_addr_ok, uint32_t vrf_id);
  61. #if defined(__FreeBSD__) || defined(__APPLE__) || defined(__Userspace__)
  62. int sctp_v6src_match_nexthop(struct sockaddr_in6 *src6, sctp_route_t *ro);
  63. int sctp_v4src_match_nexthop(struct sctp_ifa *sifa, sctp_route_t *ro);
  64. #endif
  65. void sctp_send_initiate(struct sctp_inpcb *, struct sctp_tcb *, int);
  66. void
  67. sctp_send_initiate_ack(struct sctp_inpcb *, struct sctp_tcb *,
  68. struct sctp_nets *, struct mbuf *,
  69. int, int,
  70. struct sockaddr *, struct sockaddr *,
  71. struct sctphdr *, struct sctp_init_chunk *,
  72. #if defined(__FreeBSD__) && !defined(__Userspace__)
  73. uint8_t, uint32_t,
  74. #endif
  75. uint32_t, uint16_t);
  76. struct mbuf *
  77. sctp_arethere_unrecognized_parameters(struct mbuf *, int, int *,
  78. struct sctp_chunkhdr *, int *, int *);
  79. void sctp_queue_op_err(struct sctp_tcb *, struct mbuf *);
  80. int
  81. sctp_send_cookie_echo(struct mbuf *, int, int, struct sctp_tcb *,
  82. struct sctp_nets *);
  83. void sctp_send_cookie_ack(struct sctp_tcb *);
  84. void
  85. sctp_send_heartbeat_ack(struct sctp_tcb *, struct mbuf *, int, int,
  86. struct sctp_nets *);
  87. void
  88. sctp_remove_from_wheel(struct sctp_tcb *stcb,
  89. struct sctp_association *asoc,
  90. struct sctp_stream_out *strq, int holds_lock);
  91. void sctp_send_shutdown(struct sctp_tcb *, struct sctp_nets *);
  92. void sctp_send_shutdown_ack(struct sctp_tcb *, struct sctp_nets *);
  93. void sctp_send_shutdown_complete(struct sctp_tcb *, struct sctp_nets *, int);
  94. void sctp_send_shutdown_complete2(struct sockaddr *, struct sockaddr *,
  95. struct sctphdr *,
  96. #if defined(__FreeBSD__) && !defined(__Userspace__)
  97. uint8_t, uint32_t, uint16_t,
  98. #endif
  99. uint32_t, uint16_t);
  100. void sctp_send_asconf(struct sctp_tcb *, struct sctp_nets *, int addr_locked);
  101. void sctp_send_asconf_ack(struct sctp_tcb *);
  102. uint32_t sctp_get_frag_point(struct sctp_tcb *);
  103. void sctp_toss_old_cookies(struct sctp_tcb *, struct sctp_association *);
  104. void sctp_toss_old_asconf(struct sctp_tcb *);
  105. void sctp_fix_ecn_echo(struct sctp_association *);
  106. void sctp_move_chunks_from_net(struct sctp_tcb *stcb, struct sctp_nets *net);
  107. #define SCTP_DATA_CHUNK_OVERHEAD(stcb) ((stcb)->asoc.idata_supported ? \
  108. sizeof(struct sctp_idata_chunk) : \
  109. sizeof(struct sctp_data_chunk))
  110. #if defined(__FreeBSD__) && !defined(__Userspace__)
  111. int
  112. sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *,
  113. struct mbuf *, struct thread *, int);
  114. #elif defined(_WIN32) && !defined(__Userspace__)
  115. sctp_output(struct sctp_inpcb *, struct mbuf *, struct sockaddr *,
  116. struct mbuf *, PKTHREAD, int);
  117. #else
  118. #if defined(__Userspace__)
  119. /* sctp_output is called bu sctp_sendm. Not using sctp_sendm for __Userspace__ */
  120. #endif
  121. int
  122. sctp_output(struct sctp_inpcb *,
  123. struct mbuf *,
  124. struct sockaddr *,
  125. struct mbuf *,
  126. struct proc *, int);
  127. #endif
  128. void sctp_chunk_output(struct sctp_inpcb *, struct sctp_tcb *, int, int);
  129. void sctp_send_abort_tcb(struct sctp_tcb *, struct mbuf *, int);
  130. void send_forward_tsn(struct sctp_tcb *, struct sctp_association *);
  131. void sctp_send_sack(struct sctp_tcb *, int);
  132. void sctp_send_hb(struct sctp_tcb *, struct sctp_nets *, int);
  133. void sctp_send_ecn_echo(struct sctp_tcb *, struct sctp_nets *, uint32_t);
  134. void
  135. sctp_send_packet_dropped(struct sctp_tcb *, struct sctp_nets *, struct mbuf *,
  136. int, int, int);
  137. void sctp_send_cwr(struct sctp_tcb *, struct sctp_nets *, uint32_t, uint8_t);
  138. void
  139. sctp_add_stream_reset_result(struct sctp_tmit_chunk *, uint32_t, uint32_t);
  140. void
  141. sctp_send_deferred_reset_response(struct sctp_tcb *,
  142. struct sctp_stream_reset_list *,
  143. int);
  144. void
  145. sctp_add_stream_reset_result_tsn(struct sctp_tmit_chunk *,
  146. uint32_t, uint32_t, uint32_t, uint32_t);
  147. int
  148. sctp_send_stream_reset_out_if_possible(struct sctp_tcb *, int);
  149. int
  150. sctp_send_str_reset_req(struct sctp_tcb *, uint16_t , uint16_t *,
  151. uint8_t, uint8_t, uint8_t, uint16_t, uint16_t, uint8_t);
  152. void
  153. sctp_send_abort(struct mbuf *, int, struct sockaddr *, struct sockaddr *,
  154. struct sctphdr *, uint32_t, struct mbuf *,
  155. #if defined(__FreeBSD__) && !defined(__Userspace__)
  156. uint8_t, uint32_t, uint16_t,
  157. #endif
  158. uint32_t, uint16_t);
  159. void
  160. sctp_send_operr_to(struct sockaddr *, struct sockaddr *,
  161. struct sctphdr *, uint32_t, struct mbuf *,
  162. #if defined(__FreeBSD__) && !defined(__Userspace__)
  163. uint8_t, uint32_t, uint16_t,
  164. #endif
  165. uint32_t, uint16_t);
  166. #endif /* _KERNEL || __Userspace__ */
  167. #if defined(_KERNEL) || defined(__Userspace__)
  168. int
  169. sctp_sosend(struct socket *so,
  170. struct sockaddr *addr,
  171. struct uio *uio,
  172. struct mbuf *top,
  173. struct mbuf *control,
  174. #if defined(__APPLE__) && !defined(__Userspace__)
  175. int flags
  176. #else
  177. int flags,
  178. #if defined(__FreeBSD__) && !defined(__Userspace__)
  179. struct thread *p
  180. #elif defined(_WIN32) && !defined(__Userspace__)
  181. PKTHREAD p
  182. #else
  183. #if defined(__Userspace__)
  184. /* proc is a dummy in __Userspace__ and will not be passed to sctp_lower_sosend */
  185. #endif
  186. struct proc *p
  187. #endif
  188. #endif
  189. );
  190. #endif
  191. #endif