1 1.1 rjs /* $KAME: sctp_var.h,v 1.24 2005/03/06 16:04:19 itojun Exp $ */ 2 1.4 rjs /* $NetBSD: sctp_var.h,v 1.4 2020/04/27 19:21:43 rjs Exp $ */ 3 1.1 rjs 4 1.1 rjs /* 5 1.1 rjs * Copyright (c) 2001, 2002, 2003, 2004 Cisco Systems, Inc. 6 1.1 rjs * All rights reserved. 7 1.1 rjs * 8 1.1 rjs * Redistribution and use in source and binary forms, with or without 9 1.1 rjs * modification, are permitted provided that the following conditions 10 1.1 rjs * are met: 11 1.1 rjs * 1. Redistributions of source code must retain the above copyright 12 1.1 rjs * notice, this list of conditions and the following disclaimer. 13 1.1 rjs * 2. Redistributions in binary form must reproduce the above copyright 14 1.1 rjs * notice, this list of conditions and the following disclaimer in the 15 1.1 rjs * documentation and/or other materials provided with the distribution. 16 1.1 rjs * 3. All advertising materials mentioning features or use of this software 17 1.1 rjs * must display the following acknowledgement: 18 1.1 rjs * This product includes software developed by Cisco Systems, Inc. 19 1.1 rjs * 4. Neither the name of the project nor the names of its contributors 20 1.1 rjs * may be used to endorse or promote products derived from this software 21 1.1 rjs * without specific prior written permission. 22 1.1 rjs * 23 1.1 rjs * THIS SOFTWARE IS PROVIDED BY CISCO SYSTEMS AND CONTRIBUTORS ``AS IS'' AND 24 1.1 rjs * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25 1.1 rjs * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26 1.1 rjs * ARE DISCLAIMED. IN NO EVENT SHALL CISCO SYSTEMS OR CONTRIBUTORS BE LIABLE 27 1.1 rjs * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 1.1 rjs * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 1.1 rjs * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 1.1 rjs * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 1.1 rjs * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 1.1 rjs * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 1.1 rjs * SUCH DAMAGE. 34 1.1 rjs */ 35 1.1 rjs 36 1.1 rjs #ifndef _NETINET_SCTP_VAR_H_ 37 1.1 rjs #define _NETINET_SCTP_VAR_H_ 38 1.1 rjs 39 1.1 rjs #include <sys/socketvar.h> 40 1.1 rjs #include <netinet/sctp_uio.h> 41 1.1 rjs 42 1.1 rjs /* SCTP Kernel structures */ 43 1.1 rjs 44 1.1 rjs /* 45 1.1 rjs * Names for SCTP sysctl objects 46 1.1 rjs */ 47 1.1 rjs #ifndef __APPLE__ 48 1.1 rjs #define SCTPCTL_MAXDGRAM 1 /* max datagram size */ 49 1.1 rjs #define SCTPCTL_RECVSPACE 2 /* default receive buffer space */ 50 1.1 rjs #define SCTPCTL_AUTOASCONF 3 /* auto asconf enable/disable flag */ 51 1.1 rjs #define SCTPCTL_ECN_ENABLE 4 /* Is ecn allowed */ 52 1.1 rjs #define SCTPCTL_ECN_NONCE 5 /* Is ecn nonce allowed */ 53 1.1 rjs #define SCTPCTL_STRICT_SACK 6 /* strictly require sack'd TSN's to be 54 1.1 rjs * smaller than sndnxt. 55 1.1 rjs */ 56 1.1 rjs #define SCTPCTL_NOCSUM_LO 7 /* Require that the Loopback NOT have 57 1.1 rjs * the crc32 checksum on packets routed over 58 1.1 rjs * it. 59 1.1 rjs */ 60 1.1 rjs #define SCTPCTL_STRICT_INIT 8 61 1.1 rjs #define SCTPCTL_PEER_CHK_OH 9 62 1.1 rjs #define SCTPCTL_MAXBURST 10 63 1.1 rjs #define SCTPCTL_MAXCHUNKONQ 11 64 1.1 rjs #define SCTPCTL_DELAYED_SACK 12 65 1.1 rjs #define SCTPCTL_HB_INTERVAL 13 66 1.1 rjs #define SCTPCTL_PMTU_RAISE 14 67 1.1 rjs #define SCTPCTL_SHUTDOWN_GUARD 15 68 1.1 rjs #define SCTPCTL_SECRET_LIFETIME 16 69 1.1 rjs #define SCTPCTL_RTO_MAX 17 70 1.1 rjs #define SCTPCTL_RTO_MIN 18 71 1.1 rjs #define SCTPCTL_RTO_INITIAL 19 72 1.1 rjs #define SCTPCTL_INIT_RTO_MAX 20 73 1.1 rjs #define SCTPCTL_COOKIE_LIFE 21 74 1.1 rjs #define SCTPCTL_INIT_RTX_MAX 22 75 1.1 rjs #define SCTPCTL_ASSOC_RTX_MAX 23 76 1.1 rjs #define SCTPCTL_PATH_RTX_MAX 24 77 1.1 rjs #define SCTPCTL_NR_OUTGOING_STREAMS 25 78 1.1 rjs #ifdef SCTP_DEBUG 79 1.1 rjs #define SCTPCTL_DEBUG 26 80 1.1 rjs #endif 81 1.1 rjs 82 1.1 rjs #endif 83 1.1 rjs 84 1.1 rjs #if defined(_KERNEL) 85 1.1 rjs 86 1.1 rjs extern const struct pr_usrreqs sctp_usrreqs; 87 1.1 rjs 88 1.1 rjs int sctp_usrreq(struct socket *, int, struct mbuf *, struct mbuf *, 89 1.1 rjs struct mbuf *, struct lwp *); 90 1.1 rjs 91 1.1 rjs #define sctp_sbspace(sb) ((long) (((sb)->sb_hiwat > (sb)->sb_cc) ? ((sb)->sb_hiwat - (sb)->sb_cc) : 0)) 92 1.1 rjs 93 1.1 rjs #define sctp_sbspace_sub(a,b) ((a > b) ? (a - b) : 0) 94 1.1 rjs 95 1.1 rjs extern int sctp_sendspace; 96 1.1 rjs extern int sctp_recvspace; 97 1.1 rjs extern int sctp_ecn; 98 1.1 rjs extern int sctp_ecn_nonce; 99 1.1 rjs 100 1.1 rjs #define sctp_ucount_incr(val) { \ 101 1.1 rjs val++; \ 102 1.1 rjs } 103 1.1 rjs 104 1.1 rjs #define sctp_ucount_decr(val) { \ 105 1.1 rjs if (val > 0) { \ 106 1.1 rjs val--; \ 107 1.1 rjs } else { \ 108 1.1 rjs val = 0; \ 109 1.1 rjs } \ 110 1.1 rjs } 111 1.1 rjs 112 1.1 rjs #define sctp_flight_size_decrease(tp1) do { \ 113 1.1 rjs if (tp1->whoTo->flight_size >= tp1->book_size) \ 114 1.1 rjs tp1->whoTo->flight_size -= tp1->book_size; \ 115 1.1 rjs else \ 116 1.1 rjs tp1->whoTo->flight_size = 0; \ 117 1.1 rjs } while (0) 118 1.1 rjs 119 1.1 rjs #define sctp_flight_size_increase(tp1) do { \ 120 1.1 rjs (tp1)->whoTo->flight_size += (tp1)->book_size; \ 121 1.1 rjs } while (0) 122 1.1 rjs 123 1.1 rjs #define sctp_total_flight_decrease(stcb, tp1) do { \ 124 1.1 rjs if (stcb->asoc.total_flight >= tp1->book_size) { \ 125 1.1 rjs stcb->asoc.total_flight -= tp1->book_size; \ 126 1.1 rjs if (stcb->asoc.total_flight_count > 0) \ 127 1.1 rjs stcb->asoc.total_flight_count--; \ 128 1.1 rjs } else { \ 129 1.1 rjs stcb->asoc.total_flight = 0; \ 130 1.1 rjs stcb->asoc.total_flight_count = 0; \ 131 1.1 rjs } \ 132 1.1 rjs } while (0) 133 1.1 rjs 134 1.1 rjs #define sctp_total_flight_increase(stcb, tp1) do { \ 135 1.1 rjs (stcb)->asoc.total_flight_count++; \ 136 1.1 rjs (stcb)->asoc.total_flight += (tp1)->book_size; \ 137 1.1 rjs } while (0) 138 1.1 rjs 139 1.1 rjs 140 1.1 rjs struct sctp_nets; 141 1.1 rjs struct sctp_inpcb; 142 1.1 rjs struct sctp_tcb; 143 1.1 rjs struct sctphdr; 144 1.1 rjs 145 1.1 rjs void* sctp_ctlinput(int, const struct sockaddr *, void *); 146 1.1 rjs int sctp_ctloutput(int, struct socket *, struct sockopt *); 147 1.3 maxv void sctp_input(struct mbuf *, int, int); 148 1.1 rjs void sctp_drain(void); 149 1.1 rjs void sctp_init(void); 150 1.1 rjs int sctp_shutdown(struct socket *); 151 1.1 rjs void sctp_notify(struct sctp_inpcb *, int, struct sctphdr *, 152 1.1 rjs struct sockaddr *, struct sctp_tcb *, 153 1.1 rjs struct sctp_nets *); 154 1.1 rjs int sctp_rcvd(struct socket *, int, struct lwp *); 155 1.1 rjs int sctp_send(struct socket *, struct mbuf *, struct sockaddr *, 156 1.1 rjs struct mbuf *, struct lwp *); 157 1.1 rjs 158 1.1 rjs #if defined(INET6) 159 1.1 rjs void ip_2_ip6_hdr(struct ip6_hdr *, struct ip *); 160 1.1 rjs #endif 161 1.1 rjs 162 1.1 rjs int sctp_bindx(struct socket *, int, struct sockaddr_storage *, 163 1.1 rjs int, int, struct lwp *); 164 1.4 rjs int sctp_do_connect_x(struct socket *, struct sctp_connectx_addrs *, 165 1.4 rjs struct lwp *, int); 166 1.1 rjs 167 1.1 rjs /* can't use sctp_assoc_t here */ 168 1.1 rjs int sctp_peeloff(struct socket *, struct socket *, int, vaddr_t, int *); 169 1.1 rjs 170 1.1 rjs 171 1.1 rjs sctp_assoc_t sctp_getassocid(struct sockaddr *); 172 1.1 rjs int sctp_sockaddr(struct socket *, struct sockaddr *); 173 1.1 rjs int sctp_peeraddr(struct socket *, struct sockaddr *); 174 1.1 rjs int sctp_listen(struct socket *, struct lwp *); 175 1.1 rjs int sctp_accept(struct socket *, struct sockaddr *); 176 1.1 rjs 177 1.1 rjs int sctp_sysctl(int *, u_int, void *, size_t *, void *, size_t); 178 1.1 rjs 179 1.1 rjs #endif /* _KERNEL */ 180 1.1 rjs 181 1.1 rjs #endif /* !_NETINET_SCTP_VAR_H_ */ 182