Skip to content

Commit d36bda7

Browse files
gekyadbridge
authored andcommitted
lwip - Added support for NSAPI_UNSPEC to lwip
1 parent 1703ed3 commit d36bda7

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
@@ -130,7 +130,8 @@ static bool convert_mbed_addr_to_lwip(ip_addr_t *out, const nsapi_addr_t *in)
130130
#if !LWIP_IPV4
131131
/* For bind() and other purposes, need to accept "null" of other type */
132132
/* (People use IPv4 0.0.0.0 as a general null) */
133-
if (in->version == NSAPI_IPv4 && all_zeros(in->bytes, 4)) {
133+
if (in->version == NSAPI_UNSPEC ||
134+
(in->version == NSAPI_IPv4 && all_zeros(in->bytes, 4))) {
134135
ip_addr_set_zero_ip6(out);
135136
return true;
136137
}
@@ -145,13 +146,25 @@ static bool convert_mbed_addr_to_lwip(ip_addr_t *out, const nsapi_addr_t *in)
145146
}
146147
#if !LWIP_IPV6
147148
/* For symmetry with above, accept IPv6 :: as a general null */
148-
if (in->version == NSAPI_IPv6 && all_zeros(in->bytes, 16)) {
149+
if (in->version == NSAPI_UNSPEC ||
150+
(in->version == NSAPI_IPv6 && all_zeros(in->bytes, 16))) {
149151
ip_addr_set_zero_ip4(out);
150152
return true;
151153
}
152154
#endif
153155
#endif
154156

157+
#if LWIP_IPV4 && LWIP_IPV6
158+
if (in->version == NSAPI_UNSPEC) {
159+
#if IP_VERSION_PREF == PREF_IPV4
160+
ip_addr_set_zero_ip4(out);
161+
#else
162+
ip_addr_set_zero_ip6(out);
163+
#endif
164+
return true;
165+
}
166+
#endif
167+
155168
return false;
156169
}
157170

0 commit comments

Comments
 (0)