summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hcid/dbus-rfcomm.c3
-rw-r--r--hcid/dbus-sdp.c3
-rw-r--r--hcid/dbus.c38
-rw-r--r--hcid/hcid.h4
-rw-r--r--hcid/main.c13
5 files changed, 44 insertions, 17 deletions
diff --git a/hcid/dbus-rfcomm.c b/hcid/dbus-rfcomm.c
index 6b5912d8..a7d7cbc1 100644
--- a/hcid/dbus-rfcomm.c
+++ b/hcid/dbus-rfcomm.c
@@ -702,6 +702,9 @@ DBusHandlerResult handle_rfcomm_method(DBusConnection *conn, DBusMessage *msg,
{
service_handler_func_t handler;
+ if (!hcid_dbus_use_experimental())
+ return error_unknown_method(conn, msg);
+
if (!data) {
error("RFCOMM method called with NULL data pointer!");
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
diff --git a/hcid/dbus-sdp.c b/hcid/dbus-sdp.c
index c31512dc..ea861823 100644
--- a/hcid/dbus-sdp.c
+++ b/hcid/dbus-sdp.c
@@ -1066,6 +1066,9 @@ DBusHandlerResult handle_sdp_method(DBusConnection *conn, DBusMessage *msg, void
{
service_handler_func_t handler;
+ if (!hcid_dbus_use_experimental())
+ return error_unknown_method(conn, msg);
+
handler = find_service_handler(sdp_services, msg);
if (handler)
diff --git a/hcid/dbus.c b/hcid/dbus.c
index 13368b04..316fa267 100644
--- a/hcid/dbus.c
+++ b/hcid/dbus.c
@@ -49,9 +49,21 @@ static DBusConnection *connection;
static int default_dev = -1;
+static int experimental = 0;
+
#define MAX_CONN_NUMBER 10
#define RECONNECT_RETRY_TIMEOUT 5000
+void hcid_dbus_set_experimental(void)
+{
+ experimental = 1;
+}
+
+int hcid_dbus_use_experimental(void)
+{
+ return experimental;
+}
+
void disc_device_info_free(void *data, void *user_data)
{
struct discovered_dev_info *dev = data;
@@ -209,22 +221,22 @@ static DBusMessage *dbus_msg_new_authentication_return(DBusMessage *msg, uint8_t
case 0x22: /* LMP response timeout */
case 0x28: /* instant passed - is this a timeout? */
return dbus_message_new_error(msg, ERROR_INTERFACE".AuthenticationTimeout",
- "Authentication Timeout");
+ "Authentication Timeout");
case 0x17: /* too frequent pairing attempts */
return dbus_message_new_error(msg, ERROR_INTERFACE".RepeatedAttemps",
- "Repeated Attempts");
+ "Repeated Attempts");
case 0x18: /* pairing not allowed (e.g. gw rejected attempt) */
return dbus_message_new_error(msg, ERROR_INTERFACE".AuthenticationRejected",
- "Authentication Rejected");
-
+ "Authentication Rejected");
+
case 0x07: /* memory capacity */
case 0x09: /* connection limit */
case 0x0a: /* synchronous connection limit */
case 0x0d: /* limited resources */
case 0x14: /* terminated due to low resources */
return dbus_message_new_error(msg, ERROR_INTERFACE".AuthenticationCanceled",
- "Authentication Canceled");
+ "Authentication Canceled");
case 0x05: /* authentication failure */
case 0x06: /* pin missing */
@@ -235,7 +247,7 @@ static DBusMessage *dbus_msg_new_authentication_return(DBusMessage *msg, uint8_t
case 0x2f: /* insufficient security - is this auth failure? */
default:
return dbus_message_new_error(msg, ERROR_INTERFACE".AuthenticationFailed",
- "Authentication Failed");
+ "Authentication Failed");
}
}
@@ -1324,7 +1336,7 @@ static void watch_toggled(DBusWatch *watch, void *data)
remove_watch(watch, data);
}
-gboolean hcid_dbus_init(void)
+int hcid_dbus_init(void)
{
int ret_val;
DBusError err;
@@ -1336,7 +1348,7 @@ gboolean hcid_dbus_init(void)
if (dbus_error_is_set(&err)) {
error("Can't open system message bus connection: %s", err.message);
dbus_error_free(&err);
- return FALSE;
+ return -1;
}
dbus_connection_set_exit_on_disconnect(connection, FALSE);
@@ -1345,27 +1357,27 @@ gboolean hcid_dbus_init(void)
if (ret_val != DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER ) {
error("Service could not become the primary owner.");
- return FALSE;
+ return -1;
}
if (dbus_error_is_set(&err)) {
error("Can't get system message bus name: %s", err.message);
dbus_error_free(&err);
- return FALSE;
+ return -1;
}
if (!register_dbus_path(BASE_PATH, INVALID_DEV_ID, &obj_mgr_vtable, TRUE))
- return FALSE;
+ return -1;
if (!dbus_connection_add_filter(connection, hci_dbus_signal_filter, NULL, NULL)) {
error("Can't add new HCI filter");
- return FALSE;
+ return -1;
}
dbus_connection_set_watch_functions(connection,
add_watch, remove_watch, watch_toggled, NULL, NULL);
- return TRUE;
+ return 0;
}
void hcid_dbus_exit(void)
diff --git a/hcid/hcid.h b/hcid/hcid.h
index d1c69c1d..0b27a34d 100644
--- a/hcid/hcid.h
+++ b/hcid/hcid.h
@@ -142,8 +142,10 @@ void toggle_pairing(int enable);
void set_pin_length(bdaddr_t *sba, int length);
-gboolean hcid_dbus_init(void);
+int hcid_dbus_init(void);
void hcid_dbus_exit(void);
+void hcid_dbus_set_experimental();
+int hcid_dbus_use_experimental();
gboolean hcid_dbus_register_device(uint16_t id);
gboolean hcid_dbus_unregister_device(uint16_t id);
gboolean hcid_dbus_dev_up(uint16_t id);
diff --git a/hcid/main.c b/hcid/main.c
index 86a4a773..757d436f 100644
--- a/hcid/main.c
+++ b/hcid/main.c
@@ -654,7 +654,7 @@ int main(int argc, char *argv[])
struct hci_filter flt;
struct sigaction sa;
GIOChannel *ctl_io;
- int opt, daemonize = 1, sdp = 0;
+ int opt, daemonize = 1, sdp = 0, experimental = 0;
/* Default HCId settings */
memset(&hcid, 0, sizeof(hcid));
@@ -671,7 +671,7 @@ int main(int argc, char *argv[])
init_defaults();
- while ((opt = getopt(argc, argv, "nsf:")) != EOF) {
+ while ((opt = getopt(argc, argv, "nsxf:")) != EOF) {
switch (opt) {
case 'n':
daemonize = 0;
@@ -681,6 +681,10 @@ int main(int argc, char *argv[])
sdp = 1;
break;
+ case 'x':
+ experimental = 1;
+ break;
+
case 'f':
hcid.config_file = strdup(optarg);
break;
@@ -744,11 +748,14 @@ int main(int argc, char *argv[])
init_devices();
- if (hcid_dbus_init() == FALSE) {
+ if (hcid_dbus_init() < 0) {
error("Unable to get on D-Bus");
exit(1);
}
+ if (experimental)
+ hcid_dbus_set_experimental();
+
init_security_data();
/* Create event loop */