summaryrefslogtreecommitdiffstats
path: root/hcid/dbus-adapter.c
diff options
context:
space:
mode:
Diffstat (limited to 'hcid/dbus-adapter.c')
-rw-r--r--hcid/dbus-adapter.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/hcid/dbus-adapter.c b/hcid/dbus-adapter.c
index c2564fe6..81e48cc9 100644
--- a/hcid/dbus-adapter.c
+++ b/hcid/dbus-adapter.c
@@ -870,23 +870,9 @@ static DBusHandlerResult handle_dev_set_minor_class_req(DBusConnection *conn, DB
return error_invalid_arguments(conn, msg);
}
- /* FIXME: check if the major class is computer. If not, return UnsupportedMajorClass */
-
if (!minor)
return error_invalid_arguments(conn, msg);
- /* FIXME: currently, only computer minor classes are allowed */
- for (i = 0; i < sizeof(computer_minor_cls) / sizeof(*computer_minor_cls); i++)
- if (!strcasecmp(minor, computer_minor_cls[i])) {
- /* Remove the format type */
- dev_class = i << 2;
- break;
- }
-
- /* Check if it's a valid minor class */
- if (dev_class == 0xFFFFFFFF)
- return error_invalid_arguments(conn, msg);
-
dd = hci_open_dev(dbus_data->dev_id);
if (dd < 0)
return error_no_such_adapter(conn, msg);
@@ -899,12 +885,27 @@ static DBusHandlerResult handle_dev_set_minor_class_req(DBusConnection *conn, DB
return error_failed(conn, msg, err);
}
- dev_class |= (cls[2] << 16) | (cls[1] << 8);
+ /* Currently, only computer major class is supported */
+ if ((cls[1] & 0x1f) != 1)
+ return error_unsupported_major_class(conn, msg);
+
+ for (i = 0; i < sizeof(computer_minor_cls) / sizeof(*computer_minor_cls); i++)
+ if (!strcasecmp(minor, computer_minor_cls[i])) {
+ /* Remove the format type */
+ dev_class = i << 2;
+ break;
+ }
- cls[2] = 0x00; /* no service classes */
- cls[1] = 0x01; /* major class computer */
+ /* Check if it's a valid minor class */
+ if (dev_class == 0xFFFFFFFF)
+ return error_invalid_arguments(conn, msg);
+
+ /* update the minor class before store */
cls[0] = (dev_class & 0xff);
+ /* set the service class and major class */
+ dev_class |= (cls[2] << 16) | (cls[1] << 8);
+
hci_devba(dbus_data->dev_id, &bdaddr);
write_local_class(&bdaddr, cls);