Skip to content

Commit

Permalink
Restart DnssdServer on connectivity change, not only on ipv4, but als…
Browse files Browse the repository at this point in the history
…o on ipv6

Signed-off-by: Lo,Chin-Ran <[email protected]>
  • Loading branch information
crlonxp committed Oct 24, 2024
1 parent beef6d0 commit fa94ca0
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions src/platform/Linux/ConnectivityManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1781,19 +1781,29 @@ void ConnectivityManagerImpl::PostNetworkConnect()
strncmp(ifName, sWiFiIfName, sizeof(ifName)) == 0)
{
chip::Inet::IPAddress addr;
if ((it.GetAddress(addr) == CHIP_NO_ERROR) && addr.IsIPv4())
if (it.GetAddress(addr) != CHIP_NO_ERROR)
{
ChipDeviceEvent event{ .Type = DeviceEventType::kInternetConnectivityChange,
.InternetConnectivityChange = {
.IPv4 = kConnectivity_Established, .IPv6 = kConnectivity_NoChange, .ipAddress = addr } };

char ipStrBuf[chip::Inet::IPAddress::kMaxStringLength] = { 0 };
addr.ToString(ipStrBuf);

ChipLogDetail(DeviceLayer, "Got IP address on interface: %s IP: %s", ifName, ipStrBuf);
ChipLogError(DeviceLayer, "Failed to got IP address on interface: %s", ifName);
continue;
}
ChipDeviceEvent event{ .Type = DeviceEventType::kInternetConnectivityChange,
.InternetConnectivityChange = { .ipAddress = addr } };

PlatformMgr().PostEventOrDie(&event);
if (addr.IsIPv4())
{
event.InternetConnectivityChange.IPv4 = kConnectivity_Established;
event.InternetConnectivityChange.IPv6 = kConnectivity_NoChange;
}
else if (addr.IsIPv6())
{
event.InternetConnectivityChange.IPv4 = kConnectivity_NoChange;
event.InternetConnectivityChange.IPv6 = kConnectivity_Established;
}

char ipStrBuf[chip::Inet::IPAddress::kMaxStringLength] = { 0 };
addr.ToString(ipStrBuf);
ChipLogDetail(DeviceLayer, "Got IP address on interface: %s IP: %s", ifName, ipStrBuf);
PlatformMgr().PostEventOrDie(&event);
}
}

Expand Down

0 comments on commit fa94ca0

Please sign in to comment.