Skip to content

Commit b444153

Browse files
lxindavem330
authored andcommitted
sctp: add support for generating add stream change event notification
This patch is to add Stream Change Event described in rfc6525 section 6.1.3. Signed-off-by: Xin Long <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 692787c commit b444153

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

include/net/sctp/ulpevent.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,10 @@ struct sctp_ulpevent *sctp_ulpevent_make_assoc_reset_event(
136136
const struct sctp_association *asoc, __u16 flags,
137137
__u32 local_tsn, __u32 remote_tsn, gfp_t gfp);
138138

139+
struct sctp_ulpevent *sctp_ulpevent_make_stream_change_event(
140+
const struct sctp_association *asoc, __u16 flags,
141+
__u32 strchange_instrms, __u32 strchange_outstrms, gfp_t gfp);
142+
139143
void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
140144
struct msghdr *);
141145
void sctp_ulpevent_read_rcvinfo(const struct sctp_ulpevent *event,

include/uapi/linux/sctp.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,17 @@ struct sctp_assoc_reset_event {
513513
__u32 assocreset_remote_tsn;
514514
};
515515

516+
#define SCTP_ASSOC_CHANGE_DENIED 0x0004
517+
#define SCTP_ASSOC_CHANGE_FAILED 0x0008
518+
struct sctp_stream_change_event {
519+
__u16 strchange_type;
520+
__u16 strchange_flags;
521+
__u32 strchange_length;
522+
sctp_assoc_t strchange_assoc_id;
523+
__u16 strchange_instrms;
524+
__u16 strchange_outstrms;
525+
};
526+
516527
/*
517528
* Described in Section 7.3
518529
* Ancillary Data and Notification Interest Options
@@ -530,6 +541,7 @@ struct sctp_event_subscribe {
530541
__u8 sctp_sender_dry_event;
531542
__u8 sctp_stream_reset_event;
532543
__u8 sctp_assoc_reset_event;
544+
__u8 sctp_stream_change_event;
533545
};
534546

535547
/*
@@ -556,6 +568,7 @@ union sctp_notification {
556568
struct sctp_sender_dry_event sn_sender_dry_event;
557569
struct sctp_stream_reset_event sn_strreset_event;
558570
struct sctp_assoc_reset_event sn_assocreset_event;
571+
struct sctp_stream_change_event sn_strchange_event;
559572
};
560573

561574
/* Section 5.3.1
@@ -587,6 +600,8 @@ enum sctp_sn_type {
587600
#define SCTP_STREAM_RESET_EVENT SCTP_STREAM_RESET_EVENT
588601
SCTP_ASSOC_RESET_EVENT,
589602
#define SCTP_ASSOC_RESET_EVENT SCTP_ASSOC_RESET_EVENT
603+
SCTP_STREAM_CHANGE_EVENT,
604+
#define SCTP_STREAM_CHANGE_EVENT SCTP_STREAM_CHANGE_EVENT
590605
};
591606

592607
/* Notification error codes used to fill up the error fields in some

net/sctp/ulpevent.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,34 @@ struct sctp_ulpevent *sctp_ulpevent_make_assoc_reset_event(
911911
return event;
912912
}
913913

914+
struct sctp_ulpevent *sctp_ulpevent_make_stream_change_event(
915+
const struct sctp_association *asoc, __u16 flags,
916+
__u32 strchange_instrms, __u32 strchange_outstrms, gfp_t gfp)
917+
{
918+
struct sctp_stream_change_event *schange;
919+
struct sctp_ulpevent *event;
920+
struct sk_buff *skb;
921+
922+
event = sctp_ulpevent_new(sizeof(struct sctp_stream_change_event),
923+
MSG_NOTIFICATION, gfp);
924+
if (!event)
925+
return NULL;
926+
927+
skb = sctp_event2skb(event);
928+
schange = (struct sctp_stream_change_event *)
929+
skb_put(skb, sizeof(struct sctp_stream_change_event));
930+
931+
schange->strchange_type = SCTP_STREAM_CHANGE_EVENT;
932+
schange->strchange_flags = flags;
933+
schange->strchange_length = sizeof(struct sctp_stream_change_event);
934+
sctp_ulpevent_set_owner(event, asoc);
935+
schange->strchange_assoc_id = sctp_assoc2id(asoc);
936+
schange->strchange_instrms = strchange_instrms;
937+
schange->strchange_outstrms = strchange_outstrms;
938+
939+
return event;
940+
}
941+
914942
/* Return the notification type, assuming this is a notification
915943
* event.
916944
*/

0 commit comments

Comments
 (0)