diff options
author | Geir Ola Vaagland <geirola@gmail.com> | 2014-07-12 14:30:37 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-07-16 17:40:03 -0400 |
commit | 0d3a421d284812d07970b4ccee74d4fa38737e4d (patch) | |
tree | c9d97227606c9682671e8d9e7d2ebfc727416c31 /include/uapi | |
parent | 63b949382c5f263746b1c177f6ff84de2201ae9d (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 'include/uapi')
-rw-r--r-- | include/uapi/linux/sctp.h | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/include/uapi/linux/sctp.h b/include/uapi/linux/sctp.h index a387761f7e02..29b81bbfc53d 100644 --- a/include/uapi/linux/sctp.h +++ b/include/uapi/linux/sctp.h | |||
@@ -95,6 +95,7 @@ typedef __s32 sctp_assoc_t; | |||
95 | #define SCTP_GET_ASSOC_ID_LIST 29 /* Read only */ | 95 | #define SCTP_GET_ASSOC_ID_LIST 29 /* Read only */ |
96 | #define SCTP_AUTO_ASCONF 30 | 96 | #define SCTP_AUTO_ASCONF 30 |
97 | #define SCTP_PEER_ADDR_THLDS 31 | 97 | #define SCTP_PEER_ADDR_THLDS 31 |
98 | #define SCTP_RECVRCVINFO 32 | ||
98 | 99 | ||
99 | /* Internal Socket Options. Some of the sctp library functions are | 100 | /* Internal Socket Options. Some of the sctp library functions are |
100 | * implemented using these socket options. | 101 | * implemented using these socket options. |
@@ -110,8 +111,7 @@ typedef __s32 sctp_assoc_t; | |||
110 | #define SCTP_SOCKOPT_CONNECTX3 111 /* CONNECTX requests (updated) */ | 111 | #define SCTP_SOCKOPT_CONNECTX3 111 /* CONNECTX requests (updated) */ |
111 | #define SCTP_GET_ASSOC_STATS 112 /* Read only */ | 112 | #define SCTP_GET_ASSOC_STATS 112 /* Read only */ |
112 | 113 | ||
113 | /* | 114 | /* 5.3.1 SCTP Initiation Structure (SCTP_INIT) |
114 | * 5.2.1 SCTP Initiation Structure (SCTP_INIT) | ||
115 | * | 115 | * |
116 | * This cmsghdr structure provides information for initializing new | 116 | * This cmsghdr structure provides information for initializing new |
117 | * SCTP associations with sendmsg(). The SCTP_INITMSG socket option | 117 | * SCTP associations with sendmsg(). The SCTP_INITMSG socket option |
@@ -121,7 +121,6 @@ typedef __s32 sctp_assoc_t; | |||
121 | * cmsg_level cmsg_type cmsg_data[] | 121 | * cmsg_level cmsg_type cmsg_data[] |
122 | * ------------ ------------ ---------------------- | 122 | * ------------ ------------ ---------------------- |
123 | * IPPROTO_SCTP SCTP_INIT struct sctp_initmsg | 123 | * IPPROTO_SCTP SCTP_INIT struct sctp_initmsg |
124 | * | ||
125 | */ | 124 | */ |
126 | struct sctp_initmsg { | 125 | struct sctp_initmsg { |
127 | __u16 sinit_num_ostreams; | 126 | __u16 sinit_num_ostreams; |
@@ -130,8 +129,7 @@ struct sctp_initmsg { | |||
130 | __u16 sinit_max_init_timeo; | 129 | __u16 sinit_max_init_timeo; |
131 | }; | 130 | }; |
132 | 131 | ||
133 | /* | 132 | /* 5.3.2 SCTP Header Information Structure (SCTP_SNDRCV) |
134 | * 5.2.2 SCTP Header Information Structure (SCTP_SNDRCV) | ||
135 | * | 133 | * |
136 | * This cmsghdr structure specifies SCTP options for sendmsg() and | 134 | * This cmsghdr structure specifies SCTP options for sendmsg() and |
137 | * describes SCTP header information about a received message through | 135 | * describes SCTP header information about a received message through |
@@ -140,7 +138,6 @@ struct sctp_initmsg { | |||
140 | * cmsg_level cmsg_type cmsg_data[] | 138 | * cmsg_level cmsg_type cmsg_data[] |
141 | * ------------ ------------ ---------------------- | 139 | * ------------ ------------ ---------------------- |
142 | * IPPROTO_SCTP SCTP_SNDRCV struct sctp_sndrcvinfo | 140 | * IPPROTO_SCTP SCTP_SNDRCV struct sctp_sndrcvinfo |
143 | * | ||
144 | */ | 141 | */ |
145 | struct sctp_sndrcvinfo { | 142 | struct sctp_sndrcvinfo { |
146 | __u16 sinfo_stream; | 143 | __u16 sinfo_stream; |
@@ -170,13 +167,32 @@ struct sctp_sndinfo { | |||
170 | sctp_assoc_t snd_assoc_id; | 167 | sctp_assoc_t snd_assoc_id; |
171 | }; | 168 | }; |
172 | 169 | ||
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 | |||
173 | /* | 190 | /* |
174 | * sinfo_flags: 16 bits (unsigned integer) | 191 | * sinfo_flags: 16 bits (unsigned integer) |
175 | * | 192 | * |
176 | * This field may contain any of the following flags and is composed of | 193 | * This field may contain any of the following flags and is composed of |
177 | * a bitwise OR of these values. | 194 | * a bitwise OR of these values. |
178 | */ | 195 | */ |
179 | |||
180 | enum sctp_sinfo_flags { | 196 | enum sctp_sinfo_flags { |
181 | SCTP_UNORDERED = 1, /* Send/receive message unordered. */ | 197 | SCTP_UNORDERED = 1, /* Send/receive message unordered. */ |
182 | SCTP_ADDR_OVER = 2, /* Override the primary destination. */ | 198 | SCTP_ADDR_OVER = 2, /* Override the primary destination. */ |
@@ -199,6 +215,8 @@ typedef enum sctp_cmsg_type { | |||
199 | #define SCTP_SNDRCV SCTP_SNDRCV | 215 | #define SCTP_SNDRCV SCTP_SNDRCV |
200 | SCTP_SNDINFO, /* 5.3.4 SCTP Send Information Structure */ | 216 | SCTP_SNDINFO, /* 5.3.4 SCTP Send Information Structure */ |
201 | #define SCTP_SNDINFO SCTP_SNDINFO | 217 | #define SCTP_SNDINFO SCTP_SNDINFO |
218 | SCTP_RCVINFO, /* 5.3.5 SCTP Receive Information Structure */ | ||
219 | #define SCTP_RCVINFO SCTP_RCVINFO | ||
202 | } sctp_cmsg_t; | 220 | } sctp_cmsg_t; |
203 | 221 | ||
204 | /* | 222 | /* |