Direct-BT  2.3.1
Direct-BT - Direct Bluetooth Programming.
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
direct_bt::SMPPDUMsg Class Reference

Handles the Security Manager Protocol (SMP) using Protocol Data Unit (PDU) encoded messages over L2CAP channel. More...

#include <SMPTypes.hpp>

Inheritance diagram for direct_bt::SMPPDUMsg:
Collaboration diagram for direct_bt::SMPPDUMsg:

Public Types

enum  Opcode : uint8_t {
  Opcode::UNDEFINED = 0x00, Opcode::PAIRING_REQUEST = 0x01, Opcode::PAIRING_RESPONSE = 0x02, Opcode::PAIRING_CONFIRM = 0x03,
  Opcode::PAIRING_RANDOM = 0x04, Opcode::PAIRING_FAILED = 0x05, Opcode::ENCRYPTION_INFORMATION = 0x06, Opcode::MASTER_IDENTIFICATION = 0x07,
  Opcode::IDENTITY_INFORMATION = 0x08, Opcode::IDENTITY_ADDRESS_INFORMATION = 0x09, Opcode::SIGNING_INFORMATION = 0x0A, Opcode::SECURITY_REQUEST = 0x0B,
  Opcode::PAIRING_PUBLIC_KEY = 0x0C, Opcode::PAIRING_DHKEY_CHECK = 0x0D, Opcode::PAIRING_KEYPRESS_NOTIFICATION = 0x0E
}
 SMP Command Codes Vol 3, Part H (SM): 3.3. More...
 

Public Member Functions

 SMPPDUMsg (const uint8_t *source, const jau::nsize_t size)
 Persistent memory, w/ ownership . More...
 
 SMPPDUMsg (const Opcode opc, const jau::nsize_t size)
 Persistent memory, w/ ownership . More...
 
virtual ~SMPPDUMsg () noexcept
 
constexpr uint64_t getTimestamp () const noexcept
 
constexpr Opcode getOpcode () const noexcept
 SMP Command Codes Vol 3, Part H (SM): 3.3. More...
 
constexpr jau::nsize_t getPDUParamSize () const noexcept
 Returns the actual PDU size less one octet for the opcode, which should result in 0-22 octets or 64 octets. More...
 
virtual constexpr_cxx20 jau::nsize_t getDataSize () const noexcept
 Returns the required data size according to the specified packet, which should be within 0-22 or 64 octets. More...
 
constexpr jau::nsize_t getDataOffset () const noexcept
 Returns the octet offset to the data segment in this PDU including the mandatory opcode, i.e. More...
 
virtual constexpr_cxx20 std::string getName () const noexcept
 
virtual std::string toString () const noexcept
 

Static Public Member Functions

static constexpr uint8_t number (const Opcode rhs) noexcept
 
static std::string getOpcodeString (const Opcode opc) noexcept
 
static std::unique_ptr< const SMPPDUMsggetSpecialized (const uint8_t *buffer, jau::nsize_t const buffer_size) noexcept
 Return a newly created specialized instance pointer to base class. More...
 
template<class T >
static T * clone (const T &source) noexcept
 Clone template for convenience, based on derived class's copy-constructor. More...
 

Protected Member Functions

void checkOpcode (const Opcode expected) const
 
void checkOpcode (const Opcode exp1, const Opcode exp2) const
 
virtual std::string baseString () const noexcept
 
virtual std::string valueString () const noexcept
 

Protected Attributes

POctets pdu
 actual received PDU More...
 
uint64_t ts_creation
 creation timestamp in milliseconds More...
 

Friends

class SMPHandler
 

Detailed Description

Handles the Security Manager Protocol (SMP) using Protocol Data Unit (PDU) encoded messages over L2CAP channel.

Vol 3 (Host), Part H (SM): 3 (SMP), 3.3 Command Format

Message format between both devices, negotiating security details.

Vol 3 (Host), Part H Security Manager Specification (SM): 1.2.1 Bit and byte ordering conventions
Little-Endian: Multiple-octet fields shall be transmitted with the least significant octet first.

See also
SMPAuthReqs

Definition at line 643 of file SMPTypes.hpp.

Member Enumeration Documentation

◆ Opcode

enum direct_bt::SMPPDUMsg::Opcode : uint8_t
strong

SMP Command Codes Vol 3, Part H (SM): 3.3.

Enumerator
UNDEFINED 
PAIRING_REQUEST 
PAIRING_RESPONSE 
PAIRING_CONFIRM 
PAIRING_RANDOM 
PAIRING_FAILED 
ENCRYPTION_INFORMATION 
MASTER_IDENTIFICATION 
IDENTITY_INFORMATION 
IDENTITY_ADDRESS_INFORMATION 
SIGNING_INFORMATION 
SECURITY_REQUEST 
PAIRING_PUBLIC_KEY 
PAIRING_DHKEY_CHECK 
PAIRING_KEYPRESS_NOTIFICATION 

Definition at line 647 of file SMPTypes.hpp.

Constructor & Destructor Documentation

◆ SMPPDUMsg() [1/2]

direct_bt::SMPPDUMsg::SMPPDUMsg ( const uint8_t *  source,
const jau::nsize_t  size 
)
inline

Persistent memory, w/ ownership .

Definition at line 718 of file SMPTypes.hpp.

Here is the call graph for this function:

◆ SMPPDUMsg() [2/2]

direct_bt::SMPPDUMsg::SMPPDUMsg ( const Opcode  opc,
const jau::nsize_t  size 
)
inline

Persistent memory, w/ ownership .

Definition at line 725 of file SMPTypes.hpp.

Here is the call graph for this function:

◆ ~SMPPDUMsg()

virtual direct_bt::SMPPDUMsg::~SMPPDUMsg ( )
inlinevirtualnoexcept

Definition at line 732 of file SMPTypes.hpp.

Member Function Documentation

◆ baseString()

virtual std::string direct_bt::SMPPDUMsg::baseString ( ) const
inlineprotectedvirtualnoexcept

Definition at line 693 of file SMPTypes.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkOpcode() [1/2]

void direct_bt::SMPPDUMsg::checkOpcode ( const Opcode  exp1,
const Opcode  exp2 
) const
inlineprotected

Definition at line 683 of file SMPTypes.hpp.

Here is the call graph for this function:

◆ checkOpcode() [2/2]

void direct_bt::SMPPDUMsg::checkOpcode ( const Opcode  expected) const
inlineprotected

Definition at line 675 of file SMPTypes.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ clone()

template<class T >
static T* direct_bt::SMPPDUMsg::clone ( const T &  source)
inlinestaticnoexcept

Clone template for convenience, based on derived class's copy-constructor.

const SMPPDUMsg & smpPDU;
const SMPSignInfoMsg * signInfo = static_cast<const SMPSignInfoMsg *>(&smpPDU);
SMPPDUMsg* b1 = SMPPDUMsg::clone(*signInfo);
SMPSignInfoMsg* b2 = SMPPDUMsg::clone(*signInfo);
Template Parameters
TThe derived definite class type, deducible by source argument
Parameters
sourcethe source to be copied
Returns
a new instance.

Definition at line 747 of file SMPTypes.hpp.

◆ getDataOffset()

constexpr jau::nsize_t direct_bt::SMPPDUMsg::getDataOffset ( ) const
inlineconstexprnoexcept

Returns the octet offset to the data segment in this PDU including the mandatory opcode, i.e.

the number of octets until the first value octet.

Definition at line 789 of file SMPTypes.hpp.

Here is the caller graph for this function:

◆ getDataSize()

virtual constexpr_cxx20 jau::nsize_t direct_bt::SMPPDUMsg::getDataSize ( ) const
inlinevirtualnoexcept

Returns the required data size according to the specified packet, which should be within 0-22 or 64 octets.

See also
SMPPDUMsg::getPDUParamSize()

Reimplemented in direct_bt::SMPSecurityReqMsg, direct_bt::SMPSignInfoMsg, direct_bt::SMPIdentAddrInfoMsg, direct_bt::SMPIdentInfoMsg, direct_bt::SMPMasterIdentMsg, direct_bt::SMPEncInfoMsg, direct_bt::SMPPasskeyNotification, direct_bt::SMPPairDHKeyCheckMsg, direct_bt::SMPPairPubKeyMsg, direct_bt::SMPPairFailedMsg, direct_bt::SMPPairRandMsg, direct_bt::SMPPairConfirmMsg, and direct_bt::SMPPairingMsg.

Definition at line 779 of file SMPTypes.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getName()

virtual constexpr_cxx20 std::string direct_bt::SMPPDUMsg::getName ( ) const
inlinevirtualnoexcept

◆ getOpcode()

constexpr Opcode direct_bt::SMPPDUMsg::getOpcode ( ) const
inlineconstexprnoexcept

SMP Command Codes Vol 3, Part H (SM): 3.3.

Definition at line 752 of file SMPTypes.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getOpcodeString()

std::string SMPPDUMsg::getOpcodeString ( const Opcode  opc)
staticnoexcept

Definition at line 376 of file SMPTypes.cpp.

Here is the caller graph for this function:

◆ getPDUParamSize()

constexpr jau::nsize_t direct_bt::SMPPDUMsg::getPDUParamSize ( ) const
inlineconstexprnoexcept

Returns the actual PDU size less one octet for the opcode, which should result in 0-22 octets or 64 octets.

Note that the PDU parameter include the data value below.

Use getDataSize() for the actual required data size according to the specific packet.

See also
SMPPDUMsg::getDataSize()

Definition at line 769 of file SMPTypes.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getSpecialized()

std::unique_ptr< const SMPPDUMsg > SMPPDUMsg::getSpecialized ( const uint8_t *  buffer,
jau::nsize_t const  buffer_size 
)
staticnoexcept

Return a newly created specialized instance pointer to base class.

Returned memory reference is managed by caller (delete etc)

Definition at line 423 of file SMPTypes.cpp.

◆ getTimestamp()

constexpr uint64_t direct_bt::SMPPDUMsg::getTimestamp ( ) const
inlineconstexprnoexcept

Definition at line 749 of file SMPTypes.hpp.

◆ number()

static constexpr uint8_t direct_bt::SMPPDUMsg::number ( const Opcode  rhs)
inlinestaticconstexprnoexcept

Definition at line 667 of file SMPTypes.hpp.

Here is the caller graph for this function:

◆ toString()

virtual std::string direct_bt::SMPPDUMsg::toString ( ) const
inlinevirtualnoexcept

Definition at line 795 of file SMPTypes.hpp.

Here is the call graph for this function:

◆ valueString()

virtual std::string direct_bt::SMPPDUMsg::valueString ( ) const
inlineprotectedvirtualnoexcept

Reimplemented in direct_bt::SMPSecurityReqMsg, direct_bt::SMPSignInfoMsg, direct_bt::SMPIdentAddrInfoMsg, direct_bt::SMPIdentInfoMsg, direct_bt::SMPMasterIdentMsg, direct_bt::SMPEncInfoMsg, direct_bt::SMPPasskeyNotification, direct_bt::SMPPairDHKeyCheckMsg, direct_bt::SMPPairPubKeyMsg, direct_bt::SMPPairFailedMsg, direct_bt::SMPPairRandMsg, direct_bt::SMPPairConfirmMsg, and direct_bt::SMPPairingMsg.

Definition at line 697 of file SMPTypes.hpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Friends And Related Function Documentation

◆ SMPHandler

friend class SMPHandler
friend

Definition at line 673 of file SMPTypes.hpp.

Member Data Documentation

◆ pdu

POctets direct_bt::SMPPDUMsg::pdu
protected

actual received PDU

Definition at line 703 of file SMPTypes.hpp.

◆ ts_creation

uint64_t direct_bt::SMPPDUMsg::ts_creation
protected

creation timestamp in milliseconds

Definition at line 706 of file SMPTypes.hpp.


The documentation for this class was generated from the following files: