* Use __be16, __be32.
* Add SCTP_NL() in the spirit of SCTP_U32() and friends.
* Tiny tweak in sctp_chunk_assign_ssn().
Signed-off-by: Alexey Dobriyan <[EMAIL PROTECTED]>
---
include/linux/sctp.h | 60 ++++++++++++++++++++++-----------------------
include/net/sctp/command.h | 2 +
include/net/sctp/sctp.h | 2 -
include/net/sctp/sm.h | 6 ++--
include/net/sctp/structs.h | 4 +--
include/net/sctp/tsnmap.h | 4 +--
include/net/sctp/user.h | 2 -
net/sctp/associola.c | 2 -
net/sctp/ipv6.c | 4 +--
net/sctp/outqueue.c | 2 -
net/sctp/protocol.c | 2 -
net/sctp/sm_make_chunk.c | 31 +++++++++++------------
net/sctp/sm_statefuns.c | 10 +++----
net/sctp/ulpevent.c | 2 -
14 files changed, 67 insertions(+), 66 deletions(-)
diff -uprN linux-vanilla/include/linux/sctp.h linux-sctp/include/linux/sctp.h
--- linux-vanilla/include/linux/sctp.h 2005-07-29 03:31:11.000000000 +0400
+++ linux-sctp/include/linux/sctp.h 2005-07-29 03:39:50.000000000 +0400
@@ -57,17 +57,17 @@
/* Section 3.1. SCTP Common Header Format */
typedef struct sctphdr {
- __u16 source;
- __u16 dest;
- __u32 vtag;
- __u32 checksum;
+ __be16 source;
+ __be16 dest;
+ __be32 vtag;
+ __be32 checksum;
} __attribute__((packed)) sctp_sctphdr_t;
/* Section 3.2. Chunk Field Descriptions. */
typedef struct sctp_chunkhdr {
__u8 type;
__u8 flags;
- __u16 length;
+ __be16 length;
} __attribute__((packed)) sctp_chunkhdr_t;
@@ -153,8 +153,8 @@ 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 {
@@ -203,9 +203,9 @@ enum { SCTP_PARAM_ACTION_MASK = __consta
/* RFC 2960 Section 3.3.1 Payload Data (DATA) (0) */
typedef struct sctp_datahdr {
- __u32 tsn;
- __u16 stream;
- __u16 ssn;
+ __be32 tsn;
+ __be16 stream;
+ __be16 ssn;
__u32 ppid;
__u8 payload[0];
} __attribute__((packed)) sctp_datahdr_t;
@@ -232,11 +232,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 +261,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) */
@@ -284,7 +284,7 @@ typedef struct sctp_ecn_capable_param {
/* ADDIP Section 3.2.6 Adaption Layer Indication */
typedef struct sctp_adaption_ind_param {
struct sctp_paramhdr param_hdr;
- __u32 adaption_ind;
+ __be32 adaption_ind;
} __attribute__((packed)) sctp_adaption_ind_param_t;
/* RFC 2960. Section 3.3.3 Initiation Acknowledgement (INIT ACK) (2):
@@ -328,10 +328,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 +371,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 +382,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;
@@ -462,7 +462,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 +474,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 +529,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));
@@ -582,7 +582,7 @@ typedef struct sctp_addip_param {
} __attribute__((packed)) sctp_addip_param_t;
typedef struct sctp_addiphdr {
- __u32 serial;
+ __be32 serial;
__u8 params[0];
} __attribute__((packed)) sctp_addiphdr_t;
diff -uprN linux-vanilla/include/net/sctp/command.h
linux-sctp/include/net/sctp/command.h
--- linux-vanilla/include/net/sctp/command.h 2005-07-29 03:31:12.000000000
+0400
+++ linux-sctp/include/net/sctp/command.h 2005-07-29 03:39:50.000000000
+0400
@@ -113,6 +113,7 @@ typedef enum {
#define SCTP_MAX_NUM_COMMANDS 14
typedef union {
+ __be32 nl;
__s32 i32;
__u32 u32;
__u16 u16;
@@ -160,6 +161,7 @@ static inline sctp_arg_t \
SCTP_## name (type arg) \
{ sctp_arg_t retval; retval.elt = arg; return retval; }
+SCTP_ARG_CONSTRUCTOR(NL, __be32, nl)
SCTP_ARG_CONSTRUCTOR(I32, __s32, i32)
SCTP_ARG_CONSTRUCTOR(U32, __u32, u32)
SCTP_ARG_CONSTRUCTOR(U16, __u16, u16)
diff -uprN linux-vanilla/include/net/sctp/sctp.h
linux-sctp/include/net/sctp/sctp.h
--- linux-vanilla/include/net/sctp/sctp.h 2005-07-29 03:31:12.000000000
+0400
+++ linux-sctp/include/net/sctp/sctp.h 2005-07-29 03:39:50.000000000 +0400
@@ -537,7 +537,7 @@ static inline int ipver2af(__u8 ipver)
}
/* Convert from an address parameter type to an address family. */
-static inline int param_type2af(__u16 type)
+static inline int param_type2af(__be16 type)
{
switch (type) {
case SCTP_PARAM_IPV4_ADDRESS:
diff -uprN linux-vanilla/include/net/sctp/sm.h linux-sctp/include/net/sctp/sm.h
--- linux-vanilla/include/net/sctp/sm.h 2005-07-29 03:31:12.000000000 +0400
+++ linux-sctp/include/net/sctp/sm.h 2005-07-29 03:39:50.000000000 +0400
@@ -213,7 +213,7 @@ struct sctp_chunk *sctp_make_shutdown_ac
const struct sctp_chunk *);
struct sctp_chunk *sctp_make_shutdown_complete(const struct sctp_association *,
const struct sctp_chunk *);
-void sctp_init_cause(struct sctp_chunk *, __u16 cause, const void *, size_t);
+void sctp_init_cause(struct sctp_chunk *, __be16 cause, const void *, size_t);
struct sctp_chunk *sctp_make_abort(const struct sctp_association *,
const struct sctp_chunk *,
const size_t hint);
@@ -237,14 +237,14 @@ struct sctp_chunk *sctp_make_heartbeat_a
const size_t paylen);
struct sctp_chunk *sctp_make_op_error(const struct sctp_association *,
const struct sctp_chunk *chunk,
- __u16 cause_code,
+ __be16 cause_code,
const void *payload,
size_t paylen);
struct sctp_chunk *sctp_make_asconf_update_ip(struct sctp_association *,
union sctp_addr *,
struct sockaddr *,
- int, __u16);
+ int, __be16);
struct sctp_chunk *sctp_make_asconf_set_prim(struct sctp_association *asoc,
union sctp_addr *addr);
struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,
diff -uprN linux-vanilla/include/net/sctp/structs.h
linux-sctp/include/net/sctp/structs.h
--- linux-vanilla/include/net/sctp/structs.h 2005-07-29 03:31:12.000000000
+0400
+++ linux-sctp/include/net/sctp/structs.h 2005-07-29 03:39:50.000000000
+0400
@@ -547,7 +547,7 @@ struct sctp_pf {
struct sctp_sock *);
int (*bind_verify) (struct sctp_sock *, union sctp_addr *);
int (*send_verify) (struct sctp_sock *, union sctp_addr *);
- int (*supported_addrs)(const struct sctp_sock *, __u16 *);
+ int (*supported_addrs)(const struct sctp_sock *, __be16 *);
struct sock *(*create_accept_sk) (struct sock *sk,
struct sctp_association *asoc);
void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
@@ -1432,7 +1432,7 @@ struct sctp_association {
/* This mask is used to disable sending the ASCONF chunk
* with specified parameter to peer.
*/
- __u16 addip_disabled_mask;
+ __be16 addip_disabled_mask;
struct sctp_inithdr i;
int cookie_len;
diff -uprN linux-vanilla/include/net/sctp/tsnmap.h
linux-sctp/include/net/sctp/tsnmap.h
--- linux-vanilla/include/net/sctp/tsnmap.h 2005-07-29 03:31:12.000000000
+0400
+++ linux-sctp/include/net/sctp/tsnmap.h 2005-07-29 03:39:50.000000000
+0400
@@ -105,7 +105,7 @@ struct sctp_tsnmap {
* every SACK. Store up to SCTP_MAX_DUP_TSNS worth of
* information.
*/
- __u32 dup_tsns[SCTP_MAX_DUP_TSNS];
+ __be32 dup_tsns[SCTP_MAX_DUP_TSNS];
__u16 num_dup_tsns;
/* Record gap ack block information here. */
@@ -162,7 +162,7 @@ static inline __u16 sctp_tsnmap_num_dups
}
/* Return pointer to duplicate tsn array as needed by SACK. */
-static inline __u32 *sctp_tsnmap_get_dups(struct sctp_tsnmap *map)
+static inline __be32 *sctp_tsnmap_get_dups(struct sctp_tsnmap *map)
{
map->num_dup_tsns = 0;
return map->dup_tsns;
diff -uprN linux-vanilla/include/net/sctp/user.h
linux-sctp/include/net/sctp/user.h
--- linux-vanilla/include/net/sctp/user.h 2005-07-29 03:31:12.000000000
+0400
+++ linux-sctp/include/net/sctp/user.h 2005-07-29 03:39:50.000000000 +0400
@@ -270,7 +270,7 @@ struct sctp_remote_error {
__u16 sre_type;
__u16 sre_flags;
__u32 sre_length;
- __u16 sre_error;
+ __be16 sre_error;
sctp_assoc_t sre_assoc_id;
__u8 sre_data[0];
};
diff -uprN linux-vanilla/net/sctp/associola.c linux-sctp/net/sctp/associola.c
--- linux-vanilla/net/sctp/associola.c 2005-07-29 03:31:13.000000000 +0400
+++ linux-sctp/net/sctp/associola.c 2005-07-29 03:39:50.000000000 +0400
@@ -803,7 +803,7 @@ struct sctp_transport *sctp_assoc_lookup
struct list_head *entry, *pos;
struct sctp_transport *transport;
struct sctp_chunk *chunk;
- __u32 key = htonl(tsn);
+ __be32 key = htonl(tsn);
match = NULL;
diff -uprN linux-vanilla/net/sctp/ipv6.c linux-sctp/net/sctp/ipv6.c
--- linux-vanilla/net/sctp/ipv6.c 2005-07-29 03:31:13.000000000 +0400
+++ linux-sctp/net/sctp/ipv6.c 2005-07-29 03:39:50.000000000 +0400
@@ -242,7 +242,7 @@ static inline int sctp_v6_addr_match_len
int i, j;
for (i = 0; i < 4 ; i++) {
- __u32 a1xora2;
+ __be32 a1xora2;
a1xora2 = a1->s6_addr32[i] ^ a2->s6_addr32[i];
@@ -862,7 +862,7 @@ static int sctp_inet6_send_verify(struct
* Returns number of addresses supported.
*/
static int sctp_inet6_supported_addrs(const struct sctp_sock *opt,
- __u16 *types)
+ __be16 *types)
{
types[0] = SCTP_PARAM_IPV4_ADDRESS;
types[1] = SCTP_PARAM_IPV6_ADDRESS;
diff -uprN linux-vanilla/net/sctp/outqueue.c linux-sctp/net/sctp/outqueue.c
--- linux-vanilla/net/sctp/outqueue.c 2005-07-29 03:31:13.000000000 +0400
+++ linux-sctp/net/sctp/outqueue.c 2005-07-29 03:39:50.000000000 +0400
@@ -1621,7 +1621,7 @@ pass:
}
static inline int sctp_get_skip_pos(struct sctp_fwdtsn_skip *skiplist,
- int nskips, __u16 stream)
+ int nskips, __be16 stream)
{
int i;
diff -uprN linux-vanilla/net/sctp/protocol.c linux-sctp/net/sctp/protocol.c
--- linux-vanilla/net/sctp/protocol.c 2005-07-29 03:31:13.000000000 +0400
+++ linux-sctp/net/sctp/protocol.c 2005-07-29 03:39:50.000000000 +0400
@@ -787,7 +787,7 @@ static int sctp_inet_send_verify(struct
* chunks. Returns number of addresses supported.
*/
static int sctp_inet_supported_addrs(const struct sctp_sock *opt,
- __u16 *types)
+ __be16 *types)
{
types[0] = SCTP_PARAM_IPV4_ADDRESS;
return 1;
diff -uprN linux-vanilla/net/sctp/sm_make_chunk.c
linux-sctp/net/sctp/sm_make_chunk.c
--- linux-vanilla/net/sctp/sm_make_chunk.c 2005-07-29 03:31:13.000000000
+0400
+++ linux-sctp/net/sctp/sm_make_chunk.c 2005-07-29 03:39:50.000000000 +0400
@@ -111,7 +111,7 @@ static const struct sctp_paramhdr prsctp
* provided chunk, as most cause codes will be embedded inside an
* abort chunk.
*/
-void sctp_init_cause(struct sctp_chunk *chunk, __u16 cause_code,
+void sctp_init_cause(struct sctp_chunk *chunk, __be16 cause_code,
const void *payload, size_t paylen)
{
sctp_errhdr_t err;
@@ -183,7 +183,7 @@ struct sctp_chunk *sctp_make_init(const
int num_types, addrs_len = 0;
struct sctp_sock *sp;
sctp_supported_addrs_param_t sat;
- __u16 types[2];
+ __be16 types[2];
sctp_adaption_ind_param_t aiparam;
/* RFC 2960 3.3.2 Initiation (INIT) (1)
@@ -777,7 +777,7 @@ struct sctp_chunk *sctp_make_abort_no_da
const struct sctp_chunk *chunk, __u32 tsn)
{
struct sctp_chunk *retval;
- __u32 payload;
+ __be32 payload;
retval = sctp_make_abort(asoc, chunk, sizeof(sctp_errhdr_t)
+ sizeof(tsn));
@@ -965,7 +965,7 @@ nodata:
/* Create an Operation Error chunk. */
struct sctp_chunk *sctp_make_op_error(const struct sctp_association *asoc,
const struct sctp_chunk *chunk,
- __u16 cause_code, const void *payload,
+ __be16 cause_code, const void *payload,
size_t paylen)
{
struct sctp_chunk *retval;
@@ -1209,10 +1209,9 @@ void sctp_chunk_assign_ssn(struct sctp_c
ssn = sctp_ssn_next(&chunk->asoc->ssnmap->out, sid);
else
ssn = sctp_ssn_peek(&chunk->asoc->ssnmap->out, sid);
- ssn = htons(ssn);
}
- chunk->subh.data_hdr->ssn = ssn;
+ chunk->subh.data_hdr->ssn = htons(ssn);
chunk->has_ssn = 1;
}
@@ -1517,8 +1516,8 @@ malformed:
********************************************************************/
struct __sctp_missing {
- __u32 num_missing;
- __u16 type;
+ __be32 num_missing;
+ __be16 type;
} __attribute__((packed));
/*
@@ -2208,7 +2207,7 @@ struct sctp_chunk *sctp_make_asconf_upda
union sctp_addr *laddr,
struct sockaddr *addrs,
int addrcnt,
- __u16 flags)
+ __be16 flags)
{
sctp_addip_param_t param;
struct sctp_chunk *retval;
@@ -2342,13 +2341,13 @@ static struct sctp_chunk *sctp_make_asco
/* Add response parameters to an ASCONF_ACK chunk. */
static void sctp_add_asconf_response(struct sctp_chunk *chunk, __u32 crr_id,
- __u16 err_code, sctp_addip_param_t *asconf_param)
+ __be16 err_code, sctp_addip_param_t *asconf_param)
{
sctp_addip_param_t ack_param;
sctp_errhdr_t err_param;
int asconf_param_len = 0;
int err_param_len = 0;
- __u16 response_type;
+ __be16 response_type;
if (SCTP_ERROR_NO_ERROR == err_code) {
response_type = SCTP_PARAM_SUCCESS_REPORT;
@@ -2382,7 +2381,7 @@ static void sctp_add_asconf_response(str
}
/* Process a asconf parameter. */
-static __u16 sctp_process_asconf_param(struct sctp_association *asoc,
+static __be16 sctp_process_asconf_param(struct sctp_association *asoc,
struct sctp_chunk *asconf,
sctp_addip_param_t *asconf_param)
{
@@ -2465,7 +2464,7 @@ struct sctp_chunk *sctp_process_asconf(s
sctp_addip_param_t *asconf_param;
struct sctp_chunk *asconf_ack;
- __u16 err_code;
+ __be16 err_code;
int length = 0;
int chunk_len = asconf->skb->len;
__u32 serial;
@@ -2602,7 +2601,7 @@ static int sctp_asconf_param_success(str
* All TLVs after the failed response are considered unsuccessful unless a
* specific success indication is present for the parameter.
*/
-static __u16 sctp_get_asconf_response(struct sctp_chunk *asconf_ack,
+static __be16 sctp_get_asconf_response(struct sctp_chunk *asconf_ack,
sctp_addip_param_t *asconf_param,
int no_err)
{
@@ -2610,7 +2609,7 @@ static __u16 sctp_get_asconf_response(st
sctp_errhdr_t *err_param;
int length;
int asconf_ack_len = asconf_ack->skb->len;
- __u16 err_code;
+ __be16 err_code;
if (no_err)
err_code = SCTP_ERROR_NO_ERROR;
@@ -2666,7 +2665,7 @@ int sctp_process_asconf_ack(struct sctp_
int all_param_pass = 0;
int no_err = 1;
int retval = 0;
- __u16 err_code = SCTP_ERROR_NO_ERROR;
+ __be16 err_code = SCTP_ERROR_NO_ERROR;
/* Skip the chunkhdr and addiphdr from the last asconf sent and store
* a pointer to address parameter.
diff -uprN linux-vanilla/net/sctp/sm_statefuns.c
linux-sctp/net/sctp/sm_statefuns.c
--- linux-vanilla/net/sctp/sm_statefuns.c 2005-07-29 03:31:13.000000000
+0400
+++ linux-sctp/net/sctp/sm_statefuns.c 2005-07-29 03:39:50.000000000 +0400
@@ -93,7 +93,7 @@ static sctp_disposition_t sctp_sf_shut_8
static struct sctp_sackhdr *sctp_sm_pull_sack(struct sctp_chunk *chunk);
static sctp_disposition_t sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands,
- __u16 error,
+ __be16 error,
const struct sctp_association *asoc,
struct sctp_transport *transport);
@@ -2236,7 +2236,7 @@ sctp_disposition_t sctp_sf_do_9_1_abort(
{
struct sctp_chunk *chunk = arg;
unsigned len;
- __u16 error = SCTP_ERROR_NO_ERROR;
+ __be16 error = SCTP_ERROR_NO_ERROR;
if (!sctp_vtag_verify_either(chunk, asoc))
return sctp_sf_pdiscard(ep, asoc, type, arg, commands);
@@ -2280,7 +2280,7 @@ sctp_disposition_t sctp_sf_cookie_wait_a
{
struct sctp_chunk *chunk = arg;
unsigned len;
- __u16 error = SCTP_ERROR_NO_ERROR;
+ __be16 error = SCTP_ERROR_NO_ERROR;
if (!sctp_vtag_verify_either(chunk, asoc))
return sctp_sf_pdiscard(ep, asoc, type, arg, commands);
@@ -2340,7 +2340,7 @@ sctp_disposition_t sctp_sf_cookie_echoed
* This is common code called by several sctp_sf_*_abort() functions above.
*/
static sctp_disposition_t sctp_stop_t1_and_abort(sctp_cmd_seq_t *commands,
- __u16 error,
+ __be16 error,
const struct sctp_association *asoc,
struct sctp_transport *transport)
{
@@ -2437,7 +2437,7 @@ sctp_disposition_t sctp_sf_do_9_2_shutdo
* received by the SHUTDOWN sender.
*/
sctp_add_cmd_sf(commands, SCTP_CMD_PROCESS_CTSN,
- SCTP_U32(chunk->subh.shutdown_hdr->cum_tsn_ack));
+ SCTP_NL(chunk->subh.shutdown_hdr->cum_tsn_ack));
/* API 5.3.1.5 SCTP_SHUTDOWN_EVENT
* When a peer sends a SHUTDOWN, SCTP delivers this notification to
diff -uprN linux-vanilla/net/sctp/ulpevent.c linux-sctp/net/sctp/ulpevent.c
--- linux-vanilla/net/sctp/ulpevent.c 2005-07-29 03:31:13.000000000 +0400
+++ linux-sctp/net/sctp/ulpevent.c 2005-07-29 03:39:50.000000000 +0400
@@ -356,7 +356,7 @@ struct sctp_ulpevent *sctp_ulpevent_make
struct sctp_remote_error *sre;
struct sk_buff *skb;
sctp_errhdr_t *ch;
- __u16 cause;
+ __be16 cause;
int elen;
ch = (sctp_errhdr_t *)(chunk->skb->data);
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at http://vger.kernel.org/majordomo-info.html