Skip to content

icmp ipv6可用 #709

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

icmp ipv6可用 #709

wants to merge 3 commits into from

Conversation

bamlan
Copy link

@bamlan bamlan commented Apr 8, 2025

windows:

PS E:\Codes\cpp\libhvN\build\bin\Debug> ./ping 2400:3200::1
64 bytes from 2400:3200::1: icmp_seq=1 time=43.1 ms
64 bytes from 2400:3200::1: icmp_seq=2 time=43.1 ms
64 bytes from 2400:3200::1: icmp_seq=3 time=43.0 ms
64 bytes from 2400:3200::1: icmp_seq=4 time=48.9 ms
--- 2400:3200::1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3172 ms
rtt min/avg/max = 43.016/44.509/48.893 ms
PS E:\Codes\cpp\libhvN\build\bin\Debug> ./ping baidu.com
64 bytes from 39.156.66.10: icmp_seq=1 ttl=49 time=42.6 ms
64 bytes from 39.156.66.10: icmp_seq=2 ttl=49 time=43.2 ms
64 bytes from 39.156.66.10: icmp_seq=3 ttl=49 time=43.1 ms
64 bytes from 39.156.66.10: icmp_seq=4 ttl=49 time=43.4 ms
--- baidu.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3172 ms
rtt min/avg/max = 42.563/43.057/43.420 ms
PS E:\Codes\cpp\libhvN\build\bin\Debug>

ubuntu:

n@NVBox:~/codes/cpp/libhvN/build/bin$ sudo ./ping baidu.com
64 bytes from 110.242.68.66: icmp_seq=1 ttl=50 time=46.8 ms
64 bytes from 110.242.68.66: icmp_seq=2 ttl=50 time=43.8 ms
64 bytes from 110.242.68.66: icmp_seq=3 ttl=50 time=43.9 ms
64 bytes from 110.242.68.66: icmp_seq=4 ttl=50 time=43.9 ms
--- baidu.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3180 ms
rtt min/avg/max = 43.790/44.589/46.763 ms
n@NVBox:~/codes/cpp/libhvN/build/bin$ sudo ./ping 2400:3200::1
64 bytes from 2400:3200::1: icmp_seq=1 time=44.7 ms
64 bytes from 2400:3200::1: icmp_seq=2 time=44.3 ms
64 bytes from 2400:3200::1: icmp_seq=3 time=43.8 ms
64 bytes from 2400:3200::1: icmp_seq=4 time=44.7 ms
--- 2400:3200::1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3180 ms
rtt min/avg/max = 43.804/44.368/44.679 ms

@@ -0,0 +1,15 @@
#include <stdio.h>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

存在一份unittest/ping_test.c可以复用

icmp_res->icmp_seq == seq) {
icmp_res = (icmp_t *)(recvbuf + iphdr_len);
if (!addr_ipv6) {
// IPv4校验需先把数据包中的校验码段置0
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不要使用中文

else
fprintf(stderr, "usage: ping <host ip or address>\n");
return 0;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hconfig.h这个文件还没决定是否删除,这个PR里先不要删

@@ -98,6 +98,11 @@ typedef struct tcphdr_s {
#define ICMP_ADDRESS 17 /* Address Mask Request */
#define ICMP_ADDRESSREPLY 18 /* Address Mask Reply */

#define ICMPV6_DEST_UNREACH 1
Copy link
Owner

@ithewei ithewei Apr 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

数值前增加空格对齐下吧

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

Successfully merging this pull request may close these issues.

2 participants