summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2006-08-29 17:16:12 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2006-08-29 17:16:12 +0000
commita68204dbb9f7cfee00d44315282124628ef4cded (patch)
tree8feb20792cba87865fc59b415674f817a1b3edea
parent250ed56dd4ec7aa5175b53304edc7db4524a5e72 (diff)
changed sdp error handling
-rw-r--r--hcid/dbus-error.c26
-rw-r--r--hcid/dbus-sdp.c12
-rw-r--r--hcid/dbus.h1
3 files changed, 35 insertions, 4 deletions
diff --git a/hcid/dbus-error.c b/hcid/dbus-error.c
index ef59272d..da8d166a 100644
--- a/hcid/dbus-error.c
+++ b/hcid/dbus-error.c
@@ -236,3 +236,29 @@ DBusHandlerResult error_service_search_in_progress(DBusConnection *conn, DBusMes
return error_in_progress(conn, msg, "Service search in progress");
}
+static const char *strsdperror(int err)
+{
+ switch (err) {
+ case SDP_INVALID_VERSION:
+ return "Invalid/unsupported SDP version";
+ case SDP_INVALID_RECORD_HANDLE:
+ return "Invalid Service Record Handle";
+ case SDP_INVALID_SYNTAX:
+ return "Invalid request syntax";
+ case SDP_INVALID_PDU_SIZE:
+ return "Invalid PDU size";
+ case SDP_INVALID_CSTATE:
+ return "Invalid Continuation State";
+ default:
+ return "Undefined error";
+ }
+}
+
+DBusHandlerResult error_sdp_failed(DBusConnection *conn, DBusMessage *msg, int err)
+{
+ const char *str = strsdperror(err);
+
+ return send_reply_and_unref(conn,
+ dbus_message_new_error(msg, ERROR_INTERFACE ".Failed", str));
+}
+
diff --git a/hcid/dbus-sdp.c b/hcid/dbus-sdp.c
index 15ef33c0..3bfe5a4d 100644
--- a/hcid/dbus-sdp.c
+++ b/hcid/dbus-sdp.c
@@ -504,13 +504,13 @@ static void search_completed_cb(uint8_t type, uint16_t err, uint8_t *rsp, size_t
if (!ctxt)
return;
- if (err) {
- error("SDP error: %s(%d)", strerror(err), err);
- error_failed(ctxt->conn, ctxt->rq, err);
+ if (type == SDP_ERROR_RSP) {
+ error_sdp_failed(ctxt->conn, ctxt->rq, err);
return;
}
- if (type != SDP_SVC_SEARCH_ATTR_RSP || !rsp) {
+ /* check response PDU ID */
+ if (type != SDP_SVC_SEARCH_ATTR_RSP) {
error("SDP error: %s(%d)", strerror(EPROTO), EPROTO);
error_failed(ctxt->conn, ctxt->rq, EPROTO);
return;
@@ -525,6 +525,10 @@ static void search_completed_cb(uint8_t type, uint16_t err, uint8_t *rsp, size_t
dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
DBUS_TYPE_STRING_AS_STRING, &array_iter);
+ /*
+ * FIXME: check rsp? How check for I/O error or wrong transaction id?
+ * check the type value(Zero) is not reasonable!
+ */
pdata = rsp;
scanned = sdp_extract_seqtype(pdata, &dataType, &seqlen);
diff --git a/hcid/dbus.h b/hcid/dbus.h
index 90d7b325..1467d6ca 100644
--- a/hcid/dbus.h
+++ b/hcid/dbus.h
@@ -182,6 +182,7 @@ DBusHandlerResult error_service_already_exists(DBusConnection *conn, DBusMessage
DBusHandlerResult error_service_does_not_exist(DBusConnection *conn, DBusMessage *msg);
DBusHandlerResult error_service_search_in_progress(DBusConnection *conn, DBusMessage *msg);
DBusHandlerResult error_connect_canceled(DBusConnection *conn, DBusMessage *msg);
+DBusHandlerResult error_sdp_failed(DBusConnection *conn, DBusMessage *msg, int err);
typedef void (*name_cb_t)(const char *name, void *user_data);