移植好ipv6,版本升级之后遇到的一点小问题

发布于 2019-08-15 09:14:04    浏览:623
是这样的,我这段时间移植好ipv6之后,现在启用了ipv4和ipv6双版本,因为我们的产品大多用在机房中,客户需要产品支持ipv6,支持地址设置。
我在lwip初始化时给ipv6设置好了本地的地址,但是一查地址的时候就变成了自动获取的地址,我想怎么才能设置ipv6为静态地址。
[img]data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAn0AAABBCAYAAACkVBIyAAAONUlEQVR4nO2dyY3jOhCGFRcDqjS6Q+DFUfjOeyfRFyYwQF8eMAHUO0iySYqbFi89+j7AaMzQ5q7SryqKHP78+aN//vzR//77T1U1+/fz87OYDgAAAADvzzCLPtW7wOv95ITf10X0+8fq5eqe3RYAAAAAKDCknr7Pz0/9+/dv8/P5+ZnJzun1YvXnW/Ty5bMFfl+HYtqYbvTjY5g+Rq/fHa1wosMw3D/G6r0Ep3JLM2q9qrfm9l1j/ZTFEOcxDDrIXbhak6YbFVtux7KKG/P3Vs3t/0RdoU0z3lk1JtcPAAAAcGaynr5e0bfw9E0evp+vTrGW8mP1chH92dgYJ7EAChJu4u6OVzGyEEXemsx3VUehNYuu8fe2VF6Fbfk7lYWA82qT+nsrKtapR+kBAABAwmGevu/rEHjopk8Y4v2W2//nPH3Z31/sqsYURZ+3asSpqh89ZOJ0FlLLr/aKsvG7sjKKvTV/J0lZqZD1VmVtZQAAAOA0HOvpm8K631ejXwV33c+XKYd3f6xeVgq9kKroM3b6a0av2U0Ipl9d4YkzD/b0hfkn9V201YkasSq30K6ow+MHAAAAE0VPX+0FjuKavncVfXN41Ika60YxZXMh35YoS9bcbVBVe/K/icBZxCb5hmsUVb1ay5o+AAAAGDnM09cM7048U/Tdw6NeZRAVGVTcJLxMXnytCb9uYVf+U0g3F1b21uiQCMGyCAYAAICzcejbu7Og+7q8h6cvFEfWGDVmElVO1AxDdj3eW4s+9SpTOzJyVa0Z7t5Bn3v5AwAAAM7KoWv6vq+DXr+dXj/SN3CdXlMv4Meg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A6wFT99B1I1Kn6h6tehr3opLN8We9VODURvc5Rb9pbX2H7f+apfoS+pwF0X7y2+l94o+kcnLtyb/TtFXWd7fNb7F8ps08n+06Fs7/7xXb0uevEb6FtH37val2f+d/Vssvz3/3l/0fcRr+HLhXUX0wX7w9B1Ey6iM4Zj61RoKD2+laPwfE96N17j4aY1Nj6Eckyrtmxdgz22b1t8sRV+5/T3918Pm8O4UOrmFOH2nUO4sv5XeJ/qm/nNl4bc9vFuZH53jWyu/SjP/48K7m+a3jv0Xhr+9k0hIt9KDkorh3d9rX9r933V9l8rvmH9hu7wbPYvrRV+j/+Z1kVtU2c+XSvAih7teFi9yNMO7e8qH04Cn7wDChfPitLAoOl0IP60dCvNxyULtW+K0xUEl/GFNJn3VxR8vNB9M+OScLz/Ovt6+sI+MWHXWaLrFSLn9ff1Xpqf/jFrn6mv2fCN9c/n19J75FW7ZEi56H9Pb7U/HP/ciR3l+tMa3p/w6zfmTe1FgCBb7V9P3z29rRCVKj+dHKz2k9CLHr7YvrfFp9m+9/FXzw4g6Kyuvj5Z96tg2qdVFX1cdPj50+PhYbtkyNrL6IsdY/u/dvQGeA54+AH3dvmgACx60ZQs8kjES8MjtiOpbtvjGSx4AI3j64PREXoR33bsNTgUPIb+MaS3mw6Q6mzPDQeDpAwAAADgBePr+dYrbIaxfV/WWvLp9ry7/t0P//W4YP4BfBZ4+AAAAgBOApw8AAADgBODpAwAAADgB/wOpZJzGBRWoqgAAAABJRU5ErkJggg==[/img]


查看更多

9 个回答
aozima
aozima 2019-08-15
拒绝白嫖,拒绝键盘侠!
直接修改 netif 中的IPV6地址就可以了,写几行代码就可以。
kuailedeluojie
kuailedeluojie 2019-08-15
This guy hasn't written anything yet
inet_pton(AF_INET6,RT_LWIP_IPADDR,netif_default->ip6_addr);
kuailedeluojie
kuailedeluojie 2019-08-15
This guy hasn't written anything yet
aozima 发表于 2019-8-15 09:20
直接修改 netif 中的IPV6地址就可以了,写几行代码就可以。


inet_pton(AF_INET6,RT_LWIP_IPADDR,netif_default->ip6_addr);

这是我写的代码,有参考代码吗?这个问题卡了一点时间了。
aozima
aozima 2019-08-15
拒绝白嫖,拒绝键盘侠!
不能太懒啊!

void set_if6(char* netif_name, char* ip6_addr)
{
struct netif* netif = netif_list;

if(strlen(netif_name) > sizeof(netif->name))
{
rt_kprintf("network interface name too long!\r\n");
return;
}

while(netif != RT_NULL)
{
if(strncmp(netif_name, netif->name, sizeof(netif->name)) == 0)
break;

netif = netif->next;
if( netif == RT_NULL)
{
rt_kprintf("network interface: %s not found!\r\n", netif_name);
return;
}
}
struct ip6_addr ip6addr;
if((ip6_addr != RT_NULL) && ip6addr_aton(ip6_addr, &ip6addr))
{
ip6_addr_copy(netif->ip6_addr[1], ip6addr);
netif_ip6_addr_set_state(netif, 1, IP6_ADDR_TENTATIVE);
}
}
FINSH_FUNCTION_EXPORT(set_if6, set ipv6 local address)


---------------------
版权声明:本文为CSDN博主「hduffddybz」的原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处链接及本声明。
原文链接:
kuailedeluojie
kuailedeluojie 2019-08-15
This guy hasn't written anything yet
aozima 发表于 2019-8-15 09:52
不能太懒啊!




收到,谢谢!不是懒啊,是确实没找到这个,谢谢啊,谢谢啊!
kuailedeluojie
kuailedeluojie 2019-08-15
This guy hasn't written anything yet
kuailedeluojie
kuailedeluojie 2019-08-15
This guy hasn't written anything yet
aozima 发表于 2019-8-15 09:52
不能太懒啊!




第一次用这个函数的时候就出错误,死机
aozima
aozima 2019-08-15
拒绝白嫖,拒绝键盘侠!
单步调试一下,看哪里死机,并分析下原因。

另外,已解决的问题,记得及时回帖分享解决办法。
kuailedeluojie
kuailedeluojie 2019-08-15
This guy hasn't written anything yet
aozima 发表于 2019-8-15 15:31
单步调试一下,看哪里死机,并分析下原因。

另外,已解决的问题,记得及时回帖分享解决办法。 ...


新发了帖子,关注一下,是不是要把网卡先停一下才能再用这个函数。

撰写答案

请登录后再发布答案,点击登录
关注者
0
被浏览
623

发布
问题

分享
好友

手机
浏览

扫码手机浏览