/*******************************************************************************
**
** Function         bta_ag_create_records
**
** Description      Create SDP records for registered services.
**
**
** Returns          void
**
*******************************************************************************/
void bta_ag_create_records(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data)
{
    int                 i;
    tBTA_SERVICE_MASK   services;

    services = p_scb->reg_services >> BTA_HSP_SERVICE_ID;
    for (i = 0; i < BTA_AG_NUM_IDX && services != 0; i++, services >>= 1)
    {
        /* if service is set in mask */
        if (services & 1)
        {
            /* add sdp record if not already registered */
            if (bta_ag_cb.profile[i].sdp_handle == 0)
            {
                bta_ag_cb.profile[i].sdp_handle = SDP_CreateRecord();
                bta_ag_cb.profile[i].scn = BTM_AllocateSCN();
                bta_ag_add_record(bta_ag_uuid[i], p_data->api_register.p_name[i],
                    bta_ag_cb.profile[i].scn, p_data->api_register.features,
                    bta_ag_cb.profile[i].sdp_handle);
                bta_sys_add_uuid(bta_ag_uuid[i]);
            }
        }
    }

    p_scb->hsp_version = HSP_VERSION_1_2;

}
Esempio n. 2
0
/*******************************************************************************
**
** Function         bta_hf_client_create_record
**
** Description      Create SDP record for registered service.
**
**
** Returns          void
**
*******************************************************************************/
void bta_hf_client_create_record(tBTA_HF_CLIENT_DATA *p_data)
{
    /* add sdp record if not already registered */
    if (bta_hf_client_cb.sdp_handle == 0) {
        bta_hf_client_cb.sdp_handle = SDP_CreateRecord();
        bta_hf_client_cb.scn = BTM_AllocateSCN();
        bta_hf_client_add_record(p_data->api_register.name,
                                 bta_hf_client_cb.scn,
                                 p_data->api_register.features,
                                 bta_hf_client_cb.sdp_handle);

        bta_sys_add_uuid(UUID_SERVCLASS_HF_HANDSFREE);
    }

}
Esempio n. 3
0
File: bta_ar.c Progetto: tve/esp-idf
/******************************************************************************
**
** Function         bta_ar_reg_avrc
**
** Description      This function is called to register an SDP record for AVRCP.
**
** Returns          void
**
******************************************************************************/
void bta_ar_reg_avrc(UINT16 service_uuid, char *service_name, char *provider_name,
                     UINT16 categories, tBTA_SYS_ID sys_id)
{
    UINT8   mask = bta_ar_id (sys_id);
    UINT8   temp[8], *p;

    if (!mask || !categories) {
        return;
    }

    if (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET) {
        if (bta_ar_cb.sdp_tg_handle == 0) {
            bta_ar_cb.tg_registered = mask;
            bta_ar_cb.sdp_tg_handle = SDP_CreateRecord();
            AVRC_AddRecord(service_uuid, service_name, provider_name, categories, bta_ar_cb.sdp_tg_handle);
            bta_sys_add_uuid(service_uuid);
        }
        /* only one TG is allowed (first-come, first-served).
         * If sdp_tg_handle is non-0, ignore this request */
    } else if ((service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL) || (service_uuid == UUID_SERVCLASS_AV_REM_CTRL_CONTROL)) {
        bta_ar_cb.ct_categories [mask - 1] = categories;
        categories = bta_ar_cb.ct_categories[0] | bta_ar_cb.ct_categories[1];
        if (bta_ar_cb.sdp_ct_handle == 0) {
            bta_ar_cb.sdp_ct_handle = SDP_CreateRecord();
            AVRC_AddRecord(service_uuid, service_name, provider_name, categories, bta_ar_cb.sdp_ct_handle);
            bta_sys_add_uuid(service_uuid);
        } else {
            /* multiple CTs are allowed.
             * Change supported categories on the second 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);
        }
    }
}
Esempio n. 4
0
/*****************************************************************************
**
**  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;
}
/*******************************************************************************
**
** Function         bta_av_api_register
**
** Description      allocate stream control block,
**                  register the service to stack
**                  create SDP record
**
** Returns          void
**
*******************************************************************************/
static void bta_av_api_register(tBTA_AV_DATA *p_data)
{
    tBTA_AV_REGISTER    registr;
    tBTA_AV_SCB         *p_scb;    /* stream control block */
    tAVDT_REG       reg;
    tAVDT_CS        cs;
    char            *p_service_name;
    tBTA_AV_CODEC   codec_type;
    tBTA_UTL_COD    cod;
    UINT8           index = 0;

    memset(&cs,0,sizeof(tAVDT_CS));

    registr.status = BTA_AV_FAIL_RESOURCES;
    registr.app_id = p_data->api_reg.app_id;
    registr.chnl   = (tBTA_AV_CHNL)p_data->hdr.layer_specific;
    do
    {
        p_scb = bta_av_alloc_scb(registr.chnl);
        if(p_scb == NULL)
        {
            APPL_TRACE_ERROR0("failed to alloc SCB");
            break;
        }

        registr.hndl    = p_scb->hndl;
        p_scb->app_id   = registr.app_id;

        /* initialize the stream control block */
        p_scb->timer.p_cback = (TIMER_CBACK*)&bta_av_timer_cback;
        registr.status = BTA_AV_SUCCESS;

        if((bta_av_cb.reg_audio + bta_av_cb.reg_video) == 0)
        {
            /* the first channel registered. register to AVDTP */
            reg.ctrl_mtu = p_bta_av_cfg->sig_mtu;
            reg.ret_tout = BTA_AV_RET_TOUT;
            reg.sig_tout = BTA_AV_SIG_TOUT;
            reg.idle_tout = BTA_AV_IDLE_TOUT;
            reg.sec_mask = bta_av_cb.sec_mask;
#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE)
            bta_ar_reg_avdt(&reg, bta_av_conn_cback, BTA_ID_AV);
#endif
            bta_sys_role_chg_register(&bta_av_sys_rs_cback);

            /* create remote control TG service if required */
            if (bta_av_cb.features & (BTA_AV_FEAT_RCTG))
            {
                /* register with no authorization; let AVDTP use authorization instead */
#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE)
#if (BTA_AV_WITH_AVCTP_AUTHORIZATION == TRUE)
                bta_ar_reg_avct(p_bta_av_cfg->avrc_mtu, p_bta_av_cfg->avrc_br_mtu,
                                bta_av_cb.sec_mask, BTA_ID_AV);
#else
                bta_ar_reg_avct(p_bta_av_cfg->avrc_mtu, p_bta_av_cfg->avrc_br_mtu,
                                (UINT8)(bta_av_cb.sec_mask & (~BTA_SEC_AUTHORIZE)), BTA_ID_AV);
#endif

                bta_ar_reg_avrc(UUID_SERVCLASS_AV_REM_CTRL_TARGET, "AV Remote Control Target", NULL,
                                p_bta_av_cfg->avrc_tg_cat, BTA_ID_AV);
#endif
            }

            /* Set the Capturing service class bit */
            cod.service = BTM_COD_SERVICE_CAPTURING;
            utl_set_device_class(&cod, BTA_UTL_SET_COD_SERVICE_CLASS);
        } /* if 1st channel */

        /* get stream configuration and create stream */
        /* memset(&cs.cfg,0,sizeof(tAVDT_CFG)); */
        cs.cfg.num_codec = 1;
#ifdef A2DP_SINK
        cs.tsep = AVDT_TSEP_SNK;
#else
        cs.tsep = AVDT_TSEP_SRC;
#endif

        /*
         * memset of cs takes care setting call back pointers to null.
        cs.p_data_cback = NULL;
        cs.p_report_cback = NULL;
        */
#ifdef A2DP_SINK
        cs.p_data_cback = bta_av_a2dp_data_cback;
#endif
        cs.nsc_mask = AVDT_NSC_RECONFIG |
              ((bta_av_cb.features & BTA_AV_FEAT_PROTECT) ? 0 : AVDT_NSC_SECURITY);
        APPL_TRACE_DEBUG1("nsc_mask: 0x%x", cs.nsc_mask);

        if (p_data->api_reg.p_service_name[0] == 0)
        {
            p_service_name = NULL;
        }
        else
        {
            p_service_name = p_data->api_reg.p_service_name;
        }

        p_scb->suspend_sup  = TRUE;
        p_scb->recfg_sup    = TRUE;

        cs.p_ctrl_cback  = bta_av_dt_cback[p_scb->hdi];
        if(registr.chnl == BTA_AV_CHNL_AUDIO)
        {
            /* set up the audio stream control block */
            p_scb->p_act_tbl = (const tBTA_AV_ACT *)bta_av_a2d_action;
            p_scb->p_cos     = &bta_av_a2d_cos;
            p_scb->media_type= AVDT_MEDIA_AUDIO;
            cs.cfg.psc_mask  = AVDT_PSC_TRANS;
            cs.media_type    = AVDT_MEDIA_AUDIO;
            cs.mtu           = p_bta_av_cfg->audio_mtu;
            cs.flush_to      = L2CAP_DEFAULT_FLUSH_TO;
#if AVDT_REPORTING == TRUE
            if(bta_av_cb.features & BTA_AV_FEAT_REPORT)
            {
                cs.cfg.psc_mask |= AVDT_PSC_REPORT;
                cs.p_report_cback = bta_av_a2dp_report_cback;
#if AVDT_MULTIPLEXING == TRUE
                cs.cfg.mux_tsid_report = 2;
#endif
            }
#endif
            if(bta_av_cb.features & BTA_AV_FEAT_DELAY_RPT)
                cs.cfg.psc_mask |= AVDT_PSC_DELAY_RPT;

            /* keep the configuration in the stream control block */
            memcpy(&p_scb->cfg, &cs.cfg, sizeof(tAVDT_CFG));
            while(index < BTA_AV_MAX_SEPS &&
                (*bta_av_a2d_cos.init)(&codec_type, cs.cfg.codec_info,
                &cs.cfg.num_protect, cs.cfg.protect_info, index) == TRUE)
            {
                if(AVDT_CreateStream(&p_scb->seps[index].av_handle, &cs) == AVDT_SUCCESS)
                {
                    p_scb->seps[index].codec_type = codec_type;
                    APPL_TRACE_DEBUG3("audio[%d] av_handle: %d codec_type: %d",
                        index, p_scb->seps[index].av_handle, p_scb->seps[index].codec_type);
                    index++;
                }
                else
                    break;
            }

            if(!bta_av_cb.reg_audio)
            {
                /* create the SDP records on the 1st audio channel */
                bta_av_cb.sdp_a2d_handle = SDP_CreateRecord();
#ifdef A2DP_SINK
                A2D_AddRecord(UUID_SERVCLASS_AUDIO_SINK, p_service_name, NULL,
                                  A2D_SUPF_SPEAKER, bta_av_cb.sdp_a2d_handle);
                bta_sys_add_uuid(UUID_SERVCLASS_AUDIO_SINK);
#else
                A2D_AddRecord(UUID_SERVCLASS_AUDIO_SOURCE, p_service_name, NULL,
                                  A2D_SUPF_PLAYER, bta_av_cb.sdp_a2d_handle);
                bta_sys_add_uuid(UUID_SERVCLASS_AUDIO_SOURCE);
#endif

                /* start listening when A2DP is registered */
                if (bta_av_cb.features & BTA_AV_FEAT_RCTG)
                    bta_av_rc_create(&bta_av_cb, AVCT_ACP, 0, BTA_AV_NUM_LINKS + 1);

                /* if the AV and AVK are both supported, it cannot support the CT role */
                if (bta_av_cb.features & (BTA_AV_FEAT_RCCT))
                {
                    /* if TG is not supported, we need to register to AVCT now */
                    if ((bta_av_cb.features & (BTA_AV_FEAT_RCTG)) == 0)
                    {
#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE)
#if (BTA_AV_WITH_AVCTP_AUTHORIZATION == TRUE)
                        bta_ar_reg_avct(p_bta_av_cfg->avrc_mtu, p_bta_av_cfg->avrc_br_mtu,
                                        bta_av_cb.sec_mask, BTA_ID_AV);
#else
                        bta_ar_reg_avct(p_bta_av_cfg->avrc_mtu, p_bta_av_cfg->avrc_br_mtu,
                                        (UINT8)(bta_av_cb.sec_mask & (~BTA_SEC_AUTHORIZE)), BTA_ID_AV);
#endif
#endif
                    }
#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE)
                    /* create an SDP record as AVRC CT. */
                    bta_ar_reg_avrc(UUID_SERVCLASS_AV_REMOTE_CONTROL, NULL, NULL,
                           p_bta_av_cfg->avrc_ct_cat, BTA_ID_AV);
#endif
                }
            }
            bta_av_cb.reg_audio |= BTA_AV_HNDL_TO_MSK(p_scb->hdi);
            APPL_TRACE_DEBUG1("reg_audio: 0x%x",bta_av_cb.reg_audio);
        }
        else
        {
            bta_av_cb.reg_video = BTA_AV_HNDL_TO_MSK(p_scb->hdi);
            bta_av_cb.sdp_vdp_handle = SDP_CreateRecord();
            /* register the video channel */
            /* no need to verify the function pointer here. it's verified prior */
            (*p_bta_av_cfg->p_reg)(&cs, p_service_name, p_scb);
        }
    } while (0);

    /* call callback with register event */
    (*bta_av_cb.p_cback)(BTA_AV_REGISTER_EVT, (tBTA_AV *)&registr);
}
Esempio n. 6
0
/***********************************************************************
 *
 * FUNCTION NAME:    OBEX_RegisterSyncServer
 * DESCRIPTION:
 
 This function will send a PUSH command to the IrMC Client

 * KNOWN ISSUES:

 none.
 
 *
 *
 ***********************************************************************/
APIDECL1 t_api APIDECL2 OBEX_RegisterSyncServer(u_int8 channel, u_int8 supported_types)
{
	u_int32 handle;
	
	u_int16 _16bit;
	u_int8 _8bit;
	
	t_SDP_serviceRecord *pRecord;
	t_SDP_dataElement e1,e2,e3,e4,e5;
		
	t_SDP_dataElement* list[4];
	
	/* Create a Service Record */ 
	
	SDP_CreateRecord(&handle,&pRecord);
	
	/* service class list */
	
	_16bit = SDP_SCLASS_UUID_IRMC_SYNC;
	
	SDP_EncodeAttribute(SDP_UUID,2,(u_int8*)&_16bit,&e1);
	
	
	list[0] = &e1;
	
	SDP_CreateList(SDP_SEQUENCE,1,list,&e3);
	
	SDP_AddAttribute(pRecord,SDP_AID_SERVICE_CLASS,&e3);
	
	/* protocol descriptor list */
	
	_16bit = SDP_PROTOCOL_UUID_L2CAP;
	
	SDP_EncodeAttribute(SDP_UUID,2,(u_int8*)&_16bit,&e1);
	
	list[0] = &e1;
	
	SDP_CreateList(SDP_SEQUENCE,1,list,&e2);
	
	_16bit = SDP_PROTOCOL_UUID_RFCOMM;
	
	SDP_EncodeAttribute(SDP_UUID,2,(u_int8*)&_16bit,&e1);
	
	_8bit = channel;
	
	SDP_EncodeAttribute(SDP_UINT,1,&_8bit,&e3);
	
	list[0] = &e1;
	list[1] = &e3;
	
	SDP_CreateList(SDP_SEQUENCE,2,list,&e4);
	
	_16bit = SDP_PROTOCOL_UUID_OBEX;
	
	SDP_EncodeAttribute(SDP_UUID,2,(u_int8*)&_16bit,&e1);
	
	list[0] = &e1;
	
	SDP_CreateList(SDP_SEQUENCE,1,list,&e3);
	
	list[0] = &e2;
	list[1] = &e4;
	list[2] = &e3;
	
	SDP_CreateList(SDP_SEQUENCE,3,list,&e1);
	
	SDP_AddAttribute(pRecord,SDP_AID_PROTOCOL,&e1);
		
	/* profile - list */
	
	_16bit = SDP_SCLASS_UUID_IRMC_SYNC;
	
	SDP_EncodeAttribute(SDP_UUID,2,(u_int8*)&_16bit,&e1);
	
	_16bit = 0x0100;
	
	SDP_EncodeAttribute(SDP_UINT,2,(u_int8*)&_16bit,&e2);
	
	list[0] = &e1;
	list[1] = &e2;
	
	SDP_CreateList(SDP_SEQUENCE,2,list,&e3);
	
	list[0] = &e3;
	
	SDP_CreateList(SDP_SEQUENCE,1,list,&e2);
	
	SDP_AddAttribute(pRecord,SDP_AID_PROFILE_LIST,&e2);
	
	/* service name */
	
	SDP_EncodeAttribute(SDP_TEXT,20,(u_int8 *)"IrMC Synchronisation",&e1);
	
	SDP_AddAttribute(pRecord,0x0100,&e1);
	
	/* supported formats */
	_16bit = 0;

	if(supported_types & 0x01)
	{
		_8bit = 1;	
		SDP_EncodeAttribute(SDP_UINT,1,&_8bit,&e1);
		list[_16bit++] = &e1;
	}

	if(supported_types & 0x02)
	{
		_8bit = 3;	
		SDP_EncodeAttribute(SDP_UINT,1,&_8bit,&e2);
		list[_16bit++] = &e2;
	}

	if(supported_types & 0x04)
	{
		_8bit = 5;	
		SDP_EncodeAttribute(SDP_UINT,1,&_8bit,&e3);
		list[_16bit++] = &e3;
	}

	if(supported_types & 0x08)
	{
		_8bit = 6;	
		SDP_EncodeAttribute(SDP_UINT,1,&_8bit,&e4);
		list[_16bit++] = &e4;
	}

	SDP_CreateList(SDP_SEQUENCE,_16bit,list,&e5);
	
	SDP_AddAttribute(pRecord,SDP_AID_DATA_STORES,&e5);


	_16bit = SDP_SCLASS_UUID_PUBLIC;
	
	SDP_EncodeAttribute(SDP_UUID,2,(u_int8*)&_16bit,&e1);
	
	
	list[0] = &e1;
	
	SDP_CreateList(SDP_SEQUENCE,1,list,&e3);
	
	SDP_AddAttribute(pRecord,SDP_AID_BROWSE_LIST,&e3);



	
	return BT_NOERROR;
}
Esempio n. 7
0
void sample_setup(int rfcomm_chan)
{
    u_int8 channel;
    u_int32 handle;
    u_int16 serial_uuid,l2cap_uuid,rfcomm_uuid,language_id,language_encoding,language_base;
    t_SDP_serviceRecord *pRecord;
    t_SDP_dataElement SerialPortUUID,ServiceClassList,L2CAP_UUID,Protocol0,RFCOMM_UUID,RFCOMM_CHANNEL,Protocol1;
    t_SDP_dataElement ProtocolDescriptorList,Serial_Name,Lang_id,Lang_Enc,Lang_base,Lang_list_1,Lang_base_list;
    t_SDP_dataElement* list[10];

    char* Service_name = "Serial_user_a";

    handle = 16;

    /* Create a Service Record */

    SDP_CreateRecord(&handle,&pRecord);

    /* service class list */

    serial_uuid = 0x1101; /* serial port uuid */
    SDP_EncodeAttribute(SDP_UUID,2,&serial_uuid,&SerialPortUUID);

    /* place the uuid in a list */

    list[0] = &SerialPortUUID;
    SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList);

    /* add this as an attribute to the service record */

    SDP_AddAttribute(pRecord,0x0001,&ServiceClassList);

    /* protocol descriptor list */


    /* construct the l2cap protocol entry */

    l2cap_uuid = 0x0100;
    SDP_EncodeAttribute(SDP_UUID,2,&l2cap_uuid,&L2CAP_UUID);

    /* place l2cap uuid in a list */

    list[0] = &L2CAP_UUID;
    SDP_CreateList(SDP_SEQUENCE,1,list,&Protocol0);


    /* construct the rfcomm entry */

    rfcomm_uuid = 0x0003;
    SDP_EncodeAttribute(SDP_UUID,2,&rfcomm_uuid,&RFCOMM_UUID);

    channel = rfcomm_chan; /* setting of the RFCOMM channel number */
    SDP_EncodeAttribute(SDP_UINT,1,&channel,&RFCOMM_CHANNEL);

    /* place rfcomm uuid and chanel number in a list */

    list[0] = &RFCOMM_UUID;
    list[1] = &RFCOMM_CHANNEL;
    SDP_CreateList(SDP_SEQUENCE,2,list,&Protocol1);

    /* place protocol 0 and protocol 1 in a list */

    list[0] = &Protocol0;
    list[1] = &Protocol1;

    SDP_CreateList(SDP_SEQUENCE,2,list,&ProtocolDescriptorList);

    /* add this as an attribute to the service record */

    SDP_AddAttribute(pRecord,0x0004,&ProtocolDescriptorList);


    /* language base list */

    /* language identifier english */

    language_id = ('e' << 8) + 'n';

    SDP_EncodeAttribute(SDP_UINT,2,&language_id,&Lang_id);

    /* language encoding  utf-8 */

    language_encoding = 106;

    SDP_EncodeAttribute(SDP_UINT,2,&language_encoding,&Lang_Enc);

    /* language base */

    language_base = 0x0100;

    SDP_EncodeAttribute(SDP_UINT,2,&language_base,&Lang_base);

    /* place the entries in a list */

    list[0] = &Lang_id;
    list[1] = &Lang_Enc;
    list[2] = &Lang_base;

    SDP_CreateList(SDP_SEQUENCE,3,list,&Lang_list_1);

    /* add this to the main list */

    list[0] = &Lang_list_1;

    SDP_CreateList(SDP_SEQUENCE,1,list,&Lang_base_list);

    /* add this as an attribute to the service record */

    SDP_AddAttribute(pRecord,0x0006,&Lang_base_list);

    /* service name */

    SDP_EncodeAttribute(SDP_TEXT,sizeof(Service_name),Service_name,&Serial_Name);

    /* add this as an attribute to the service record */

    SDP_AddAttribute(pRecord,language_base + 0,&Serial_Name);

}
Esempio n. 8
0
/***********************************************************************
 *
 * FUNCTION NAME:    OBEX_RegisterFTPServer
 * DESCRIPTION:
 
 This function will send a PUSH command to the IrMC Client

 * KNOWN ISSUES:

 none.
 
 *
 *
 ***********************************************************************/
APIDECL1 t_api APIDECL2 OBEX_RegisterFTPServer(u_int8 channel)
{
	u_int32 handle;
	
	u_int16 _16bit;
	u_int8 _8bit;
	
	t_SDP_serviceRecord *pRecord;
	t_SDP_dataElement e1,e2,e3,e4;
		
	t_SDP_dataElement* list[3];
	
	if(!channel)
		return BT_INVALIDPARAM;


	/* Create a Service Record */ 
	
	SDP_CreateRecord(&handle,&pRecord);
	
	/* service class list */
	
	_16bit = SDP_SCLASS_UUID_OBEX_FTP;
	
	SDP_EncodeAttribute(SDP_UUID,2,(u_int8*)&_16bit,&e1);
	
	
	list[0] = &e1;
	
	SDP_CreateList(SDP_SEQUENCE,1,list,&e3);
	
	SDP_AddAttribute(pRecord,SDP_AID_SERVICE_CLASS,&e3);
	
	/* protocol descriptor list */
	
	_16bit = SDP_PROTOCOL_UUID_L2CAP;
	
	SDP_EncodeAttribute(SDP_UUID,2,(u_int8*)&_16bit,&e1);
	
	list[0] = &e1;
	
	SDP_CreateList(SDP_SEQUENCE,1,list,&e2);
	
	_16bit = SDP_PROTOCOL_UUID_RFCOMM;
	
	SDP_EncodeAttribute(SDP_UUID,2,(u_int8*)&_16bit,&e1);
	
	_8bit = channel;
	
	SDP_EncodeAttribute(SDP_UINT,1,&_8bit,&e3);
	
	list[0] = &e1;
	list[1] = &e3;
	
	SDP_CreateList(SDP_SEQUENCE,2,list,&e4);
	
	_16bit = SDP_PROTOCOL_UUID_OBEX;
	
	SDP_EncodeAttribute(SDP_UUID,2,(u_int8*)&_16bit,&e1);
	
	list[0] = &e1;
	
	SDP_CreateList(SDP_SEQUENCE,1,list,&e3);
	
	list[0] = &e2;
	list[1] = &e4;
	list[2] = &e3;
	
	SDP_CreateList(SDP_SEQUENCE,3,list,&e1);
	
	SDP_AddAttribute(pRecord,SDP_AID_PROTOCOL,&e1);
		
	/* profile - list */
	
	_16bit = SDP_SCLASS_UUID_OBEX_FTP;
	
	SDP_EncodeAttribute(SDP_UUID,2,(u_int8*)&_16bit,&e1);
	
	_16bit = 0x0100;
	
	SDP_EncodeAttribute(SDP_UINT,2,(u_int8*)&_16bit,&e2);
	
	list[0] = &e1;
	list[1] = &e2;
	
	SDP_CreateList(SDP_SEQUENCE,2,list,&e3);
	
	list[0] = &e3;
	
	SDP_CreateList(SDP_SEQUENCE,1,list,&e2);
	
	SDP_AddAttribute(pRecord,SDP_AID_PROFILE_LIST,&e2);
	
	/* service name */
	
	SDP_EncodeAttribute(SDP_TEXT,18,(u_int8 *)"OBEX File Transfer",&e1);
	
	SDP_AddAttribute(pRecord,0x0100,&e1);
		
	return BT_NOERROR;
}
Esempio n. 9
0
void create_browse_tree(void)
{
  /*
    see page 339 of spec.
   */

  u_int32 handle;
  u_int16 uuid;
  t_SDP_serviceRecord *pRecord;
  t_SDP_dataElement SerialPortUUID,BrowseGroupList,ServiceClassList,BGL1;
  t_SDP_dataElement Serial_Name;
  t_SDP_dataElement* list[10];
  
  char* Service_name[20];

  strcpy(Service_name,"Entertainment");

  handle = 200;

  handle++;

  /* Create a Service Record */ 

  SDP_CreateRecord(&handle,&pRecord);

  /* service class list */
  
  uuid = 0x1001; /* serial port uuid */
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID);

  /* place the uuid in a list */
  
  list[0] = &SerialPortUUID;
  SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0001,&ServiceClassList);

  /* browse group list */
  
  uuid = 0x1002;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  /*
  uuid = 0x1001;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  */

  list[0] = &BGL1;

  SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList);

  SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList);
  
  /* browse group descriptor */

  uuid = 0xe001;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);

  SDP_AddAttribute(pRecord,0x0200,&BGL1);

  /* service name */

  SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0100,&Serial_Name);


  strcpy(Service_name,"News");

  handle++;

  /* Create a Service Record */ 

  SDP_CreateRecord(&handle,&pRecord);

  /* service class list */
  
  uuid = 0x1001; /* serial port uuid */
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID);

  /* place the uuid in a list */
  
  list[0] = &SerialPortUUID;
  SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0001,&ServiceClassList);

  /* browse group list */
  
  uuid = 0x1002;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  /*
  uuid = 0x1001;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  */

  list[0] = &BGL1;

  SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList);

  SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList);
  
  /* browse group descriptor */

  uuid = 0xe002;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);

  SDP_AddAttribute(pRecord,0x0200,&BGL1);

  /* service name */

  SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0100,&Serial_Name);

  strcpy(Service_name,"Reference");

  handle++;

  /* Create a Service Record */ 

  SDP_CreateRecord(&handle,&pRecord);

  /* service class list */
  
  uuid = 0x1001; /* serial port uuid */
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID);

  /* place the uuid in a list */
  
  list[0] = &SerialPortUUID;
  SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0001,&ServiceClassList);

  /* browse group list */
  
  uuid = 0x1002;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  /*
  uuid = 0x1001;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  */

  list[0] = &BGL1;

  SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList);

  SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList);
  
  /* browse group descriptor */

  uuid = 0xe003;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);

  SDP_AddAttribute(pRecord,0x0200,&BGL1);

  /* service name */

  SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0100,&Serial_Name);

  strcpy(Service_name,"Games");

  handle++;

  /* Create a Service Record */ 

  SDP_CreateRecord(&handle,&pRecord);

  /* service class list */
  
  uuid = 0x1001; /* serial port uuid */
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID);

  /* place the uuid in a list */
  
  list[0] = &SerialPortUUID;
  SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0001,&ServiceClassList);

  /* browse group list */
  
  uuid = 0xe001;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  /*
  uuid = 0x1001;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  */

  list[0] = &BGL1;

  SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList);

  SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList);
  
  /* browse group descriptor */

  uuid = 0xe004;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);

  SDP_AddAttribute(pRecord,0x0200,&BGL1);

  /* service name */

  SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0100,&Serial_Name);


  strcpy(Service_name,"Movies");

  handle++;

  /* Create a Service Record */ 

  SDP_CreateRecord(&handle,&pRecord);

  /* service class list */
  
  uuid = 0x1001; /* serial port uuid */
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID);

  /* place the uuid in a list */
  
  list[0] = &SerialPortUUID;
  SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0001,&ServiceClassList);

  /* browse group list */
  
  uuid = 0xe001;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  /*
  uuid = 0x1001;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  */

  list[0] = &BGL1;

  SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList);

  SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList);
  
  /* browse group descriptor */

  uuid = 0xe005;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);

  SDP_AddAttribute(pRecord,0x0200,&BGL1);

  /* service name */

  SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0100,&Serial_Name);


  strcpy(Service_name,"Starcraft");

  handle++;

  /* Create a Service Record */ 

  SDP_CreateRecord(&handle,&pRecord);

  /* service class list */
  
  uuid = 0x1101; /* serial port uuid */
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID);

  /* place the uuid in a list */
  
  list[0] = &SerialPortUUID;
  SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0001,&ServiceClassList);

  /* browse group list */
  
  uuid = 0xe004;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  /*
  uuid = 0x1001;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  */

  list[0] = &BGL1;

  SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList);

  SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList);
  
  /* browse group descriptor */
  /*
  uuid = 0xe001;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);

  SDP_AddAttribute(pRecord,0x0200,&BGL1);
  */

  /* service name */

  SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0100,&Serial_Name);

  strcpy(Service_name,"A Bug's Life");

  handle++;

  /* Create a Service Record */ 

  SDP_CreateRecord(&handle,&pRecord);

  /* service class list */
  
  uuid = 0x1101; /* serial port uuid */
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID);

  /* place the uuid in a list */
  
  list[0] = &SerialPortUUID;
  SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0001,&ServiceClassList);

  /* browse group list */
  
  uuid = 0xe005;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  /*
  uuid = 0x1001;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  */

  list[0] = &BGL1;

  SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList);

  SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList);
  
  /* browse group descriptor */
  /*
  uuid = 0xe001;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);

  SDP_AddAttribute(pRecord,0x0200,&BGL1);
  */
  /* service name */

  SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0100,&Serial_Name);

  strcpy(Service_name,"Dictionary");

  handle++;

  /* Create a Service Record */ 

  SDP_CreateRecord(&handle,&pRecord);

  /* service class list */
  
  uuid = 0x1101; /* serial port uuid */
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID);

  /* place the uuid in a list */
  
  list[0] = &SerialPortUUID;
  SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0001,&ServiceClassList);

  /* browse group list */
  
  uuid = 0xe003;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  /*
  uuid = 0x1001;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  */

  list[0] = &BGL1;

  SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList);

  SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList);
  
  /* browse group descriptor */
  /*
  uuid = 0xe001;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);

  SDP_AddAttribute(pRecord,0x0200,&BGL1);
  */
  /* service name */

  SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0100,&Serial_Name);

  strcpy(Service_name,"Encyclopedia");

  handle++;

  /* Create a Service Record */ 

  SDP_CreateRecord(&handle,&pRecord);

  /* service class list */
  
  uuid = 0x1101; /* serial port uuid */
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID);

  /* place the uuid in a list */
  
  list[0] = &SerialPortUUID;
  SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0001,&ServiceClassList);

  /* browse group list */
  
  uuid = 0xe003;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  /*
  uuid = 0x1001;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  */

  list[0] = &BGL1;

  SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList);

  SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList);
  
  /* browse group descriptor */
  /*
  uuid = 0xe001;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);

  SDP_AddAttribute(pRecord,0x0200,&BGL1);
  */
  /* service name */

  SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0100,&Serial_Name);

  strcpy(Service_name,"New York Times");

  handle++;

  /* Create a Service Record */ 

  SDP_CreateRecord(&handle,&pRecord);

  /* service class list */
  
  uuid = 0x1101; /* serial port uuid */
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID);

  /* place the uuid in a list */
  
  list[0] = &SerialPortUUID;
  SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0001,&ServiceClassList);

  /* browse group list */
  
  uuid = 0xe002;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  /*
  uuid = 0x1001;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  */

  list[0] = &BGL1;

  SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList);

  SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList);
  
  /* browse group descriptor */
  /*
  uuid = 0xe001;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);

  SDP_AddAttribute(pRecord,0x0200,&BGL1);
  */
  /* service name */

  SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0100,&Serial_Name);

  strcpy(Service_name,"Limerick Post");

  handle++;

  /* Create a Service Record */ 

  SDP_CreateRecord(&handle,&pRecord);

  /* service class list */
  
  uuid = 0x1101; /* serial port uuid */
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID);

  /* place the uuid in a list */
  
  list[0] = &SerialPortUUID;
  SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0001,&ServiceClassList);

  /* browse group list */
  
  uuid = 0xe002;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  /*
  uuid = 0x1001;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  */

  list[0] = &BGL1;

  SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList);

  SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList);
  
  /* browse group descriptor */
  /*
  uuid = 0xe001;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);

  SDP_AddAttribute(pRecord,0x0200,&BGL1);
  */
  /* service name */

  SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0100,&Serial_Name);

  strcpy(Service_name,"London Times");

  handle++;

  /* Create a Service Record */ 

  SDP_CreateRecord(&handle,&pRecord);

  /* service class list */
  
  uuid = 0x1101; /* serial port uuid */
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&SerialPortUUID);

  /* place the uuid in a list */
  
  list[0] = &SerialPortUUID;
  SDP_CreateList(SDP_SEQUENCE,1,list,&ServiceClassList);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0001,&ServiceClassList);

  /* browse group list */
  
  uuid = 0xe002;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  /*
  uuid = 0x1001;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);
  */

  list[0] = &BGL1;

  SDP_CreateList(SDP_SEQUENCE,1,list,&BrowseGroupList);

  SDP_AddAttribute(pRecord,0x0005,&BrowseGroupList);
  
  /* browse group descriptor */
  /*
  uuid = 0xe001;
  SDP_EncodeAttribute(SDP_UUID,2,&uuid,&BGL1);

  SDP_AddAttribute(pRecord,0x0200,&BGL1);
  */
  /* service name */

  SDP_EncodeAttribute(SDP_TEXT,strlen(Service_name),Service_name,&Serial_Name);

  /* add this as an attribute to the service record */

  SDP_AddAttribute(pRecord,0x0100,&Serial_Name);
      
}
Esempio n. 10
0
void Synchronisation()
{
  t_SDP_dataElement* list[10];

  t_SDP_dataElement element1,element2,element3,element4;

  u_int32 _32bit;
  u_int16 _16bit;
  u_int8  _8bit;
  t_SDP_serviceRecord *pRecord;
  u_int32 handle;


  char* _url= "http://www.foo.org/docs";
  char* _exe_url = "http://www.foo.org/exe/*/test";
  char* _icon_url = "http://www.foo.org/icons/*";
  char* _service_name = "synchronisation";
  char* _description = "Well do a sync I think!!";
  char* _provider = "Acme.";


  /* Create a Service Record */ 

  SDP_CreateRecord(&handle,&pRecord);


  /* 0x0001 */

  _16bit = 0x1107;
  element1.type = SDP_UUID;
  element1.size = 1;  
  element1.data_length = 2;

  prh_sdp_encode_data(&element1,&_16bit);  
  
  list[0] = &element1;
  prh_sdp_encode_list(&element2,1,list);

  prh_sdp_add(pRecord,0x0001,&element2);
  
  /* 0x0002 */
  /*
    this is created automaticaly
   */

  /* 0x0003 */
  
  _16bit = 0x4321;
  
  element1.type = SDP_UUID;
  element1.size = 1;
  element1.data_length = 2;
  
  prh_sdp_encode_data(&element1,&_16bit);
  
  prh_sdp_add(pRecord,0x0003,&element1);

  /* 0x0004 */

  _16bit = 0x0100;

  element1.type = SDP_UUID;
  element1.size = 1;
  element1.data_length = 2;
  prh_sdp_encode_data(&element1,&_16bit);
  
  list[0] = &element1;

  prh_sdp_encode_list(&element3,1,list);

  _16bit = 0x0003;
  element1.type = SDP_UUID;
  element1.size = 1;
  element1.data_length = 2;
  prh_sdp_encode_data(&element1,&_16bit);
  
  _8bit = 23;
  
  element2.type = SDP_UINT;
  element2.size = 0;
  element2.data_length = 1;

  prh_sdp_encode_data(&element2,&_8bit);

  list[0] = &element1;
  list[1] = &element2;

  prh_sdp_encode_list(&element4,2,list);

  list[0] = &element3;
  list[1] = &element4;
  
  prh_sdp_encode_list(&element1,2,list);

  prh_sdp_add(pRecord,0x0004,&element1);
  
  /* 0x0005 */

  _16bit = 0x1002;
  
  element1.type = SDP_UUID;
  element1.size = 1;
  element1.data_length = 2;

  prh_sdp_encode_data(&element1,&_16bit);
  
  list[0] = &element1;

  prh_sdp_encode_list(&element2,1,list);

  prh_sdp_add(pRecord,0x0005,&element2);

  /* 0x0006 */

  _16bit = ('e' << 8) + 'n';

  element1.type = SDP_UINT;
  element1.size = 1;
  element1.data_length = 2;
  
  prh_sdp_encode_data(&element1,&_16bit);
  
  _16bit = 106;

  element2.type = SDP_UINT;
  element2.size = 1;
  element2.data_length = 2;
  
  prh_sdp_encode_data(&element2,&_16bit);
  
  _16bit = 0x0100;
  
  element3.type = SDP_UINT;
  element3.size = 1;
  element3.data_length  = 2;

  prh_sdp_encode_data(&element3,&_16bit);
  
  list[0] = &element1;
  list[1] = &element2;
  list[2] = &element3;

  prh_sdp_encode_list(&element4,3,list);

  prh_sdp_add(pRecord,0x0006,&element4);

  /* 0x0007 */

  _32bit = 0x00000060;
  
  element1.type = SDP_UINT;
  element1.size = 2;
  element1.data_length = 4;
  
  prh_sdp_encode_data(&element1,&_32bit);

  prh_sdp_add(pRecord,0x0007,&element1);
  
  /* 0x0008 */

  _8bit = 0xff;

  element1.type = SDP_UINT;
  element1.size = 0;
  element1.data_length = 1;
  
  prh_sdp_encode_data(&element1,&_8bit);

  prh_sdp_add(pRecord,0x0008,&element1);

  /* 0x0009 */

  _16bit = 0x0100;
  
  element1.type = SDP_UINT;
  element1.size = 1;
  element1.data_length = 2;
  
  prh_sdp_encode_data(&element1,&_16bit);
  
  _16bit = 0x1104;
  
  element2.type = SDP_UUID;
  element2.size = 1;
  element2.data_length = 2;

  prh_sdp_encode_data(&element2,&_16bit);
  
  list[0] = &element2;
  list[1] = &element1;
  
  prh_sdp_encode_list(&element3,2,list);
  
  list[0] = &element3;
  
  prh_sdp_encode_list(&element1,1,list);
  
  prh_sdp_add(pRecord,0x0009,&element1);
      
  /* 0x000a */

  element1.type = SDP_URL;
  element1.size = 5;
  element1.data_length = strlen(_url);

  prh_sdp_encode_data(&element1,_url);
  
  prh_sdp_add(pRecord,0x000a,&element1);

  /* 0x000b */

  element1.type = SDP_URL;
  element1.size = 5;
  element1.data_length = strlen(_exe_url);

  prh_sdp_encode_data(&element1,_exe_url);

  prh_sdp_add(pRecord,0x000b,&element1);

  /* 0x000c */
  
  element1.type = SDP_URL;
  element1.size = 5;
  element1.data_length = strlen(_icon_url);
  
  prh_sdp_encode_data(&element1,_icon_url);

  prh_sdp_add(pRecord,0x000c,&element1);

  /* 0x0100 + 0 */

  element1.type = SDP_TEXT;
  element1.size = 5;
  element1.data_length = strlen(_service_name);

  prh_sdp_encode_data(&element1,_service_name);

  prh_sdp_add(pRecord,0x0100,&element1);

  /* 0x0100 + 1 */

  element1.type = SDP_TEXT;
  element1.size = 5;
  element1.data_length = strlen(_description);
  
  prh_sdp_encode_data(&element1,_description);

  prh_sdp_add(pRecord,0x0101,&element1);
  
  /* 0x0100 + 2 */
  
  element1.type = SDP_TEXT;
  element1.size = 5;
  element1.data_length = strlen(_provider);

  prh_sdp_encode_data(&element1,_provider);

  prh_sdp_add(pRecord,0x0102,&element1);
  
  /* 0x0301 */

  _8bit = 0x05;

  element1.type = SDP_UINT;
  element1.size = 0;
  element1.data_length = 1;
  
  prh_sdp_encode_data(&element1,&_8bit);
  
  list[0] = &element1;
  
  prh_sdp_encode_list(&element2,1,list);

  prh_sdp_add(pRecord,0x0301,&element2);
    


}
Esempio n. 11
0
void upf_3_obex(void)
{
  u_int32 handle;

  u_int16 _16bit;
  u_int8 _8bit;
  
  t_SDP_serviceRecord *pRecord;
  t_SDP_dataElement e1,e2,e3,e4;
  
  t_SDP_dataElement* list[10];
  
  char Service_name[] = "OBEX Object Push";

  handle = 0x00010002;

  /* Create a Service Record */ 

  SDP_CreateRecord(&handle,&pRecord);

  /* service class list */
  
  _16bit = 0x1105;
  
  SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1);
  

  list[0] = &e1;
  
  SDP_CreateList(SDP_SEQUENCE,1,list,&e3);

  SDP_AddAttribute(pRecord,0x0001,&e3);
  
  /* protocol descriptor list */

  _16bit = 0x0100;
  
  SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1);
  
  list[0] = &e1;
  
  SDP_CreateList(SDP_SEQUENCE,1,list,&e2);

  _16bit = 0x0003;

  SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1);
  
  _8bit = 0x01;
  
  SDP_EncodeAttribute(SDP_UINT,1,&_16bit,&e3);
  
  list[0] = &e1;
  list[1] = &e3;

  SDP_CreateList(SDP_SEQUENCE,2,list,&e4);
  
  _16bit = 0x0008;

  SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1);

  list[0] = &e1;

  SDP_CreateList(SDP_SEQUENCE,1,list,&e3);

  list[0] = &e2;
  list[1] = &e4;
  list[2] = &e3;

  SDP_CreateList(SDP_SEQUENCE,3,list,&e1);
  
  SDP_AddAttribute(pRecord,0x0004,&e1);

  /* browse group */

  _16bit = 0x1002;
  
  SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1);
  
  list[0] = &e1;

  SDP_CreateList(SDP_SEQUENCE,1,list,&e2);

  SDP_AddAttribute(pRecord,0x0005,&e2);

  /* language base */

  _16bit = ('e' << 8) + 'n';

  SDP_EncodeAttribute(SDP_UINT,2,&_16bit,&e1);

  _16bit = 106;

  SDP_EncodeAttribute(SDP_UINT,2,&_16bit,&e2);
   
  _16bit = 0x0100;
  
  SDP_EncodeAttribute(SDP_UINT,2,&_16bit,&e3);
  
  list[0] = &e1;
  list[1] = &e2;
  list[2] = &e3;

  SDP_CreateList(SDP_SEQUENCE,3,list,&e4);

  SDP_AddAttribute(pRecord,0x0006,&e4);

  /* profile - list */

  _16bit = 0x1105;
  
  SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1);

  _16bit = 0x0100;

  SDP_EncodeAttribute(SDP_UINT,2,&_16bit,&e2);

  list[0] = &e1;
  list[1] = &e2;
  
  SDP_CreateList(SDP_SEQUENCE,2,list,&e3);
  
  list[0] = &e3;

  SDP_CreateList(SDP_SEQUENCE,1,list,&e2);

  SDP_AddAttribute(pRecord,0x0009,&e2);

  /* service name */

  SDP_EncodeAttribute(SDP_TEXT,sizeof(Service_name) -1,Service_name,&e1);

  SDP_AddAttribute(pRecord,0x0100,&e1);
}
Esempio n. 12
0
void test_db_api_sample_4(void)
{
  u_int32 handle;

  u_int16 _16bit;
  u_int8 _8bit;
  
  t_SDP_serviceRecord *pRecord;
  t_SDP_dataElement e1,e2,e3,e4;
  
  t_SDP_dataElement* list[10];
  
  char Service_name[] = "A sample database";

  handle = 0x00010002;

  /* Create a Service Record */ 

  SDP_CreateRecord(&handle,&pRecord);

  /* service class list */
  
  _16bit = 0x2323;
  
  SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1);
  

  list[0] = &e1;
  
  SDP_CreateList(SDP_SEQUENCE,1,list,&e3);

  SDP_AddAttribute(pRecord,0x0001,&e3);
  
  /* protocol descriptor list */

  _16bit = 0x0100;
  
  SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1);
  
  list[0] = &e1;
  
  SDP_CreateList(SDP_SEQUENCE,1,list,&e2);

  _16bit = 0x0003;

  SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1);
  
  _8bit = 0x01;
  
  SDP_EncodeAttribute(SDP_UINT,1,&_16bit,&e3);
  
  list[0] = &e1;
  list[1] = &e3;

  SDP_CreateList(SDP_SEQUENCE,2,list,&e4);
  
  _16bit = 0x0008;

  SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1);

  list[0] = &e1;

  SDP_CreateList(SDP_SEQUENCE,1,list,&e3);

  list[0] = &e2;
  list[1] = &e4;
  list[2] = &e3;

  SDP_CreateList(SDP_SEQUENCE,3,list,&e1);
  
  SDP_AddAttribute(pRecord,0x0004,&e1);

  /* browse group */

  _16bit = 0x1002;
  
  SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1);
  
  list[0] = &e1;

  SDP_CreateList(SDP_SEQUENCE,1,list,&e2);

  SDP_AddAttribute(pRecord,0x0005,&e2);

  /* language base */

  _16bit = ('e' << 8) + 'n';

  SDP_EncodeAttribute(SDP_UINT,2,&_16bit,&e1);

  _16bit = 106;

  SDP_EncodeAttribute(SDP_UINT,2,&_16bit,&e2);
   
  _16bit = 0x0100;
  
  SDP_EncodeAttribute(SDP_UINT,2,&_16bit,&e3);
  
  list[0] = &e1;
  list[1] = &e2;
  list[2] = &e3;

  SDP_CreateList(SDP_SEQUENCE,3,list,&e4);

  SDP_AddAttribute(pRecord,0x0006,&e4);

  /* profile - list */

  _16bit = 0x1105;
  
  SDP_EncodeAttribute(SDP_UUID,2,&_16bit,&e1);

  _16bit = 0x0100;

  SDP_EncodeAttribute(SDP_UINT,2,&_16bit,&e2);

  list[0] = &e1;
  list[1] = &e2;
  
  SDP_CreateList(SDP_SEQUENCE,2,list,&e3);

  SDP_AddAttribute(pRecord,0x0009,&e3);

  /* service name */

  SDP_EncodeAttribute(SDP_TEXT,sizeof(Service_name) -1,Service_name,&e1);

  SDP_AddAttribute(pRecord,0x0100,&e1);


  handle = 0;
  /* now to get the next one from the list  */
  SDP_GetNextRecord(0x00010002,&handle);

}
Esempio n. 13
0
/*******************************************************************************
**
** Function         pan_register_with_sdp
**
** Description
**
** Returns
**
*******************************************************************************/
UINT32 pan_register_with_sdp (UINT16 uuid, UINT8 sec_mask, char *p_name, char *p_desc)
{
    UINT32  sdp_handle;
    UINT16  browse_list = UUID_SERVCLASS_PUBLIC_BROWSE_GROUP;
    UINT16  security = 0;
    UINT8   availability;
    UINT32  proto_len = (UINT32)pan_proto_elem_data[1];

    /* Create a record */
    sdp_handle = SDP_CreateRecord ();

    if (sdp_handle == 0)
    {
        PAN_TRACE_ERROR0 ("PAN_SetRole - could not create SDP record");
        return 0;
    }

    /* Service Class ID List */
    SDP_AddServiceClassIdList (sdp_handle, 1, &uuid);

    /* Add protocol element sequence from the constant string */
    SDP_AddAttribute (sdp_handle, ATTR_ID_PROTOCOL_DESC_LIST, DATA_ELE_SEQ_DESC_TYPE,
                      proto_len, (UINT8 *)(pan_proto_elem_data+2));

// btla-specific ++
#if 0
    availability = 0xFF;
    SDP_AddAttribute (sdp_handle, ATTR_ID_SERVICE_AVAILABILITY, UINT_DESC_TYPE, 1, &availability);
#endif
// btla-specific --

    /* Language base */
    SDP_AddLanguageBaseAttrIDList (sdp_handle, LANG_ID_CODE_ENGLISH, LANG_ID_CHAR_ENCODE_UTF8, LANGUAGE_BASE_ID);

    /* Profile descriptor list */
    SDP_AddProfileDescriptorList (sdp_handle, uuid, PAN_PROFILE_VERSION);

    /* Service Name */
    SDP_AddAttribute (sdp_handle, ATTR_ID_SERVICE_NAME, TEXT_STR_DESC_TYPE,
                        (UINT8) (strlen(p_name) + 1), (UINT8 *)p_name);

    /* Service description */
    SDP_AddAttribute (sdp_handle, ATTR_ID_SERVICE_DESCRIPTION, TEXT_STR_DESC_TYPE,
                        (UINT8) (strlen(p_desc) + 1), (UINT8 *)p_desc);

    /* Security description */
    if (sec_mask)
    {
        UINT16_TO_BE_FIELD(&security, 0x0001);
    }
    SDP_AddAttribute (sdp_handle, ATTR_ID_SECURITY_DESCRIPTION, UINT_DESC_TYPE, 2, (UINT8 *)&security);

#if (defined (PAN_SUPPORTS_ROLE_NAP) && PAN_SUPPORTS_ROLE_NAP == TRUE)
    if (uuid == UUID_SERVCLASS_NAP)
    {
        UINT16  NetAccessType = 0x0005;      /* Ethernet */
        UINT32  NetAccessRate = 0x0001312D0; /* 10Mb/sec */
        UINT8   array[10], *p;

        /* Net access type. */
        p = array;
        UINT16_TO_BE_STREAM (p, NetAccessType);
        SDP_AddAttribute (sdp_handle, ATTR_ID_NET_ACCESS_TYPE, UINT_DESC_TYPE, 2, array);

        /* Net access rate. */
        p = array;
        UINT32_TO_BE_STREAM (p, NetAccessRate);
        SDP_AddAttribute (sdp_handle, ATTR_ID_MAX_NET_ACCESS_RATE, UINT_DESC_TYPE, 4, array);

        /* Register with Security Manager for the specific security level */
        if ((!BTM_SetSecurityLevel (TRUE, p_name, BTM_SEC_SERVICE_BNEP_NAP,
                                    sec_mask, BT_PSM_BNEP, BTM_SEC_PROTO_BNEP, UUID_SERVCLASS_NAP))
         || (!BTM_SetSecurityLevel (FALSE, p_name, BTM_SEC_SERVICE_BNEP_NAP,
                                    sec_mask, BT_PSM_BNEP, BTM_SEC_PROTO_BNEP, UUID_SERVCLASS_NAP)))
        {
            PAN_TRACE_ERROR0 ("PAN Security Registration failed for PANU");
        }
    }
#endif
#if (defined (PAN_SUPPORTS_ROLE_GN) && PAN_SUPPORTS_ROLE_GN == TRUE)
    if (uuid == UUID_SERVCLASS_GN)
    {
        if ((!BTM_SetSecurityLevel (TRUE, p_name, BTM_SEC_SERVICE_BNEP_GN,
                                    sec_mask, BT_PSM_BNEP, BTM_SEC_PROTO_BNEP, UUID_SERVCLASS_GN))
         || (!BTM_SetSecurityLevel (FALSE, p_name, BTM_SEC_SERVICE_BNEP_GN,
                                    sec_mask, BT_PSM_BNEP, BTM_SEC_PROTO_BNEP, UUID_SERVCLASS_GN)))
        {
            PAN_TRACE_ERROR0 ("PAN Security Registration failed for GN");
        }
    }
#endif
#if (defined (PAN_SUPPORTS_ROLE_PANU) && PAN_SUPPORTS_ROLE_PANU == TRUE)
    if (uuid == UUID_SERVCLASS_PANU)
    {
        if ((!BTM_SetSecurityLevel (TRUE, p_name, BTM_SEC_SERVICE_BNEP_PANU,
                                    sec_mask, BT_PSM_BNEP, BTM_SEC_PROTO_BNEP, UUID_SERVCLASS_PANU))
         || (!BTM_SetSecurityLevel (FALSE, p_name, BTM_SEC_SERVICE_BNEP_PANU,
                                    sec_mask, BT_PSM_BNEP, BTM_SEC_PROTO_BNEP, UUID_SERVCLASS_PANU)))
        {
            PAN_TRACE_ERROR0 ("PAN Security Registration failed for PANU");
        }
    }
#endif

    /* Make the service browsable */
    SDP_AddUuidSequence (sdp_handle,  ATTR_ID_BROWSE_GROUP_LIST, 1, &browse_list);


    return sdp_handle;
}