Skip to content

Commit

Permalink
OpenThread PR comment resolution (August 14).
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnulf Rupp committed Aug 14, 2023
1 parent 65367a0 commit bf495e9
Show file tree
Hide file tree
Showing 12 changed files with 198 additions and 163 deletions.
2 changes: 1 addition & 1 deletion etc/gn/openthread.gni
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ if (openthread_enable_core_config_args) {
openthread_config_backbone_router_enable = false

# Enable BLE based commissioning functionality
OPENTHREAD_CONFIG_BLE_TCAT_ENABLE = false
openthread_config_ble_tcat_enable = false

# Enable border agent support
openthread_config_border_agent_enable = false
Expand Down
8 changes: 1 addition & 7 deletions include/openthread/ble_secure.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,6 @@ typedef void (*otHandleBleSecureConnect)(otInstance *aInstance,
/**
* Pointer to call when data was received over a BLE Secure TLS connection.
*
*
* @param[in] aMessage A pointer to the message.
* @param[in] aTcatMessageType The message type received.
* @param[in] aServiceName The name of the service the message is direced to.
* @param[in] aContext A pointer to arbitrary context information.
*
*/
typedef otHandleTcatApplicationDataReceive otHandleBleSecureReceive;

Expand Down Expand Up @@ -120,7 +114,7 @@ otError otBleSecureStart(otInstance *aInstance,
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aVendorInfo A pointer to the Vendor Information (must remain valid after the method call, may be
* NULL).
* NULL).
* @param[in] aHandler A pointer to a function that is called when the join operation completes.
*
* @retval OT_ERROR_NONE Successfully started the BLE Secure Joiner role.
Expand Down
2 changes: 1 addition & 1 deletion include/openthread/instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ extern "C" {
* @note This number versions both OpenThread platform and user APIs.
*
*/
#define OPENTHREAD_API_VERSION (347)
#define OPENTHREAD_API_VERSION (350)

/**
* @addtogroup api-instance
Expand Down
22 changes: 9 additions & 13 deletions include/openthread/platform/ble.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,15 @@ otError otPlatBleGapDisconnect(otInstance *aInstance);
*/
otError otPlatBleGattMtuGet(otInstance *aInstance, uint16_t *aMtu);

/**
* The BLE driver calls this method to notify OpenThread that ATT_MTU has been updated.
*
* @param[in] aInstance The OpenThread instance structure.
* @param[in] aMtu The updated ATT_MTU value.
*
*/
extern void otPlatBleGattOnMtuUpdate(otInstance *aInstance, uint16_t aMtu);

/*******************************************************************************
* @section Bluetooth Low Energy GATT Server.
******************************************************************************/
Expand Down Expand Up @@ -258,19 +267,6 @@ otError otPlatBleGattServerIndicate(otInstance *aInstance, uint16_t aHandle, con
*/
extern void otPlatBleGattServerOnWriteRequest(otInstance *aInstance, uint16_t aHandle, const otBleRadioPacket *aPacket);

/**
* The BLE driver calls this method to notify OpenThread that an ATT Read Request
* packet has been received.
*
* @note This function shall be used only for GATT Server.
*
* @param[in] aInstance The OpenThread instance structure.
* @param[in] aHandle The handle of the attribute to be read.
* @param[out] aPacket A pointer to the packet to be filled with pointers to attribute data to be read.
*
*/
extern void otPlatBleGattServerOnReadRequest(otInstance *aInstance, uint16_t aHandle, const otBleRadioPacket *aPacket);

/**
* @}
*
Expand Down
54 changes: 0 additions & 54 deletions include/openthread/tcat.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,60 +114,6 @@ typedef enum otTcatCommandClass

} otTcatCommandClass;

/**
* The certificate authorization field header type to indicate the type and version of the certificate.
*
*/
typedef uint8_t otTcatCertificateAuthorizationFieldHeader;

enum
{
OT_TCAT_CERTIFICATE_AUTHORIZATION_FIELD_HEADER_C_FLAG = 1 << 0, ///< TCAT commissioner ('1') or device ('0')
OT_TCAT_CERTIFICATE_AUTHORIZATION_FIELD_HEADER_VERSION = 0xD0, ///< Header version (3 bits)
};

/**
* The command class flag type to indicate which requirements apply for a given command class.
*
* This is a combination of bit-flags. The specific bit-flags are defined in the enumeration
* `OT_TCAT_COMMAND_CLASS_FLAG_*`.
*
*/
typedef uint8_t otTcatCommandClassFlags;

enum
{
OT_TCAT_COMMAND_CLASS_FLAG_ACCESS = 1 << 0, ///< Access to the command class (device: without without additional requirements).
OT_TCAT_COMMAND_CLASS_FLAG_PSKD = 1 << 1, ///< Access requires proof-of-possession of the device's PSKd
OT_TCAT_COMMAND_CLASS_FLAG_NETWORK_NAME = 1 << 2, ///< Access requires matching network name
OT_TCAT_COMMAND_CLASS_FLAG_XPANID = 1 << 3, ///< Access requires matching XPANID
OT_TCAT_COMMAND_CLASS_FLAG_THREAD_DOMAIN = 1 << 4, ///< Access requires matching XPANID
OT_TCAT_COMMAND_CLASS_FLAG_PSKC = 1 << 5, ///< Access requires proof-of-possession of the device's PSKc
};

/**
* @struct otTcatCertificateAuthorizationField
*
* Represents a data structure for storing TCAT Commissioner authorization information is the field 1.3.6.1.4.1.44970.3.
*
*/
OT_TOOL_PACKED_BEGIN
struct otTcatCertificateAuthorizationField
{
otTcatCertificateAuthorizationFieldHeader mHeader; ///< Typ and version
otTcatCommandClassFlags mCommissioningFlags; ///< Command class flags
otTcatCommandClassFlags mExtractionFlags; ///< Command class flags
otTcatCommandClassFlags mDecommissioningFlags; ///< Command class flags
otTcatCommandClassFlags mApplicationFlags; ///< Command class flags

} OT_TOOL_PACKED_END;

/**
* Represents a data structure for storing TCAT Commissioner authorization information is the field 1.3.6.1.4.1.44970.3.
*
*/
typedef struct otTcatCertificateAuthorizationField otTcatCertificateAuthorizationField;

/**
* This structure represents a TCAT vendor information.
*
Expand Down
9 changes: 5 additions & 4 deletions src/cli/cli_tcat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,10 @@ static void HandleBleSecureReceive(otInstance *aInstance,
OT_UNUSED_VARIABLE(aContext);
OT_UNUSED_VARIABLE(aTcatMessageType);
OT_UNUSED_VARIABLE(aServiceName);
static constexpr int kTextMaxLen = 100;
static constexpr uint8_t kBufPrefixLen = 5;
uint16_t nLen;
uint8_t buf[100];
uint8_t buf[kTextMaxLen];

nLen = otMessageRead(aMessage, otMessageGetOffset(aMessage), buf + kBufPrefixLen, sizeof(buf) - kBufPrefixLen - 1);

Expand All @@ -115,11 +116,11 @@ template <> otError Tcat::Process<Cmd("start")>(Arg aArgs[])
sVendorInfo.mPskdString = kPskdVendor;
sVendorInfo.mProvisioningUrl = kUrl;

otBleSecureSetCertificate(GetInstancePtr(), (const uint8_t *)(OT_CLI_BBTC_X509_CERT),
sizeof(OT_CLI_BBTC_X509_CERT), (const uint8_t *)(OT_CLI_BBTC_PRIV_KEY),
otBleSecureSetCertificate(GetInstancePtr(), reinterpret_cast<const uint8_t *>(OT_CLI_BBTC_X509_CERT),
sizeof(OT_CLI_BBTC_X509_CERT), reinterpret_cast<const uint8_t *>(OT_CLI_BBTC_PRIV_KEY),
sizeof(OT_CLI_BBTC_PRIV_KEY));

otBleSecureSetCaCertificateChain(GetInstancePtr(), (const uint8_t *)(OT_CLI_BBTC_TRUSTED_ROOT_CERTIFICATE),
otBleSecureSetCaCertificateChain(GetInstancePtr(), reinterpret_cast<const uint8_t *>(OT_CLI_BBTC_TRUSTED_ROOT_CERTIFICATE),
sizeof(OT_CLI_BBTC_TRUSTED_ROOT_CERTIFICATE));

otBleSecureSetSslAuthMode(GetInstancePtr(), true);
Expand Down
2 changes: 1 addition & 1 deletion src/core/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ if (openthread_enable_core_config_args) {
defines += [ "OPENTHREAD_CONFIG_BACKBONE_ROUTER_ENABLE=1" ]
}

if (OPENTHREAD_CONFIG_BLE_TCAT_ENABLE) {
if (openthread_config_ble_tcat_enable) {
defines += [ "OPENTHREAD_CONFIG_BLE_TCAT_ENABLE=1" ]
}

Expand Down
5 changes: 3 additions & 2 deletions src/core/api/ble_secure_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,13 @@ bool otBleSecureIsPskcVerified(otInstance *aInstance)

bool otBleSecureIsCommandClassAuthorized(otInstance *aInstance, otTcatCommandClass aCommandClass)
{
return AsCoreType(aInstance).Get<Ble::BleSecure>().IsCommandClassAuthorized(aCommandClass);
return AsCoreType(aInstance).Get<Ble::BleSecure>().IsCommandClassAuthorized(
static_cast<Ble::BleSecure::CommandClass>(aCommandClass));
}

otError otBleSecureSendMessage(otInstance *aInstance, otMessage *aMessage)
{
return AsCoreType(aInstance).Get<Ble::BleSecure>().SendMessage(static_cast<Message *>(aMessage));
return AsCoreType(aInstance).Get<Ble::BleSecure>().SendMessage(AsCoreType(aMessage));
}

otError otBleSecureSend(otInstance *aInstance, uint8_t *aBuf, uint16_t aLength)
Expand Down
Loading

0 comments on commit bf495e9

Please sign in to comment.