Add an ancillary message to the buffer. Returns `true` if the message was added successfully.
(&mut self, msg: SendAncillaryMessage<'slice, 'fd>)
| 297 | /// |
| 298 | /// Returns `true` if the message was added successfully. |
| 299 | pub fn push(&mut self, msg: SendAncillaryMessage<'slice, 'fd>) -> bool { |
| 300 | match msg { |
| 301 | SendAncillaryMessage::ScmRights(fds) => { |
| 302 | let fds_bytes = |
| 303 | unsafe { slice::from_raw_parts(fds.as_ptr().cast::<u8>(), size_of_val(fds)) }; |
| 304 | self.push_ancillary(fds_bytes, c::SOL_SOCKET as _, c::SCM_RIGHTS as _) |
| 305 | } |
| 306 | #[cfg(linux_kernel)] |
| 307 | SendAncillaryMessage::ScmCredentials(ucred) => { |
| 308 | let ucred_bytes = unsafe { |
| 309 | slice::from_raw_parts(addr_of!(ucred).cast::<u8>(), size_of_val(&ucred)) |
| 310 | }; |
| 311 | self.push_ancillary(ucred_bytes, c::SOL_SOCKET as _, c::SCM_CREDENTIALS as _) |
| 312 | } |
| 313 | #[cfg(target_os = "linux")] |
| 314 | SendAncillaryMessage::TxTime(tx_time) => { |
| 315 | let tx_time_bytes = unsafe { |
| 316 | slice::from_raw_parts(addr_of!(tx_time).cast::<u8>(), size_of_val(&tx_time)) |
| 317 | }; |
| 318 | self.push_ancillary(tx_time_bytes, c::SOL_SOCKET as _, c::SO_TXTIME as _) |
| 319 | } |
| 320 | } |
| 321 | } |
| 322 | |
| 323 | /// Pushes an ancillary message to the buffer. |
| 324 | fn push_ancillary(&mut self, source: &[u8], cmsg_level: c::c_int, cmsg_type: c::c_int) -> bool { |