Support IPPROTO_IPV6

f-stack中缺乏对`IPPROTO_IPV6`协议相关选项`IPV6_V6ONLY`的支持;无法在ipv6兼容ipv4场景进行网络通信。调用setsockopt时会出现失败。
This commit is contained in:
Hawker 2021-02-07 15:41:58 +08:00 committed by fengbojiang
parent 64362bc1ac
commit d428f7900c
1 changed files with 15 additions and 0 deletions

View File

@ -94,6 +94,8 @@
#define LINUX_IP_ADD_MEMBERSHIP 35
#define LINUX_IP_DROP_MEMBERSHIP 36
#define LINUX_IPV6_V6ONLY 26
#define LINUX_TCP_NODELAY 1
#define LINUX_TCP_MAXSEG 2
#define LINUX_TCP_KEEPIDLE 4
@ -383,6 +385,17 @@ ip_opt_convert(int optname)
}
}
static int
ip6_opt_convert(int optname)
{
switch(optname) {
case LINUX_IPV6_V6ONLY:
return IPV6_V6ONLY;
default:
return optname;
}
}
static int
tcp_opt_convert(int optname)
{
@ -414,6 +427,8 @@ linux2freebsd_opt(int level, int optname)
return so_opt_convert(optname);
case IPPROTO_IP:
return ip_opt_convert(optname);
case IPPROTO_IPV6:
return ip6_opt_convert(optname);
case IPPROTO_TCP:
return tcp_opt_convert(optname);
default: