@@ -217,7 +217,7 @@ static int lwip_err_remap(err_t err) {
217
217
218
218
219
219
/* LWIP network stack implementation */
220
- static nsapi_addr_t lwip_get_addr (nsapi_stack_t * stack )
220
+ static nsapi_addr_t lwip_getaddr (nsapi_stack_t * stack )
221
221
{
222
222
if (!lwip_get_ip_address ()) {
223
223
return (nsapi_addr_t ){0 };
@@ -229,6 +229,17 @@ static nsapi_addr_t lwip_get_addr(nsapi_stack_t *stack)
229
229
return addr ;
230
230
}
231
231
232
+ static int lwip_gethostbyname (nsapi_stack_t * stack , nsapi_addr_t * addr , const char * host )
233
+ {
234
+ err_t err = netconn_gethostbyname (host , (ip_addr_t * )addr -> bytes );
235
+ if (err != ERR_OK ) {
236
+ return NSAPI_ERROR_DNS_FAILURE ;
237
+ }
238
+
239
+ addr -> version = NSAPI_IPv4 ;
240
+ return 0 ;
241
+ }
242
+
232
243
static int lwip_socket_open (nsapi_stack_t * stack , nsapi_socket_t * handle , nsapi_protocol_t proto )
233
244
{
234
245
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
445
456
446
457
/* LWIP network stack */
447
458
const nsapi_stack_api_t lwip_stack_api = {
448
- .get_ip_address = lwip_get_addr ,
459
+ .get_ip_address = lwip_getaddr ,
460
+ .gethostbyname = lwip_gethostbyname ,
449
461
.socket_open = lwip_socket_open ,
450
462
.socket_close = lwip_socket_close ,
451
463
.socket_bind = lwip_socket_bind ,
0 commit comments