public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
From: Jordi Jaen Pallares <jordijp@gmail.com>
To: bluez-devel@lists.sourceforge.net
Subject: [Bluez-devel] Trouble adding a text parameter to the SDP service record
Date: Sat, 30 Jul 2005 12:54:13 +0200	[thread overview]
Message-ID: <537e39c905073003545b9466c@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 3092 bytes --]

Hi list,

I am trying to add a attribute "Public Key" (20 bytes length) to the 
description of a service, but I get a segfault (see code below). 

Following some examples in the bluez source code 
(and in 
http://people.csail.mit.edu/people/albert/pubs/ashuang-sm-thesis-2005.pdf) 
I have managed to add successfully the PSM and the protocol version 
attributes to the service description, but I could not find examples of 
adding "custom" parameters. 

I am sure that I still have to provide an identifier to the attribute, but 
could not find out how to do it.

Any further help will be appreciated.

Here is the code :

---- snip ----

int main()
{
int ret = 0;
uint32_t service_uuid_int[] = { 0, 0, 0, 0x00FF };
uint16_t l2cap_psm = 1111, ver = 0x001;
uuid_t root_uuid, l2cap_uuid, svc_uuid;

sdp_list_t *l2cap_list = 0 ,
*root_list = 0 ,
*proto_list = 0 ,
*access_proto_list = 0 ;

sdp_data_t *psm = 0 , *version = 0, *psha1 = 0;

const char *service_name = "new service";
const char *service_dsc = "description of my service" ;
const char *service_prov = "Bluetooth Access Point" ;

// this is the key I want to put in the parameter
const char *pubsha1 = "0123456789abcdef6789" ;

sdp_record_t *record = sdp_record_alloc();

// set the general service ID
sdp_uuid128_create (&svc_uuid, &service_uuid_int) ;
sdp_set_service_id (record, svc_uuid) ;

// make the service record publicly browsable
sdp_uuid16_create (&root_uuid, PUBLIC_BROWSE_GROUP) ;
root_list = sdp_list_append (0, &root_uuid) ;
sdp_set_browse_groups (record, root_list) ;
sdp_list_free (root_list, 0);

// set l2cap information
sdp_uuid16_create (&l2cap_uuid, L2CAP_UUID) ;
l2cap_list = sdp_list_append (0, &l2cap_uuid) ;

// set PSM information 
psm = sdp_data_alloc (SDP_UINT16, &l2cap_psm) ;
l2cap_list = sdp_list_append (l2cap_list, psm) ; 

// set protocol version 
version = sdp_data_alloc(SDP_UINT16, &ver);
l2cap_list = sdp_list_append(l2cap_list, version);

// set key parameter
psha1 = sdp_data_alloc(SDP_TEXT_STR16, pubsha1) ;
l2cap_list = sdp_list_append (l2cap_list, psha1) ;

proto_list = sdp_list_append (0 , l2cap_list) ;

// attach protocol information to service record
access_proto_list = sdp_list_append ( 0 , proto_list ) ;
printf("The next line causes segmentation fault\n");
sdp_set_access_protos ( record, access_proto_list ) ;
printf("not reached\n");

// set the name, provider , and description
sdp_set_info_attr (record, service_name, service_prov, service_dsc ) ;

// connect to the local SDP server and register the service record
sdp_session_t *session = 0 ;

session = sdp_connect ( BDADDR_ANY, BDADDR_LOCAL, SDP_RETRY_IF_BUSY ) ;
ret = sdp_record_register ( session , record , SDP_RECORD_PERSIST ) ;
if (ret < 0) {
printf("Service Record registration failed\n");
ret = -1;

} 

printf("Service registration completed\n");

// cleanup
sdp_list_free (l2cap_list, 0);
sdp_list_free (access_proto_list, 0);
sdp_record_free (record);

return ret;
}

--- snap ---

Best regards,

Jordi

[-- Attachment #2: Type: text/html, Size: 5046 bytes --]

                 reply	other threads:[~2005-07-30 10:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=537e39c905073003545b9466c@mail.gmail.com \
    --to=jordijp@gmail.com \
    --cc=bluez-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox