History

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.

Geir Ola Vaagland committed 12 years ago

Commit 0d3a4211 parent 63b94935 files · +105 −9Browse files

Showing the changes to include/uapi/linux (1 of 5 files). Show all

Unified · Split

include/uapi/linux/sctp.h+25−7
@@ -95,6 +95,7 @@ typedef __s32 sctp_assoc_t; · 94 unmodified lines
9595 #define SCTP_GET_ASSOC_ID_LIST 29 /* Read only */
9696 #define SCTP_AUTO_ASCONF 30
9797 #define SCTP_PEER_ADDR_THLDS 31
98+#define SCTP_RECVRCVINFO 32
9899
99100 /* Internal Socket Options. Some of the sctp library functions are
100101 * implemented using these socket options.
@@ -110,8 +111,7 @@ typedef __s32 sctp_assoc_t; · 9 unmodified lines
110111 #define SCTP_SOCKOPT_CONNECTX3 111 /* CONNECTX requests (updated) */
111112 #define SCTP_GET_ASSOC_STATS 112 /* Read only */
112113
113−/*
114− * 5.2.1 SCTP Initiation Structure (SCTP_INIT)
114+/* 5.3.1 SCTP Initiation Structure (SCTP_INIT)
115115 *
116116 * This cmsghdr structure provides information for initializing new
117117 * SCTP associations with sendmsg(). The SCTP_INITMSG socket option
@@ -121,7 +121,6 @@ typedef __s32 sctp_assoc_t; · 3 unmodified lines
121121 * cmsg_level cmsg_type cmsg_data[]
122122 * ------------ ------------ ----------------------
123123 * IPPROTO_SCTP SCTP_INIT struct sctp_initmsg
124− *
125124 */
126125 struct sctp_initmsg {
127126 __u16 sinit_num_ostreams;
@@ -130,8 +129,7 @@ struct sctp_initmsg { · 2 unmodified lines
130129 __u16 sinit_max_init_timeo;
131130 };
132131
133−/*
134− * 5.2.2 SCTP Header Information Structure (SCTP_SNDRCV)
132+/* 5.3.2 SCTP Header Information Structure (SCTP_SNDRCV)
135133 *
136134 * This cmsghdr structure specifies SCTP options for sendmsg() and
137135 * describes SCTP header information about a received message through
@@ -140,7 +138,6 @@ struct sctp_initmsg { · 2 unmodified lines
140138 * cmsg_level cmsg_type cmsg_data[]
141139 * ------------ ------------ ----------------------
142140 * IPPROTO_SCTP SCTP_SNDRCV struct sctp_sndrcvinfo
143− *
144141 */
145142 struct sctp_sndrcvinfo {
146143 __u16 sinfo_stream;
@@ -170,13 +167,32 @@ struct sctp_sndinfo { · 23 unmodified lines
170167 sctp_assoc_t snd_assoc_id;
171168 };
172169
170+/* 5.3.5 SCTP Receive Information Structure (SCTP_RCVINFO)
171+ *
172+ * This cmsghdr structure describes SCTP receive information
173+ * about a received message through recvmsg().
174+ *
175+ * cmsg_level cmsg_type cmsg_data[]
176+ * ------------ ------------ -------------------
177+ * IPPROTO_SCTP SCTP_RCVINFO struct sctp_rcvinfo
178+ */
179+struct sctp_rcvinfo {
180+ __u16 rcv_sid;
181+ __u16 rcv_ssn;
182+ __u16 rcv_flags;
183+ __u32 rcv_ppid;
184+ __u32 rcv_tsn;
185+ __u32 rcv_cumtsn;
186+ __u32 rcv_context;
187+ sctp_assoc_t rcv_assoc_id;
188+};
189+
173190 /*
174191 * sinfo_flags: 16 bits (unsigned integer)
175192 *
176193 * This field may contain any of the following flags and is composed of
177194 * a bitwise OR of these values.
178195 */
179−
180196 enum sctp_sinfo_flags {
181197 SCTP_UNORDERED = 1, /* Send/receive message unordered. */
182198 SCTP_ADDR_OVER = 2, /* Override the primary destination. */
@@ -199,6 +215,8 @@ typedef enum sctp_cmsg_type { · 16 unmodified lines
199215 #define SCTP_SNDRCV SCTP_SNDRCV
200216 SCTP_SNDINFO, /* 5.3.4 SCTP Send Information Structure */
201217 #define SCTP_SNDINFO SCTP_SNDINFO
218+ SCTP_RCVINFO, /* 5.3.5 SCTP Receive Information Structure */
219+#define SCTP_RCVINFO SCTP_RCVINFO
202220 } sctp_cmsg_t;
203221
204222 /*