如题,有没有哪个函数结构可以自己分配终端IP的?比如任何终端连接,我只让分配192.168.1.2给它用。
Yue TANG:
只是建议。按理解,你需要对dhcp做配置。而dhcp只有一个配置项如下,你可以把ipv4_addr_start 和ipv4_addr_last 都设成192.168.1.2试试。
SlNetAppDhcpServerBasicOpt_t dhcpParams; unsigned char outLen = sizeof(SlNetAppDhcpServerBasicOpt_t); dhcpParams.lease_time = 1000; dhcpParams.ipv4_addr_start = SL_IPV4_VAL(192,168,1,2); // first IP Address for allocation. dhcpParams.ipv4_addr_last = SL_IPV4_VAL(192,168,1,2); // last IP Address for allocation.
lRetVal = sl_NetAppStop(SL_NET_APP_DHCP_SERVER_ID);
if (iRetVal < 0)return;
lRetVal = sl_NetAppSet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT,outLen, (unsigned char*)&dhcpParams);
if (iRetVal < 0)return;
lRetVal = sl_NetAppStart(SL_NET_APP_DHCP_SERVER_ID);
if (iRetVal < 0)return;
Viki Shi:
可以参考这个静态IP的例子:http://processors.wiki.ti.com/index.php/CC31xx_IP_Configuration_Application