summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@home.transmeta.com>2002-08-28 21:23:10 -0700
committerLinus Torvalds <torvalds@home.transmeta.com>2002-08-28 21:23:10 -0700
commitfb4b1e4067352ea154a97e2b6a77f983249ad492 (patch)
treefb7f119c1ba09ef6cecdcd1f3f0aca866175c1bb /include
parent1849a36f3e62ac147523c0482851f187935c9e44 (diff)
parent20c77dc6df3db1dadba222b3ff67048a0deadb2e (diff)
Merge master.kernel.org:/home/davem/BK/sparc-2.5
into home.transmeta.com:/home/torvalds/v2.5/linux
Diffstat (limited to 'include')
-rw-r--r--include/linux/in.h5
-rw-r--r--include/linux/net.h1
-rw-r--r--include/linux/netdevice.h1
-rw-r--r--include/linux/sctp.h590
-rw-r--r--include/linux/skbuff.h5
-rw-r--r--include/linux/socket.h1
-rw-r--r--include/linux/sysctl.h16
-rw-r--r--include/linux/tcp.h3
-rw-r--r--include/linux/usb.h8
-rw-r--r--include/net/inet_common.h8
-rw-r--r--include/net/inetpeer.h5
-rw-r--r--include/net/ip.h16
-rw-r--r--include/net/ipv6.h10
-rw-r--r--include/net/sctp/sctp.h509
-rw-r--r--include/net/sctp/sctp_command.h213
-rw-r--r--include/net/sctp/sctp_constants.h453
-rw-r--r--include/net/sctp/sctp_sla1.h80
-rw-r--r--include/net/sctp/sctp_sm.h420
-rw-r--r--include/net/sctp/sctp_structs.h1543
-rw-r--r--include/net/sctp/sctp_tsnmap.h161
-rw-r--r--include/net/sctp/sctp_ulpevent.h137
-rw-r--r--include/net/sctp/sctp_ulpqueue.h95
-rw-r--r--include/net/sctp/sctp_user.h609
-rw-r--r--include/net/sock.h2
-rw-r--r--include/net/tcp.h26
-rw-r--r--include/net/tcp_ecn.h5
26 files changed, 4904 insertions, 18 deletions
diff --git a/include/linux/in.h b/include/linux/in.h
index f41a61dce932..eebfb0306d1b 100644
--- a/include/linux/in.h
+++ b/include/linux/in.h
@@ -37,11 +37,12 @@ enum {
IPPROTO_IPV6 = 41, /* IPv6-in-IPv4 tunnelling */
- IPPROTO_PIM = 103, /* Protocol Independent Multicast */
-
IPPROTO_ESP = 50, /* Encapsulation Security Payload protocol */
IPPROTO_AH = 51, /* Authentication Header protocol */
+ IPPROTO_PIM = 103, /* Protocol Independent Multicast */
+
IPPROTO_COMP = 108, /* Compression Header protocol */
+ IPPROTO_SCTP = 132, /* Stream Control Transport Protocol */
IPPROTO_RAW = 255, /* Raw IP packets */
IPPROTO_MAX
diff --git a/include/linux/net.h b/include/linux/net.h
index 8cd440ce36d6..c84c7033fed1 100644
--- a/include/linux/net.h
+++ b/include/linux/net.h
@@ -137,6 +137,7 @@ extern int sock_sendmsg(struct socket *, struct msghdr *m, int len);
extern int sock_recvmsg(struct socket *, struct msghdr *m, int len, int flags);
extern int sock_readv_writev(int type, struct inode * inode, struct file * file,
const struct iovec * iov, long count, long size);
+extern int sock_map_fd(struct socket *sock);
extern int net_ratelimit(void);
extern unsigned long net_random(void);
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 9d3bbc92e21e..6ed74303fbda 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -365,6 +365,7 @@ struct net_device
#define NETIF_F_HW_VLAN_RX 256 /* Receive VLAN hw acceleration */
#define NETIF_F_HW_VLAN_FILTER 512 /* Receive filtering on VLAN */
#define NETIF_F_VLAN_CHALLENGED 1024 /* Device cannot handle VLAN packets */
+#define NETIF_F_TSO 2048 /* Can offload TCP/IP segmentation */
/* Called after device is detached from network. */
void (*uninit)(struct net_device *dev);
diff --git a/include/linux/sctp.h b/include/linux/sctp.h
new file mode 100644
index 000000000000..b070fc1220e5
--- /dev/null
+++ b/include/linux/sctp.h
@@ -0,0 +1,590 @@
+/* SCTP kernel reference Implementation
+ * Copyright (c) 1999-2000 Cisco, Inc.
+ * Copyright (c) 1999-2001 Motorola, Inc.
+ * Copyright (c) 2001 International Business Machines, Corp.
+ * Copyright (c) 2001 Intel Corp.
+ * Copyright (c) 2001 Nokia, Inc.
+ * Copyright (c) 2001 La Monte H.P. Yarroll
+ *
+ * This file is part of the SCTP kernel reference Implementation
+ *
+ * $Header: /cvsroot/lksctp/lksctp/sctp_cvs/include/linux/sctp.h,v 1.7 2002/07/17 16:13:50 jgrimm Exp $
+ *
+ * Various protocol defined structures.
+ *
+ * The SCTP reference implementation is free software;
+ * you can redistribute it and/or modify it under the terms of
+ * the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * The SCTP reference implementation is distributed in the hope that it
+ * will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * ************************
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU CC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Please send any bug reports or fixes you make to the
+ * email address(es):
+ * lksctp developers <sctp-developers-list@cig.mot.com>
+ *
+ * Or submit a bug report through the following website:
+ * http://www.sf.net/projects/lksctp
+ *
+ * Written or modified by:
+ * La Monte H.P. Yarroll <piggy@acm.org>
+ * Karl Knutson <karl@athena.chicago.il.us>
+ * Jon Grimm <jgrimm@us.ibm.com>
+ * Xingang Guo <xingang.guo@intel.com>
+ * randall@sctp.chicago.il.us
+ * kmorneau@cisco.com
+ * qxie1@email.mot.com
+ *
+ * Any bugs reported given to us we will try to fix... any fixes shared will
+ * be incorporated into the next SCTP release.
+ */
+#ifndef __LINUX_SCTP_H__
+#define __LINUX_SCTP_H__
+
+#include <linux/in.h> /* We need in_addr. */
+#include <linux/in6.h> /* We need in6_addr. */
+
+
+/* Section 3.1. SCTP Common Header Format */
+typedef struct sctphdr {
+ __u16 source;
+ __u16 dest;
+ __u32 vtag;
+ __u32 checksum;
+} sctp_sctphdr_t __attribute__((packed));
+
+/* Section 3.2. Chunk Field Descriptions. */
+typedef struct sctp_chunkhdr {
+ __u8 type;
+ __u8 flags;
+ __u16 length;
+} sctp_chunkhdr_t __attribute__((packed));
+
+
+/* Section 3.2. Chunk Type Values.
+ * [Chunk Type] identifies the type of information contained in the Chunk
+ * Value field. It takes a value from 0 to 254. The value of 255 is
+ * reserved for future use as an extension field.
+ */
+typedef enum {
+ SCTP_CID_DATA = 0,
+ SCTP_CID_INIT = 1,
+ SCTP_CID_INIT_ACK = 2,
+ SCTP_CID_SACK = 3,
+ SCTP_CID_HEARTBEAT = 4,
+ SCTP_CID_HEARTBEAT_ACK = 5,
+ SCTP_CID_ABORT = 6,
+ SCTP_CID_SHUTDOWN = 7,
+ SCTP_CID_SHUTDOWN_ACK = 8,
+ SCTP_CID_ERROR = 9,
+ SCTP_CID_COOKIE_ECHO = 10,
+ SCTP_CID_COOKIE_ACK = 11,
+ SCTP_CID_ECN_ECNE = 12,
+ SCTP_CID_ECN_CWR = 13,
+ SCTP_CID_SHUTDOWN_COMPLETE = 14,
+
+ /* Use hex, as defined in ADDIP sec. 3.1 */
+ SCTP_CID_ASCONF = 0xC1,
+ SCTP_CID_ASCONF_ACK = 0x80,
+} sctp_cid_t; /* enum */
+
+
+/* Section 3.2
+ * Chunk Types are encoded such that the highest-order two bits specify
+ * the action that must be taken if the processing endpoint does not
+ * recognize the Chunk Type.
+ */
+typedef enum {
+ SCTP_CID_ACTION_DISCARD = 0x00,
+ SCTP_CID_ACTION_DISCARD_ERR = 0x40,
+ SCTP_CID_ACTION_SKIP = 0x80,
+ SCTP_CID_ACTION_SKIP_ERR = 0xc0,
+} sctp_cid_action_t;
+
+enum { SCTP_CID_ACTION_MASK = 0xc0, };
+
+/* This flag is used in Chunk Flags for ABORT and SHUTDOWN COMPLETE.
+ *
+ * 3.3.7 Abort Association (ABORT) (6):
+ * The T bit is set to 0 if the sender had a TCB that it destroyed.
+ * If the sender did not have a TCB it should set this bit to 1.
+ */
+enum { SCTP_CHUNK_FLAG_T = 0x01 };
+
+/*
+ * Set the T bit
+ *
+ * 0 1 2 3
+ * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ * | Type = 14 |Reserved |T| Length = 4 |
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ * Chunk Flags: 8 bits
+ *
+ * Reserved: 7 bits
+ * Set to 0 on transmit and ignored on receipt.
+ *
+ * T bit: 1 bit
+ * The T bit is set to 0 if the sender had a TCB that it destroyed. If
+ * the sender did NOT have a TCB it should set this bit to 1.
+ *
+ * Note: Special rules apply to this chunk for verification, please
+ * see Section 8.5.1 for details.
+ */
+
+#define sctp_test_T_bit(c) ((c)->chunk_hdr->flags & SCTP_CHUNK_FLAG_T)
+
+/* RFC 2960
+ * Section 3.2.1 Optional/Variable-length Parmaeter Format.
+ */
+
+typedef struct sctp_paramhdr {
+ __u16 type;
+ __u16 length;
+} sctp_paramhdr_t __attribute((packed));
+
+typedef enum {
+
+ /* RFC 2960 Section 3.3.5 */
+ SCTP_PARAM_HEATBEAT_INFO = __constant_htons(1),
+ /* RFC 2960 Section 3.3.2.1 */
+ SCTP_PARAM_IPV4_ADDRESS = __constant_htons(5),
+ SCTP_PARAM_IPV6_ADDRESS = __constant_htons(6),
+ SCTP_PARAM_STATE_COOKIE = __constant_htons(7),
+ SCTP_PARAM_UNRECOGNIZED_PARAMETERS = __constant_htons(8),
+ SCTP_PARAM_COOKIE_PRESERVATIVE = __constant_htons(9),
+ SCTP_PARAM_HOST_NAME_ADDRESS = __constant_htons(11),
+ SCTP_PARAM_SUPPORTED_ADDRESS_TYPES = __constant_htons(12),
+ SCTP_PARAM_ECN_CAPABLE = __constant_htons(0x8000),
+
+ /* Add-IP Extension. Section 3.2 */
+ SCTP_PARAM_ADD_IP = __constant_htons(0xc001),
+ SCTP_PARAM_DEL_IP = __constant_htons(0xc002),
+ SCTP_PARAM_ERR_CAUSE = __constant_htons(0xc003),
+ SCTP_PARAM_SET_PRIMARY = __constant_htons(0xc004),
+ SCTP_PARAM_SUCCESS_REPORT = __constant_htons(0xc005),
+ SCTP_PARAM_ADAPTION_LAYER_IND = __constant_htons(0xc006),
+
+} sctp_param_t; /* enum */
+
+
+/* RFC 2960 Section 3.2.1
+ * The Parameter Types are encoded such that the highest-order two bits
+ * specify the action that must be taken if the processing endpoint does
+ * not recognize the Parameter Type.
+ *
+ */
+typedef enum {
+ SCTP_PARAM_ACTION_DISCARD = __constant_htons(0x0000),
+ SCTP_PARAM_ACTION_DISCARD_ERR = __constant_htons(0x4000),
+ SCTP_PARAM_ACTION_SKIP = __constant_htons(0x8000),
+ SCTP_PARAM_ACTION_SKIP_ERR = __constant_htons(0xc000),
+} sctp_param_action_t;
+
+
+/* RFC 2960 Section 3.3.1 Payload Data (DATA) (0) */
+
+typedef struct sctp_datahdr {
+ __u32 tsn;
+ __u16 stream;
+ __u16 ssn;
+ __u32 ppid;
+ __u8 payload[0];
+} sctp_datahdr_t __attribute__((packed));
+
+typedef struct sctp_data_chunk {
+ sctp_chunkhdr_t chunk_hdr;
+ sctp_datahdr_t data_hdr;
+} sctp_data_chunk_t __attribute__((packed));
+
+/* DATA Chuck Specific Flags */
+enum {
+ SCTP_DATA_MIDDLE_FRAG = 0x00,
+ SCTP_DATA_LAST_FRAG = 0x01,
+ SCTP_DATA_FIRST_FRAG = 0x02,
+ SCTP_DATA_NOT_FRAG = 0x03,
+ SCTP_DATA_UNORDERED = 0x04,
+};
+enum { SCTP_DATA_FRAG_MASK = 0x03, };
+
+
+/* RFC 2960 Section 3.3.2 Initiation (INIT) (1)
+ *
+ * This chunk is used to initiate a SCTP association between two
+ * endpoints.
+ */
+typedef struct sctp_inithdr {
+ __u32 init_tag;
+ __u32 a_rwnd;
+ __u16 num_outbound_streams;
+ __u16 num_inbound_streams;
+ __u32 initial_tsn;
+ __u8 params[0];
+} sctp_inithdr_t __attribute__((packed));
+
+typedef struct sctp_init_chunk {
+ sctp_chunkhdr_t chunk_hdr;
+ sctp_inithdr_t init_hdr;
+} sctp_init_chunk_t __attribute__((packed));
+
+
+/* Section 3.3.2.1. IPv4 Address Parameter (5) */
+typedef struct sctp_ipv4addr_param {
+ sctp_paramhdr_t param_hdr;
+ struct in_addr addr;
+} sctp_ipv4addr_param_t __attribute__((packed));
+
+/* Section 3.3.2.1. IPv6 Address Parameter (6) */
+typedef struct sctp_ipv6addr_param {
+ sctp_paramhdr_t param_hdr;
+ struct in6_addr addr;
+} sctp_ipv6addr_param_t __attribute__((packed));
+
+/* Section 3.3.2.1 Cookie Preservative (9) */
+typedef struct sctp_cookie_preserve_param {
+ sctp_paramhdr_t param_hdr;
+ uint32_t lifespan_increment;
+} sctp_cookie_preserve_param_t __attribute__((packed));
+
+/* Section 3.3.2.1 Host Name Address (11) */
+typedef struct sctp_hostname_param {
+ sctp_paramhdr_t param_hdr;
+ uint8_t hostname[0];
+} sctp_hostname_param_t __attribute__((packed));
+
+/* Section 3.3.2.1 Supported Address Types (12) */
+typedef struct sctp_supported_addrs_param {
+ sctp_paramhdr_t param_hdr;
+ uint16_t types[0];
+} sctp_supported_addrs_param_t __attribute__((packed));
+
+/* Appendix A. ECN Capable (32768) */
+typedef struct sctp_ecn_capable_param {
+ sctp_paramhdr_t param_hdr;
+} sctp_ecn_capable_param_t __attribute__((packed));
+
+
+
+/* RFC 2960. Section 3.3.3 Initiation Acknowledgement (INIT ACK) (2):
+ * The INIT ACK chunk is used to acknowledge the initiation of an SCTP
+ * association.
+ */
+typedef sctp_init_chunk_t sctp_initack_chunk_t;
+
+/* Section 3.3.3.1 State Cookie (7) */
+typedef struct sctp_cookie_param {
+ sctp_paramhdr_t p;
+ __u8 body[0];
+} sctp_cookie_param_t __attribute__((packed));
+
+/* Section 3.3.3.1 Unrecognized Parameters (8) */
+typedef struct sctp_unrecognized_param {
+ sctp_paramhdr_t param_hdr;
+ sctp_paramhdr_t unrecognized;
+} sctp_unrecognized_param_t __attribute__((packed));
+
+
+
+/*
+ * 3.3.4 Selective Acknowledgement (SACK) (3):
+ *
+ * This chunk is sent to the peer endpoint to acknowledge received DATA
+ * chunks and to inform the peer endpoint of gaps in the received
+ * subsequences of DATA chunks as represented by their TSNs.
+ */
+
+typedef struct sctp_gap_ack_block {
+ __u16 start;
+ __u16 end;
+} sctp_gap_ack_block_t __attribute__((packed));
+
+typedef uint32_t sctp_dup_tsn_t;
+
+typedef union {
+ sctp_gap_ack_block_t gab;
+ sctp_dup_tsn_t dup;
+} sctp_sack_variable_t;
+
+typedef struct sctp_sackhdr {
+ __u32 cum_tsn_ack;
+ __u32 a_rwnd;
+ __u16 num_gap_ack_blocks;
+ __u16 num_dup_tsns;
+ sctp_sack_variable_t variable[0];
+} sctp_sackhdr_t __attribute__((packed));
+
+typedef struct sctp_sack_chunk {
+ sctp_chunkhdr_t chunk_hdr;
+ sctp_sackhdr_t sack_hdr;
+} sctp_sack_chunk_t __attribute__((packed));
+
+
+/* RFC 2960. Section 3.3.5 Heartbeat Request (HEARTBEAT) (4):
+ *
+ * An endpoint should send this chunk to its peer endpoint to probe the
+ * reachability of a particular destination transport address defined in
+ * the present association.
+ */
+
+typedef struct sctp_heartbeathdr {
+ sctp_paramhdr_t info;
+} sctp_heartbeathdr_t __attribute__((packed));
+
+typedef struct sctp_heartbeat_chunk {
+ sctp_chunkhdr_t chunk_hdr;
+ sctp_heartbeathdr_t hb_hdr;
+} sctp_heartbeat_chunk_t __attribute__((packed));
+
+
+/* For the abort and shutdown ACK we must carry the init tag in the
+ * common header. Just the common header is all that is needed with a
+ * chunk descriptor.
+ */
+typedef struct sctp_abort_chunk {
+ sctp_chunkhdr_t uh;
+} sctp_abort_chunkt_t __attribute__((packed));
+
+
+/* For the graceful shutdown we must carry the tag (in common header)
+ * and the highest consecutive acking value.
+ */
+typedef struct sctp_shutdownhdr {
+ __u32 cum_tsn_ack;
+} sctp_shutdownhdr_t __attribute__((packed));
+
+struct sctp_shutdown_chunk_t {
+ sctp_chunkhdr_t chunk_hdr;
+ sctp_shutdownhdr_t shutdown_hdr;
+} __attribute__((packed));
+
+
+
+/* RFC 2960. Section 3.3.10 Operation Error (ERROR) (9) */
+
+typedef struct sctp_errhdr {
+ __u16 cause;
+ __u16 length;
+ __u8 variable[0];
+} sctp_errhdr_t __attribute__((packed));
+
+typedef struct sctp_operr_chunk {
+ sctp_chunkhdr_t chunk_hdr;
+ sctp_errhdr_t err_hdr;
+} sctp_operr_chunk_t __attribute__((packed));
+
+/* RFC 2960 3.3.10 - Operation Error
+ *
+ * Cause Code: 16 bits (unsigned integer)
+ *
+ * Defines the type of error conditions being reported.
+ * Cause Code
+ * Value Cause Code
+ * --------- ----------------
+ * 1 Invalid Stream Identifier
+ * 2 Missing Mandatory Parameter
+ * 3 Stale Cookie Error
+ * 4 Out of Resource
+ * 5 Unresolvable Address
+ * 6 Unrecognized Chunk Type
+ * 7 Invalid Mandatory Parameter
+ * 8 Unrecognized Parameters
+ * 9 No User Data
+ * 10 Cookie Received While Shutting Down
+ */
+typedef enum {
+
+ SCTP_ERROR_NO_ERROR = __constant_htons(0x00),
+ SCTP_ERROR_INV_STRM = __constant_htons(0x01),
+ SCTP_ERROR_MISS_PARAM = __constant_htons(0x02),
+ SCTP_ERROR_STALE_COOKIE = __constant_htons(0x03),
+ SCTP_ERROR_NO_RESOURCE = __constant_htons(0x04),
+ SCTP_ERROR_DNS_FAILED = __constant_htons(0x05),
+ SCTP_ERROR_UNKNOWN_CHUNK = __constant_htons(0x06),
+ SCTP_ERROR_INV_PARAM = __constant_htons(0x07),
+ SCTP_ERROR_UNKNOWN_PARAM = __constant_htons(0x08),
+ SCTP_ERROR_NO_DATA = __constant_htons(0x09),
+ SCTP_ERROR_COOKIE_IN_SHUTDOWN = __constant_htons(0x0a),
+
+
+ /* SCTP Implementation Guide:
+ * 11 Restart of an association with new addresses
+ * 12 User Initiated Abort
+ */
+
+ SCTP_ERROR_RESTART = __constant_htons(0x0b),
+ SCTP_ERROR_USER_ABORT = __constant_htons(0x0c),
+
+ /* ADDIP Section 3.3 New Error Causes
+ *
+ * Four new Error Causes are added to the SCTP Operational Errors,
+ * primarily for use in the ASCONF-ACK chunk.
+ *
+ * Value Cause Code
+ * --------- ----------------
+ * 0x0100 Request to Delete Last Remaining IP Address.
+ * 0x0101 Operation Refused Due to Resource Shortage.
+ * 0x0102 Request to Delete Source IP Address.
+ * 0x0103 Association Aborted due to illegal ASCONF-ACK
+ */
+ SCTP_ERROR_DEL_LAST_IP = __constant_htons(0x0100),
+ SCTP_ERROR_RSRC_LOW = __constant_htons(0x0101),
+ SCTP_ERROR_DEL_SRC_IP = __constant_htons(0x0102),
+ SCTP_ERROR_ASCONF_ACK = __constant_htons(0x0103),
+
+} sctp_error_t;
+
+
+
+/* RFC 2960. Appendix A. Explicit Congestion Notification.
+ * Explicit Congestion Notification Echo (ECNE) (12)
+ */
+typedef struct sctp_ecnehdr {
+ __u32 lowest_tsn;
+} sctp_ecnehdr_t;
+
+typedef struct sctp_ecne_chunk {
+ sctp_chunkhdr_t chunk_hdr;
+ sctp_ecnehdr_t ence_hdr;
+} sctp_ecne_chunk_t __attribute__((packed));
+
+/* RFC 2960. Appendix A. Explicit Congestion Notification.
+ * Congestion Window Reduced (CWR) (13)
+ */
+typedef struct sctp_cwrhdr {
+ __u32 lowest_tsn;
+} sctp_cwrhdr_t;
+
+typedef struct sctp_cwr_chunk {
+ sctp_chunkhdr_t chunk_hdr;
+ sctp_cwrhdr_t cwr_hdr;
+} sctp_cwr_chunk_t __attribute__((packed));
+
+
+/* FIXME: Cleanup needs to continue below this line. */
+
+/*
+ * ADDIP Section 3.1 New Chunk Types
+ */
+
+
+/* ADDIP Section 3.1.1
+ *
+ * ASCONF-Request Correlation ID: 32 bits (unsigned integer)
+ *
+ * This is an opaque integer assigned by the sender to identify each
+ * request parameter. It is in host byte order and is only meaningful
+ * to the sender. The receiver of the ASCONF Chunk will copy this 32
+ * bit value into the ASCONF Correlation ID field of the
+ * ASCONF-ACK. The sender of the ASCONF can use this same value in the
+ * ASCONF-ACK to find which request the response is for.
+ *
+ * ASCONF Parameter: TLV format
+ *
+ * Each Address configuration change is represented by a TLV parameter
+ * as defined in Section 3.2. One or more requests may be present in
+ * an ASCONF Chunk.
+ */
+typedef struct {
+ __u32 correlation;
+ sctp_paramhdr_t p;
+ __u8 payload[0];
+} sctpAsconfReq_t;
+
+/* ADDIP
+ * 3.1.1 Address/Stream Configuration Change Chunk (ASCONF)
+ *
+ * This chunk is used to communicate to the remote endpoint one of the
+ * configuration change requests that MUST be acknowledged. The
+ * information carried in the ASCONF Chunk uses the form of a
+ * Tag-Length-Value (TLV), as described in "3.2.1
+ * Optional/Variable-length Parameter Format" in [RFC2960], for all
+ * variable parameters.
+ */
+typedef struct {
+ __u32 serial;
+ __u8 reserved[3];
+ __u8 addr_type;
+ __u32 addr[4];
+ sctpAsconfReq_t requests[0];
+} sctpAsconf_t;
+
+/* ADDIP
+ * 3.1.2 Address/Stream Configuration Acknowledgment Chunk (ASCONF-ACK)
+ *
+ * ASCONF-Request Correlation ID: 32 bits (unsigned integer)
+ *
+ * This value is copied from the ASCONF Correlation ID received in the
+ * ASCONF Chunk. It is used by the receiver of the ASCONF-ACK to identify
+ * which ASCONF parameter this response is associated with.
+ *
+ * ASCONF Parameter Response : TLV format
+ *
+ * The ASCONF Parameter Response is used in the ASCONF-ACK to report
+ * status of ASCONF processing. By default, if a responding endpoint
+ * does not include any Error Cause, a success is indicated. Thus a
+ * sender of an ASCONF-ACK MAY indicate complete success of all TLVs in
+ * an ASCONF by returning only the Chunk Type, Chunk Flags, Chunk Length
+ * (set to 8) and the Serial Number.
+ */
+typedef union {
+ struct {
+ __u32 correlation;
+ sctp_paramhdr_t header; /* success report */
+ } success;
+ struct {
+ __u32 correlation;
+ sctp_paramhdr_t header; /* error cause indication */
+ sctp_paramhdr_t errcause;
+ uint8_t request[0]; /* original request from ASCONF */
+ } error;
+#define __correlation success.correlation
+#define __header success.header
+#define __cause error.errcause
+#define __request error.request
+} sctpAsconfAckRsp_t;
+
+/* ADDIP
+ * 3.1.2 Address/Stream Configuration Acknowledgment Chunk (ASCONF-ACK)
+ *
+ * This chunk is used by the receiver of an ASCONF Chunk to
+ * acknowledge the reception. It carries zero or more results for any
+ * ASCONF Parameters that were processed by the receiver.
+ */
+typedef struct {
+ __u32 serial;
+ sctpAsconfAckRsp_t responses[0];
+} sctpAsconfAck_t;
+
+/*********************************************************************
+ * Internal structures
+ *
+ * These are data structures which never go out on the wire.
+ *********************************************************************/
+
+/* What is this data structure for? The TLV isn't one--it is just a
+ * value. Perhaps this data structure ought to have a type--otherwise
+ * it is not unambigiously parseable. --piggy
+ */
+typedef struct {
+ struct list_head hook;
+ int length; /* length of the TLV */
+
+ /* the actually TLV to be copied into ASCONF_ACK */
+ sctpAsconfAckRsp_t TLV;
+} sctpAsconfAckRspNode_t;
+
+
+
+
+#endif /* __LINUX_SCTP_H__ */
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index a81268125163..9b6e6ad08e2a 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -109,7 +109,8 @@ struct sk_buff_head {
struct sk_buff;
-#define MAX_SKB_FRAGS 6
+/* To allow 64K frame to be packed as single skb without frag_list */
+#define MAX_SKB_FRAGS (65536/PAGE_SIZE + 2)
typedef struct skb_frag_struct skb_frag_t;
@@ -125,6 +126,8 @@ struct skb_frag_struct {
struct skb_shared_info {
atomic_t dataref;
unsigned int nr_frags;
+ unsigned short tso_size;
+ unsigned short tso_segs;
struct sk_buff *frag_list;
skb_frag_t frags[MAX_SKB_FRAGS];
};
diff --git a/include/linux/socket.h b/include/linux/socket.h
index 74303f129fdd..f8e90303576d 100644
--- a/include/linux/socket.h
+++ b/include/linux/socket.h
@@ -227,6 +227,7 @@ struct ucred {
#define SOL_UDP 17
#define SOL_IPV6 41
#define SOL_ICMPV6 58
+#define SOL_SCTP 132
#define SOL_RAW 255
#define SOL_IPX 256
#define SOL_AX25 257
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index 07eed48ea3f8..4c598d745e2e 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -172,6 +172,7 @@ enum
NET_TR=14,
NET_DECNET=15,
NET_ECONET=16,
+ NET_SCTP=17,
};
/* /proc/sys/kernel/random */
@@ -516,6 +517,21 @@ enum {
NET_DECNET_CONF_DEV_STATE = 7
};
+/* /proc/sys/net/sctp */
+enum {
+ NET_SCTP_RTO_INITIAL = 1,
+ NET_SCTP_RTO_MIN = 2,
+ NET_SCTP_RTO_MAX = 3,
+ NET_SCTP_RTO_ALPHA = 4,
+ NET_SCTP_RTO_BETA = 5,
+ NET_SCTP_VALID_COOKIE_LIFE = 6,
+ NET_SCTP_ASSOCIATION_MAX_RETRANS = 7,
+ NET_SCTP_PATH_MAX_RETRANS = 8,
+ NET_SCTP_MAX_INIT_RETRANSMITS = 9,
+ NET_SCTP_HB_INTERVAL = 10,
+ NET_SCTP_MAX_BURST = 11,
+};
+
/* CTL_PROC names: */
/* CTL_FS names: */
diff --git a/include/linux/tcp.h b/include/linux/tcp.h
index 24cc0ac95504..ce34341d6a2c 100644
--- a/include/linux/tcp.h
+++ b/include/linux/tcp.h
@@ -241,7 +241,8 @@ struct tcp_opt {
__u32 snd_wnd; /* The window we expect to receive */
__u32 max_window; /* Maximal window ever seen from peer */
__u32 pmtu_cookie; /* Last pmtu seen by socket */
- __u16 mss_cache; /* Cached effective mss, not including SACKS */
+ __u32 mss_cache; /* Cached effective mss, not including SACKS */
+ __u16 mss_cache_std; /* Like mss_cache, but without TSO */
__u16 mss_clamp; /* Maximal mss, negotiated at connection setup */
__u16 ext_header_len; /* Network protocol overhead (IP/IPv6 options) */
__u8 ca_state; /* State of fast-retransmit machine */
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 5e5c14883819..7e78883daa20 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -1036,6 +1036,14 @@ struct urb *usb_buffer_map (struct urb *urb);
void usb_buffer_dmasync (struct urb *urb);
void usb_buffer_unmap (struct urb *urb);
+struct scatterlist;
+int usb_buffer_map_sg (struct usb_device *dev, unsigned pipe,
+ struct scatterlist *sg, int nents);
+void usb_buffer_dmasync_sg (struct usb_device *dev, unsigned pipe,
+ struct scatterlist *sg, int n_hw_ents);
+void usb_buffer_unmap_sg (struct usb_device *dev, unsigned pipe,
+ struct scatterlist *sg, int n_hw_ents);
+
/*-------------------------------------------------------------------*
* SYNCHRONOUS CALL SUPPORT *
*-------------------------------------------------------------------*/
diff --git a/include/net/inet_common.h b/include/net/inet_common.h
index 87b3fd324347..bbb1fa70099e 100644
--- a/include/net/inet_common.h
+++ b/include/net/inet_common.h
@@ -43,6 +43,14 @@ extern void inet_sock_release(struct sock *sk);
extern void inet_sock_destruct(struct sock *sk);
extern atomic_t inet_sock_nr;
+extern int inet_bind(struct socket *sock,
+ struct sockaddr *uaddr, int addr_len);
+extern int inet_getname(struct socket *sock,
+ struct sockaddr *uaddr,
+ int *uaddr_len, int peer);
+extern int inet_ioctl(struct socket *sock,
+ unsigned int cmd, unsigned long arg);
+
#endif
diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
index 33105051f304..5fd62eb25a04 100644
--- a/include/net/inetpeer.h
+++ b/include/net/inetpeer.h
@@ -53,12 +53,13 @@ static inline void inet_putpeer(struct inet_peer *p)
extern spinlock_t inet_peer_idlock;
/* can be called with or without local BH being disabled */
-static inline __u16 inet_getid(struct inet_peer *p)
+static inline __u16 inet_getid(struct inet_peer *p, int more)
{
__u16 id;
spin_lock_bh(&inet_peer_idlock);
- id = p->ip_id_count++;
+ id = p->ip_id_count;
+ p->ip_id_count += 1 + more;
spin_unlock_bh(&inet_peer_idlock);
return id;
}
diff --git a/include/net/ip.h b/include/net/ip.h
index e2da92393da8..75c55173ecb0 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -187,7 +187,7 @@ int ip_dont_fragment(struct sock *sk, struct dst_entry *dst)
!(dst->mxlock&(1<<RTAX_MTU))));
}
-extern void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst);
+extern void __ip_select_ident(struct iphdr *iph, struct dst_entry *dst, int more);
static inline void ip_select_ident(struct iphdr *iph, struct dst_entry *dst, struct sock *sk)
{
@@ -200,7 +200,19 @@ static inline void ip_select_ident(struct iphdr *iph, struct dst_entry *dst, str
iph->id = (sk && inet_sk(sk)->daddr) ?
htons(inet_sk(sk)->id++) : 0;
} else
- __ip_select_ident(iph, dst);
+ __ip_select_ident(iph, dst, 0);
+}
+
+static inline void ip_select_ident_more(struct iphdr *iph, struct dst_entry *dst, struct sock *sk, int more)
+{
+ if (iph->frag_off&__constant_htons(IP_DF)) {
+ if (sk && inet_sk(sk)->daddr) {
+ iph->id = htons(inet_sk(sk)->id);
+ inet_sk(sk)->id += 1 + more;
+ } else
+ iph->id = 0;
+ } else
+ __ip_select_ident(iph, dst, more);
}
/*
diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 55ca37370540..1c7a736a2796 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -4,7 +4,7 @@
* Authors:
* Pedro Roque <roque@di.fc.ul.pt>
*
- * $Id: ipv6.h,v 1.23 2000/12/13 18:31:48 davem Exp $
+ * $Id: ipv6.h,v 1.1 2002/05/20 15:13:07 jgrimm Exp $
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -336,6 +336,14 @@ extern void ipv6_icmp_error(struct sock *sk, struct sk_buff *skb, int err, u16
u32 info, u8 *payload);
extern void ipv6_local_error(struct sock *sk, int err, struct flowi *fl, u32 info);
+extern int inet6_release(struct socket *sock);
+extern int inet6_bind(struct socket *sock, struct sockaddr *uaddr,
+ int addr_len);
+extern int inet6_getname(struct socket *sock, struct sockaddr *uaddr,
+ int *uaddr_len, int peer);
+extern int inet6_ioctl(struct socket *sock, unsigned int cmd,
+ unsigned long arg);
+
#endif /* __KERNEL__ */
#endif /* _NET_IPV6_H */
diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
new file mode 100644
index 000000000000..185e39ee064c
--- /dev/null
+++ b/include/net/sctp/sctp.h
@@ -0,0 +1,509 @@
+/* SCTP kernel reference Implementation
+ * Copyright (c) 1999-2000 Cisco, Inc.
+ * Copyright (c) 1999-2001 Motorola, Inc.
+ * Copyright (c) 2001 International Business Machines, Corp.
+ * Copyright (c) 2001 Intel Corp.
+ *
+ * This file is part of the SCTP kernel reference Implementation
+ *
+ * $Id: sctp.h,v 1.40 2002/08/21 18:34:03 jgrimm Exp $
+ *
+ * The base lksctp header.
+ *
+ * The SCTP reference implementation is free software;
+ * you can redistribute it and/or modify it under the terms of
+ * the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * The SCTP reference implementation is distributed in the hope that it
+ * will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * ************************
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU CC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Please send any bug reports or fixes you make to the
+ * email address(es):
+ * lksctp developers <lksctp-developers@lists.sourceforge.net>
+ *
+ * Or submit a bug report through the following website:
+ * http://www.sf.net/projects/lksctp
+ *
+ * Written or modified by:
+ * La Monte H.P. Yarroll <piggy@acm.org>
+ * Xingang Guo <xingang.guo@intel.com>
+ * Jon Grimm <jgrimm@us.ibm.com>
+ * Daisy Chang <daisyc@us.ibm.com>
+ *
+ * Any bugs reported given to us we will try to fix... any fixes shared will
+ * be incorporated into the next SCTP release.
+ */
+
+#ifndef __net_sctp_h__
+#define __net_sctp_h__
+
+/* Header Strategy.
+ * Start getting some control over the header file depencies:
+ * includes
+ * constants
+ * structs
+ * prototypes
+ * macros, externs, and inlines
+ *
+ * Move test_frame specific items out of the kernel headers
+ * and into the test frame headers. This is not perfect in any sense
+ * and will continue to evolve.
+ */
+
+
+#include <linux/config.h>
+
+#ifdef TEST_FRAME
+#undef CONFIG_PROC_FS
+#undef CONFIG_SCTP_DBG_OBJCNT
+#undef CONFIG_SYSCTL
+#endif /* TEST_FRAME */
+
+#include <linux/types.h>
+#include <linux/slab.h>
+#include <linux/in.h>
+#include <linux/tty.h>
+#include <linux/proc_fs.h>
+#include <linux/spinlock.h>
+#include <linux/jiffies.h>
+
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+#include <net/ipv6.h>
+#include <net/ip6_route.h>
+#endif
+
+#include <asm/uaccess.h>
+#include <asm/page.h>
+#include <net/sock.h>
+#include <net/sctp/sctp_structs.h>
+#include <net/sctp/sctp_constants.h>
+#include <net/sctp/sctp_sm.h>
+
+
+/* Set SCTP_DEBUG flag via config if not already set. */
+#ifndef SCTP_DEBUG
+#ifdef CONFIG_SCTP_DBG_MSG
+#define SCTP_DEBUG 1
+#else
+#define SCTP_DEBUG 0
+#endif /* CONFIG_SCTP_DBG */
+#endif /* SCTP_DEBUG */
+
+#ifdef CONFIG_IP_SCTP_MODULE
+#define SCTP_PROTOSW_FLAG 0
+#else /* static! */
+#define SCTP_PROTOSW_FLAG INET_PROTOSW_PERMANENT
+#endif
+
+/*
+ * Function declarations.
+ */
+
+/*
+ * sctp_protocol.c
+ */
+extern sctp_protocol_t sctp_proto;
+extern struct sock *sctp_get_ctl_sock(void);
+extern int sctp_copy_local_addr_list(sctp_protocol_t *, sctp_bind_addr_t *,
+ sctp_scope_t, int priority, int flags);
+
+
+/*
+ * sctp_socket.c
+ */
+extern int sctp_backlog_rcv(struct sock *sk, struct sk_buff *skb);
+extern int sctp_inet_listen(struct socket *sock, int backlog);
+extern void sctp_write_space(struct sock *sk);
+extern unsigned int sctp_poll(struct file *file, struct socket *sock,
+ poll_table *wait);
+
+/*
+ * sctp_primitive.c
+ */
+extern int sctp_primitive_ASSOCIATE(sctp_association_t *, void *arg);
+extern int sctp_primitive_SHUTDOWN(sctp_association_t *, void *arg);
+extern int sctp_primitive_ABORT(sctp_association_t *, void *arg);
+extern int sctp_primitive_SEND(sctp_association_t *, void *arg);
+
+
+/*
+ * sctp_crc32c.c
+ */
+extern __u32 count_crc(__u8 *ptr, __u16 count);
+
+/*
+ * sctp_input.c
+ */
+extern int sctp_rcv(struct sk_buff *skb);
+extern void sctp_v4_err(struct sk_buff *skb, u32 info);
+extern void sctp_hash_established(sctp_association_t *);
+extern void __sctp_hash_established(sctp_association_t *);
+extern void sctp_unhash_established(sctp_association_t *);
+extern void __sctp_unhash_established(sctp_association_t *);
+extern void sctp_hash_endpoint(sctp_endpoint_t *);
+extern void __sctp_hash_endpoint(sctp_endpoint_t *);
+extern void sctp_unhash_endpoint(sctp_endpoint_t *);
+extern void __sctp_unhash_endpoint(sctp_endpoint_t *);
+
+/*
+ * sctp_hashdriver.c
+ */
+extern void sctp_hash_digest(const char *secret, const int secret_len,
+ const char *text, const int text_len,
+ __u8 *digest);
+
+/*
+ * Section: Macros, externs, and inlines
+ */
+
+
+#ifdef TEST_FRAME
+
+#include <test_frame.h>
+
+#else
+
+/* spin lock wrappers. */
+#define sctp_spin_lock_irqsave(lock, flags) spin_lock_irqsave(lock, flags)
+#define sctp_spin_unlock_irqrestore(lock, flags) \
+ spin_unlock_irqrestore(lock, flags)
+#define sctp_local_bh_disable() local_bh_disable()
+#define sctp_local_bh_enable() local_bh_enable()
+#define sctp_spin_lock(lock) spin_lock(lock)
+#define sctp_spin_unlock(lock) spin_unlock(lock)
+#define sctp_write_lock(lock) write_lock(lock)
+#define sctp_write_unlock(lock) write_unlock(lock)
+#define sctp_read_lock(lock) read_lock(lock)
+#define sctp_read_unlock(lock) read_unlock(lock)
+
+/* sock lock wrappers. */
+#define sctp_lock_sock(sk) lock_sock(sk)
+#define sctp_release_sock(sk) release_sock(sk)
+#define sctp_bh_lock_sock(sk) bh_lock_sock(sk)
+#define sctp_bh_unlock_sock(sk) bh_unlock_sock(sk)
+#define __sctp_sock_busy(sk) ((sk)->lock.users)
+#define SCTP_SOCK_SLEEP_PRE(sk) SOCK_SLEEP_PRE(sk)
+#define SCTP_SOCK_SLEEP_POST(sk) SOCK_SLEEP_POST(sk)
+
+
+/* Determine if this is a valid kernel address. */
+static inline int sctp_is_valid_kaddr(unsigned long addr)
+{
+ struct page *page;
+
+ /* Make sure the address is not in the user address space. */
+ if (addr < PAGE_OFFSET)
+ return 0;
+
+ page = virt_to_page(addr);
+
+ /* Is this page valid? */
+ if (!virt_addr_valid(addr) || PageReserved(page))
+ return 0;
+
+ return 1;
+}
+
+#endif /* !TEST_FRAME */
+
+
+/* Print debugging messages. */
+#if SCTP_DEBUG
+extern int sctp_debug_flag;
+#define SCTP_DEBUG_PRINTK(whatever...) \
+ ((void) (sctp_debug_flag && printk(KERN_DEBUG whatever)))
+#define SCTP_ENABLE_DEBUG { sctp_debug_flag = 1; }
+#define SCTP_DISABLE_DEBUG { sctp_debug_flag = 0; }
+
+#define SCTP_ASSERT(expr, str, func) \
+ if (!(expr)) { \
+ SCTP_DEBUG_PRINTK("Assertion Failed: %s(%s) at %s:%s:%d\n", \
+ str, (#expr), __FILE__, __FUNCTION__, __LINE__); \
+ func; \
+ }
+
+#else /* SCTP_DEBUG */
+
+#define SCTP_DEBUG_PRINTK(whatever...)
+#define SCTP_ENABLE_DEBUG
+#define SCTP_DISABLE_DEBUG
+#define SCTP_ASSERT(expr, str, func)
+
+#endif /* SCTP_DEBUG */
+
+
+/*
+ * Macros for keeping a global reference of object allocations.
+ */
+#ifdef CONFIG_SCTP_DBG_OBJCNT
+
+extern atomic_t sctp_dbg_objcnt_sock;
+extern atomic_t sctp_dbg_objcnt_ep;
+extern atomic_t sctp_dbg_objcnt_assoc;
+extern atomic_t sctp_dbg_objcnt_transport;
+extern atomic_t sctp_dbg_objcnt_chunk;
+extern atomic_t sctp_dbg_objcnt_bind_addr;
+extern atomic_t sctp_dbg_objcnt_addr;
+
+/* Macros to atomically increment/decrement objcnt counters. */
+#define SCTP_DBG_OBJCNT_INC(name) \
+atomic_inc(&sctp_dbg_objcnt_## name)
+#define SCTP_DBG_OBJCNT_DEC(name) \
+atomic_dec(&sctp_dbg_objcnt_## name)
+#define SCTP_DBG_OBJCNT(name) \
+atomic_t sctp_dbg_objcnt_## name = ATOMIC_INIT(0)
+
+/* Macro to help create new entries in in the global array of
+ * objcnt counters.
+ */
+#define SCTP_DBG_OBJCNT_ENTRY(name) \
+{.label= #name, .counter= &sctp_dbg_objcnt_## name}
+
+extern void sctp_dbg_objcnt_init(void);
+extern void sctp_dbg_objcnt_exit(void);
+
+#else
+
+#define SCTP_DBG_OBJCNT_INC(name)
+#define SCTP_DBG_OBJCNT_DEC(name)
+
+static inline void sctp_dbg_objcnt_init(void) { return; }
+static inline void sctp_dbg_objcnt_exit(void) { return; }
+
+#endif /* CONFIG_SCTP_DBG_OBJCOUNT */
+
+#if defined CONFIG_SYSCTL
+extern void sctp_sysctl_register(void);
+extern void sctp_sysctl_unregister(void);
+#else
+static inline void sctp_sysctl_register(void) { return; }
+static inline void sctp_sysctl_unregister(void) { return; }
+#endif
+
+
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+
+extern int sctp_v6_init(void);
+extern void sctp_v6_exit(void);
+
+static inline int sctp_ipv6_addr_type(const struct in6_addr *addr)
+{
+ return ipv6_addr_type((struct in6_addr*) addr);
+}
+
+#define SCTP_SAT_LEN (sizeof(sctp_paramhdr_t) + 2 * sizeof(__u16))
+
+/* Note: These V6 macros are obsolescent. */
+/* Use this macro to enclose code fragments which are V6-dependent. */
+#define SCTP_V6(m...) m
+#define SCTP_V6_SUPPORT 1
+
+#else /* #ifdef defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */
+
+#define sctp_ipv6_addr_type(a) 0
+#define SCTP_SAT_LEN (sizeof(sctp_paramhdr_t) + 1 * sizeof(__u16))
+#define SCTP_V6(m...) /* Do nothing. */
+#undef SCTP_V6_SUPPORT
+
+static inline int sctp_v6_init(void) { return 0; }
+static inline void sctp_v6_exit(void) { return; }
+
+#endif /* #ifdef defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) */
+
+
+/* Map an association to an assoc_id. */
+static inline sctp_assoc_t sctp_assoc2id(const sctp_association_t *asoc)
+{
+ return (sctp_assoc_t) asoc;
+}
+
+/* Look up the association by its id. */
+static inline sctp_association_t *sctp_id2assoc(const struct sock *sk, sctp_assoc_t id)
+{
+ sctp_association_t *asoc = NULL;
+
+ /* First, verify that this is a kernel address. */
+ if (sctp_is_valid_kaddr((unsigned long) id)) {
+ sctp_association_t *temp = (sctp_association_t *) id;
+
+ /* Verify that this _is_ an sctp_association_t
+ * data structure and if so, that the socket matches.
+ */
+ if ((SCTP_ASSOC_EYECATCHER == temp->eyecatcher) &&
+ (temp->base.sk == sk))
+ asoc = temp;
+ }
+
+ return asoc;
+}
+
+/* A macro to walk a list of skbs. */
+#define sctp_skb_for_each(pos, head, tmp) \
+for (pos = (head)->next;\
+ tmp = (pos)->next, pos != ((struct sk_buff *)(head));\
+ pos = tmp)
+
+
+/* A helper to append an entire skb list (list) to another (head). */
+static inline void sctp_skb_list_tail(struct sk_buff_head *list,
+ struct sk_buff_head *head)
+{
+ int flags __attribute__ ((unused));
+
+ sctp_spin_lock_irqsave(&head->lock, flags);
+ sctp_spin_lock(&list->lock);
+
+ list_splice((struct list_head *)list, (struct list_head *)head->prev);
+
+ head->qlen += list->qlen;
+ list->qlen = 0;
+
+ sctp_spin_unlock(&list->lock);
+ sctp_spin_unlock_irqrestore(&head->lock, flags);
+}
+
+/**
+ * sctp_list_dequeue - remove from the head of the queue
+ * @list: list to dequeue from
+ *
+ * Remove the head of the list. The head item is
+ * returned or %NULL if the list is empty.
+ */
+
+static inline struct list_head *sctp_list_dequeue(struct list_head *list)
+{
+ struct list_head *result = NULL;
+
+ if (list->next != list) {
+ result = list->next;
+ list->next = result->next;
+ list->next->prev = list;
+ INIT_LIST_HEAD(result);
+ }
+ return result;
+}
+
+/* Calculate the size (in bytes) occupied by the data of an iovec. */
+static inline size_t get_user_iov_size(struct iovec *iov, int iovlen)
+{
+ size_t retval = 0;
+
+ for (; iovlen > 0; --iovlen) {
+ retval += iov->iov_len;
+ iov++;
+ }
+
+ return retval;
+}
+
+
+/* Round an int up to the next multiple of 4. */
+#define WORD_ROUND(s) (((s)+3)&~3)
+
+/* Make a new instance of type. */
+#define t_new(type, flags) (type *)kmalloc(sizeof(type), flags)
+
+/* Compare two timevals. */
+#define tv_lt(s, t) \
+ (s.tv_sec < t.tv_sec || (s.tv_sec == t.tv_sec && s.tv_usec < t.tv_usec))
+
+/* Stolen from net/profile.h. Using it from there is more grief than
+ * it is worth.
+ */
+static inline void tv_add(const struct timeval *entered, struct timeval *leaved)
+{
+ time_t usecs = leaved->tv_usec + entered->tv_usec;
+ time_t secs = leaved->tv_sec + entered->tv_sec;
+
+ if (usecs >= 1000000) {
+ usecs -= 1000000;
+ secs++;
+ }
+ leaved->tv_sec = secs;
+ leaved->tv_usec = usecs;
+}
+
+
+/* External references. */
+
+extern struct proto sctp_prot;
+extern struct proc_dir_entry *proc_net_sctp;
+extern void sctp_put_port(struct sock *sk);
+
+/* Static inline functions. */
+
+/* Return the SCTP protocol structure. */
+static inline sctp_protocol_t *sctp_get_protocol(void)
+{
+ return &sctp_proto;
+}
+
+/* Warning: The following hash functions assume a power of two 'size'. */
+/* This is the hash function for the SCTP port hash table. */
+static inline int sctp_phashfn(__u16 lport)
+{
+ sctp_protocol_t *sctp_proto = sctp_get_protocol();
+ return (lport & (sctp_proto->port_hashsize - 1));
+}
+
+/* This is the hash function for the endpoint hash table. */
+static inline int sctp_ep_hashfn(__u16 lport)
+{
+ sctp_protocol_t *sctp_proto = sctp_get_protocol();
+ return (lport & (sctp_proto->ep_hashsize - 1));
+}
+
+/* This is the hash function for the association hash table. */
+static inline int sctp_assoc_hashfn(__u16 lport, __u16 rport)
+{
+ sctp_protocol_t *sctp_proto = sctp_get_protocol();
+ int h = (lport << 16) + rport;
+ h ^= h>>8;
+ return (h & (sctp_proto->assoc_hashsize - 1));
+}
+
+/* This is the hash function for the association hash table. This is
+ * not used yet, but could be used as a better hash function when
+ * we have a vtag.
+ */
+static inline int sctp_vtag_hashfn(__u16 lport, __u16 rport, __u32 vtag)
+{
+ sctp_protocol_t *sctp_proto = sctp_get_protocol();
+ int h = (lport << 16) + rport;
+ h ^= vtag;
+ return (h & (sctp_proto->assoc_hashsize-1));
+}
+
+/* WARNING: Do not change the layout of the members in sctp_sock! */
+struct sctp_sock {
+ struct sock sk;
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+ struct ipv6_pinfo *pinet6;
+#endif /* CONFIG_IPV6 || CONFIG_IPV6_MODULE */
+ struct inet_opt inet;
+ struct sctp_opt sctp;
+};
+
+#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
+struct sctp6_sock {
+ struct sock sk;
+ struct ipv6_pinfo *pinet6;
+ struct inet_opt inet;
+ struct sctp_opt sctp;
+ struct ipv6_pinfo inet6;
+};
+#endif /* CONFIG_IPV6 || CONFIG_IPV6_MODULE */
+
+#define sctp_sk(__sk) (&((struct sctp_sock *)__sk)->sctp)
+
+#endif /* __net_sctp_h__ */
diff --git a/include/net/sctp/sctp_command.h b/include/net/sctp/sctp_command.h
new file mode 100644
index 000000000000..4fd50d56fefb
--- /dev/null
+++ b/include/net/sctp/sctp_command.h
@@ -0,0 +1,213 @@
+/* SCTP kernel reference Implementation Copyright (C) 1999-2001
+ * Cisco, Motorola, and IBM
+ *
+ * This file is part of the SCTP kernel reference Implementation
+ *
+ * $Header: /cvsroot/lksctp/lksctp/sctp_cvs/include/net/sctp/sctp_command.h,v 1.19 2002/08/16 19:30:49 jgrimm Exp $
+ *
+ * These are the definitions needed for the command object.
+ *
+ * The SCTP reference implementation is free software;
+ * you can redistribute it and/or modify it under the terms of
+ * the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * the SCTP reference implementation is distributed in the hope that it
+ * will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * ************************
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU CC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Please send any bug reports or fixes you make to one of the
+ * following email addresses:
+ *
+ * La Monte H.P. Yarroll <piggy@acm.org>
+ * Karl Knutson <karl@athena.chicago.il.us>
+ *
+ * Any bugs reported given to us we will try to fix... any fixes shared will
+ * be incorporated into the next SCTP release.
+ */
+
+
+#ifndef __net_sctp_command_h__
+#define __net_sctp_command_h__
+
+#include <net/sctp/sctp_constants.h>
+#include <net/sctp/sctp_structs.h>
+
+
+typedef enum {
+ SCTP_CMD_NOP = 0, /* Do nothing. */
+ SCTP_CMD_NEW_ASOC, /* Register a new association. */
+ SCTP_CMD_DELETE_TCB, /* Delete the current association. */
+ SCTP_CMD_NEW_STATE, /* Enter a new state. */
+ SCTP_CMD_REPORT_TSN, /* Record the arrival of a TSN. */
+ SCTP_CMD_GEN_SACK, /* Send a Selective ACK (maybe). */
+ SCTP_CMD_PROCESS_SACK, /* Process an inbound SACK. */
+ SCTP_CMD_GEN_INIT_ACK, /* Generate an INIT ACK chunk. */
+ SCTP_CMD_PEER_INIT, /* Process a INIT from the peer. */
+ SCTP_CMD_GEN_COOKIE_ECHO, /* Generate a COOKIE ECHO chunk. */
+ SCTP_CMD_CHUNK_ULP, /* Send a chunk to the sockets layer. */
+ SCTP_CMD_EVENT_ULP, /* Send a notification to the sockets layer. */
+ SCTP_CMD_REPLY, /* Send a chunk to our peer. */
+ SCTP_CMD_SEND_PKT, /* Send a full packet to our peer. */
+ SCTP_CMD_RETRAN, /* Mark a transport for retransmission. */
+ SCTP_CMD_ECN_CE, /* Do delayed CE processing. */
+ SCTP_CMD_ECN_ECNE, /* Do delayed ECNE processing. */
+ SCTP_CMD_ECN_CWR, /* Do delayed CWR processing. */
+ SCTP_CMD_TIMER_START, /* Start a timer. */
+ SCTP_CMD_TIMER_RESTART, /* Restart a timer. */
+ SCTP_CMD_TIMER_STOP, /* Stop a timer. */
+ SCTP_CMD_COUNTER_RESET, /* Reset a counter. */
+ SCTP_CMD_COUNTER_INC, /* Increment a counter. */
+ SCTP_CMD_INIT_RESTART, /* High level, do init timer work. */
+ SCTP_CMD_INIT_FAILED, /* High level, do init failure work. */
+ SCTP_CMD_REPORT_DUP, /* Report a duplicate TSN. */
+ SCTP_CMD_REPORT_BIGGAP, /* Narc on a TSN (it was too high). */
+ SCTP_CMD_SET_BIND_ADDR, /* Set the association bind_addr. */
+ SCTP_CMD_STRIKE, /* Mark a strike against a transport. */
+ SCTP_CMD_TRANSMIT, /* Transmit the outqueue. */
+ SCTP_CMD_HB_TIMERS_START, /* Start the heartbeat timers. */
+ SCTP_CMD_TRANSPORT_RESET, /* Reset the status of a transport. */
+ SCTP_CMD_TRANSPORT_ON, /* Mark the transport as active. */
+ SCTP_CMD_REPORT_ERROR, /* Pass this error back out of the sm. */
+ SCTP_CMD_REPORT_BAD_TAG, /* Verification tags didn't match. */
+ SCTP_CMD_PROCESS_CTSN, /* Sideeffect from shutdown. */
+ SCTP_CMD_ASSOC_FAILED, /* Handle association failure. */
+ SCTP_CMD_DISCARD_PACKET, /* Discard the whole packet. */
+ SCTP_CMD_GEN_SHUTDOWN, /* Generate a SHUTDOWN chunk. */
+ SCTP_CMD_UPDATE_ASSOC, /* Update association information. */
+ SCTP_CMD_PURGE_OUTQUEUE, /* Purge all data waiting to be sent. */
+ SCTP_CMD_SETUP_T2, /* Hi-level, setup T2-shutdown parms. */
+
+ SCTP_CMD_LAST
+} sctp_verb_t;
+
+#define SCTP_CMD_MAX (SCTP_CMD_LAST - 1)
+#define SCTP_CMD_NUM_VERBS (SCTP_CMD_MAX + 1)
+
+/* How many commands can you put in an sctp_cmd_seq_t?
+ * This is a rather arbitrary number, ideally derived from a careful
+ * analysis of the state functions, but in reality just taken from
+ * thin air in the hopes othat we don't trigger a kernel panic.
+ */
+#define SCTP_MAX_NUM_COMMANDS 14
+
+typedef union {
+ __s32 i32;
+ __u32 u32;
+ __u16 u16;
+ __u8 u8;
+ int error;
+ sctp_state_t state;
+ sctp_event_timeout_t to;
+ sctp_counter_t counter;
+ void *ptr;
+ sctp_chunk_t *chunk;
+ sctp_association_t *asoc;
+ sctp_transport_t *transport;
+ sctp_bind_addr_t *bp;
+ sctp_init_chunk_t *init;
+ sctp_ulpevent_t *ulpevent;
+ sctp_packet_t *packet;
+ sctp_sackhdr_t *sackh;
+} sctp_arg_t;
+
+/* We are simulating ML type constructors here.
+ *
+ * SCTP_ARG_CONSTRUCTOR(NAME, TYPE, ELT) builds a function called
+ * SCTP_NAME() which takes an argument of type TYPE and returns an
+ * sctp_arg_t. It does this by inserting the sole argument into the
+ * ELT union element of a local sctp_arg_t.
+ *
+ * E.g., SCTP_ARG_CONSTRUCTOR(I32, __s32, i32) builds SCTP_I32(arg),
+ * which takes an __s32 and returns a sctp_arg_t containing the
+ * __s32. So, after foo = SCTP_I32(arg), foo.i32 == arg.
+ */
+static inline sctp_arg_t SCTP_NULL(void)
+{
+ sctp_arg_t retval; retval.ptr = NULL; return retval;
+}
+static inline sctp_arg_t SCTP_NOFORCE(void)
+{
+ sctp_arg_t retval; retval.i32 = 0; return retval;
+}
+static inline sctp_arg_t SCTP_FORCE(void)
+{
+ sctp_arg_t retval; retval.i32 = 1; return retval;
+}
+
+#define SCTP_ARG_CONSTRUCTOR(name, type, elt) \
+static inline sctp_arg_t \
+SCTP_## name (type arg) \
+{ sctp_arg_t retval; retval.elt = arg; return retval; }
+
+SCTP_ARG_CONSTRUCTOR(I32, __s32, i32)
+SCTP_ARG_CONSTRUCTOR(U32, __u32, u32)
+SCTP_ARG_CONSTRUCTOR(U16, __u16, u16)
+SCTP_ARG_CONSTRUCTOR(U8, __u8, u8)
+SCTP_ARG_CONSTRUCTOR(ERROR, int, error)
+SCTP_ARG_CONSTRUCTOR(STATE, sctp_state_t, state)
+SCTP_ARG_CONSTRUCTOR(COUNTER, sctp_counter_t, counter)
+SCTP_ARG_CONSTRUCTOR(TO, sctp_event_timeout_t, to)
+SCTP_ARG_CONSTRUCTOR(PTR, void *, ptr)
+SCTP_ARG_CONSTRUCTOR(CHUNK, sctp_chunk_t *, chunk)
+SCTP_ARG_CONSTRUCTOR(ASOC, sctp_association_t *, asoc)
+SCTP_ARG_CONSTRUCTOR(TRANSPORT, sctp_transport_t *, transport)
+SCTP_ARG_CONSTRUCTOR(BA, sctp_bind_addr_t *, bp)
+SCTP_ARG_CONSTRUCTOR(PEER_INIT, sctp_init_chunk_t *, init)
+SCTP_ARG_CONSTRUCTOR(ULPEVENT, sctp_ulpevent_t *, ulpevent)
+SCTP_ARG_CONSTRUCTOR(PACKET, sctp_packet_t *, packet)
+SCTP_ARG_CONSTRUCTOR(SACKH, sctp_sackhdr_t *, sackh)
+
+typedef struct {
+ sctp_arg_t obj;
+ sctp_verb_t verb;
+} sctp_cmd_t;
+
+typedef struct {
+ sctp_cmd_t cmds[SCTP_MAX_NUM_COMMANDS];
+ __u8 next_free_slot;
+ __u8 next_cmd;
+} sctp_cmd_seq_t;
+
+
+/* Create a new sctp_command_sequence.
+ * Return NULL if creating a new sequence fails.
+ */
+sctp_cmd_seq_t *sctp_new_cmd_seq(int priority);
+
+/* Initialize a block of memory as a command sequence.
+ * Return 0 if the initialization fails.
+ */
+int sctp_init_cmd_seq(sctp_cmd_seq_t *seq);
+
+/* Add a command to an sctp_cmd_seq_t.
+ * Return 0 if the command sequence is full.
+ *
+ * Use the SCTP_* constructors defined by SCTP_ARG_CONSTRUCTOR() above
+ * to wrap data which goes in the obj argument.
+ */
+int sctp_add_cmd(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj);
+
+/* Rewind an sctp_cmd_seq_t to iterate from the start.
+ * Return 0 if the rewind fails.
+ */
+int sctp_rewind_sequence(sctp_cmd_seq_t *seq);
+
+/* Return the next command structure in an sctp_cmd_seq.
+ * Return NULL at the end of the sequence.
+ */
+sctp_cmd_t *sctp_next_cmd(sctp_cmd_seq_t *seq);
+
+/* Dispose of a command sequence. */
+void sctp_free_cmd_seq(sctp_cmd_seq_t *seq);
+
+#endif /* __net_sctp_command_h__ */
+
diff --git a/include/net/sctp/sctp_constants.h b/include/net/sctp/sctp_constants.h
new file mode 100644
index 000000000000..58e910dd87da
--- /dev/null
+++ b/include/net/sctp/sctp_constants.h
@@ -0,0 +1,453 @@
+/* SCTP kernel reference Implementation
+ * Copyright (c) 1999-2000 Cisco, Inc.
+ * Copyright (c) 1999-2001 Motorola, Inc.
+ * Copyright (c) 2001 Intel Corp.
+ * Copyright (c) 2001-2002 International Business Machines Corp.
+ *
+ * This file is part of the SCTP kernel reference Implementation
+ *
+ * This file is part of the implementation of the add-IP extension,
+ * based on <draft-ietf-tsvwg-addip-sctp-02.txt> June 29, 2001,
+ * for the SCTP kernel reference Implementation.
+ *
+ *
+ * $Header: /cvsroot/lksctp/lksctp/sctp_cvs/include/net/sctp/sctp_constants.h,v 1.11 2002/07/26 22:52:32 jgrimm Exp $
+ *
+ * The SCTP reference implementation is free software;
+ * you can redistribute it and/or modify it under the terms of
+ * the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * the SCTP reference implementation is distributed in the hope that it
+ * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
+ * ************************
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU CC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Please send any bug reports or fixes you make to one of the following email
+ * addresses:
+ *
+ * La Monte H.P. Yarroll <piggy@acm.org>
+ * Karl Knutson <karl@athena.chicago.il.us>
+ * Randall Stewart <randall@stewart.chicago.il.us>
+ * Ken Morneau <kmorneau@cisco.com>
+ * Qiaobing Xie <qxie1@motorola.com>
+ * Xingang Guo <xingang.guo@intel.com>
+ * Sridhar Samudrala <samudrala@us.ibm.com>
+ * Daisy Chang <daisyc@us.ibm.com>
+ *
+ * Any bugs reported given to us we will try to fix... any fixes shared will
+ * be incorporated into the next SCTP release.
+ *
+ * There are still LOTS of bugs in this code... I always run on the motto
+ * "it is a wonder any code ever works :)"
+ *
+ *
+ */
+
+#ifndef __sctp_constants_h__
+#define __sctp_constants_h__
+
+#include <linux/tcp.h> /* For TCP states used in sctp_sock_state_t */
+#include <linux/sctp.h>
+#include <linux/ipv6.h> /* For ipv6hdr. */
+#include <net/sctp/sctp_user.h>
+
+/* What a hack! Jiminy Cricket! */
+enum { SCTP_MAX_STREAM = 10 };
+
+/* Define the amount of space to reserve for SCTP, IP, LL.
+ * There is a little bit of waste that we are always allocating
+ * for ipv6 headers, but this seems worth the simplicity.
+ */
+
+#define SCTP_IP_OVERHEAD ((sizeof(struct sctphdr)\
+ + sizeof(struct ipv6hdr)\
+ + MAX_HEADER))
+
+/* Define the amount of space to reserve for SCTP, IP, LL.
+ * There is a little bit of waste that we are always allocating
+ * for ipv6 headers, but this seems worth the simplicity.
+ */
+
+#define SCTP_IP_OVERHEAD ((sizeof(struct sctphdr)\
+ + sizeof(struct ipv6hdr)\
+ + MAX_HEADER))
+
+/* Since CIDs are sparse, we need all four of the following
+ * symbols. CIDs are dense through SCTP_CID_BASE_MAX.
+ */
+#define SCTP_CID_BASE_MAX SCTP_CID_SHUTDOWN_COMPLETE
+#define SCTP_CID_MAX SCTP_CID_ASCONF_ACK
+
+#define SCTP_NUM_BASE_CHUNK_TYPES (SCTP_CID_BASE_MAX + 1)
+#define SCTP_NUM_CHUNK_TYPES (SCTP_NUM_BASE_CHUNKTYPES + 2)
+
+
+/* These are the different flavours of event. */
+typedef enum {
+
+ SCTP_EVENT_T_CHUNK = 1,
+ SCTP_EVENT_T_TIMEOUT,
+ SCTP_EVENT_T_OTHER,
+ SCTP_EVENT_T_PRIMITIVE
+
+} sctp_event_t;
+
+#define SCTP_EVENT_T_MAX SCTP_EVENT_T_PRIMITIVE
+#define SCTP_EVENT_T_NUM (SCTP_EVENT_T_MAX + 1)
+
+/* As a convenience for the state machine, we append SCTP_EVENT_* and
+ * SCTP_ULP_* to the list of possible chunks.
+ */
+
+typedef enum {
+
+ SCTP_EVENT_TIMEOUT_NONE = 0,
+ SCTP_EVENT_TIMEOUT_T1_COOKIE,
+ SCTP_EVENT_TIMEOUT_T1_INIT,
+ SCTP_EVENT_TIMEOUT_T2_SHUTDOWN,
+ SCTP_EVENT_TIMEOUT_T3_RTX,
+ SCTP_EVENT_TIMEOUT_T4_RTO,
+ SCTP_EVENT_TIMEOUT_HEARTBEAT,
+ SCTP_EVENT_TIMEOUT_SACK,
+ SCTP_EVENT_TIMEOUT_AUTOCLOSE,
+ SCTP_EVENT_TIMEOUT_PMTU_RAISE,
+
+} sctp_event_timeout_t;
+
+#define SCTP_EVENT_TIMEOUT_MAX SCTP_EVENT_TIMEOUT_PMTU_RAISE
+#define SCTP_NUM_TIMEOUT_TYPES (SCTP_EVENT_TIMEOUT_MAX + 1)
+
+typedef enum {
+
+ SCTP_EVENT_NO_PENDING_TSN = 0,
+ SCTP_EVENT_ICMP_UNREACHFRAG,
+
+} sctp_event_other_t;
+
+#define SCTP_EVENT_OTHER_MAX SCTP_EVENT_ICMP_UNREACHFRAG
+#define SCTP_NUM_OTHER_TYPES (SCTP_EVENT_OTHER_MAX + 1)
+
+/* These are primitive requests from the ULP. */
+typedef enum {
+
+ SCTP_PRIMITIVE_INITIALIZE = 0,
+ SCTP_PRIMITIVE_ASSOCIATE,
+ SCTP_PRIMITIVE_SHUTDOWN,
+ SCTP_PRIMITIVE_ABORT,
+ SCTP_PRIMITIVE_SEND,
+ SCTP_PRIMITIVE_SETPRIMARY,
+ SCTP_PRIMITIVE_RECEIVE,
+ SCTP_PRIMITIVE_STATUS,
+ SCTP_PRIMITIVE_CHANGEHEARTBEAT,
+ SCTP_PRIMITIVE_REQUESTHEARTBEAT,
+ SCTP_PRIMITIVE_GETSRTTREPORT,
+ SCTP_PRIMITIVE_SETFAILURETHRESHOLD,
+ SCTP_PRIMITIVE_SETPROTOPARAMETERS,
+ SCTP_PRIMITIVE_RECEIVE_UNSENT,
+ SCTP_PRIMITIVE_RECEIVE_UNACKED,
+ SCTP_PRIMITIVE_DESTROY,
+
+} sctp_event_primitive_t;
+
+#define SCTP_EVENT_PRIMITIVE_MAX SCTP_PRIMITIVE_DESTROY
+#define SCTP_NUM_PRIMITIVE_TYPES (SCTP_EVENT_PRIMITIVE_MAX + 1)
+
+/* We define here a utility type for manipulating subtypes.
+ * The subtype constructors all work like this:
+ *
+ * sctp_subtype_t foo = SCTP_ST_CHUNK(SCTP_CID_INIT);
+ */
+
+typedef union {
+
+ sctp_cid_t chunk;
+ sctp_event_timeout_t timeout;
+ sctp_event_other_t other;
+ sctp_event_primitive_t primitive;
+
+} sctp_subtype_t;
+
+#define SCTP_SUBTYPE_CONSTRUCTOR(_name, _type, _elt) \
+static inline sctp_subtype_t \
+SCTP_ST_## _name (_type _arg) \
+{ sctp_subtype_t _retval; _retval._elt = _arg; return _retval; }
+
+SCTP_SUBTYPE_CONSTRUCTOR(CHUNK, sctp_cid_t, chunk)
+SCTP_SUBTYPE_CONSTRUCTOR(TIMEOUT, sctp_event_timeout_t, timeout)
+SCTP_SUBTYPE_CONSTRUCTOR(OTHER, sctp_event_other_t, other)
+SCTP_SUBTYPE_CONSTRUCTOR(PRIMITIVE, sctp_event_primitive_t, primitive)
+
+
+#define sctp_chunk_is_control(a) (a->chunk_hdr->type != SCTP_CID_DATA)
+#define sctp_chunk_is_data(a) (a->chunk_hdr->type == SCTP_CID_DATA)
+
+/* Calculate the actual data size in a data chunk */
+#define SCTP_DATA_SNDSIZE(c) ((int)((unsigned long)(c->chunk_end)\
+ - (unsigned long)(c->chunk_hdr)\
+ - sizeof(sctp_data_chunk_t)))
+
+/* This is a table of printable names of sctp_param_t's. */
+extern const char *sctp_param_tbl[];
+
+
+#define SCTP_MAX_ERROR_CAUSE SCTP_ERROR_NONEXIST_IP
+#define SCTP_NUM_ERROR_CAUSE 10
+
+/* Internal error codes */
+typedef enum {
+
+ SCTP_IERROR_NO_ERROR = 0,
+ SCTP_IERROR_BASE = 1000,
+ SCTP_IERROR_NO_COOKIE,
+ SCTP_IERROR_BAD_SIG,
+ SCTP_IERROR_STALE_COOKIE,
+ SCTP_IERROR_NOMEM,
+ SCTP_IERROR_MALFORMED,
+ SCTP_IERROR_BAD_TAG,
+ SCTP_IERROR_BIG_GAP,
+ SCTP_IERROR_DUP_TSN,
+
+} sctp_ierror_t;
+
+
+
+/* SCTP state defines for internal state machine */
+typedef enum {
+
+ SCTP_STATE_EMPTY = 0,
+ SCTP_STATE_CLOSED = 1,
+ SCTP_STATE_COOKIE_WAIT = 2,
+ SCTP_STATE_COOKIE_ECHOED = 3,
+ SCTP_STATE_ESTABLISHED = 4,
+ SCTP_STATE_SHUTDOWN_PENDING = 5,
+ SCTP_STATE_SHUTDOWN_SENT = 6,
+ SCTP_STATE_SHUTDOWN_RECEIVED = 7,
+ SCTP_STATE_SHUTDOWN_ACK_SENT = 8,
+
+} sctp_state_t;
+
+#define SCTP_STATE_MAX SCTP_STATE_SHUTDOWN_ACK_SENT
+#define SCTP_STATE_NUM_STATES (SCTP_STATE_MAX + 1)
+
+/* These are values for sk->state.
+ * For a UDP-style SCTP socket, the states are defined as follows
+ * (at this point of time, may change later after more discussions: FIXME)
+ * A socket in SCTP_SS_UNCONNECTED state indicates that it is not willing
+ * to accept new associations, but it can initiate the creation of new
+ * ones.
+ * A socket in SCTP_SS_LISTENING state indicates that it is willing to
+ * accept new associations and can initiate the creation of new ones.
+ * A socket in SCTP_SS_ESTABLISHED state indicates that it is a peeled off
+ * socket with one association.
+ */
+typedef enum {
+ SCTP_SS_CLOSED = TCP_CLOSE,
+ SCTP_SS_LISTENING = TCP_LISTEN,
+ SCTP_SS_ESTABLISHING = TCP_SYN_SENT,
+ SCTP_SS_ESTABLISHED = TCP_ESTABLISHED,
+ SCTP_SS_DISCONNECTING = TCP_CLOSING,
+} sctp_sock_state_t;
+
+/* These functions map various type to printable names. */
+const char *sctp_cname(const sctp_subtype_t); /* chunk types */
+const char *sctp_oname(const sctp_subtype_t); /* other events */
+const char *sctp_tname(const sctp_subtype_t); /* timeouts */
+const char *sctp_pname(const sctp_subtype_t); /* primitives */
+
+/* This is a table of printable names of sctp_state_t's. */
+extern const char *sctp_state_tbl[], *sctp_evttype_tbl[], *sctp_status_tbl[];
+
+/* SCTP reachability state for each address */
+#define SCTP_ADDR_NOHB 4
+#define SCTP_ADDR_REACHABLE 2
+#define SCTP_ADDR_NOT_REACHABLE 1
+
+
+
+
+/* Guess at how big to make the TSN mapping array.
+ * We guarantee that we can handle at least this big a gap between the
+ * cumulative ACK and the highest TSN. In practice, we can often
+ * handle up to twice this value.
+ *
+ * NEVER make this more than 32767 (2^15-1). The Gap Ack Blocks in a
+ * SACK (see section 3.3.4) are only 16 bits, so 2*SCTP_TSN_MAP_SIZE
+ * must be less than 65535 (2^16 - 1), or we will have overflow
+ * problems creating SACK's.
+ */
+#define SCTP_TSN_MAP_SIZE 2048
+#define SCTP_TSN_MAX_GAP 65535
+
+/* We will not record more than this many duplicate TSNs between two
+ * SACKs. The minimum PMTU is 576. Remove all the headers and there
+ * is enough room for 131 duplicate reports. Round down to the
+ * nearest power of 2.
+ */
+#define SCTP_MAX_DUP_TSNS 128
+
+typedef enum {
+ SCTP_COUNTER_INIT_ERROR,
+} sctp_counter_t;
+
+/* How many counters does an association need? */
+#define SCTP_NUMBER_COUNTERS 5
+
+
+/* Here we define the default timers. */
+
+/* cookie timer def = ? seconds */
+#define SCTP_DEFAULT_TIMEOUT_T1_COOKIE (3 * HZ)
+
+/* init timer def = 3 seconds */
+#define SCTP_DEFAULT_TIMEOUT_T1_INIT (3 * HZ)
+
+/* shutdown timer def = 300 ms */
+#define SCTP_DEFAULT_TIMEOUT_T2_SHUTDOWN ((300 * HZ) / 1000)
+
+/* 0 seconds + RTO */
+#define SCTP_DEFAULT_TIMEOUT_HEARTBEAT (10 * HZ)
+
+/* recv timer def = 200ms (in usec) */
+#define SCTP_DEFAULT_TIMEOUT_SACK ((200 * HZ) / 1000)
+#define SCTP_DEFAULT_TIMEOUT_SACK_MAX ((500 * HZ) / 1000) /* 500 ms */
+
+/* How long do we wait before attempting to raise the PMTU? */
+#define SCTP_DEFAULT_TIMEOUT_PMTU_RAISE (10 * 60 * HZ) /* 10 Minutes */
+#define SCTP_DEFAULT_TIMEOUT_PMTU_RAISE_MIN (10 * 60 * HZ) /* 10 Minutes */
+
+/* RTO.Initial - 3 seconds
+ * RTO.Min - 1 second
+ * RTO.Max - 60 seconds
+ * RTO.Alpha - 1/8
+ * RTO.Beta - 1/4
+ */
+#define SCTP_RTO_INITIAL (3 * HZ)
+#define SCTP_RTO_MIN (1 * HZ)
+#define SCTP_RTO_MAX (60 * HZ)
+
+#define SCTP_RTO_ALPHA 3 /* 1/8 when converted to right shifts. */
+#define SCTP_RTO_BETA 2 /* 1/4 when converted to right shifts. */
+
+/* Maximum number of new data packets that can be sent in a burst. */
+#define SCTP_MAX_BURST 4
+
+#define SCTP_CLOCK_GRANULARITY 1 /* 1 jiffy */
+
+#define SCTP_DEF_MAX_INIT 6
+#define SCTP_DEF_MAX_SEND 10
+
+#define SCTP_DEFAULT_COOKIE_LIFE_SEC 60 /* seconds */
+#define SCTP_DEFAULT_COOKIE_LIFE_USEC 0 /* microseconds */
+
+#define SCTP_DEFAULT_MINWINDOW 1500 /* default minimum rwnd size */
+#define SCTP_DEFAULT_MAXWINDOW 32768 /* default rwnd size */
+#define SCTP_DEFAULT_MAXSEGMENT 1500 /* MTU size, this is the limit
+ * to which we will raise the P-MTU.
+ */
+#define SCTP_DEFAULT_MINSEGMENT 512 /* MTU size ... if no mtu disc */
+#define SCTP_HOW_MANY_SECRETS 2 /* How many secrets I keep */
+#define SCTP_HOW_LONG_COOKIE_LIVE 3600 /* How many seconds the current
+ * secret will live?
+ */
+#define SCTP_SECRET_SIZE 32 /* Number of octets in a 256 bits. */
+
+#define SCTP_SIGNATURE_SIZE 20 /* size of a SLA-1 signature */
+
+#define SCTP_COOKIE_MULTIPLE 64 /* Pad out our cookie to make our hash
+ * functions simpler to write.
+ */
+
+/* These return values describe the success or failure of a number of
+ * routines which form the lower interface to SCTP_outqueue.
+ */
+typedef enum {
+ SCTP_XMIT_OK,
+ SCTP_XMIT_PMTU_FULL,
+ SCTP_XMIT_RWND_FULL,
+ SCTP_XMIT_MUST_FRAG,
+} sctp_xmit_t;
+
+/* These are the commands for manipulating transports. */
+typedef enum {
+ SCTP_TRANSPORT_UP,
+ SCTP_TRANSPORT_DOWN,
+} sctp_transport_cmd_t;
+
+/* These are the address scopes defined mainly for IPv4 addresses
+ * based on draft of SCTP IPv4 scoping <draft-stewart-tsvwg-sctp-ipv4-00.txt>.
+ * These scopes are hopefully generic enough to be used on scoping both
+ * IPv4 and IPv6 addresses in SCTP.
+ * At this point, the IPv6 scopes will be mapped to these internal scopes
+ * as much as possible.
+ */
+typedef enum {
+ SCTP_SCOPE_GLOBAL, /* IPv4 global addresses */
+ SCTP_SCOPE_PRIVATE, /* IPv4 private addresses */
+ SCTP_SCOPE_LINK, /* IPv4 link local address */
+ SCTP_SCOPE_LOOPBACK, /* IPv4 loopback address */
+ SCTP_SCOPE_UNUSABLE, /* IPv4 unusable addresses */
+} sctp_scope_t;
+
+/* Based on IPv4 scoping <draft-stewart-tsvwg-sctp-ipv4-00.txt>,
+ * SCTP IPv4 unusable addresses: 0.0.0.0/8, 224.0.0.0/4, 198.18.0.0/24,
+ * 192.88.99.0/24.
+ * Also, RFC 8.4, non-unicast addresses are not considered valid SCTP
+ * addresses.
+ */
+#define IS_IPV4_UNUSABLE_ADDRESS(a) \
+ ((INADDR_BROADCAST == *a) || \
+ (MULTICAST(*a)) || \
+ (((unsigned char *)(a))[0] == 0) || \
+ ((((unsigned char *)(a))[0] == 198) && \
+ (((unsigned char *)(a))[1] == 18) && \
+ (((unsigned char *)(a))[2] == 0)) || \
+ ((((unsigned char *)(a))[0] == 192) && \
+ (((unsigned char *)(a))[1] == 88) && \
+ (((unsigned char *)(a))[2] == 99)))
+
+/* IPv4 Link-local addresses: 169.254.0.0/16. */
+#define IS_IPV4_LINK_ADDRESS(a) \
+ ((((unsigned char *)(a))[0] == 169) && \
+ (((unsigned char *)(a))[1] == 254))
+
+/* RFC 1918 "Address Allocation for Private Internets" defines the IPv4
+ * private address space as the following:
+ *
+ * 10.0.0.0 - 10.255.255.255 (10/8 prefix)
+ * 172.16.0.0.0 - 172.31.255.255 (172.16/12 prefix)
+ * 192.168.0.0 - 192.168.255.255 (192.168/16 prefix)
+ */
+#define IS_IPV4_PRIVATE_ADDRESS(a) \
+ ((((unsigned char *)(a))[0] == 10) || \
+ ((((unsigned char *)(a))[0] == 172) && \
+ (((unsigned char *)(a))[1] >= 16) && \
+ (((unsigned char *)(a))[1] < 32)) || \
+ ((((unsigned char *)(a))[0] == 192) && \
+ (((unsigned char *)(a))[1] == 168)))
+
+/* Flags used for the bind address copy functions. */
+#define SCTP_ADDR6_ALLOWED 0x00000001 /* IPv6 address is allowed by
+ local sock family */
+#define SCTP_ADDR4_PEERSUPP 0x00000002 /* IPv4 address is supported by
+ peer */
+#define SCTP_ADDR6_PEERSUPP 0x00000004 /* IPv6 address is supported by
+ peer */
+
+/* Reasons to lower cwnd. */
+typedef enum {
+ SCTP_LOWER_CWND_T3_RTX,
+ SCTP_LOWER_CWND_FAST_RTX,
+ SCTP_LOWER_CWND_ECNE,
+ SCTP_LOWER_CWND_INACTIVE,
+} sctp_lower_cwnd_t;
+
+#endif /* __sctp_constants_h__ */
+
diff --git a/include/net/sctp/sctp_sla1.h b/include/net/sctp/sctp_sla1.h
new file mode 100644
index 000000000000..9e88f6748334
--- /dev/null
+++ b/include/net/sctp/sctp_sla1.h
@@ -0,0 +1,80 @@
+/* SCTP reference Implementation
+ * Copyright (C) 1999 Cisco, Inc.
+ * Copyright (C) 1999 Motorola, Inc.
+ *
+ * This file originates from Randy Stewart's SCTP reference Implementation.
+ *
+ * The SCTP reference implementation is distributed in the hope that it
+ * will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * ************************
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU CC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Please send any bug reports or fixes you make to the
+ * email address(es):
+ * lksctp developers <lksctp-developers@lists.sourceforge.net>
+ *
+ * Or submit a bug report through the following website:
+ * http://www.sf.net/projects/lksctp
+ *
+ * Written or modified by:
+ * Randy Stewart <rstewar1@email.mot.com>
+ * Ken Morneau <kmorneau@cisco.com>
+ * Qiaobing Xie <qxie1@email.mot.com>
+ */
+
+#ifndef __SLA1_h__
+#define __SLA1_h__
+
+struct SLA_1_Context {
+ unsigned int A;
+ unsigned int B;
+ unsigned int C;
+ unsigned int D;
+ unsigned int E;
+ unsigned int H0;
+ unsigned int H1;
+ unsigned int H2;
+ unsigned int H3;
+ unsigned int H4;
+ unsigned int words[80];
+ unsigned int TEMP;
+
+ /* block I am collecting to process */
+ char SLAblock[64];
+
+ /* collected so far */
+ int howManyInBlock;
+ unsigned int runningTotal;
+};
+
+
+#define F1(B,C,D) (((B & C) | ((~B) & D))) /* 0 <= t <= 19 */
+#define F2(B,C,D) (B ^ C ^ D) /* 20 <= t <= 39 */
+#define F3(B,C,D) ((B & C) | (B & D) | (C & D)) /* 40 <= t <= 59 */
+#define F4(B,C,D) (B ^ C ^ D) /*600 <= t <= 79 */
+/* circular shift */
+
+#define CSHIFT(A,B) ((B << A) | (B >> (32-A)))
+
+#define K1 0x5a827999 /* 0 <= t <= 19 */
+#define K2 0x6ed9eba1 /* 20 <= t <= 39 */
+#define K3 0x8f1bbcdc /* 40 <= t <= 59 */
+#define K4 0xca62c1d6 /* 60 <= t <= 79 */
+
+#define H0INIT 0x67452301
+#define H1INIT 0xefcdab89
+#define H2INIT 0x98badcfe
+#define H3INIT 0x10325476
+#define H4INIT 0xc3d2e1f0
+
+extern void SLA1_Init(struct SLA_1_Context *);
+extern void SLA1_Process(struct SLA_1_Context *, const unsigned char *, int);
+extern void SLA1_Final(struct SLA_1_Context *, unsigned char *);
+
+#endif
diff --git a/include/net/sctp/sctp_sm.h b/include/net/sctp/sctp_sm.h
new file mode 100644
index 000000000000..2d1ac5826c89
--- /dev/null
+++ b/include/net/sctp/sctp_sm.h
@@ -0,0 +1,420 @@
+/* SCTP kernel reference Implementation
+ * Copyright (c) 1999-2000 Cisco, Inc.
+ * Copyright (c) 1999-2001 Motorola, Inc.
+ * Copyright (c) 2001 Intel Corp.
+ * Copyright (c) 2001-2002 International Business Machines Corp.
+ *
+ * This file is part of the SCTP kernel reference Implementation
+ *
+ * This file is part of the implementation of the add-IP extension,
+ * based on <draft-ietf-tsvwg-addip-sctp-02.txt> June 29, 2001,
+ * for the SCTP kernel reference Implementation.
+ *
+ * $Header: /cvsroot/lksctp/lksctp/sctp_cvs/include/net/sctp/sctp_sm.h,v 1.34 2002/08/21 18:34:04 jgrimm Exp $
+ *
+ * These are definitions needed by the state machine.
+ *
+ * The SCTP reference implementation is free software;
+ * you can redistribute it and/or modify it under the terms of
+ * the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * The SCTP reference implementation is distributed in the hope that it
+ * will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * ************************
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU CC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Please send any bug reports or fixes you make to the
+ * email addresses:
+ * lksctp developers <lksctp-developers@lists.sourceforge.net>
+ *
+ * Or submit a bug report through the following website:
+ * http://www.sf.net/projects/lksctp
+ *
+ * Written or modified by:
+ * La Monte H.P. Yarroll <piggy@acm.org>
+ * Karl Knutson <karl@athena.chicago.il.us>
+ * Xingang Guo <xingang.guo@intel.com>
+ * Jon Grimm <jgrimm@us.ibm.com>
+ * Dajiang Zhang <dajiang.zhang@nokia.com>
+ * Sridhar Samudrala <sri@us.ibm.com>
+ * Daisy Chang <daisyc@us.ibm.com>
+ *
+ * Any bugs reported given to us we will try to fix... any fixes shared will
+ * be incorporated into the next SCTP release.
+ */
+
+
+#include <linux/types.h>
+#include <linux/compiler.h>
+#include <linux/sched.h>
+#include <linux/slab.h>
+#include <linux/in.h>
+#include <net/sctp/sctp_command.h>
+#include <net/sctp/sctp.h>
+
+#ifndef __sctp_sm_h__
+#define __sctp_sm_h__
+
+/*
+ * Possible values for the disposition are:
+ */
+typedef enum {
+ SCTP_DISPOSITION_DISCARD, /* No further processing. */
+ SCTP_DISPOSITION_CONSUME, /* Process return values normally. */
+ SCTP_DISPOSITION_NOMEM, /* We ran out of memory--recover. */
+ SCTP_DISPOSITION_DELETE_TCB, /* Close the association. */
+ SCTP_DISPOSITION_ABORT, /* Close the association NOW. */
+ SCTP_DISPOSITION_VIOLATION, /* The peer is misbehaving. */
+ SCTP_DISPOSITION_NOT_IMPL, /* This entry is not implemented. */
+ SCTP_DISPOSITION_ERROR, /* This is plain old user error. */
+ SCTP_DISPOSITION_BUG, /* This is a bug. */
+} sctp_disposition_t;
+
+typedef struct {
+ int name;
+ int action;
+} sctp_sm_command_t;
+
+typedef sctp_disposition_t (sctp_state_fn_t) (const sctp_endpoint_t *,
+ const sctp_association_t *,
+ const sctp_subtype_t type,
+ void *arg,
+ sctp_cmd_seq_t *);
+typedef void (sctp_timer_event_t) (unsigned long);
+typedef struct {
+ sctp_state_fn_t *fn;
+ char *name;
+} sctp_sm_table_entry_t;
+
+/* A naming convention of "sctp_sf_xxx" applies to all the state functions
+ * currently in use.
+ */
+
+/* Prototypes for generic state functions. */
+sctp_state_fn_t sctp_sf_not_impl;
+sctp_state_fn_t sctp_sf_bug;
+
+/* Prototypes for gener timer state functions. */
+sctp_state_fn_t sctp_sf_timer_ignore;
+
+/* Prototypes for chunk state functions. */
+sctp_state_fn_t sctp_sf_do_9_1_abort;
+sctp_state_fn_t sctp_sf_cookie_wait_abort;
+sctp_state_fn_t sctp_sf_cookie_echoed_abort;
+sctp_state_fn_t sctp_sf_do_5_1B_init;
+sctp_state_fn_t sctp_sf_do_5_1C_ack;
+sctp_state_fn_t sctp_sf_do_5_1D_ce;
+sctp_state_fn_t sctp_sf_do_5_1E_ca;
+sctp_state_fn_t sctp_sf_do_4_C;
+sctp_state_fn_t sctp_sf_eat_data_6_2;
+sctp_state_fn_t sctp_sf_eat_data_fast_4_4;
+sctp_state_fn_t sctp_sf_eat_sack_6_2;
+sctp_state_fn_t sctp_sf_tabort_8_4_8;
+sctp_state_fn_t sctp_sf_operr_notify;
+sctp_state_fn_t sctp_sf_t1_timer_expire;
+sctp_state_fn_t sctp_sf_t2_timer_expire;
+sctp_state_fn_t sctp_sf_sendbeat_8_3;
+sctp_state_fn_t sctp_sf_beat_8_3;
+sctp_state_fn_t sctp_sf_backbeat_8_3;
+sctp_state_fn_t sctp_sf_do_9_2_final;
+sctp_state_fn_t sctp_sf_do_9_2_shutdown;
+sctp_state_fn_t sctp_sf_do_ecn_cwr;
+sctp_state_fn_t sctp_sf_do_ecne;
+sctp_state_fn_t sctp_sf_ootb;
+sctp_state_fn_t sctp_sf_shut_8_4_5;
+sctp_state_fn_t sctp_sf_pdiscard;
+sctp_state_fn_t sctp_sf_violation;
+sctp_state_fn_t sctp_sf_discard_chunk;
+sctp_state_fn_t sctp_sf_do_5_2_1_siminit;
+sctp_state_fn_t sctp_sf_do_5_2_2_dupinit;
+sctp_state_fn_t sctp_sf_do_5_2_4_dupcook;
+
+/* Prototypes for primitive event state functions. */
+sctp_state_fn_t sctp_sf_do_prm_asoc;
+sctp_state_fn_t sctp_sf_do_prm_send;
+sctp_state_fn_t sctp_sf_do_9_2_prm_shutdown;
+sctp_state_fn_t sctp_sf_cookie_wait_prm_shutdown;
+sctp_state_fn_t sctp_sf_cookie_echoed_prm_shutdown;
+sctp_state_fn_t sctp_sf_do_9_1_prm_abort;
+sctp_state_fn_t sctp_sf_cookie_wait_prm_abort;
+sctp_state_fn_t sctp_sf_cookie_echoed_prm_abort;
+sctp_state_fn_t sctp_sf_error_closed;
+sctp_state_fn_t sctp_sf_error_shutdown;
+sctp_state_fn_t sctp_sf_ignore_primitive;
+
+/* Prototypes for other event state functions. */
+sctp_state_fn_t sctp_sf_do_9_2_start_shutdown;
+sctp_state_fn_t sctp_sf_do_9_2_shutdown_ack;
+sctp_state_fn_t sctp_sf_ignore_other;
+
+/* Prototypes for timeout event state functions. */
+sctp_state_fn_t sctp_sf_do_6_3_3_rtx;
+sctp_state_fn_t sctp_sf_do_6_2_sack;
+sctp_state_fn_t sctp_sf_autoclose_timer_expire;
+
+
+/* These are state functions which are either obsolete or not in use yet.
+ * If any of these functions needs to be revived, it should be renamed with
+ * the "sctp_sf_xxx" prefix, and be moved to the above prototype groups.
+ */
+
+/* Prototypes for chunk state functions. Not in use. */
+sctp_state_fn_t sctp_sf_do_5_2_6_stale;
+sctp_state_fn_t sctp_sf_do_9_2_reshutack;
+sctp_state_fn_t sctp_sf_do_9_2_reshut;
+sctp_state_fn_t sctp_sf_do_9_2_shutack;
+
+sctp_state_fn_t lucky;
+sctp_state_fn_t other_stupid;
+
+/* Prototypes for timeout event state functions. Not in use. */
+sctp_state_fn_t sctp_do_4_2_reinit;
+sctp_state_fn_t sctp_do_4_3_reecho;
+sctp_state_fn_t sctp_do_9_2_reshut;
+sctp_state_fn_t sctp_do_9_2_reshutack;
+sctp_state_fn_t sctp_do_8_3_hb_err;
+sctp_state_fn_t sctp_heartoff;
+
+/* Prototypes for addip related state functions. Not in use. */
+sctp_state_fn_t sctp_addip_do_asconf;
+sctp_state_fn_t sctp_addip_do_asconf_ack;
+
+/* Prototypes for utility support functions. */
+__u8 sctp_get_chunk_type(sctp_chunk_t *chunk);
+sctp_sm_table_entry_t *sctp_sm_lookup_event(sctp_event_t event_type,
+ sctp_state_t state,
+ sctp_subtype_t event_subtype);
+
+time_t timeval_sub(struct timeval *, struct timeval *);
+sctp_association_t *sctp_make_temp_asoc(const sctp_endpoint_t *,
+ sctp_chunk_t *,
+ const int priority);
+__u32 sctp_generate_verification_tag(void);
+sctpParam_t sctp_get_my_addrs_raw(const sctp_association_t *,
+ const int priority, int *addrs_len);
+
+void sctp_populate_tie_tags(__u8 *cookie, __u32 curTag, __u32 hisTag);
+
+/* Prototypes for chunk-building functions. */
+sctp_chunk_t *sctp_make_init(const sctp_association_t *,
+ const sctp_bind_addr_t *,
+ int priority);
+sctp_chunk_t *sctp_make_init_ack(const sctp_association_t *,
+ const sctp_chunk_t *,
+ const int priority);
+sctp_chunk_t *sctp_make_cookie_echo(const sctp_association_t *,
+ const sctp_chunk_t *);
+sctp_chunk_t *sctp_make_cookie_ack(const sctp_association_t *,
+ const sctp_chunk_t *);
+sctp_chunk_t *sctp_make_cwr(const sctp_association_t *,
+ const __u32 lowest_tsn,
+ const sctp_chunk_t *);
+sctp_chunk_t *sctp_make_datafrag(sctp_association_t *,
+ const struct sctp_sndrcvinfo *sinfo,
+ int len, const __u8 *data,
+ __u8 flags, __u16 ssn);
+sctp_chunk_t * sctp_make_datafrag_empty(sctp_association_t *,
+ const struct sctp_sndrcvinfo *sinfo,
+ int len, const __u8 flags,
+ __u16 ssn);
+sctp_chunk_t *sctp_make_data(sctp_association_t *,
+ const struct sctp_sndrcvinfo *sinfo,
+ int len, const __u8 *data);
+sctp_chunk_t *sctp_make_data_empty(sctp_association_t *,
+ const struct sctp_sndrcvinfo *, int len);
+sctp_chunk_t *sctp_make_ecne(const sctp_association_t *,
+ const __u32);
+sctp_chunk_t *sctp_make_sack(const sctp_association_t *);
+sctp_chunk_t *sctp_make_shutdown(const sctp_association_t *asoc);
+sctp_chunk_t *sctp_make_shutdown_ack(const sctp_association_t *asoc,
+ const sctp_chunk_t *);
+sctp_chunk_t *sctp_make_shutdown_complete(const sctp_association_t *,
+ const sctp_chunk_t *);
+void sctp_init_cause(sctp_chunk_t *, __u16 cause, const void *, size_t);
+sctp_chunk_t *sctp_make_abort(const sctp_association_t *,
+ const sctp_chunk_t *,
+ const size_t hint);
+sctp_chunk_t *sctp_make_abort_no_data(const sctp_association_t *,
+ const sctp_chunk_t *,
+ __u32 tsn);
+sctp_chunk_t *sctp_make_heartbeat(const sctp_association_t *,
+ const sctp_transport_t *,
+ const void *payload,
+ const size_t paylen);
+sctp_chunk_t *sctp_make_heartbeat_ack(const sctp_association_t *,
+ const sctp_chunk_t *,
+ const void *payload,
+ const size_t paylen);
+sctp_chunk_t *sctp_make_op_error(const sctp_association_t *,
+ const sctp_chunk_t *chunk,
+ __u16 cause_code,
+ const void *payload,
+ size_t paylen);
+void sctp_chunk_assign_tsn(sctp_chunk_t *);
+
+
+/* Prototypes for statetable processing. */
+
+int sctp_do_sm(sctp_event_t event_type, sctp_subtype_t subtype,
+ sctp_state_t state,
+ sctp_endpoint_t *,
+ sctp_association_t *asoc,
+ void *event_arg,
+ int priority);
+
+int sctp_side_effects(sctp_event_t event_type, sctp_subtype_t subtype,
+ sctp_state_t state,
+ sctp_endpoint_t *,
+ sctp_association_t *asoc,
+ void *event_arg,
+ sctp_disposition_t status,
+ sctp_cmd_seq_t *commands,
+ int priority);
+
+/* 2nd level prototypes */
+int
+sctp_cmd_interpreter(sctp_event_t event_type, sctp_subtype_t subtype,
+ sctp_state_t state,
+ sctp_endpoint_t *ep,
+ sctp_association_t *asoc,
+ void *event_arg,
+ sctp_disposition_t status,
+ sctp_cmd_seq_t *retval,
+ int priority);
+
+
+int sctp_gen_sack(sctp_association_t *, int force, sctp_cmd_seq_t *);
+void sctp_do_TSNdup(sctp_association_t *, sctp_chunk_t *, long gap);
+
+void sctp_generate_t3_rtx_event(unsigned long peer);
+void sctp_generate_heartbeat_event(unsigned long peer);
+
+sctp_sackhdr_t *sctp_sm_pull_sack(sctp_chunk_t *);
+
+sctp_cookie_param_t *
+sctp_pack_cookie(const sctp_endpoint_t *, const sctp_association_t *,
+ const sctp_chunk_t *, int *cookie_len,
+ const __u8 *, int addrs_len);
+sctp_association_t *sctp_unpack_cookie(const sctp_endpoint_t *,
+ const sctp_association_t *,
+ sctp_chunk_t *, int priority, int *err);
+int sctp_addip_addr_config(sctp_association_t *, sctp_param_t,
+ struct sockaddr_storage*, int);
+
+/* 3rd level prototypes */
+__u32 sctp_generate_tag(const sctp_endpoint_t *);
+__u32 sctp_generate_tsn(const sctp_endpoint_t *);
+
+/* 4th level prototypes */
+void sctp_param2sockaddr(sockaddr_storage_t *addr, const sctpParam_t param,
+ __u16 port);
+int sctp_addr2sockaddr(const sctpParam_t, sockaddr_storage_t *);
+int sockaddr2sctp_addr(const sockaddr_storage_t *, sctpParam_t);
+
+/* Extern declarations for major data structures. */
+sctp_sm_table_entry_t *sctp_chunk_event_lookup(sctp_cid_t, sctp_state_t);
+extern sctp_sm_table_entry_t
+primitive_event_table[SCTP_NUM_PRIMITIVE_TYPES][SCTP_STATE_NUM_STATES];
+extern sctp_sm_table_entry_t
+other_event_table[SCTP_NUM_OTHER_TYPES][SCTP_STATE_NUM_STATES];
+extern sctp_sm_table_entry_t
+timeout_event_table[SCTP_NUM_TIMEOUT_TYPES][SCTP_STATE_NUM_STATES];
+extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
+
+/* These are some handy utility macros... */
+
+
+/* Get the size of a DATA chunk payload. */
+static inline __u16 sctp_data_size(sctp_chunk_t *chunk)
+{
+ __u16 size;
+
+ size = ntohs(chunk->chunk_hdr->length);
+ size -= sizeof(sctp_data_chunk_t);
+
+ return size;
+}
+
+/* Compare two TSNs */
+
+/* RFC 1982 - Serial Number Arithmetic
+ *
+ * 2. Comparison
+ * Then, s1 is said to be equal to s2 if and only if i1 is equal to i2,
+ * in all other cases, s1 is not equal to s2.
+ *
+ * s1 is said to be less than s2 if, and only if, s1 is not equal to s2,
+ * and
+ *
+ * (i1 < i2 and i2 - i1 < 2^(SERIAL_BITS - 1)) or
+ * (i1 > i2 and i1 - i2 > 2^(SERIAL_BITS - 1))
+ *
+ * s1 is said to be greater than s2 if, and only if, s1 is not equal to
+ * s2, and
+ *
+ * (i1 < i2 and i2 - i1 > 2^(SERIAL_BITS - 1)) or
+ * (i1 > i2 and i1 - i2 < 2^(SERIAL_BITS - 1))
+ */
+
+/*
+ * RFC 2960
+ * 1.6 Serial Number Arithmetic
+ *
+ * Comparisons and arithmetic on TSNs in this document SHOULD use Serial
+ * Number Arithmetic as defined in [RFC1982] where SERIAL_BITS = 32.
+ */
+
+enum {
+ TSN_SIGN_BIT = (1<<31)
+};
+
+static inline int TSN_lt(__u32 s, __u32 t)
+{
+ return (((s) - (t)) & TSN_SIGN_BIT);
+}
+
+static inline int TSN_lte(__u32 s, __u32 t)
+{
+ return (((s) == (t)) || (((s) - (t)) & TSN_SIGN_BIT));
+}
+
+/* Compare two SSNs */
+
+/*
+ * RFC 2960
+ * 1.6 Serial Number Arithmetic
+ *
+ * Comparisons and arithmetic on Stream Sequence Numbers in this document
+ * SHOULD use Serial Number Arithmetic as defined in [RFC1982] where
+ * SERIAL_BITS = 16.
+ */
+enum {
+ SSN_SIGN_BIT = (1<<15)
+};
+
+static inline int SSN_lt(__u16 s, __u16 t)
+{
+ return (((s) - (t)) & SSN_SIGN_BIT);
+}
+
+static inline int SSN_lte(__u16 s, __u16 t)
+{
+ return (((s) == (t)) || (((s) - (t)) & SSN_SIGN_BIT));
+}
+
+/* Run sctp_add_cmd() generating a BUG() if there is a failure. */
+static inline void sctp_add_cmd_sf(sctp_cmd_seq_t *seq, sctp_verb_t verb, sctp_arg_t obj)
+{
+ if (unlikely(!sctp_add_cmd(seq, verb, obj)))
+ BUG();
+}
+
+#endif /* __sctp_sm_h__ */
diff --git a/include/net/sctp/sctp_structs.h b/include/net/sctp/sctp_structs.h
new file mode 100644
index 000000000000..bb7715795c81
--- /dev/null
+++ b/include/net/sctp/sctp_structs.h
@@ -0,0 +1,1543 @@
+/* SCTP kernel reference Implementation
+ * Copyright (c) 1999-2000 Cisco, Inc.
+ * Copyright (c) 1999-2001 Motorola, Inc.
+ * Copyright (c) 2001 Intel Corp.
+ * Copyright (c) 2001 International Business Machines Corp.
+ *
+ * This file is part of the SCTP kernel reference Implementation
+ *
+ * $Header: /cvsroot/lksctp/lksctp/sctp_cvs/include/net/sctp/sctp_structs.h,v 1.21 2002/08/16 19:30:49 jgrimm Exp $
+ *
+ * The SCTP reference implementation is free software;
+ * you can redistribute it and/or modify it under the terms of
+ * the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * The SCTP reference implementation is distributed in the hope that it
+ * will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * ************************
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU CC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Please send any bug reports or fixes you make to the
+ * email addresses:
+ * lksctp developers <lksctp-developers@lists.sourceforge.net>
+ *
+ * Or submit a bug report through the following website:
+ * http://www.sf.net/projects/lksctp
+ *
+ * Written or modified by:
+ * Randall Stewart <randall@sctp.chicago.il.us>
+ * Ken Morneau <kmorneau@cisco.com>
+ * Qiaobing Xie <qxie1@email.mot.com>
+ * La Monte H.P. Yarroll <piggy@acm.org>
+ * Karl Knutson <karl@athena.chicago.il.us>
+ * Jon Grimm <jgrimm@us.ibm.com>
+ * Xingang Guo <xingang.guo@intel.com>
+ * Hui Huang <hui.huang@nokia.com>
+ * Sridhar Samudrala <sri@us.ibm.com>
+ * Daisy Chang <daisyc@us.ibm.com>
+ * Dajiang Zhang <dajiang.zhang@nokia.com>
+ *
+ * Any bugs reported given to us we will try to fix... any fixes shared will
+ * be incorporated into the next SCTP release.
+ */
+
+#ifndef __sctp_structs_h__
+#define __sctp_structs_h__
+
+#include <linux/time.h> /* We get struct timespec. */
+#include <linux/socket.h> /* linux/in.h needs this!! */
+#include <linux/in.h> /* We get struct sockaddr_in. */
+#include <linux/in6.h> /* We get struct in6_addr */
+#include <asm/param.h> /* We get MAXHOSTNAMELEN. */
+#include <asm/atomic.h> /* This gets us atomic counters. */
+#include <linux/skbuff.h> /* We need sk_buff_head. */
+#include <linux/tqueue.h> /* We need tq_struct. */
+#include <linux/sctp.h> /* We need sctp* header structs. */
+
+/*
+ * This is (almost) a direct quote from RFC 2553.
+ */
+
+/*
+ * Desired design of maximum size and alignment
+ */
+#define _SS_MAXSIZE 128 /* Implementation specific max size */
+#define _SS_ALIGNSIZE (sizeof (__s64))
+ /* Implementation specific desired alignment */
+/*
+ * Definitions used for sockaddr_storage structure paddings design.
+ */
+#define _SS_PAD1SIZE (_SS_ALIGNSIZE - sizeof (sa_family_t))
+#define _SS_PAD2SIZE (_SS_MAXSIZE - (sizeof (sa_family_t)+ \
+ _SS_PAD1SIZE + _SS_ALIGNSIZE))
+
+struct sockaddr_storage {
+ sa_family_t __ss_family; /* address family */
+ /* Following fields are implementation specific */
+ char __ss_pad1[_SS_PAD1SIZE];
+ /* 6 byte pad, to make implementation */
+ /* specific pad up to alignment field that */
+ /* follows explicit in the data structure */
+ __s64 __ss_align; /* field to force desired structure */
+ /* storage alignment */
+ char __ss_pad2[_SS_PAD2SIZE];
+ /* 112 byte pad to achieve desired size, */
+ /* _SS_MAXSIZE value minus size of ss_family */
+ /* __ss_pad1, __ss_align fields is 112 */
+};
+
+/* A convenience structure for handling sockaddr structures.
+ * We should wean ourselves off this.
+ */
+typedef union {
+ struct sockaddr_in v4;
+ struct sockaddr_in6 v6;
+ struct sockaddr sa;
+} sockaddr_storage_t;
+
+
+/* Forward declarations for data structures. */
+struct SCTP_protocol;
+struct SCTP_endpoint;
+struct SCTP_association;
+struct SCTP_transport;
+struct SCTP_packet;
+struct SCTP_chunk;
+struct SCTP_inqueue;
+struct SCTP_outqueue;
+struct SCTP_bind_addr;
+struct sctp_opt;
+struct sctp_endpoint_common;
+
+
+typedef struct SCTP_protocol sctp_protocol_t;
+typedef struct SCTP_endpoint sctp_endpoint_t;
+typedef struct SCTP_association sctp_association_t;
+typedef struct SCTP_transport sctp_transport_t;
+typedef struct SCTP_packet sctp_packet_t;
+typedef struct SCTP_chunk sctp_chunk_t;
+typedef struct SCTP_inqueue sctp_inqueue_t;
+typedef struct SCTP_outqueue sctp_outqueue_t;
+typedef struct SCTP_bind_addr sctp_bind_addr_t;
+typedef struct sctp_opt sctp_opt_t;
+typedef struct sctp_endpoint_common sctp_endpoint_common_t;
+
+#include <net/sctp/sctp_tsnmap.h>
+#include <net/sctp/sctp_ulpevent.h>
+#include <net/sctp/sctp_ulpqueue.h>
+
+
+/* Structures useful for managing bind/connect. */
+
+typedef struct sctp_bind_bucket {
+ unsigned short port;
+ unsigned short fastreuse;
+ struct sctp_bind_bucket *next;
+ struct sctp_bind_bucket **pprev;
+ struct sock *sk;
+} sctp_bind_bucket_t;
+
+typedef struct sctp_bind_hashbucket {
+ spinlock_t lock;
+ struct sctp_bind_bucket *chain;
+} sctp_bind_hashbucket_t;
+
+/* Used for hashing all associations. */
+typedef struct sctp_hashbucket {
+ rwlock_t lock;
+ sctp_endpoint_common_t *chain;
+} sctp_hashbucket_t __attribute__((__aligned__(8)));
+
+
+/* The SCTP protocol structure. */
+struct SCTP_protocol {
+ /* RFC2960 Section 14. Suggested SCTP Protocol Parameter Values
+ *
+ * The following protocol parameters are RECOMMENDED:
+ *
+ * RTO.Initial - 3 seconds
+ * RTO.Min - 1 second
+ * RTO.Max - 60 seconds
+ * RTO.Alpha - 1/8 (3 when converted to right shifts.)
+ * RTO.Beta - 1/4 (2 when converted to right shifts.)
+ */
+ __u32 rto_initial;
+ __u32 rto_min;
+ __u32 rto_max;
+
+ /* Note: rto_alpha and rto_beta are really defined as inverse
+ * powers of two to facilitate integer operations.
+ */
+ int rto_alpha;
+ int rto_beta;
+
+ /* Max.Burst - 4 */
+ int max_burst;
+
+ /* Valid.Cookie.Life - 60 seconds */
+ int valid_cookie_life;
+
+ /* Association.Max.Retrans - 10 attempts
+ * Path.Max.Retrans - 5 attempts (per destination address)
+ * Max.Init.Retransmits - 8 attempts
+ */
+ int max_retrans_association;
+ int max_retrans_path;
+ int max_retrans_init;
+
+ /* HB.interval - 30 seconds */
+ int hb_interval;
+
+ /* The following variables are implementation specific. */
+
+ /* Default initialization values to be applied to new associations. */
+ __u16 max_instreams;
+ __u16 max_outstreams;
+
+ /* This is a list of groups of functions for each address
+ * family that we support.
+ */
+ list_t address_families;
+
+ /* This is the hash of all endpoints. */
+ int ep_hashsize;
+ sctp_hashbucket_t *ep_hashbucket;
+
+ /* This is the hash of all associations. */
+ int assoc_hashsize;
+ sctp_hashbucket_t *assoc_hashbucket;
+
+ /* This is the sctp port control hash. */
+ int port_hashsize;
+ int port_rover;
+ spinlock_t port_alloc_lock; /* Protects port_rover. */
+ sctp_bind_hashbucket_t *port_hashtable;
+
+ /* This is the global local address list.
+ * We actively maintain this complete list of interfaces on
+ * the system by catching routing events.
+ *
+ * It is a list of struct sockaddr_storage_list.
+ */
+ list_t local_addr_list;
+ spinlock_t local_addr_lock;
+};
+
+
+/*
+ * Pointers to address related SCTP functions.
+ * (i.e. things that depend on the address family.)
+ */
+typedef struct sctp_func {
+ int (*queue_xmit) (struct sk_buff *skb);
+ int (*setsockopt) (struct sock *sk,
+ int level,
+ int optname,
+ char *optval,
+ int optlen);
+ int (*getsockopt) (struct sock *sk,
+ int level,
+ int optname,
+ char *optval,
+ int *optlen);
+ int (*get_dst_mtu) (const sockaddr_storage_t *address);
+ __u16 net_header_len;
+ int sockaddr_len;
+ sa_family_t sa_family;
+ list_t list;
+} sctp_func_t;
+
+sctp_func_t *sctp_get_af_specific(const sockaddr_storage_t *address);
+
+/* SCTP Socket type: UDP or TCP style. */
+typedef enum {
+ SCTP_SOCKET_UDP = 0,
+ SCTP_SOCKET_UDP_HIGH_BANDWIDTH,
+ SCTP_SOCKET_TCP
+} sctp_socket_type_t;
+
+/* Per socket SCTP information. */
+struct sctp_opt {
+ /* What kind of a socket is this? */
+ sctp_socket_type_t type;
+
+ /* What is our base endpointer? */
+ sctp_endpoint_t *ep;
+
+ /* Various Socket Options. */
+ __u16 default_stream;
+ __u32 default_ppid;
+ struct sctp_initmsg initmsg;
+ struct sctp_rtoinfo rtoinfo;
+ struct sctp_paddrparams paddrparam;
+ struct sctp_event_subscribe subscribe;
+ __u32 autoclose;
+ __u8 nodelay;
+ __u8 disable_fragments;
+};
+
+
+
+/* This is our APPLICATION-SPECIFIC state cookie.
+ * THIS IS NOT DICTATED BY THE SPECIFICATION.
+ */
+/* These are the parts of an association which we send in the cookie.
+ * Most of these are straight out of:
+ * RFC2960 12.2 Parameters necessary per association (i.e. the TCB)
+ *
+ */
+
+typedef struct sctp_cookie {
+
+ /* My : Tag expected in every inbound packet and sent
+ * Verification: in the INIT or INIT ACK chunk.
+ * Tag :
+ */
+ __u32 my_vtag;
+
+ /* Peer's : Tag expected in every outbound packet except
+ * Verification: in the INIT chunk.
+ * Tag :
+ */
+ __u32 peer_vtag;
+
+ /* The rest of these are not from the spec, but really need to
+ * be in the cookie.
+ */
+
+ /* My Tie Tag : Assist in discovering a restarting association. */
+ __u32 my_ttag;
+
+ /* Peer's Tie Tag: Assist in discovering a restarting association. */
+ __u32 peer_ttag;
+
+ /* When does this cookie expire? */
+ struct timeval expiration;
+
+ /* Number of inbound/outbound streams which are set
+ * and negotiated during the INIT process. */
+ __u16 sinit_num_ostreams;
+ __u16 sinit_max_instreams;
+
+ /* This is the first sequence number I used. */
+ __u32 initial_tsn;
+
+ /* This holds the originating address of the INIT packet. */
+ sockaddr_storage_t peer_addr;
+
+ /* This is a shim for my peer's INIT packet, followed by
+ * a copy of the raw address list of the association.
+ * The length of the raw address list is saved in the
+ * raw_addr_list_len field, which will be used at the time when
+ * the association TCB is re-constructed from the cookie.
+ */
+ __u32 raw_addr_list_len;
+ sctp_init_chunk_t peer_init[0];
+} sctp_cookie_t;
+
+
+/* The format of our cookie that we send to our peer. */
+typedef struct sctp_signed_cookie {
+ __u8 signature[SCTP_SECRET_SIZE];
+ sctp_cookie_t c;
+} sctp_signed_cookie_t;
+
+
+/* This convenience type allows us to avoid casting when walking
+ * through a parameter list.
+ */
+typedef union {
+ __u8 *v;
+ sctp_paramhdr_t *p;
+
+ sctp_cookie_preserve_param_t *bht;
+ sctp_hostname_param_t *dns;
+ sctp_cookie_param_t *cookie;
+ sctp_supported_addrs_param_t *sat;
+ sctp_ipv4addr_param_t *v4;
+ sctp_ipv6addr_param_t *v6;
+} sctpParam_t;
+
+/* This is another convenience type to allocate memory for address
+ * params for the maximum size and pass such structures around
+ * internally.
+ */
+typedef union {
+ sctp_ipv4addr_param_t v4;
+ sctp_ipv6addr_param_t v6;
+} sctpIpAddress_t;
+
+/* RFC 2960. Section 3.3.5 Heartbeat.
+ * Heartbeat Information: variable length
+ * The Sender-specific Heartbeat Info field should normally include
+ * information about the sender's current time when this HEARTBEAT
+ * chunk is sent and the destination transport address to which this
+ * HEARTBEAT is sent (see Section 8.3).
+ */
+typedef struct sctp_sender_hb_info {
+ sctp_paramhdr_t param_hdr;
+ sockaddr_storage_t daddr;
+ unsigned long sent_at;
+} sctp_sender_hb_info_t __attribute__((packed));
+
+/* RFC2960 1.4 Key Terms
+ *
+ * o Chunk: A unit of information within an SCTP packet, consisting of
+ * a chunk header and chunk-specific content.
+ *
+ * As a matter of convenience, we remember the SCTP common header for
+ * each chunk as well as a few other header pointers...
+ */
+struct SCTP_chunk {
+ /* These first three elements MUST PRECISELY match the first
+ * three elements of struct sk_buff. This allows us to reuse
+ * all the skb_* queue management functions.
+ */
+ sctp_chunk_t *next;
+ sctp_chunk_t *prev;
+ struct sk_buff_head *list;
+
+ /* This is our link to the per-transport transmitted list. */
+ struct list_head transmitted_list;
+
+ /* This field is used by chunks that hold fragmented data.
+ * For the first fragment this is the list that holds the rest of
+ * fragments. For the remaining fragments, this is the link to the
+ * frag_list maintained in the first fragment.
+ */
+ struct list_head frag_list;
+
+ /* This points to the sk_buff containing the actual data. */
+ struct sk_buff *skb;
+
+ /* These are the SCTP headers by reverse order in a packet.
+ * Note that some of these may happen more than once. In that
+ * case, we point at the "current" one, whatever that means
+ * for that level of header.
+ */
+
+ /* We point this at the FIRST TLV parameter to chunk_hdr. */
+ sctpParam_t param_hdr;
+ union {
+ __u8 *v;
+ sctp_datahdr_t *data_hdr;
+ sctp_inithdr_t *init_hdr;
+ sctp_sackhdr_t *sack_hdr;
+ sctp_heartbeathdr_t *hb_hdr;
+ sctp_sender_hb_info_t *hbs_hdr;
+ sctp_shutdownhdr_t *shutdown_hdr;
+ sctp_signed_cookie_t *cookie_hdr;
+ sctp_ecnehdr_t *ecne_hdr;
+ sctp_cwrhdr_t *ecn_cwr_hdr;
+ sctp_errhdr_t *err_hdr;
+ } subh;
+
+ __u8 *chunk_end;
+
+ sctp_chunkhdr_t *chunk_hdr;
+
+ sctp_sctphdr_t *sctp_hdr;
+
+ /* This needs to be recoverable for SCTP_SEND_FAILED events. */
+ struct sctp_sndrcvinfo sinfo;
+
+ /* Which association does this belong to? */
+ sctp_association_t *asoc;
+
+ /* What endpoint received this chunk? */
+ sctp_endpoint_common_t *rcvr;
+
+ /* We fill this in if we are calculating RTT. */
+ unsigned long sent_at;
+
+ __u8 rtt_in_progress; /* Is this chunk used for RTT calculation? */
+ __u8 num_times_sent; /* How man times did we send this? */
+ __u8 has_tsn; /* Does this chunk have a TSN yet? */
+ __u8 singleton; /* Was this the only chunk in the packet? */
+ __u8 end_of_packet; /* Was this the last chunk in the packet? */
+ __u8 ecn_ce_done; /* Have we processed the ECN CE bit? */
+ __u8 pdiscard; /* Discard the whole packet now? */
+ __u8 tsn_gap_acked; /* Is this chunk acked by a GAP ACK? */
+ __u8 fast_retransmit; /* Is this chunk fast retransmitted? */
+ __u8 tsn_missing_report; /* Data chunk missing counter. */
+
+ /* What is the origin IP address for this chunk? */
+ sockaddr_storage_t source;
+
+ /* For an inbound chunk, this tells us where it came from.
+ * For an outbound chunk, it tells us where we'd like it to
+ * go. It is NULL if we have no preference.
+ */
+ sctp_transport_t *transport;
+};
+
+sctp_chunk_t *sctp_make_chunk(const sctp_association_t *, __u8 type,
+ __u8 flags, int size);
+void sctp_free_chunk(sctp_chunk_t *);
+sctp_chunk_t *sctp_copy_chunk(sctp_chunk_t *, int flags);
+void *sctp_addto_chunk(sctp_chunk_t *chunk, int len, const void *data);
+int sctp_user_addto_chunk(sctp_chunk_t *chunk, int len, struct iovec *data);
+sctp_chunk_t *sctp_chunkify(struct sk_buff *, const sctp_association_t *,
+ struct sock *);
+void sctp_init_source(sctp_chunk_t *chunk);
+const sockaddr_storage_t *sctp_source(const sctp_chunk_t *chunk);
+
+/* This is a structure for holding either an IPv6 or an IPv4 address. */
+/* sin_family -- AF_INET or AF_INET6
+ * sin_port -- ordinary port number
+ * sin_addr -- cast to either (struct in_addr) or (struct in6_addr)
+ */
+struct sockaddr_storage_list {
+ list_t list;
+ sockaddr_storage_t a;
+};
+
+typedef sctp_chunk_t *(sctp_packet_phandler_t)(sctp_association_t *);
+
+/* This structure holds lists of chunks as we are assembling for
+ * transmission.
+ */
+struct SCTP_packet {
+ /* These are the SCTP header values (host order) for the packet. */
+ __u16 source_port;
+ __u16 destination_port;
+ __u32 vtag;
+
+ /* This contains the payload chunks. */
+ struct sk_buff_head chunks;
+ /* This is the total size of all chunks INCLUDING padding. */
+ size_t size;
+
+ /* The packet is destined for this transport address.
+ * The function we finally use to pass down to the next lower
+ * layer lives in the transport structure.
+ */
+ sctp_transport_t *transport;
+
+ /* Allow a callback for getting a high priority chunk
+ * bundled early into the packet (This is used for ECNE).
+ */
+ sctp_packet_phandler_t *get_prepend_chunk;
+
+ /* This packet should advertise ECN capability to the network
+ * via the ECT bit.
+ */
+ int ecn_capable;
+
+ /* This packet contains a COOKIE-ECHO chunk. */
+ int has_cookie_echo;
+
+ int malloced;
+};
+
+typedef int (sctp_outqueue_thandler_t)(sctp_outqueue_t *, void *);
+typedef int (sctp_outqueue_ehandler_t)(sctp_outqueue_t *);
+typedef sctp_packet_t *(sctp_outqueue_ohandler_init_t)
+ (sctp_packet_t *,
+ sctp_transport_t *,
+ __u16 sport,
+ __u16 dport);
+typedef sctp_packet_t *(sctp_outqueue_ohandler_config_t)
+ (sctp_packet_t *,
+ __u32 vtag,
+ int ecn_capable,
+ sctp_packet_phandler_t *get_prepend_chunk);
+typedef sctp_xmit_t (sctp_outqueue_ohandler_t)(sctp_packet_t *,
+ sctp_chunk_t *);
+typedef int (sctp_outqueue_ohandler_force_t)(sctp_packet_t *);
+
+sctp_outqueue_ohandler_init_t sctp_packet_init;
+sctp_outqueue_ohandler_config_t sctp_packet_config;
+sctp_outqueue_ohandler_t sctp_packet_append_chunk;
+sctp_outqueue_ohandler_t sctp_packet_transmit_chunk;
+sctp_outqueue_ohandler_force_t sctp_packet_transmit;
+void sctp_packet_free(sctp_packet_t *);
+
+
+/* This represents a remote transport address.
+ * For local transport addresses, we just use sockaddr_storage_t.
+ *
+ * RFC2960 Section 1.4 Key Terms
+ *
+ * o Transport address: A Transport Address is traditionally defined
+ * by Network Layer address, Transport Layer protocol and Transport
+ * Layer port number. In the case of SCTP running over IP, a
+ * transport address is defined by the combination of an IP address
+ * and an SCTP port number (where SCTP is the Transport protocol).
+ *
+ * RFC2960 Section 7.1 SCTP Differences from TCP Congestion control
+ *
+ * o The sender keeps a separate congestion control parameter set for
+ * each of the destination addresses it can send to (not each
+ * source-destination pair but for each destination). The parameters
+ * should decay if the address is not used for a long enough time
+ * period.
+ *
+ */
+struct SCTP_transport {
+ /* A list of transports. */
+ list_t transports;
+
+ /* Reference counting. */
+ atomic_t refcnt;
+ int dead;
+
+ /* This is the peer's IP address and port. */
+ sockaddr_storage_t ipaddr;
+
+ /* These are the functions we call to handle LLP stuff. */
+ sctp_func_t *af_specific;
+
+ /* Which association do we belong to? */
+ sctp_association_t *asoc;
+
+ /* RFC2960
+ *
+ * 12.3 Per Transport Address Data
+ *
+ * For each destination transport address in the peer's
+ * address list derived from the INIT or INIT ACK chunk, a
+ * number of data elements needs to be maintained including:
+ */
+ __u32 rtt; /* This is the most recent RTT. */
+
+ /* RTO : The current retransmission timeout value. */
+ __u32 rto;
+
+ /* RTTVAR : The current RTT variation. */
+ __u32 rttvar;
+
+ /* SRTT : The current smoothed round trip time. */
+ __u32 srtt;
+
+ /* RTO-Pending : A flag used to track if one of the DATA
+ * chunks sent to this address is currently being
+ * used to compute a RTT. If this flag is 0,
+ * the next DATA chunk sent to this destination
+ * should be used to compute a RTT and this flag
+ * should be set. Every time the RTT
+ * calculation completes (i.e. the DATA chunk
+ * is SACK'd) clear this flag.
+ */
+ int rto_pending;
+
+
+ /*
+ * These are the congestion stats.
+ */
+ /* cwnd : The current congestion window. */
+ __u32 cwnd; /* This is the actual cwnd. */
+
+ /* ssthresh : The current slow start threshold value. */
+ __u32 ssthresh;
+
+ /* partial : The tracking method for increase of cwnd when in
+ * bytes acked : congestion avoidance mode (see Section 6.2.2)
+ */
+ __u32 partial_bytes_acked;
+
+ /* Data that has been sent, but not acknowledged. */
+ __u32 flight_size;
+
+ /* PMTU : The current known path MTU. */
+ __u32 pmtu;
+
+ /* When was the last time(in jiffies) that a data packet was sent on
+ * this transport? This is used to adjust the cwnd when the transport
+ * becomes inactive.
+ */
+ unsigned long last_time_used;
+
+ /* Heartbeat interval: The endpoint sends out a Heartbeat chunk to
+ * the destination address every heartbeat interval.
+ */
+ int hb_interval;
+
+ /* When was the last time (in jiffies) that we heard from this
+ * transport? We use this to pick new active and retran paths.
+ */
+ unsigned long last_time_heard;
+
+ /* Last time(in jiffies) when cwnd is reduced due to the congestion
+ * indication based on ECNE chunk.
+ */
+ unsigned long last_time_ecne_reduced;
+
+ /* state : The current state of this destination,
+ * : i.e. DOWN, UP, ALLOW-HB, NO-HEARTBEAT, etc.
+ */
+ struct {
+ int active;
+ int hb_allowed;
+ } state;
+
+ /* These are the error stats for this destination. */
+
+ /* Error count : The current error count for this destination. */
+ unsigned short error_count;
+
+ /* Error : Current error threshold for this destination
+ * Threshold : i.e. what value marks the destination down if
+ * : errorCount reaches this value.
+ */
+ unsigned short error_threshold;
+
+ /* This is the max_retrans value for the transport and will
+ * be initialized to proto.max_retrans.path. This can be changed
+ * using SCTP_SET_PEER_ADDR_PARAMS socket option.
+ */
+ int max_retrans;
+
+ /* We use this name for debugging output... */
+ char *debug_name;
+
+ /* Per : A timer used by each destination.
+ * Destination :
+ * Timer :
+ *
+ * [Everywhere else in the text this is called T3-rtx. -ed]
+ */
+ struct timer_list T3_rtx_timer;
+
+ /* Heartbeat timer is per destination. */
+ struct timer_list hb_timer;
+
+ /* Since we're using per-destination retransmission timers
+ * (see above), we're also using per-destination "transmitted"
+ * queues. This probably ought to be a private struct
+ * accessible only within the outqueue, but it's not, yet.
+ */
+ struct list_head transmitted;
+
+ /* We build bundle-able packets for this transport here. */
+ sctp_packet_t packet;
+
+ /* This is the list of transports that have chunks to send. */
+ struct list_head send_ready;
+
+ int malloced; /* Is this structure kfree()able? */
+};
+
+extern sctp_transport_t *sctp_transport_new(const sockaddr_storage_t *, int);
+extern sctp_transport_t *sctp_transport_init(sctp_transport_t *,
+ const sockaddr_storage_t *, int);
+extern void sctp_transport_set_owner(sctp_transport_t *, sctp_association_t *);
+extern void sctp_transport_free(sctp_transport_t *);
+extern void sctp_transport_destroy(sctp_transport_t *);
+extern void sctp_transport_reset_timers(sctp_transport_t *);
+extern void sctp_transport_hold(sctp_transport_t *);
+extern void sctp_transport_put(sctp_transport_t *);
+extern void sctp_transport_update_rto(sctp_transport_t *, __u32);
+extern void sctp_transport_raise_cwnd(sctp_transport_t *, __u32, __u32);
+extern void sctp_transport_lower_cwnd(sctp_transport_t *, sctp_lower_cwnd_t);
+
+/* This is the structure we use to queue packets as they come into
+ * SCTP. We write packets to it and read chunks from it. It handles
+ * fragment reassembly and chunk unbundling.
+ */
+struct SCTP_inqueue {
+ /* This is actually a queue of sctp_chunk_t each
+ * containing a partially decoded packet.
+ */
+ struct sk_buff_head in;
+ /* This is the packet which is currently off the in queue and is
+ * being worked on through the inbound chunk processing.
+ */
+ sctp_chunk_t *in_progress;
+
+ /* This is the delayed task to finish delivering inbound
+ * messages.
+ */
+ struct tq_struct immediate;
+
+ int malloced; /* Is this structure kfree()able? */
+};
+
+sctp_inqueue_t *sctp_inqueue_new(void);
+void sctp_inqueue_init(sctp_inqueue_t *);
+void sctp_inqueue_free(sctp_inqueue_t *);
+void sctp_push_inqueue(sctp_inqueue_t *, sctp_chunk_t *packet);
+sctp_chunk_t *sctp_pop_inqueue(sctp_inqueue_t *);
+void sctp_inqueue_set_th_handler(sctp_inqueue_t *,
+ void (*)(void *), void *);
+
+/* This is the structure we use to hold outbound chunks. You push
+ * chunks in and they automatically pop out the other end as bundled
+ * packets (it calls (*output_handler)()).
+ *
+ * This structure covers sections 6.3, 6.4, 6.7, 6.8, 6.10, 7., 8.1,
+ * and 8.2 of the v13 draft.
+ *
+ * It handles retransmissions. The connection to the timeout portion
+ * of the state machine is through sctp_..._timeout() and timeout_handler.
+ *
+ * If you feed it SACKs, it will eat them.
+ *
+ * If you give it big chunks, it will fragment them.
+ *
+ * It assigns TSN's to data chunks. This happens at the last possible
+ * instant before transmission.
+ *
+ * When free()'d, it empties itself out via output_handler().
+ */
+struct SCTP_outqueue {
+ sctp_association_t *asoc;
+
+ /* BUG: This really should be an array of streams.
+ * This really holds a list of chunks (one stream).
+ * FIXME: If true, why so?
+ */
+ struct sk_buff_head out;
+
+ /* These are control chunks we want to send. */
+ struct sk_buff_head control;
+
+ /* These are chunks that have been sacked but are above the
+ * CTSN, or cumulative tsn ack point.
+ */
+ struct list_head sacked;
+
+ /* Put chunks on this list to schedule them for
+ * retransmission.
+ */
+ struct list_head retransmit;
+
+ /* Call these functions to send chunks down to the next lower
+ * layer. This is always SCTP_packet, but we separate the two
+ * structures to make testing simpler.
+ */
+ sctp_outqueue_ohandler_init_t *init_output;
+ sctp_outqueue_ohandler_config_t *config_output;
+ sctp_outqueue_ohandler_t *append_output;
+ sctp_outqueue_ohandler_t *build_output;
+ sctp_outqueue_ohandler_force_t *force_output;
+
+ /* How many unackd bytes do we have in-flight? */
+ __u32 outstanding_bytes;
+
+ /* Is this structure empty? */
+ int empty;
+
+ /* Are we kfree()able? */
+ int malloced;
+};
+
+sctp_outqueue_t *sctp_outqueue_new(sctp_association_t *);
+void sctp_outqueue_init(sctp_association_t *, sctp_outqueue_t *);
+void sctp_outqueue_teardown(sctp_outqueue_t *);
+void sctp_outqueue_free(sctp_outqueue_t*);
+void sctp_force_outqueue(sctp_outqueue_t *);
+int sctp_push_outqueue(sctp_outqueue_t *, sctp_chunk_t *chunk);
+int sctp_flush_outqueue(sctp_outqueue_t *, int);
+int sctp_sack_outqueue(sctp_outqueue_t *, sctp_sackhdr_t *);
+int sctp_outqueue_is_empty(const sctp_outqueue_t *);
+int sctp_outqueue_set_output_handlers(sctp_outqueue_t *,
+ sctp_outqueue_ohandler_init_t init,
+ sctp_outqueue_ohandler_config_t config,
+ sctp_outqueue_ohandler_t append,
+ sctp_outqueue_ohandler_t build,
+ sctp_outqueue_ohandler_force_t force);
+void sctp_outqueue_restart(sctp_outqueue_t *);
+void sctp_retransmit(sctp_outqueue_t *, sctp_transport_t *, __u8);
+
+
+/* These bind address data fields common between endpoints and associations */
+struct SCTP_bind_addr {
+
+ /* RFC 2960 12.1 Parameters necessary for the SCTP instance
+ *
+ * SCTP Port: The local SCTP port number the endpoint is
+ * bound to.
+ */
+ __u16 port;
+
+ /* RFC 2960 12.1 Parameters necessary for the SCTP instance
+ *
+ * Address List: The list of IP addresses that this instance
+ * has bound. This information is passed to one's
+ * peer(s) in INIT and INIT ACK chunks.
+ */
+ list_t address_list;
+
+ int malloced; /* Are we kfree()able? */
+};
+
+sctp_bind_addr_t *sctp_bind_addr_new(int gfp_mask);
+void sctp_bind_addr_init(sctp_bind_addr_t *, __u16 port);
+void sctp_bind_addr_free(sctp_bind_addr_t *);
+int sctp_bind_addr_copy(sctp_bind_addr_t *dest, const sctp_bind_addr_t *src,
+ sctp_scope_t scope, int priority,int flags);
+int sctp_add_bind_addr(sctp_bind_addr_t *, sockaddr_storage_t *,
+ int priority);
+int sctp_del_bind_addr(sctp_bind_addr_t *, sockaddr_storage_t *);
+int sctp_bind_addr_has_addr(sctp_bind_addr_t *, const sockaddr_storage_t *);
+sctpParam_t sctp_bind_addrs_to_raw(const sctp_bind_addr_t *bp,
+ int *addrs_len,
+ int priority);
+int sctp_raw_to_bind_addrs(sctp_bind_addr_t *bp,
+ __u8 *raw_addr_list,
+ int addrs_len,
+ unsigned short port,
+ int priority);
+
+sctp_scope_t sctp_scope(const sockaddr_storage_t *);
+int sctp_in_scope(const sockaddr_storage_t *addr, const sctp_scope_t scope);
+int sctp_is_any(const sockaddr_storage_t *addr);
+int sctp_addr_is_valid(const sockaddr_storage_t *addr);
+
+
+/* What type of sctp_endpoint_common? */
+typedef enum {
+ SCTP_EP_TYPE_SOCKET,
+ SCTP_EP_TYPE_ASSOCIATION,
+} sctp_endpoint_type_t;
+
+/*
+ * A common base class to bridge the implmentation view of a
+ * socket (usually listening) endpoint versus an association's
+ * local endpoint.
+ * This common structure is useful for several purposes:
+ * 1) Common interface for lookup routines.
+ * a) Subfunctions work for either endpoint or association
+ * b) Single interface to lookup allows hiding the lookup lock rather
+ * than acquiring it externally.
+ * 2) Common interface for the inbound chunk handling/state machine.
+ * 3) Common object handling routines for reference counting, etc.
+ * 4) Disentangle association lookup from endpoint lookup, where we
+ * do not have to find our endpoint to find our association.
+ *
+ */
+
+struct sctp_endpoint_common {
+ /* Fields to help us manage our entries in the hash tables. */
+ sctp_endpoint_common_t *next;
+ sctp_endpoint_common_t **pprev;
+ int hashent;
+
+ /* Runtime type information. What kind of endpoint is this? */
+ sctp_endpoint_type_t type;
+
+ /* Some fields to help us manage this object.
+ * refcnt - Reference count access to this object.
+ * dead - Do not attempt to use this object.
+ * malloced - Do we need to kfree this object?
+ */
+ atomic_t refcnt;
+ char dead;
+ char malloced;
+
+ /* What socket does this endpoint belong to? */
+ struct sock *sk;
+
+ /* This is where we receive inbound chunks. */
+ sctp_inqueue_t inqueue;
+
+ /* This substructure includes the defining parameters of the
+ * endpoint:
+ * bind_addr.port is our shared port number.
+ * bind_addr.address_list is our set of local IP addresses.
+ */
+ sctp_bind_addr_t bind_addr;
+
+ /* Protection during address list comparisons. */
+ rwlock_t addr_lock;
+};
+
+
+/* RFC Section 1.4 Key Terms
+ *
+ * o SCTP endpoint: The logical sender/receiver of SCTP packets. On a
+ * multi-homed host, an SCTP endpoint is represented to its peers as a
+ * combination of a set of eligible destination transport addresses to
+ * which SCTP packets can be sent and a set of eligible source
+ * transport addresses from which SCTP packets can be received.
+ * All transport addresses used by an SCTP endpoint must use the
+ * same port number, but can use multiple IP addresses. A transport
+ * address used by an SCTP endpoint must not be used by another
+ * SCTP endpoint. In other words, a transport address is unique
+ * to an SCTP endpoint.
+ *
+ * From an implementation perspective, each socket has one of these.
+ * A TCP-style socket will have exactly one association on one of
+ * these. An UDP-style socket will have multiple associations hanging
+ * off one of these.
+ */
+
+struct SCTP_endpoint {
+ /* Common substructure for endpoint and association. */
+ sctp_endpoint_common_t base;
+
+ /* These are the system-wide defaults and other stuff which is
+ * endpoint-independent.
+ */
+ sctp_protocol_t *proto;
+
+ /* Associations: A list of current associations and mappings
+ * to the data consumers for each association. This
+ * may be in the form of a hash table or other
+ * implementation dependent structure. The data
+ * consumers may be process identification
+ * information such as file descriptors, named pipe
+ * pointer, or table pointers dependent on how SCTP
+ * is implemented.
+ */
+ /* This is really a list of sctp_association_t entries. */
+ list_t asocs;
+
+ /* Secret Key: A secret key used by this endpoint to compute
+ * the MAC. This SHOULD be a cryptographic quality
+ * random number with a sufficient length.
+ * Discussion in [RFC1750] can be helpful in
+ * selection of the key.
+ */
+ __u8 secret_key[SCTP_HOW_MANY_SECRETS][SCTP_SECRET_SIZE];
+ int current_key;
+ int last_key;
+ int key_changed_at;
+
+ /* Default timeouts. */
+ int timeouts[SCTP_NUM_TIMEOUT_TYPES];
+
+ /* Various thresholds. */
+
+ /* Name for debugging output... */
+ char *debug_name;
+};
+
+/* Recover the outter endpoint structure. */
+static inline sctp_endpoint_t *sctp_ep(sctp_endpoint_common_t *base)
+{
+ sctp_endpoint_t *ep;
+
+ /* We are not really a list, but the list_entry() macro is
+ * really quite generic to find the address of an outter struct.
+ */
+ ep = list_entry(base, sctp_endpoint_t, base);
+ return ep;
+}
+
+/* These are function signatures for manipulating endpoints. */
+sctp_endpoint_t *sctp_endpoint_new(sctp_protocol_t *, struct sock *, int);
+sctp_endpoint_t *sctp_endpoint_init(sctp_endpoint_t *, sctp_protocol_t *,
+ struct sock *, int priority);
+void sctp_endpoint_free(sctp_endpoint_t *);
+void sctp_endpoint_put(sctp_endpoint_t *);
+void sctp_endpoint_hold(sctp_endpoint_t *);
+void sctp_endpoint_add_asoc(sctp_endpoint_t *, sctp_association_t *asoc);
+sctp_association_t *sctp_endpoint_lookup_assoc(const sctp_endpoint_t *ep,
+ const sockaddr_storage_t *paddr,
+ sctp_transport_t **);
+sctp_endpoint_t *sctp_endpoint_is_match(sctp_endpoint_t *,
+ const sockaddr_storage_t *);
+
+void sctp_process_init(sctp_association_t *asoc, sctp_cid_t cid,
+ const sockaddr_storage_t *peer_addr,
+ sctp_init_chunk_t *peer_init, int priority);
+int sctp_process_param(sctp_association_t *asoc,
+ sctpParam_t param,
+ const sockaddr_storage_t *peer_addr,
+ sctp_cid_t cid, int priority);
+__u32 sctp_generate_tag(const sctp_endpoint_t *ep);
+__u32 sctp_generate_tsn(const sctp_endpoint_t *ep);
+
+
+/* RFC2960
+ *
+ * 12. Recommended Transmission Control Block (TCB) Parameters
+ *
+ * This section details a recommended set of parameters that should
+ * be contained within the TCB for an implementation. This section is
+ * for illustrative purposes and should not be deemed as requirements
+ * on an implementation or as an exhaustive list of all parameters
+ * inside an SCTP TCB. Each implementation may need its own additional
+ * parameters for optimization.
+ */
+
+
+/* Here we have information about each individual association. */
+struct SCTP_association {
+
+ /* A base structure common to endpoint and association.
+ * In this context, it represents the associations's view
+ * of the local endpoint of the association.
+ */
+ sctp_endpoint_common_t base;
+
+ /* Associations on the same socket. */
+ list_t asocs;
+
+ /* This is a signature that lets us know that this is a
+ * sctp_association_t data structure. Used for mapping an
+ * association id to an association.
+ */
+ __u32 eyecatcher;
+
+ /* This is our parent endpoint. */
+ sctp_endpoint_t *ep;
+
+ /* These are those association elements needed in the cookie. */
+ sctp_cookie_t c;
+
+ /* This is all information about our peer. */
+ struct {
+ /* rwnd
+ *
+ * Peer Rwnd : Current calculated value of the peer's rwnd.
+ */
+ __u32 rwnd;
+
+ /* transport_addr_list
+ *
+ * Peer : A list of SCTP transport addresses that the
+ * Transport : peer is bound to. This information is derived
+ * Address : from the INIT or INIT ACK and is used to
+ * List : associate an inbound packet with a given
+ * : association. Normally this information is
+ * : hashed or keyed for quick lookup and access
+ * : of the TCB.
+ *
+ * It is a list of SCTP_transport's.
+ */
+ list_t transport_addr_list;
+
+ /* port
+ * The transport layer port number.
+ */
+ __u16 port;
+
+ /* primary_path
+ *
+ * Primary : This is the current primary destination
+ * Path : transport address of the peer endpoint. It
+ * : may also specify a source transport address
+ * : on this endpoint.
+ *
+ * All of these paths live on transport_addr_list.
+ *
+ * At the bakeoffs, we discovered that the intent of
+ * primaryPath is that it only changes when the ULP
+ * asks to have it changed. We add the activePath to
+ * designate the connection we are currently using to
+ * transmit new data and most control chunks.
+ */
+ sctp_transport_t *primary_path;
+
+ /* active_path
+ * The path that we are currently using to
+ * transmit new data and most control chunks.
+ */
+ sctp_transport_t *active_path;
+
+ /* retran_path
+ *
+ * RFC2960 6.4 Multi-homed SCTP Endpoints
+ * ...
+ * Furthermore, when its peer is multi-homed, an
+ * endpoint SHOULD try to retransmit a chunk to an
+ * active destination transport address that is
+ * different from the last destination address to
+ * which the DATA chunk was sent.
+ */
+ sctp_transport_t *retran_path;
+
+ /* Pointer to last transport I have sent on. */
+ sctp_transport_t *last_sent_to;
+
+ /* This is the last transport I have recieved DATA on. */
+ sctp_transport_t *last_data_from;
+
+ /*
+ * Mapping An array of bits or bytes indicating which out of
+ * Array order TSN's have been received (relative to the
+ * Last Rcvd TSN). If no gaps exist, i.e. no out of
+ * order packets have been received, this array
+ * will be set to all zero. This structure may be
+ * in the form of a circular buffer or bit array.
+ *
+ * Last Rcvd : This is the last TSN received in
+ * TSN : sequence. This value is set initially by
+ * : taking the peer's Initial TSN, received in
+ * : the INIT or INIT ACK chunk, and subtracting
+ * : one from it.
+ *
+ * Throughout most of the specification this is called the
+ * "Cumulative TSN ACK Point". In this case, we
+ * ignore the advice in 12.2 in favour of the term
+ * used in the bulk of the text. This value is hidden
+ * in tsn_map--we get it by calling sctp_tsnmap_get_ctsn().
+ */
+ sctp_tsnmap_t tsn_map;
+ __u8 _map[sctp_tsnmap_storage_size(SCTP_TSN_MAP_SIZE)];
+
+ /* We record duplicate TSNs here. We clear this after
+ * every SACK.
+ * FIXME: We should move this into the tsnmap? --jgrimm
+ */
+ sctp_dup_tsn_t dup_tsns[SCTP_MAX_DUP_TSNS];
+ int next_dup_tsn;
+
+ /* Do we need to sack the peer? */
+ int sack_needed;
+
+ /* These are capabilities which our peer advertised. */
+ __u8 ecn_capable; /* Can peer do ECN? */
+ __u8 ipv4_address; /* Peer understands IPv4 addresses? */
+ __u8 ipv6_address; /* Peer understands IPv6 addresses? */
+ __u8 hostname_address;/* Peer understands DNS addresses? */
+ sctp_inithdr_t i;
+ int cookie_len;
+ void *cookie;
+
+ /* ADDIP Extention (ADDIP) --xguo */
+ /* <expected peer-serial-number> minus 1 (ADDIP sec. 4.2 C1) */
+ __u32 addip_serial;
+ } peer;
+
+ /* State : A state variable indicating what state the
+ * : association is in, i.e. COOKIE-WAIT,
+ * : COOKIE-ECHOED, ESTABLISHED, SHUTDOWN-PENDING,
+ * : SHUTDOWN-SENT, SHUTDOWN-RECEIVED, SHUTDOWN-ACK-SENT.
+ *
+ * Note: No "CLOSED" state is illustrated since if a
+ * association is "CLOSED" its TCB SHOULD be removed.
+ *
+ * In this implementation we DO have a CLOSED
+ * state which is used during initiation and shutdown.
+ *
+ * State takes values from SCTP_STATE_*.
+ */
+ sctp_state_t state;
+
+ /* When did we enter this state? */
+ int state_timestamp;
+
+ /* The cookie life I award for any cookie. */
+ struct timeval cookie_life;
+ __u32 cookie_preserve;
+
+ /* Overall : The overall association error count.
+ * Error Count : [Clear this any time I get something.]
+ */
+ int overall_error_count;
+
+ /* Overall : The threshold for this association that if
+ * Error : the Overall Error Count reaches will cause
+ * Threshold : this association to be torn down.
+ */
+ int overall_error_threshold;
+
+ /* These are the association's initial, max, and min RTO values.
+ * These values will be initialized by system defaults, but can
+ * be modified via the SCTP_RTOINFO socket option.
+ */
+ __u32 rto_initial;
+ __u32 rto_max;
+ __u32 rto_min;
+
+ /* Maximum number of new data packets that can be sent in a burst. */
+ int max_burst;
+
+ /* This is the max_retrans value for the association. This value will
+ * be initialized initialized from system defaults, but can be
+ * modified by the SCTP_ASSOCINFO socket option.
+ */
+ int max_retrans;
+
+ /* Maximum number of times the endpoint will retransmit INIT */
+ __u16 max_init_attempts;
+
+ /* How many times have we resent an INIT? */
+ __u16 init_retries;
+
+ /* The largest timeout or RTO value to use in attempting an INIT */
+ __u16 max_init_timeo;
+
+
+ int timeouts[SCTP_NUM_TIMEOUT_TYPES];
+ struct timer_list timers[SCTP_NUM_TIMEOUT_TYPES];
+
+ /* Transport to which SHUTDOWN chunk was last sent. */
+ sctp_transport_t *shutdown_last_sent_to;
+
+ /* Next TSN : The next TSN number to be assigned to a new
+ * : DATA chunk. This is sent in the INIT or INIT
+ * : ACK chunk to the peer and incremented each
+ * : time a DATA chunk is assigned a TSN
+ * : (normally just prior to transmit or during
+ * : fragmentation).
+ */
+ __u32 next_tsn;
+
+ /*
+ * Last Rcvd : This is the last TSN received in sequence. This value
+ * TSN : is set initially by taking the peer's Initial TSN,
+ * : received in the INIT or INIT ACK chunk, and
+ * : subtracting one from it.
+ *
+ * Most of RFC 2960 refers to this as the Cumulative TSN Ack Point.
+ */
+
+ __u32 ctsn_ack_point;
+
+ /* The number of unacknowledged data chunks. Reported through
+ * the SCTP_STATUS sockopt.
+ */
+ __u16 unack_data;
+
+ /* This is the association's receive buffer space. This value is used
+ * to set a_rwnd field in an INIT or a SACK chunk.
+ */
+ __u32 rwnd;
+
+ /* Number of bytes by which the rwnd has slopped. The rwnd is allowed
+ * to slop over a maximum of the association's frag_point.
+ */
+ __u32 rwnd_over;
+
+ /* This is the sndbuf size in use for the association.
+ * This corresponds to the sndbuf size for the association,
+ * as specified in the sk->sndbuf.
+ */
+ int sndbuf_used;
+
+ /* This is the wait queue head for send requests waiting on
+ * the association sndbuf space.
+ */
+ wait_queue_head_t wait;
+
+ /* Association : The smallest PMTU discovered for all of the
+ * PMTU : peer's transport addresses.
+ */
+ __u32 pmtu;
+
+ /* The message size at which SCTP fragmentation will occur. */
+ __u32 frag_point;
+
+ /* Ack State : This flag indicates if the next received
+ * : packet is to be responded to with a
+ * : SACK. This is initializedto 0. When a packet
+ * : is received it is incremented. If this value
+ * : reaches 2 or more, a SACK is sent and the
+ * : value is reset to 0. Note: This is used only
+ * : when no DATA chunks are received out of
+ * : order. When DATA chunks are out of order,
+ * : SACK's are not delayed (see Section 6).
+ */
+ /* Do we need to send an ack?
+ * When counters[SctpCounterAckState] is above 1 we do!
+ */
+ int counters[SCTP_NUMBER_COUNTERS];
+
+ struct {
+ __u16 stream;
+ __u32 ppid;
+ } defaults;
+
+ /* This tracks outbound ssn for a given stream. */
+ __u16 ssn[SCTP_MAX_STREAM];
+
+ /* All outbound chunks go through this structure. */
+ sctp_outqueue_t outqueue;
+
+ /* A smart pipe that will handle reordering and fragmentation,
+ * as well as handle passing events up to the ULP.
+ * In the future, we should make this at least dynamic, if
+ * not also some sparse structure.
+ */
+ sctp_ulpqueue_t ulpq;
+ __u8 _ssnmap[sctp_ulpqueue_storage_size(SCTP_MAX_STREAM)];
+
+ /* Need to send an ECNE Chunk? */
+ int need_ecne;
+
+ /* Last TSN that caused an ECNE Chunk to be sent. */
+ __u32 last_ecne_tsn;
+
+ /* Last TSN that caused a CWR Chunk to be sent. */
+ __u32 last_cwr_tsn;
+
+ /* How many duplicated TSNs have we seen? */
+ int numduptsns;
+
+ /* Number of seconds of idle time before an association is closed. */
+ __u32 autoclose;
+
+ /* Name for debugging output... */
+ char *debug_name;
+
+ /* These are to support
+ * "SCTP Extensions for Dynamic Reconfiguration of IP Addresses
+ * and Enforcement of Flow and Message Limits"
+ * <draft-ietf-tsvwg-addip-sctp-02.txt>
+ * or "ADDIP" for short.
+ */
+
+ /* Is the ADDIP extension enabled for this association? */
+ int addip_enable;
+
+ /* ADDIP Section 4.1.1 Congestion Control of ASCONF Chunks
+ *
+ * R1) One and only one ASCONF Chunk MAY be in transit and
+ * unacknowledged at any one time. If a sender, after sending
+ * an ASCONF chunk, decides it needs to transfer another
+ * ASCONF Chunk, it MUST wait until the ASCONF-ACK Chunk
+ * returns from the previous ASCONF Chunk before sending a
+ * subsequent ASCONF. Note this restriction binds each side,
+ * so at any time two ASCONF may be in-transit on any given
+ * association (one sent from each endpoint).
+ *
+ * [This is our one-and-only-one ASCONF in flight. If we do
+ * not have an ASCONF in flight, this is NULL.]
+ */
+ sctp_chunk_t *addip_last_asconf;
+
+ /* ADDIP Section 4.2 Upon reception of an ASCONF Chunk.
+ *
+ * IMPLEMENTATION NOTE: As an optimization a receiver may wish
+ * to save the last ASCONF-ACK for some predetermined period
+ * of time and instead of re-processing the ASCONF (with the
+ * same serial number) it may just re-transmit the
+ * ASCONF-ACK. It may wish to use the arrival of a new serial
+ * number to discard the previously saved ASCONF-ACK or any
+ * other means it may choose to expire the saved ASCONF-ACK.
+ *
+ * [This is our saved ASCONF-ACK. We invalidate it when a new
+ * ASCONF serial number arrives.]
+ */
+ sctp_chunk_t *addip_last_asconf_ack;
+
+ /* These ASCONF chunks are waiting to be sent.
+ *
+ * These chunaks can't be pushed to outqueue until receiving
+ * ASCONF_ACK for the previous ASCONF indicated by
+ * addip_last_asconf, so as to guarantee that only one ASCONF
+ * is in flight at any time.
+ *
+ * ADDIP Section 4.1.1 Congestion Control of ASCONF Chunks
+ *
+ * In defining the ASCONF Chunk transfer procedures, it is
+ * essential that these transfers MUST NOT cause congestion
+ * within the network. To achieve this, we place these
+ * restrictions on the transfer of ASCONF Chunks:
+ *
+ * R1) One and only one ASCONF Chunk MAY be in transit and
+ * unacknowledged at any one time. If a sender, after sending
+ * an ASCONF chunk, decides it needs to transfer another
+ * ASCONF Chunk, it MUST wait until the ASCONF-ACK Chunk
+ * returns from the previous ASCONF Chunk before sending a
+ * subsequent ASCONF. Note this restriction binds each side,
+ * so at any time two ASCONF may be in-transit on any given
+ * association (one sent from each endpoint).
+ *
+ *
+ * [I really think this is EXACTLY the sort of intelligence
+ * which already resides in SCTP_outqueue. Please move this
+ * queue and its supporting logic down there. --piggy]
+ */
+ struct sk_buff_head addip_chunks;
+
+ /* ADDIP Section 4.1 ASCONF Chunk Procedures
+ *
+ * A2) A serial number should be assigned to the Chunk. The
+ * serial number should be a monotonically increasing
+ * number. All serial numbers are defined to be initialized at
+ * the start of the association to the same value as the
+ * Initial TSN.
+ *
+ * [and]
+ *
+ * ADDIP
+ * 3.1.1 Address/Stream Configuration Change Chunk (ASCONF)
+ *
+ * Serial Number : 32 bits (unsigned integer)
+ *
+ * This value represents a Serial Number for the ASCONF
+ * Chunk. The valid range of Serial Number is from 0 to
+ * 4294967295 (2**32 - 1). Serial Numbers wrap back to 0
+ * after reaching 4294967295.
+ */
+ __u32 addip_serial;
+};
+
+
+/* An eyecatcher for determining if we are really looking at an
+ * association data structure.
+ */
+enum {
+ SCTP_ASSOC_EYECATCHER = 0xa550c123,
+};
+
+/* Recover the outter association structure. */
+static inline sctp_association_t *sctp_assoc(sctp_endpoint_common_t *base)
+{
+ sctp_association_t *asoc;
+
+ /* We are not really a list, but the list_entry() macro is
+ * really quite generic find the address of an outter struct.
+ */
+ asoc = list_entry(base, sctp_association_t, base);
+ return asoc;
+}
+
+/* These are function signatures for manipulating associations. */
+
+
+sctp_association_t *
+sctp_association_new(const sctp_endpoint_t *, const struct sock *,
+ sctp_scope_t scope, int priority);
+sctp_association_t *
+sctp_association_init(sctp_association_t *, const sctp_endpoint_t *,
+ const struct sock *, sctp_scope_t scope,
+ int priority);
+void sctp_association_free(sctp_association_t *);
+void sctp_association_put(sctp_association_t *);
+void sctp_association_hold(sctp_association_t *);
+
+sctp_transport_t *sctp_assoc_choose_shutdown_transport(sctp_association_t *);
+sctp_transport_t *sctp_assoc_lookup_paddr(const sctp_association_t *,
+ const sockaddr_storage_t *);
+sctp_transport_t *sctp_assoc_add_peer(sctp_association_t *,
+ const sockaddr_storage_t *address,
+ const int priority);
+void sctp_assoc_control_transport(sctp_association_t *, sctp_transport_t *,
+ sctp_transport_cmd_t, sctp_sn_error_t);
+sctp_transport_t *sctp_assoc_lookup_tsn(sctp_association_t *, __u32);
+sctp_transport_t *sctp_assoc_is_match(sctp_association_t *,
+ const sockaddr_storage_t *,
+ const sockaddr_storage_t *);
+void sctp_assoc_migrate(sctp_association_t *, struct sock *);
+void sctp_assoc_update(sctp_association_t *dst, sctp_association_t *src);
+
+__u32 __sctp_association_get_next_tsn(sctp_association_t *);
+__u32 __sctp_association_get_tsn_block(sctp_association_t *, int);
+__u16 __sctp_association_get_next_ssn(sctp_association_t *, __u16 sid);
+
+int sctp_cmp_addr(const sockaddr_storage_t *ss1,
+ const sockaddr_storage_t *ss2);
+int sctp_cmp_addr_exact(const sockaddr_storage_t *ss1,
+ const sockaddr_storage_t *ss2);
+sctp_chunk_t *sctp_get_ecne_prepend(sctp_association_t *asoc);
+sctp_chunk_t *sctp_get_no_prepend(sctp_association_t *asoc);
+
+
+/* A convenience structure to parse out SCTP specific CMSGs. */
+typedef struct sctp_cmsgs {
+ struct sctp_initmsg *init;
+ struct sctp_sndrcvinfo *info;
+} sctp_cmsgs_t;
+
+/* Structure for tracking memory objects */
+typedef struct {
+ char *label;
+ atomic_t *counter;
+} sctp_dbg_objcnt_entry_t;
+
+#endif /* __sctp_structs_h__ */
diff --git a/include/net/sctp/sctp_tsnmap.h b/include/net/sctp/sctp_tsnmap.h
new file mode 100644
index 000000000000..2d75c3fc4d61
--- /dev/null
+++ b/include/net/sctp/sctp_tsnmap.h
@@ -0,0 +1,161 @@
+/* SCTP kernel reference Implementation Copyright (C) 1999-2001
+ * Cisco, Motorola, Intel, and International Business Machines Corp.
+ *
+ * This file is part of the SCTP kernel reference Implementation
+ *
+ * $Header: /cvsroot/lksctp/lksctp/sctp_cvs/include/net/sctp/sctp_tsnmap.h,v 1.8 2002/07/16 14:51:58 jgrimm Exp $
+ *
+ * These are the definitions needed for the tsnmap type. The tsnmap is used
+ * to track out of order TSNs received.
+ *
+ * The SCTP reference implementation is free software;
+ * you can redistribute it and/or modify it under the terms of
+ * the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * the SCTP reference implementation is distributed in the hope that it
+ * will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * ************************
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU CC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Please send any bug reports or fixes you make to one of the
+ * following email addresses:
+ *
+ * Jon Grimm <jgrimm@us.ibm.com>
+ * La Monte H.P. Yarroll <piggy@acm.org>
+ * Karl Knutson <karl@athena.chicago.il.us>
+ *
+ * Any bugs reported given to us we will try to fix... any fixes shared will
+ * be incorporated into the next SCTP release.
+ */
+#include <net/sctp/sctp_constants.h>
+
+#ifndef __sctp_tsnmap_h__
+#define __sctp_tsnmap_h__
+
+
+
+/* RFC 2960 12.2 Parameters necessary per association (i.e. the TCB)
+ * Mapping An array of bits or bytes indicating which out of
+ * Array order TSN's have been received (relative to the
+ * Last Rcvd TSN). If no gaps exist, i.e. no out of
+ * order packets have been received, this array
+ * will be set to all zero. This structure may be
+ * in the form of a circular buffer or bit array.
+ */
+typedef struct sctp_tsnmap {
+
+
+ /* This array counts the number of chunks with each TSN.
+ * It points at one of the two buffers with which we will
+ * ping-pong between.
+ */
+ __u8 *tsn_map;
+
+ /* This marks the tsn which overflows the tsn_map, when the
+ * cumulative ack point reaches this point we know we can switch
+ * maps (tsn_map and overflow_map swap).
+ */
+ __u32 overflow_tsn;
+
+ /* This is the overflow array for tsn_map.
+ * It points at one of the other ping-pong buffers.
+ */
+ __u8 *overflow_map;
+
+ /* This is the TSN at tsn_map[0]. */
+ __u32 base_tsn;
+
+ /* Last Rcvd : This is the last TSN received in
+ * TSN : sequence. This value is set initially by
+ * : taking the peer's Initial TSN, received in
+ * : the INIT or INIT ACK chunk, and subtracting
+ * : one from it.
+ *
+ * Throughout most of the specification this is called the
+ * "Cumulative TSN ACK Point". In this case, we
+ * ignore the advice in 12.2 in favour of the term
+ * used in the bulk of the text.
+ */
+ __u32 cumulative_tsn_ack_point;
+
+ /* This is the minimum number of TSNs we can track. This corresponds
+ * to the size of tsn_map. Note: the overflow_map allows us to
+ * potentially track more than this quantity.
+ */
+ __u16 len;
+
+ /* This is the highest TSN we've marked. */
+ __u32 max_tsn_seen;
+
+ /* No. of data chunks pending receipt. used by SCTP_STATUS sockopt */
+ __u16 pending_data;
+
+ int malloced;
+
+ __u8 raw_map[0];
+} sctp_tsnmap_t;
+
+typedef struct sctp_tsnmap_iter {
+ __u32 start;
+} sctp_tsnmap_iter_t;
+
+
+/* Create a new tsnmap. */
+sctp_tsnmap_t *sctp_tsnmap_new(__u16 len, __u32 initial_tsn,
+ int priority);
+
+/* Dispose of a tsnmap. */
+void sctp_tsnmap_free(sctp_tsnmap_t *map);
+
+/* This macro assists in creation of external storage for variable length
+ * internal buffers. We double allocate so the overflow map works.
+ */
+#define sctp_tsnmap_storage_size(count) (sizeof(__u8) * (count) * 2)
+
+/* Initialize a block of memory as a tsnmap. */
+sctp_tsnmap_t *sctp_tsnmap_init(sctp_tsnmap_t *map, __u16 len, __u32 initial_tsn);
+
+
+
+/* Test the tracking state of this TSN.
+ * Returns:
+ * 0 if the TSN has not yet been seen
+ * >0 if the TSN has been seen (duplicate)
+ * <0 if the TSN is invalid (too large to track)
+ */
+int sctp_tsnmap_check(const sctp_tsnmap_t *map, __u32 tsn);
+
+/* Mark this TSN as seen. */
+void sctp_tsnmap_mark(sctp_tsnmap_t *map, __u32 tsn);
+
+/* Retrieve the Cumulative TSN ACK Point. */
+__u32 sctp_tsnmap_get_ctsn(const sctp_tsnmap_t *map);
+
+/* Retrieve the highest TSN we've seen. */
+__u32 sctp_tsnmap_get_max_tsn_seen(const sctp_tsnmap_t *map);
+
+/* Is there a gap in the TSN map? */
+int sctp_tsnmap_has_gap(const sctp_tsnmap_t *map);
+
+/* Initialize a gap ack block interator from user-provided memory. */
+void sctp_tsnmap_iter_init(const sctp_tsnmap_t *map, sctp_tsnmap_iter_t *iter);
+
+/* Get the next gap ack blocks. We return 0 if there are no more
+ * gap ack blocks.
+ */
+int sctp_tsnmap_next_gap_ack(const sctp_tsnmap_t *map, sctp_tsnmap_iter_t *iter,
+ __u16 *start, __u16 *end);
+
+
+#endif /* __sctp_tsnmap_h__ */
+
+
+
diff --git a/include/net/sctp/sctp_ulpevent.h b/include/net/sctp/sctp_ulpevent.h
new file mode 100644
index 000000000000..75e8ba9efc05
--- /dev/null
+++ b/include/net/sctp/sctp_ulpevent.h
@@ -0,0 +1,137 @@
+/* SCTP kernel reference Implementation
+ * Copyright (c) 1999-2000 Cisco, Inc.
+ * Copyright (c) 1999-2001 Motorola, Inc.
+ * Copyright (c) 2001 International Business Machines, Corp.
+ * Copyright (c) 2001 Intel Corp.
+ * Copyright (c) 2001 Nokia, Inc.
+ * Copyright (c) 2001 La Monte H.P. Yarroll
+ *
+ * $Header: /cvsroot/lksctp/lksctp/sctp_cvs/include/net/sctp/sctp_ulpevent.h,v 1.5 2002/07/12 14:50:25 jgrimm Exp $
+ *
+ * These are the definitions needed for the sctp_ulpevent type. The
+ * sctp_ulpevent type is used to carry information from the state machine
+ * upwards to the ULP.
+ *
+ * The SCTP reference implementation is free software;
+ * you can redistribute it and/or modify it under the terms of
+ * the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * the SCTP reference implementation is distributed in the hope that it
+ * will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * ************************
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU CC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Please send any bug reports or fixes you make to one of the
+ * following email addresses:
+ *
+ * Jon Grimm <jgrimm@us.ibm.com>
+ * La Monte H.P. Yarroll <piggy@acm.org>
+ * Karl Knutson <karl@athena.chicago.il.us>
+ *
+ * Any bugs reported given to us we will try to fix... any fixes shared will
+ * be incorporated into the next SCTP release.
+ */
+
+
+#ifndef __sctp_ulpevent_h__
+#define __sctp_ulpevent_h__
+
+/* A structure to carry information to the ULP (e.g. Sockets API) */
+/* Warning: This sits inside an skb.cb[] area. Be very careful of
+ * growing this structure as it is at the maximum limit now.
+ */
+typedef struct sctp_ulpevent {
+ int malloced;
+ sctp_association_t *asoc;
+ struct sk_buff *parent;
+ struct sctp_sndrcvinfo sndrcvinfo;
+ int chunk_flags; /* Temp. until we get a new chunk_t */
+ int msg_flags;
+} sctp_ulpevent_t;
+
+
+sctp_ulpevent_t *sctp_ulpevent_new(int size, int msg_flags, int priority);
+
+sctp_ulpevent_t *sctp_ulpevent_init(sctp_ulpevent_t *event, struct sk_buff *skb, int msg_flags);
+
+void sctp_ulpevent_free(sctp_ulpevent_t *event);
+
+int sctp_ulpevent_is_notification(const sctp_ulpevent_t *event);
+
+sctp_ulpevent_t *sctp_ulpevent_make_assoc_change(
+ const struct SCTP_association *asoc,
+ __u16 flags,
+ __u16 state,
+ __u16 error,
+ __u16 outbound,
+ __u16 inbound,
+ int priority);
+
+sctp_ulpevent_t *sctp_ulpevent_make_peer_addr_change(
+ const struct SCTP_association *asoc,
+ const struct sockaddr_storage *aaddr,
+ int flags,
+ int state,
+ int error,
+ int priority);
+
+sctp_ulpevent_t *sctp_ulpevent_make_remote_error(
+ const struct SCTP_association *asoc,
+ struct SCTP_chunk *chunk,
+ __u16 flags,
+ int priority);
+sctp_ulpevent_t *sctp_ulpevent_make_send_failed(
+ const struct SCTP_association *asoc,
+ struct SCTP_chunk *chunk,
+ __u16 flags,
+ __u32 error,
+ int priority);
+
+sctp_ulpevent_t *sctp_ulpevent_make_shutdown_event(
+ const struct SCTP_association *asoc,
+ __u16 flags,
+ int priority);
+
+sctp_ulpevent_t *sctp_ulpevent_make_rcvmsg(struct SCTP_association *asoc,
+ struct SCTP_chunk *chunk,
+ int priority);
+
+void sctp_ulpevent_read_sndrcvinfo(const sctp_ulpevent_t *event,
+ struct msghdr *msghdr);
+
+__u16 sctp_ulpevent_get_notification_type(const sctp_ulpevent_t *event);
+
+
+
+/* Given an event subscription, is this event enabled? */
+static inline int sctp_ulpevent_is_enabled(const sctp_ulpevent_t *event,
+ const struct sctp_event_subscribe *mask)
+{
+ const char *amask = (const char *) mask;
+ __u16 sn_type;
+ int enabled = 1;
+
+ if (sctp_ulpevent_is_notification(event)) {
+ sn_type = sctp_ulpevent_get_notification_type(event);
+ enabled = amask[sn_type - SCTP_SN_TYPE_BASE];
+ }
+ return enabled;
+}
+
+
+#endif /* __sctp_ulpevent_h__ */
+
+
+
+
+
+
+
diff --git a/include/net/sctp/sctp_ulpqueue.h b/include/net/sctp/sctp_ulpqueue.h
new file mode 100644
index 000000000000..83c1b9749659
--- /dev/null
+++ b/include/net/sctp/sctp_ulpqueue.h
@@ -0,0 +1,95 @@
+/* SCTP kernel reference Implementation
+ * Copyright (c) 1999-2000 Cisco, Inc.
+ * Copyright (c) 1999-2001 Motorola, Inc.
+ * Copyright (c) 2001 International Business Machines, Corp.
+ * Copyright (c) 2001 Intel Corp.
+ * Copyright (c) 2001 Nokia, Inc.
+ * Copyright (c) 2001 La Monte H.P. Yarroll
+ *
+ * $Header: /cvsroot/lksctp/lksctp/sctp_cvs/include/net/sctp/sctp_ulpqueue.h,v 1.2 2002/07/12 14:50:25 jgrimm Exp $
+ *
+ * These are the definitions needed for the sctp_ulpqueue type. The
+ * sctp_ulpqueue is the interface between the Upper Layer Protocol, or ULP,
+ * and the core SCTP state machine. This is the component which handles
+ * reassembly and ordering.
+ *
+ * The SCTP reference implementation is free software;
+ * you can redistribute it and/or modify it under the terms of
+ * the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * the SCTP reference implementation is distributed in the hope that it
+ * will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * ************************
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU CC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Please send any bug reports or fixes you make to one of the
+ * following email addresses:
+ *
+ * Jon Grimm <jgrimm@us.ibm.com>
+ * La Monte H.P. Yarroll <piggy@acm.org>
+ *
+ * Any bugs reported given to us we will try to fix... any fixes shared will
+ * be incorporated into the next SCTP release.
+ */
+
+#ifndef __sctp_ulpqueue_h__
+#define __sctp_ulpqueue_h__
+
+/* A structure to carry information to the ULP (e.g. Sockets API) */
+typedef struct sctp_ulpqueue {
+ int malloced;
+ spinlock_t lock;
+ sctp_association_t *asoc;
+ struct sk_buff_head reasm;
+ struct sk_buff_head lobby;
+ __u16 ssn[0];
+} sctp_ulpqueue_t;
+
+/* This macro assists in creation of external storage for variable length
+ * internal buffers.
+ */
+#define sctp_ulpqueue_storage_size(inbound) (sizeof(__u16) * (inbound))
+
+sctp_ulpqueue_t *sctp_ulpqueue_new(sctp_association_t *asoc,
+ __u16 inbound,
+ int priority);
+
+sctp_ulpqueue_t *sctp_ulpqueue_init(sctp_ulpqueue_t *ulpq,
+ sctp_association_t *asoc,
+ __u16 inbound);
+
+void sctp_ulpqueue_free(sctp_ulpqueue_t *);
+
+
+/* Add a new DATA chunk for processing. */
+int sctp_ulpqueue_tail_data(sctp_ulpqueue_t *,
+ sctp_chunk_t *chunk,
+ int priority);
+
+
+/* Add a new event for propogation to the ULP. */
+int sctp_ulpqueue_tail_event(sctp_ulpqueue_t *,
+ sctp_ulpevent_t *event);
+
+
+/* Is the ulpqueue empty. */
+int sctp_ulpqueue_is_empty(sctp_ulpqueue_t *);
+
+int sctp_ulpqueue_is_data_empty(sctp_ulpqueue_t *);
+
+#endif /* __sctp_ulpqueue_h__ */
+
+
+
+
+
+
+
diff --git a/include/net/sctp/sctp_user.h b/include/net/sctp/sctp_user.h
new file mode 100644
index 000000000000..54eaadd802e2
--- /dev/null
+++ b/include/net/sctp/sctp_user.h
@@ -0,0 +1,609 @@
+/* SCTP kernel reference Implementation
+ * Copyright (c) 1999-2000 Cisco, Inc.
+ * Copyright (c) 1999-2001 Motorola, Inc.
+ * Copyright (c) 2001 International Business Machines, Corp.
+ *
+ * This file is part of the SCTP kernel reference Implementation
+ *
+ * $Header: /cvsroot/lksctp/lksctp/sctp_cvs/include/net/sctp/sctp_user.h,v 1.17 2002/07/29 21:04:23 jgrimm Exp $
+ *
+ * This header represents the structures and constants needed to support
+ * the SCTP Extension to the Sockets API.
+ *
+ * The SCTP reference implementation is free software;
+ * you can redistribute it and/or modify it under the terms of
+ * the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * The SCTP reference implementation is distributed in the hope that it
+ * will be useful, but WITHOUT ANY WARRANTY; without even the implied
+ * ************************
+ * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GNU CC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * Please send any bug reports or fixes you make to the
+ * email address(es):
+ * lksctp developers <lksctp-developers@lists.sourceforge.net>
+ *
+ * Or submit a bug report through the following website:
+ * http://www.sf.net/projects/lksctp
+ *
+ * Written or modified by:
+ * La Monte H.P. Yarroll <piggy@acm.org>
+ * R. Stewart <randall@sctp.chicago.il.us>
+ * K. Morneau <kmorneau@cisco.com>
+ * Q. Xie <qxie1@email.mot.com>
+ * Karl Knutson <karl@athena.chicago.il.us>
+ * Jon Grimm <jgrimm@us.ibm.com>
+ * Daisy Chang <daisyc@us.ibm.com>
+ *
+ *
+ * Any bugs reported given to us we will try to fix... any fixes shared will
+ * be incorporated into the next SCTP release.
+ */
+#include <linux/types.h>
+#include <linux/socket.h>
+
+#ifndef __net_sctp_user_h__
+#define __net_sctp_user_h__
+
+
+typedef void * sctp_assoc_t;
+
+/* The following symbols come from the Sockets API Extensions for
+ * SCTP <draft-ietf-tsvwg-sctpsocket-04.txt>.
+ */
+enum sctp_optname {
+ SCTP_RTOINFO,
+#define SCTP_RTOINFO SCTP_RTOINFO
+ SCTP_ASSOCRTXINFO,
+#define SCTP_ASSOCRTXINFO SCTP_ASSOCRTXINFO
+ SCTP_INITMSG,
+#define SCTP_INITMSG SCTP_INITMSG
+ SCTP_AUTO_CLOSE,
+#define SCTP_AUTO_CLOSE SCTP_AUTO_CLOSE
+ SCTP_SET_PRIMARY_ADDR,
+#define SCTP_SET_PRIMARY_ADDR SCTP_SET_PRIMARY_ADDR
+ SCTP_SET_PEER_PRIMARY_ADDR,
+#define SCTP_SET_PEER_PRIMARY_ADDR SCTP_SET_PEER_PRIMARY_ADDR
+ SCTP_SET_ADAPTATION_LAYER,
+#define SCTP_SET_ADAPTATION_LAYER SCTP_SET_ADAPTATION_LAYER
+ SCTP_SET_STREAM_TIMEOUTS,
+#define SCTP_SET_STREAM_TIMEOUTS SCTP_SET_STREAM_TIMEOUTS
+ SCTP_DISABLE_FRAGMENTS,
+#define SCTP_DISABLE_FRAGMENTS SCTP_DISABLE_FRAGMENTS
+ SCTP_SET_PEER_ADDR_PARAMS,
+#define SCTP_SET_PEER_ADDR_PARAMS SCTP_SET_PEER_ADDR_PARAMS
+ SCTP_GET_PEER_ADDR_PARAMS,
+#define SCTP_GET_PEER_ADDR_PARAMS SCTP_GET_PEER_ADDR_PARAMS
+ SCTP_STATUS,
+#define SCTP_STATUS SCTP_STATUS
+ SCTP_GET_PEER_ADDR_INFO,
+#define SCTP_GET_PEER_ADDR_INFO SCTP_GET_PEER_ADDR_INFO
+ SCTP_SET_EVENTS,
+#define SCTP_SET_EVENTS SCTP_SET_EVENTS
+ SCTP_AUTOCLOSE,
+#define SCTP_AUTOCLOSE SCTP_AUTOCLOSE
+ SCTP_SET_DEFAULT_SEND_PARAM,
+#define SCTP_SET_DEFAULT_SEND_PARAM SCTP_SET_DEFAULT_SEND_PARAM
+
+ SCTP_SOCKOPT_DEBUG_NAME = 42, /* FIXME */
+#define SCTP_SOCKOPT_DEBUG_NAME SCTP_SOCKOPT_DEBUG_NAME
+
+ SCTP_SOCKOPT_BINDX_ADD, /* BINDX requests for adding addresses. */
+#define SCTP_SOCKOPT_BINDX_ADD SCTP_SOCKOPT_BINDX_ADD
+ SCTP_SOCKOPT_BINDX_REM, /* BINDX requests for removing addresses. */
+#define SCTP_SOCKOPT_BINDX_REM SCTP_SOCKOPT_BINDX_REM
+ SCTP_SOCKOPT_PEELOFF, /* peel off association. */
+#define SCTP_SOCKOPT_PEELOFF SCTP_SOCKOPT_PEELOFF
+};
+
+
+/*
+ * 5.2 SCTP msg_control Structures
+ *
+ * A key element of all SCTP-specific socket extensions is the use of
+ * ancillary data to specify and access SCTP-specific data via the
+ * struct msghdr's msg_control member used in sendmsg() and recvmsg().
+ * Fine-grained control over initialization and sending parameters are
+ * handled with ancillary data.
+ *
+ * Each ancillary data item is preceeded by a struct cmsghdr (see
+ * Section 5.1), which defines the function and purpose of the data
+ * contained in in the cmsg_data[] member.
+ */
+
+/*
+ * 5.2.1 SCTP Initiation Structure (SCTP_INIT)
+ *
+ * This cmsghdr structure provides information for initializing new
+ * SCTP associations with sendmsg(). The SCTP_INITMSG socket option
+ * uses this same data structure. This structure is not used for
+ * recvmsg().
+ *
+ * cmsg_level cmsg_type cmsg_data[]
+ * ------------ ------------ ----------------------
+ * IPPROTO_SCTP SCTP_INIT struct sctp_initmsg
+ *
+ */
+struct sctp_initmsg {
+ __u16 sinit_num_ostreams;
+ __u16 sinit_max_instreams;
+ __u16 sinit_max_attempts;
+ __u16 sinit_max_init_timeo;
+};
+
+
+/*
+ * 5.2.2 SCTP Header Information Structure (SCTP_SNDRCV)
+ *
+ * This cmsghdr structure specifies SCTP options for sendmsg() and
+ * describes SCTP header information about a received message through
+ * recvmsg().
+ *
+ * cmsg_level cmsg_type cmsg_data[]
+ * ------------ ------------ ----------------------
+ * IPPROTO_SCTP SCTP_SNDRCV struct sctp_sndrcvinfo
+ *
+ */
+struct sctp_sndrcvinfo {
+ __u16 sinfo_stream;
+ __u16 sinfo_ssn;
+ __u16 sinfo_flags;
+ __u32 sinfo_ppid;
+ __u32 sinfo_context;
+ __u32 sinfo_timetolive;
+ __u32 sinfo_tsn;
+ sctp_assoc_t sinfo_assoc_id;
+};
+
+/*
+ * sinfo_flags: 16 bits (unsigned integer)
+ *
+ * This field may contain any of the following flags and is composed of
+ * a bitwise OR of these values.
+ */
+
+enum sctp_sinfo_flags {
+ MSG_UNORDERED = 1, /* Send/recieve message unordered. */
+ MSG_ADDR_OVER = 2, /* Override the primary destination. */
+ MSG_ABORT=4, /* Send an ABORT message to the peer. */
+ /* MSG_EOF is already defined per socket.h */
+};
+
+
+typedef union {
+ __u8 raw;
+ struct sctp_initmsg init;
+ struct sctp_sndrcvinfo sndrcv;
+} sctp_cmsg_data_t;
+
+/* These are cmsg_types. */
+typedef enum sctp_cmsg_type {
+ SCTP_INIT, /* 5.2.1 SCTP Initiation Structure */
+ SCTP_SNDRCV, /* 5.2.2 SCTP Header Information Structure */
+} sctp_cmsg_t;
+
+
+/*
+ * 5.3.1.1 SCTP_ASSOC_CHANGE
+ *
+ * Communication notifications inform the ULP that an SCTP association
+ * has either begun or ended. The identifier for a new association is
+ * provided by this notificaion. The notification information has the
+ * following format:
+ *
+ */
+
+struct sctp_assoc_change {
+ __u16 sac_type;
+ __u16 sac_flags;
+ __u32 sac_length;
+ __u16 sac_state;
+ __u16 sac_error;
+ __u16 sac_outbound_streams;
+ __u16 sac_inbound_streams;
+ sctp_assoc_t sac_assoc_id;
+};
+
+/*
+ * sac_state: 32 bits (signed integer)
+ *
+ * This field holds one of a number of values that communicate the
+ * event that happened to the association. They include:
+ *
+ * Note: The following state names deviate from the API draft as
+ * the names clash too easily with other kernel symbols.
+ */
+enum sctp_sac_state {
+ SCTP_COMM_UP,
+ SCTP_COMM_LOST,
+ SCTP_RESTART,
+ SCTP_SHUTDOWN_COMP,
+ SCTP_CANT_STR_ASSOC,
+};
+
+/*
+ * 5.3.1.2 SCTP_PEER_ADDR_CHANGE
+ *
+ * When a destination address on a multi-homed peer encounters a change
+ * an interface details event is sent. The information has the
+ * following structure:
+ */
+struct sctp_paddr_change {
+ __u16 spc_type;
+ __u16 spc_flags;
+ __u32 spc_length;
+ struct sockaddr_storage spc_aaddr;
+ int spc_state;
+ int spc_error;
+ sctp_assoc_t spc_assoc_id;
+};
+
+/*
+ * spc_state: 32 bits (signed integer)
+ *
+ * This field holds one of a number of values that communicate the
+ * event that happened to the address. They include:
+ */
+enum sctp_spc_state {
+ ADDRESS_AVAILABLE,
+ ADDRESS_UNREACHABLE,
+ ADDRESS_REMOVED,
+ ADDRESS_ADDED,
+ ADDRESS_MADE_PRIM,
+};
+
+
+/*
+ * 5.3.1.3 SCTP_REMOTE_ERROR
+ *
+ * A remote peer may send an Operational Error message to its peer.
+ * This message indicates a variety of error conditions on an
+ * association. The entire error TLV as it appears on the wire is
+ * included in a SCTP_REMOTE_ERROR event. Please refer to the SCTP
+ * specification [SCTP] and any extensions for a list of possible
+ * error formats. SCTP error TLVs have the format:
+ */
+struct sctp_remote_error {
+ __u16 sre_type;
+ __u16 sre_flags;
+ __u32 sre_length;
+ __u16 sre_error;
+ __u16 sre_len;
+ sctp_assoc_t sre_assoc_id;
+ __u8 sre_data[0];
+};
+
+
+/*
+ * 5.3.1.4 SCTP_SEND_FAILED
+ *
+ * If SCTP cannot deliver a message it may return the message as a
+ * notification.
+ */
+struct sctp_send_failed {
+ __u16 ssf_type;
+ __u16 ssf_flags;
+ __u32 ssf_length;
+ __u32 ssf_error;
+ struct sctp_sndrcvinfo ssf_info;
+ sctp_assoc_t ssf_assoc_id;
+ __u8 ssf_data[0];
+};
+
+/*
+ * ssf_flags: 16 bits (unsigned integer)
+ *
+ * The flag value will take one of the following values
+ *
+ * SCTP_DATA_UNSENT - Indicates that the data was never put on
+ * the wire.
+ *
+ * SCTP_DATA_SENT - Indicates that the data was put on the wire.
+ * Note that this does not necessarily mean that the
+ * data was (or was not) successfully delivered.
+ */
+
+enum sctp_ssf_flags {
+ SCTP_DATA_UNSENT,
+ SCTP_DATA_SENT,
+};
+
+/*
+ * 5.3.1.5 SCTP_SHUTDOWN_EVENT
+ *
+ * When a peer sends a SHUTDOWN, SCTP delivers this notification to
+ * inform the application that it should cease sending data.
+ */
+
+struct sctp_shutdown_event {
+ __u16 sse_type;
+ __u16 sse_flags;
+ __u32 sse_length;
+ sctp_assoc_t sse_assoc_id;
+};
+
+/*
+ * 5.3.1.6 SCTP_ADAPTION_INDICATION
+ *
+ * When a peer sends a Adaption Layer Indication parameter , SCTP
+ * delivers this notification to inform the application
+ * that of the peers requested adaption layer.
+ */
+struct sctp_adaption_event {
+ __u16 sai_type;
+ __u16 sai_flags;
+ __u32 sai_length;
+ __u32 sai_adaptation_bits;
+ sctp_assoc_t sse_assoc_id;
+};
+
+/*
+ * 5.3.1.7 SCTP_PARTIAL_DELIVERY_EVENT
+ *
+ * When a reciever is engaged in a partial delivery of a
+ * message this notification will be used to inidicate
+ * various events.
+ */
+
+struct sctp_rcv_pdapi_event {
+ __u16 pdapi_type;
+ __u16 pdapi_flags;
+ __u32 pdapi_length;
+ __u32 pdapi_indication;
+ sctp_assoc_t pdapi_assoc_id;
+};
+
+
+/*
+ * Described in Section 7.3
+ * Ancillary Data and Notification Interest Options
+ */
+struct sctp_event_subscribe {
+ __u8 sctp_data_io_event;
+ __u8 sctp_association_event;
+ __u8 sctp_address_event;
+ __u8 sctp_send_failure_event;
+ __u8 sctp_peer_error_event;
+ __u8 sctp_shutdown_event;
+ __u8 sctp_partial_delivery_event;
+ __u8 sctp_adaption_layer_event;
+};
+
+/*
+ * 5.3.1 SCTP Notification Structure
+ *
+ * The notification structure is defined as the union of all
+ * notification types.
+ *
+ */
+union sctp_notification {
+ struct {
+ __u16 sn_type; /* Notification type. */
+ __u16 sn_flags;
+ __u32 sn_length;
+ } h;
+ struct sctp_assoc_change sn_assoc_change;
+ struct sctp_paddr_change sn_padr_change;
+ struct sctp_remote_error sn_remote_error;
+ struct sctp_send_failed sn_send_failed;
+ struct sctp_shutdown_event sn_shutdown_event;
+ struct sctp_adaption_event sn_adaption_event;
+ struct sctp_rcv_pdapi_event sn_rcv_pdapi_event;
+};
+
+/* Section 5.3.1
+ * All standard values for sn_type flags are greater than 2^15.
+ * Values from 2^15 and down are reserved.
+ */
+
+enum sctp_sn_type {
+ SCTP_SN_TYPE_BASE = (1<<15),
+ SCTP_ASSOC_CHANGE,
+ SCTP_PEER_ADDR_CHANGE,
+ SCTP_REMOTE_ERROR,
+ SCTP_SEND_FAILED,
+ SCTP_SHUTDOWN_EVENT,
+ SCTP_PARTIAL_DELIVERY_EVENT,
+ SCTP_ADAPTION_INDICATION,
+};
+
+/* Notification error codes used to fill up the error fields in some
+ * notifications.
+ * SCTP_PEER_ADDRESS_CHAGE : spc_error
+ * SCTP_ASSOC_CHANGE : sac_error
+ * These names should be potentially included in the draft 04 of the SCTP
+ * sockets API specification.
+ */
+typedef enum sctp_sn_error {
+ SCTP_FAILED_THRESHOLD,
+ SCTP_RECEIVED_SACK,
+ SCTP_HEARTBEAT_SUCCESS,
+ SCTP_RESPONSE_TO_USER_REQ,
+ SCTP_INTERNAL_ERROR,
+ SCTP_SHUTDOWN_GUARD_EXPIRES,
+ SCTP_PEER_FAULTY,
+} sctp_sn_error_t;
+
+/*
+ *
+ * 7.1.14 Peer Address Parameters
+ *
+ * Applications can enable or disable heartbeats for any peer address
+ * of an association, modify an address's heartbeat interval, force a
+ * heartbeat to be sent immediately, and adjust the address's maximum
+ * number of retransmissions sent before an address is considered
+ * unreachable. The following structure is used to access and modify an
+ * address's parameters:
+ */
+
+struct sctp_paddrparams {
+ struct sockaddr_storage spp_address;
+ __u32 spp_hbinterval;
+ __u16 spp_pathmaxrxt;
+ sctp_assoc_t spp_assoc_id;
+};
+
+/*
+ * 7.2.2 Peer Address Information
+ *
+ * Applications can retrieve information about a specific peer address
+ * of an association, including its reachability state, congestion
+ * window, and retransmission timer values. This information is
+ * read-only. The following structure is used to access this
+ * information:
+ */
+
+struct sctp_paddrinfo {
+ sctp_assoc_t spinfo_assoc_id;
+ struct sockaddr_storage spinfo_address;
+ __s32 spinfo_state;
+ __u32 spinfo_cwnd;
+ __u32 spinfo_srtt;
+ __u32 spinfo_rto;
+ __u32 spinfo_mtu;
+};
+
+
+/*
+ * 7.1.1 Retransmission Timeout Parameters (SCTP_RTOINFO)
+ *
+ * The protocol parameters used to initialize and bound retransmission
+ * timeout (RTO) are tunable. See [SCTP] for more information on how
+ * these parameters are used in RTO calculation. The peer address
+ * parameter is ignored for TCP style socket.
+ */
+
+struct sctp_rtoinfo {
+ __u32 srto_initial;
+ __u32 srto_max;
+ __u32 srto_min;
+ sctp_assoc_t srto_assoc_id;
+};
+
+/*
+ * 7.1.2 Association Retransmission Parameter (SCTP_ASSOCRTXINFO)
+ *
+ * The protocol parameter used to set the number of retransmissions
+ * sent before an association is considered unreachable.
+ * See [SCTP] for more information on how this parameter is used. The
+ * peer address parameter is ignored for TCP style socket.
+ */
+
+struct sctp_assocparams {
+ __u16 sasoc_asocmaxrxt;
+ sctp_assoc_t sasoc_assoc_id;
+};
+
+
+/*
+ * 7.1.9 Set Primary Address (SCTP_SET_PRIMARY_ADDR)
+ *
+ * Requests that the peer mark the enclosed address as the association
+ * primary. The enclosed address must be one of the association's
+ * locally bound addresses. The following structure is used to make a
+ * set primary request:
+ */
+
+struct sctp_setprim {
+ struct sockaddr_storage ssp_addr;
+ sctp_assoc_t ssp_assoc_id;
+};
+
+/*
+ * 7.1.10 Set Peer Primary Address (SCTP_SET_PEER_PRIMARY_ADDR)
+ *
+ * Requests that the local SCTP stack use the enclosed peer address as
+ * the association primary. The enclosed address must be one of the
+ * association peer's addresses. The following structure is used to
+ * make a set peer primary request:
+ */
+
+struct sctp_setpeerprim {
+ struct sockaddr_storage sspp_addr;
+ sctp_assoc_t sspp_assoc_id;
+};
+
+/*
+ * 7.2.1 Association Status (SCTP_STATUS)
+ *
+ * Applications can retrieve current status information about an
+ * association, including association state, peer receiver window size,
+ * number of unacked data chunks, and number of data chunks pending
+ * receipt. This information is read-only. The following structure is
+ * used to access this information:
+ */
+struct sctp_status {
+ sctp_assoc_t sstat_assoc_id;
+ __s32 sstat_state;
+ __u32 sstat_rwnd;
+ __u16 sstat_unackdata;
+ __u16 sstat_penddata;
+ __u16 sstat_instrms;
+ __u16 sstat_outstrms;
+ __u32 sstat_fragmentation_point;
+ struct sctp_paddrinfo sstat_primary;
+};
+
+
+/*
+ * 7.1.12 Set Adaption Layer Indicator
+ *
+ * Requests that the local endpoint set the specified Adaption Layer
+ * Indication parameter for all future
+ * INIT and INIT-ACK exchanges.
+ */
+
+struct sctp_setadaption {
+ __u32 ssb_adaption_ind;
+};
+
+/*
+ * 7.1.12 Set default message time outs (SCTP_SET_STREAM_TIMEOUTS)
+ *
+ * This option requests that the requested stream apply a
+ * default time-out for messages in queue.
+ */
+struct sctp_setstrm_timeout {
+ sctp_assoc_t ssto_assoc_id;
+ __u32 ssto_timeout;
+ __u16 ssto_streamid_start;
+ __u16 ssto_streamid_end;
+};
+
+
+/* These are bit fields for msghdr->msg_flags. See section 5.1. */
+/* On user space Linux, these live in <bits/socket.h> as an enum. */
+enum sctp_msg_flags {
+ MSG_NOTIFICATION = 0x8000,
+#define MSG_NOTIFICATION MSG_NOTIFICATION
+};
+
+/*
+ * 8.1 sctp_bindx()
+ *
+ * The flags parameter is formed from the bitwise OR of zero or more of the
+ * following currently defined flags:
+ */
+#define BINDX_ADD_ADDR 0x01
+#define BINDX_REM_ADDR 0x02
+
+/* This is the structure that is passed as an argument(optval) to
+ * getsockopt(SCTP_SOCKOPT_PEELOFF).
+ */
+typedef struct {
+ sctp_assoc_t associd;
+ int sd;
+} sctp_peeloff_arg_t;
+
+#endif /* __net_sctp_user_h__ */
+
+
+
diff --git a/include/net/sock.h b/include/net/sock.h
index 57159c6ce0bd..ccf82ecab360 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -130,7 +130,7 @@ struct sock {
bsdism;
unsigned char debug;
unsigned char rcvtstamp;
- /* Hole of 1 byte. Try to pack. */
+ unsigned char no_largesend;
int route_caps;
int proc;
unsigned long lingertime;
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 07102180d2fa..e6382e0539e1 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -905,16 +905,21 @@ static inline void tcp_reset_xmit_timer(struct sock *sk, int what, unsigned long
/* Compute the current effective MSS, taking SACKs and IP options,
* and even PMTU discovery events into account.
+ *
+ * LARGESEND note: !urg_mode is overkill, only frames up to snd_up
+ * cannot be large. However, taking into account rare use of URG, this
+ * is not a big flaw.
*/
-static __inline__ unsigned int tcp_current_mss(struct sock *sk)
+static __inline__ unsigned int tcp_current_mss(struct sock *sk, int large)
{
struct tcp_opt *tp = tcp_sk(sk);
struct dst_entry *dst = __sk_dst_get(sk);
- int mss_now = tp->mss_cache;
+ int mss_now = large && (sk->route_caps&NETIF_F_TSO) && !tp->urg_mode ?
+ tp->mss_cache : tp->mss_cache_std;
if (dst && dst->pmtu != tp->pmtu_cookie)
- mss_now = tcp_sync_mss(sk, dst->pmtu);
+ mss_now = tcp_sync_mss(sk, dst->pmtu);
if (tp->eff_sacks)
mss_now -= (TCPOLEN_SACK_BASE_ALIGNED +
@@ -933,7 +938,7 @@ static __inline__ unsigned int tcp_current_mss(struct sock *sk)
static inline void tcp_initialize_rcv_mss(struct sock *sk)
{
struct tcp_opt *tp = tcp_sk(sk);
- unsigned int hint = min(tp->advmss, tp->mss_cache);
+ unsigned int hint = min(tp->advmss, tp->mss_cache_std);
hint = min(hint, tp->rcv_wnd/2);
hint = min(hint, TCP_MIN_RCVMSS);
@@ -1269,7 +1274,7 @@ static __inline__ void __tcp_push_pending_frames(struct sock *sk,
static __inline__ void tcp_push_pending_frames(struct sock *sk,
struct tcp_opt *tp)
{
- __tcp_push_pending_frames(sk, tp, tcp_current_mss(sk), tp->nonagle);
+ __tcp_push_pending_frames(sk, tp, tcp_current_mss(sk, 1), tp->nonagle);
}
static __inline__ int tcp_may_send_now(struct sock *sk, struct tcp_opt *tp)
@@ -1277,7 +1282,7 @@ static __inline__ int tcp_may_send_now(struct sock *sk, struct tcp_opt *tp)
struct sk_buff *skb = tp->send_head;
return (skb &&
- tcp_snd_test(tp, skb, tcp_current_mss(sk),
+ tcp_snd_test(tp, skb, tcp_current_mss(sk, 1),
tcp_skb_is_last(sk, skb) ? 1 : tp->nonagle));
}
@@ -1839,6 +1844,15 @@ static inline int tcp_paws_check(struct tcp_opt *tp, int rst)
return 1;
}
+static inline void tcp_v4_setup_caps(struct sock *sk, struct dst_entry *dst)
+{
+ sk->route_caps = dst->dev->features;
+ if (sk->route_caps & NETIF_F_TSO) {
+ if (sk->no_largesend)
+ sk->route_caps &= ~NETIF_F_TSO;
+ }
+}
+
#define TCP_CHECK_TIMER(sk) do { } while (0)
#endif /* _TCP_H */
diff --git a/include/net/tcp_ecn.h b/include/net/tcp_ecn.h
index d21c115a240d..3785af8bbe74 100644
--- a/include/net/tcp_ecn.h
+++ b/include/net/tcp_ecn.h
@@ -28,12 +28,13 @@ TCP_ECN_send_synack(struct tcp_opt *tp, struct sk_buff *skb)
}
static __inline__ void
-TCP_ECN_send_syn(struct tcp_opt *tp, struct sk_buff *skb)
+TCP_ECN_send_syn(struct sock *sk, struct tcp_opt *tp, struct sk_buff *skb)
{
tp->ecn_flags = 0;
- if (sysctl_tcp_ecn) {
+ if (sysctl_tcp_ecn && !(sk->route_caps&NETIF_F_TSO)) {
TCP_SKB_CB(skb)->flags |= TCPCB_FLAG_ECE|TCPCB_FLAG_CWR;
tp->ecn_flags = TCP_ECN_OK;
+ sk->no_largesend = 1;
}
}