diff options
author | Harish Paryani <hparyani@broadcom.com> | 2012-04-03 23:49:45 -0700 |
---|---|---|
committer | Matthew Xie <mattx@google.com> | 2012-07-14 11:19:14 -0700 |
commit | 66aa5171e4e7c9f942971a30419c03134e67a4a4 (patch) | |
tree | 60fe10f29e7c3a574dcc317567a3c9bf05c85387 /stack/sdp | |
parent | 04db88d9bd23fa98916e031987f3ba2063783acc (diff) | |
download | external_bluetooth_bluedroid-66aa5171e4e7c9f942971a30419c03134e67a4a4.zip external_bluetooth_bluedroid-66aa5171e4e7c9f942971a30419c03134e67a4a4.tar.gz external_bluetooth_bluedroid-66aa5171e4e7c9f942971a30419c03134e67a4a4.tar.bz2 |
Check in for - new rfc multi accept code
Change-Id: I66794a8821481c58e045bb8acd8b7b758900d3e9
Diffstat (limited to 'stack/sdp')
-rw-r--r-- | stack/sdp/sdp_api.c | 102 | ||||
-rw-r--r-- | stack/sdp/sdp_main.c | 42 | ||||
-rw-r--r-- | stack/sdp/sdpint.h | 3 |
3 files changed, 105 insertions, 42 deletions
diff --git a/stack/sdp/sdp_api.c b/stack/sdp/sdp_api.c index 2545181..ef13f15 100644 --- a/stack/sdp/sdp_api.c +++ b/stack/sdp/sdp_api.c @@ -23,6 +23,12 @@ #include "sdpint.h" #include "btu.h" +#include <cutils/log.h> +#define info(fmt, ...) LOGI ("%s: " fmt,__FUNCTION__, ## __VA_ARGS__) +#define debug(fmt, ...) LOGD ("%s: " fmt,__FUNCTION__, ## __VA_ARGS__) +#define error(fmt, ...) LOGE ("## ERROR : %s: " fmt "##",__FUNCTION__, ## __VA_ARGS__) +#define asrt(s) if(!(s)) LOGE ("## %s assert %s failed at line:%d ##",__FUNCTION__, #s, __LINE__) + /********************************************************************** ** C L I E N T F U N C T I O N P R O T O T Y P E S * @@ -94,9 +100,9 @@ BOOLEAN SDP_InitDiscoveryDb (tSDP_DISCOVERY_DB *p_db, UINT32 len, UINT16 num_uui ** ** Function SDP_CancelServiceSearch ** -** Description This function cancels an active query to an SDP server. +** Description This function cancels an active query to an SDP server. ** -** Returns TRUE if discovery cancelled, FALSE if a matching activity is not found. +** Returns TRUE if discovery cancelled, FALSE if a matching activity is not found. ** *******************************************************************************/ BOOLEAN SDP_CancelServiceSearch (tSDP_DISCOVERY_DB *p_db) @@ -118,9 +124,9 @@ BOOLEAN SDP_CancelServiceSearch (tSDP_DISCOVERY_DB *p_db) ** ** Function SDP_ServiceSearchRequest ** -** Description This function queries an SDP server for information. +** Description This function queries an SDP server for information. ** -** Returns TRUE if discovery started, FALSE if failed. +** Returns TRUE if discovery started, FALSE if failed. ** *******************************************************************************/ BOOLEAN SDP_ServiceSearchRequest (UINT8 *p_bd_addr, tSDP_DISCOVERY_DB *p_db, @@ -150,14 +156,14 @@ BOOLEAN SDP_ServiceSearchRequest (UINT8 *p_bd_addr, tSDP_DISCOVERY_DB *p_db, ** ** Function SDP_ServiceSearchAttributeRequest ** -** Description This function queries an SDP server for information. +** Description This function queries an SDP server for information. ** ** The difference between this API function and the function -** SDP_ServiceSearchRequest is that this one does a +** SDP_ServiceSearchRequest is that this one does a ** combined ServiceSearchAttributeRequest SDP function. ** (This is for Unplug Testing) ** -** Returns TRUE if discovery started, FALSE if failed. +** Returns TRUE if discovery started, FALSE if failed. ** *******************************************************************************/ BOOLEAN SDP_ServiceSearchAttributeRequest (UINT8 *p_bd_addr, tSDP_DISCOVERY_DB *p_db, @@ -183,6 +189,44 @@ BOOLEAN SDP_ServiceSearchAttributeRequest (UINT8 *p_bd_addr, tSDP_DISCOVERY_DB * return (FALSE); #endif } +/******************************************************************************* +** +** Function SDP_ServiceSearchAttributeRequest2 +** +** Description This function queries an SDP server for information. +** +** The difference between this API function and the function +** SDP_ServiceSearchRequest is that this one does a +** combined ServiceSearchAttributeRequest SDP function. +** (This is for Unplug Testing) +** +** Returns TRUE if discovery started, FALSE if failed. +** +*******************************************************************************/ +BOOLEAN SDP_ServiceSearchAttributeRequest2 (UINT8 *p_bd_addr, tSDP_DISCOVERY_DB *p_db, + tSDP_DISC_CMPL_CB2 *p_cb2, void * user_data) +{ +#if SDP_CLIENT_ENABLED == TRUE + tCONN_CB *p_ccb; + + /* Specific BD address */ + p_ccb = sdp_conn_originate (p_bd_addr); + + if (!p_ccb) + return (FALSE); + + p_ccb->disc_state = SDP_DISC_WAIT_CONN; + p_ccb->p_db = p_db; + p_ccb->p_cb2 = p_cb2; + + p_ccb->is_attr_search = TRUE; + p_ccb->user_data = user_data; + + return (TRUE); +#else + return (FALSE); +#endif +} #if SDP_CLIENT_ENABLED == TRUE void SDP_SetIdleTimeout (BD_ADDR addr, UINT16 timeout) @@ -272,10 +316,10 @@ tSDP_DISC_ATTR *SDP_FindAttributeInRec (tSDP_DISC_REC *p_rec, UINT16 attr_id) ** Description This function is called to read the service UUID within a record ** if there is any. ** -** Parameters: p_rec - pointer to a SDP record. +** Parameters: p_rec - pointer to a SDP record. ** p_uuid - output parameter to save the UUID found. ** -** Returns TRUE if found, otherwise FALSE. +** Returns TRUE if found, otherwise FALSE. ** *******************************************************************************/ BOOLEAN SDP_FindServiceUUIDInRec(tSDP_DISC_REC *p_rec, tBT_UUID * p_uuid) @@ -612,7 +656,7 @@ BOOLEAN SDP_FindAddProtoListsElemInRec (tSDP_DISC_REC *p_rec, UINT16 layer_uuid, #if SDP_CLIENT_ENABLED == TRUE tSDP_DISC_ATTR *p_attr, *p_sattr; BOOLEAN ret = FALSE; - + p_attr = p_rec->p_first_attr; while (p_attr) { @@ -645,7 +689,7 @@ BOOLEAN SDP_FindAddProtoListsElemInRec (tSDP_DISC_REC *p_rec, UINT16 layer_uuid, ** ** Description This function looks at a specific discovery record for the ** Profile list descriptor, and pulls out the version number. -** The version number consists of an 8-bit major version and +** The version number consists of an 8-bit major version and ** an 8-bit minor version. ** ** Returns TRUE if found, FALSE if not @@ -732,11 +776,11 @@ UINT16 SDP_DiDiscover( BD_ADDR remote_device, tSDP_DISCOVERY_DB *p_db, tSDP_UUID init_uuid; init_uuid.len = 2; init_uuid.uu.uuid16 = di_uuid; - + if( SDP_InitDiscoveryDb(p_db, len, num_uuids, &init_uuid, 0, NULL) ) if( SDP_ServiceSearchRequest(remote_device, p_db, p_cb) ) result = SDP_SUCCESS; - + return result; #else return SDP_DI_DISC_FAILED; @@ -777,7 +821,7 @@ UINT8 SDP_GetNumDiRecords( tSDP_DISCOVERY_DB *p_db ) ** Function SDP_GetDiRecord ** ** Description This function retrieves a remote device's DI record from -** the specified database. +** the specified database. ** ** Returns SDP_SUCCESS if record retrieved, else error ** @@ -788,7 +832,7 @@ UINT16 SDP_GetDiRecord( UINT8 get_record_index, tSDP_DI_GET_RECORD *p_device_inf #if SDP_CLIENT_ENABLED == TRUE UINT16 result = SDP_NO_DI_RECORD_FOUND; UINT8 curr_record_index = 1; - + tSDP_DISC_REC *p_curr_record = NULL; /* find the requested SDP record in the discovery database */ @@ -801,7 +845,7 @@ UINT16 SDP_GetDiRecord( UINT8 get_record_index, tSDP_DI_GET_RECORD *p_device_inf if( curr_record_index++ == get_record_index ) { result = SDP_SUCCESS; - break; + break; } } }while( p_curr_record ); @@ -840,31 +884,31 @@ UINT16 SDP_GetDiRecord( UINT8 get_record_index, tSDP_DI_GET_RECORD *p_device_inf p_device_info->spec_id = p_curr_attr->attr_value.v.u16; else result = SDP_ERR_ATTR_NOT_PRESENT; - + p_curr_attr = SDP_FindAttributeInRec( p_curr_record, ATTR_ID_VENDOR_ID ); if( p_curr_attr ) p_device_info->rec.vendor = p_curr_attr->attr_value.v.u16; else result = SDP_ERR_ATTR_NOT_PRESENT; - + p_curr_attr = SDP_FindAttributeInRec( p_curr_record, ATTR_ID_VENDOR_ID_SOURCE ); if( p_curr_attr ) p_device_info->rec.vendor_id_source = p_curr_attr->attr_value.v.u16; else result = SDP_ERR_ATTR_NOT_PRESENT; - + p_curr_attr = SDP_FindAttributeInRec( p_curr_record, ATTR_ID_PRODUCT_ID ); if( p_curr_attr ) p_device_info->rec.product = p_curr_attr->attr_value.v.u16; else result = SDP_ERR_ATTR_NOT_PRESENT; - + p_curr_attr = SDP_FindAttributeInRec( p_curr_record, ATTR_ID_PRODUCT_VERSION ); if( p_curr_attr ) p_device_info->rec.version = p_curr_attr->attr_value.v.u16; else result = SDP_ERR_ATTR_NOT_PRESENT; - + p_curr_attr = SDP_FindAttributeInRec( p_curr_record, ATTR_ID_PRIMARY_RECORD ); if( p_curr_attr ) p_device_info->rec.primary_record = (BOOLEAN)p_curr_attr->attr_value.v.u8; @@ -888,7 +932,7 @@ UINT16 SDP_GetDiRecord( UINT8 get_record_index, tSDP_DI_GET_RECORD *p_device_inf ** ** Description This function adds a DI record to the local SDP database. ** -** +** ** ** Returns Returns SDP_SUCCESS if record added successfully, else error ** @@ -912,7 +956,7 @@ UINT16 SDP_SetLocalDiRecord( tSDP_DI_RECORD *p_device_info, UINT32 *p_handle ) if( p_device_info->primary_record == TRUE && sdp_cb.server_db.di_primary_handle ) handle = sdp_cb.server_db.di_primary_handle; else - { + { if( (handle = SDP_CreateRecord()) == 0 ) return SDP_NO_RESOURCES; } @@ -1013,7 +1057,7 @@ UINT16 SDP_SetLocalDiRecord( tSDP_DI_RECORD *p_device_info, UINT32 *p_handle ) BOOLEAN_DESC_TYPE, 1, &u8)) ) result = SDP_DI_REG_FAILED; } - + /* mandatory */ if ( result == SDP_SUCCESS) { @@ -1028,7 +1072,7 @@ UINT16 SDP_SetLocalDiRecord( tSDP_DI_RECORD *p_device_info, UINT32 *p_handle ) SDP_DeleteRecord( handle ); else if (p_device_info->primary_record == TRUE) sdp_cb.server_db.di_primary_handle = handle; - + return result; #else /* SDP_SERVER_ENABLED is FALSE */ return SDP_DI_REG_FAILED; @@ -1056,7 +1100,7 @@ UINT16 SDP_GetLocalDiRecord(tSDP_DI_GET_RECORD *p_device_info, UINT32 *p_handle tSDP_ATTRIBUTE *p_attr; UINT8 *p_temp; INT32 templen; - + if (*p_handle == 0) *p_handle = sdp_cb.server_db.di_primary_handle; @@ -1172,7 +1216,7 @@ UINT8 SDP_SetTraceLevel (UINT8 new_level) ** Function SDP_ConnOpen ** ** Description This function creates a connection to the SDP server on the -** given device. +** given device. ** ** Returns 0, if failed to initiate connection. Otherwise, the handle. ** @@ -1212,7 +1256,7 @@ UINT32 SDP_ConnOpen (UINT8 *p_bd_addr, tSDP_DISC_RES_CB *p_rcb, ** ** Description This function sends data to the connected SDP server. ** -** Returns TRUE if data is sent, FALSE if failed. +** Returns TRUE if data is sent, FALSE if failed. ** *******************************************************************************/ BOOLEAN SDP_WriteData (UINT32 handle, BT_HDR *p_msg) @@ -1244,7 +1288,7 @@ BOOLEAN SDP_WriteData (UINT32 handle, BT_HDR *p_msg) ** ** Parameters: handle - Handle of the connection returned by SDP_ConnOpen ** -** Returns TRUE if connection is closed, FALSE if failed to find the handle. +** Returns TRUE if connection is closed, FALSE if failed to find the handle. ** *******************************************************************************/ BOOLEAN SDP_ConnClose (UINT32 handle) diff --git a/stack/sdp/sdp_main.c b/stack/sdp/sdp_main.c index 8a9f6c5..8e84b8c 100644 --- a/stack/sdp/sdp_main.c +++ b/stack/sdp/sdp_main.c @@ -79,7 +79,7 @@ void sdp_init (void) #if SDP_SERVER_ENABLED == TRUE /* Register with Security Manager for the specific security level */ - if (!BTM_SetSecurityLevel (FALSE, SDP_SERVICE_NAME, BTM_SEC_SERVICE_SDP_SERVER, + if (!BTM_SetSecurityLevel (FALSE, SDP_SERVICE_NAME, BTM_SEC_SERVICE_SDP_SERVER, SDP_SECURITY_LEVEL, SDP_PSM, 0, 0)) { SDP_TRACE_ERROR0 ("Security Registration Server failed"); @@ -89,7 +89,7 @@ void sdp_init (void) #if SDP_CLIENT_ENABLED == TRUE /* Register with Security Manager for the specific security level */ - if (!BTM_SetSecurityLevel (TRUE, SDP_SERVICE_NAME, BTM_SEC_SERVICE_SDP_SERVER, + if (!BTM_SetSecurityLevel (TRUE, SDP_SERVICE_NAME, BTM_SEC_SERVICE_SDP_SERVER, SDP_SECURITY_LEVEL, SDP_PSM, 0, 0)) { SDP_TRACE_ERROR0 ("Security Registration for Client failed"); @@ -149,7 +149,7 @@ UINT16 sdp_set_max_attr_list_size (UINT16 max_size) ** ** Description This function handles an inbound connection indication ** from L2CAP. This is the case where we are acting as a -** server. +** server. ** ** Returns void ** @@ -171,7 +171,7 @@ static void sdp_connect_ind (BD_ADDR bd_addr, UINT16 l2cap_cid, UINT16 psm, UIN p_ccb->connection_id = l2cap_cid; /* Send response to the L2CAP layer. */ - L2CA_ConnectRsp (bd_addr, l2cap_id, l2cap_cid, L2CAP_CONN_OK, L2CAP_CONN_OK); + L2CA_ConnectRsp (bd_addr, l2cap_id, l2cap_cid, L2CAP_CONN_OK, L2CAP_CONN_OK); { tL2CAP_CFG_INFO cfg = sdp_cb.l2cap_my_cfg; @@ -195,7 +195,7 @@ static void sdp_connect_ind (BD_ADDR bd_addr, UINT16 l2cap_cid, UINT16 psm, UIN SDP_TRACE_EVENT1 ("SDP - Rcvd L2CAP conn ind, sent config req, CID 0x%x", p_ccb->connection_id); #else /* No server */ /* Reject the connection */ - L2CA_ConnectRsp (bd_addr, l2cap_id, l2cap_cid, L2CAP_CONN_NO_PSM, 0); + L2CA_ConnectRsp (bd_addr, l2cap_id, l2cap_cid, L2CAP_CONN_NO_PSM, 0); #endif } @@ -215,7 +215,7 @@ static void sdp_connect_cfm (UINT16 l2cap_cid, UINT16 result) { tCONN_CB *p_ccb; tL2CAP_CFG_INFO cfg; - + /* Find CCB based on CID */ if ((p_ccb = sdpu_find_ccb_by_cid (l2cap_cid)) == NULL) { @@ -254,20 +254,25 @@ static void sdp_connect_cfm (UINT16 l2cap_cid, UINT16 result) SDP_TRACE_WARNING2 ("SDP - Rcvd conn cnf with error: 0x%x CID 0x%x", result, p_ccb->connection_id); /* Tell the user if he has a callback */ - if (p_ccb->p_cb) + if (p_ccb->p_cb || p_ccb->p_cb2) { + UINT16 err = -1; if ((result == HCI_ERR_HOST_REJECT_SECURITY) || (result == HCI_ERR_AUTH_FAILURE) || (result == HCI_ERR_PAIRING_NOT_ALLOWED) || (result == HCI_ERR_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED) || (result == HCI_ERR_KEY_MISSING)) - (*p_ccb->p_cb) (SDP_SECURITY_ERR); + err = SDP_SECURITY_ERR; else if (result == HCI_ERR_HOST_REJECT_DEVICE) - (*p_ccb->p_cb) (SDP_CONN_REJECTED); + err = SDP_CONN_REJECTED; else - (*p_ccb->p_cb) (SDP_CONN_FAILED); - } + err = SDP_CONN_FAILED; + if(p_ccb->p_cb) + (*p_ccb->p_cb)(err); + else if(p_ccb->p_cb2) + (*p_ccb->p_cb2)(err, p_ccb->user_data); + } sdpu_release_ccb (p_ccb); } } @@ -456,6 +461,10 @@ static void sdp_disconnect_ind (UINT16 l2cap_cid, BOOLEAN ack_needed) if (p_ccb->p_cb) (*p_ccb->p_cb) ((UINT16) ((p_ccb->con_state == SDP_STATE_CONNECTED) ? SDP_SUCCESS : SDP_CONN_FAILED)); + else if (p_ccb->p_cb2) + (*p_ccb->p_cb2) ((UINT16) ((p_ccb->con_state == SDP_STATE_CONNECTED) ? + SDP_SUCCESS : SDP_CONN_FAILED), p_ccb->user_data); + #endif sdpu_release_ccb (p_ccb); } @@ -478,7 +487,7 @@ static void sdp_disconnect_ind (UINT16 l2cap_cid, BOOLEAN ack_needed) static void sdp_data_ind (UINT16 l2cap_cid, BT_HDR *p_msg) { tCONN_CB *p_ccb; - + /* Find CCB based on CID */ if ((p_ccb = sdpu_find_ccb_by_cid (l2cap_cid)) != NULL) { @@ -499,7 +508,7 @@ static void sdp_data_ind (UINT16 l2cap_cid, BT_HDR *p_msg) { SDP_TRACE_WARNING1 ("SDP - Rcvd L2CAP data, unknown CID: 0x%x", l2cap_cid); } - + GKI_freebuf (p_msg); } @@ -628,6 +637,8 @@ void sdp_disconnect (tCONN_CB*p_ccb, UINT16 reason) /* Tell the user if he has a callback */ if (p_ccb->p_cb) (*p_ccb->p_cb) (reason); + else if (p_ccb->p_cb2) + (*p_ccb->p_cb2) (reason, p_ccb->user_data); sdpu_release_ccb (p_ccb); } @@ -659,6 +670,9 @@ static void sdp_disconnect_cfm (UINT16 l2cap_cid, UINT16 result) /* Tell the user if he has a callback */ if (p_ccb->p_cb) (*p_ccb->p_cb) (p_ccb->disconnect_reason); + else if (p_ccb->p_cb2) + (*p_ccb->p_cb2) (p_ccb->disconnect_reason, p_ccb->user_data); + sdpu_release_ccb (p_ccb); } @@ -685,6 +699,8 @@ void sdp_conn_timeout (tCONN_CB*p_ccb) /* Tell the user if he has a callback */ if (p_ccb->p_cb) (*p_ccb->p_cb) (SDP_CONN_FAILED); + else if (p_ccb->p_cb2) + (*p_ccb->p_cb2) (SDP_CONN_FAILED, p_ccb->user_data); #endif sdpu_release_ccb (p_ccb); } diff --git a/stack/sdp/sdpint.h b/stack/sdp/sdpint.h index 0f16b8c..f4416d0 100644 --- a/stack/sdp/sdpint.h +++ b/stack/sdp/sdpint.h @@ -176,6 +176,8 @@ typedef struct #if SDP_CLIENT_ENABLED == TRUE tSDP_DISCOVERY_DB *p_db; /* Database to save info into */ tSDP_DISC_CMPL_CB *p_cb; /* Callback for discovery done */ + tSDP_DISC_CMPL_CB2 *p_cb2; /* Callback for discovery done piggy back with the user data */ + void *user_data; /* piggy back user data */ UINT32 handles[SDP_MAX_DISC_SERVER_RECS]; /* Discovered server record handles */ UINT16 num_handles; /* Number of server handles */ UINT16 cur_handle; /* Current handle being processed */ @@ -200,6 +202,7 @@ typedef struct UINT16 cont_offset; /* Continuation state data in the server response */ tSDP_CONT_INFO cont_info; /* structure to hold continuation information for the server response */ #endif /* SDP_SERVER_ENABLED == TRUE */ + } tCONN_CB; |