Fixed netdb.c when LWIP_SOCKET_HAVE_SA_LEN == 0

Fields sin6_len and sin_len are always used in the file but not all implementations of sockaddr_in or sockaddr_in6 have this fields (including Linux implementation).
Added #if-check to avoid compilation errors in such cases.
This commit is contained in:
Kirill Lokotkov 2023-11-29 13:23:23 +03:00 committed by goldsimon
parent 7c494b3829
commit 93821fc437

View File

@ -383,7 +383,9 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
/* set up sockaddr */ /* set up sockaddr */
inet6_addr_from_ip6addr(&sa6->sin6_addr, ip_2_ip6(&addr)); inet6_addr_from_ip6addr(&sa6->sin6_addr, ip_2_ip6(&addr));
sa6->sin6_family = AF_INET6; sa6->sin6_family = AF_INET6;
#if LWIP_SOCKET_HAVE_SA_LEN
sa6->sin6_len = sizeof(struct sockaddr_in6); sa6->sin6_len = sizeof(struct sockaddr_in6);
#endif /* LWIP_SOCKET_HAVE_SA_LEN */
sa6->sin6_port = lwip_htons((u16_t)port_nr); sa6->sin6_port = lwip_htons((u16_t)port_nr);
sa6->sin6_scope_id = ip6_addr_zone(ip_2_ip6(&addr)); sa6->sin6_scope_id = ip6_addr_zone(ip_2_ip6(&addr));
ai->ai_family = AF_INET6; ai->ai_family = AF_INET6;
@ -394,7 +396,9 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
/* set up sockaddr */ /* set up sockaddr */
inet_addr_from_ip4addr(&sa4->sin_addr, ip_2_ip4(&addr)); inet_addr_from_ip4addr(&sa4->sin_addr, ip_2_ip4(&addr));
sa4->sin_family = AF_INET; sa4->sin_family = AF_INET;
#if LWIP_SOCKET_HAVE_SA_LEN
sa4->sin_len = sizeof(struct sockaddr_in); sa4->sin_len = sizeof(struct sockaddr_in);
#endif /* LWIP_SOCKET_HAVE_SA_LEN */
sa4->sin_port = lwip_htons((u16_t)port_nr); sa4->sin_port = lwip_htons((u16_t)port_nr);
ai->ai_family = AF_INET; ai->ai_family = AF_INET;
#endif /* LWIP_IPV4 */ #endif /* LWIP_IPV4 */