diff options
-rw-r--r-- | common/glib-helper.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/common/glib-helper.c b/common/glib-helper.c index 5938e654..be3f7a25 100644 --- a/common/glib-helper.c +++ b/common/glib-helper.c @@ -58,10 +58,41 @@ static void search_completed_cb(uint8_t type, uint16_t status, { struct search_context *ctxt = user_data; sdp_list_t *recs = NULL; + int scanned, seqlen = 0; + uint8_t dataType; + int err = 0; + + if (status || type != SDP_SVC_SEARCH_ATTR_RSP) { + err = -EPROTO; + goto done; + } + + scanned = sdp_extract_seqtype(rsp, &dataType, &seqlen); + if (!scanned || !seqlen) + goto done; + + rsp += scanned; + do { + sdp_record_t *rec; + int recsize; + + recsize = 0; + rec = sdp_extract_pdu(rsp, &recsize); + if (!rec) + break; + + if (!recsize) { + sdp_record_free(rec); + break; + } - /* FIXME: Extract the records */ + scanned += recsize; + rsp += recsize; - ctxt->cb(ctxt->user_data, recs, 0); + recs = sdp_list_append(recs, rec); + } while (scanned < size); +done: + ctxt->cb(ctxt->user_data, recs, err); search_context_cleanup(ctxt); } |