Skip to content

Commit aac9141

Browse files
Parse SOL_TLS control message, closes #2064
1 parent 9a3010b commit aac9141

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/sys/socket/mod.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,11 @@ pub enum ControlMessageOwned {
829829
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
830830
Ipv6RecvErr(libc::sock_extended_err, Option<sockaddr_in6>),
831831

832+
/// `SOL_TLS` messages of type `TLS_GET_RECORD_TYPE`, containing the TLS message content type,
833+
/// normally one of change_cipher_spec(20), alert(21), handshake(22) (for TLS 1.3
834+
/// resumption tickets), application_data(23)
835+
TlsGetRecordType(u8),
836+
832837
/// Catch-all variant for unimplemented cmsg types.
833838
#[doc(hidden)]
834839
Unknown(UnknownCmsg),
@@ -846,6 +851,12 @@ pub struct Timestamps {
846851
pub hw_raw: TimeSpec,
847852
}
848853

854+
// Defined in `linux/tls.h`
855+
#[cfg(all(target_os = "linux"))]
856+
const TLS_GET_RECORD_TYPE: c_int = 2;
857+
858+
const SOL_TLS: c_int = 282;
859+
849860
impl ControlMessageOwned {
850861
/// Decodes a `ControlMessageOwned` from raw bytes.
851862
///
@@ -988,6 +999,11 @@ impl ControlMessageOwned {
988999
let dl = ptr::read_unaligned(p as *const libc::sockaddr_in6);
9891000
ControlMessageOwned::Ipv6OrigDstAddr(dl)
9901001
},
1002+
#[cfg(all(target_os = "linux"))]
1003+
(SOL_TLS, TLS_GET_RECORD_TYPE) => {
1004+
let content_type = ptr::read_unaligned(p as *const u8);
1005+
ControlMessageOwned::TlsGetRecordType(content_type)
1006+
},
9911007
(_, _) => {
9921008
let sl = std::slice::from_raw_parts(p, len);
9931009
let ucmsg = UnknownCmsg(*header, Vec::<u8>::from(sl));

0 commit comments

Comments
 (0)