mirror of https://github.com/ARMmbed/mbed-os.git
Adopted netconn_gethostbyname in the lwip interface
Provides proper integration with DHCP through lwippull/2590/head
parent
6c2a82b96a
commit
83286c3e78
|
@ -217,7 +217,7 @@ static int lwip_err_remap(err_t err) {
|
||||||
|
|
||||||
|
|
||||||
/* LWIP network stack implementation */
|
/* LWIP network stack implementation */
|
||||||
static nsapi_addr_t lwip_get_addr(nsapi_stack_t *stack)
|
static nsapi_addr_t lwip_getaddr(nsapi_stack_t *stack)
|
||||||
{
|
{
|
||||||
if (!lwip_get_ip_address()) {
|
if (!lwip_get_ip_address()) {
|
||||||
return (nsapi_addr_t){0};
|
return (nsapi_addr_t){0};
|
||||||
|
@ -229,6 +229,17 @@ static nsapi_addr_t lwip_get_addr(nsapi_stack_t *stack)
|
||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int lwip_gethostbyname(nsapi_stack_t *stack, nsapi_addr_t *addr, const char *host)
|
||||||
|
{
|
||||||
|
err_t err = netconn_gethostbyname(host, (ip_addr_t *)addr->bytes);
|
||||||
|
if (err != ERR_OK) {
|
||||||
|
return NSAPI_ERROR_DNS_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
addr->version = NSAPI_IPv4;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int lwip_socket_open(nsapi_stack_t *stack, nsapi_socket_t *handle, nsapi_protocol_t proto)
|
static int lwip_socket_open(nsapi_stack_t *stack, nsapi_socket_t *handle, nsapi_protocol_t proto)
|
||||||
{
|
{
|
||||||
struct lwip_socket *s = lwip_arena_alloc();
|
struct lwip_socket *s = lwip_arena_alloc();
|
||||||
|
@ -445,7 +456,8 @@ static void lwip_socket_attach(nsapi_stack_t *stack, nsapi_socket_t handle, void
|
||||||
|
|
||||||
/* LWIP network stack */
|
/* LWIP network stack */
|
||||||
const nsapi_stack_api_t lwip_stack_api = {
|
const nsapi_stack_api_t lwip_stack_api = {
|
||||||
.get_ip_address = lwip_get_addr,
|
.get_ip_address = lwip_getaddr,
|
||||||
|
.gethostbyname = lwip_gethostbyname,
|
||||||
.socket_open = lwip_socket_open,
|
.socket_open = lwip_socket_open,
|
||||||
.socket_close = lwip_socket_close,
|
.socket_close = lwip_socket_close,
|
||||||
.socket_bind = lwip_socket_bind,
|
.socket_bind = lwip_socket_bind,
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
|
|
||||||
#define LWIP_DHCP 1
|
#define LWIP_DHCP 1
|
||||||
#define LWIP_DNS 1
|
#define LWIP_DNS 1
|
||||||
|
#define LWIP_SOCKET 0
|
||||||
|
|
||||||
#define SO_REUSE 1
|
#define SO_REUSE 1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue