Skip to content

Commit 6d9ac9f

Browse files
committed
lwip - Added support for NSAPI_UNSPEC to lwip
1 parent 1f4eb0a commit 6d9ac9f

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

features/FEATURE_LWIP/lwip-interface/lwip_stack.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,8 @@ static bool convert_mbed_addr_to_lwip(ip_addr_t *out, const nsapi_addr_t *in)
120120
#if !LWIP_IPV4
121121
/* For bind() and other purposes, need to accept "null" of other type */
122122
/* (People use IPv4 0.0.0.0 as a general null) */
123-
if (in->version == NSAPI_IPv4 && all_zeros(in->bytes, 4)) {
123+
if (in->version == NSAPI_UNSPEC ||
124+
(in->version == NSAPI_IPv4 && all_zeros(in->bytes, 4))) {
124125
ip_addr_set_zero_ip6(out);
125126
return true;
126127
}
@@ -135,13 +136,25 @@ static bool convert_mbed_addr_to_lwip(ip_addr_t *out, const nsapi_addr_t *in)
135136
}
136137
#if !LWIP_IPV6
137138
/* For symmetry with above, accept IPv6 :: as a general null */
138-
if (in->version == NSAPI_IPv6 && all_zeros(in->bytes, 16)) {
139+
if (in->version == NSAPI_UNSPEC ||
140+
(in->version == NSAPI_IPv6 && all_zeros(in->bytes, 16))) {
139141
ip_addr_set_zero_ip4(out);
140142
return true;
141143
}
142144
#endif
143145
#endif
144146

147+
#if LWIP_IPV4 && LWIP_IPV6
148+
if (in->version == NSAPI_UNSPEC) {
149+
#if IP_VERSION_PREF == PREF_IPV4
150+
ip_addr_set_zero_ip4(out);
151+
#else
152+
ip_addr_set_zero_ip6(out);
153+
#endif
154+
return true;
155+
}
156+
#endif
157+
145158
return false;
146159
}
147160

0 commit comments

Comments
 (0)