4568|2

83

帖子

0

TA的资源

一粒金砂(初级)

楼主
 

vxworks的DHCP客户端问题 [复制链接]

 我现在有两个网卡,分别在不同的网络里,IP地址的分别是通过DHCP服务器自动分配,设计了一套DHCP客户端申请程序,单个网口可以实现IP地址的动态分配,串行方式两个网口都可动态获得IP地址,能不能实现两个网口同时动态申请IP地址哪?这样可以节约时间,因为一个DHCP申请需要大约8s左右,望高手不吝赐教。谢谢!!!!


STATUS DhcpClient(char * ipName)
{
    unsigned long duration;
    struct ifnet *pIf;
    STATUS result;
    void *pLeaseCookie;
    extern struct ifnet *ifunit ();
    struct dhcp_param paramList;
    pIf = ifunit (ipName); /* Access network device. */
    /* Initialize lease variables for automatic configuration. */
    pLeaseCookie = dhcpcInit (pIf, TRUE);
    if (pLeaseCookie == NULL)
    {
        printf("dhcpcInit error\n");
        return (ERROR);
    }

    /* Set any lease options here. */
    duration = htonl(DHCP_PORT);
    dhcpcOptionAdd (pLeaseCookie, _DHCP_LEASE_TIME_TAG, 4, (UCHAR*)&duration);
    dhcpcOptionSet (pLeaseCookie, _DHCP_ROUTER_TAG);
    dhcpcOptionSet (pLeaseCookie, _DHCP_DNS_SERVER_TAG);
    dhcpcOptionSet (pLeaseCookie, _DHCP_DNS_DOMAIN_TAG);
    dhcpcOptionSet (pLeaseCookie, _DHCP_ROUTER_DISCOVER_TAG);
    dhcpcOptionSet (pLeaseCookie, _DHCP_STATIC_ROUTE_TAG);
    dhcpcOptionSet (pLeaseCookie, _DHCP_VENDOR_SPEC_TAG);
    dhcpcOptionSet (pLeaseCookie, _DHCP_NBN_SERVER_TAG);
    dhcpcOptionSet (pLeaseCookie, _DHCP_NB_NODETYPE_TAG);
    dhcpcOptionSet (pLeaseCookie, _DHCP_NB_SCOPE_TAG);

    result = dhcpcBind (pLeaseCookie, TRUE); // Synchronous execution.
    if (result != OK)
    {
        printf("dhcpcBind error\n");
        return (ERROR);
    }


    /****************************************************************/
    /**************** Using dhcpcParamsGet() ***********************/
    /* prepare to use dhcpcParamsGet() */
    memset((char *)¶mList, 0x00, sizeof(paramList));
    paramList.subnet_mask = (struct in_addr *)malloc(sizeof(struct
                             in_addr));
    memset((char *)paramList.subnet_mask, 0x00,
    sizeof(paramList.subnet_mask));
    paramList.sname = (char *)malloc(256);
    memset((char *)paramList.sname, 0x00, sizeof(paramList.sname));
    paramList.dns_server = (struct in_addrs *)malloc(sizeof(struct in_addrs));
    memset((char *)paramList.dns_server, 0x00,
    sizeof(paramList.dns_server));
    paramList.dns_domain = (char *)malloc(256);
    if (dhcpcParamsGet(pLeaseCookie, ¶mList) == ERROR)
      logMsg("Can not get parameter list. % x \n", errno,0,0,0,0,0);
    else
    {
       logMsg("DHCP server host name is: %s. \n", paramList.sname,0,0,0,0,0);
       logMsg("DHCP dns domain name is: %s. \n",
       paramList.dns_domain,0,0,0,0,0);
       logMsg("DHCP server's IP address is: %s.\n",
       inet_ntoa(paramList.server_id),0,0,0,0,0);
       logMsg("This client's pre-dhcp assigned address is: %s.\n",
       inet_ntoa(paramList.ciaddr),0,0,0,0,0);
       logMsg("This client's assigned address is: %s.\n",
        inet_ntoa(paramList.yiaddr),0,0,0,0,0);
         logMsg("This client's subnet mask is:%s.\n",
       inet_ntoa(*(paramList.subnet_mask)),0,0,0,0,0);
/* next log msg was commented out by sjk since it doesn't work */
//logMsg("DNS server IP address is: %s. \n",
//inet_ntoa(*(paramList.dns_server)),0,0,0,0,0);
/* dhcpcParamsShow() gives the dns IP addresses */
}

    //dhcpcServerShow(pLeaseCookie);
   
    return OK;
}

最新回复

是讲关于dhcp客户端IP地址申请的问题,与操作系统无关,不知道大家遇到过这种情况没有??  详情 回复 发表于 2009-9-24 10:33
点赞 关注
 

回复
举报

66

帖子

0

TA的资源

一粒金砂(初级)

沙发
 
可能是发贴地方不对,呵
 
 
 

回复

60

帖子

0

TA的资源

一粒金砂(初级)

板凳
 
是讲关于dhcp客户端IP地址申请的问题,与操作系统无关,不知道大家遇到过这种情况没有??
 
 
 

回复
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/10 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2025 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表