diff --git a/src/api/api_lib.c b/src/api/api_lib.c index 971fe918..97660377 100644 --- a/src/api/api_lib.c +++ b/src/api/api_lib.c @@ -829,20 +829,19 @@ netconn_gethostbyname(const char *name, ip_addr_t *addr) API_VAR_ALLOC(struct dns_api_msg, MEMP_DNS_API_MSG, msg); #if LWIP_MPU_COMPATIBLE - if (addr == NULL) { - addr = IP_ADDR_ANY; - } -#else + strncpy(API_VAR_REF(msg).name, name, DNS_MAX_NAME_LENGTH-1); + API_VAR_REF(msg).name[DNS_MAX_NAME_LENGTH-1] = 0; +#else /* LWIP_MPU_COMPATIBLE */ msg.err = &err; msg.sem = &sem; API_VAR_REF(msg).addr = API_VAR_REF(addr); + API_VAR_REF(msg).name = name; #endif /* LWIP_MPU_COMPATIBLE */ err = sys_sem_new(API_EXPR_REF(API_VAR_REF(msg).sem), 0); if (err != ERR_OK) { API_VAR_FREE(MEMP_DNS_API_MSG, msg); return err; } - API_VAR_REF(msg).name = name; tcpip_callback(lwip_netconn_do_gethostbyname, &API_VAR_REF(msg)); sys_sem_wait(API_EXPR_REF(API_VAR_REF(msg).sem)); diff --git a/src/include/lwip/api_msg.h b/src/include/lwip/api_msg.h index 95614b7a..f9a195ae 100644 --- a/src/include/lwip/api_msg.h +++ b/src/include/lwip/api_msg.h @@ -140,7 +140,11 @@ struct api_msg { (see netconn_gethostbyname). */ struct dns_api_msg { /** Hostname to query or dotted IP address string */ +#if LWIP_MPU_COMPATIBLE + char name[DNS_MAX_NAME_LENGTH]; +#else /* LWIP_MPU_COMPATIBLE */ const char *name; +#endif /* LWIP_MPU_COMPATIBLE */ /** Rhe resolved address is stored here */ ip_addr_t API_MSG_M_DEF(addr); /** This semaphore is posted when the name is resolved, the application thread