static void tcpip_init_done(void* arg) { current_task->name = "[tcpipd]"; current_task->description = "TCP/IP Stack daemon"; current_task->priority = TASK_PRIO_MIN; #if DEBUG kprintf(LOG "[%d] tcpip: initialized in %d MS\n", sys_getpid(), (uintptr_t) (timer_getms() - (uintptr_t) arg)); #else (void) arg; #endif struct netif* lo = netif_find("lo0"); if(likely(lo)) { netif_set_up(lo); netif_set_default(lo); } else kprintf(WARN "netif: Loopback interface not found\n"); ip_addr_t dns[2]; IP4_ADDR(&dns[0], 8, 8, 8, 8); IP4_ADDR(&dns[1], 8, 8, 4, 4); dns_setserver(0, &dns[0]); dns_setserver(1, &dns[1]); }
/** * Change IP configuration settings disabling the dhcp client * @param local_ip Static ip configuration * @param gateway Static gateway configuration * @param subnet Static Subnet mask * @param dns1 Static DNS server 1 * @param dns2 Static DNS server 2 */ bool WiFiSTAClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1, IPAddress dns2) { if(!WiFi.enableSTA(true)) { return false; } esp_wifi_start(); tcpip_adapter_ip_info_t info; info.ip.addr = static_cast<uint32_t>(local_ip); info.gw.addr = static_cast<uint32_t>(gateway); info.netmask.addr = static_cast<uint32_t>(subnet); tcpip_adapter_dhcpc_stop(TCPIP_ADAPTER_IF_STA); if(tcpip_adapter_set_ip_info(TCPIP_ADAPTER_IF_STA, &info) == ESP_OK) { _useStaticIp = true; } else { return false; } ip_addr_t d; if(dns1 != (uint32_t)0x00000000) { // Set DNS1-Server d.u_addr.ip4.addr = static_cast<uint32_t>(dns1); dns_setserver(0, &d); } if(dns2 != (uint32_t)0x00000000) { // Set DNS2-Server d.u_addr.ip4.addr = static_cast<uint32_t>(dns2); dns_setserver(1, &d); } return true; }
/** * Change IP configuration settings disabling the dhcp client * @param local_ip Static ip configuration * @param gateway Static gateway configuration * @param subnet Static Subnet mask * @param dns1 Static DNS server 1 * @param dns2 Static DNS server 2 */ bool ESP8266WiFiSTAClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns1, IPAddress dns2) { if(!WiFi.enableSTA(true)) { return false; } struct ip_info info; info.ip.addr = static_cast<uint32_t>(local_ip); info.gw.addr = static_cast<uint32_t>(gateway); info.netmask.addr = static_cast<uint32_t>(subnet); wifi_station_dhcpc_stop(); if(wifi_set_ip_info(STATION_IF, &info)) { _useStaticIp = true; } else { return false; } ip_addr_t d; if(dns1 != (uint32_t)0x00000000) { // Set DNS1-Server d.addr = static_cast<uint32_t>(dns1); dns_setserver(0, &d); } if(dns2 != (uint32_t)0x00000000) { // Set DNS2-Server d.addr = static_cast<uint32_t>(dns2); dns_setserver(1, &d); } return true; }
static nsapi_error_t mbed_lwip_add_dns_server(nsapi_stack_t *stack, nsapi_addr_t addr) { // Shift all dns servers down to give precedence to new server for (int i = DNS_MAX_SERVERS-1; i > 0; i--) { dns_setserver(i, dns_getserver(i-1)); } ip_addr_t ip_addr; if (!convert_mbed_addr_to_lwip(&ip_addr, &addr)) { return NSAPI_ERROR_PARAMETER; } dns_setserver(0, &ip_addr); return 0; }
void add_dns_addr(struct netif *lwip_netif) { const ip_addr_t *ip_addr = mbed_lwip_get_ip_addr(true, lwip_netif); if (ip_addr) { if (IP_IS_V6(ip_addr)) { const ip_addr_t *dns_ip_addr; bool dns_addr_exists = false; for (char numdns = 0; numdns < DNS_MAX_SERVERS; numdns++) { dns_ip_addr = dns_getserver(numdns); if (!ip_addr_isany(dns_ip_addr)) { dns_addr_exists = true; break; } } if (!dns_addr_exists) { /* 2001:4860:4860::8888 google */ ip_addr_t ipv6_dns_addr = IPADDR6_INIT( PP_HTONL(0x20014860UL), PP_HTONL(0x48600000UL), PP_HTONL(0x00000000UL), PP_HTONL(0x00008888UL)); dns_setserver(0, &ipv6_dns_addr); } } } }
STATIC mp_obj_t ppp_ifconfig(size_t n_args, const mp_obj_t *args) { ppp_if_obj_t *self = MP_OBJ_TO_PTR(args[0]); ip_addr_t dns; if (n_args == 1) { // get if (self->pcb != NULL) { dns = dns_getserver(0); struct netif *pppif = ppp_netif(self->pcb); mp_obj_t tuple[4] = { netutils_format_ipv4_addr((uint8_t*)&pppif->ip_addr, NETUTILS_BIG), netutils_format_ipv4_addr((uint8_t*)&pppif->gw, NETUTILS_BIG), netutils_format_ipv4_addr((uint8_t*)&pppif->netmask, NETUTILS_BIG), netutils_format_ipv4_addr((uint8_t*)&dns, NETUTILS_BIG), }; return mp_obj_new_tuple(4, tuple); } else { mp_obj_t tuple[4] = { mp_const_none, mp_const_none, mp_const_none, mp_const_none }; return mp_obj_new_tuple(4, tuple); } } else { mp_obj_t *items; mp_obj_get_array_fixed_n(args[1], 4, &items); netutils_parse_ipv4_addr(items[3], (uint8_t*)&dns.u_addr.ip4, NETUTILS_BIG); dns_setserver(0, &dns); return mp_const_none; } }
void set_dns(char* dns_server) { struct in_addr addr; if ((dns_server != RT_NULL) && inet_aton(dns_server, &addr)) { dns_setserver(0, (struct ip_addr *)&addr); } }
void set_dns(char* dns_server) { struct ip_addr addr; if ((dns_server != NULL) && ipaddr_aton(dns_server, &addr)) { dns_setserver(0, &addr); } }
void set_dns(char* dns_server) { ip_addr_t *addr; if ((dns_server != RT_NULL) && ipaddr_aton(dns_server, addr)) { dns_setserver(0, addr); } }
static void add_dns_addr_to_dns_list_index(const u8_t addr_type, const u8_t index) { #if LWIP_IPV6 if (addr_type == IPADDR_TYPE_V6) { /* 2001:4860:4860::8888 google */ ip_addr_t ipv6_dns_addr = IPADDR6_INIT( PP_HTONL(0x20014860UL), PP_HTONL(0x48600000UL), PP_HTONL(0x00000000UL), PP_HTONL(0x00008888UL)); dns_setserver(index, &ipv6_dns_addr); } #endif #if LWIP_IPV4 if (addr_type == IPADDR_TYPE_V4) { /* 8.8.8.8 google */ ip_addr_t ipv4_dns_addr = IPADDR4_INIT(0x08080808); dns_setserver(index, &ipv4_dns_addr); } #endif }
static void ppp_status_cb(void *ctx, int err, void *arg) { switch (err) { case PPPERR_NONE: CYG_TEST_INFO("PPP link up"); // Setup DNS server { struct ppp_addrs *addrs = (struct ppp_addrs *) arg; dns_setserver(2, &addrs->dns1); } if (test_state == TEST_PPP_INIT_WAIT) test_state = TEST_PPP_UP; break; case PPPERR_PARAM: CYG_TEST_INFO("Invalid parameter"); test_state = TEST_PPP_CLOSE_WAIT; break; case PPPERR_OPEN: CYG_TEST_INFO("Unable to open PPP session"); test_state = TEST_PPP_CLOSE_WAIT; break; case PPPERR_DEVICE: CYG_TEST_INFO("Invalid I/O device for PPP"); test_state = TEST_PPP_CLOSE_WAIT; break; case PPPERR_ALLOC: CYG_TEST_INFO("Unable to allocate resources"); test_state = TEST_PPP_CLOSE_WAIT; break; case PPPERR_USER: CYG_TEST_INFO("User interrupt"); test_state = TEST_PPP_CLOSE_WAIT; break; case PPPERR_CONNECT: CYG_TEST_INFO("Connection lost"); test_state = TEST_PPP_CLOSE_WAIT; break; case PPPERR_AUTHFAIL: CYG_TEST_INFO("Failed authentication challenge"); test_state = TEST_PPP_CLOSE_WAIT; break; case PPPERR_PROTOCOL: CYG_TEST_INFO("Failed to meet protocol"); test_state = TEST_PPP_CLOSE_WAIT; break; } }
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; } }
void ESP8266WiFiClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, IPAddress dns) { struct ip_info info; info.ip.addr = static_cast<uint32_t>(local_ip); info.gw.addr = static_cast<uint32_t>(gateway); info.netmask.addr = static_cast<uint32_t>(subnet); wifi_station_dhcpc_stop(); wifi_set_ip_info(STATION_IF, &info); // Set DNS-Server ip_addr_t d; d.addr = static_cast<uint32_t>(dns); dns_setserver(0,&d); _useStaticIp = true; }
/** * @brief Init_lwIP initialize the LwIP */ void Init_lwIP(void) { struct ip_addr ipaddr; struct ip_addr netmask; struct ip_addr gw; struct ip_addr dnsserver; long *cfg_ip=(long *)wireless_ip; // sys_init(); /* Initializes the dynamic memory heap defined by MEM_SIZE.*/ mem_init(); /* Initializes the memory pools defined by MEMP_NUM_x.*/ memp_init(); pbuf_init(); netif_init(); printf("TCP/IP initializing...\n"); if(*cfg_ip==0){//no ip addr,use DHCP /* 启用DHCP服务器 */ ipaddr.addr = 0; netmask.addr = 0; gw.addr = 0; printf("using dhcp!\n"); netif_add(&netif, &ipaddr, &netmask, &gw, NULL, ðernetif_init, ðernet_input); netif_set_default(&netif); netif_set_up(&netif); dhcp_start(&netif); } else{ printf("using static ip!\n"); /* 启用静态IP */ IP4_ADDR(&ipaddr,wireless_ip[0], wireless_ip[1], wireless_ip[2], wireless_ip[3]); IP4_ADDR(&netmask, wireless_mask[0], wireless_mask[1], wireless_mask[2], wireless_mask[3]); IP4_ADDR(&gw, wireless_gw[0], wireless_gw[1], wireless_gw[2], wireless_gw[3]); IP4_ADDR(&dnsserver, wireless_dns[0], wireless_dns[1], wireless_dns[2], wireless_dns[3]); dns_init(); dns_setserver(0, &dnsserver);//set dns server addr netif_add(&netif, &ipaddr, &netmask, &gw, NULL, ðernetif_init, ðernet_input); netif_set_default(&netif); netif_set_up(&netif); } timerbase_config(); printf("TCP/IP initialized.\n"); }
// Lua: s = net.dns.setdnsserver(ip_addr, [index]) static int net_setdnsserver( lua_State* L ) { size_t l; u32_t ip32; const char *server = luaL_checklstring( L, 1, &l ); if (l>16 || server == NULL || (ip32 = ipaddr_addr(server)) == IPADDR_NONE || ip32 == IPADDR_ANY) return luaL_error( L, "invalid dns server ip" ); int numdns = luaL_optint(L, 2, 0); if (numdns >= DNS_MAX_SERVERS) return luaL_error( L, "server index out of range [0-%d]", DNS_MAX_SERVERS - 1); ip_addr_t ipaddr; ip4_addr_set_u32(&ipaddr, ip32); dns_setserver(numdns,&ipaddr); return 0; }
STATIC void wiznet5k_lwip_init(wiznet5k_obj_t *self) { ip_addr_t ipconfig[4]; ipconfig[0].addr = 0; ipconfig[1].addr = 0; ipconfig[2].addr = 0; ipconfig[3].addr = 0; netif_add(&self->netif, &ipconfig[0], &ipconfig[1], &ipconfig[2], self, wiznet5k_netif_init, ethernet_input); self->netif.name[0] = 'e'; self->netif.name[1] = '0'; netif_set_default(&self->netif); dns_setserver(0, &ipconfig[3]); dhcp_set_struct(&self->netif, &self->dhcp_struct); // Setting NETIF_FLAG_UP then clearing it is a workaround for dhcp_start and the // LWIP_DHCP_CHECK_LINK_UP option, so that the DHCP client schedules itself to // automatically start when the interface later goes up. self->netif.flags |= NETIF_FLAG_UP; dhcp_start(&self->netif); self->netif.flags &= ~NETIF_FLAG_UP; }
int dnsclient_main(int argc, FAR char *argv[]) #endif { struct hostent *shost = NULL; ip_addr_t dns_addr; if (argc < 2) { show_usage(argv[0]); return 0; } if (argc == 3 && argv[2] != NULL) { printf("dnsclient : dns_add_nameserver : %s\n", argv[2]); IP_SET_TYPE_VAL(dns_addr, IPADDR_TYPE_V4); #ifdef CONFIG_NET_IPv6 dns_addr.u_addr.ip4.addr = inet_addr(argv[2]); #else dns_addr.addr = inet_addr(argv[2]); #endif /* CONFIG_NET_IPv6 */ dns_setserver(0, &dns_addr); } memset(hostname, 0x00, DNS_NAME_MAXSIZE); if (strlen(argv[1]) > DNS_NAME_MAXSIZE) { printf("dnsclient : length of hostname has to lower than %d\n", DNS_NAME_MAXSIZE); return -1; } strncpy(hostname, argv[1], DNS_NAME_MAXSIZE); printf("\nHostname : %s [len %d]\n", hostname, strlen(hostname)); if ((shost = gethostbyname(hostname)) == NULL || shost->h_addr_list == NULL) { printf("dnsclient : failed to resolve host's IP address, shost %p\n", shost); return -1; } else { printf("DNS results\n"); printf("IP Address : %s\n", ip_ntoa((ip_addr_t *)shost->h_addr_list[0])); } return 0; }
int ethApplyIPConfig(void) { t_ip_info ip_info; struct ip_addr ipaddr, netmask, gw, dns, dns_curr; int result; if((result = ps2ip_getconfig("sm0", &ip_info)) >= 0) { IP4_ADDR(&ipaddr, ps2_ip[0], ps2_ip[1], ps2_ip[2], ps2_ip[3]); IP4_ADDR(&netmask, ps2_netmask[0], ps2_netmask[1], ps2_netmask[2], ps2_netmask[3]); IP4_ADDR(&gw, ps2_gateway[0], ps2_gateway[1], ps2_gateway[2], ps2_gateway[3]); IP4_ADDR(&dns, ps2_dns[0], ps2_dns[1], ps2_dns[2], ps2_dns[3]); dns_curr = dns_getserver(0); //Check if it's the same. Otherwise, apply the new configuration. if((ps2_ip_use_dhcp != ip_info.dhcp_enabled) || (!ps2_ip_use_dhcp && (!ip_addr_cmp(&ipaddr, (struct ip_addr*)&ip_info.ipaddr) || !ip_addr_cmp(&netmask, (struct ip_addr*)&ip_info.netmask) || !ip_addr_cmp(&gw, (struct ip_addr*)&ip_info.gw) || !ip_addr_cmp(&dns, &dns_curr)))) { if(ps2_ip_use_dhcp){ IP4_ADDR((struct ip_addr*)&ip_info.ipaddr, 169, 254, 0, 1); IP4_ADDR((struct ip_addr*)&ip_info.netmask, 255, 255, 0, 0); IP4_ADDR((struct ip_addr*)&ip_info.gw, 0, 0, 0, 0); IP4_ADDR(&dns, 0, 0, 0, 0); ip_info.dhcp_enabled = 1; }else{ ip_addr_set((struct ip_addr*)&ip_info.ipaddr, &ipaddr); ip_addr_set((struct ip_addr*)&ip_info.netmask, &netmask); ip_addr_set((struct ip_addr*)&ip_info.gw, &gw); ip_info.dhcp_enabled = 0; } dns_setserver(0, &dns); result = ps2ip_setconfig(&ip_info); }else result = 0; } return result; }
static int tcpecho_netsetup() { /* If this task is excecutated as an NSH built-in function, then the * network has already been configured by NSH's start-up logic. */ #ifndef CONFIG_NSH_BUILTIN_APPS struct in_addr addr; #if defined(CONFIG_EXAMPLES_TCPECHO_DHCPC) || defined(CONFIG_EXAMPLES_TCPECHO_NOMAC) uint8_t mac[IFHWADDRLEN]; #endif #ifdef CONFIG_EXAMPLES_TCPECHO_DHCPC struct dhcpc_state ds; void *handle; #endif /* Many embedded network interfaces must have a software assigned MAC */ #ifdef CONFIG_EXAMPLES_TCPECHO_NOMAC mac[0] = 0x00; mac[1] = 0xe0; mac[2] = 0xde; mac[3] = 0xad; mac[4] = 0xbe; mac[5] = 0xef; netlib_setmacaddr("eth0", mac); #endif /* Set up our host address */ #ifdef CONFIG_EXAMPLES_TCPECHO_DHCPC addr.s_addr = 0; #else addr.s_addr = HTONL(CONFIG_EXAMPLES_TCPECHO_IPADDR); #endif netlib_sethostaddr("eth0", &addr); /* Set up the default router address */ addr.s_addr = HTONL(CONFIG_EXAMPLES_TCPECHO_DRIPADDR); netlib_setdraddr("eth0", &addr); /* Setup the subnet mask */ addr.s_addr = HTONL(CONFIG_EXAMPLES_TCPECHO_NETMASK); netlib_setnetmask("eth0", &addr); #ifdef CONFIG_EXAMPLES_TCPECHO_DHCPC /* Set up the resolver */ dns_bind(); /* Get the MAC address of the NIC */ netlib_getmacaddr("eth0", mac); /* Set up the DHCPC modules */ handle = dhcpc_open(&mac, IFHWADDRLEN); /* Get an IP address. Note: there is no logic here for renewing the address in this * example. The address should be renewed in ds.lease_time/2 seconds. */ if (!handle) { return ERROR; } if (dhcpc_request(handle, &ds) != OK) { return ERROR; } netlib_sethostaddr("eth1", &ds.ipaddr); if (ds.netmask.s_addr != 0) { netlib_setnetmask("eth0", &ds.netmask); } if (ds.default_router.s_addr != 0) { netlib_setdraddr("eth0", &ds.default_router); } if (ds.dnsaddr.s_addr != 0) { dns_setserver(&ds.dnsaddr); } dhcpc_close(handle); printf("IP: %s\n", inet_ntoa(ds.ipaddr)); #endif /* CONFIG_EXAMPLES_TCPECHO_DHCPC */ #endif /* CONFIG_NSH_BUILTIN_APPS */ return OK; }
void MTD_FLASHMEM NSLookup::setDNSServer(uint32_t num, IPAddress server) { ip_addr_t a = server.get_ip_addr_t(); dns_setserver(num, &a); }
void cbIP_initPanInterfaceStatic( char* hostname, const cbIP_IPv4Settings * const IPv4Settings, const cbIP_IPv6Settings * const IPv6Settings, cbIP_interfaceSettings const * const ifConfig, cbIP_statusIndication callback, void* callbackArg) { struct ip_addr ipaddr; struct ip_addr netmask; struct ip_addr gw; struct ip_addr dns0; struct ip_addr dns1; struct ip6_addr ip6addr; MBED_ASSERT(callback != NULL && hostname != NULL && IPv4Settings != NULL && ifConfig != NULL); gw.addr = IPv4Settings->gateway.value; ipaddr.addr = IPv4Settings->address.value; netmask.addr = IPv4Settings->netmask.value; dns0.addr = IPv4Settings->dns0.value; dns1.addr = IPv4Settings->dns1.value; memcpy(&ip6addr, &IPv6Settings->linklocal.value, sizeof(ip6addr)); memcpy(&panIf.ifConfig, ifConfig, sizeof(panIf.ifConfig)); panIf.statusCallback = callback; panIf.callbackArg = callbackArg; netif_add(&panIf.hInterface, &ipaddr, &netmask, &gw, &panIf, cb_netif_init, ethernet_input); panIf.hInterface.hostname = hostname; panIf.hInterface.ip6_autoconfig_enabled = 0; if ((ip6addr.addr[0] == 0) && (ip6addr.addr[1] == 0) && (ip6addr.addr[2] == 0) && (ip6addr.addr[3] == 0)) { netif_create_ip6_linklocal_address(&panIf.hInterface, 1); } else { memcpy(&panIf.hInterface.ip6_addr[0], &ip6addr, sizeof(ip6addr)); } netif_ip6_addr_set_state((&panIf.hInterface), 0, IP6_ADDR_TENTATIVE); dns_setserver(0, &dns0); dns_setserver(1, &dns1); LWIP_PRINT("Using static ip addresses\n"); LWIP_PRINT("IP address: %d.%d.%d.%d\n", ip4_addr1(&ipaddr), ip4_addr2(&ipaddr), ip4_addr3(&ipaddr), ip4_addr4(&ipaddr)); LWIP_PRINT("Netmask: %d.%d.%d.%d\n", ip4_addr1(&netmask), ip4_addr2(&netmask), ip4_addr3(&netmask), ip4_addr4(&netmask)); LWIP_PRINT("Gateway: %d.%d.%d.%d\n", ip4_addr1(&gw), ip4_addr2(&gw), ip4_addr3(&gw), ip4_addr4(&gw)); LWIP_PRINT("Primary dns: %d.%d.%d.%d\n", ip4_addr1(&dns0), ip4_addr2(&dns0), ip4_addr3(&dns0), ip4_addr4(&dns0)); LWIP_PRINT("Secondary dns: %d.%d.%d.%d\n", ip4_addr1(&dns1), ip4_addr2(&dns1), ip4_addr3(&dns1), ip4_addr4(&dns1)); panIf.statusCallback = callback; panIf.hInterface.state = &panIf; netif_set_status_callback(&panIf.hInterface, netif_status_callback); netif_set_up(&panIf.hInterface); cb_uint32 result; result = cbBTPAN_registerDataCallback(&_panCallBack); MBED_ASSERT(result == cbBTPAN_RESULT_OK); }
/**************************************************************************** * Name: dhcpc_request ****************************************************************************/ static int dhcpc_request(void *handle, struct dhcpc_state *presult) { if (!handle) { ndbg("ERROR : handle must not be null\n"); return -100; } if (!presult) { ndbg("ERROR : presult must not be null\n"); return -100; } struct dhcpc_state_s *pdhcpc = (struct dhcpc_state_s *)handle; g_pResult = presult; struct in_addr oldaddr; struct in_addr newaddr; uint8_t msgtype; int retries = 0, result = 0; char *intf; #define CNT_MAX_DISCOVER 5 #define CNT_MAX_REQUEST 5 /* Save the currently assigned IP address (should be INADDR_ANY) */ oldaddr.s_addr = 0; intf = pdhcpc->nic; int ret = netlib_get_ipv4addr(intf, &oldaddr); if (ret == -1) { printf("Set IPv4 fail\n"); } /* Loop until we receive the lease (or an error occurs) */ /* Set the IP address to INADDR_ANY. */ newaddr.s_addr = INADDR_ANY; if (netlib_set_ipv4addr(intf, &newaddr) == ERROR) { ndbg("netlib_set_ipv4addr failed\n"); } /* Loop sending DISCOVER until we receive an OFFER from a DHCP * server. We will lock on to the first OFFER and decline any * subsequent offers (which will happen if there are more than one * DHCP servers on the network. */ g_dhcpc_state = STATE_INITIAL; do { /* Get the DHCPOFFER response */ if (++retries > CNT_MAX_DISCOVER) { /* reach max try */ return -2; } ndbg("Send Discover Packet\n"); result = dhcpc_sendmsg(pdhcpc, g_pResult, DHCPDISCOVER); usleep(100000); if (result < 0) { if (get_errno() == EAGAIN) { continue; } ndbg("sendDiscover Error\n"); return -1; } ndbg("Waiting Offer...(%d)\n", pdhcpc->sockfd); result = recv(pdhcpc->sockfd, &pdhcpc->packet, sizeof(struct dhcp_msg), 0); ndbg("Received...(%d)\n", result); if (result <= 0) { ndbg("receive fail\n"); continue; } msgtype = dhcpc_parsemsg(pdhcpc, result, presult); if (msgtype == DHCPOFFER) { /* Save the servid from the presult so that it is not clobbered * by a new OFFER. */ ndbg("Received OFFER from %08x\n", ntohl(presult->serverid.s_addr)); pdhcpc->ipaddr.s_addr = presult->ipaddr.s_addr; pdhcpc->serverid.s_addr = presult->serverid.s_addr; /* Temporarily use the address offered by the server and break * out of the loop. */ ret = netlib_set_ipv4addr(intf, &presult->ipaddr); if (ret == -1) { ndbg("Set IPv4 fail\n"); } g_dhcpc_state = STATE_HAVE_OFFER; break; } else { ndbg("Received AnotherData %d %x\n", result, msgtype); } } while (g_dhcpc_state == STATE_INITIAL); /* Loop sending the REQUEST up to three times (if there is no response) */ retries = 0; /* Send the REQUEST message to obtain the lease that was offered to us. */ ndbg("Send REQUEST\n"); do { if (retries++ > CNT_MAX_REQUEST) break; ndbg("Send Request Packet\n"); result = dhcpc_sendmsg(pdhcpc, g_pResult, DHCPREQUEST); if (result < 0) { ndbg("thread_sendRequest Error\n"); return -3; } usleep(100000); /* Get the ACK/NAK response to the REQUEST (or timeout) */ ndbg("Waiting Ack...\n"); result = recv(pdhcpc->sockfd, &pdhcpc->packet, sizeof(struct dhcp_msg), 0); ndbg("Received...(%d)\n", result); if (result <= 0) { ndbg("recv request error(%d)(%d)\n", result, errno); continue; } /* Parse the response */ ndbg("Data Received\n"); msgtype = dhcpc_parsemsg(pdhcpc, result, presult); /* The ACK response means that the server has accepted our request * and we have the lease. */ if (msgtype == DHCPACK) { ndbg("Received ACK\n"); g_dhcpc_state = STATE_HAVE_LEASE; } /* NAK means the server has refused our request. Break out of * this loop with state == STATE_HAVE_OFFER and send DISCOVER again */ else if (msgtype == DHCPNAK) { ndbg("Received NAK\n"); break; } /* If we get any OFFERs from other servers, then decline them now * and continue waiting for the ACK from the server that we * requested from. */ else if (msgtype == DHCPOFFER) { /* If we get OFFERs from same dhcp server, do not send DECLINE */ if (pdhcpc->serverid.s_addr == presult->serverid.s_addr) { ndbg("Received duplicated OFFER from %08x\n", ntohl(presult->serverid.s_addr)); } else { ndbg("Received another OFFER from %08x, send DECLINE\n", ntohl(presult->serverid.s_addr)); result = dhcpc_sendmsg(pdhcpc, presult, DHCPDECLINE); if (result <= 0) { ndbg("recv request error(%d)(%d)\n", result, errno); } } } /* Otherwise, it is something that we do not recognize */ else { ndbg("Ignoring msgtype=%d %d\n", msgtype, result); } usleep(100000L); /* An error has occurred. If this was a timeout error (meaning * that nothing was received on this socket for a long period of time). * Then break out and send the DISCOVER command again (at most * 3 times). */ } while (g_dhcpc_state == STATE_HAVE_OFFER); ndbg("Got IP address %d.%d.%d.%d\n", (presult->ipaddr.s_addr) & 0xff, (presult->ipaddr.s_addr >> 8) & 0xff, (presult->ipaddr.s_addr >> 16) & 0xff, (presult->ipaddr.s_addr >> 24) & 0xff); ndbg("Got netmask %d.%d.%d.%d\n", (presult->netmask.s_addr) & 0xff, (presult->netmask.s_addr >> 8) & 0xff, (presult->netmask.s_addr >> 16) & 0xff, (presult->netmask.s_addr >> 24) & 0xff); ndbg("Got DNS server %d.%d.%d.%d\n", (presult->dnsaddr.s_addr) & 0xff, (presult->dnsaddr.s_addr >> 8) & 0xff, (presult->dnsaddr.s_addr >> 16) & 0xff, (presult->dnsaddr.s_addr >> 24) & 0xff); ndbg("Got default router %d.%d.%d.%d\n", (presult->default_router.s_addr) & 0xff, (presult->default_router.s_addr >> 8) & 0xff, (presult->default_router.s_addr >> 16) & 0xff, (presult->default_router.s_addr >> 24) & 0xff); ndbg("Lease expires in %d seconds\n", presult->lease_time); #if defined CONFIG_NET_LWIP // this is temporal fix. it should be modified later ip_addr_t dns_addr; IP_SET_TYPE_VAL(dns_addr, IPADDR_TYPE_V4); #ifdef CONFIG_NET_IPv6 dns_addr.u_addr.ip4.addr = presult->dnsaddr.s_addr; #else dns_addr.addr = presult->dnsaddr.s_addr; #endif dns_setserver(0, &dns_addr); #endif /* CONFIG_NET_LWIP */ #if defined(CONFIG_NETDB_DNSCLIENT) && defined(CONFIG_NETDB_DNSSERVER_BY_DHCP) struct sockaddr_in dns; if (presult->dnsaddr.s_addr != 0) { ndbg("Set DNS IP address via dns_add_nameserver\n"); dns.sin_addr.s_addr = presult->dnsaddr.s_addr; dns.sin_family = AF_INET; dns.sin_port = htons(DNS_DEFAULT_PORT); dns_add_nameserver((FAR struct sockaddr *)&dns, sizeof(struct sockaddr_in)); } #endif return OK; }
/****************************************************************************** * FunctionName : espconn_dns_setserver * Description : Initialize one of the DNS servers. * Parameters : numdns -- the index of the DNS server to set must * be < DNS_MAX_SERVERS = 2 * dnsserver -- IP address of the DNS server to set * Returns : none *******************************************************************************/ void ICACHE_FLASH_ATTR espconn_dns_setserver(u8_t numdns, ip_addr_t *dnsserver) { dns_setserver(numdns,dnsserver); }
int main(int argc, char *argv[]) { int c; int keep_alive; int non_local; struct netif *netif; int dns_count; char *str; char *endptr; int mtu; int fd_in; int fd_out; ip4_addr_t ipaddr; ip4_addr_t netmask; ip4_addr_t gateway; ip4_addr_t dns; struct event_base *base; char *pcap_file; struct conn_info *local; struct conn_info *remote; struct conn_info *socks; struct conn_info *info; ip_addr_set_zero(&ipaddr); ip_addr_set_zero(&netmask); ip_addr_set_zero(&gateway); local = remote = socks = NULL; dns_count = 0; keep_alive = 0; fd_in = 0; fd_out = 1; mtu = 0; pcap_file = NULL; non_local = 0; signal(SIGPIPE, SIG_IGN); base = event_base_new(); lwip_init(); libevent_timeouts_init(base); if ((str = getenv("INTERNAL_IP4_ADDRESS"))) ip4addr_aton(str, &ipaddr); if ((str = getenv("INTERNAL_IP4_MTU"))) mtu = strtoul(str, NULL, 0); if ((str = getenv("VPNFD"))) fd_in = fd_out = strtoul(str, NULL, 0); if ((str = getenv("CISCO_DEF_DOMAIN"))) { endptr = str; while ((str = tokenize(endptr, ", ", &endptr))) host_add_search(str); } if ((str = getenv("INTERNAL_IP4_DNS"))) { endptr = str; while ((str = tokenize(endptr, ", ", &endptr))) { ip4addr_aton(str, &dns); dns_setserver(dns_count++, &dns); free(str); } } while ((c = getopt(argc, argv, "L:D:R:k:m:s:d:i:n:G:p:gh")) != -1) { switch (c) { case 'L': info = parse_conn_info(optarg, 4); if (!info) print_usage(argv[0]); info->next = local; local = info; break; case 'D': info = parse_conn_info(optarg, 2); if (!info) print_usage(argv[0]); info->next = socks; socks = info; break; case 'R': info = parse_conn_info(optarg, 4); if (!info) print_usage(argv[0]); info->next = remote; remote = info; break; case 'k': keep_alive = strtoul(optarg, &endptr, 0); if (*endptr) print_usage(argv[0]); keep_alive *= 1000; break; case 'm': mtu = strtoul(optarg, &endptr, 0); if (*endptr) print_usage(argv[0]); break; case 's': while ((str = tokenize(optarg, ", ", &optarg))) host_add_search(str); break; case 'd': while ((str = tokenize(optarg, ", ", &optarg))) { ip4addr_aton(str, &dns); dns_setserver(dns_count++, &dns); free(str); } break; case 'i': ip4addr_aton(optarg, &ipaddr); break; case 'n': ip4addr_aton(optarg, &netmask); break; case 'G': ip4addr_aton(optarg, &gateway); break; #ifdef USE_PCAP case 'p': pcap_file = strdup(optarg); break; #endif case 'g': non_local = 1; break; default: print_usage(argv[0]); } } while (local) { info = local; str = info->bind && info->bind[0] ? info->bind : NULL; if (!non_local) str = str ? : "localhost"; if (forward_local(base, str, info->bind_port, info->host, info->host_port, keep_alive) < 0) return -1; local = info->next; free_conn_info(info); } while (socks) { info = socks; str = info->bind && info->bind[0] ? info->bind : NULL; if (!non_local) str = str ? : "localhost"; if (socks_listen(base, str, info->bind_port, keep_alive) < 0) return -1; socks = socks->next; free_conn_info(info); } while (remote) { info = remote; if (forward_remote(base, info->bind_port, info->host, info->host_port, keep_alive) < 0) return -1; remote = info->next; free_conn_info(info); } netif = tunif_add(base, fd_in, fd_out, pcap_file); netif_set_ipaddr(netif, &ipaddr); netif_set_netmask(netif, &netmask); netif_set_gw(netif, &gateway); if (mtu) netif->mtu = mtu; netif_set_up(netif); event_base_dispatch(base); return 0; }
HRESULT LWIP_SOCKETS_Driver::UpdateAdapterConfiguration( UINT32 interfaceIndex, UINT32 updateFlags, SOCK_NetworkConfiguration* config ) { NATIVE_PROFILE_PAL_NETWORK(); if(interfaceIndex >= NETWORK_INTERFACE_COUNT) { return CLR_E_INVALID_PARAMETER; } BOOL fEnableDhcp = (0 != (config->flags & SOCK_NETWORKCONFIGURATION_FLAGS_DHCP)); BOOL fDynamicDns = (0 != (config->flags & SOCK_NETWORKCONFIGURATION_FLAGS_DYNAMIC_DNS)); BOOL fDhcpStarted; struct netif *pNetIf = netif_find_interface(g_LWIP_SOCKETS_Driver.m_interfaces[interfaceIndex].m_interfaceNumber); if (NULL == pNetIf) { return CLR_E_FAIL; } fDhcpStarted = (0 != (pNetIf->flags & NETIF_FLAG_DHCP)); #if LWIP_DNS // when using DHCP do not use the static settings if(0 != (updateFlags & SOCK_NETWORKCONFIGURATION_UPDATE_DNS)) { if(!fDynamicDns && (config->dnsServer1 != 0 || config->dnsServer2 != 0)) { // user defined DNS addresses if(config->dnsServer1 != 0) { u8_t idx = 0; dns_setserver(idx, (struct ip_addr *)&config->dnsServer1); } if(config->dnsServer2 != 0) { u8_t idx = 1; dns_setserver(idx, (struct ip_addr *)&config->dnsServer2); } } } #endif #if LWIP_DHCP if(0 != (updateFlags & SOCK_NETWORKCONFIGURATION_UPDATE_DHCP)) { if(fEnableDhcp) { if(!fDhcpStarted) { if(ERR_OK != dhcp_start(pNetIf)) { return CLR_E_FAIL; } } } else { if(fDhcpStarted) { dhcp_stop(pNetIf); } netif_set_addr(pNetIf, (struct ip_addr *) &config->ipaddr, (struct ip_addr *)&config->subnetmask, (struct ip_addr *)&config->gateway); Network_PostEvent( NETWORK_EVENT_TYPE_ADDRESS_CHANGED, 0 ); } } if(fEnableDhcp && fDhcpStarted) { // Try Renew before release since renewing after release will fail if(0 != (updateFlags & SOCK_NETWORKCONFIGURATION_UPDATE_DHCP_RENEW)) { //netifapi_netif_common(pNetIf, NULL, dhcp_renew); dhcp_renew(pNetIf); } else if(0 != (updateFlags & SOCK_NETWORKCONFIGURATION_UPDATE_DHCP_RELEASE)) { //netifapi_netif_common(pNetIf, NULL, dhcp_release); dhcp_release(pNetIf); } } #endif if(0 != (updateFlags & SOCK_NETWORKCONFIGURATION_UPDATE_MAC)) { int len = __min(config->macAddressLen, sizeof(pNetIf->hwaddr)); memcpy(pNetIf->hwaddr, config->macAddressBuffer, len); pNetIf->hwaddr_len = len; // mac address requires stack re-init Network_Interface_Close(interfaceIndex); g_LWIP_SOCKETS_Driver.m_interfaces[interfaceIndex].m_interfaceNumber = Network_Interface_Open(interfaceIndex); } return S_OK; }
int uip_main(int argc, char *argv[]) { struct in_addr addr; #if defined(CONFIG_EXAMPLES_UIP_DHCPC) || defined(CONFIG_EXAMPLES_UIP_NOMAC) uint8_t mac[IFHWADDRLEN]; #endif #ifdef CONFIG_EXAMPLES_UIP_DHCPC void *handle; #endif /* Many embedded network interfaces must have a software assigned MAC */ #ifdef CONFIG_EXAMPLES_UIP_NOMAC mac[0] = 0x00; mac[1] = 0xe0; mac[2] = 0xde; mac[3] = 0xad; mac[4] = 0xbe; mac[5] = 0xef; uip_setmacaddr("eth0", mac); #endif /* Set up our host address */ #ifdef CONFIG_EXAMPLES_UIP_DHCPC addr.s_addr = 0; #else addr.s_addr = HTONL(CONFIG_EXAMPLES_UIP_IPADDR); #endif uip_sethostaddr("eth0", &addr); /* Set up the default router address */ addr.s_addr = HTONL(CONFIG_EXAMPLES_UIP_DRIPADDR); uip_setdraddr("eth0", &addr); /* Setup the subnet mask */ addr.s_addr = HTONL(CONFIG_EXAMPLES_UIP_NETMASK); uip_setnetmask("eth0", &addr); #ifdef CONFIG_EXAMPLES_UIP_DHCPC /* Set up the resolver */ dns_bind(); /* Get the MAC address of the NIC */ uip_getmacaddr("eth0", mac); /* Set up the DHCPC modules */ handle = dhcpc_open(&mac, IFHWADDRLEN); /* Get an IP address. Note: there is no logic here for renewing the address in this * example. The address should be renewed in ds.lease_time/2 seconds. */ printf("Getting IP address\n"); if (handle) { struct dhcpc_state ds; (void)dhcpc_request(handle, &ds); uip_sethostaddr("eth1", &ds.ipaddr); if (ds.netmask.s_addr != 0) { uip_setnetmask("eth0", &ds.netmask); } if (ds.default_router.s_addr != 0) { uip_setdraddr("eth0", &ds.default_router); } if (ds.dnsaddr.s_addr != 0) { dns_setserver(&ds.dnsaddr); } dhcpc_close(handle); printf("IP: %s\n", inet_ntoa(ds.ipaddr)); } #endif #ifdef CONFIG_NET_TCP printf("Starting webserver\n"); httpd_init(); cgi_register(); httpd_listen(); #endif while (1) { sleep(3); printf("uip_main: Still running\n"); #if CONFIG_NFILE_DESCRIPTORS > 0 fflush(stdout); #endif } return 0; }
int discover_main(int argc, char *argv[]) { /* If this task is excecutated as an NSH built-in function, then the * network has already been configured by NSH's start-up logic. */ #ifndef CONFIG_NSH_BUILTIN_APPS struct in_addr addr; #if defined(CONFIG_EXAMPLES_DISCOVER_DHCPC) || defined(CONFIG_EXAMPLES_DISCOVER_NOMAC) uint8_t mac[IFHWADDRLEN]; #endif #ifdef CONFIG_EXAMPLES_DISCOVER_DHCPC void *handle; #endif /* Many embedded network interfaces must have a software assigned MAC */ #ifdef CONFIG_EXAMPLES_DISCOVER_NOMAC mac[0] = 0x00; mac[1] = 0xe0; mac[2] = 0xde; mac[3] = 0xad; mac[4] = 0xbe; mac[5] = 0xef; uip_setmacaddr("eth0", mac); #endif /* Set up our host address */ #ifdef CONFIG_EXAMPLES_DISCOVER_DHCPC addr.s_addr = 0; #else addr.s_addr = HTONL(CONFIG_EXAMPLES_DISCOVER_IPADDR); #endif uip_sethostaddr("eth0", &addr); /* Set up the default router address */ addr.s_addr = HTONL(CONFIG_EXAMPLES_DISCOVER_DRIPADDR); uip_setdraddr("eth0", &addr); /* Setup the subnet mask */ addr.s_addr = HTONL(CONFIG_EXAMPLES_DISCOVER_NETMASK); uip_setnetmask("eth0", &addr); #ifdef CONFIG_EXAMPLES_DISCOVER_DHCPC /* Set up the resolver */ dns_bind(); /* Get the MAC address of the NIC */ uip_getmacaddr("eth0", mac); /* Set up the DHCPC modules */ handle = dhcpc_open(&mac, IFHWADDRLEN); /* Get an IP address. Note: there is no logic here for renewing the address in this * example. The address should be renewed in ds.lease_time/2 seconds. */ printf("Getting IP address\n"); if (handle) { struct dhcpc_state ds; (void)dhcpc_request(handle, &ds); uip_sethostaddr("eth1", &ds.ipaddr); if (ds.netmask.s_addr != 0) { uip_setnetmask("eth0", &ds.netmask); } if (ds.default_router.s_addr != 0) { uip_setdraddr("eth0", &ds.default_router); } if (ds.dnsaddr.s_addr != 0) { dns_setserver(&ds.dnsaddr); } dhcpc_close(handle); printf("IP: %s\n", inet_ntoa(ds.ipaddr)); } #endif /* CONFIG_EXAMPLES_DISCOVER_DHCPC */ #endif /* CONFIG_NSH_BUILTIN_APPS */ if (discover_start(NULL) < 0) { ndbg("Could not start discover daemon.\n"); return ERROR; } return OK; }
void tls_netif_dns_setserver(u8 numdns, ip_addr_t *dnsserver) { dns_setserver(numdns, dnsserver); }
/** * Change IP configuration settings disabling the dhcp client * @param local_ip Static ip configuration * @param gateway Static gateway configuration * @param subnet Static Subnet mask * @param dns1 Static DNS server 1 * @param dns2 Static DNS server 2 */ bool ESP8266WiFiSTAClass::config(IPAddress local_ip, IPAddress arg1, IPAddress arg2, IPAddress arg3, IPAddress dns2) { if(!WiFi.enableSTA(true)) { return false; } //ESP argument order is: ip, gateway, subnet, dns1 //Arduino arg order is: ip, dns, gateway, subnet. //first, check whether dhcp should be used, which is when ip == 0 && gateway == 0 && subnet == 0. bool espOrderUseDHCP = (local_ip == 0U && arg1 == 0U && arg2 == 0U); bool arduinoOrderUseDHCP = (local_ip == 0U && arg2 == 0U && arg3 == 0U); if (espOrderUseDHCP || arduinoOrderUseDHCP) { _useStaticIp = false; wifi_station_dhcpc_start(); return true; } //To allow compatibility, check first octet of 3rd arg. If 255, interpret as ESP order, otherwise Arduino order. IPAddress gateway = arg1; IPAddress subnet = arg2; IPAddress dns1 = arg3; if(subnet[0] != 255) { //octet is not 255 => interpret as Arduino order gateway = arg2; subnet = arg3[0] == 0 ? IPAddress(255,255,255,0) : arg3; //arg order is arduino and 4th arg not given => assign it arduino default dns1 = arg1; } // check whether all is IPv4 (or gateway not set) if (!(local_ip.isV4() && subnet.isV4() && (!gateway.isSet() || gateway.isV4()))) { return false; } //ip and gateway must be in the same subnet if((local_ip.v4() & subnet.v4()) != (gateway.v4() & subnet.v4())) { return false; } struct ip_info info; info.ip.addr = local_ip.v4(); info.gw.addr = gateway.v4(); info.netmask.addr = subnet.v4(); wifi_station_dhcpc_stop(); if(wifi_set_ip_info(STATION_IF, &info)) { _useStaticIp = true; } else { return false; } if(dns1.isSet()) { // Set DNS1-Server dns_setserver(0, dns1); } if(dns2.isSet()) { // Set DNS2-Server dns_setserver(1, dns2); } return true; }
/********************************************************************************************************* ** 函数名称: __tshellIfconfig ** 功能描述: 系统命令 "ifconfig" ** 输 入 : iArgC 参数个数 ** ppcArgV 参数表 ** 输 出 : 0 ** 全局变量: ** 调用模块: *********************************************************************************************************/ static INT __tshellIfconfig (INT iArgC, PCHAR *ppcArgV) { struct netif *netif; struct in_addr inaddr; ip_addr_t ipaddr; if (iArgC == 1) { LWIP_NETIF_LOCK(); __netIfShowAll(); /* 打印所有网口信息 */ LWIP_NETIF_UNLOCK(); return (ERROR_NONE); } else if (iArgC == 2) { LWIP_NETIF_LOCK(); __netIfShow(ppcArgV[1], LW_NULL); /* 打印指定网口信息 */ LWIP_NETIF_UNLOCK(); return (ERROR_NONE); } /* * 网络设置 */ if (iArgC >= 4) { if (lib_strcmp(ppcArgV[1], "dns") == 0) { /* * 指定 DNS 设置 */ INT iDnsIndex = 0; sscanf(ppcArgV[2], "%d", &iDnsIndex); if (iDnsIndex >= DNS_MAX_SERVERS) { fprintf(stderr, "argments error!\n"); return (-ERROR_TSHELL_EPARAM); } if (inet_aton(ppcArgV[3], &inaddr) == 0) { /* 获得 IP 地址 */ fprintf(stderr, "address error.\n"); return (-ERROR_TSHELL_EPARAM); } ipaddr.addr = inaddr.s_addr; dns_setserver((u8_t)iDnsIndex, &ipaddr); /* 设置 DNS */ } else { /* * 指定网络接口设置 */ INT iIndex; netif = netif_find(ppcArgV[1]); /* 查询网络接口 */ if (netif == LW_NULL) { fprintf(stderr, "can not find net interface.\n"); return (-ERROR_TSHELL_EPARAM); } for (iIndex = 2; iIndex < (iArgC - 1); iIndex += 2) { /* 连续设置参数 */ if (inet_aton(ppcArgV[iIndex + 1], &inaddr) == 0) { /* 获得 IP 地址 */ fprintf(stderr, "address error.\n"); return (-ERROR_TSHELL_EPARAM); } ipaddr.addr = inaddr.s_addr; __netIfSet(netif, ppcArgV[iIndex], ipaddr); /* 设置网络接口 */ } } } return (ERROR_NONE); }