Skip to content

Commit 6fd059e

Browse files
Fixed LWIPStack socket_sendto member to fail if interface IP4/6 version differ from destination adress IP version
1 parent fc645bc commit 6fd059e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

features/lwipstack/LWIPStack.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,12 +488,18 @@ nsapi_size_or_error_t LWIP::socket_sendto(nsapi_socket_t handle, const SocketAdd
488488
{
489489
struct mbed_lwip_socket *s = (struct mbed_lwip_socket *)handle;
490490
ip_addr_t ip_addr;
491+
nsapi_addr_t interface_addr;
491492

492493
nsapi_addr_t addr = address.get_addr();
493494
if (!convert_mbed_addr_to_lwip(&ip_addr, &addr)) {
494495
return NSAPI_ERROR_PARAMETER;
495496
}
496497

498+
convert_lwip_addr_to_mbed(&interface_addr, get_ip_addr(true, &default_interface->netif));
499+
if(addr.version != interface_addr.version){
500+
return NSAPI_ERROR_PARAMETER;
501+
}
502+
497503
struct netbuf *buf = netbuf_new();
498504

499505
err_t err = netbuf_ref(buf, data, (u16_t)size);

0 commit comments

Comments
 (0)