Ejemplo n.º 1
0
/****************************************************************************
NAME    
    AuthResetConfirmationFlags
    
DESCRIPTION
    Helper function to reset the confirmations flag and associated BT address

RETURNS
    void 
*/
void AuthResetConfirmationFlags(void)
{
    AUTH_DEBUG(("auth: reset confirmation flags\n"));
    if (theHeadset.confirmation_addr != NULL)
    {
        AUTH_DEBUG(("auth: free confirmation addr\n"));
        free(theHeadset.confirmation_addr);
    }
    theHeadset.confirmation_addr = NULL;
    theHeadset.confirmation = FALSE;
}
Ejemplo n.º 2
0
/****************************************************************************
NAME    
    headsetPairingRejectRes 
    
DESCRIPTION
    Respond reject to a pairing info request ind

RETURNS
    void
*/
void headsetPairingRejectRes(void)
{
    if (AuthCanHeadsetPair() && theHeadset.confirmation)
    {
        AUTH_DEBUG(("auth: rejected confirmation req\n"));
        ConnectionSmUserConfirmationResponse(theHeadset.confirmation_addr, FALSE);
    }
    else
    {
        AUTH_DEBUG(("auth: invalid state for confirmation\n"));
    }
}
Ejemplo n.º 3
0
/*****************************************************************************
NAME    
     headsetHandleIoCapabilityInd
    
DESCRIPTION
     This function is called on receipt on an CL_SM_IO_CAPABILITY_REQ_IND

RETURNS
     void 
*/
void headsetHandleIoCapabilityInd(const CL_SM_IO_CAPABILITY_REQ_IND_T* ind)
{
    /* Only send IO capabilities if we are pairable */
    if (AuthCanHeadsetPair())
    {
        cl_sm_io_capability local_io_caps = cl_sm_io_cap_display_yes_no;/*cl_sm_io_cap_no_input_no_output;*/
        AUTH_DEBUG(("auth: sending IO capability\n"));
        ConnectionSmIoCapabilityResponse(&ind->bd_addr, local_io_caps, FALSE, TRUE, FALSE, 0, 0);
    }
    else /* send a reject response */
    {
        AUTH_DEBUG(("auth: rejecting IO capability req\n"));
        ConnectionSmIoCapabilityResponse(&ind->bd_addr, cl_sm_reject_request, FALSE, FALSE, FALSE, 0, 0);
    }
}
Ejemplo n.º 4
0
/****************************************************************************
NAME    
    AuthInitPermanentPairing
    
DESCRIPTION
    Add devices stored in CONFIG_PERMANENT_PAIRING to Connection library's PDL
    
RETURNS
    void
*/
void AuthInitPermanentPairing (void)
{
    bdaddr ps_bd_addr;
    
    AUTH_DEBUG(("AuthInitPermanentPairing\n"));
    
    /* Obtain just the bluetooth address of a permanently paired device */
    readPsPermanentPairing(&ps_bd_addr, 0, 0, 0);
    AUTH_DEBUG(("   ps bd_addr = [%x:%x:%lx]\n", ps_bd_addr.uap, ps_bd_addr.nap, ps_bd_addr.lap));
    
    if ( !BdaddrIsZero(&ps_bd_addr) )
    {   /* A valid address has been obtained, ask CL for info on it */
        ConnectionSmGetAuthDevice(&theSink.task, (const bdaddr *)&ps_bd_addr);
    }
}
Ejemplo n.º 5
0
/****************************************************************************
NAME    
    AuthUpdatePermanentPairing
    
DESCRIPTION
    Use supplied BDADDR to obtain linkkey from Connection library and update
    CONFIG_PERMANENT_PAIRING to retain this as the permanently paired device
    
RETURNS
    void
*/
void AuthUpdatePermanentPairing (const bdaddr *bd_addr, const sink_attributes *attributes)
{
    AUTH_DEBUG(("AuthUpdatePermanentPairing\n"));
    
    /* Update permanent pairing info */
    writePsPermanentPairing(0, 0, 0, attributes);
    
    ConnectionSmGetAuthDevice(&theSink.task, bd_addr);
}
Ejemplo n.º 6
0
/****************************************************************************
NAME    
    AuthRemovePermanentPairing
    
DESCRIPTION
    Removes permanent paired device from Connection library's PDL.
    Will also erase CONFIG_PERMANENT_PAIRING if erase_ps_key set TRUE.
    
RETURNS
    void
*/
void AuthRemovePermanentPairing (bool erase_ps_key)
{
    bdaddr ps_bd_addr;
    
    AUTH_DEBUG(("AuthRemovePermanentPairing  erase_ps_key = %u\n", erase_ps_key));
    
    readPsPermanentPairing(&ps_bd_addr, 0, 0, 0);
    AUTH_DEBUG(("   ps bd_addr = [%x:%x:%lx]\n", ps_bd_addr.uap, ps_bd_addr.nap, ps_bd_addr.lap));
    
    if ( !BdaddrIsZero(&ps_bd_addr) )
    {
        ConnectionSmDeleteAuthDeviceReq(TYPED_BDADDR_PUBLIC, (const bdaddr *)&ps_bd_addr);
    }
    
    if ( erase_ps_key )
    {
        PsStore(CONFIG_PERMANENT_PAIRING, 0, 0);
    }
}
Ejemplo n.º 7
0
void headsetHandlePinCodeInd(const CL_SM_PIN_CODE_IND_T* ind)
{
    uint16 pin_length = 0;
    uint8 pin[16];
    
    if ( AuthCanHeadsetPair () )
    {
	    
		AUTH_DEBUG(("auth: Can Pin\n")) ;
			
    	/* 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 */
        	AUTH_DEBUG(("auth : failed to get pin\n")) ;
        	pin_length = 0; 
    	}	
	} 
    /* Respond to the PIN code request */
    ConnectionSmPinCodeResponse(&ind->bd_addr, pin_length, pin); 
}
Ejemplo n.º 8
0
/****************************************************************************
NAME    
    AuthCanHeadsetConnect 
    
DESCRIPTION
    Helper function to indicate if connecting is allowed.

RETURNS
    bool
*/
static bool AuthCanHeadsetConnect ( void )
{
	bool lCanConnect = FALSE ;
	
	/* If the headset is on then authorise */
	if (stateManagerGetHfpState() != headsetPoweringOn)
	{
		lCanConnect = TRUE ;
		AUTH_DEBUG(("auth: headset is on\n")) ;
	}
		
    return lCanConnect ;
}
Ejemplo n.º 9
0
/*****************************************************************************
NAME    
     headsetHandleUserConfirmationInd
    
DESCRIPTION
     This function is called on receipt on an CL_SM_USER_CONFIRMATION_REQ_IND

RETURNS
     void
*/
void headsetHandleUserConfirmationInd(const CL_SM_USER_CONFIRMATION_REQ_IND_T* ind)
{
    if (AuthCanHeadsetPair())
    {
#if 1  
        theHeadset.confirmation = TRUE;
        AUTH_DEBUG(("auth: can confirm %ld\n", ind->numeric_value));
        /* should use text to speech here */
        theHeadset.confirmation_addr = (bdaddr*)PanicUnlessMalloc(sizeof(bdaddr));
        *theHeadset.confirmation_addr = ind->bd_addr;
#else
        ConnectionSmUserConfirmationResponse(&ind->bd_addr, TRUE);
        /* infor ssp numeric_value */
        UartPrintf("\r\n+SSP=%ld\r\n",ind->numeric_value);
#endif        
    }
    else
    {
        /* reject the confirmation request */
        AUTH_DEBUG(("auth: rejecting confirmation req\n"));
        ConnectionSmUserConfirmationResponse(&ind->bd_addr, FALSE);
    }
}
Ejemplo n.º 10
0
void headsetHandleAuthoriseInd(const CL_SM_AUTHORISE_IND_T *ind)
{
	
	bool lAuthorised = FALSE ;
	
	if ( AuthCanHeadsetConnect() )
	{
		lAuthorised = TRUE ;
	}
	
	AUTH_DEBUG(("auth: Authorised [%d]\n" , lAuthorised)) ;
	    
    /*complete the authentication with the authorised or not flag*/		
    ConnectionSmAuthoriseResponse(&ind->bd_addr, ind->protocol_id, ind->channel, ind->incoming, lAuthorised);
}
Ejemplo n.º 11
0
/****************************************************************************
NAME    
    handleGetAuthDeviceCfm
    
DESCRIPTION
    Called in response to CL_SM_GET_AUTH_DEVICE_CFM message, which is generated
    due to calling updatePermanentPairing.
    Both the BDADDR and linkkey contained in CL_SM_GET_AUTH_DEVICE_CFM are used to
    update CONFIG_PERMANENT_PAIRING to retain this as the permanently paired device
    
RETURNS
    void
*/
void handleGetAuthDeviceCfm (CL_SM_GET_AUTH_DEVICE_CFM_T *cfm)
{
    AUTH_DEBUG(("handleGetAuthDeviceCfm\n"));
    AUTH_DEBUG(("   status = %u\n",cfm->status));
    AUTH_DEBUG(("   ps bd_addr = [%x:%x:%lx]\n", cfm->bd_addr.uap, cfm->bd_addr.nap, cfm->bd_addr.lap));
    AUTH_DEBUG(("   trusted = %u\n",cfm->trusted));
    AUTH_DEBUG(("   link key type = %u",cfm->link_key_type));
    AUTH_DEBUG(("   link key size = %u\n",cfm->size_link_key));
    
    if ( cfm->status == success )
    {   /* Device exists in CL PDL */
        sink_attributes attributes;
        uint16 link_key_status = ((cfm->trusted & 0xF)<<8) | ((cfm->link_key_type & 0xF)<<4) | (cfm->size_link_key & 0xF);
        
        /* Update permanent pairing info */
        writePsPermanentPairing(&cfm->bd_addr, cfm->link_key, link_key_status, 0);
        
        /* Update attributes */
        readPsPermanentPairing(0, 0, 0, &attributes);
        deviceManagerStoreAttributes(&attributes, (const bdaddr *)&cfm->bd_addr);
        
        /* Mark the device as trusted and push it to the top of the PDL */
        ConnectionSmUpdateMruDevice((const bdaddr *)&cfm->bd_addr);
#ifdef ENABLE_SOUNDBAR
        /* ensure priority devices are shifted back to top of PDL */
        ConnectionAuthSetPriorityDevice((const bdaddr *)&cfm->bd_addr, FALSE);            
#endif            
    }
    else
    {   /* Device *does not* exist in CL PDL */ 
        bdaddr ps_bd_addr;
        uint16 ps_link_key_status;
        uint16 ps_link_key[LINK_KEY_SIZE];
    
        readPsPermanentPairing(&ps_bd_addr, ps_link_key, &ps_link_key_status, 0);
    
        if ( !BdaddrIsZero(&ps_bd_addr) )
        {   /* We have permanently paired device, add it to CL PDL */
            bool trusted = (bool)((ps_link_key_status>>8) & 0xF);
            cl_sm_link_key_type key_type = (cl_sm_link_key_type)((ps_link_key_status>>4) & 0xF);
            uint16 size_link_key = ps_link_key_status & 0xF;
        
            ConnectionSmAddAuthDevice(&theSink.task, (const bdaddr *)&ps_bd_addr, trusted, TRUE, key_type, size_link_key, (const uint16 *)ps_link_key);
        }
    }
Ejemplo n.º 12
0
/*****************************************************************************
NAME    
     headsetHandleRemoteIoCapabilityInd
    
DESCRIPTION
     This function is called on receipt on an CL_SM_REMOTE_IO_CAPABILITY_IND
 
RETURNS
     void 
*/
void headsetHandleRemoteIoCapabilityInd(const CL_SM_REMOTE_IO_CAPABILITY_IND_T* ind)
{
    AUTH_DEBUG(("auth: Incoming Authentication Request\n"));
}
Ejemplo n.º 13
0
/*****************************************************************************
NAME    
     headsetHandleUserPasskeyNotificationInd
    
DESCRIPTION
     This function is called on receipt on an CL_SM_USER_PASSKEY_NOTIFICATION_IND

RETURNS
     void
*/
void headsetHandleUserPasskeyNotificationInd(const CL_SM_USER_PASSKEY_NOTIFICATION_IND_T* ind)
{
    AUTH_DEBUG(("auth: Passkey [%ld]\n", ind->passkey));
}
Ejemplo n.º 14
0
/*****************************************************************************
NAME    
     headsetHandleUserPasskeyInd
    
DESCRIPTION
     This function is called on receipt on an CL_SM_USER_PASSKEY_IND

RETURNS
     void
*/
void headsetHandleUserPasskeyInd(const CL_SM_USER_PASSKEY_REQ_IND_T* ind)
{
    /* reject the passkey request */
    AUTH_DEBUG(("auth: rejecting passkey req\n"));
    ConnectionSmUserPasskeyResponse(&ind->bd_addr, TRUE, 0);
}