【求助】可以使用netifapi_netif_set_addr修改IP立即生效吗?

发布于 2014-06-04 00:41:42    浏览:2007
如题
stm32F103ze +enc28j60
rt1.2.1

netifapi_netif_set_addr 修改IP后 新旧IP都不通了。

查看更多

3 个回答
sxf_zero
sxf_zero 2014-06-04
This guy hasn't written anything yet
	  if (netif_default != RT_NULL)
{
struct ip_addr ipaddr, netmask, gw;

IP4_ADDR(&ipaddr, apcfg->DriveIP[0], apcfg->DriveIP[1], apcfg->DriveIP[2], apcfg->DriveIP[3]);
IP4_ADDR(&gw,apcfg->DriveGateWay[0], apcfg->DriveGateWay[1], apcfg->DriveGateWay[2],apcfg->DriveGateWay[3]);
IP4_ADDR(&netmask, apcfg->DriveIPMASK[0], apcfg->DriveIPMASK[1],apcfg->DriveIPMASK[2], apcfg->DriveIPMASK[3]);


netifapi_netif_set_addr(netif_default, &ipaddr, &netmask, &gw);

rt_kprintf("ip=%d.%d.%d.%d
",apcfg->DriveIP[0], apcfg->DriveIP[1], apcfg->DriveIP[2], apcfg->DriveIP[3]);
rt_kprintf("gw=%d.%d.%d.%d
",apcfg->DriveGateWay[0], apcfg->DriveGateWay[1], apcfg->DriveGateWay[2], apcfg->DriveGateWay[3]);
rt_kprintf("mask=%d.%d.%d.%d
",apcfg->DriveIPMASK[0], apcfg->DriveIPMASK[1], apcfg->DriveIPMASK[2], apcfg->DriveIPMASK[3]);
}


修改IP时用的就是上面的代码,
aozima
aozima 2014-06-04
拒绝白嫖,拒绝键盘侠!
finsh>>set_if("e0", *****)

撰写答案

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

发布
问题

分享
好友

手机
浏览

扫码手机浏览