Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c918704 authored by Xin Long's avatar Xin Long Committed by David S. Miller
Browse files

sctp: remove the typedef sctp_paramhdr_t



This patch is to remove the typedef sctp_paramhdr_t, and replace
with struct sctp_paramhdr in the places where it's using this
typedef.

It is also to fix some indents and  use sizeof(variable) instead
of sizeof(type).

Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent ec431c2c
Loading
Loading
Loading
Loading
+22 −22
Original line number Original line Diff line number Diff line
@@ -162,10 +162,10 @@ enum { SCTP_CHUNK_FLAG_T = 0x01 };
 * Section 3.2.1 Optional/Variable-length Parmaeter Format.
 * Section 3.2.1 Optional/Variable-length Parmaeter Format.
 */
 */


typedef struct sctp_paramhdr {
struct sctp_paramhdr {
	__be16 type;
	__be16 type;
	__be16 length;
	__be16 length;
} sctp_paramhdr_t;
};


typedef enum {
typedef enum {


@@ -274,37 +274,37 @@ typedef struct sctp_init_chunk {


/* Section 3.3.2.1. IPv4 Address Parameter (5) */
/* Section 3.3.2.1. IPv4 Address Parameter (5) */
typedef struct sctp_ipv4addr_param {
typedef struct sctp_ipv4addr_param {
	sctp_paramhdr_t param_hdr;
	struct sctp_paramhdr param_hdr;
	struct in_addr  addr;
	struct in_addr  addr;
} sctp_ipv4addr_param_t;
} sctp_ipv4addr_param_t;


/* Section 3.3.2.1. IPv6 Address Parameter (6) */
/* Section 3.3.2.1. IPv6 Address Parameter (6) */
typedef struct sctp_ipv6addr_param {
typedef struct sctp_ipv6addr_param {
	sctp_paramhdr_t param_hdr;
	struct sctp_paramhdr param_hdr;
	struct in6_addr addr;
	struct in6_addr addr;
} sctp_ipv6addr_param_t;
} sctp_ipv6addr_param_t;


/* Section 3.3.2.1 Cookie Preservative (9) */
/* Section 3.3.2.1 Cookie Preservative (9) */
typedef struct sctp_cookie_preserve_param {
typedef struct sctp_cookie_preserve_param {
	sctp_paramhdr_t param_hdr;
	struct sctp_paramhdr param_hdr;
	__be32          lifespan_increment;
	__be32          lifespan_increment;
} sctp_cookie_preserve_param_t;
} sctp_cookie_preserve_param_t;


/* Section 3.3.2.1 Host Name Address (11) */
/* Section 3.3.2.1 Host Name Address (11) */
typedef struct sctp_hostname_param {
typedef struct sctp_hostname_param {
	sctp_paramhdr_t param_hdr;
	struct sctp_paramhdr param_hdr;
	uint8_t hostname[0];
	uint8_t hostname[0];
} sctp_hostname_param_t;
} sctp_hostname_param_t;


/* Section 3.3.2.1 Supported Address Types (12) */
/* Section 3.3.2.1 Supported Address Types (12) */
typedef struct sctp_supported_addrs_param {
typedef struct sctp_supported_addrs_param {
	sctp_paramhdr_t param_hdr;
	struct sctp_paramhdr param_hdr;
	__be16 types[0];
	__be16 types[0];
} sctp_supported_addrs_param_t;
} sctp_supported_addrs_param_t;


/* Appendix A. ECN Capable (32768) */
/* Appendix A. ECN Capable (32768) */
typedef struct sctp_ecn_capable_param {
typedef struct sctp_ecn_capable_param {
	sctp_paramhdr_t param_hdr;
	struct sctp_paramhdr param_hdr;
} sctp_ecn_capable_param_t;
} sctp_ecn_capable_param_t;


/* ADDIP Section 3.2.6 Adaptation Layer Indication */
/* ADDIP Section 3.2.6 Adaptation Layer Indication */
@@ -321,19 +321,19 @@ typedef struct sctp_supported_ext_param {


/* AUTH Section 3.1 Random */
/* AUTH Section 3.1 Random */
typedef struct sctp_random_param {
typedef struct sctp_random_param {
	sctp_paramhdr_t param_hdr;
	struct sctp_paramhdr param_hdr;
	__u8 random_val[0];
	__u8 random_val[0];
} sctp_random_param_t;
} sctp_random_param_t;


/* AUTH Section 3.2 Chunk List */
/* AUTH Section 3.2 Chunk List */
typedef struct sctp_chunks_param {
typedef struct sctp_chunks_param {
	sctp_paramhdr_t param_hdr;
	struct sctp_paramhdr param_hdr;
	__u8 chunks[0];
	__u8 chunks[0];
} sctp_chunks_param_t;
} sctp_chunks_param_t;


/* AUTH Section 3.3 HMAC Algorithm */
/* AUTH Section 3.3 HMAC Algorithm */
typedef struct sctp_hmac_algo_param {
typedef struct sctp_hmac_algo_param {
	sctp_paramhdr_t param_hdr;
	struct sctp_paramhdr param_hdr;
	__be16 hmac_ids[0];
	__be16 hmac_ids[0];
} sctp_hmac_algo_param_t;
} sctp_hmac_algo_param_t;


@@ -345,14 +345,14 @@ typedef sctp_init_chunk_t sctp_initack_chunk_t;


/* Section 3.3.3.1 State Cookie (7) */
/* Section 3.3.3.1 State Cookie (7) */
typedef struct sctp_cookie_param {
typedef struct sctp_cookie_param {
	sctp_paramhdr_t p;
	struct sctp_paramhdr p;
	__u8 body[0];
	__u8 body[0];
} sctp_cookie_param_t;
} sctp_cookie_param_t;


/* Section 3.3.3.1 Unrecognized Parameters (8) */
/* Section 3.3.3.1 Unrecognized Parameters (8) */
typedef struct sctp_unrecognized_param {
typedef struct sctp_unrecognized_param {
	sctp_paramhdr_t param_hdr;
	struct sctp_paramhdr param_hdr;
	sctp_paramhdr_t unrecognized;
	struct sctp_paramhdr unrecognized;
} sctp_unrecognized_param_t;
} sctp_unrecognized_param_t;




@@ -399,7 +399,7 @@ typedef struct sctp_sack_chunk {
 */
 */


typedef struct sctp_heartbeathdr {
typedef struct sctp_heartbeathdr {
	sctp_paramhdr_t info;
	struct sctp_paramhdr info;
} sctp_heartbeathdr_t;
} sctp_heartbeathdr_t;


typedef struct sctp_heartbeat_chunk {
typedef struct sctp_heartbeat_chunk {
@@ -639,7 +639,7 @@ struct sctp_fwdtsn_chunk {
 *	report status of ASCONF processing.
 *	report status of ASCONF processing.
 */
 */
typedef struct sctp_addip_param {
typedef struct sctp_addip_param {
	sctp_paramhdr_t	param_hdr;
	struct sctp_paramhdr	param_hdr;
	__be32		crr_id;
	__be32		crr_id;
} sctp_addip_param_t;
} sctp_addip_param_t;


@@ -724,7 +724,7 @@ struct sctp_reconf_chunk {
};
};


struct sctp_strreset_outreq {
struct sctp_strreset_outreq {
	sctp_paramhdr_t param_hdr;
	struct sctp_paramhdr param_hdr;
	__u32 request_seq;
	__u32 request_seq;
	__u32 response_seq;
	__u32 response_seq;
	__u32 send_reset_at_tsn;
	__u32 send_reset_at_tsn;
@@ -732,18 +732,18 @@ struct sctp_strreset_outreq {
};
};


struct sctp_strreset_inreq {
struct sctp_strreset_inreq {
	sctp_paramhdr_t param_hdr;
	struct sctp_paramhdr param_hdr;
	__u32 request_seq;
	__u32 request_seq;
	__u16 list_of_streams[0];
	__u16 list_of_streams[0];
};
};


struct sctp_strreset_tsnreq {
struct sctp_strreset_tsnreq {
	sctp_paramhdr_t param_hdr;
	struct sctp_paramhdr param_hdr;
	__u32 request_seq;
	__u32 request_seq;
};
};


struct sctp_strreset_addstrm {
struct sctp_strreset_addstrm {
	sctp_paramhdr_t param_hdr;
	struct sctp_paramhdr param_hdr;
	__u32 request_seq;
	__u32 request_seq;
	__u16 number_of_streams;
	__u16 number_of_streams;
	__u16 reserved;
	__u16 reserved;
@@ -760,13 +760,13 @@ enum {
};
};


struct sctp_strreset_resp {
struct sctp_strreset_resp {
	sctp_paramhdr_t param_hdr;
	struct sctp_paramhdr param_hdr;
	__u32 response_seq;
	__u32 response_seq;
	__u32 result;
	__u32 result;
};
};


struct sctp_strreset_resptsn {
struct sctp_strreset_resptsn {
	sctp_paramhdr_t param_hdr;
	struct sctp_paramhdr param_hdr;
	__u32 response_seq;
	__u32 response_seq;
	__u32 result;
	__u32 result;
	__u32 senders_next_tsn;
	__u32 senders_next_tsn;
+1 −1
Original line number Original line Diff line number Diff line
@@ -470,7 +470,7 @@ _sctp_walk_params((pos), (chunk), ntohs((chunk)->chunk_hdr.length), member)
#define _sctp_walk_params(pos, chunk, end, member)\
#define _sctp_walk_params(pos, chunk, end, member)\
for (pos.v = chunk->member;\
for (pos.v = chunk->member;\
     pos.v <= (void *)chunk + end - ntohs(pos.p->length) &&\
     pos.v <= (void *)chunk + end - ntohs(pos.p->length) &&\
     ntohs(pos.p->length) >= sizeof(sctp_paramhdr_t);\
     ntohs(pos.p->length) >= sizeof(struct sctp_paramhdr);\
     pos.v += SCTP_PAD4(ntohs(pos.p->length)))
     pos.v += SCTP_PAD4(ntohs(pos.p->length)))


#define sctp_walk_errors(err, chunk_hdr)\
#define sctp_walk_errors(err, chunk_hdr)\
+3 −2
Original line number Original line Diff line number Diff line
@@ -310,9 +310,10 @@ struct sctp_cookie {


	__u32 adaptation_ind;
	__u32 adaptation_ind;


	__u8 auth_random[sizeof(sctp_paramhdr_t) + SCTP_AUTH_RANDOM_LENGTH];
	__u8 auth_random[sizeof(struct sctp_paramhdr) +
			 SCTP_AUTH_RANDOM_LENGTH];
	__u8 auth_hmacs[SCTP_AUTH_NUM_HMACS * sizeof(__u16) + 2];
	__u8 auth_hmacs[SCTP_AUTH_NUM_HMACS * sizeof(__u16) + 2];
	__u8 auth_chunks[sizeof(sctp_paramhdr_t) + SCTP_AUTH_MAX_CHUNKS];
	__u8 auth_chunks[sizeof(struct sctp_paramhdr) + SCTP_AUTH_MAX_CHUNKS];


	/* This is a shim for my peer's INIT packet, followed by
	/* This is a shim for my peer's INIT packet, followed by
	 * a copy of the raw address list of the association.
	 * a copy of the raw address list of the association.
+3 −3
Original line number Original line Diff line number Diff line
@@ -71,7 +71,7 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
{
{
	struct net *net = sock_net(sk);
	struct net *net = sock_net(sk);
	struct sctp_sock *sp;
	struct sctp_sock *sp;
	sctp_paramhdr_t *p;
	struct sctp_paramhdr *p;
	int i;
	int i;


	/* Retrieve the SCTP per socket area.  */
	/* Retrieve the SCTP per socket area.  */
@@ -284,9 +284,9 @@ static struct sctp_association *sctp_association_init(struct sctp_association *a
			ntohs(ep->auth_chunk_list->param_hdr.length));
			ntohs(ep->auth_chunk_list->param_hdr.length));


	/* Get the AUTH random number for this association */
	/* Get the AUTH random number for this association */
	p = (sctp_paramhdr_t *)asoc->c.auth_random;
	p = (struct sctp_paramhdr *)asoc->c.auth_random;
	p->type = SCTP_PARAM_RANDOM;
	p->type = SCTP_PARAM_RANDOM;
	p->length = htons(sizeof(sctp_paramhdr_t) + SCTP_AUTH_RANDOM_LENGTH);
	p->length = htons(sizeof(*p) + SCTP_AUTH_RANDOM_LENGTH);
	get_random_bytes(p+1, SCTP_AUTH_RANDOM_LENGTH);
	get_random_bytes(p+1, SCTP_AUTH_RANDOM_LENGTH);


	return asoc;
	return asoc;
+13 −9
Original line number Original line Diff line number Diff line
@@ -538,7 +538,8 @@ struct sctp_hmac *sctp_auth_asoc_get_hmac(const struct sctp_association *asoc)
	if (!hmacs)
	if (!hmacs)
		return NULL;
		return NULL;


	n_elt = (ntohs(hmacs->param_hdr.length) - sizeof(sctp_paramhdr_t)) >> 1;
	n_elt = (ntohs(hmacs->param_hdr.length) -
		 sizeof(struct sctp_paramhdr)) >> 1;
	for (i = 0; i < n_elt; i++) {
	for (i = 0; i < n_elt; i++) {
		id = ntohs(hmacs->hmac_ids[i]);
		id = ntohs(hmacs->hmac_ids[i]);


@@ -589,7 +590,8 @@ int sctp_auth_asoc_verify_hmac_id(const struct sctp_association *asoc,
		return 0;
		return 0;


	hmacs = (struct sctp_hmac_algo_param *)asoc->c.auth_hmacs;
	hmacs = (struct sctp_hmac_algo_param *)asoc->c.auth_hmacs;
	n_elt = (ntohs(hmacs->param_hdr.length) - sizeof(sctp_paramhdr_t)) >> 1;
	n_elt = (ntohs(hmacs->param_hdr.length) -
		 sizeof(struct sctp_paramhdr)) >> 1;


	return __sctp_auth_find_hmacid(hmacs->hmac_ids, n_elt, hmac_id);
	return __sctp_auth_find_hmacid(hmacs->hmac_ids, n_elt, hmac_id);
}
}
@@ -612,8 +614,8 @@ void sctp_auth_asoc_set_default_hmac(struct sctp_association *asoc,
	if (asoc->default_hmac_id)
	if (asoc->default_hmac_id)
		return;
		return;


	n_params = (ntohs(hmacs->param_hdr.length)
	n_params = (ntohs(hmacs->param_hdr.length) -
				- sizeof(sctp_paramhdr_t)) >> 1;
		    sizeof(struct sctp_paramhdr)) >> 1;
	ep = asoc->ep;
	ep = asoc->ep;
	for (i = 0; i < n_params; i++) {
	for (i = 0; i < n_params; i++) {
		id = ntohs(hmacs->hmac_ids[i]);
		id = ntohs(hmacs->hmac_ids[i]);
@@ -641,7 +643,7 @@ static int __sctp_auth_cid(enum sctp_cid chunk, struct sctp_chunks_param *param)
	if (!param || param->param_hdr.length == 0)
	if (!param || param->param_hdr.length == 0)
		return 0;
		return 0;


	len = ntohs(param->param_hdr.length) - sizeof(sctp_paramhdr_t);
	len = ntohs(param->param_hdr.length) - sizeof(struct sctp_paramhdr);


	/* SCTP-AUTH, Section 3.2
	/* SCTP-AUTH, Section 3.2
	 *    The chunk types for INIT, INIT-ACK, SHUTDOWN-COMPLETE and AUTH
	 *    The chunk types for INIT, INIT-ACK, SHUTDOWN-COMPLETE and AUTH
@@ -775,7 +777,7 @@ int sctp_auth_ep_add_chunkid(struct sctp_endpoint *ep, __u8 chunk_id)


	/* Check if we can add this chunk to the array */
	/* Check if we can add this chunk to the array */
	param_len = ntohs(p->param_hdr.length);
	param_len = ntohs(p->param_hdr.length);
	nchunks = param_len - sizeof(sctp_paramhdr_t);
	nchunks = param_len - sizeof(struct sctp_paramhdr);
	if (nchunks == SCTP_NUM_CHUNK_TYPES)
	if (nchunks == SCTP_NUM_CHUNK_TYPES)
		return -EINVAL;
		return -EINVAL;


@@ -812,8 +814,10 @@ int sctp_auth_ep_set_hmacs(struct sctp_endpoint *ep,
		return -EINVAL;
		return -EINVAL;


	for (i = 0; i < hmacs->shmac_num_idents; i++)
	for (i = 0; i < hmacs->shmac_num_idents; i++)
		ep->auth_hmacs_list->hmac_ids[i] = htons(hmacs->shmac_idents[i]);
		ep->auth_hmacs_list->hmac_ids[i] =
	ep->auth_hmacs_list->param_hdr.length = htons(sizeof(sctp_paramhdr_t) +
				htons(hmacs->shmac_idents[i]);
	ep->auth_hmacs_list->param_hdr.length =
			htons(sizeof(struct sctp_paramhdr) +
			hmacs->shmac_num_idents * sizeof(__u16));
			hmacs->shmac_num_idents * sizeof(__u16));
	return 0;
	return 0;
}
}
Loading