Skip to content

Commit 34c1fac

Browse files
authored
Merge pull request #3585 from ARMmbed/release-candidate
Release candidate for mbed-os-5.3.3
2 parents 2885c1b + 27ba238 commit 34c1fac

File tree

263 files changed

+55565
-10769
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

263 files changed

+55565
-10769
lines changed

events/equeue/equeue_mbed.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ static void equeue_sema_timeout(equeue_sema_t *s) {
124124
bool equeue_sema_wait(equeue_sema_t *s, int ms) {
125125
int signal = 0;
126126
Timeout timeout;
127-
timeout.attach_us(s, equeue_sema_timeout, ms*1000);
127+
if (ms > 0) {
128+
timeout.attach_us(callback(equeue_sema_timeout, s), ms*1000);
129+
}
128130

129131
core_util_critical_section_enter();
130132
while (!*s) {

features/FEATURE_LWIP/lwip-interface/lwip_stack.c

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -243,37 +243,43 @@ const ip_addr_t *mbed_lwip_get_ip_addr(bool any_addr, const struct netif *netif)
243243
return NULL;
244244
}
245245

246-
#if LWIP_IPV6
247246
void add_dns_addr(struct netif *lwip_netif)
248247
{
248+
// Do nothing if not brought up
249249
const ip_addr_t *ip_addr = mbed_lwip_get_ip_addr(true, lwip_netif);
250-
if (ip_addr) {
251-
if (IP_IS_V6(ip_addr)) {
252-
const ip_addr_t *dns_ip_addr;
253-
bool dns_addr_exists = false;
254-
255-
for (char numdns = 0; numdns < DNS_MAX_SERVERS; numdns++) {
256-
dns_ip_addr = dns_getserver(numdns);
257-
if (!ip_addr_isany(dns_ip_addr)) {
258-
dns_addr_exists = true;
259-
break;
260-
}
261-
}
250+
if (!ip_addr) {
251+
return;
252+
}
262253

263-
if (!dns_addr_exists) {
264-
/* 2001:4860:4860::8888 google */
265-
ip_addr_t ipv6_dns_addr = IPADDR6_INIT(
266-
PP_HTONL(0x20014860UL),
267-
PP_HTONL(0x48600000UL),
268-
PP_HTONL(0x00000000UL),
269-
PP_HTONL(0x00008888UL));
270-
dns_setserver(0, &ipv6_dns_addr);
271-
}
254+
// Check for existing dns server
255+
for (char numdns = 0; numdns < DNS_MAX_SERVERS; numdns++) {
256+
const ip_addr_t *dns_ip_addr = dns_getserver(numdns);
257+
if (!ip_addr_isany(dns_ip_addr)) {
258+
return;
272259
}
273260
}
274-
}
261+
262+
#if LWIP_IPV6
263+
if (IP_IS_V6(ip_addr)) {
264+
/* 2001:4860:4860::8888 google */
265+
ip_addr_t ipv6_dns_addr = IPADDR6_INIT(
266+
PP_HTONL(0x20014860UL),
267+
PP_HTONL(0x48600000UL),
268+
PP_HTONL(0x00000000UL),
269+
PP_HTONL(0x00008888UL));
270+
dns_setserver(0, &ipv6_dns_addr);
271+
}
275272
#endif
276273

274+
#if LWIP_IPV4
275+
if (IP_IS_V4(ip_addr)) {
276+
/* 8.8.8.8 google */
277+
ip_addr_t ipv4_dns_addr = IPADDR4_INIT(0x08080808);
278+
dns_setserver(0, &ipv4_dns_addr);
279+
}
280+
#endif
281+
}
282+
277283
static sys_sem_t lwip_tcpip_inited;
278284
static void mbed_lwip_tcpip_init_irq(void *eh)
279285
{
@@ -495,7 +501,6 @@ nsapi_error_t mbed_lwip_bringup(bool dhcp, const char *ip, const char *netmask,
495501
if (ret == SYS_ARCH_TIMEOUT) {
496502
return NSAPI_ERROR_DHCP_FAILURE;
497503
}
498-
lwip_connected = true;
499504
}
500505

501506
#if ADDR_TIMEOUT
@@ -506,10 +511,9 @@ nsapi_error_t mbed_lwip_bringup(bool dhcp, const char *ip, const char *netmask,
506511
}
507512
#endif
508513

509-
#if LWIP_IPV6
510514
add_dns_addr(&lwip_netif);
511-
#endif
512515

516+
lwip_connected = true;
513517
return 0;
514518
}
515519

@@ -618,6 +622,22 @@ static nsapi_error_t mbed_lwip_gethostbyname(nsapi_stack_t *stack, const char *h
618622
return 0;
619623
}
620624

625+
static nsapi_error_t mbed_lwip_add_dns_server(nsapi_stack_t *stack, nsapi_addr_t addr)
626+
{
627+
// Shift all dns servers down to give precedence to new server
628+
for (int i = DNS_MAX_SERVERS-1; i > 0; i--) {
629+
dns_setserver(i, dns_getserver(i-1));
630+
}
631+
632+
ip_addr_t ip_addr;
633+
if (!convert_mbed_addr_to_lwip(&ip_addr, &addr)) {
634+
return NSAPI_ERROR_PARAMETER;
635+
}
636+
637+
dns_setserver(0, &ip_addr);
638+
return 0;
639+
}
640+
621641
static nsapi_error_t mbed_lwip_socket_open(nsapi_stack_t *stack, nsapi_socket_t *handle, nsapi_protocol_t proto)
622642
{
623643
// check if network is connected
@@ -874,6 +894,7 @@ static void mbed_lwip_socket_attach(nsapi_stack_t *stack, nsapi_socket_t handle,
874894
/* LWIP network stack */
875895
const nsapi_stack_api_t lwip_stack_api = {
876896
.gethostbyname = mbed_lwip_gethostbyname,
897+
.add_dns_server = mbed_lwip_add_dns_server,
877898
.socket_open = mbed_lwip_socket_open,
878899
.socket_close = mbed_lwip_socket_close,
879900
.socket_bind = mbed_lwip_socket_bind,
486 KB
Binary file not shown.
480 KB
Binary file not shown.
480 KB
Binary file not shown.
349 KB
Binary file not shown.
343 KB
Binary file not shown.
343 KB
Binary file not shown.
857 KB
Binary file not shown.
849 KB
Binary file not shown.

0 commit comments

Comments
 (0)