ping: sizeof to struct not pointer

This commit is contained in:
quanjia 2021-11-22 16:52:17 +08:00 committed by Erik Ekman
parent 53c09fe921
commit 553fedd443

View File

@ -152,7 +152,7 @@ ping_send(int s, const ip_addr_t *addr)
#if LWIP_IPV4
if(IP_IS_V4(addr)) {
struct sockaddr_in *to4 = (struct sockaddr_in*)&to;
to4->sin_len = sizeof(to4);
to4->sin_len = sizeof(*to4);
to4->sin_family = AF_INET;
inet_addr_from_ip4addr(&to4->sin_addr, ip_2_ip4(addr));
}
@ -161,7 +161,7 @@ ping_send(int s, const ip_addr_t *addr)
#if LWIP_IPV6
if(IP_IS_V6(addr)) {
struct sockaddr_in6 *to6 = (struct sockaddr_in6*)&to;
to6->sin6_len = sizeof(to6);
to6->sin6_len = sizeof(*to6);
to6->sin6_family = AF_INET6;
inet6_addr_from_ip6addr(&to6->sin6_addr, ip_2_ip6(addr));
}