Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get an echo response for IPv6. #19

Closed
kkazuo opened this issue May 13, 2022 · 1 comment
Closed

Can't get an echo response for IPv6. #19

kkazuo opened this issue May 13, 2022 · 1 comment

Comments

@kkazuo
Copy link

kkazuo commented May 13, 2022

Thank you for making such a great crate.
I am wondering because I just can't get an echo response for IPv6.

And I made this little patch.
Can I hear your thoughts?

Thanks.


patch diff.

diff --git a/src/client.rs b/src/client.rs
index 41bf474..30cc1c8 100644
--- a/src/client.rs
+++ b/src/client.rs
@@ -179,8 +179,7 @@ fn gen_uuid_with_payload(addr: IpAddr, datas: &[u8]) -> Option<Uuid> {
             }
         }
         IpAddr::V6(_) => {
-            if let Some(ipv6_packet) = ipv6::Ipv6Packet::new(datas) {
-                if let Some(icmpv6_packet) = icmpv6::Icmpv6Packet::new(ipv6_packet.payload()) {
+                if let Some(icmpv6_packet) = icmpv6::Icmpv6Packet::new(datas) {
                     let payload = icmpv6_packet.payload();

                     if payload.len() < 20 {
@@ -190,7 +189,6 @@ fn gen_uuid_with_payload(addr: IpAddr, datas: &[u8]) -> Option<Uuid> {
                     let uuid = &payload[4..20];
                     return Uuid::from_slice(uuid).ok();
                 }
-            }
         }
     }
     None

Results without patch. ipv6 something went wrong.

% sudo ./target/debug/examples/simple --host 127.0.0.1
V4(Icmpv4Packet { source: 127.0.0.1, destination: 127.0.0.1, ttl: 64, icmp_type: IcmpType(0), icmp_code: IcmpCode(0), size: 64, real_dest: 127.0.0.1, identifier: 111, sequence: 0 }) 90.90µs
% sudo ./target/debug/examples/simple --host ::1
Request timeout for icmp_seq 0

Results with patch. it looks good.

% sudo ./target/debug/examples/simple --host 127.0.0.1
V4(Icmpv4Packet { source: 127.0.0.1, destination: 127.0.0.1, ttl: 64, icmp_type: IcmpType(0), icmp_code: IcmpCode(0), size: 64, real_dest: 127.0.0.1, identifier: 111, sequence: 0 }) 55.15µs
% sudo ./target/debug/examples/simple --host ::1
V6(Icmpv6Packet { source: ::1, destination: ::1, max_hop_limit: 0, icmpv6_type: Icmpv6Type(129), icmpv6_code: Icmpv6Code(0), size: 64, real_dest: ::1, identifier: 111, sequence: 0 }) 161.13µs
@kolapapa
Copy link
Owner

Thanks a lot for helping to find this problem~ 😊

My network support for IPv6 is not good enough, it has been unable to test.
Today, I have incorporated it into the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants