• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ dhcp_stop函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中dhcp_stop函数的典型用法代码示例。如果您正苦于以下问题:C++ dhcp_stop函数的具体用法?C++ dhcp_stop怎么用?C++ dhcp_stop使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了dhcp_stop函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: LwIP_DHCP_Process_Handle

/**
  * @brief  LwIP_DHCP_Process_Handle
  * @param  None
  * @retval None
  */
void LwIP_DHCP_Process_Handle()
{
  struct ip_addr ipaddr;
  struct ip_addr netmask;
  struct ip_addr gw;

  switch (DHCP_state)
  {
    case DHCP_START:
    {
      dhcp_start(&netif);
      IPaddress = 0;
      DHCP_state = DHCP_WAIT_ADDRESS;
      LwIP_DHCP_begin();
    }
    break;

    case DHCP_WAIT_ADDRESS:
    {
      /* Read the new IP address */
      IPaddress = netif.ip_addr.addr;

      if (IPaddress!=0) 
      {
        DHCP_state = DHCP_ADDRESS_ASSIGNED;	

        /* Stop DHCP */
        dhcp_stop(&netif);

        /* DHCP complete */
        LwIP_DHCP_done(IPaddress);
      }
      else
      {
        /* DHCP timeout */
        if (netif.dhcp->tries > MAX_DHCP_TRIES)
        {
          DHCP_state = DHCP_TIMEOUT;

          /* Stop DHCP */
          dhcp_stop(&netif);
          
          /* Deliver timeout call */
          LwIP_DHCP_timeout();

          /* Static address used */
          IP4_ADDR(&ipaddr, IP_ADDR0 ,IP_ADDR1 , IP_ADDR2 , IP_ADDR3 );
          IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3);
          IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
          netif_set_addr(&netif, &ipaddr , &netmask, &gw);

          /* Deliver static IP complete call */
          LwIP_static_done((IP_ADDR0 << 24) | (IP_ADDR1 << 16) | (IP_ADDR2 << 8) | IP_ADDR3);
        }
      }
    }
    break;
    default: break;
  }
}
开发者ID:carl3721,项目名称:stm32-dmx512,代码行数:65,代码来源:netconf.c


示例2: LwIP_DHCP_Process_Handle

/**
  * @brief  LwIP_DHCP_Process_Handle
  * @param  None
  * @retval None
  */
void LwIP_DHCP_Process_Handle()
{
  struct ip_addr ipaddr;
  struct ip_addr netmask;
  struct ip_addr gw;

  switch (DHCP_state)
  {
    case DHCP_START:
    {
      dhcp_start(&netif);
      IPaddress = 0;
      DHCP_state = DHCP_WAIT_ADDRESS;
    }
    break;

    case DHCP_WAIT_ADDRESS:
    {
      /* Read the new IP address */
      IPaddress = netif.ip_addr.addr;

      if (IPaddress!=0) 
      {
        DHCP_state = DHCP_ADDRESS_ASSIGNED;	

        /* Stop DHCP */
        dhcp_stop(&netif);

        STM_EVAL_LEDOn(LED1);
      }
      else
      {
        /* DHCP timeout */
        if (netif.dhcp->tries > MAX_DHCP_TRIES)
        {
          DHCP_state = DHCP_TIMEOUT;

          /* Stop DHCP */
          dhcp_stop(&netif);

          /* Static address used */
          IP4_ADDR(&ipaddr, IP_ADDR0 ,IP_ADDR1 , IP_ADDR2 , IP_ADDR3 );
          IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3);
          IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
          netif_set_addr(&netif, &ipaddr , &netmask, &gw);
   
          STM_EVAL_LEDOn(LED1);
        }
      }
    }
    break;
    default: break;
  }
}
开发者ID:eagle860,项目名称:stm32f207,代码行数:59,代码来源:netconf.c


示例3: lwip_bringdown

void lwip_bringdown(void)
{
    // Disconnect from the network
    dhcp_release(&lwip_netif);
    dhcp_stop(&lwip_netif);
    lwip_ip_addr[0] = '\0';
}
开发者ID:andreaslarssonublox,项目名称:mbed,代码行数:7,代码来源:lwip_stack.c


示例4: netif_remove_hook

/*********************************************************************************************************
** 函数名称: netif_remove_hook
** 功能描述: 删除网络接口回调函数. (网络上下文中调用)
** 输 入  : pvNetif     网络接口
** 输 出  : 
** 全局变量: 
** 调用模块: 
*********************************************************************************************************/
VOID  netif_remove_hook (PVOID  pvNetif)
{
    struct netif  *netif = (struct netif *)pvNetif;
    INT            iNum  = (INT)netif->num;
    
    rt_netif_remove_hook(netif);                                        /*  更新路由表有效标志          */
    
    if (iNum < __LW_NETIF_MAX_NUM) {
        LWIP_NETIF_LOCK();                                              /*  进入临界区                  */
        _G_pnetifArray[iNum] = LW_NULL;
        _G_uiNetifNum--;
        LWIP_NETIF_UNLOCK();                                            /*  退出临界区                  */
    }
    
#if LW_CFG_NET_NPF_EN > 0
    __npfNetifRemoveHook(netif);
#endif                                                                  /*  LW_CFG_NET_NPF_EN > 0       */

#if LW_CFG_LWIP_DHCP > 0
    if (netif->dhcp) {
        dhcp_stop(netif);                                               /*  关闭 DHCP 回收 UDP 控制块   */
        dhcp_cleanup(netif);                                            /*  回收 DHCP 内存              */
    }
#endif                                                                  /*  LW_CFG_LWIP_DHCP > 0        */

#if LW_CFG_LWIP_AUTOIP > 0
    if (netif->autoip) {
        mem_free(netif->autoip);                                        /*  回收 AUTOIP 内存            */
        netif->autoip = LW_NULL;
    }
#endif                                                                  /*  LW_CFG_LWIP_AUTOIP > 0       */
}
开发者ID:Ga-vin,项目名称:libsylixos,代码行数:40,代码来源:lwip_netifnum.c


示例5: runDHCP

static int runDHCP(const char* ifname)
{
    char ipaddr[PROPERTY_VALUE_MAX];
    uint32_t prefixLength;
    char gateway[PROPERTY_VALUE_MAX];
    char    dns1[PROPERTY_VALUE_MAX];
    char    dns2[PROPERTY_VALUE_MAX];
    char    dns3[PROPERTY_VALUE_MAX];
    char    dns4[PROPERTY_VALUE_MAX];
    const char *dns[5] = {dns1, dns2, dns3, dns4, NULL};
    char  server[PROPERTY_VALUE_MAX];
    uint32_t lease;
    char vendorInfo[PROPERTY_VALUE_MAX];
    char domains[PROPERTY_VALUE_MAX];

    ALOGD("stop dhcp for wlan0...");
    dhcp_stop("wlan0");
    ifc_clear_addresses("wlan0");

    //dhcp_do_request: start dhcpcd service to get ip address
    if(dhcp_do_request(ifname, ipaddr, gateway, &prefixLength, dns, server, &lease, vendorInfo, domains))
    {
        ALOGE("dhcp_do_request for wlan0 failed!");
        return -1;
    }

    //ifc_configure: use the dhcp info to configure interface
    if(ifc_configure(ifname, inet_addr(ipaddr), prefixLength, inet_addr(gateway), inet_addr(dns1), inet_addr(dns2)))
    {
        ALOGE("ifc_configure for wlan0 failed!");
        return -1;
    }

    return 0;
}
开发者ID:XuQiufeng,项目名称:CWifimanger,代码行数:35,代码来源:wifimanager.c


示例6: disable_wifi

void disable_wifi()
{
    wifi_state = DISABLING;

    ALOGD("stop dhcp for wlan0...");
    dhcp_stop("wlan0");
    ifc_disable("wlan0");
    ifc_clear_addresses("wlan0");

    ALOGD("stop supplicant...");
    if(wifi_stop_supplicant(1) != 0)
    {
        ALOGE("stop supplicant failed!");
    }

    ALOGD("unload wlan driver...");
    wifi_unload_driver();

    wifi_state = DISABLED;
    WIFI_MSG_INFO_CALLBACK("Wifi diabled.");
    //disable wifi also a event automanager should check.
    sem_post(&sem);

    return ;
}
开发者ID:XuQiufeng,项目名称:CWifimanger,代码行数:25,代码来源:wifimanager.c


示例7: ethernet_set_configuration

// This sets the IP configuration on-the-fly
void ethernet_set_configuration(IPAddress ipAddress, IPAddress netMask, IPAddress gateWay)
{
	if ((gs_net_if.flags & NETIF_FLAG_DHCP) != 0)
	{
		// stop DHCP if it was used before
		dhcp_stop(&gs_net_if);
	}

	struct ip_addr x_ip_addr, x_net_mask, x_gateway;
	x_ip_addr.addr = ipAddress.GetV4LittleEndian();
	x_net_mask.addr = netMask.GetV4LittleEndian();
	x_gateway.addr = gateWay.GetV4LittleEndian();

	if (x_ip_addr.addr == 0)
	{
		// start DHCP and request a dynamic IP address
		dhcp_start(&gs_net_if);
	}
	else
	{
		// use static IP address
		netif_set_ipaddr(&gs_net_if, &x_ip_addr);
		netif_set_netmask(&gs_net_if, &x_net_mask);
		netif_set_gw(&gs_net_if, &x_gateway);

		// don't forget to set it up again
		netif_set_up(&gs_net_if);
	}
}
开发者ID:dc42,项目名称:RepRapFirmware,代码行数:30,代码来源:ethernet_sam.cpp


示例8: ethernet_set_configuration

// This sets the IP configuration on-the-fly
void ethernet_set_configuration(const uint8_t ipAddress[], const uint8_t netMask[], const uint8_t gateWay[])
{
	if ((gs_net_if.flags & NETIF_FLAG_DHCP) != 0)
	{
		// stop DHCP if it was used before
		dhcp_stop(&gs_net_if);
	}

	struct ip_addr x_ip_addr, x_net_mask, x_gateway;
	IP4_ADDR(&x_ip_addr, ipAddress[0], ipAddress[1], ipAddress[2], ipAddress[3]);
	IP4_ADDR(&x_net_mask, netMask[0], netMask[1], netMask[2], netMask[3]);
	IP4_ADDR(&x_gateway, gateWay[0], gateWay[1], gateWay[2], gateWay[3]);

	if (x_ip_addr.addr == 0)
	{
		// start DHCP and request a dynamic IP address
		dhcp_start(&gs_net_if);
	}
	else
	{
		// use static IP address
		netif_set_ipaddr(&gs_net_if, &x_ip_addr);
		netif_set_netmask(&gs_net_if, &x_net_mask);
		netif_set_gw(&gs_net_if, &x_gateway);

		// don't forget to set it up again
		netif_set_up(&gs_net_if);
	}
}
开发者ID:chrishamm,项目名称:RepRapFirmware,代码行数:30,代码来源:ethernet_sam.c


示例9: _lwip_sys_init

static void _lwip_sys_init(void)
{
    struct ip_addr ipaddr, netmask, gw;
    unsigned char *ip;

    ip = getCfgIP();
    IP4_ADDR(&ipaddr,ip[0],ip[1],ip[2],ip[3]);
    ip = getCfgGateWay();
    IP4_ADDR(&gw, ip[0],ip[1],ip[2],ip[3]);
    ip = getCfgNetMask();
    IP4_ADDR(&netmask,ip[0],ip[1],ip[2],ip[3]);

    tcpip_init(RT_NULL, RT_NULL);

    netif_set_addr(netif_default, &ipaddr, &netmask, &gw);
    // We SHOULD define an IP address (udp setup should work any time).
    // So, it may send DHCP packets of src_addr not all zero, tested ok.
    /*
       if( isDHCPEnabled() )
       {
    // when DHCP is enabled, ip/netmask/gateway should be set to all 0.
    IP4_ADDR(&ipaddr,0,0,0,0);
    netif_set_addr(netif_default, &ipaddr, &ipaddr, &ipaddr);
    }
    else
    {
    netif_set_addr(netif_default, &ipaddr, &netmask, &gw);
    }*/
    netif_set_up(netif_default);

    if( isDHCPEnabled() )
        dhcp_start(netif_default);
    else
        dhcp_stop(netif_default);
}
开发者ID:visitor83,项目名称:fighting_stm32,代码行数:35,代码来源:apptasks.c


示例10: net_shutdown

void net_shutdown(void) {
	printf("Releasing DHCP lease...\n");
	dhcp_release(&eth);
	dhcp_stop(&eth);
	printf("Shutting down network...\n");
	netif_remove(&eth);
	gelicif_shutdown(&eth);
}
开发者ID:Stadtpirat,项目名称:open-p3go,代码行数:8,代码来源:network.c


示例11: mod_network_nic_ifconfig

mp_obj_t mod_network_nic_ifconfig(struct netif *netif, size_t n_args, const mp_obj_t *args) {
    if (n_args == 0) {
        // Get IP addresses
        const ip_addr_t *dns = dns_getserver(0);
        mp_obj_t tuple[4] = {
            netutils_format_ipv4_addr((uint8_t*)&netif->ip_addr, NETUTILS_BIG),
            netutils_format_ipv4_addr((uint8_t*)&netif->netmask, NETUTILS_BIG),
            netutils_format_ipv4_addr((uint8_t*)&netif->gw, NETUTILS_BIG),
            netutils_format_ipv4_addr((uint8_t*)dns, NETUTILS_BIG),
        };
        return mp_obj_new_tuple(4, tuple);
    } else if (args[0] == MP_OBJ_NEW_QSTR(MP_QSTR_dhcp)) {
        // Start the DHCP client
        if (dhcp_supplied_address(netif)) {
            dhcp_renew(netif);
        } else {
            dhcp_stop(netif);
            dhcp_start(netif);
        }

        // Wait for DHCP to get IP address
        uint32_t start = mp_hal_ticks_ms();
        while (!dhcp_supplied_address(netif)) {
            if (mp_hal_ticks_ms() - start > 10000) {
                mp_raise_msg(&mp_type_OSError, "timeout waiting for DHCP to get IP address");
            }
            mp_hal_delay_ms(100);
        }

        return mp_const_none;
    } else {
        // Release and stop any existing DHCP
        dhcp_release(netif);
        dhcp_stop(netif);
        // Set static IP addresses
        mp_obj_t *items;
        mp_obj_get_array_fixed_n(args[0], 4, &items);
        netutils_parse_ipv4_addr(items[0], (uint8_t*)&netif->ip_addr, NETUTILS_BIG);
        netutils_parse_ipv4_addr(items[1], (uint8_t*)&netif->netmask, NETUTILS_BIG);
        netutils_parse_ipv4_addr(items[2], (uint8_t*)&netif->gw, NETUTILS_BIG);
        ip_addr_t dns;
        netutils_parse_ipv4_addr(items[3], (uint8_t*)&dns, NETUTILS_BIG);
        dns_setserver(0, &dns);
        return mp_const_none;
    }
}
开发者ID:DanielO,项目名称:micropython,代码行数:46,代码来源:modnetwork.c


示例12: cbIP_removePanInterface

void cbIP_removePanInterface(void)
{
    LWIP_PRINT("Interface down\n");

    dhcp_stop(&panIf.hInterface);
    netif_remove(&panIf.hInterface);
    dhcp_cleanup(&panIf.hInterface);
}
开发者ID:u-blox,项目名称:ublox-odin-w2-lwip-adapt,代码行数:8,代码来源:cb_ip_panif.c


示例13: lwipStopDHCP

//Stop DHCP protocol on a specific layer3 interface.
BOOL lwipStopDHCP(LPVOID pL3Interface)
{
	struct netif* pif = (struct netif*)pL3Interface;
	if (NULL == pif)
	{
		BUG();
	}
	dhcp_stop(pif);
	return TRUE;
}
开发者ID:AlexShiLucky,项目名称:HelloX_OS,代码行数:11,代码来源:lwip_pro.c


示例14: dhcp_release

int EthernetInterface::disconnect() {
    if (use_dhcp) {
        dhcp_release(&netif);
        dhcp_stop(&netif);
    } else {
        netif_set_down(&netif);
    }
    
    eth_arch_disable_interrupts();
    
    return 0;
}
开发者ID:Wiredhome,项目名称:mbed,代码行数:12,代码来源:EthernetInterface.cpp


示例15: dhcp_release

int EthernetInterface::disconnect() {
    if (use_dhcp) {
        dhcp_release(&lpcNetif);
        dhcp_stop(&lpcNetif);
    } else {
        netif_set_down(&lpcNetif);
    }
    
    NVIC_DisableIRQ(ENET_IRQn);
    
    return 0;
}
开发者ID:CNCBASHER,项目名称:mbed,代码行数:12,代码来源:EthernetInterface.cpp


示例16: mbed_lwip_bringdown_2

nsapi_error_t mbed_lwip_bringdown_2(bool ppp)
{
    // Check if we've connected
    if (lwip_connected == NSAPI_STATUS_DISCONNECTED) {
        return NSAPI_ERROR_PARAMETER;
    }

#if LWIP_DHCP
    // Disconnect from the network
    if (lwip_dhcp) {
        dhcp_release(&lwip_netif);
        dhcp_stop(&lwip_netif);
        lwip_dhcp = false;
        lwip_dhcp_has_to_be_set = false;
    }
#endif

    if (ppp) {
        /* this is a blocking call, returns when PPP is properly closed */
       err_t err = ppp_lwip_disconnect();
       if (err) {
           return mbed_lwip_err_remap(err);
       }
       MBED_ASSERT(!netif_is_link_up(&lwip_netif));
       /*if (netif_is_link_up(&lwip_netif)) {
           if (sys_arch_sem_wait(&lwip_netif_unlinked, 15000) == SYS_ARCH_TIMEOUT) {
               return NSAPI_ERROR_DEVICE_ERROR;
           }
       }*/
    } else {
        netif_set_down(&lwip_netif);
    }

#if LWIP_IPV6
    mbed_lwip_clear_ipv6_addresses(&lwip_netif);
#endif

    sys_sem_free(&lwip_netif_has_any_addr);
    sys_sem_new(&lwip_netif_has_any_addr, 0);
#if PREF_ADDR_TIMEOUT
    sys_sem_free(&lwip_netif_has_pref_addr);
    sys_sem_new(&lwip_netif_has_pref_addr, 0);
#endif
#if BOTH_ADDR_TIMEOUT
    sys_sem_free(&lwip_netif_has_both_addr);
    sys_sem_new(&lwip_netif_has_both_addr, 0);
#endif
    lwip_has_addr_state = 0;
    lwip_connected = NSAPI_STATUS_DISCONNECTED;
    return 0;
}
开发者ID:OpenNuvoton,项目名称:mbed,代码行数:51,代码来源:lwip_stack.c


示例17: lwip_dhcp_stop

void lwip_dhcp_stop(void *pParameter)
{
	struct netif *pNetif = (struct netif *)pParameter;
	struct ip_addr ipaddr;
	struct ip_addr netmask;
	struct ip_addr gw;

	if(pNetif->ip_addr.addr != 0)
	{
	  /* Stop DHCP */
      dhcp_stop(pNetif);

	  uprintf(UPRINT_INFO, UPRINT_BLK_NET, "LWIP DHCP get IP addr: 0x%08x\n", pNetif->ip_addr.addr);
	}
	else
	{
	  /* DHCP timeout */
      if (pNetif->dhcp->tries > MAX_DHCP_TRIES)
      {

        /* Stop DHCP */
        dhcp_stop(pNetif);

        /* Static address used */
        IP4_ADDR(&ipaddr, IP_ADDR0 ,IP_ADDR1 , IP_ADDR2 , IP_ADDR3 );
        IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3);
        IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
        netif_set_addr(pNetif, &ipaddr , &netmask, &gw);

		uprintf(UPRINT_INFO, UPRINT_BLK_NET, "LWIP DHCP use static IP addr: 0x%08x\n", pNetif->ip_addr.addr);
      }
	  else
	  {
	  	/* continue to monitor */
	  	sys_timeout(2000, lwip_dhcp_stop, pNetif);
	  }
	}
}
开发者ID:phuuix,项目名称:probability,代码行数:38,代码来源:netconf.c


示例18: lwip_bringdown

int lwip_bringdown(void)
{
    // Check if we've connected
    if (!lwip_get_ip_address()) {
        return NSAPI_ERROR_PARAMETER;
    }

    // Disconnect from the network
    dhcp_release(&lwip_netif);
    dhcp_stop(&lwip_netif);
    lwip_ip_addr[0] = '\0';

    return 0;
}
开发者ID:apullin,项目名称:mbed,代码行数:14,代码来源:lwip_stack.c


示例19: ps2ip_setconfig

int
ps2ip_setconfig(t_ip_info* pInfo)
{
	NetIF*	pNetIF=netif_find(pInfo->netif_name);

	if	(pNetIF==NULL)
	{
		return	0;
	}
	netif_set_ipaddr(pNetIF,(IPAddr*)&pInfo->ipaddr);
	netif_set_netmask(pNetIF,(IPAddr*)&pInfo->netmask);
	netif_set_gw(pNetIF,(IPAddr*)&pInfo->gw);

#if	LWIP_DHCP

	//Enable dhcp here

	if (pInfo->dhcp_enabled)
	{
		if (!pNetIF->dhcp)
		{

			//Start dhcp client

			dhcp_start(pNetIF);
		}
	}
	else
	{
		if (pNetIF->dhcp)
		{

			//Stop dhcp client

			dhcp_stop(pNetIF);
		}
	}

#endif

	return	1;
}
开发者ID:AzagraMac,项目名称:PS2_SDK,代码行数:42,代码来源:ps2ip.c


示例20: wl_cm_disconn_cb

static void
wl_cm_disconn_cb(void* ctx)
{
	struct ctx_server* hs = ctx;

	LINK_LED_OFF();
	INFO_INIT("Disconnection cb...\n");

    if (hs->net_cfg.dhcp_running) {
    	printk("link down, release dhcp\n");
        dhcp_release(hs->net_cfg.netif);
        dhcp_stop(hs->net_cfg.netif);
        hs->net_cfg.dhcp_running = 0;
     } else {
    	 printk("link down\n");
    	 netif_set_down(hs->net_cfg.netif);
     }

     set_result_cmd(WL_FAILURE);
}
开发者ID:gameswarp,项目名称:Arduino,代码行数:20,代码来源:main.c



注:本文中的dhcp_stop函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ dhd_customer_gpio_wlan_ctrl函数代码示例发布时间:2022-05-30
下一篇:
C++ dgettext函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap