summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2008-11-19 00:35:11 +0200
committerJohan Hedberg <johan.hedberg@nokia.com>2008-11-19 00:35:11 +0200
commitc62bc3f70fcd6bf86c2145659fb9b010f5bd97dc (patch)
treeb4e14c84315da18916ad4b2f8db68cf5e3c40679
parent50b3be4b21fa9a4638204a4d70a6bb8e8a2c56c2 (diff)
Move set_limited_discoverable() from dbus-hci.c to adapter.c
The function was only used from within adapter.c so it makes sense to have it static inside adapter.c
-rw-r--r--src/adapter.c38
-rw-r--r--src/dbus-hci.c38
-rw-r--r--src/dbus-hci.h1
3 files changed, 38 insertions, 39 deletions
diff --git a/src/adapter.c b/src/adapter.c
index 7865c6b3..1f20cb40 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -449,6 +449,44 @@ static struct bonding_request_info *bonding_request_new(DBusConnection *conn,
return bonding;
}
+static int set_limited_discoverable(int dd, const uint8_t *cls, gboolean limited)
+{
+ uint32_t dev_class;
+ int num = (limited ? 2 : 1);
+ uint8_t lap[] = { 0x33, 0x8b, 0x9e, 0x00, 0x8b, 0x9e };
+ /*
+ * 1: giac
+ * 2: giac + liac
+ */
+ if (hci_write_current_iac_lap(dd, num, lap, HCI_REQ_TIMEOUT) < 0) {
+ int err = errno;
+ error("Can't write current IAC LAP: %s(%d)",
+ strerror(err), err);
+ return -err;
+ }
+
+ if (limited) {
+ if (cls[1] & 0x20)
+ return 0; /* Already limited */
+
+ dev_class = (cls[2] << 16) | ((cls[1] | 0x20) << 8) | cls[0];
+ } else {
+ if (!(cls[1] & 0x20))
+ return 0; /* Already clear */
+
+ dev_class = (cls[2] << 16) | ((cls[1] & 0xdf) << 8) | cls[0];
+ }
+
+ if (hci_write_class_of_dev(dd, dev_class, HCI_REQ_TIMEOUT) < 0) {
+ int err = errno;
+ error("Can't write class of device: %s (%d)",
+ strerror(err), err);
+ return -err;
+ }
+
+ return 0;
+}
+
static const char *mode2str(uint8_t mode)
{
switch(mode) {
diff --git a/src/dbus-hci.c b/src/dbus-hci.c
index 23c59414..1359d9af 100644
--- a/src/dbus-hci.c
+++ b/src/dbus-hci.c
@@ -1244,44 +1244,6 @@ void hcid_dbus_disconn_complete(bdaddr_t *local, uint8_t status,
}
}
-int set_limited_discoverable(int dd, const uint8_t *cls, gboolean limited)
-{
- uint32_t dev_class;
- int num = (limited ? 2 : 1);
- uint8_t lap[] = { 0x33, 0x8b, 0x9e, 0x00, 0x8b, 0x9e };
- /*
- * 1: giac
- * 2: giac + liac
- */
- if (hci_write_current_iac_lap(dd, num, lap, HCI_REQ_TIMEOUT) < 0) {
- int err = errno;
- error("Can't write current IAC LAP: %s(%d)",
- strerror(err), err);
- return -err;
- }
-
- if (limited) {
- if (cls[1] & 0x20)
- return 0; /* Already limited */
-
- dev_class = (cls[2] << 16) | ((cls[1] | 0x20) << 8) | cls[0];
- } else {
- if (!(cls[1] & 0x20))
- return 0; /* Already clear */
-
- dev_class = (cls[2] << 16) | ((cls[1] & 0xdf) << 8) | cls[0];
- }
-
- if (hci_write_class_of_dev(dd, dev_class, HCI_REQ_TIMEOUT) < 0) {
- int err = errno;
- error("Can't write class of device: %s (%d)",
- strerror(err), err);
- return -err;
- }
-
- return 0;
-}
-
int set_service_classes(int dd, const uint8_t *cls, uint8_t value)
{
uint32_t dev_class;
diff --git a/src/dbus-hci.h b/src/dbus-hci.h
index 17fd39d3..20336f90 100644
--- a/src/dbus-hci.h
+++ b/src/dbus-hci.h
@@ -52,7 +52,6 @@ DBusMessage *new_authentication_return(DBusMessage *msg, uint8_t status);
int cancel_discovery(struct btd_adapter *adapter);
int cancel_periodic_discovery(struct btd_adapter *adapter);
-int set_limited_discoverable(int dd, const uint8_t *cls, gboolean limited);
int set_service_classes(int dd, const uint8_t *cls, uint8_t value);
int set_major_class(int dd, const uint8_t *cls, uint8_t major);
int set_minor_class(int dd, const uint8_t *cls, uint8_t minor);