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

protocol/icmp在IPv6下recvfrom返回错误 #613

Open
bamlan opened this issue Aug 27, 2024 · 5 comments
Open

protocol/icmp在IPv6下recvfrom返回错误 #613

bamlan opened this issue Aug 27, 2024 · 5 comments

Comments

@bamlan
Copy link

bamlan commented Aug 27, 2024

protocol/icmp在IPv6下无法使用, sendto调用正常返回,windows下recvfrom时错误代码10060, linux下错误代码 11

@bamlan bamlan changed the title i protocol/icmp在IPv6下recvfrom返回错误 Aug 27, 2024
@ithewei
Copy link
Owner

ithewei commented Aug 27, 2024

通过so_rcvtimeo设置了接收超时的,windows 10060和linux 11错误码都是超时未收到响应导致的,这个是正常现象

@bamlan
Copy link
Author

bamlan commented Aug 27, 2024

通过so_rcvtimeo设置了接收超时的,windows 10060和linux 11错误码都是超时未收到响应导致的,这个是正常现象

但我把超时时间设置为30秒都显示超时状态,ping ipv4地址就正常返回,地址使用系统ping程序都是正常能ping通的。

@ithewei
Copy link
Owner

ithewei commented Aug 27, 2024

我发现有个socket选项可能没用适配ipv6,把IPPROTO_ICMP改成IPPROTO_ICMPV6试试呢

@bamlan
Copy link
Author

bamlan commented Aug 28, 2024

我发现有个socket选项可能没用适配ipv6,把IPPROTO_ICMP改成IPPROTO_ICMPV6试试呢

修改成:int sockfd = socket(peeraddr.sa.sa_family, SOCK_RAW, peeraddr.sa.sa_family == AF_INET6 ? IPPROTO_ICMPV6 : IPPROTO_ICMP); 还是一样的运行结果

@ithewei
Copy link
Owner

ithewei commented Sep 2, 2024

应该是ICMPV6和ICMP的报文内容也不同,需要详细研究下

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