diff options
author | Xin Long <lucien.xin@gmail.com> | 2017-12-08 08:04:00 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-12-11 11:23:04 -0500 |
commit | ad05a7a05ede28ba6dd935d9e932264a22518b1f (patch) | |
tree | 9a60d1b471879cce652cd1eeae0f0735913aa039 | |
parent | 96b120b3c1397c90b64d1f4b2300fb7ce4aa8a68 (diff) |
sctp: add basic structures and make chunk function for idata
sctp_idatahdr and sctp_idata_chunk are used to define and parse
I-DATA chunk format, and sctp_make_idata is a function to build
the chunk.
The I-DATA Chunk Format is defined in section 2.1 of RFC8260.
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/sctp.h | 17 | ||||
-rw-r--r-- | include/net/sctp/sm.h | 2 | ||||
-rw-r--r-- | include/net/sctp/structs.h | 1 | ||||
-rw-r--r-- | net/sctp/sm_make_chunk.c | 6 |
4 files changed, 26 insertions, 0 deletions
diff --git a/include/linux/sctp.h b/include/linux/sctp.h index 6d2bd64b6ffe..38e2cf66195f 100644 --- a/include/linux/sctp.h +++ b/include/linux/sctp.h | |||
@@ -243,6 +243,23 @@ struct sctp_data_chunk { | |||
243 | struct sctp_datahdr data_hdr; | 243 | struct sctp_datahdr data_hdr; |
244 | }; | 244 | }; |
245 | 245 | ||
246 | struct sctp_idatahdr { | ||
247 | __be32 tsn; | ||
248 | __be16 stream; | ||
249 | __be16 reserved; | ||
250 | __be32 mid; | ||
251 | union { | ||
252 | __u32 ppid; | ||
253 | __be32 fsn; | ||
254 | }; | ||
255 | __u8 payload[0]; | ||
256 | }; | ||
257 | |||
258 | struct sctp_idata_chunk { | ||
259 | struct sctp_chunkhdr chunk_hdr; | ||
260 | struct sctp_idatahdr data_hdr; | ||
261 | }; | ||
262 | |||
246 | /* DATA Chuck Specific Flags */ | 263 | /* DATA Chuck Specific Flags */ |
247 | enum { | 264 | enum { |
248 | SCTP_DATA_MIDDLE_FRAG = 0x00, | 265 | SCTP_DATA_MIDDLE_FRAG = 0x00, |
diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h index 70fb397f65b0..5389ae034cfa 100644 --- a/include/net/sctp/sm.h +++ b/include/net/sctp/sm.h | |||
@@ -197,6 +197,8 @@ struct sctp_chunk *sctp_make_cookie_ack(const struct sctp_association *asoc, | |||
197 | struct sctp_chunk *sctp_make_cwr(const struct sctp_association *asoc, | 197 | struct sctp_chunk *sctp_make_cwr(const struct sctp_association *asoc, |
198 | const __u32 lowest_tsn, | 198 | const __u32 lowest_tsn, |
199 | const struct sctp_chunk *chunk); | 199 | const struct sctp_chunk *chunk); |
200 | struct sctp_chunk *sctp_make_idata(const struct sctp_association *asoc, | ||
201 | __u8 flags, int paylen, gfp_t gfp); | ||
200 | struct sctp_chunk *sctp_make_datafrag_empty(struct sctp_association *asoc, | 202 | struct sctp_chunk *sctp_make_datafrag_empty(struct sctp_association *asoc, |
201 | const struct sctp_sndrcvinfo *sinfo, | 203 | const struct sctp_sndrcvinfo *sinfo, |
202 | int len, const __u8 flags, | 204 | int len, const __u8 flags, |
diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h index 7030cbe11f45..7026a8039367 100644 --- a/include/net/sctp/structs.h +++ b/include/net/sctp/structs.h | |||
@@ -575,6 +575,7 @@ struct sctp_chunk { | |||
575 | struct sctp_addiphdr *addip_hdr; | 575 | struct sctp_addiphdr *addip_hdr; |
576 | struct sctp_fwdtsn_hdr *fwdtsn_hdr; | 576 | struct sctp_fwdtsn_hdr *fwdtsn_hdr; |
577 | struct sctp_authhdr *auth_hdr; | 577 | struct sctp_authhdr *auth_hdr; |
578 | struct sctp_idatahdr *idata_hdr; | ||
578 | } subh; | 579 | } subh; |
579 | 580 | ||
580 | __u8 *chunk_end; | 581 | __u8 *chunk_end; |
diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c index da33c8550170..b969397fb773 100644 --- a/net/sctp/sm_make_chunk.c +++ b/net/sctp/sm_make_chunk.c | |||
@@ -1425,6 +1425,12 @@ static struct sctp_chunk *sctp_make_data(const struct sctp_association *asoc, | |||
1425 | return _sctp_make_chunk(asoc, SCTP_CID_DATA, flags, paylen, gfp); | 1425 | return _sctp_make_chunk(asoc, SCTP_CID_DATA, flags, paylen, gfp); |
1426 | } | 1426 | } |
1427 | 1427 | ||
1428 | struct sctp_chunk *sctp_make_idata(const struct sctp_association *asoc, | ||
1429 | __u8 flags, int paylen, gfp_t gfp) | ||
1430 | { | ||
1431 | return _sctp_make_chunk(asoc, SCTP_CID_I_DATA, flags, paylen, gfp); | ||
1432 | } | ||
1433 | |||
1428 | static struct sctp_chunk *sctp_make_control(const struct sctp_association *asoc, | 1434 | static struct sctp_chunk *sctp_make_control(const struct sctp_association *asoc, |
1429 | __u8 type, __u8 flags, int paylen, | 1435 | __u8 type, __u8 flags, int paylen, |
1430 | gfp_t gfp) | 1436 | gfp_t gfp) |