Compare commits

..

No commits in common. "master" and "v0.2.0" have entirely different histories.

View File

@ -70,14 +70,10 @@ pub struct IcmpSocket4 {
}
impl IcmpSocket4 {
/// Construct a new raw socket. The socket must be bound to an address using `bind_to`
/// Construct a new socket. The socket must be bound to an address using `bind_to`
/// before it can be used to send and receive packets.
pub fn new() -> std::io::Result<Self> {
let socket = Socket::new(Domain::IPV4, Type::RAW, Some(Protocol::ICMPV4))?;
Self::new_from_socket(socket)
}
fn new_from_socket(socket: Socket) -> std::io::Result<Self> {
socket.set_recv_buffer_size(512)?;
Ok(Self {
bound_to: None,
@ -89,13 +85,6 @@ impl IcmpSocket4 {
},
})
}
/// Construct a new dgram socket. The socket must be bound to an address using `bind_to`
/// before it can be used to send and receive packets.
pub fn new_dgram_socket() -> std::io::Result<Self> {
let socket = Socket::new(Domain::IPV4, Type::DGRAM, Some(Protocol::ICMPV4))?;
Self::new_from_socket(socket)
}
}
impl IcmpSocket for IcmpSocket4 {
@ -147,14 +136,10 @@ pub struct IcmpSocket6 {
}
impl IcmpSocket6 {
/// Construct a new raw socket. The socket must be bound to an address using `bind_to`
/// Construct a new socket. The socket must be bound to an address using `bind_to`
/// before it can be used to send and receive packets.
pub fn new() -> std::io::Result<Self> {
let socket = Socket::new(Domain::IPV6, Type::RAW, Some(Protocol::ICMPV6))?;
Self::new_from_socket(socket)
}
fn new_from_socket(socket: Socket) -> std::io::Result<Self> {
socket.set_recv_buffer_size(512)?;
Ok(Self {
bound_to: None,
@ -166,13 +151,6 @@ impl IcmpSocket6 {
},
})
}
/// Construct a new dgram socket. The socket must be bound to an address using `bind_to`
/// before it can be used to send and receive packets.
pub fn new_dgram_socket() -> std::io::Result<Self> {
let socket = Socket::new(Domain::IPV6, Type::DGRAM, Some(Protocol::ICMPV6))?;
Self::new_from_socket(socket)
}
}
impl IcmpSocket for IcmpSocket6 {