|
22 | 22 |
|
23 | 23 | #include <app/icd/server/ICDServerConfig.h>
|
24 | 24 | #include <crypto/RandUtils.h>
|
| 25 | +#include <inet/InetConfig.h> |
25 | 26 | #include <lib/core/CHIPConfig.h>
|
26 | 27 | #include <lib/core/CHIPSafeCasts.h>
|
27 | 28 | #include <lib/dnssd/IPAddressSorter.h>
|
@@ -527,33 +528,39 @@ CHIP_ERROR DiscoveryImplPlatform::PublishService(const char * serviceType, TextE
|
527 | 528 | const OperationalAdvertisingParameters & params)
|
528 | 529 | {
|
529 | 530 | return PublishService(serviceType, textEntries, textEntrySize, subTypes, subTypeSize, params.GetPort(), params.GetInterfaceId(),
|
530 |
| - params.GetMac(), DnssdServiceProtocol::kDnssdProtocolTcp, params.GetPeerId()); |
| 531 | + params.GetMac(), DnssdServiceProtocol::kDnssdProtocolTcp, params.GetPeerId(), params.IsIPv4Enabled()); |
531 | 532 | }
|
532 | 533 |
|
533 | 534 | CHIP_ERROR DiscoveryImplPlatform::PublishService(const char * serviceType, TextEntry * textEntries, size_t textEntrySize,
|
534 | 535 | const char ** subTypes, size_t subTypeSize,
|
535 | 536 | const CommissionAdvertisingParameters & params)
|
536 | 537 | {
|
537 | 538 | return PublishService(serviceType, textEntries, textEntrySize, subTypes, subTypeSize, params.GetPort(), params.GetInterfaceId(),
|
538 |
| - params.GetMac(), DnssdServiceProtocol::kDnssdProtocolUdp, PeerId()); |
| 539 | + params.GetMac(), DnssdServiceProtocol::kDnssdProtocolUdp, PeerId(), params.IsIPv4Enabled()); |
539 | 540 | }
|
540 | 541 |
|
541 | 542 | CHIP_ERROR DiscoveryImplPlatform::PublishService(const char * serviceType, TextEntry * textEntries, size_t textEntrySize,
|
542 | 543 | const char ** subTypes, size_t subTypeSize, uint16_t port,
|
543 | 544 | Inet::InterfaceId interfaceId, const chip::ByteSpan & mac,
|
544 |
| - DnssdServiceProtocol protocol, PeerId peerId) |
| 545 | + DnssdServiceProtocol protocol, PeerId peerId, bool ipv4Enabled) |
545 | 546 | {
|
546 | 547 | DnssdService service;
|
547 | 548 | ReturnErrorOnFailure(MakeHostName(service.mHostName, sizeof(service.mHostName), mac));
|
548 | 549 | ReturnErrorOnFailure(protocol == DnssdServiceProtocol::kDnssdProtocolTcp
|
549 | 550 | ? MakeInstanceName(service.mName, sizeof(service.mName), peerId)
|
550 | 551 | : GetCommissionableInstanceName(service.mName, sizeof(service.mName)));
|
551 | 552 | Platform::CopyString(service.mType, serviceType);
|
552 |
| -#if INET_CONFIG_ENABLE_IPV4 |
553 |
| - service.mAddressType = Inet::IPAddressType::kAny; |
554 |
| -#else |
555 |
| - service.mAddressType = Inet::IPAddressType::kIPv6; |
556 |
| -#endif |
| 553 | +#if !INET_CONFIG_ENABLE_IPV4 |
| 554 | + ipv4Enabled = false; |
| 555 | +#endif // INET_CONFIG_ENABLE_IPV4 |
| 556 | + if (ipv4Enabled) |
| 557 | + { |
| 558 | + service.mAddressType = Inet::IPAddressType::kAny; |
| 559 | + } |
| 560 | + else |
| 561 | + { |
| 562 | + service.mAddressType = Inet::IPAddressType::kIPv6; |
| 563 | + } |
557 | 564 | service.mInterface = interfaceId;
|
558 | 565 | service.mProtocol = protocol;
|
559 | 566 | service.mPort = port;
|
|
0 commit comments