Skip to content

Commit dc2ca42

Browse files
Parse SOL_TLS control message, closes #2064
1 parent 996db47 commit dc2ca42

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
@@ -856,6 +856,11 @@ pub enum ControlMessageOwned {
856856
#[cfg_attr(docsrs, doc(cfg(feature = "net")))]
857857
Ipv6RecvErr(libc::sock_extended_err, Option<sockaddr_in6>),
858858

859+
/// `SOL_TLS` messages of type `TLS_GET_RECORD_TYPE`, containing the TLS message content type,
860+
/// normally one of change_cipher_spec(20), alert(21), handshake(22) (for TLS 1.3
861+
/// resumption tickets), application_data(23)
862+
TlsGetRecordType(u8),
863+
859864
/// Catch-all variant for unimplemented cmsg types.
860865
#[doc(hidden)]
861866
Unknown(UnknownCmsg),
@@ -873,6 +878,12 @@ pub struct Timestamps {
873878
pub hw_raw: TimeSpec,
874879
}
875880

881+
// Defined in `linux/tls.h`
882+
#[cfg(all(target_os = "linux"))]
883+
const TLS_GET_RECORD_TYPE: c_int = 2;
884+
885+
const SOL_TLS: c_int = 282;
886+
876887
impl ControlMessageOwned {
877888
/// Decodes a `ControlMessageOwned` from raw bytes.
878889
///
@@ -1015,6 +1026,11 @@ impl ControlMessageOwned {
10151026
let dl = ptr::read_unaligned(p as *const libc::sockaddr_in6);
10161027
ControlMessageOwned::Ipv6OrigDstAddr(dl)
10171028
},
1029+
#[cfg(all(target_os = "linux"))]
1030+
(SOL_TLS, TLS_GET_RECORD_TYPE) => {
1031+
let content_type = ptr::read_unaligned(p as *const u8);
1032+
ControlMessageOwned::TlsGetRecordType(content_type)
1033+
},
10181034
(_, _) => {
10191035
let sl = std::slice::from_raw_parts(p, len);
10201036
let ucmsg = UnknownCmsg(*header, Vec::<u8>::from(sl));

0 commit comments

Comments
 (0)