diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2006-11-17 13:01:49 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2006-11-17 13:01:49 +0000 |
commit | f3fc1efa4cbab8d6d107c6523d465d39c52e02c2 (patch) | |
tree | a1202863a973e8ab848c77c40ef0cc0970f35856 /sdpd | |
parent | 914bf7ce2fcc811ea8561c30e7a43394d8834555 (diff) | |
download | bluez-f3fc1efa4cbab8d6d107c6523d465d39c52e02c2.tar.gz |
Use common logging functions
Diffstat (limited to 'sdpd')
-rw-r--r-- | sdpd/Makefile.am | 3 | ||||
-rw-r--r-- | sdpd/main.c | 35 | ||||
-rw-r--r-- | sdpd/request.c | 106 | ||||
-rw-r--r-- | sdpd/sdpd.h | 9 | ||||
-rw-r--r-- | sdpd/service.c | 38 | ||||
-rw-r--r-- | sdpd/servicedb.c | 18 |
6 files changed, 101 insertions, 108 deletions
diff --git a/sdpd/Makefile.am b/sdpd/Makefile.am index a82c27566..226d1f5cd 100644 --- a/sdpd/Makefile.am +++ b/sdpd/Makefile.am @@ -2,7 +2,8 @@ sbin_PROGRAMS = sdpd sdpd_SOURCES = main.c request.c service.c cstate.c servicedb.c sdpd.h -sdpd_LDADD = @BLUEZ_LIBS@ + +sdpd_LDADD = @BLUEZ_LIBS@ $(top_builddir)/common/libhelper.a AM_CFLAGS = @BLUEZ_CFLAGS@ diff --git a/sdpd/main.c b/sdpd/main.c index 5bb86951f..c21380cd7 100644 --- a/sdpd/main.c +++ b/sdpd/main.c @@ -33,10 +33,8 @@ #include <unistd.h> #include <stdlib.h> #include <signal.h> -#include <syslog.h> #include <getopt.h> #include <sys/stat.h> -#include <sys/ioctl.h> #include <sys/socket.h> #define _XOPEN_SOURCE 600 @@ -51,6 +49,7 @@ #include <netinet/in.h> #include "sdpd.h" +#include "logging.h" static int l2cap_sock, unix_sock; static fd_set active_fdset; @@ -242,7 +241,7 @@ static int init_server(uint16_t mtu, int master, int public) /* Create L2CAP socket */ l2cap_sock = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP); if (l2cap_sock < 0) { - SDPERR("opening L2CAP socket: %s", strerror(errno)); + error("opening L2CAP socket: %s", strerror(errno)); return -1; } @@ -250,14 +249,14 @@ static int init_server(uint16_t mtu, int master, int public) l2addr.l2_family = AF_BLUETOOTH; l2addr.l2_psm = htobs(SDP_PSM); if (bind(l2cap_sock, (struct sockaddr *)&l2addr, sizeof(l2addr)) < 0) { - SDPERR("binding L2CAP socket: %s", strerror(errno)); + error("binding L2CAP socket: %s", strerror(errno)); return -1; } if (master) { int opt = L2CAP_LM_MASTER; if (setsockopt(l2cap_sock, SOL_L2CAP, L2CAP_LM, &opt, sizeof(opt)) < 0) { - SDPERR("setsockopt: %s", strerror(errno)); + error("setsockopt: %s", strerror(errno)); return -1; } } @@ -267,14 +266,14 @@ static int init_server(uint16_t mtu, int master, int public) optlen = sizeof(opts); if (getsockopt(l2cap_sock, SOL_L2CAP, L2CAP_OPTIONS, &opts, &optlen) < 0) { - SDPERR("getsockopt: %s", strerror(errno)); + error("getsockopt: %s", strerror(errno)); return -1; } opts.imtu = mtu; if (setsockopt(l2cap_sock, SOL_L2CAP, L2CAP_OPTIONS, &opts, sizeof(opts)) < 0) { - SDPERR("setsockopt: %s", strerror(errno)); + error("setsockopt: %s", strerror(errno)); return -1; } } @@ -286,7 +285,7 @@ static int init_server(uint16_t mtu, int master, int public) /* Create local Unix socket */ unix_sock = socket(PF_UNIX, SOCK_STREAM, 0); if (unix_sock < 0) { - SDPERR("opening UNIX socket: %s", strerror(errno)); + error("opening UNIX socket: %s", strerror(errno)); return -1; } @@ -294,7 +293,7 @@ static int init_server(uint16_t mtu, int master, int public) strcpy(unaddr.sun_path, SDP_UNIX_PATH); unlink(unaddr.sun_path); if (bind(unix_sock, (struct sockaddr *)&unaddr, sizeof(unaddr)) < 0) { - SDPERR("binding UNIX socket: %s", strerror(errno)); + error("binding UNIX socket: %s", strerror(errno)); return -1; } @@ -308,7 +307,7 @@ static int init_server(uint16_t mtu, int master, int public) static void sig_term(int sig) { - SDPINF("terminating... \n"); + info("terminating... \n"); sdp_svcdb_reset(); close(l2cap_sock); close(unix_sock); @@ -354,7 +353,7 @@ static inline void handle_request(int sk, uint8_t *data, int len) static void close_sock(int fd, int r) { if (r < 0) - SDPERR("Read error: %s", strerror(errno)); + error("Read error: %s", strerror(errno)); FD_CLR(fd, &active_fdset); close(fd); sdp_svcdb_collect_all(fd); @@ -436,10 +435,14 @@ int main(int argc, char *argv[]) exit(0); } - openlog("sdpd", LOG_PID | LOG_NDELAY, LOG_DAEMON); + start_logging("sdpd", "Bluetooth SDP daemon"); + +#ifdef SDP_DEBUG + enable_debug(); +#endif if (daemonize && daemon(0, 0)) { - SDPERR("Server startup failed: %s (%d)", strerror(errno), errno); + error("Server startup failed: %s (%d)", strerror(errno), errno); return -1; } @@ -447,12 +450,10 @@ int main(int argc, char *argv[]) argv += optind; if (init_server(mtu, master, public) < 0) { - SDPERR("Server initialization failed"); + error("Server initialization failed"); return -1; } - SDPINF("Bluetooth SDP daemon"); - signal(SIGINT, sig_term); signal(SIGTERM, sig_term); signal(SIGABRT, sig_term); @@ -475,7 +476,7 @@ int main(int argc, char *argv[]) num = pselect(active_maxfd + 1, &mask, NULL, NULL, NULL, &sigs); if (num <= 0) { - SDPDBG("Select error:%s", strerror(errno)); + debug("Select error:%s", strerror(errno)); goto exit; } diff --git a/sdpd/request.c b/sdpd/request.c index 0c80d5a9c..fbcbaa8cb 100644 --- a/sdpd/request.c +++ b/sdpd/request.c @@ -31,7 +31,6 @@ #include <stdio.h> #include <errno.h> #include <malloc.h> -#include <syslog.h> #include <sys/socket.h> #include <bluetooth/bluetooth.h> @@ -41,6 +40,7 @@ #include <netinet/in.h> #include "sdpd.h" +#include "logging.h" #define MIN(x, y) ((x) < (y))? (x): (y) @@ -67,28 +67,28 @@ static int extract_des(uint8_t *buf, int len, sdp_list_t **svcReqSeq, uint8_t *p scanned = sdp_extract_seqtype(buf, &seqType, &data_size); - SDPDBG("Seq type : %d\n", seqType); + debug("Seq type : %d\n", seqType); if (!scanned || (seqType != SDP_SEQ8 && seqType != SDP_SEQ16)) { - SDPERR("Unknown seq type \n"); + error("Unknown seq type \n"); return -1; } p = buf + scanned; - SDPDBG("Data size : %d\n", data_size); + debug("Data size : %d\n", data_size); for (;;) { char *pElem = NULL; int localSeqLength = 0; dataType = *(uint8_t *)p; - SDPDBG("Data type: 0x%02x\n", dataType); + debug("Data type: 0x%02x\n", dataType); if (expectedType == SDP_TYPE_UUID) { if (dataType != SDP_UUID16 && dataType != SDP_UUID32 && dataType != SDP_UUID128) { - SDPDBG("->Unexpected Data type (expected UUID_ANY)\n"); + debug("->Unexpected Data type (expected UUID_ANY)\n"); return -1; } } else if (expectedType != SDP_TYPE_ANY && dataType != expectedType) { - SDPDBG("->Unexpected Data type (expected 0x%02x)\n", expectedType); + debug("->Unexpected Data type (expected 0x%02x)\n", expectedType); return -1; } @@ -125,7 +125,7 @@ static int extract_des(uint8_t *buf, int len, sdp_list_t **svcReqSeq, uint8_t *p if (status == 0) { pSeq = sdp_list_append(pSeq, pElem); numberOfElements++; - SDPDBG("No of elements : %d\n", numberOfElements); + debug("No of elements : %d\n", numberOfElements); if (seqlen == data_size) break; @@ -146,7 +146,7 @@ static int sdp_set_cstate_pdu(sdp_buf_t *buf, sdp_cont_state_t *cstate) int length = 0; if (cstate) { - SDPDBG("Non null sdp_cstate_t id : 0x%lx\n", cstate->timestamp); + debug("Non null sdp_cstate_t id : 0x%lx\n", cstate->timestamp); *(uint8_t *)pdata = sizeof(sdp_cont_state_t); pdata += sizeof(uint8_t); length += sizeof(uint8_t); @@ -171,13 +171,13 @@ static sdp_cont_state_t *sdp_cstate_get(uint8_t *buffer) * Check if continuation state exists, if yes attempt * to get response remainder from cache, else send error */ - SDPDBG("Continuation State size : %d\n", cStateSize); + debug("Continuation State size : %d\n", cStateSize); pdata += sizeof(uint8_t); if (cStateSize != 0) { sdp_cont_state_t *cstate = (sdp_cont_state_t *)pdata; - SDPDBG("Cstate TS : 0x%lx\n", cstate->timestamp); - SDPDBG("Bytes sent : %d\n", cstate->cStateValue.maxBytesSent); + debug("Cstate TS : 0x%lx\n", cstate->timestamp); + debug("Bytes sent : %d\n", cstate->cStateValue.maxBytesSent); return cstate; } return NULL; @@ -203,7 +203,7 @@ static int sdp_match_uuid(sdp_list_t *search, sdp_list_t *pattern) */ int patlen = sdp_list_len(pattern); - SDPDBG(""); + debug(""); if (patlen < sdp_list_len(search)) return -1; @@ -243,7 +243,7 @@ static int service_search_req(sdp_req_t *req, sdp_buf_t *buf) short *pTotalRecordCount, *pCurrentRecordCount; uint8_t *pdata = req->buf + sizeof(sdp_pdu_hdr_t); - SDPDBG(""); + debug(""); scanned = extract_des(pdata, req->len - sizeof(sdp_pdu_hdr_t), &pattern, &dtd, SDP_TYPE_UUID); @@ -264,8 +264,8 @@ static int service_search_req(sdp_req_t *req, sdp_buf_t *buf) expected = ntohs(sdp_get_unaligned((uint16_t *)pdata)); - SDPDBG("Expected count: %d\n", expected); - SDPDBG("Bytes scanned : %d\n", scanned); + debug("Expected count: %d\n", expected); + debug("Bytes scanned : %d\n", scanned); pdata += sizeof(uint16_t); @@ -301,7 +301,7 @@ static int service_search_req(sdp_req_t *req, sdp_buf_t *buf) for (; list && rsp_count < expected; list = list->next) { sdp_record_t *rec = (sdp_record_t *) list->data; - SDPDBG("Checking svcRec : 0x%x\n", rec->handle); + debug("Checking svcRec : 0x%x\n", rec->handle); if (sdp_match_uuid(pattern, rec->pattern) > 0 && sdp_check_access(rec->handle, &req->device)) { @@ -312,7 +312,7 @@ static int service_search_req(sdp_req_t *req, sdp_buf_t *buf) } } - SDPDBG("Match count: %d\n", rsp_count); + debug("Match count: %d\n", rsp_count); buf->data_size += handleSize; sdp_put_unaligned(htons(rsp_count), (uint16_t *)pTotalRecordCount); @@ -394,7 +394,7 @@ static int service_search_req(sdp_req_t *req, sdp_buf_t *buf) */ sdp_cont_state_t newState; - SDPDBG("Setting non-NULL sdp_cstate_t\n"); + debug("Setting non-NULL sdp_cstate_t\n"); if (cstate) memcpy((char *)&newState, cstate, sizeof(sdp_cont_state_t)); @@ -428,13 +428,13 @@ static int extract_attrs(sdp_record_t *rec, sdp_list_t *seq, uint8_t dtd, sdp_bu #ifdef SDP_DEBUG if (seq) - SDPDBG("Entries in attr seq : %d\n", sdp_list_len(seq)); + debug("Entries in attr seq : %d\n", sdp_list_len(seq)); else - SDPDBG("NULL attribute descriptor\n"); - SDPDBG("AttrDataType : %d\n", dtd); + debug("NULL attribute descriptor\n"); + debug("AttrDataType : %d\n", dtd); #endif if (seq == NULL) { - SDPDBG("Attribute sequence is NULL\n"); + debug("Attribute sequence is NULL\n"); return 0; } if (dtd == SDP_UINT16) @@ -454,9 +454,9 @@ static int extract_attrs(sdp_record_t *rec, sdp_list_t *seq, uint8_t dtd, sdp_bu uint16_t high = 0x0000ffff & range; sdp_data_t *data; - SDPDBG("attr range : 0x%x\n", range); - SDPDBG("Low id : 0x%x\n", low); - SDPDBG("High id : 0x%x\n", high); + debug("attr range : 0x%x\n", range); + debug("Low id : 0x%x\n", low); + debug("High id : 0x%x\n", high); if (low == 0x0000 && high == 0xffff && pdu.data_size <= buf->buf_size) { /* copy it */ @@ -476,8 +476,8 @@ static int extract_attrs(sdp_record_t *rec, sdp_list_t *seq, uint8_t dtd, sdp_bu } free(pdu.data); } else { - SDPERR("Unexpected data type : 0x%x\n", dtd); - SDPERR("Expect uint16_t or uint32_t\n"); + error("Unexpected data type : 0x%x\n", dtd); + error("Expect uint16_t or uint32_t\n"); return SDP_INVALID_SYNTAX; } return 0; @@ -502,7 +502,7 @@ static int service_attr_req(sdp_req_t *req, sdp_buf_t *buf) uint8_t *pdata = req->buf + sizeof(sdp_pdu_hdr_t); uint32_t handle = ntohl(sdp_get_unaligned((uint32_t *)pdata)); - SDPDBG(""); + debug(""); pdata += sizeof(uint32_t); max_rsp_size = ntohs(sdp_get_unaligned((uint16_t *)pdata)); @@ -531,8 +531,8 @@ static int service_attr_req(sdp_req_t *req, sdp_buf_t *buf) */ cstate = sdp_cstate_get(pdata); - SDPDBG("SvcRecHandle : 0x%x\n", handle); - SDPDBG("max_rsp_size : %d\n", max_rsp_size); + debug("SvcRecHandle : 0x%x\n", handle); + debug("max_rsp_size : %d\n", max_rsp_size); /* * Calculate Attribute size acording to MTU @@ -548,7 +548,7 @@ static int service_attr_req(sdp_req_t *req, sdp_buf_t *buf) if (cstate) { sdp_buf_t *pCache = sdp_get_cached_rsp(cstate); - SDPDBG("Obtained cached rsp : %p\n", pCache); + debug("Obtained cached rsp : %p\n", pCache); if (pCache) { short sent = MIN(max_rsp_size, pCache->data_size - cstate->cStateValue.maxBytesSent); @@ -557,7 +557,7 @@ static int service_attr_req(sdp_req_t *req, sdp_buf_t *buf) buf->data_size += sent; cstate->cStateValue.maxBytesSent += sent; - SDPDBG("Response size : %d sending now : %d bytes sent so far : %d\n", + debug("Response size : %d sending now : %d bytes sent so far : %d\n", pCache->data_size, sent, cstate->cStateValue.maxBytesSent); if (cstate->cStateValue.maxBytesSent == pCache->data_size) cstate_size = sdp_set_cstate_pdu(buf, NULL); @@ -565,7 +565,7 @@ static int service_attr_req(sdp_req_t *req, sdp_buf_t *buf) cstate_size = sdp_set_cstate_pdu(buf, cstate); } else { status = SDP_INVALID_CSTATE; - SDPERR("NULL cache buffer and non-NULL continuation state\n"); + error("NULL cache buffer and non-NULL continuation state\n"); } } else { sdp_record_t *rec = sdp_record_find(handle); @@ -579,7 +579,7 @@ static int service_attr_req(sdp_req_t *req, sdp_buf_t *buf) * Reset the buffer size to the maximum expected and * set the sdp_cont_state_t */ - SDPDBG("Creating continuation state of size : %d\n", buf->data_size); + debug("Creating continuation state of size : %d\n", buf->data_size); buf->data_size = max_rsp_size; newState.cStateValue.maxBytesSent = max_rsp_size; cstate_size = sdp_set_cstate_pdu(buf, &newState); @@ -630,13 +630,13 @@ static int service_search_attr_req(sdp_req_t *req, sdp_buf_t *buf) } totscanned = scanned; - SDPDBG("Bytes scanned: %d", scanned); + debug("Bytes scanned: %d", scanned); pdata += scanned; max = ntohs(sdp_get_unaligned((uint16_t *)pdata)); pdata += sizeof(uint16_t); - SDPDBG("Max Attr expected: %d", max); + debug("Max Attr expected: %d", max); /* extract the attribute list */ scanned = extract_des(pdata, req->len - sizeof(sdp_pdu_hdr_t), @@ -687,10 +687,10 @@ static int service_search_attr_req(sdp_req_t *req, sdp_buf_t *buf) rsp_count++; status = extract_attrs(rec, seq, dtd, &tmpbuf); - SDPDBG("Response count : %d\n", rsp_count); - SDPDBG("Local PDU size : %d\n", tmpbuf.data_size); + debug("Response count : %d\n", rsp_count); + debug("Local PDU size : %d\n", tmpbuf.data_size); if (status) { - SDPDBG("Extract attr from record returns err\n"); + debug("Extract attr from record returns err\n"); break; } if (buf->data_size + tmpbuf.data_size < buf->buf_size) { @@ -699,10 +699,10 @@ static int service_search_attr_req(sdp_req_t *req, sdp_buf_t *buf) tmpbuf.data_size = 0; memset(tmpbuf.data, 0, USHRT_MAX); } else { - SDPERR("Relocation needed\n"); + error("Relocation needed\n"); break; } - SDPDBG("Net PDU size : %d\n", buf->data_size); + debug("Net PDU size : %d\n", buf->data_size); } } if (buf->data_size > max) { @@ -734,7 +734,7 @@ static int service_search_attr_req(sdp_req_t *req, sdp_buf_t *buf) cstate_size = sdp_set_cstate_pdu(buf, cstate); } else { status = SDP_INVALID_CSTATE; - SDPDBG("Non-null continuation state, but null cache buffer\n"); + debug("Non-null continuation state, but null cache buffer\n"); } } @@ -779,7 +779,7 @@ void process_request(sdp_req_t *req) int sent = 0; int status = SDP_INVALID_SYNTAX; - SDPDBG(""); + debug(""); memset(buf, 0, USHRT_MAX); rsp.data = buf + sizeof(sdp_pdu_hdr_t); @@ -793,44 +793,44 @@ void process_request(sdp_req_t *req) } switch (reqhdr->pdu_id) { case SDP_SVC_SEARCH_REQ: - SDPDBG("Got a svc srch req\n"); + debug("Got a svc srch req\n"); status = service_search_req(req, &rsp); rsphdr->pdu_id = SDP_SVC_SEARCH_RSP; break; case SDP_SVC_ATTR_REQ: - SDPDBG("Got a svc attr req\n"); + debug("Got a svc attr req\n"); status = service_attr_req(req, &rsp); rsphdr->pdu_id = SDP_SVC_ATTR_RSP; break; case SDP_SVC_SEARCH_ATTR_REQ: - SDPDBG("Got a svc srch attr req\n"); + debug("Got a svc srch attr req\n"); status = service_search_attr_req(req, &rsp); rsphdr->pdu_id = SDP_SVC_SEARCH_ATTR_RSP; break; /* Following requests are allowed only for local connections */ case SDP_SVC_REGISTER_REQ: - SDPDBG("Service register request\n"); + debug("Service register request\n"); if (req->local) { status = service_register_req(req, &rsp); rsphdr->pdu_id = SDP_SVC_REGISTER_RSP; } break; case SDP_SVC_UPDATE_REQ: - SDPDBG("Service update request\n"); + debug("Service update request\n"); if (req->local) { status = service_update_req(req, &rsp); rsphdr->pdu_id = SDP_SVC_UPDATE_RSP; } break; case SDP_SVC_REMOVE_REQ: - SDPDBG("Service removal request\n"); + debug("Service removal request\n"); if (req->local) { status = service_remove_req(req, &rsp); rsphdr->pdu_id = SDP_SVC_REMOVE_RSP; } break; default: - SDPERR("Unknown PDU ID : 0x%x received\n", reqhdr->pdu_id); + error("Unknown PDU ID : 0x%x received\n", reqhdr->pdu_id); status = SDP_INVALID_SYNTAX; break; } @@ -842,7 +842,7 @@ send_rsp: rsp.data_size = sizeof(uint16_t); } - SDPDBG("Sending rsp. status %d", status); + debug("Sending rsp. status %d", status); rsphdr->tid = reqhdr->tid; rsphdr->plen = htons(rsp.data_size); @@ -854,7 +854,7 @@ send_rsp: /* stream the rsp PDU */ sent = send(req->sock, rsp.data, rsp.data_size, 0); - SDPDBG("Bytes Sent : %d\n", sent); + debug("Bytes Sent : %d\n", sent); free(rsp.data); free(req->buf); diff --git a/sdpd/sdpd.h b/sdpd/sdpd.h index e73936c3f..69c1446ee 100644 --- a/sdpd/sdpd.h +++ b/sdpd/sdpd.h @@ -27,15 +27,6 @@ #define sdp_get_unaligned bt_get_unaligned #define sdp_put_unaligned bt_put_unaligned -#define SDPINF(fmt, arg...) syslog(LOG_INFO, fmt "\n", ## arg) -#define SDPERR(fmt, arg...) syslog(LOG_ERR, "%s: " fmt "\n", __func__ , ## arg) - -#ifdef SDP_DEBUG -#define SDPDBG(fmt, arg...) syslog(LOG_DEBUG, "%s: " fmt "\n", __func__ , ## arg) -#else -#define SDPDBG(fmt...) -#endif - typedef struct request { bdaddr_t device; bdaddr_t bdaddr; diff --git a/sdpd/service.c b/sdpd/service.c index 781555fb6..276f4481b 100644 --- a/sdpd/service.c +++ b/sdpd/service.c @@ -30,7 +30,6 @@ #include <stdio.h> #include <errno.h> -#include <syslog.h> #include <sys/socket.h> #include <bluetooth/bluetooth.h> @@ -40,6 +39,7 @@ #include <netinet/in.h> #include "sdpd.h" +#include "logging.h" extern void update_db_timestamp(void); @@ -58,13 +58,13 @@ static sdp_record_t *extract_pdu_server(bdaddr_t *device, uint8_t *p, uint32_t h p += *scanned; lookAheadAttrId = ntohs(sdp_get_unaligned((uint16_t *) (p + sizeof(uint8_t)))); - SDPDBG("Look ahead attr id : %d\n", lookAheadAttrId); + debug("Look ahead attr id : %d\n", lookAheadAttrId); if (lookAheadAttrId == SDP_ATTR_RECORD_HANDLE) { handle = ntohl(sdp_get_unaligned((uint32_t *) (p + sizeof(uint8_t) + sizeof(uint16_t) + sizeof(uint8_t)))); - SDPDBG("SvcRecHandle : 0x%x\n", handle); + debug("SvcRecHandle : 0x%x\n", handle); rec = sdp_record_find(handle); } else if (handleExpected != 0xffffffff) rec = sdp_record_find(handleExpected); @@ -85,33 +85,33 @@ static sdp_record_t *extract_pdu_server(bdaddr_t *device, uint8_t *p, uint32_t h int attrSize = sizeof(uint8_t); int attrValueLength = 0; - SDPDBG("Extract PDU, sequenceLength: %d localExtractedLength: %d", seqlen, localExtractedLength); + debug("Extract PDU, sequenceLength: %d localExtractedLength: %d", seqlen, localExtractedLength); dtd = *(uint8_t *) p; attrId = ntohs(sdp_get_unaligned((uint16_t *) (p + attrSize))); attrSize += sizeof(uint16_t); - SDPDBG("DTD of attrId : %d Attr id : 0x%x \n", dtd, attrId); + debug("DTD of attrId : %d Attr id : 0x%x \n", dtd, attrId); pAttr = sdp_extract_attr(p + attrSize, &attrValueLength, rec); - SDPDBG("Attr id : 0x%x attrValueLength : %d\n", attrId, attrValueLength); + debug("Attr id : 0x%x attrValueLength : %d\n", attrId, attrValueLength); attrSize += attrValueLength; if (pAttr == NULL) { - SDPDBG("Terminating extraction of attributes"); + debug("Terminating extraction of attributes"); break; } localExtractedLength += attrSize; p += attrSize; sdp_attr_replace(rec, attrId, pAttr); extractStatus = 0; - SDPDBG("Extract PDU, seqLength: %d localExtractedLength: %d", + debug("Extract PDU, seqLength: %d localExtractedLength: %d", seqlen, localExtractedLength); } if (extractStatus == 0) { - SDPDBG("Successful extracting of Svc Rec attributes\n"); + debug("Successful extracting of Svc Rec attributes\n"); #ifdef SDP_DEBUG sdp_print_service_attr(rec->attrlist); #endif @@ -192,26 +192,26 @@ int service_update_req(sdp_req_t *req, sdp_buf_t *rsp) uint8_t *p = req->buf + sizeof(sdp_pdu_hdr_t); uint32_t handle = ntohl(sdp_get_unaligned((uint32_t *) p)); - SDPDBG(""); + debug(""); - SDPDBG("Svc Rec Handle: 0x%x\n", handle); + debug("Svc Rec Handle: 0x%x\n", handle); p += sizeof(uint32_t); orec = sdp_record_find(handle); - SDPDBG("SvcRecOld: 0x%x\n", (uint32_t)orec); + debug("SvcRecOld: %p\n", orec); if (orec) { sdp_record_t *nrec = extract_pdu_server(BDADDR_ANY, p, handle, &scanned); if (nrec && handle == nrec->handle) update_db_timestamp(); else { - SDPDBG("SvcRecHandle : 0x%x\n", handle); - SDPDBG("SvcRecHandleNew : 0x%x\n", nrec->handle); - SDPDBG("SvcRecNew : 0x%x\n", (uint32_t) nrec); - SDPDBG("SvcRecOld : 0x%x\n", (uint32_t) orec); - SDPDBG("Failure to update, restore old value\n"); + debug("SvcRecHandle : 0x%x\n", handle); + debug("SvcRecHandleNew : 0x%x\n", nrec->handle); + debug("SvcRecNew : %p\n", nrec); + debug("SvcRecOld : %p\n", orec); + debug("Failure to update, restore old value\n"); if (nrec) sdp_record_free(nrec); @@ -236,7 +236,7 @@ int service_remove_req(sdp_req_t *req, sdp_buf_t *rsp) sdp_record_t *rec; int status = 0; - SDPDBG(""); + debug(""); /* extract service record handle */ p += sizeof(uint32_t); @@ -250,7 +250,7 @@ int service_remove_req(sdp_req_t *req, sdp_buf_t *rsp) update_db_timestamp(); } else { status = SDP_INVALID_RECORD_HANDLE; - SDPDBG("Could not find record : 0x%x\n", handle); + debug("Could not find record : 0x%x\n", handle); } p = rsp->data; diff --git a/sdpd/servicedb.c b/sdpd/servicedb.c index 7e8b5d195..f433c5c39 100644 --- a/sdpd/servicedb.c +++ b/sdpd/servicedb.c @@ -31,7 +31,6 @@ #include <stdio.h> #include <errno.h> #include <malloc.h> -#include <syslog.h> #include <sys/socket.h> #include <bluetooth/bluetooth.h> @@ -40,6 +39,7 @@ #include <bluetooth/sdp_lib.h> #include "sdpd.h" +#include "logging.h" static sdp_list_t *service_db; static sdp_list_t *access_db; @@ -60,7 +60,7 @@ static int record_sort(const void *r1, const void *r2) const sdp_record_t *rec2 = (const sdp_record_t *) r2; if (!rec1 || !rec2) { - SDPERR("NULL RECORD LIST FATAL\n"); + error("NULL RECORD LIST FATAL\n"); return -1; } @@ -73,7 +73,7 @@ static int access_sort(const void *r1, const void *r2) const sdp_access_t *rec2 = (const sdp_access_t *) r2; if (!rec1 || !rec2) { - SDPERR("NULL RECORD LIST FATAL\n"); + error("NULL RECORD LIST FATAL\n"); return -1; } @@ -170,8 +170,8 @@ void sdp_record_add(bdaddr_t *device, sdp_record_t *rec) sdp_access_t *dev; #ifdef SDP_DEBUG - SDPDBG("Adding rec : 0x%lx\n", (long) rec); - SDPDBG("with handle : 0x%x\n", rec->handle); + debug("Adding rec : 0x%lx\n", (long) rec); + debug("with handle : 0x%x\n", rec->handle); #endif service_db = sdp_list_insert_sorted(service_db, rec, record_sort); @@ -196,7 +196,7 @@ static sdp_list_t *record_locate(uint32_t handle) return p; } - SDPDBG("Could not find svcRec for : 0x%x\n", handle); + debug("Could not find svcRec for : 0x%x\n", handle); return NULL; } @@ -211,7 +211,7 @@ static sdp_list_t *access_locate(uint32_t handle) return p; } - SDPDBG("Could not find access data for : 0x%x\n", handle); + debug("Could not find access data for : 0x%x\n", handle); return NULL; } @@ -223,7 +223,7 @@ sdp_record_t *sdp_record_find(uint32_t handle) sdp_list_t *p = record_locate(handle); if (!p) { - SDPDBG("Couldn't find record for : 0x%x\n", handle); + debug("Couldn't find record for : 0x%x\n", handle); return 0; } @@ -240,7 +240,7 @@ int sdp_record_remove(uint32_t handle) sdp_access_t *a; if (!p) { - SDPERR("Remove : Couldn't find record for : 0x%x\n", handle); + error("Remove : Couldn't find record for : 0x%x\n", handle); return -1; } |