Skip to content

Not able to create IPv6 raw socket #517

Description

@jjnicola

I have the following function (also one for IPv4 with the IPV4 domain, which works as expected)

fn new_raw_ipv6_socket() -> Result<Socket, FunctionErrorKind> {
    match Socket::new(
        Domain::IPV6, // 10
        socket2::Type::RAW, // 3
        Some(Protocol::from(IPPROTO_RAW)), // 255
    ) {
        Ok(s) => Ok(s),
        Err(e) => Err(FunctionErrorKind::Dirty(format!(
            "new_raw_ipv6_socket: Not possible to create a raw socket: {}",
            e
        ))),
    }
}

If I call the function and try to set an option:

    let soc = new_raw_ipv6_socket()?; // do not fails here

    if let Err(e) = soc.set_header_included(true) { // It fails here
        return Err(FunctionErrorKind::Dirty(format!(
            "Not possible to create a raw socket: {}",
            e
        )));
    };

I get the following error:

send_v6packet: Not possible to create a raw socket: Protocol not available (os error 92)

Is this a bug or I am doing something wrong? This is working as expected in the program written in C. So, I discard some permission issue or OS issue. Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions