From: "José Antonio Santos Cadenas" <jcaden@libresoft.es>
To: Marcel Holtmann <marcel@holtmann.org>
Cc: Claudio Takahasi <claudio.takahasi@openbossa.org>,
"linux-bluetooth@vger.kernel.org"
<linux-bluetooth@vger.kernel.org>
Subject: Re: [PATCH] SDP patch to add support for HDP
Date: Mon, 14 Dec 2009 12:35:16 +0100 [thread overview]
Message-ID: <200912141235.16872.jcaden@libresoft.es> (raw)
In-Reply-To: <1260556350.2901.74.camel@violet>
Hi all,
Here's the corrected patch
Regards.
diff --git a/lib/sdp.c b/lib/sdp.c
index 822ec1a..89505f9 100644
--- a/lib/sdp.c
+++ b/lib/sdp.c
@@ -4621,3 +4621,114 @@ uint16_t sdp_gen_tid(sdp_session_t *session)
{
return session->tid++;
}
+
+/*
+ * Set the supported features
+ */
+int sdp_set_supp_feat(sdp_record_t *rec, const sdp_list_t *sf)
+{
+ const sdp_list_t *p, *r;
+ sdp_data_t *feat, *seq_feat;
+ int seqlen, i;
+ void **seqDTDs, **seqVals;
+
+ seqlen = sdp_list_len(sf);
+ seqDTDs = malloc(seqlen * sizeof(void *));
+ if (!seqDTDs)
+ return -1;
+ seqVals = malloc(seqlen * sizeof(void *));
+ if (!seqVals) {
+ free(seqDTDs);
+ return -1;
+ }
+
+ for (p = sf, i = 0; p; p = p->next, i++) {
+ int plen, j;
+ void **dtds, **vals;
+
+ plen = sdp_list_len(p->data);
+ dtds = malloc(plen * sizeof(void *));
+ if (!dtds)
+ goto fail;
+ vals = malloc(plen * sizeof(void *));
+ if (!vals) {
+ free(dtds);
+ goto fail;
+ }
+ for (r = p->data, j = 0; r; r = r->next, j++) {
+ sdp_data_t *data = (sdp_data_t*)r->data;
+ dtds[j] = &data->dtd;
+ vals[j] = &data->val;
+ }
+ feat = sdp_seq_alloc(dtds, vals, plen);
+ free(dtds);
+ free(vals);
+ if (!feat)
+ goto fail;
+ seqDTDs[i] = &feat->dtd;
+ seqVals[i] = feat;
+ }
+ seq_feat = sdp_seq_alloc(seqDTDs, seqVals, seqlen);
+ if (!seq_feat)
+ goto fail;
+ sdp_attr_replace(rec, SDP_ATTR_SUPPORTED_FEATURES_LIST, seq_feat);
+
+ free(seqVals);
+ free(seqDTDs);
+ return 0;
+
+fail:
+ free(seqVals);
+ free(seqDTDs);
+ return -1;
+}
+
+/*
+ * Get the supported features
+ * If an error occurred -1 is returned and errno is set
+ */
+int sdp_get_supp_feat(const sdp_record_t *rec, sdp_list_t **seqp)
+{
+ sdp_data_t *sdpdata, *d;
+ sdp_list_t *tseq;
+ tseq = NULL;
+
+ sdpdata = sdp_data_get(rec, SDP_ATTR_SUPPORTED_FEATURES_LIST);
+
+ if (!sdpdata || sdpdata->dtd < SDP_SEQ8 || sdpdata->dtd > SDP_SEQ32)
+ return sdp_get_uuidseq_attr(rec,
+ SDP_ATTR_SUPPORTED_FEATURES_LIST, seqp);
+
+ for (d = sdpdata->val.dataseq; d; d = d->next) {
+ sdp_data_t *dd;
+ sdp_list_t *subseq;
+
+ if (d->dtd < SDP_SEQ8 || d->dtd > SDP_SEQ32)
+ goto fail;
+ subseq = NULL;
+ for (dd = d->val.dataseq; dd; dd = dd->next) {
+ sdp_data_t *data;
+ if (dd->dtd != SDP_UINT8 && dd->dtd != SDP_UINT16 &&
+ dd->dtd != SDP_TEXT_STR8)
+ goto fail;
+ data = sdp_data_alloc(dd->dtd, &dd->val);
+ if (data)
+ subseq = sdp_list_append(subseq, data);
+ }
+ tseq = sdp_list_append(tseq, subseq);
+ }
+ *seqp = tseq;
+ return 0;
+
+fail:
+ while (tseq) {
+ sdp_list_t * next;
+
+ next = tseq->next;
+ sdp_list_free(tseq, free);
+ tseq = next;
+ }
+ errno = EINVAL;
+ return -1;
+}
+
diff --git a/lib/sdp.h b/lib/sdp.h
index 375261e..b493985 100644
--- a/lib/sdp.h
+++ b/lib/sdp.h
@@ -244,13 +244,16 @@ extern "C" {
#define SDP_ATTR_GROUP_ID 0x0200
#define SDP_ATTR_IP_SUBNET 0x0200
#define SDP_ATTR_VERSION_NUM_LIST 0x0200
+#define SDP_ATTR_SUPPORTED_FEATURES_LIST 0x0200
#define SDP_ATTR_SVCDB_STATE 0x0201
#define SDP_ATTR_SERVICE_VERSION 0x0300
#define SDP_ATTR_EXTERNAL_NETWORK 0x0301
#define SDP_ATTR_SUPPORTED_DATA_STORES_LIST 0x0301
+#define SDP_ATTR_DATA_EXCHANGE_SPEC 0x0301
#define SDP_ATTR_FAX_CLASS1_SUPPORT 0x0302
#define SDP_ATTR_REMOTE_AUDIO_VOLUME_CONTROL 0x0302
+#define SDP_ATTR_MCAP_SUPPORTED_PROCEDURES 0x0302
#define SDP_ATTR_FAX_CLASS20_SUPPORT 0x0303
#define SDP_ATTR_SUPPORTED_FORMATS_LIST 0x0303
#define SDP_ATTR_FAX_CLASS2_SUPPORT 0x0304
diff --git a/lib/sdp_lib.h b/lib/sdp_lib.h
index ee39df8..bebb745 100644
--- a/lib/sdp_lib.h
+++ b/lib/sdp_lib.h
@@ -585,6 +585,20 @@ static inline int sdp_get_icon_url(const sdp_record_t *rec, char *str, int len)
return sdp_get_string_attr(rec, SDP_ATTR_ICON_URL, str, len);
}
+/*
+ * Set the supported features
+ * sf should be a list of list with each feature data
+ * Returns 0 on success -1 on fail
+ */
+int sdp_set_supp_feat(sdp_record_t *rec, const sdp_list_t *sf);
+
+/*
+ * Get the supported features
+ * seqp is set to a list of list with each feature data
+ * Returns 0 on success, if an error occurred -1 is returned and errno is set
+ */
+int sdp_get_supp_feat(const sdp_record_t *rec, sdp_list_t **seqp);
+
sdp_record_t *sdp_extract_pdu(const uint8_t *pdata, int bufsize, int *scanned);
sdp_record_t *sdp_copy_record(sdp_record_t *rec);
next prev parent reply other threads:[~2009-12-14 11:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-13 12:43 [PATCH] SDP patch to add support for HDP José Antonio Santos Cadenas
2009-11-16 17:30 ` Claudio Takahasi
2009-11-16 17:52 ` Claudio Takahasi
2009-11-17 11:08 ` José Antonio Santos Cadenas
2009-12-05 16:25 ` Marcel Holtmann
2009-12-10 10:49 ` José Antonio Santos Cadenas
2009-12-10 10:50 ` José Antonio Santos Cadenas
2009-12-10 21:59 ` Marcel Holtmann
2009-12-11 9:21 ` José Antonio Santos Cadenas
2009-12-11 18:32 ` Marcel Holtmann
2009-12-14 11:35 ` José Antonio Santos Cadenas [this message]
2009-12-14 20:25 ` Marcel Holtmann
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=200912141235.16872.jcaden@libresoft.es \
--to=jcaden@libresoft.es \
--cc=claudio.takahasi@openbossa.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=marcel@holtmann.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.