本文整理汇总了C++中dhcp_stop函数的典型用法代码示例。如果您正苦于以下问题:C++ dhcp_stop函数的具体用法?C++ dhcp_stop怎么用?C++ dhcp_stop使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了dhcp_stop函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
示例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;
}
}
示例3: lwip_bringdown
void lwip_bringdown(void)
{
// Disconnect from the network
dhcp_release(&lwip_netif);
dhcp_stop(&lwip_netif);
lwip_ip_addr[0] = '\0';
}
示例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 */
}
示例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;
}
示例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 ;
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例10: net_shutdown
void net_shutdown(void) {
printf("Releasing DHCP lease...\n");
dhcp_release(ð);
dhcp_stop(ð);
printf("Shutting down network...\n");
netif_remove(ð);
gelicif_shutdown(ð);
}
示例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;
}
}
示例12: cbIP_removePanInterface
void cbIP_removePanInterface(void)
{
LWIP_PRINT("Interface down\n");
dhcp_stop(&panIf.hInterface);
netif_remove(&panIf.hInterface);
dhcp_cleanup(&panIf.hInterface);
}
示例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;
}
示例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;
}
示例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;
}