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