net: sctp: implement rfc6458, 5.3.5. SCTP_RCVINFO cmsg support
[deliverable/linux.git] / net / sctp / ulpevent.c
index b6842fdb53d4b09ffdafec78c2bab535e6eaad2d..b31f365f18ab0ce39a44b319cdfa24a027313850 100644 (file)
@@ -886,6 +886,31 @@ void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
                 sizeof(sinfo), &sinfo);
 }
 
+/* RFC6458, Section 5.3.5 SCTP Receive Information Structure
+ * (SCTP_SNDRCV)
+ */
+void sctp_ulpevent_read_rcvinfo(const struct sctp_ulpevent *event,
+                               struct msghdr *msghdr)
+{
+       struct sctp_rcvinfo rinfo;
+
+       if (sctp_ulpevent_is_notification(event))
+               return;
+
+       memset(&rinfo, 0, sizeof(struct sctp_rcvinfo));
+       rinfo.rcv_sid = event->stream;
+       rinfo.rcv_ssn = event->ssn;
+       rinfo.rcv_ppid = event->ppid;
+       rinfo.rcv_flags = event->flags;
+       rinfo.rcv_tsn = event->tsn;
+       rinfo.rcv_cumtsn = event->cumtsn;
+       rinfo.rcv_assoc_id = sctp_assoc2id(event->asoc);
+       rinfo.rcv_context = event->asoc->default_rcv_context;
+
+       put_cmsg(msghdr, IPPROTO_SCTP, SCTP_RCVINFO,
+                sizeof(rinfo), &rinfo);
+}
+
 /* Do accounting for bytes received and hold a reference to the association
  * for each skb.
  */
This page took 0.027347 seconds and 5 git commands to generate.