@@ -217,7 +217,7 @@ static int lwip_err_remap(err_t err) {
217217
218218
219219/* 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 )
221221{
222222 if (!lwip_get_ip_address ()) {
223223 return (nsapi_addr_t ){0 };
@@ -229,6 +229,17 @@ static nsapi_addr_t lwip_get_addr(nsapi_stack_t *stack)
229229 return addr ;
230230}
231231
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+
232243static int lwip_socket_open (nsapi_stack_t * stack , nsapi_socket_t * handle , nsapi_protocol_t proto )
233244{
234245 struct lwip_socket * s = lwip_arena_alloc ();
@@ -449,7 +460,8 @@ static void lwip_socket_attach(nsapi_stack_t *stack, nsapi_socket_t handle, void
449460
450461/* LWIP network stack */
451462const nsapi_stack_api_t lwip_stack_api = {
452- .get_ip_address = lwip_get_addr ,
463+ .get_ip_address = lwip_getaddr ,
464+ .gethostbyname = lwip_gethostbyname ,
453465 .socket_open = lwip_socket_open ,
454466 .socket_close = lwip_socket_close ,
455467 .socket_bind = lwip_socket_bind ,
0 commit comments