123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408 |
- #ifndef SMP_H
- #define SMP_H
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- #include "bcomdef.h"
-
- #include "sm_internal.h"
-
- #define SMP_PAIRING_REQ 0x01
- #define SMP_PAIRING_RSP 0x02
- #define SMP_PAIRING_CONFIRM 0x03
- #define SMP_PAIRING_RANDOM 0x04
- #define SMP_PAIRING_FAILED 0x05
- #define SMP_ENCRYPTION_INFORMATION 0x06
- #define SMP_MASTER_IDENTIFICATION 0x07
- #define SMP_IDENTITY_INFORMATION 0x08
- #define SMP_IDENTITY_ADDR_INFORMATION 0x09
- #define SMP_SIGNING_INFORMATION 0x0A
- #define SMP_SECURITY_REQUEST 0x0B
- #define SMP_IO_CAP_DISPLAY_ONLY 0x00
- #define SMP_IO_CAP_DISPLAY_YES_NO 0x01
- #define SMP_IO_CAP_KEYBOARD_ONLY 0x02
- #define SMP_IO_CAP_NO_INPUT_NO_OUTPUT 0x03
- #define SMP_IO_CAP_KEYBOARD_DISPLAY 0x04
-
- #define SMP_OOB_AUTH_DATA_NOT_PRESENT 0x00
- #define SMP_OOB_AUTH_DATA_REMOTE_DEVICE_PRESENT 0x01
-
- #define SMP_AUTHREQ_BONDING 0x01
- #define SMP_AUTHREQ_MITM 0x04
-
- #define SMP_CONFIRM_LEN 16
- #define SMP_RANDOM_LEN 16
-
- #define SMP_PAIRING_FAILED_PASSKEY_ENTRY_FAILED 0x01
- #define SMP_PAIRING_FAILED_OOB_NOT_AVAIL 0x02
- #define SMP_PAIRING_FAILED_AUTH_REQ 0x03
- #define SMP_PAIRING_FAILED_CONFIRM_VALUE 0x04
- #define SMP_PAIRING_FAILED_NOT_SUPPORTED 0x05
- #define SMP_PAIRING_FAILED_ENC_KEY_SIZE 0x06
- #define SMP_PAIRING_FAILED_CMD_NOT_SUPPORTED 0x07
- #define SMP_PAIRING_FAILED_UNSPECIFIED 0x08
- #define SMP_PAIRING_FAILED_REPEATED_ATTEMPTS 0x09
-
- #define SMP_PAIRING_FAILED_LOCAL_KEY_FAILURE 0x0A
- #define SMP_PAIRING_REQ_LEN 7
- #define SMP_PAIRING_RSP_LEN 7
- #define SMP_PAIRING_CONFIRM_LEN 17
- #define SMP_PAIRING_RANDOM_LEN 17
- #define SMP_PAIRING_FAILED_LEN 2
- #define SMP_ENCRYPTION_INFORMATION_LEN 17
- #define SMP_MASTER_IDENTIFICATION_LEN 11
- #define SMP_IDENTITY_INFORMATION_LEN 17
- #define SMP_IDENTITY_ADDR_INFORMATION_LEN 8
- #define SMP_SIGNING_INFORMATION_LEN 17
- #define SMP_SECURITY_REQUEST_LEN 2
-
- #define smSendPairingReq( connHandle, msgStruct ) \
- smSendSMMsg( (connHandle), SMP_PAIRING_REQ_LEN, \
- (smpMsgs_t *)(msgStruct), \
- (pfnSMBuildCmd_t)(smpBuildPairingReq) )
- #define smSendPairingRsp( connHandle, msgStruct ) \
- smSendSMMsg( (connHandle), SMP_PAIRING_RSP_LEN, \
- (smpMsgs_t *)(msgStruct), \
- (pfnSMBuildCmd_t)(smpBuildPairingRsp) )
- #define smSendPairingConfirm( connHandle, msgStruct ) \
- smSendSMMsg( (connHandle), SMP_PAIRING_CONFIRM_LEN, \
- (smpMsgs_t *)(msgStruct), \
- (pfnSMBuildCmd_t)(smpBuildPairingConfirm) )
- #define smSendPairingRandom( connHandle, msgStruct ) \
- smSendSMMsg( (connHandle), SMP_PAIRING_RANDOM_LEN, \
- (smpMsgs_t *)(msgStruct), \
- (pfnSMBuildCmd_t)(smpBuildPairingRandom) )
- #define smSendPairingFailed( connHandle, msgStruct ) \
- smSendSMMsg( (connHandle), SMP_PAIRING_FAILED_LEN, \
- (smpMsgs_t *)(msgStruct), \
- (pfnSMBuildCmd_t)(smpBuildPairingFailed) )
- #define smSendEncInfo( connHandle, msgStruct ) \
- smSendSMMsg( (connHandle), SMP_ENCRYPTION_INFORMATION_LEN, \
- (smpMsgs_t *)(msgStruct), \
- (pfnSMBuildCmd_t)(smpBuildEncInfo) )
- #define smSendMasterID( connHandle, msgStruct ) \
- smSendSMMsg( (connHandle), SMP_MASTER_IDENTIFICATION_LEN, \
- (smpMsgs_t *)(msgStruct), \
- (pfnSMBuildCmd_t)(smpBuildMasterID) )
- #define smSendIdentityInfo( connHandle, msgStruct ) \
- smSendSMMsg( (connHandle), SMP_IDENTITY_INFORMATION_LEN, \
- (smpMsgs_t *)(msgStruct), \
- (pfnSMBuildCmd_t)(smpBuildIdentityInfo) )
- #define smSendIdentityAddrInfo( connHandle, msgStruct ) \
- smSendSMMsg( (connHandle), SMP_IDENTITY_ADDR_INFORMATION_LEN, \
- (smpMsgs_t *)(msgStruct), \
- (pfnSMBuildCmd_t)(smpBuildIdentityAddrInfo) )
-
- #define smSendSigningInfo( connHandle, msgStruct ) \
- smSendSMMsg( (connHandle), SMP_SIGNING_INFORMATION_LEN, \
- (smpMsgs_t *)(msgStruct), \
- (pfnSMBuildCmd_t)(smpBuildSigningInfo) )
- #define smSendSecurityReq( connHandle, msgStruct ) \
- smSendSMMsg( (connHandle), SMP_SECURITY_REQUEST_LEN, \
- (smpMsgs_t *)(msgStruct), \
- (pfnSMBuildCmd_t)(smpBuildSecurityReq) )
-
- typedef struct
- {
- uint8 ioCapability;
- uint8 oobDataFlag;
- authReq_t authReq;
- uint8 maxEncKeySize;
- keyDist_t keyDist;
- } smpPairingReq_t;
- typedef smpPairingReq_t smpPairingRsp_t;
- typedef struct
- {
- uint8 confirmValue[SMP_CONFIRM_LEN];
- } smpPairingConfirm_t;
- typedef struct
- {
- uint8 randomValue[SMP_RANDOM_LEN];
- } smpPairingRandom_t;
- typedef struct
- {
- uint8 reason;
- } smpPairingFailed_t;
- typedef struct
- {
- uint8 ltk[KEYLEN];
- } smpEncInfo_t;
- typedef struct
- {
- uint16 ediv;
- uint16 rand[B_RANDOM_NUM_SIZE];
- } smpMasterID_t;
- typedef struct
- {
- uint8 irk[KEYLEN];
- } smpIdentityInfo_t;
- typedef struct
- {
- uint8 addrType;
- uint8 bdAddr[B_ADDR_LEN];
- } smpIdentityAddrInfo_t;
- typedef struct
- {
- uint8 signature[KEYLEN];
- } smpSigningInfo_t;
- typedef struct
- {
- authReq_t authReq;
- } smpSecurityReq_t;
- typedef union
- {
- smpPairingReq_t pairingReq;
- smpPairingReq_t pairingRsp;
- smpPairingConfirm_t pairingConfirm;
- smpPairingRandom_t pairingRandom;
- smpPairingFailed_t pairingFailed;
- smpEncInfo_t encInfo;
- smpMasterID_t masterID;
- smpIdentityInfo_t idInfo;
- smpIdentityAddrInfo_t idAddrInfo;
- smpSigningInfo_t signingInfo;
- smpSecurityReq_t secReq;
- } smpMsgs_t;
- typedef uint8 (*pfnSMBuildCmd_t)( smpMsgs_t *pMsgStruct, uint8 *pBuf );
- extern smpPairingReq_t pairingReg;
-
- extern bStatus_t smpBuildPairingReq( smpPairingReq_t *pPairingReq, uint8 *pBuf );
-
- extern bStatus_t smpBuildPairingRsp( smpPairingRsp_t *pPairingRsp, uint8 *pBuf );
-
- extern bStatus_t smpBuildPairingReqRsp( uint8 opCode, smpPairingReq_t *pPairingReq, uint8 *pBuf );
-
- extern bStatus_t smpParsePairingReq( uint8 *pBuf, smpPairingReq_t *pPairingReq );
-
- #define smpParsePairingRsp( a, b ) smpParsePairingReq( (a), (b) )
-
-
- extern bStatus_t smpBuildPairingConfirm( smpPairingConfirm_t *pPairingConfirm,
- uint8 *pBuf );
-
-
- extern bStatus_t smpParsePairingConfirm( uint8 *pBuf,
- smpPairingConfirm_t *pPairingConfirm );
-
-
- extern bStatus_t smpBuildPairingRandom( smpPairingRandom_t *pPairingRandom,
- uint8 *pBuf );
-
- extern bStatus_t smpParsePairingRandom( uint8 *pBuf,
- smpPairingRandom_t *pPairingRandom );
-
-
- extern bStatus_t smpBuildPairingFailed( smpPairingFailed_t *pPairingFailed,
- uint8 *pBuf );
-
- extern bStatus_t smpParsePairingFailed( uint8 *pBuf,
- smpPairingFailed_t *pPairingFailed );
-
-
- extern bStatus_t smpBuildEncInfo( smpEncInfo_t *pEncInfo, uint8 *pBuf );
-
- extern bStatus_t smpParseEncInfo( uint8 *buf, smpEncInfo_t *encInfo );
-
-
- extern bStatus_t smpBuildMasterID( smpMasterID_t *pMasterID, uint8 *pBuf );
-
-
- extern bStatus_t smpParseMasterID( uint8 *pBuf, smpMasterID_t *pMasterID );
-
-
- extern bStatus_t smpBuildIdentityInfo( smpIdentityInfo_t *pIdInfo, uint8 *pBuf );
-
- extern bStatus_t smpBuildIdentityAddrInfo( smpIdentityAddrInfo_t *pIdInfo, uint8 *pBuf );
-
- extern bStatus_t smpParseIdentityInfo( uint8 *pBuf, smpIdentityInfo_t *pIdInfo );
-
-
- extern bStatus_t smpParseIdentityAddrInfo( uint8 *pBuf, smpIdentityAddrInfo_t *pIdInfo );
-
-
- extern bStatus_t smpBuildSigningInfo( smpSigningInfo_t *pSigningInfo, uint8 *pBuf );
-
- extern bStatus_t smpParseSigningInfo( uint8 *pBuf, smpSigningInfo_t *pSigningInfo );
-
-
- extern bStatus_t smpBuildSecurityReq( smpSecurityReq_t *pSecReq, uint8 *pBuf );
-
- extern bStatus_t smpParseSecurityReq( uint8 *pBuf, smpSecurityReq_t *pSecReq );
-
-
- extern bStatus_t smSendSMMsg( uint16 connHandle, uint8 bufLen, smpMsgs_t *pMsg, pfnSMBuildCmd_t buildFn );
- #ifdef __cplusplus
- }
- #endif
- #endif
|