aboutsummaryrefslogtreecommitdiffstats
path: root/net/sctp/ulpevent.c
diff options
context:
space:
mode:
authorGeir Ola Vaagland <geirola@gmail.com>2014-07-12 14:30:37 -0400
committerDavid S. Miller <davem@davemloft.net>2014-07-16 17:40:03 -0400
commit0d3a421d284812d07970b4ccee74d4fa38737e4d (patch)
treec9d97227606c9682671e8d9e7d2ebfc727416c31 /net/sctp/ulpevent.c
parent63b949382c5f263746b1c177f6ff84de2201ae9d (diff)
net: sctp: implement rfc6458, 5.3.5. SCTP_RCVINFO cmsg support
This patch implements section 5.3.5. of RFC6458, that is, support for 'SCTP Receive Information Structure' (SCTP_RCVINFO) which is placed into ancillary data cmsghdr structure for each recvmsg() call. This option can be enabled/disabled via setsockopt(2) on SOL_SCTP level by setting an int value with 1/0 for SCTP_RECVRCVINFO in user space applications as per RFC6458, section 8.1.29. The sctp_rcvinfo structure is defined as per RFC as below ... struct sctp_rcvinfo { uint16_t rcv_sid; uint16_t rcv_ssn; uint16_t rcv_flags; <-- 2 bytes hole --> uint32_t rcv_ppid; uint32_t rcv_tsn; uint32_t rcv_cumtsn; uint32_t rcv_context; sctp_assoc_t rcv_assoc_id; }; ... and provided under cmsg_level IPPROTO_SCTP, cmsg_type SCTP_RCVINFO, while cmsg_data[] contains struct sctp_rcvinfo. An sctp_rcvinfo item always corresponds to the data in msg_iov. Joint work with Daniel Borkmann. Signed-off-by: Geir Ola Vaagland <geirola@gmail.com> Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/sctp/ulpevent.c')
-rw-r--r--net/sctp/ulpevent.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/net/sctp/ulpevent.c b/net/sctp/ulpevent.c
index b6842fdb53d4..b31f365f18ab 100644
--- a/net/sctp/ulpevent.c
+++ b/net/sctp/ulpevent.c
@@ -886,6 +886,31 @@ void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event,
886 sizeof(sinfo), &sinfo); 886 sizeof(sinfo), &sinfo);
887} 887}
888 888
889/* RFC6458, Section 5.3.5 SCTP Receive Information Structure
890 * (SCTP_SNDRCV)
891 */
892void sctp_ulpevent_read_rcvinfo(const struct sctp_ulpevent *event,
893 struct msghdr *msghdr)
894{
895 struct sctp_rcvinfo rinfo;
896
897 if (sctp_ulpevent_is_notification(event))
898 return;
899
900 memset(&rinfo, 0, sizeof(struct sctp_rcvinfo));
901 rinfo.rcv_sid = event->stream;
902 rinfo.rcv_ssn = event->ssn;
903 rinfo.rcv_ppid = event->ppid;
904 rinfo.rcv_flags = event->flags;
905 rinfo.rcv_tsn = event->tsn;
906 rinfo.rcv_cumtsn = event->cumtsn;
907 rinfo.rcv_assoc_id = sctp_assoc2id(event->asoc);
908 rinfo.rcv_context = event->asoc->default_rcv_context;
909
910 put_cmsg(msghdr, IPPROTO_SCTP, SCTP_RCVINFO,
911 sizeof(rinfo), &rinfo);
912}
913
889/* Do accounting for bytes received and hold a reference to the association 914/* Do accounting for bytes received and hold a reference to the association
890 * for each skb. 915 * for each skb.
891 */ 916 */