mirror of
https://github.com/zaphar/icmp-socket.git
synced 2025-07-22 19:30:05 -04:00
Fix binding of socket for examples
This commit is contained in:
parent
931113a868
commit
b85822c95d
@ -20,7 +20,7 @@ pub fn main() {
|
||||
let address = std::env::args().nth(1).unwrap_or("127.0.0.1".to_owned());
|
||||
let mut socket4 = IcmpSocket4::new().unwrap();
|
||||
socket4
|
||||
.bind("127.0.0.1".parse::<Ipv4Addr>().unwrap())
|
||||
.bind("0.0.0.0".parse::<Ipv4Addr>().unwrap())
|
||||
.unwrap();
|
||||
let mut echo_socket = echo::EchoSocket::new(socket4);
|
||||
echo_socket
|
||||
|
@ -19,7 +19,7 @@ use icmp_socket::*;
|
||||
pub fn main() {
|
||||
let address = std::env::args().nth(1).unwrap_or("::1".to_owned());
|
||||
let mut socket6 = IcmpSocket6::new().unwrap();
|
||||
socket6.bind("::1".parse::<Ipv6Addr>().unwrap()).unwrap();
|
||||
socket6.bind("::0".parse::<Ipv6Addr>().unwrap()).unwrap();
|
||||
let mut echo_socket = echo::EchoSocket::new(socket6);
|
||||
echo_socket
|
||||
.send_ping(
|
||||
|
@ -79,10 +79,8 @@ impl IcmpSocket for IcmpSocket4 {
|
||||
fn send_to(&mut self, dest: Self::AddrType, packet: Self::PacketType) -> std::io::Result<()> {
|
||||
let dest = ip_to_socket(&IpAddr::V4(dest));
|
||||
self.inner.set_ttl(self.opts.hops)?;
|
||||
self.inner.send_to(
|
||||
dbg!(&packet.with_checksum().get_bytes(true)),
|
||||
&(dbg!(dest.into())),
|
||||
)?;
|
||||
self.inner
|
||||
.send_to(&packet.with_checksum().get_bytes(true), &(dest.into()))?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user