Skip to content

Commit

Permalink
lwip - Added support for NSAPI_UNSPEC to lwip
Browse files Browse the repository at this point in the history
  • Loading branch information
geky committed Oct 5, 2016
1 parent 1f4eb0a commit 6d9ac9f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions features/FEATURE_LWIP/lwip-interface/lwip_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ static bool convert_mbed_addr_to_lwip(ip_addr_t *out, const nsapi_addr_t *in)
#if !LWIP_IPV4
/* For bind() and other purposes, need to accept "null" of other type */
/* (People use IPv4 0.0.0.0 as a general null) */
if (in->version == NSAPI_IPv4 && all_zeros(in->bytes, 4)) {
if (in->version == NSAPI_UNSPEC ||
(in->version == NSAPI_IPv4 && all_zeros(in->bytes, 4))) {
ip_addr_set_zero_ip6(out);
return true;
}
Expand All @@ -135,13 +136,25 @@ static bool convert_mbed_addr_to_lwip(ip_addr_t *out, const nsapi_addr_t *in)
}
#if !LWIP_IPV6
/* For symmetry with above, accept IPv6 :: as a general null */
if (in->version == NSAPI_IPv6 && all_zeros(in->bytes, 16)) {
if (in->version == NSAPI_UNSPEC ||
(in->version == NSAPI_IPv6 && all_zeros(in->bytes, 16))) {
ip_addr_set_zero_ip4(out);
return true;
}
#endif
#endif

#if LWIP_IPV4 && LWIP_IPV6
if (in->version == NSAPI_UNSPEC) {
#if IP_VERSION_PREF == PREF_IPV4
ip_addr_set_zero_ip4(out);
#else
ip_addr_set_zero_ip6(out);
#endif
return true;
}
#endif

return false;
}

Expand Down

0 comments on commit 6d9ac9f

Please sign in to comment.