123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235 |
- #ifndef LINKDB_H
- #define LINKDB_H
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- #define INVALID_CONNHANDLE 0xFFFF
- #define LOOPBACK_CONNHANDLE 0xFFFE
-
- #define LINK_NOT_CONNECTED 0x00
- #define LINK_CONNECTED 0x01
- #define LINK_AUTHENTICATED 0x02
- #define LINK_BOUND 0x04
- #define LINK_ENCRYPTED 0x10
- #define LINKDB_STATUS_UPDATE_NEW 0
- #define LINKDB_STATUS_UPDATE_REMOVED 1
- #define LINKDB_STATUS_UPDATE_STATEFLAGS 2
-
- #define LINKDB_ERR_INSUFFICIENT_AUTHEN 0x05
- #define LINBDB_ERR_INSUFFICIENT_KEYSIZE 0x0c
- #define LINKDB_ERR_INSUFFICIENT_ENCRYPTION 0x0f
- typedef struct
- {
- uint8 srk[KEYLEN];
- uint32 signCounter;
- } linkSec_t;
- typedef struct
- {
- uint8 ltk[KEYLEN];
- uint16 div;
- uint8 rand[B_RANDOM_NUM_SIZE];
- uint8 keySize;
- } encParams_t;
- typedef struct
- {
- uint8 taskID;
- uint16 connectionHandle;
- uint8 stateFlags;
- uint8 addrType;
- uint8 addr[B_ADDR_LEN];
- uint16 connInterval;
- linkSec_t sec;
- encParams_t *pEncParams;
- } linkDBItem_t;
- typedef void (*pfnLinkDBCB_t)( uint16 connectionHandle, uint8 changeType );
- typedef void (*pfnPerformFuncCB_t)( linkDBItem_t *pLinkItem );
-
- extern void linkDB_Init( void );
-
- extern uint8 linkDB_Register( pfnLinkDBCB_t pFunc );
-
- extern uint8 linkDB_Add( uint8 taskID, uint16 connectionHandle, uint8 stateFlags,
- uint8 addrType, uint8 *pAddr, uint16 connInterval );
-
- extern uint8 linkDB_Remove( uint16 connectionHandle );
-
- extern uint8 linkDB_Update( uint16 connectionHandle, uint8 newState );
-
- extern uint8 linkDB_NumActive( void );
-
- extern linkDBItem_t *linkDB_Find( uint16 connectionHandle );
-
- extern linkDBItem_t *linkDB_FindFirst( uint8 taskID );
-
- extern uint8 linkDB_State( uint16 connectionHandle, uint8 state );
-
- extern uint8 linkDB_Authen( uint16 connectionHandle, uint8 keySize, uint8 mitmRequired );
-
-
- extern void linkDB_PerformFunc( pfnPerformFuncCB_t cb );
-
-
- #define linkDB_Up( connectionHandle ) linkDB_State( (connectionHandle), LINK_CONNECTED )
-
- #define linkDB_Encrypted( connectionHandle ) linkDB_State( (connectionHandle), LINK_ENCRYPTED )
-
-
- #define linkDB_Authenticated( connectionHandle ) linkDB_State( (connectionHandle), LINK_AUTHENTICATED )
-
- #define linkDB_Bonded( connectionHandle ) linkDB_State( (connectionHandle), LINK_BOUND )
-
- #ifdef __cplusplus
- }
- #endif
- #endif
|