@@ -216,12 +216,17 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
216
216
}
217
217
218
218
// Init transport before operations with secure session mgr.
219
+ //
220
+ // The logic below expects that the IPv6 transport is at index 0. Keep that logic in sync with
221
+ // this code.
219
222
err = mTransports .Init (UdpListenParameters (DeviceLayer::UDPEndPointManager ())
220
223
.SetAddressType (IPAddressType::kIPv6 )
221
224
.SetListenPort (mOperationalServicePort )
222
225
.SetNativeParams (initParams.endpointNativeParams )
223
226
#if INET_CONFIG_ENABLE_IPV4
224
227
,
228
+ // The logic below expects that the IPv4 transport, if enabled, is at
229
+ // index 1. Keep that logic in sync with this code.
225
230
UdpListenParameters (DeviceLayer::UDPEndPointManager ())
226
231
.SetAddressType (IPAddressType::kIPv4 )
227
232
.SetListenPort (mOperationalServicePort )
@@ -318,13 +323,10 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
318
323
SuccessOrExit (err);
319
324
#endif
320
325
321
- //
322
- // We need to advertise the port that we're listening to for unsolicited messages over UDP. However, we have both a IPv4
323
- // and IPv6 endpoint to pick from. Given that the listen port passed in may be set to 0 (which then has the kernel select
324
- // a valid port at bind time), that will result in two possible ports being provided back from the resultant endpoint
325
- // initializations. Since IPv6 is POR for Matter, let's go ahead and pick that port.
326
- //
327
- app::DnssdServer::Instance ().SetSecuredPort (mTransports .GetTransport ().GetImplAtIndex <0 >().GetBoundPort ());
326
+ app::DnssdServer::Instance ().SetSecuredIPv6Port (mTransports .GetTransport ().GetImplAtIndex <0 >().GetBoundPort ());
327
+ #if INET_CONFIG_ENABLE_IPV4
328
+ app::DnssdServer::Instance ().SetSecuredIPv4Port (mTransports .GetTransport ().GetImplAtIndex <1 >().GetBoundPort ());
329
+ #endif // INET_CONFIG_ENABLE_IPV4
328
330
329
331
app::DnssdServer::Instance ().SetUnsecuredPort (mUserDirectedCommissioningPort );
330
332
app::DnssdServer::Instance ().SetInterfaceId (mInterfaceId );
@@ -428,9 +430,9 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)
428
430
//
429
431
// Thread LWIP devices using dedicated Inet endpoint implementations are excluded because they call this function from:
430
432
// src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread_LwIP.cpp
431
- #if !CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
433
+ #if !CHIP_SYSTEM_CONFIG_USE_OPENTHREAD_ENDPOINT
432
434
RejoinExistingMulticastGroups ();
433
- #endif // !CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
435
+ #endif // !CHIP_SYSTEM_CONFIG_USE_OPENTHREAD_ENDPOINT
434
436
435
437
// Handle deferred clean-up of a previously armed fail-safe that occurred during FabricTable commit.
436
438
// This is done at the very end since at the earlier time above when FabricTable::Init() is called,
@@ -532,7 +534,7 @@ void Server::OnPlatformEvent(const DeviceLayer::ChipDeviceEvent & event)
532
534
ResumeSubscriptions ();
533
535
#endif // CHIP_CONFIG_PERSIST_SUBSCRIPTIONS
534
536
break ;
535
- #if CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
537
+ #if CHIP_SYSTEM_CONFIG_USE_OPENTHREAD_ENDPOINT
536
538
case DeviceEventType::kThreadConnectivityChange :
537
539
if (event.ThreadConnectivityChange .Result == kConnectivity_Established )
538
540
{
@@ -541,7 +543,7 @@ void Server::OnPlatformEvent(const DeviceLayer::ChipDeviceEvent & event)
541
543
RejoinExistingMulticastGroups ();
542
544
}
543
545
break ;
544
- #endif // CHIP_SYSTEM_CONFIG_USE_OPEN_THREAD_ENDPOINT
546
+ #endif // CHIP_SYSTEM_CONFIG_USE_OPENTHREAD_ENDPOINT
545
547
default :
546
548
break ;
547
549
}
@@ -618,8 +620,7 @@ void Server::GenerateShutDownEvent()
618
620
619
621
void Server::PostFactoryResetEvent ()
620
622
{
621
- DeviceLayer::ChipDeviceEvent event;
622
- event.Type = DeviceLayer::DeviceEventType::kFactoryReset ;
623
+ DeviceLayer::ChipDeviceEvent event{ .Type = DeviceLayer::DeviceEventType::kFactoryReset };
623
624
624
625
CHIP_ERROR error = DeviceLayer::PlatformMgr ().PostEvent (&event);
625
626
if (error != CHIP_NO_ERROR)
0 commit comments