linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [Bluez-devel] sdp seq of raw data
@ 2005-12-01  9:39 Collin R. Mulliner
  2005-12-01  9:55 ` Marcel Holtmann
  0 siblings, 1 reply; 10+ messages in thread
From: Collin R. Mulliner @ 2005-12-01  9:39 UTC (permalink / raw)
  To: bluez-devel

Hi Marcel and list,

I'm trying (for hours now) to put a raw binary string into a sdp
attribute so that it shows up like this:

---8<----
Data Sequence
      Data : 0B 0X 09 06 a1 01 85 01 05 07 19 e0 29 e7 15 00 25 01 75 01
95 08 81 02 75 08 95 01 81 01 75 01 95 05 
05 08 19 01 29 05 91 02 75 03 95 01 91 01 75 08 95 06 15 00 26 ff 00 05 
------>8------

I have tryed two methods, both failed:

SEQ8 method:

unit8_t h_spec[] = { binary_crap };
uint8_t dtd2 = SDP_UNIT8;
uint8_t dtd_data = SDP_SEQ8;
void *dtds[2];
void *values[2];


// this is a other uint8 value which gets placed correctly
dtds[0] = &dtd2;
values[0] = &h_spec_leng;

for (i = 0; i < sizeof(h_spec); i++) {
 h_spec_data_lst[i] = sdp_data_alloc(dtd2, &h_spec[i]);
 h_spec_data_dtds[i] = &dtd_data;
}
// sometimes it crashes here...
h_spec_data_list = sdp_seq_alloc(h_spec_data_dtds, 
  (void**)h_spec_data_lst, sizeof(h_spec));

dtds[1] = &dtd_data;
values[1] = h_spec_data_list;
// sometimes it crashes here
h_spec_lst = sdp_seq_alloc(dtds, values, 2);
sdp_attr_add(sdp_record, SRV_ATTR_1, h_spec_lst);

// and sometimes the attributes added after this one don't get
displayed, and the binary string is only one byte long


TEXT_STR8 method:

works fine but can't use binary, because of strcpy/strlen in sdp part of
libbluetooth


I couldn't find any matching example in all the BlueZ code...

thanks ... Collin

--
Collin R. Mulliner <collin@betaversion.net>
BETAVERSiON Systems [www.betaversion.net]
info/pgp: finger collin@betaversion.net
It's a hardware problem!



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Bluez-devel] sdp seq of raw data
  2005-12-01  9:39 [Bluez-devel] sdp seq of raw data Collin R. Mulliner
@ 2005-12-01  9:55 ` Marcel Holtmann
  2005-12-01 10:03   ` Collin R. Mulliner
  0 siblings, 1 reply; 10+ messages in thread
From: Marcel Holtmann @ 2005-12-01  9:55 UTC (permalink / raw)
  To: bluez-devel

Hi Collin,

> I'm trying (for hours now) to put a raw binary string into a sdp
> attribute so that it shows up like this:
> 
> ---8<----
> Data Sequence
>       Data : 0B 0X 09 06 a1 01 85 01 05 07 19 e0 29 e7 15 00 25 01 75 01
> 95 08 81 02 75 08 95 01 81 01 75 01 95 05 
> 05 08 19 01 29 05 91 02 75 03 95 01 91 01 75 08 95 06 15 00 26 ff 00 05 
> ------>8------

this is a known (maybe only by me) problem. I fixed it for the receiving
path, but not for the sending path. You need to patch the library.

Regards

Marcel




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Bluez-devel] sdp seq of raw data
  2005-12-01  9:55 ` Marcel Holtmann
@ 2005-12-01 10:03   ` Collin R. Mulliner
  2005-12-01 10:46     ` Marcel Holtmann
  0 siblings, 1 reply; 10+ messages in thread
From: Collin R. Mulliner @ 2005-12-01 10:03 UTC (permalink / raw)
  To: bluez-devel


> this is a known (maybe only by me) problem. I fixed it for the receiving
> path, but not for the sending path. You need to patch the library.

so patching the TEXT_STR stuff would be the right way?

... Collin

--
Collin R. Mulliner <collin@betaversion.net>
BETAVERSiON Systems [www.betaversion.net]
info/pgp: finger collin@betaversion.net
Life is hard, but unfair!



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Bluez-devel] sdp seq of raw data
  2005-12-01 10:03   ` Collin R. Mulliner
@ 2005-12-01 10:46     ` Marcel Holtmann
  2005-12-01 11:23       ` Collin R. Mulliner
  0 siblings, 1 reply; 10+ messages in thread
From: Marcel Holtmann @ 2005-12-01 10:46 UTC (permalink / raw)
  To: bluez-devel

Hi Collin,

> > this is a known (maybe only by me) problem. I fixed it for the receiving
> > path, but not for the sending path. You need to patch the library.
> 
> so patching the TEXT_STR stuff would be the right way?

it is actually the only way. You must make sure that unitSize is used
and that it is used correctly.

Regards

Marcel




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Bluez-devel] sdp seq of raw data
  2005-12-01 10:46     ` Marcel Holtmann
@ 2005-12-01 11:23       ` Collin R. Mulliner
  2005-12-01 11:33         ` Marcel Holtmann
  0 siblings, 1 reply; 10+ messages in thread
From: Collin R. Mulliner @ 2005-12-01 11:23 UTC (permalink / raw)
  To: bluez-devel

Do you accept a patch for this?

> it is actually the only way. You must make sure that unitSize is used
> and that it is used correctly.
> 
> Regards
> 
> Marcel


... Collin

--
Collin R. Mulliner <collin@betaversion.net>
BETAVERSiON Systems [www.betaversion.net]
info/pgp: finger collin@betaversion.net
Life is getting harder all the time - now you even have to choose your
own religion. --Carsten Wald



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Bluez-devel] sdp seq of raw data
  2005-12-01 11:23       ` Collin R. Mulliner
@ 2005-12-01 11:33         ` Marcel Holtmann
  2005-12-01 11:50           ` Collin R. Mulliner
  0 siblings, 1 reply; 10+ messages in thread
From: Marcel Holtmann @ 2005-12-01 11:33 UTC (permalink / raw)
  To: bluez-devel

Hi Collin,

> Do you accept a patch for this?

yes :)

Regards

Marcel




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Bluez-devel] sdp seq of raw data
  2005-12-01 11:33         ` Marcel Holtmann
@ 2005-12-01 11:50           ` Collin R. Mulliner
  2005-12-02 19:42             ` Marcel Holtmann
  0 siblings, 1 reply; 10+ messages in thread
From: Collin R. Mulliner @ 2005-12-01 11:50 UTC (permalink / raw)
  To: bluez-devel

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

Hi Marcel,

here are the patches, one for include/sdp_lib.h and one src/for sdp.c.
It adds two new functions but stais backward compatible.

... Collin

PS: it's 4am and I need to go to sleep :-(

On Thu, 2005-12-01 at 12:33 +0100, Marcel Holtmann wrote:
> Hi Collin,
> 
> > Do you accept a patch for this?
> 
> yes :)
> 
> Regards
> 
> Marcel

--
Collin R. Mulliner <collin@betaversion.net>
BETAVERSiON Systems [www.betaversion.net]
info/pgp: finger collin@betaversion.net
Blessed are the Geeks, for they internet the earth!

[-- Attachment #2: bluez_libs_raw_data_src --]
[-- Type: text/plain, Size: 1921 bytes --]

--- bluez-libs-2.22/src/sdp.c	2005-10-29 16:04:28.000000000 -0700
+++ bluez-libs-2.22_new/src/sdp.c	2005-12-01 03:30:05.000000000 -0800
@@ -346,6 +346,11 @@
 
 sdp_data_t *sdp_data_alloc(uint8_t dtd, const void *value)
 {
+	return(sdp_data_alloc_leng(dtd, value, 0));
+}
+
+sdp_data_t *sdp_data_alloc_leng(uint8_t dtd, const void *value, uint32_t leng)
+{
 	sdp_data_t *seq;
 	int len = 0;
 	sdp_data_t *d = (sdp_data_t *) malloc(sizeof(sdp_data_t));
@@ -420,14 +425,15 @@
 		if (!value)
 			goto out_error;
 
-		len = strlen(value);
-		d->unitSize += len;
+		len = leng ? leng : strlen(value);
+		d->unitSize = len - 1;
 		if (len <= USHRT_MAX) {
 			d->val.str = (char *) malloc(len + 1);
 			if (!d->val.str)
 				goto out_error;
 
-			strcpy(d->val.str, value);
+			if (leng) memcpy(d->val.str, value, leng);
+			else strcpy(d->val.str, value);
 			if (len <= UCHAR_MAX) {
 				d->unitSize += sizeof(uint8_t);
 				if (dtd != SDP_URL_STR8 && dtd != SDP_TEXT_STR8) {
@@ -491,6 +497,29 @@
 	return seq;
 }
 
+sdp_data_t *sdp_seq_alloc_leng(void **dtds, void **values, int *leng, int len)
+{
+	sdp_data_t *curr = NULL, *seq = NULL;
+	int i;
+
+	for (i = 0; i < len; i++) {
+		sdp_data_t *data;
+		uint8_t dtd = *(uint8_t *)dtds[i];
+		if (dtd >= SDP_SEQ8 && dtd <= SDP_ALT32)
+			data = (sdp_data_t *)values[i];
+		else
+			data = sdp_data_alloc_leng(dtd, values[i], leng[i]);
+		if (!data)
+			return NULL;
+		if (curr)
+			curr->next = data;
+		else
+			seq = data;
+		curr = data;
+	}
+	return sdp_data_alloc_leng(SDP_SEQ8, seq, leng[i]);
+}
+
 sdp_data_t *sdp_seq_alloc(void **dtds, void **values, int len)
 {
 	sdp_data_t *curr = NULL, *seq = NULL;
@@ -681,7 +710,8 @@
 	case SDP_URL_STR16:
 	case SDP_URL_STR32:
 		src = (unsigned char *)d->val.str;
-		data_size = strlen(d->val.str);
+		//data_size = strlen(d->val.str);
+		data_size = d->unitSize;
 		sdp_set_seq_len(seqp, data_size);
 		break;
 	case SDP_SEQ8:

[-- Attachment #3: bluez_libs_raw_data_inc --]
[-- Type: text/plain, Size: 744 bytes --]

--- bluez-libs-2.22/include/sdp_lib.h	2005-10-29 16:04:28.000000000 -0700
+++ bluez-libs-2.22_new/include/sdp_lib.h	2005-12-01 02:21:16.000000000 -0800
@@ -102,10 +102,12 @@
  * Basic sdp data functions
  */
 sdp_data_t *sdp_data_alloc(uint8_t dtd, const void *value);
+sdp_data_t *sdp_data_alloc_leng(uint8_t dtd, const void *value, uint32_t leng);
 void sdp_data_free(sdp_data_t *data);
 sdp_data_t *sdp_data_get(const sdp_record_t *rec, uint16_t attr_id);
 
 sdp_data_t *sdp_seq_alloc(void **dtds, void **values, int len);
+sdp_data_t *sdp_seq_alloc_leng(void **dtds, void **values, int *leng, int len);
 sdp_data_t *sdp_seq_append(sdp_data_t *seq, sdp_data_t *data);
 
 int sdp_attr_add(sdp_record_t *rec, uint16_t attr, sdp_data_t *data);

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Bluez-devel] sdp seq of raw data
  2005-12-01 11:50           ` Collin R. Mulliner
@ 2005-12-02 19:42             ` Marcel Holtmann
  2005-12-02 19:53               ` Steven Singer
  0 siblings, 1 reply; 10+ messages in thread
From: Marcel Holtmann @ 2005-12-02 19:42 UTC (permalink / raw)
  To: bluez-devel

Hi Collin,

> here are the patches, one for include/sdp_lib.h and one src/for sdp.c.
> It adds two new functions but stais backward compatible.

make it one patch and what does leng stands for? We don't use such weird
abbreviations.

Regards

Marcel




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Bluez-devel] sdp seq of raw data
  2005-12-02 19:42             ` Marcel Holtmann
@ 2005-12-02 19:53               ` Steven Singer
  2005-12-02 20:06                 ` Marcel Holtmann
  0 siblings, 1 reply; 10+ messages in thread
From: Steven Singer @ 2005-12-02 19:53 UTC (permalink / raw)
  To: bluez-devel

Marcel Holtmann wrote:
>                     ... what does leng stands for? ...

The Plateau of Leng appears in the work of H.P. Lovecraft and is
inhabited by terrible monsters. Does that help :-)

See http://en.wikipedia.org/wiki/Plateau_of_Leng

	- Steven
-- 


This message has been scanned for viruses by BlackSpider MailControl - www.blackspider.com


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [Bluez-devel] sdp seq of raw data
  2005-12-02 19:53               ` Steven Singer
@ 2005-12-02 20:06                 ` Marcel Holtmann
  0 siblings, 0 replies; 10+ messages in thread
From: Marcel Holtmann @ 2005-12-02 20:06 UTC (permalink / raw)
  To: bluez-devel

Hi Steven,

> >                     ... what does leng stands for? ...
> 
> The Plateau of Leng appears in the work of H.P. Lovecraft and is
> inhabited by terrible monsters. Does that help :-)

I assume it is short for length, but I like your explanation more :)

Regards

Marcel




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Bluez-devel mailing list
Bluez-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bluez-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2005-12-02 20:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-12-01  9:39 [Bluez-devel] sdp seq of raw data Collin R. Mulliner
2005-12-01  9:55 ` Marcel Holtmann
2005-12-01 10:03   ` Collin R. Mulliner
2005-12-01 10:46     ` Marcel Holtmann
2005-12-01 11:23       ` Collin R. Mulliner
2005-12-01 11:33         ` Marcel Holtmann
2005-12-01 11:50           ` Collin R. Mulliner
2005-12-02 19:42             ` Marcel Holtmann
2005-12-02 19:53               ` Steven Singer
2005-12-02 20:06                 ` Marcel Holtmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).