/******************************************************************************* ** ** Function bta_hf_client_del_record ** ** Description Delete SDP record for registered service. ** ** ** Returns void ** *******************************************************************************/ void bta_hf_client_del_record(tBTA_HF_CLIENT_DATA *p_data) { UNUSED(p_data); APPL_TRACE_DEBUG("bta_hf_client_del_record"); if (bta_hf_client_cb.sdp_handle != 0) { SDP_DeleteRecord(bta_hf_client_cb.sdp_handle); bta_hf_client_cb.sdp_handle = 0; BTM_FreeSCN(bta_hf_client_cb.scn); BTM_SecClrService(BTM_SEC_SERVICE_HF_HANDSFREE); bta_sys_remove_uuid(UUID_SERVCLASS_HF_HANDSFREE); } }
/****************************************************************************** ** ** Function bta_ar_dereg_avrc ** ** Description This function is called to de-register/delete an SDP record for AVRCP. ** ** Returns void ** ******************************************************************************/ void bta_ar_dereg_avrc(UINT16 service_uuid, tBTA_SYS_ID sys_id) { UINT8 mask = bta_ar_id (sys_id); UINT16 categories = 0; UINT8 temp[8], *p; if (!mask) { return; } if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET) { if (bta_ar_cb.sdp_tg_handle && mask == bta_ar_cb.tg_registered) { bta_ar_cb.tg_registered = 0; SDP_DeleteRecord(bta_ar_cb.sdp_tg_handle); bta_ar_cb.sdp_tg_handle = 0; bta_sys_remove_uuid(service_uuid); } } else if (service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL) { if (bta_ar_cb.sdp_ct_handle) { bta_ar_cb.ct_categories [mask - 1] = 0; categories = bta_ar_cb.ct_categories[0] | bta_ar_cb.ct_categories[1]; if (!categories) { /* no CT is still registered - cleaup */ SDP_DeleteRecord(bta_ar_cb.sdp_ct_handle); bta_ar_cb.sdp_ct_handle = 0; bta_sys_remove_uuid(service_uuid); } else { /* change supported categories to the remaning one */ p = temp; UINT16_TO_BE_STREAM(p, categories); SDP_AddAttribute(bta_ar_cb.sdp_ct_handle, ATTR_ID_SUPPORTED_FEATURES, UINT_DESC_TYPE, (UINT32)2, (UINT8 *)temp); } } } }
/******************************************************************************* ** ** Function bta_ag_del_records ** ** Description Delete SDP records for any registered services. ** ** ** Returns void ** *******************************************************************************/ void bta_ag_del_records(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data) { tBTA_AG_SCB *p = &bta_ag_cb.scb[0]; tBTA_SERVICE_MASK services; tBTA_SERVICE_MASK others = 0; int i; UNUSED(p_data); /* get services of all other registered servers */ for (i = 0; i < BTA_AG_NUM_IDX; i++, p++) { if (p_scb == p) { continue; } if (p->in_use && p->dealloc == FALSE) { others |= p->reg_services; } } others >>= BTA_HSP_SERVICE_ID; services = p_scb->reg_services >> BTA_HSP_SERVICE_ID; for (i = 0; i < BTA_AG_NUM_IDX && services != 0; i++, services >>= 1, others >>= 1) { /* if service registered for this scb and not registered for any other scb */ if (((services & 1) == 1) && ((others & 1) == 0)) { APPL_TRACE_DEBUG("bta_ag_del_records %d", i); if (bta_ag_cb.profile[i].sdp_handle != 0) { SDP_DeleteRecord(bta_ag_cb.profile[i].sdp_handle); bta_ag_cb.profile[i].sdp_handle = 0; } BTM_FreeSCN(bta_ag_cb.profile[i].scn); BTM_SecClrService(bta_ag_sec_id[i]); bta_sys_remove_uuid(bta_ag_uuid[i]); } } }
/******************************************************************************* ** ** Function PAN_SetRole ** ** Description This function is called by the application to set the PAN ** profile role. This should be called after PAN_Register. ** This can be called any time to change the PAN role ** ** Parameters: role - is bit map of roles to be active ** PAN_ROLE_CLIENT is for PANU role ** PAN_ROLE_GN_SERVER is for GN role ** PAN_ROLE_NAP_SERVER is for NAP role ** sec_mask - Security mask for different roles ** It is array of UINT8. The byte represent the ** security for roles PANU, GN and NAP in order ** p_user_name - Service name for PANU role ** p_gn_name - Service name for GN role ** p_nap_name - Service name for NAP role ** Can be NULL if user wants it to be default ** ** Returns PAN_SUCCESS - if the role is set successfully ** PAN_FAILURE - if the role is not valid ** *******************************************************************************/ tPAN_RESULT PAN_SetRole (UINT8 role, UINT8 *sec_mask, char *p_user_name, char *p_gn_name, char *p_nap_name) { char *p_desc; UINT8 security[3] = {PAN_PANU_SECURITY_LEVEL, PAN_GN_SECURITY_LEVEL, PAN_NAP_SECURITY_LEVEL}; UINT8 *p_sec; /* If the role is not a valid combination reject it */ if ((!(role & (PAN_ROLE_CLIENT | PAN_ROLE_GN_SERVER | PAN_ROLE_NAP_SERVER))) && role != PAN_ROLE_INACTIVE) { PAN_TRACE_ERROR1 ("PAN role %d is invalid", role); return PAN_FAILURE; } /* If the current active role is same as the role being set do nothing */ if (pan_cb.role == role) { PAN_TRACE_EVENT1 ("PAN role already was set to: %d", role); return PAN_SUCCESS; } if (!sec_mask) p_sec = security; else p_sec = sec_mask; /* Register all the roles with SDP */ PAN_TRACE_API1 ("PAN_SetRole() called with role 0x%x", role); #if (defined (PAN_SUPPORTS_ROLE_NAP) && PAN_SUPPORTS_ROLE_NAP == TRUE) /* Check the service name */ if ((p_nap_name == NULL) || (*p_nap_name == 0)) p_nap_name = PAN_NAP_DEFAULT_SERVICE_NAME; if (role & PAN_ROLE_NAP_SERVER) { /* Registering for NAP service with SDP */ p_desc = PAN_NAP_DEFAULT_DESCRIPTION; if (pan_cb.pan_nap_sdp_handle != 0) SDP_DeleteRecord (pan_cb.pan_nap_sdp_handle); pan_cb.pan_nap_sdp_handle = pan_register_with_sdp (UUID_SERVCLASS_NAP, p_sec[2], p_nap_name, p_desc); // btla-specific ++ bta_sys_add_uuid(UUID_SERVCLASS_NAP); // btla-specific -- } /* If the NAP role is already active and now being cleared delete the record */ else if (pan_cb.role & PAN_ROLE_NAP_SERVER) { if (pan_cb.pan_nap_sdp_handle != 0) { SDP_DeleteRecord (pan_cb.pan_nap_sdp_handle); pan_cb.pan_nap_sdp_handle = 0; // btla-specific ++ bta_sys_remove_uuid(UUID_SERVCLASS_NAP); // btla-specific -- } } #endif #if (defined (PAN_SUPPORTS_ROLE_GN) && PAN_SUPPORTS_ROLE_GN == TRUE) /* Check the service name */ if ((p_gn_name == NULL) || (*p_gn_name == 0)) p_gn_name = PAN_GN_DEFAULT_SERVICE_NAME; if (role & PAN_ROLE_GN_SERVER) { /* Registering for GN service with SDP */ p_desc = PAN_GN_DEFAULT_DESCRIPTION; if (pan_cb.pan_gn_sdp_handle != 0) SDP_DeleteRecord (pan_cb.pan_gn_sdp_handle); pan_cb.pan_gn_sdp_handle = pan_register_with_sdp (UUID_SERVCLASS_GN, p_sec[1], p_gn_name, p_desc); // btla-specific ++ bta_sys_add_uuid(UUID_SERVCLASS_GN); // btla-specific -- } /* If the GN role is already active and now being cleared delete the record */ else if (pan_cb.role & PAN_ROLE_GN_SERVER) { if (pan_cb.pan_gn_sdp_handle != 0) { SDP_DeleteRecord (pan_cb.pan_gn_sdp_handle); pan_cb.pan_gn_sdp_handle = 0; // btla-specific ++ bta_sys_remove_uuid(UUID_SERVCLASS_GN); // btla-specific -- } } #endif #if (defined (PAN_SUPPORTS_ROLE_PANU) && PAN_SUPPORTS_ROLE_PANU == TRUE) /* Check the service name */ if ((p_user_name == NULL) || (*p_user_name == 0)) p_user_name = PAN_PANU_DEFAULT_SERVICE_NAME; if (role & PAN_ROLE_CLIENT) { /* Registering for PANU service with SDP */ p_desc = PAN_PANU_DEFAULT_DESCRIPTION; if (pan_cb.pan_user_sdp_handle != 0) SDP_DeleteRecord (pan_cb.pan_user_sdp_handle); pan_cb.pan_user_sdp_handle = pan_register_with_sdp (UUID_SERVCLASS_PANU, p_sec[0], p_user_name, p_desc); // btla-specific ++ bta_sys_add_uuid(UUID_SERVCLASS_PANU); // btla-specific -- } /* If the PANU role is already active and now being cleared delete the record */ else if (pan_cb.role & PAN_ROLE_CLIENT) { if (pan_cb.pan_user_sdp_handle != 0) { SDP_DeleteRecord (pan_cb.pan_user_sdp_handle); pan_cb.pan_user_sdp_handle = 0; // btla-specific ++ bta_sys_remove_uuid(UUID_SERVCLASS_PANU); // btla-specific -- } } #endif /* Check if it is a shutdown request */ if (role == PAN_ROLE_INACTIVE) pan_close_all_connections (); pan_cb.role = role; PAN_TRACE_EVENT1 ("PAN role set to: %d", role); return PAN_SUCCESS; }
/***************************************************************************** ** ** Function: bta_hl_sdp_register ** ** Purpose: Register an HDP application with SDP ** ** Parameters: p_cb - Pointer to MA instance control block ** p_service_name - MA server name ** inst_id - MAS instance ID ** msg_type - Supported message type(s) ** ** ** Returns: void ** *****************************************************************************/ tBTA_HL_STATUS bta_hl_sdp_register (UINT8 app_idx) { UINT16 svc_class_id_list[BTA_HL_NUM_SVC_ELEMS]; tSDP_PROTOCOL_ELEM proto_elem_list[BTA_HL_NUM_PROTO_ELEMS]; tSDP_PROTO_LIST_ELEM add_proto_list; tBTA_HL_SUP_FEATURE_LIST_ELEM sup_feature_list; UINT16 browse_list[] = {UUID_SERVCLASS_PUBLIC_BROWSE_GROUP}; UINT8 i,j, cnt,mdep_id, mdep_role; UINT8 data_exchange_spec = BTA_HL_SDP_IEEE_11073_20601; UINT8 mcap_sup_proc = BTA_HL_MCAP_SUP_PROC_MASK; UINT16 profile_uuid = UUID_SERVCLASS_HDP_PROFILE; UINT16 version = BTA_HL_VERSION_01_00; UINT8 num_services=1; tBTA_HL_APP_CB *p_cb = BTA_HL_GET_APP_CB_PTR(app_idx); BOOLEAN result = TRUE; tBTA_HL_STATUS status = BTA_HL_STATUS_OK; #if BTA_HL_DEBUG == TRUE APPL_TRACE_DEBUG("bta_hl_sdp_register app_idx=%d",app_idx); #endif if ((p_cb->sup_feature.app_role_mask == BTA_HL_MDEP_ROLE_MASK_SOURCE) && (!p_cb->sup_feature.advertize_source_sdp)) { return BTA_HL_STATUS_OK; } if ((p_cb->sdp_handle = SDP_CreateRecord()) == 0) { return BTA_HL_STATUS_SDP_NO_RESOURCE; } num_services=1; svc_class_id_list[0]= UUID_SERVCLASS_HDP_SOURCE; if (p_cb->sup_feature.app_role_mask == BTA_HL_MDEP_ROLE_MASK_SINK) { svc_class_id_list[0]= UUID_SERVCLASS_HDP_SINK; } else { if (p_cb->sup_feature.app_role_mask != BTA_HL_MDEP_ROLE_MASK_SOURCE) { /* dual role */ num_services=2; svc_class_id_list[1]= UUID_SERVCLASS_HDP_SINK; } } result &= SDP_AddServiceClassIdList(p_cb->sdp_handle, num_services, svc_class_id_list); if (result) { /* add the protocol element sequence */ proto_elem_list[0].protocol_uuid = UUID_PROTOCOL_L2CAP; proto_elem_list[0].num_params = 1; proto_elem_list[0].params[0] = p_cb->ctrl_psm; proto_elem_list[1].protocol_uuid = UUID_PROTOCOL_MCAP_CTRL; proto_elem_list[1].num_params = 1; proto_elem_list[1].params[0] = version; result &= SDP_AddProtocolList(p_cb->sdp_handle, BTA_HL_NUM_PROTO_ELEMS, proto_elem_list); result &= SDP_AddProfileDescriptorList(p_cb->sdp_handle, profile_uuid, version); } if (result) { add_proto_list.num_elems = BTA_HL_NUM_ADD_PROTO_ELEMS; add_proto_list.list_elem[0].protocol_uuid = UUID_PROTOCOL_L2CAP; add_proto_list.list_elem[0].num_params = 1; add_proto_list.list_elem[0].params[0] = p_cb->data_psm; add_proto_list.list_elem[1].protocol_uuid = UUID_PROTOCOL_MCAP_DATA; add_proto_list.list_elem[1].num_params = 0; result &= SDP_AddAdditionProtoLists(p_cb->sdp_handle, BTA_HL_NUM_ADD_PROTO_LISTS, (tSDP_PROTO_LIST_ELEM *)&add_proto_list); } if (result) { if (p_cb->srv_name[0] ) { result &= SDP_AddAttribute(p_cb->sdp_handle, (UINT16)ATTR_ID_SERVICE_NAME, (UINT8)TEXT_STR_DESC_TYPE, (UINT32)(strlen(p_cb->srv_name) + 1), (UINT8 *)p_cb->srv_name); } /* end of setting optional service name */ } if (result) { if (p_cb->srv_desp[0] ) { result &= SDP_AddAttribute(p_cb->sdp_handle, (UINT16)ATTR_ID_SERVICE_DESCRIPTION, (UINT8)TEXT_STR_DESC_TYPE, (UINT32)(strlen(p_cb->srv_desp) + 1), (UINT8 *)p_cb->srv_desp); } /* end of setting optional service description */ } if (result) { if (p_cb->provider_name[0] ) { result &= SDP_AddAttribute(p_cb->sdp_handle, (UINT16)ATTR_ID_PROVIDER_NAME, (UINT8)TEXT_STR_DESC_TYPE, (UINT32)(strlen(p_cb->provider_name) + 1), (UINT8 *)p_cb->provider_name); } /* end of setting optional provider name */ } /* add supported feture list */ if (result) { cnt=0; for (i=1; i<= p_cb->sup_feature.num_of_mdeps; i++) { mdep_id = (UINT8)p_cb->sup_feature.mdep[i].mdep_id; mdep_role = (UINT8)p_cb->sup_feature.mdep[i].mdep_cfg.mdep_role; for (j=0; j<p_cb->sup_feature.mdep[i].mdep_cfg.num_of_mdep_data_types; j++) { sup_feature_list.list_elem[cnt].mdep_id = mdep_id; sup_feature_list.list_elem[cnt].mdep_role = mdep_role; sup_feature_list.list_elem[cnt].data_type = p_cb->sup_feature.mdep[i].mdep_cfg.data_cfg[j].data_type; if (p_cb->sup_feature.mdep[i].mdep_cfg.data_cfg[j].desp[0] != '\0') { sup_feature_list.list_elem[cnt].p_mdep_desp = p_cb->sup_feature.mdep[i].mdep_cfg.data_cfg[j].desp; } else { sup_feature_list.list_elem[cnt].p_mdep_desp = NULL; } cnt++; if (cnt==BTA_HL_NUM_SUP_FEATURE_ELEMS) { result = FALSE; break; } } } sup_feature_list.num_elems = cnt; result &= bta_hl_add_sup_feature_list (p_cb->sdp_handle, sup_feature_list.num_elems, sup_feature_list.list_elem); } if (result) { result &= SDP_AddAttribute(p_cb->sdp_handle, ATTR_ID_HDP_DATA_EXCH_SPEC, UINT_DESC_TYPE, (UINT32)1, (UINT8*)&data_exchange_spec); } if (result) { result &= SDP_AddAttribute(p_cb->sdp_handle, ATTR_ID_HDP_MCAP_SUP_PROC, UINT_DESC_TYPE, (UINT32)1, (UINT8*)&mcap_sup_proc); } if (result) { result &= SDP_AddUuidSequence(p_cb->sdp_handle, ATTR_ID_BROWSE_GROUP_LIST, 1, browse_list); } if (result) { for(i=0; i < num_services; i++) { bta_sys_add_uuid(svc_class_id_list[i]); APPL_TRACE_DEBUG("dbg bta_sys_add_uuid i=%d uuid=0x%x", i, svc_class_id_list[i]); //todo } } else { if (p_cb->sdp_handle) { SDP_DeleteRecord(p_cb->sdp_handle); p_cb->sdp_handle = 0; } status = BTA_HL_STATUS_SDP_FAIL; } #if BTA_HL_DEBUG == TRUE APPL_TRACE_DEBUG("bta_hl_sdp_register status=%s", bta_hl_status_code(status)); #endif return status; }