Skip to content

Commit

Permalink
[api] enable DIAG_GET query function into commissioner
Browse files Browse the repository at this point in the history
This PR adds DIAG_GET query command into the commissioner module,
allowing users to query one or more diagnostic TLVs from a peer Thread
device by setting the device's mesh local address than TLV mask bits
flag.

Test:

config set pskc 445f2b5ca6f2a93a55ce570a70efeecb
[done]
start 192.168.9.2 49154
[done]
diag query ipaddr fdce:bb1d:37f6:6978:0:ff:fe00:cc00
Peer Address: fd74:95e3:6ec:feee:0:ff:fe00:ac00
Content: {
    "Ipv6 Addresses": [
        "fd74:95e3:06ec:feee:0000:00ff:fe00:fc36",
        "fd74:95e3:06ec:feee:0000:00ff:fe00:fc11",
        "fd74:95e3:06ec:feee:0000:00ff:fe00:fc10",
        "fd74:95e3:06ec:feee:0000:00ff:fe00:fc38",
        "fd11:0022:0000:0000:99e7:cece:d50d:ae6b",
        "fd74:95e3:06ec:feee:0000:00ff:fe00:fc00",
        "fd74:95e3:06ec:feee:0000:00ff:fe00:ac00",
        "fd74:95e3:06ec:feee:6142:033d:b087:2845",
        "fe80:0000:0000:0000:9cbb:e247:df46:9e70"
    ]
}
[done]
  • Loading branch information
ZhangLe2016 committed Sep 30, 2024
1 parent d4a9b90 commit bc837bb
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 64 deletions.
2 changes: 1 addition & 1 deletion include/commissioner/commissioner.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
#include <commissioner/defines.hpp>
#include <commissioner/error.hpp>
#include <commissioner/network_data.hpp>
#include <commissioner/network_diagnostic_tlvs.hpp>
#include <commissioner/network_diag_data.hpp>

namespace ot {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,43 +47,6 @@ namespace ot {

namespace commissioner {

/**
* @brief Enum representing the types of Network Diagnostic TLVs.
*/
enum class NetworkDiagTlvType : uint8_t
{
kNetworkDiagExtMacAddress = 0, ///< Extended MAC Address TLV
kNetworkDiagMacAddress = 1, ///< MAC Address TLV
kNetworkDiagMode = 2, ///< Mode TLV
kNetworkDiagTimeout = 3, ///< Timeout TLV
kNetworkDiagConnectivity = 4, ///< Connectivity TLV
kNetworkDiagRoute64 = 5, ///< Route64 TLV
kNetworkDiagLeaderData = 6, ///< Leader Data TLV
kNetworkDiagNetworkData = 7, ///< Network Data TLV
kNetworkDiagIpv6Address = 8, ///< IPv6 Address TLV
kNetworkDiagMacCounters = 9, ///< MAC Counters TLV
kNetworkDiagBatteryLevel = 14, ///< Battery Level TLV
kNetworkDiagSupplyVoltage = 15, ///< Supply Voltage TLV
kNetworkDiagChildTable = 16, ///< Child Table TLV
kNetworkDiagChannelPages = 17, ///< Channel Pages TLV
kNetworkDiagTypeList = 18, ///< Type List TLV
kNetworkDiagMaxChildTimeout = 19, ///< Max Child Timeout TLV
kNetworkDiagLDevIDSubjectPubKeyInfo = 20, ///< LDevID Subject Public Key Info TLV
kNetworkDiagIDevIDCert = 21, ///< IDevID Certificate TLV
kNetworkDiagEui64 = 23, ///< EUI-64 TLV
kNetworkDiagVersion = 24, ///< Version TLV
kNetworkDiagVendorName = 25, ///< Vendor Name TLV
kNetworkDiagVendorModel = 26, ///< Vendor Model TLV
kNetworkDiagVendorSWVersion = 27, ///< Vendor Software Version TLV
kNetworkDiagThreadStackVersion = 28, ///< Thread Stack Version TLV
kNetworkDiagChild = 29, ///< Child TLV
kNetworkDiagChildIpv6Address = 30, ///< Child IPv6 Address TLV
kNetworkDiagRouterNeighbor = 31, ///< Router Neighbor TLV
kNetworkDiagAnswer = 32, ///< Answer TLV
kNetworkDiagQueryID = 33, ///< Query ID TLV
kNetworkDiagMleCounters = 34 ///< MLE Counters TLV
};

/**
* @brief Mode TLV
*/
Expand Down Expand Up @@ -358,24 +321,17 @@ struct NetDiagTlvs
*/
uint64_t mPresentFlags;

static constexpr uint64_t kExtMacAddressBit =
(1ull << static_cast<uint8_t>(NetworkDiagTlvType::kNetworkDiagExtMacAddress));
static constexpr uint64_t kMacAddressBit =
(1ull << static_cast<uint8_t>(NetworkDiagTlvType::kNetworkDiagMacAddress));
static constexpr uint64_t kModeBit = (1ull << static_cast<uint8_t>(NetworkDiagTlvType::kNetworkDiagMode));
static constexpr uint64_t kRoute64Bit = (1ull << static_cast<uint8_t>(NetworkDiagTlvType::kNetworkDiagRoute64));
static constexpr uint64_t kLeaderDataBit =
(1ull << static_cast<uint8_t>(NetworkDiagTlvType::kNetworkDiagLeaderData));
static constexpr uint64_t kIpv6AddressBit =
(1ull << static_cast<uint8_t>(NetworkDiagTlvType::kNetworkDiagIpv6Address));
static constexpr uint64_t kChildTableBit =
(1ull << static_cast<uint8_t>(NetworkDiagTlvType::kNetworkDiagChildTable));
static constexpr uint64_t kEui64Bit = (1ull << static_cast<uint8_t>(NetworkDiagTlvType::kNetworkDiagEui64));
static constexpr uint64_t kTlvTypeBit = (1ull << static_cast<uint8_t>(NetworkDiagTlvType::kNetworkDiagTypeList));
static constexpr uint64_t kMacCountersBit =
(1ull << static_cast<uint8_t>(NetworkDiagTlvType::kNetworkDiagMacCounters));
static constexpr uint64_t kChildIpv6AddressBit =
(1ull << static_cast<uint8_t>(NetworkDiagTlvType::kNetworkDiagChildIpv6Address));
static constexpr uint64_t kExtMacAddressBit = (1ull << 63);
static constexpr uint64_t kMacAddressBit = (1ull << 62);
static constexpr uint64_t kModeBit = (1ull << 61);
static constexpr uint64_t kRoute64Bit = (1ull << 60);
static constexpr uint64_t kLeaderDataBit = (1ull << 59);
static constexpr uint64_t kIpv6AddressBit = (1ull << 58);
static constexpr uint64_t kChildTableBit = (1ull << 57);
static constexpr uint64_t kEui64Bit = (1ull << 56);
static constexpr uint64_t kTlvTypeBit = (1ull << 55);
static constexpr uint64_t kMacCountersBit = (1ull << 54);
static constexpr uint64_t kChildIpv6AddressBit = (1ull << 53);
};

} // namespace commissioner
Expand Down
2 changes: 1 addition & 1 deletion src/app/commissioner_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include "commissioner/defines.hpp"
#include "commissioner/error.hpp"
#include "commissioner/network_data.hpp"
#include "commissioner/network_diagnostic_tlvs.hpp"
#include "commissioner/network_diag_data.hpp"
#include "common/address.hpp"
#include "common/error_macros.hpp"
#include "common/utils.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/app/commissioner_app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#include "commissioner/defines.hpp"
#include "commissioner/error.hpp"
#include "commissioner/network_data.hpp"
#include "commissioner/network_diagnostic_tlvs.hpp"
#include "commissioner/network_diag_data.hpp"
#include "common/address.hpp"

namespace ot {
Expand Down
2 changes: 1 addition & 1 deletion src/app/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include <commissioner/commissioner.hpp>
#include <commissioner/error.hpp>
#include <commissioner/network_data.hpp>
#include <commissioner/network_diagnostic_tlvs.hpp>
#include <commissioner/network_diag_data.hpp>

#include "app/border_agent.hpp"
#include "app/commissioner_app.hpp"
Expand Down
3 changes: 2 additions & 1 deletion src/java/commissioner.i
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include <commissioner/defines.hpp>
#include <commissioner/error.hpp>
#include <commissioner/network_data.hpp>
#include <commissioner/network_diagnostic_tlvs.hpp>
#include <commissioner/network_diag_data.hpp>
#include <commissioner/commissioner.hpp>
%}

Expand Down Expand Up @@ -190,5 +190,6 @@ namespace commissioner {
%include <commissioner/defines.hpp>
%include <commissioner/error.hpp>
%include <commissioner/network_data.hpp>
%include <commissioner/network_diag_data.hpp>
%include <commissioner/commissioner.hpp>
%include <commissioner/commissioner.hpp>
2 changes: 1 addition & 1 deletion src/library/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ add_library(commissioner
mbedtls_error.hpp
message.hpp
network_data.cpp
network_diagnostic_tlvs.cpp
network_diag_data.cpp
openthread/bloom_filter.cpp
openthread/bloom_filter.hpp
openthread/crc16.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/library/commissioner_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
#include "commissioner/defines.hpp"
#include "commissioner/error.hpp"
#include "commissioner/network_data.hpp"
#include "commissioner/network_diagnostic_tlvs.hpp"
#include "commissioner/network_diag_data.hpp"
#include "common/address.hpp"
#include "common/error_macros.hpp"
#include "common/logging.hpp"
Expand Down
2 changes: 1 addition & 1 deletion src/library/commissioner_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include "commissioner/defines.hpp"
#include "commissioner/error.hpp"
#include "commissioner/network_data.hpp"
#include "commissioner/network_diagnostic_tlvs.hpp"
#include "commissioner/network_diag_data.hpp"
#include "common/error_macros.hpp"
#include "common/time.hpp"
#include "event2/event.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#include "commissioner/network_diagnostic_tlvs.hpp"
#include "commissioner/network_diag_data.hpp"
#include <cstddef>
#include <cstdint>
#include <string>
Expand Down

0 comments on commit bc837bb

Please sign in to comment.