Skip to content

Commit

Permalink
Fix IPv6-only builds where platform LwIP has IPv4 (#10879)
Browse files Browse the repository at this point in the history
#### Problem

When LwIP is configured for IPv6 only, its type `ip_addr_t` is identical
to `ip6_addr_t`; otherwise they are different. PR #10791 made the
incorrect assumption that we would never build CHIP without IPv4 when
then platform LwIP is configured with IPv4, and left out the constructor
overload necessary for that case.

#### Change overview

Enable the `ip_addr_t` constructor if `LWIP_IPV4` is true.

#### Testing

Built
```
scripts/build/build_examples.py \
    --target esp32-m5stack-all-clusters-ipv6only build`
```
  • Loading branch information
kpschoedel authored and pull[bot] committed Jan 21, 2022
1 parent 02f59fb commit 3222315
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/inet/IPAddress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ IPAddress::IPAddress(const ip6_addr_t & ipv6Addr)
memcpy(Addr, &ipv6Addr, sizeof(ipv6Addr));
}

#if INET_CONFIG_ENABLE_IPV4
#if INET_CONFIG_ENABLE_IPV4 || LWIP_IPV4

IPAddress::IPAddress(const ip4_addr_t & ipv4Addr)
{
Expand Down Expand Up @@ -106,6 +106,10 @@ IPAddress::IPAddress(const ip_addr_t & addr)
}
}

#endif // INET_CONFIG_ENABLE_IPV4 || LWIP_IPV4

#if INET_CONFIG_ENABLE_IPV4

ip4_addr_t IPAddress::ToIPv4() const
{
ip4_addr_t ipAddr;
Expand Down
2 changes: 1 addition & 1 deletion src/inet/IPAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class DLL_EXPORT IPAddress

#if CHIP_SYSTEM_CONFIG_USE_LWIP
explicit IPAddress(const ip6_addr_t & ipv6Addr);
#if INET_CONFIG_ENABLE_IPV4
#if INET_CONFIG_ENABLE_IPV4 || LWIP_IPV4
explicit IPAddress(const ip4_addr_t & ipv4Addr);
explicit IPAddress(const ip_addr_t & addr);
#endif // INET_CONFIG_ENABLE_IPV4
Expand Down

0 comments on commit 3222315

Please sign in to comment.