/// Creates a new `AncillaryData` instance representing the data in `cmsghdr`.
///
/// # Parameters
/// - `task`: The task that is used to read the data from the `cmsghdr`.
/// - `message_header`: The message header struct that this `AncillaryData` represents.
Creates a new `AncillaryData` instance representing the data in `cmsghdr`.
Creates a new ` AncillaryData ` instance representing the data in ` cmsghdr ` .
pub fn new(task: &Task, message_header: cmsghdr) -> Result<Self, Errno> {
        if message_header.cmsg_level != SOL_SOCKET {
            return error!(EINVAL);
        }
        if message_header.cmsg_type != AF_UNIX as u32 {
            return error!(EINVAL);
        }
        // If the message header is not long enough to fit the required fields of the
        // control data, return EINVAL.
        if message_header.cmsg_len < cmsghdr::header_length() {
            return error!(EINVAL);
        }
        // If the message data length is greater than the number of bytes that can fit in the array,
        // return EINVAL.
        if message_header.data_length() > message_header.cmsg_data.len() {
            return error!(EINVAL);
        }
        Ok(AncillaryData::Unix(UnixControlData::new(task, message_header)?))
    }
pub fn new ( task : & Task , message_header : cmsghdr ) -> Result < Self , Errno > { if message_header . cmsg_level != SOL_SOCKET { return error ! ( EINVAL ) ; } if message_header . cmsg_type != AF_UNIX as u32 { return error ! ( EINVAL ) ; } // If the message header is not long enough to fit the required fields of the // control data, return EINVAL. if message_header . cmsg_len < cmsghdr :: header_length ( ) { return error ! ( EINVAL ) ; } // If the message data length is greater than the number of bytes that can fit in the array, // return EINVAL. if message_header . data_length ( ) > message_header . cmsg_data . len ( ) { return error ! ( EINVAL ) ; } Ok ( AncillaryData :: Unix ( UnixControlData :: new ( task , message_header ) ? ) ) }
Creates a new `AncillaryData` instance representing the data in `cmsghdr`.
Creates a new ` AncillaryData ` instance representing the data in ` cmsghdr ` .
task
&Task
The task that is used to read the data from the `cmsghdr`.
The task that is used to read the data from the ` cmsghdr ` .
message_header
cmsghdr
The message header struct that this `AncillaryData` represents.
The message header struct that this ` AncillaryData ` represents .