Home | History | Annotate | Line # | Download | only in netinet
sctp_var.h revision 1.1
      1  1.1  rjs /*	$KAME: sctp_var.h,v 1.24 2005/03/06 16:04:19 itojun Exp $	*/
      2  1.1  rjs /*	$NetBSD: sctp_var.h,v 1.1 2015/10/13 21:28:35 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 #define SCTPCTL_MAXID		    27
     81  1.1  rjs #else
     82  1.1  rjs #define SCTPCTL_MAXID		    26
     83  1.1  rjs #endif
     84  1.1  rjs 
     85  1.1  rjs #endif
     86  1.1  rjs 
     87  1.1  rjs #ifdef SCTP_DEBUG
     88  1.1  rjs #define SCTPCTL_NAMES { \
     89  1.1  rjs 	{ 0, 0 }, \
     90  1.1  rjs 	{ "maxdgram", CTLTYPE_INT }, \
     91  1.1  rjs 	{ "recvspace", CTLTYPE_INT }, \
     92  1.1  rjs 	{ "autoasconf", CTLTYPE_INT }, \
     93  1.1  rjs 	{ "ecn_enable", CTLTYPE_INT }, \
     94  1.1  rjs 	{ "ecn_nonce", CTLTYPE_INT }, \
     95  1.1  rjs 	{ "strict_sack", CTLTYPE_INT }, \
     96  1.1  rjs 	{ "looback_nocsum", CTLTYPE_INT }, \
     97  1.1  rjs 	{ "strict_init", CTLTYPE_INT }, \
     98  1.1  rjs 	{ "peer_chkoh", CTLTYPE_INT }, \
     99  1.1  rjs 	{ "maxburst", CTLTYPE_INT }, \
    100  1.1  rjs 	{ "maxchunks", CTLTYPE_INT }, \
    101  1.1  rjs 	{ "delayed_sack_time", CTLTYPE_INT }, \
    102  1.1  rjs 	{ "heartbeat_interval", CTLTYPE_INT }, \
    103  1.1  rjs 	{ "pmtu_raise_time", CTLTYPE_INT }, \
    104  1.1  rjs 	{ "shutdown_guard_time", CTLTYPE_INT }, \
    105  1.1  rjs 	{ "secret_lifetime", CTLTYPE_INT }, \
    106  1.1  rjs 	{ "rto_max", CTLTYPE_INT }, \
    107  1.1  rjs 	{ "rto_min", CTLTYPE_INT }, \
    108  1.1  rjs 	{ "rto_initial", CTLTYPE_INT }, \
    109  1.1  rjs 	{ "init_rto_max", CTLTYPE_INT }, \
    110  1.1  rjs 	{ "valid_cookie_life", CTLTYPE_INT }, \
    111  1.1  rjs 	{ "init_rtx_max", CTLTYPE_INT }, \
    112  1.1  rjs 	{ "assoc_rtx_max", CTLTYPE_INT }, \
    113  1.1  rjs 	{ "path_rtx_max", CTLTYPE_INT }, \
    114  1.1  rjs 	{ "nr_outgoing_streams", CTLTYPE_INT }, \
    115  1.1  rjs 	{ "debug", CTLTYPE_INT }, \
    116  1.1  rjs }
    117  1.1  rjs #else
    118  1.1  rjs #define SCTPCTL_NAMES { \
    119  1.1  rjs 	{ 0, 0 }, \
    120  1.1  rjs 	{ "maxdgram", CTLTYPE_INT }, \
    121  1.1  rjs 	{ "recvspace", CTLTYPE_INT }, \
    122  1.1  rjs 	{ "autoasconf", CTLTYPE_INT }, \
    123  1.1  rjs 	{ "ecn_enable", CTLTYPE_INT }, \
    124  1.1  rjs 	{ "ecn_nonce", CTLTYPE_INT }, \
    125  1.1  rjs 	{ "strict_sack", CTLTYPE_INT }, \
    126  1.1  rjs 	{ "looback_nocsum", CTLTYPE_INT }, \
    127  1.1  rjs 	{ "strict_init", CTLTYPE_INT }, \
    128  1.1  rjs 	{ "peer_chkoh", CTLTYPE_INT }, \
    129  1.1  rjs 	{ "maxburst", CTLTYPE_INT }, \
    130  1.1  rjs 	{ "maxchunks", CTLTYPE_INT }, \
    131  1.1  rjs 	{ "delayed_sack_time", CTLTYPE_INT }, \
    132  1.1  rjs 	{ "heartbeat_interval", CTLTYPE_INT }, \
    133  1.1  rjs 	{ "pmtu_raise_time", CTLTYPE_INT }, \
    134  1.1  rjs 	{ "shutdown_guard_time", CTLTYPE_INT }, \
    135  1.1  rjs 	{ "secret_lifetime", CTLTYPE_INT }, \
    136  1.1  rjs 	{ "rto_max", CTLTYPE_INT }, \
    137  1.1  rjs 	{ "rto_min", CTLTYPE_INT }, \
    138  1.1  rjs 	{ "rto_initial", CTLTYPE_INT }, \
    139  1.1  rjs 	{ "init_rto_max", CTLTYPE_INT }, \
    140  1.1  rjs 	{ "valid_cookie_life", CTLTYPE_INT }, \
    141  1.1  rjs 	{ "init_rtx_max", CTLTYPE_INT }, \
    142  1.1  rjs 	{ "assoc_rtx_max", CTLTYPE_INT }, \
    143  1.1  rjs 	{ "path_rtx_max", CTLTYPE_INT }, \
    144  1.1  rjs 	{ "nr_outgoing_streams", CTLTYPE_INT }, \
    145  1.1  rjs }
    146  1.1  rjs #endif
    147  1.1  rjs 
    148  1.1  rjs #if defined(_KERNEL)
    149  1.1  rjs 
    150  1.1  rjs extern const struct pr_usrreqs sctp_usrreqs;
    151  1.1  rjs 
    152  1.1  rjs int sctp_usrreq(struct socket *, int, struct mbuf *, struct mbuf *,
    153  1.1  rjs 		      struct mbuf *, struct lwp *);
    154  1.1  rjs 
    155  1.1  rjs #define	sctp_sbspace(sb) ((long) (((sb)->sb_hiwat > (sb)->sb_cc) ? ((sb)->sb_hiwat - (sb)->sb_cc) : 0))
    156  1.1  rjs 
    157  1.1  rjs #define sctp_sbspace_sub(a,b) ((a > b) ? (a - b) : 0)
    158  1.1  rjs 
    159  1.1  rjs extern int	sctp_sendspace;
    160  1.1  rjs extern int	sctp_recvspace;
    161  1.1  rjs extern int      sctp_ecn;
    162  1.1  rjs extern int      sctp_ecn_nonce;
    163  1.1  rjs 
    164  1.1  rjs #define sctp_ucount_incr(val) { \
    165  1.1  rjs 	val++; \
    166  1.1  rjs }
    167  1.1  rjs 
    168  1.1  rjs #define sctp_ucount_decr(val) { \
    169  1.1  rjs 	if (val > 0) { \
    170  1.1  rjs 		val--; \
    171  1.1  rjs 	} else { \
    172  1.1  rjs 		val = 0; \
    173  1.1  rjs 	} \
    174  1.1  rjs }
    175  1.1  rjs 
    176  1.1  rjs #define sctp_flight_size_decrease(tp1) do { \
    177  1.1  rjs 	if (tp1->whoTo->flight_size >= tp1->book_size) \
    178  1.1  rjs 		tp1->whoTo->flight_size -= tp1->book_size; \
    179  1.1  rjs 	else \
    180  1.1  rjs 		tp1->whoTo->flight_size = 0; \
    181  1.1  rjs } while (0)
    182  1.1  rjs 
    183  1.1  rjs #define sctp_flight_size_increase(tp1) do { \
    184  1.1  rjs        (tp1)->whoTo->flight_size += (tp1)->book_size; \
    185  1.1  rjs } while (0)
    186  1.1  rjs 
    187  1.1  rjs #define sctp_total_flight_decrease(stcb, tp1) do { \
    188  1.1  rjs 	if (stcb->asoc.total_flight >= tp1->book_size) { \
    189  1.1  rjs 		stcb->asoc.total_flight -= tp1->book_size; \
    190  1.1  rjs 		if (stcb->asoc.total_flight_count > 0) \
    191  1.1  rjs 			stcb->asoc.total_flight_count--; \
    192  1.1  rjs 	} else { \
    193  1.1  rjs 		stcb->asoc.total_flight = 0; \
    194  1.1  rjs 		stcb->asoc.total_flight_count = 0; \
    195  1.1  rjs 	} \
    196  1.1  rjs } while (0)
    197  1.1  rjs 
    198  1.1  rjs #define sctp_total_flight_increase(stcb, tp1) do { \
    199  1.1  rjs        (stcb)->asoc.total_flight_count++; \
    200  1.1  rjs        (stcb)->asoc.total_flight += (tp1)->book_size; \
    201  1.1  rjs } while (0)
    202  1.1  rjs 
    203  1.1  rjs 
    204  1.1  rjs struct sctp_nets;
    205  1.1  rjs struct sctp_inpcb;
    206  1.1  rjs struct sctp_tcb;
    207  1.1  rjs struct sctphdr;
    208  1.1  rjs 
    209  1.1  rjs void*	sctp_ctlinput(int, const struct sockaddr *, void *);
    210  1.1  rjs int	sctp_ctloutput(int, struct socket *, struct sockopt *);
    211  1.1  rjs void	sctp_input(struct mbuf *, ... );
    212  1.1  rjs void	sctp_drain(void);
    213  1.1  rjs void	sctp_init(void);
    214  1.1  rjs int	sctp_shutdown(struct socket *);
    215  1.1  rjs void	sctp_notify(struct sctp_inpcb *, int, struct sctphdr *,
    216  1.1  rjs 			 struct sockaddr *, struct sctp_tcb *,
    217  1.1  rjs 			 struct sctp_nets *);
    218  1.1  rjs int sctp_rcvd(struct socket *, int, struct lwp *);
    219  1.1  rjs int sctp_send(struct socket *, struct mbuf *, struct sockaddr *,
    220  1.1  rjs 		struct mbuf *, struct lwp *);
    221  1.1  rjs 
    222  1.1  rjs #if defined(INET6)
    223  1.1  rjs void ip_2_ip6_hdr(struct ip6_hdr *, struct ip *);
    224  1.1  rjs #endif
    225  1.1  rjs 
    226  1.1  rjs int sctp_bindx(struct socket *, int, struct sockaddr_storage *,
    227  1.1  rjs 	int, int, struct lwp *);
    228  1.1  rjs 
    229  1.1  rjs /* can't use sctp_assoc_t here */
    230  1.1  rjs int sctp_peeloff(struct socket *, struct socket *, int, vaddr_t, int *);
    231  1.1  rjs 
    232  1.1  rjs 
    233  1.1  rjs sctp_assoc_t sctp_getassocid(struct sockaddr *);
    234  1.1  rjs int sctp_sockaddr(struct socket *, struct sockaddr *);
    235  1.1  rjs int sctp_peeraddr(struct socket *, struct sockaddr *);
    236  1.1  rjs int sctp_listen(struct socket *, struct lwp *);
    237  1.1  rjs int sctp_accept(struct socket *, struct sockaddr *);
    238  1.1  rjs 
    239  1.1  rjs int sctp_sysctl(int *, u_int, void *, size_t *, void *, size_t);
    240  1.1  rjs 
    241  1.1  rjs #endif /* _KERNEL */
    242  1.1  rjs 
    243  1.1  rjs #endif /* !_NETINET_SCTP_VAR_H_ */
    244