]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
sctp: add basic structures and make chunk function for idata
authorXin Long <lucien.xin@gmail.com>
Fri, 8 Dec 2017 13:04:00 +0000 (21:04 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 11 Dec 2017 16:23:04 +0000 (11:23 -0500)
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>
include/linux/sctp.h
include/net/sctp/sm.h
include/net/sctp/structs.h
net/sctp/sm_make_chunk.c

index 6d2bd64b6ffe8407567b0fad685a69d8f01731df..38e2cf66195f57a7d93ac13f9cdc0ad5484f0ba1 100644 (file)
@@ -243,6 +243,23 @@ struct sctp_data_chunk {
        struct sctp_datahdr data_hdr;
 };
 
+struct sctp_idatahdr {
+       __be32 tsn;
+       __be16 stream;
+       __be16 reserved;
+       __be32 mid;
+       union {
+               __u32 ppid;
+               __be32 fsn;
+       };
+       __u8 payload[0];
+};
+
+struct sctp_idata_chunk {
+       struct sctp_chunkhdr chunk_hdr;
+       struct sctp_idatahdr data_hdr;
+};
+
 /* DATA Chuck Specific Flags */
 enum {
        SCTP_DATA_MIDDLE_FRAG   = 0x00,
index 70fb397f65b0b8ff87492f6f29e826c84a1bd045..5389ae034cfa694fd8d7bde1e692a7b4fd21d2e4 100644 (file)
@@ -197,6 +197,8 @@ struct sctp_chunk *sctp_make_cookie_ack(const struct sctp_association *asoc,
 struct sctp_chunk *sctp_make_cwr(const struct sctp_association *asoc,
                                 const __u32 lowest_tsn,
                                 const struct sctp_chunk *chunk);
+struct sctp_chunk *sctp_make_idata(const struct sctp_association *asoc,
+                                  __u8 flags, int paylen, gfp_t gfp);
 struct sctp_chunk *sctp_make_datafrag_empty(struct sctp_association *asoc,
                                            const struct sctp_sndrcvinfo *sinfo,
                                            int len, const __u8 flags,
index 7030cbe11f45375a1728672c4a8c360d123341a9..7026a8039367efb35f62ba6ecacd40fcfb40dbc5 100644 (file)
@@ -575,6 +575,7 @@ struct sctp_chunk {
                struct sctp_addiphdr *addip_hdr;
                struct sctp_fwdtsn_hdr *fwdtsn_hdr;
                struct sctp_authhdr *auth_hdr;
+               struct sctp_idatahdr *idata_hdr;
        } subh;
 
        __u8 *chunk_end;
index da33c85501708ed20e700a29d84d707d77ae11e7..b969397fb7731dd337d3c7eb1c7a4b8a488eb854 100644 (file)
@@ -1425,6 +1425,12 @@ static struct sctp_chunk *sctp_make_data(const struct sctp_association *asoc,
        return _sctp_make_chunk(asoc, SCTP_CID_DATA, flags, paylen, gfp);
 }
 
+struct sctp_chunk *sctp_make_idata(const struct sctp_association *asoc,
+                                  __u8 flags, int paylen, gfp_t gfp)
+{
+       return _sctp_make_chunk(asoc, SCTP_CID_I_DATA, flags, paylen, gfp);
+}
+
 static struct sctp_chunk *sctp_make_control(const struct sctp_association *asoc,
                                            __u8 type, __u8 flags, int paylen,
                                            gfp_t gfp)