这些小活动你都参加了吗?快来围观一下吧!>>
电子产品世界 » 论坛首页 » 嵌入式开发 » MCU » vxworks下使用dhcp获取参数的问题

共1条 1/1 1 跳转至

vxworks下使用dhcp获取参数的问题

菜鸟
2007-06-21 05:00:15     打赏

网口先用固定的IP启动,然后尝试使用下面的代码进行DHCP配置,每次运行后ifShow能看到设备ip地址等信息均发生了重配置,但是dhcpcParamsGet获取到的参数全部为0,请大家看看代码哪有问题?谢谢!

#include <vxWorks.h>
#include <taskLib.h>

#include <stdio.h>
#include <ifLib.h>
#include <dhcpcLib.h>

void * pLeaseCookie;
struct dhcp_param ParamList;

void dtmdhcpcEventHookRtn
(
int leaseEvent, /* new or expired parameters */
void * pCookie /* lease identifier from dhcpcInit() */
)
{
if (leaseEvent == DHCPC_LEASE_NEW)
{
dhcpcParamsGet(pCookie, &ParamList);
printf("ipaddr = %x \n",ParamList.yiaddr.s_addr);

}
}


int test()
{

struct ifnet *pIf;

STATUS result;

pIf = ifunit("motfcc0"); /* Access network device. */

/* Initialize lease variables for automatic configuration. */

pLeaseCookie = dhcpcInit (pIf, TRUE);
if (pLeaseCookie == NULL)
return(ERROR);

result = dhcpcEventHookAdd(pLeaseCookie,dtmdhcpcEventHookRtn);
if (result != OK)
return (ERROR);

result = dhcpcBind (pLeaseCookie, TRUE);
if (result != OK)
return (ERROR);

return OK;
}




关键词: vxworks     使用     获取     参数     问题    

共1条 1/1 1 跳转至

回复

匿名不能发帖!请先 [ 登陆 注册 ]