📄 a2dp_sd_security.c
字号:
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2004-2006
Part of BlueLab 3.5.2-release
FILE NAME
a2dp_sd_security.c
DESCRIPTION
Handle security related functionality
NOTES
*/
/****************************************************************************
Header files
*/
#include "a2dp_sd_private.h"
#include "a2dp_sd_security.h"
#include <bdaddr.h>
#include <connection.h>
#include <ps.h>
/****************************************************************************
NAME
a2dpSdSecurityInit
DESCRIPTION
Set the security settings for this application
RETURNS
*/
void a2dpSdSecurityInit(void)
{
/* Disable SDP security for people browsing our services */
ConnectionSmSetSdpSecurityIn(TRUE);
/* Disable AVDTP security on incoming connections */
ConnectionSmRegisterIncomingService(protocol_l2cap, AVDTP_PSM, secl_none);
/* Disable AVCTP security on incoming connections */
ConnectionSmRegisterIncomingService(protocol_l2cap, AVCTP_PSM, secl_none);
}
/****************************************************************************
NAME
a2dpSdHandlePinCodeInd
DESCRIPTION
Respond to a PIN code request with the stored PIN.
RETURNS
*/
void a2dpSdHandlePinCodeInd(const CL_SM_PIN_CODE_IND_T *ind)
{
uint16 pin_length = 0;
uint8 pin[16];
/* Do we have a fixed pin in PS, if not reject pairing */
if ((pin_length = PsFullRetrieve(PSKEY_FIXED_PIN, pin, 16)) == 0 || pin_length > 16)
/* Set length to 0 indicating we're rejecting the PIN request */
pin_length = 0;
/* Respond to the PIN code request */
ConnectionSmPinCodeResponse(&ind->bd_addr, pin_length, pin);
}
/****************************************************************************
NAME
a2dpSdHandleAuthoriseInd
DESCRIPTION
Respond to an authorise indication from the connection library.
RETURNS
*/
void a2dpSdHandleAuthoriseInd(const a2dpSourceDongleTaskData *theApp, const CL_SM_AUTHORISE_IND_T *ind)
{
bool accept = 0;
/* Check if the device is connecting to a protocol supported by this app. */
if ((ind->protocol_id == protocol_l2cap) && (ind->channel == AVDTP_PSM))
{
accept = 1;
}
else if ((ind->protocol_id == protocol_l2cap) && (ind->channel == AVCTP_PSM) &&
BdaddrIsSame(&theApp->av_sink_addr, &ind->bd_addr))
{
/* If the authorise req isn't from the device we're connected to then reject it */
accept = 1;
}
/* Send the response to the connection lib */
ConnectionSmAuthoriseResponse(&ind->bd_addr, ind->protocol_id, ind->channel, ind->incoming, accept);
}
/****************************************************************************
NAME
a2dpSdHandleAuthoriseIndReject
DESCRIPTION
Reject the authorise request immediately, the application is in the
wrong state.
RETURNS
*/
void a2dpSdHandleAuthoriseIndReject(const CL_SM_AUTHORISE_IND_T *ind)
{
/* Reject the authorise request outright, we're in the wrong state */
ConnectionSmAuthoriseResponse(&ind->bd_addr, ind->protocol_id, ind->channel, ind->incoming, 0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -