This patch is to add Stream Change Event described in section 6.1.3.

Signed-off-by: Xin Long <lucien....@gmail.com>
---
 include/net/sctp/ulpevent.h |  4 ++++
 include/uapi/linux/sctp.h   | 15 +++++++++++++++
 net/sctp/ulpevent.c         | 28 ++++++++++++++++++++++++++++
 3 files changed, 47 insertions(+)

diff --git a/include/net/sctp/ulpevent.h b/include/net/sctp/ulpevent.h
index 2ab7ed4..1060494 100644
--- a/include/net/sctp/ulpevent.h
+++ b/include/net/sctp/ulpevent.h
@@ -136,6 +136,10 @@ struct sctp_ulpevent *sctp_ulpevent_make_assoc_reset_event(
        const struct sctp_association *asoc, __u16 flags,
         __u32 local_tsn, __u32 remote_tsn, gfp_t gfp);
 
+struct sctp_ulpevent *sctp_ulpevent_make_stream_change_event(
+       const struct sctp_association *asoc, __u16 flags,
+       __u32 strchange_instrms, __u32 strchange_outstrms, gfp_t gfp);
+
 void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
                                   struct msghdr *);
 void sctp_ulpevent_read_rcvinfo(const struct sctp_ulpevent *event,
diff --git a/include/uapi/linux/sctp.h b/include/uapi/linux/sctp.h
index 9da165a..90a8e2c 100644
--- a/include/uapi/linux/sctp.h
+++ b/include/uapi/linux/sctp.h
@@ -514,6 +514,17 @@ struct sctp_assoc_reset_event {
        uint32_t assocreset_remote_tsn;
 };
 
+#define SCTP_ASSOC_CHANGE_DENIED       0x0004
+#define SCTP_ASSOC_CHANGE_FAILED       0x0008
+struct sctp_stream_change_event {
+       uint16_t strchange_type;
+       uint16_t strchange_flags;
+       uint32_t strchange_length;
+       sctp_assoc_t strchange_assoc_id;
+       uint16_t strchange_instrms;
+       uint16_t strchange_outstrms;
+};
+
 /*
  * Described in Section 7.3
  *   Ancillary Data and Notification Interest Options
@@ -531,6 +542,7 @@ struct sctp_event_subscribe {
        uint8_t sctp_sender_dry_event;
        uint8_t sctp_stream_reset_event;
        uint8_t sctp_assoc_reset_event;
+       uint8_t sctp_stream_change_event;
 };
 
 /*
@@ -557,6 +569,7 @@ union sctp_notification {
        struct sctp_sender_dry_event sn_sender_dry_event;
        struct sctp_stream_reset_event sn_strreset_event;
        struct sctp_assoc_reset_event sn_assocreset_event;
+       struct sctp_stream_change_event sn_strchange_event;
 };
 
 /* Section 5.3.1
@@ -588,6 +601,8 @@ enum sctp_sn_type {
 #define SCTP_STREAM_RESET_EVENT                SCTP_STREAM_RESET_EVENT
        SCTP_ASSOC_RESET_EVENT,
 #define SCTP_ASSOC_RESET_EVENT         SCTP_ASSOC_RESET_EVENT
+       SCTP_STREAM_CHANGE_EVENT,
+#define SCTP_STREAM_CHANGE_EVENT       SCTP_STREAM_CHANGE_EVENT
 };
 
 /* Notification error codes used to fill up the error fields in some
diff --git a/net/sctp/ulpevent.c b/net/sctp/ulpevent.c
index 5492cd7..c56460f 100644
--- a/net/sctp/ulpevent.c
+++ b/net/sctp/ulpevent.c
@@ -912,6 +912,34 @@ struct sctp_ulpevent *sctp_ulpevent_make_assoc_reset_event(
        return event;
 }
 
+struct sctp_ulpevent *sctp_ulpevent_make_stream_change_event(
+       const struct sctp_association *asoc, __u16 flags,
+       __u32 strchange_instrms, __u32 strchange_outstrms, gfp_t gfp)
+{
+       struct sctp_stream_change_event *schange;
+       struct sctp_ulpevent *event;
+       struct sk_buff *skb;
+
+       event = sctp_ulpevent_new(sizeof(struct sctp_stream_change_event),
+                                 MSG_NOTIFICATION, gfp);
+       if (!event)
+               return NULL;
+
+       skb = sctp_event2skb(event);
+       schange = (struct sctp_stream_change_event *)
+               skb_put(skb, sizeof(struct sctp_stream_change_event));
+
+       schange->strchange_type = SCTP_STREAM_CHANGE_EVENT;
+       schange->strchange_flags = flags;
+       schange->strchange_length = sizeof(struct sctp_stream_change_event);
+       sctp_ulpevent_set_owner(event, asoc);
+       schange->strchange_assoc_id = sctp_assoc2id(asoc);
+       schange->strchange_instrms = strchange_instrms;
+       schange->strchange_outstrms = strchange_outstrms;
+
+       return event;
+}
+
 /* Return the notification type, assuming this is a notification
  * event.
  */
-- 
2.1.0

Reply via email to