Skip to content

Commit

Permalink
update proto for DHCPv6 PD Telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
sherysheng committed Dec 5, 2023
1 parent 4f78e4d commit 27c51a3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 35 deletions.
28 changes: 15 additions & 13 deletions src/proto/thread_telemetry.proto
Original file line number Diff line number Diff line change
Expand Up @@ -219,34 +219,36 @@ message TelemetryData {
// The counters for inbound multicast packets
optional PacketsAndBytes inbound_multicast = 16;

// The counter for inbound Internet when DHCPv6 PD enabled
optional PacketsAndBytes inbound_internet = 17;

// The counters for outbound unicast packets
optional PacketsAndBytes outbound_unicast = 18;
optional PacketsAndBytes outbound_unicast = 17;

// The counters for outbound multicast packets
optional PacketsAndBytes outbound_multicast = 19;

// The counter for outbound Internet when DHCPv6 PD enabled
optional PacketsAndBytes outbound_internet = 20;
optional PacketsAndBytes outbound_multicast = 18;

// The inbound and outbound NAT64 traffic through the border router
optional Nat64ProtocolCounters nat64_protocol_counters = 21;
optional Nat64ProtocolCounters nat64_protocol_counters = 19;

// Error counters for NAT64 translator on the border router
optional Nat64ErrorCounters nat64_error_counters = 22;
optional Nat64ErrorCounters nat64_error_counters = 20;

// The counter for inbound Internet when DHCPv6 PD enabled
optional PacketsAndBytes inbound_internet = 21;

// The counter for outbound Internet when DHCPv6 PD enabled
optional PacketsAndBytes outbound_internet = 22;
}

enum Dhcp6PdState {
DHCP6_PD_STATE_UNSPECIFIED = 0;

// DHCPv6 PD is disabled on the border router.
DHCP6_PD_STATE_DISABLED = 0;
DHCP6_PD_STATE_DISABLED = 1;

// DHCPv6 PD in enabled but won't try to request and publish a prefix.
DHCP6_PD_STATE_STOPPED = 1;
DHCP6_PD_STATE_STOPPED = 2;

// DHCPv6 PD is enabled and will try to request and publish a prefix.
DHCP6_PD_STATE_RUNNING =2;
DHCP6_PD_STATE_RUNNING = 3;
}

message PdProcessedRaInfo {
Expand Down
49 changes: 28 additions & 21 deletions src/utils/thread_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,19 +187,23 @@ void CopyNat64TrafficCounters(const otNat64Counters &from, threadnetwork::Teleme
#if OTBR_ENABLE_DHCP6_PD
threadnetwork::TelemetryData_Dhcp6PdState Dhcp6PdStateFromOtDhcp6PdState(otBorderRoutingDhcp6PdState dhcp6PdState)
{
threadnetwork::TelemetryData_Dhcp6PdState pdState = threadnetwork::TelemetryData::DHCP6_PD_STATE_UNSPECIFIED;

switch (dhcp6PdState)
{
case OT_BORDER_ROUTING_DHCP6_PD_STATE_DISABLED:
return threadnetwork::TelemetryData::DHCP6_PD_STATE_DISABLED;
pdState = threadnetwork::TelemetryData::DHCP6_PD_STATE_DISABLED;
case OT_BORDER_ROUTING_DHCP6_PD_STATE_STOPPED:
return threadnetwork::TelemetryData::DHCP6_PD_STATE_STOPPED;
pdState = threadnetwork::TelemetryData::DHCP6_PD_STATE_STOPPED;
case OT_BORDER_ROUTING_DHCP6_PD_STATE_RUNNING:
return threadnetwork::TelemetryData::DHCP6_PD_STATE_RUNNING;
pdState = threadnetwork::TelemetryData::DHCP6_PD_STATE_RUNNING;
default:
return threadnetwork::TelemetryData::DHCP6_PD_STATE_DISABLED;
break;
}

return pdState;
}
#endif // OTBR_ENABLE_DHCP6_PD
#endif // OTBR_ENABLE_DHCP6_PD

void CopyMdnsResponseCounters(const MdnsResponseCounters &from, threadnetwork::TelemetryData_MdnsResponseCounters *to)
{
Expand Down Expand Up @@ -1162,10 +1166,6 @@ otError ThreadHelper::RetrieveTelemetryData(Mdns::Publisher *aPublisher, threadn
otBorderRoutingCounters->mInboundMulticast.mPackets);
borderRoutingCouters->mutable_inbound_multicast()->set_byte_count(
otBorderRoutingCounters->mInboundMulticast.mBytes);
borderRoutingCouters->mutable_inbound_internet()->set_packet_count(
otBorderRoutingCounters->mInboundInternet.mPackets);
borderRoutingCouters->mutable_inbound_internet()->set_byte_count(
otBorderRoutingCounters->mInboundInternet.mBytes);
borderRoutingCouters->mutable_outbound_unicast()->set_packet_count(
otBorderRoutingCounters->mOutboundUnicast.mPackets);
borderRoutingCouters->mutable_outbound_unicast()->set_byte_count(
Expand All @@ -1174,16 +1174,20 @@ otError ThreadHelper::RetrieveTelemetryData(Mdns::Publisher *aPublisher, threadn
otBorderRoutingCounters->mOutboundMulticast.mPackets);
borderRoutingCouters->mutable_outbound_multicast()->set_byte_count(
otBorderRoutingCounters->mOutboundMulticast.mBytes);
borderRoutingCouters->mutable_outbound_internet()->set_packet_count(
otBorderRoutingCounters->mOutboundInternet.mPackets);
borderRoutingCouters->mutable_outbound_internet()->set_byte_count(
otBorderRoutingCounters->mOutboundInternet.mBytes);
borderRoutingCouters->set_ra_rx(otBorderRoutingCounters->mRaRx);
borderRoutingCouters->set_ra_tx_success(otBorderRoutingCounters->mRaTxSuccess);
borderRoutingCouters->set_ra_tx_failure(otBorderRoutingCounters->mRaTxFailure);
borderRoutingCouters->set_rs_rx(otBorderRoutingCounters->mRsRx);
borderRoutingCouters->set_rs_tx_success(otBorderRoutingCounters->mRsTxSuccess);
borderRoutingCouters->set_rs_tx_failure(otBorderRoutingCounters->mRsTxFailure);
borderRoutingCouters->mutable_inbound_internet()->set_packet_count(
otBorderRoutingCounters->mInboundInternet.mPackets);
borderRoutingCouters->mutable_inbound_internet()->set_byte_count(
otBorderRoutingCounters->mInboundInternet.mBytes);
borderRoutingCouters->mutable_outbound_internet()->set_packet_count(
otBorderRoutingCounters->mOutboundInternet.mPackets);
borderRoutingCouters->mutable_outbound_internet()->set_byte_count(
otBorderRoutingCounters->mOutboundInternet.mBytes);

#if OTBR_ENABLE_NAT64
{
Expand Down Expand Up @@ -1388,30 +1392,33 @@ otError ThreadHelper::RetrieveTelemetryData(Mdns::Publisher *aPublisher, threadn
#if OTBR_ENABLE_DHCP6_PD
// Start of Dhcp6PdState section.
{
auto dhcp6PdState = wpanBorderRouter->mutable_dhcp6_pd_state();
dhcp6PdState->set_dhcp6_pd_state(Dhcp6PdStateFromOtDhcp6PdState(otBorderRoutingDhcp6PdGetState(mInstance)));
wpanBorderRouter->set_dhcp6_pd_state(
Dhcp6PdStateFromOtDhcp6PdState(otBorderRoutingDhcp6PdGetState(mInstance)));
}
// End of Dhcp6PdState section.

// Start of PD prefix
{
char buffer[OT_IP6_PREFIX_STRING_SIZE];
otBorderRoutingGetPdOmrPrefix(mInstance, &aPrefixInfo);
otIp6PrefixToString(aPrefixInfo.mPrefix, buffer, sizeof(string));
wpanBorderRouter->set_pd_prefix(buffer);
char buffer[OT_IP6_PREFIX_STRING_SIZE];
otBorderRoutingPrefixTableEntry aPrefixInfo;

otBorderRoutingGetPdOmrPrefix(mInstance, &aPrefixInfo);
otIp6PrefixToString(&aPrefixInfo.mPrefix, buffer, sizeof(buffer));
wpanBorderRouter->set_pd_prefix(buffer);
}
// End of PD prefix
// Start of DHCPv6 PD processed RA Info
{
auto pdProcessedRaInfo = wpanBorderRouter->mutable_pd_processed_ra_info();
auto pdProcessedRaInfo = wpanBorderRouter->mutable_pd_processed_ra_info();
otPdProcessedRaInfo raInfo;

otBorderRoutingGetPdProcessedRaInfo(mInstance, &raInfo);
pdProcessedRaInfo->set_num_platform_ra_received(raInfo.mNumPlatformRaReceived);
pdProcessedRaInfo->set_num_platform_pio_processed(raInfo.mNumPlatformPioProcessed);
pdProcessedRaInfo->set_last_platform_ra_msec(raInfo.mLastPlatformRaMsec);
}
// End of DHCPv6 PD processed RA Info
#endif // OTBR_ENABLE_DHCP6_PD
#endif // OTBR_ENABLE_DHCP6_PD
// End of WpanBorderRouter section.

// Start of WpanRcp section.
Expand Down
2 changes: 1 addition & 1 deletion tests/dbus/test_dbus_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ void CheckTelemetryData(ThreadApiDBus *aApi)
threadnetwork::TelemetryData::NAT64_STATE_NOT_RUNNING);
#endif
#if OTBR_ENABLE_DHCP6_PD
TEST_ASSERT(telemetryData.wpan_border_router().pd_prefix() != NULL);
TEST_ASSERT(!telemetryData.wpan_border_router().pd_prefix().empty());
#endif
TEST_ASSERT(telemetryData.wpan_rcp().rcp_interface_statistics().transferred_frames_count() > 0);
TEST_ASSERT(telemetryData.coex_metrics().count_tx_request() > 0);
Expand Down

0 comments on commit 27c51a3

Please sign in to comment.