netfilter: nf_conntrack: pass template to l4proto ->error() handler
[safe/jmp/linux-2.6] / include / linux / sctp.h
index 6ec66de..c20d3ce 100644 (file)
  *
  * Various protocol defined structures.
  *
- * The SCTP reference implementation is free software;
+ * This SCTP 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
+ * This SCTP 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.
 
 /* Section 3.1.  SCTP Common Header Format */
 typedef struct sctphdr {
-       __u16 source;
-       __u16 dest;
-       __u32 vtag;
-       __u32 checksum;
+       __be16 source;
+       __be16 dest;
+       __be32 vtag;
+       __le32 checksum;
 } __attribute__((packed)) sctp_sctphdr_t;
 
+#ifdef __KERNEL__
+#include <linux/skbuff.h>
+
+static inline struct sctphdr *sctp_hdr(const struct sk_buff *skb)
+{
+       return (struct sctphdr *)skb_transport_header(skb);
+}
+#endif
+
 /* Section 3.2.  Chunk Field Descriptions. */
 typedef struct sctp_chunkhdr {
        __u8 type;
        __u8 flags;
-       __u16 length;
+       __be16 length;
 } __attribute__((packed)) sctp_chunkhdr_t;
 
 
@@ -93,6 +102,9 @@ typedef enum {
         SCTP_CID_ECN_CWR               = 13,
         SCTP_CID_SHUTDOWN_COMPLETE     = 14,
 
+       /* AUTH Extension Section 4.1 */
+       SCTP_CID_AUTH                   = 0x0F,
+
        /* PR-SCTP Sec 3.2 */
        SCTP_CID_FWD_TSN                = 0xC0,
 
@@ -153,34 +165,42 @@ enum { SCTP_CHUNK_FLAG_T = 0x01 };
  */
 
 typedef struct sctp_paramhdr {
-       __u16 type;
-       __u16 length;
+       __be16 type;
+       __be16 length;
 } __attribute__((packed)) sctp_paramhdr_t;
 
 typedef enum {
 
        /* RFC 2960 Section 3.3.5 */
-       SCTP_PARAM_HEARTBEAT_INFO               = __constant_htons(1),
+       SCTP_PARAM_HEARTBEAT_INFO               = cpu_to_be16(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),
+       SCTP_PARAM_IPV4_ADDRESS                 = cpu_to_be16(5),
+       SCTP_PARAM_IPV6_ADDRESS                 = cpu_to_be16(6),
+       SCTP_PARAM_STATE_COOKIE                 = cpu_to_be16(7),
+       SCTP_PARAM_UNRECOGNIZED_PARAMETERS      = cpu_to_be16(8),
+       SCTP_PARAM_COOKIE_PRESERVATIVE          = cpu_to_be16(9),
+       SCTP_PARAM_HOST_NAME_ADDRESS            = cpu_to_be16(11),
+       SCTP_PARAM_SUPPORTED_ADDRESS_TYPES      = cpu_to_be16(12),
+       SCTP_PARAM_ECN_CAPABLE                  = cpu_to_be16(0x8000),
+
+       /* AUTH Extension Section 3 */
+       SCTP_PARAM_RANDOM                       = cpu_to_be16(0x8002),
+       SCTP_PARAM_CHUNKS                       = cpu_to_be16(0x8003),
+       SCTP_PARAM_HMAC_ALGO                    = cpu_to_be16(0x8004),
+
+       /* Add-IP: Supported Extensions, Section 4.2 */
+       SCTP_PARAM_SUPPORTED_EXT        = cpu_to_be16(0x8008),
 
        /* PR-SCTP Sec 3.1 */
-       SCTP_PARAM_FWD_TSN_SUPPORT      = __constant_htons(0xc000),
+       SCTP_PARAM_FWD_TSN_SUPPORT      = cpu_to_be16(0xc000),
 
        /* 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_ADD_IP               = cpu_to_be16(0xc001),
+       SCTP_PARAM_DEL_IP               = cpu_to_be16(0xc002),
+       SCTP_PARAM_ERR_CAUSE            = cpu_to_be16(0xc003),
+       SCTP_PARAM_SET_PRIMARY          = cpu_to_be16(0xc004),
+       SCTP_PARAM_SUCCESS_REPORT       = cpu_to_be16(0xc005),
+       SCTP_PARAM_ADAPTATION_LAYER_IND = cpu_to_be16(0xc006),
 
 } sctp_param_t; /* enum */
 
@@ -192,21 +212,21 @@ typedef enum {
  *
  */
 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_DISCARD     = cpu_to_be16(0x0000),
+       SCTP_PARAM_ACTION_DISCARD_ERR = cpu_to_be16(0x4000),
+       SCTP_PARAM_ACTION_SKIP        = cpu_to_be16(0x8000),
+       SCTP_PARAM_ACTION_SKIP_ERR    = cpu_to_be16(0xc000),
 } sctp_param_action_t;
 
-enum { SCTP_PARAM_ACTION_MASK = __constant_htons(0xc000), };
+enum { SCTP_PARAM_ACTION_MASK = cpu_to_be16(0xc000), };
 
 /* RFC 2960 Section 3.3.1 Payload Data (DATA) (0) */
 
 typedef struct sctp_datahdr {
-       __u32 tsn;
-       __u16 stream;
-       __u16 ssn;
-       __u32 ppid;
+       __be32 tsn;
+       __be16 stream;
+       __be16 ssn;
+       __be32 ppid;
        __u8  payload[0];
 } __attribute__((packed)) sctp_datahdr_t;
 
@@ -222,6 +242,7 @@ enum {
        SCTP_DATA_FIRST_FRAG    = 0x02,
        SCTP_DATA_NOT_FRAG      = 0x03,
        SCTP_DATA_UNORDERED     = 0x04,
+       SCTP_DATA_SACK_IMM      = 0x08,
 };
 enum { SCTP_DATA_FRAG_MASK = 0x03, };
 
@@ -232,11 +253,11 @@ enum { SCTP_DATA_FRAG_MASK = 0x03, };
  *  endpoints.
  */
 typedef struct sctp_inithdr {
-       __u32 init_tag;
-       __u32 a_rwnd;
-       __u16 num_outbound_streams;
-       __u16 num_inbound_streams;
-       __u32 initial_tsn;
+       __be32 init_tag;
+       __be32 a_rwnd;
+       __be16 num_outbound_streams;
+       __be16 num_inbound_streams;
+       __be32 initial_tsn;
        __u8  params[0];
 } __attribute__((packed)) sctp_inithdr_t;
 
@@ -261,7 +282,7 @@ typedef struct sctp_ipv6addr_param {
 /* Section 3.3.2.1 Cookie Preservative (9) */
 typedef struct sctp_cookie_preserve_param {
        sctp_paramhdr_t param_hdr;
-       uint32_t        lifespan_increment;
+       __be32          lifespan_increment;
 } __attribute__((packed)) sctp_cookie_preserve_param_t;
 
 /* Section 3.3.2.1 Host Name Address (11) */
@@ -273,7 +294,7 @@ typedef struct sctp_hostname_param {
 /* Section 3.3.2.1 Supported Address Types (12) */
 typedef struct sctp_supported_addrs_param {
        sctp_paramhdr_t param_hdr;
-       uint16_t types[0];
+       __be16 types[0];
 } __attribute__((packed)) sctp_supported_addrs_param_t;
 
 /* Appendix A. ECN Capable (32768) */
@@ -281,11 +302,35 @@ typedef struct sctp_ecn_capable_param {
        sctp_paramhdr_t param_hdr;
 } __attribute__((packed)) sctp_ecn_capable_param_t;
 
-/* ADDIP Section 3.2.6 Adaption Layer Indication */
-typedef struct sctp_adaption_ind_param {
+/* ADDIP Section 3.2.6 Adaptation Layer Indication */
+typedef struct sctp_adaptation_ind_param {
+       struct sctp_paramhdr param_hdr;
+       __be32 adaptation_ind;
+} __attribute__((packed)) sctp_adaptation_ind_param_t;
+
+/* ADDIP Section 4.2.7 Supported Extensions Parameter */
+typedef struct sctp_supported_ext_param {
        struct sctp_paramhdr param_hdr;
-       __u32 adaption_ind;
-} __attribute__((packed)) sctp_adaption_ind_param_t;
+       __u8 chunks[0];
+} __attribute__((packed)) sctp_supported_ext_param_t;
+
+/* AUTH Section 3.1 Random */
+typedef struct sctp_random_param {
+       sctp_paramhdr_t param_hdr;
+       __u8 random_val[0];
+} __attribute__((packed)) sctp_random_param_t;
+
+/* AUTH Section 3.2 Chunk List */
+typedef struct sctp_chunks_param {
+       sctp_paramhdr_t param_hdr;
+       __u8 chunks[0];
+} __attribute__((packed)) sctp_chunks_param_t;
+
+/* AUTH Section 3.3 HMAC Algorithm */
+typedef struct sctp_hmac_algo_param {
+       sctp_paramhdr_t param_hdr;
+       __be16 hmac_ids[0];
+} __attribute__((packed)) sctp_hmac_algo_param_t;
 
 /* RFC 2960.  Section 3.3.3 Initiation Acknowledgement (INIT ACK) (2):
  *   The INIT ACK chunk is used to acknowledge the initiation of an SCTP
@@ -316,11 +361,11 @@ typedef struct sctp_unrecognized_param {
  */
 
 typedef struct sctp_gap_ack_block {
-       __u16 start;
-       __u16 end;
+       __be16 start;
+       __be16 end;
 } __attribute__((packed)) sctp_gap_ack_block_t;
 
-typedef uint32_t sctp_dup_tsn_t;
+typedef __be32 sctp_dup_tsn_t;
 
 typedef union {
        sctp_gap_ack_block_t    gab;
@@ -328,10 +373,10 @@ typedef union {
 } sctp_sack_variable_t;
 
 typedef struct sctp_sackhdr {
-       __u32 cum_tsn_ack;
-       __u32 a_rwnd;
-       __u16 num_gap_ack_blocks;
-       __u16 num_dup_tsns;
+       __be32 cum_tsn_ack;
+       __be32 a_rwnd;
+       __be16 num_gap_ack_blocks;
+       __be16 num_dup_tsns;
        sctp_sack_variable_t variable[0];
 } __attribute__((packed)) sctp_sackhdr_t;
 
@@ -371,7 +416,7 @@ typedef struct sctp_abort_chunk {
  * and the highest consecutive acking value.
  */
 typedef struct sctp_shutdownhdr {
-       __u32 cum_tsn_ack;
+       __be32 cum_tsn_ack;
 } __attribute__((packed)) sctp_shutdownhdr_t;
 
 struct sctp_shutdown_chunk_t {
@@ -382,8 +427,8 @@ struct sctp_shutdown_chunk_t {
 /* RFC 2960.  Section 3.3.10 Operation Error (ERROR) (9) */
 
 typedef struct sctp_errhdr {
-       __u16 cause;
-       __u16 length;
+       __be16 cause;
+       __be16 length;
        __u8  variable[0];
 } __attribute__((packed)) sctp_errhdr_t;
 
@@ -413,17 +458,17 @@ typedef struct sctp_operr_chunk {
  */
 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_ERROR_NO_ERROR        = cpu_to_be16(0x00),
+       SCTP_ERROR_INV_STRM        = cpu_to_be16(0x01),
+       SCTP_ERROR_MISS_PARAM      = cpu_to_be16(0x02),
+       SCTP_ERROR_STALE_COOKIE    = cpu_to_be16(0x03),
+       SCTP_ERROR_NO_RESOURCE     = cpu_to_be16(0x04),
+       SCTP_ERROR_DNS_FAILED      = cpu_to_be16(0x05),
+       SCTP_ERROR_UNKNOWN_CHUNK   = cpu_to_be16(0x06),
+       SCTP_ERROR_INV_PARAM       = cpu_to_be16(0x07),
+       SCTP_ERROR_UNKNOWN_PARAM   = cpu_to_be16(0x08),
+       SCTP_ERROR_NO_DATA         = cpu_to_be16(0x09),
+       SCTP_ERROR_COOKIE_IN_SHUTDOWN = cpu_to_be16(0x0a),
 
 
        /* SCTP Implementation Guide:
@@ -432,9 +477,9 @@ typedef enum {
         *  13  Protocol Violation
         */
 
-       SCTP_ERROR_RESTART         = __constant_htons(0x0b),
-       SCTP_ERROR_USER_ABORT      = __constant_htons(0x0c),
-       SCTP_ERROR_PROTO_VIOLATION = __constant_htons(0x0d),
+       SCTP_ERROR_RESTART         = cpu_to_be16(0x0b),
+       SCTP_ERROR_USER_ABORT      = cpu_to_be16(0x0c),
+       SCTP_ERROR_PROTO_VIOLATION = cpu_to_be16(0x0d),
 
        /* ADDIP Section 3.3  New Error Causes
         *
@@ -443,17 +488,29 @@ typedef enum {
         *
         * 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
-        * 0x0104          Request refused - no authorization.
+        * 0x00A0          Request to Delete Last Remaining IP Address.
+        * 0x00A1          Operation Refused Due to Resource Shortage.
+        * 0x00A2          Request to Delete Source IP Address.
+        * 0x00A3          Association Aborted due to illegal ASCONF-ACK
+        * 0x00A4          Request refused - no authorization.
+        */
+       SCTP_ERROR_DEL_LAST_IP  = cpu_to_be16(0x00A0),
+       SCTP_ERROR_RSRC_LOW     = cpu_to_be16(0x00A1),
+       SCTP_ERROR_DEL_SRC_IP   = cpu_to_be16(0x00A2),
+       SCTP_ERROR_ASCONF_ACK   = cpu_to_be16(0x00A3),
+       SCTP_ERROR_REQ_REFUSED  = cpu_to_be16(0x00A4),
+
+       /* AUTH Section 4.  New Error Cause
+        *
+        * This section defines a new error cause that will be sent if an AUTH
+        * chunk is received with an unsupported HMAC identifier.
+        * illustrates the new error cause.
+        *
+        * Cause Code      Error Cause Name
+        * --------------------------------------------------------------
+        * 0x0105          Unsupported HMAC Identifier
         */
-       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_REQ_REFUSED  = __constant_htons(0x0104)
+        SCTP_ERROR_UNSUP_HMAC  = cpu_to_be16(0x0105)
 } sctp_error_t;
 
 
@@ -462,7 +519,7 @@ typedef enum {
  *   Explicit Congestion Notification Echo (ECNE) (12)
  */
 typedef struct sctp_ecnehdr {
-       __u32 lowest_tsn;
+       __be32 lowest_tsn;
 } sctp_ecnehdr_t;
 
 typedef struct sctp_ecne_chunk {
@@ -474,7 +531,7 @@ typedef struct sctp_ecne_chunk {
  *   Congestion Window Reduced (CWR) (13)
  */
 typedef struct sctp_cwrhdr {
-       __u32 lowest_tsn;
+       __be32 lowest_tsn;
 } sctp_cwrhdr_t;
 
 typedef struct sctp_cwr_chunk {
@@ -529,12 +586,12 @@ typedef struct sctp_cwr_chunk {
  *       chunks this field MUST be filled in.
  */
 struct sctp_fwdtsn_skip {
-       __u16 stream;
-       __u16 ssn;
+       __be16 stream;
+       __be16 ssn;
 } __attribute__((packed));
 
 struct sctp_fwdtsn_hdr {
-       __u32 new_cum_tsn;
+       __be32 new_cum_tsn;
        struct sctp_fwdtsn_skip skip[0];
 } __attribute((packed));
 
@@ -578,11 +635,11 @@ struct sctp_fwdtsn_chunk {
  */
 typedef struct sctp_addip_param {
        sctp_paramhdr_t param_hdr;
-       __u32           crr_id; 
+       __be32          crr_id;
 } __attribute__((packed)) sctp_addip_param_t;
 
 typedef struct sctp_addiphdr {
-       __u32   serial;
+       __be32  serial;
        __u8    params[0];
 } __attribute__((packed)) sctp_addiphdr_t;
 
@@ -591,4 +648,64 @@ typedef struct sctp_addip_chunk {
        sctp_addiphdr_t addip_hdr;
 } __attribute__((packed)) sctp_addip_chunk_t;
 
+/* AUTH
+ * Section 4.1  Authentication Chunk (AUTH)
+ *
+ *   This chunk is used to hold the result of the HMAC calculation.
+ *
+ *    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 = 0x0F   |   Flags=0     |             Length            |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |     Shared Key Identifier     |   HMAC Identifier             |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |                                                               |
+ *   \                             HMAC                              /
+ *   /                                                               \
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ *   Type: 1 byte (unsigned integer)
+ *     This value MUST be set to 0x0F for  all AUTH-chunks.
+ *
+ *   Flags: 1 byte (unsigned integer)
+ *     Set to zero on transmit and ignored on receipt.
+ *
+ *   Length: 2 bytes (unsigned integer)
+ *     This value holds the length of the HMAC in bytes plus 8.
+ *
+ *  Shared Key Identifier: 2 bytes (unsigned integer)
+ *     This value describes which endpoint pair shared key is used.
+ *
+ *   HMAC Identifier: 2 bytes (unsigned integer)
+ *     This value describes which message digest is being used.  Table 2
+ *     shows the currently defined values.
+ *
+ *    The following Table 2 shows the currently defined values for HMAC
+ *       identifiers.
+ *
+ *      +-----------------+--------------------------+
+ *      | HMAC Identifier | Message Digest Algorithm |
+ *      +-----------------+--------------------------+
+ *      | 0               | Reserved                 |
+ *      | 1               | SHA-1 defined in [8]     |
+ *      | 2               | Reserved                 |
+ *      | 3               | SHA-256 defined in [8]   |
+ *      +-----------------+--------------------------+
+ *
+ *
+ *   HMAC: n bytes (unsigned integer) This hold the result of the HMAC
+ *      calculation.
+ */
+typedef struct sctp_authhdr {
+       __be16 shkey_id;
+       __be16 hmac_id;
+       __u8   hmac[0];
+} __attribute__((packed)) sctp_authhdr_t;
+
+typedef struct sctp_auth_chunk {
+       sctp_chunkhdr_t chunk_hdr;
+       sctp_authhdr_t auth_hdr;
+} __attribute__((packed)) sctp_auth_chunk_t;
+
 #endif /* __LINUX_SCTP_H__ */