* [PATCH v2 8/8] sdp: Decouple Device ID profile implementation
From: Szymon Janc @ 2013-09-19 14:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1379599248-7923-1-git-send-email-szymon.janc@tieto.com>
Make DeviceID profile similar to other profiles implementations. Use
btd_profile for handling DeviceID profile while adding/removing
adapters. The nice drawback is that SDP code no longer depends on
main_opts.
---
Makefile.plugins | 3 +
profiles/deviceid/deviceid.c | 187 +++++++++++++++++++++++++++++++++++++++++++
src/adapter.c | 26 +++---
src/adapter.h | 3 +
src/sdpd-server.c | 4 -
src/sdpd-service.c | 58 --------------
src/sdpd.h | 2 -
7 files changed, 204 insertions(+), 79 deletions(-)
create mode 100644 profiles/deviceid/deviceid.c
diff --git a/Makefile.plugins b/Makefile.plugins
index 7c5f71d..df5d2a1 100644
--- a/Makefile.plugins
+++ b/Makefile.plugins
@@ -82,6 +82,9 @@ builtin_sources += profiles/scanparam/scan.c
builtin_modules += deviceinfo
builtin_sources += profiles/deviceinfo/deviceinfo.c
+builtin_modules += deviceid
+builtin_sources += profiles/deviceid/deviceid.c
+
if EXPERIMENTAL
builtin_modules += alert
builtin_sources += profiles/alert/server.c
diff --git a/profiles/deviceid/deviceid.c b/profiles/deviceid/deviceid.c
new file mode 100644
index 0000000..be5df80
--- /dev/null
+++ b/profiles/deviceid/deviceid.c
@@ -0,0 +1,187 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2013 Intel Corporation
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <bluetooth/sdp.h>
+#include <bluetooth/sdp_lib.h>
+
+#include <glib.h>
+
+#include "sdpd.h"
+#include "hcid.h"
+#include "adapter.h"
+#include "profile.h"
+#include "plugin.h"
+#include "log.h"
+
+struct deviceid_adapter {
+ struct btd_adapter *adapter;
+ uint32_t handle;
+};
+
+static GSList *deviceid_adapters = NULL;
+
+static struct deviceid_adapter *find_adapter(struct btd_adapter *adapter)
+{
+ GSList *list;
+
+ for (list = deviceid_adapters; list; list = list->next) {
+ struct deviceid_adapter *da = list->data;
+
+ if (da->adapter == adapter)
+ return da;
+ }
+
+ return NULL;
+}
+
+static sdp_record_t *create_record(uint16_t source, uint16_t vendor,
+ uint16_t product, uint16_t version)
+{
+ const uint16_t spec = 0x0103;
+ const uint8_t primary = 1;
+ sdp_list_t *class_list, *group_list, *profile_list;
+ uuid_t class_uuid, group_uuid;
+ sdp_data_t *sdp_data, *primary_data, *source_data;
+ sdp_data_t *spec_data, *vendor_data, *product_data, *version_data;
+ sdp_profile_desc_t profile;
+ sdp_record_t *record = sdp_record_alloc();
+
+ DBG("%04x:%04x:%04x:%04x", source, vendor, product, version);
+
+ record->handle = sdp_next_handle();
+
+ sdp_data = sdp_data_alloc(SDP_UINT32, &record->handle);
+ sdp_attr_add(record, SDP_ATTR_RECORD_HANDLE, sdp_data);
+
+ sdp_uuid16_create(&class_uuid, PNP_INFO_SVCLASS_ID);
+ class_list = sdp_list_append(0, &class_uuid);
+ sdp_set_service_classes(record, class_list);
+ sdp_list_free(class_list, NULL);
+
+ sdp_uuid16_create(&group_uuid, PUBLIC_BROWSE_GROUP);
+ group_list = sdp_list_append(NULL, &group_uuid);
+ sdp_set_browse_groups(record, group_list);
+ sdp_list_free(group_list, NULL);
+
+ sdp_uuid16_create(&profile.uuid, PNP_INFO_PROFILE_ID);
+ profile.version = spec;
+ profile_list = sdp_list_append(NULL, &profile);
+ sdp_set_profile_descs(record, profile_list);
+ sdp_list_free(profile_list, NULL);
+
+ spec_data = sdp_data_alloc(SDP_UINT16, &spec);
+ sdp_attr_add(record, 0x0200, spec_data);
+
+ vendor_data = sdp_data_alloc(SDP_UINT16, &vendor);
+ sdp_attr_add(record, 0x0201, vendor_data);
+
+ product_data = sdp_data_alloc(SDP_UINT16, &product);
+ sdp_attr_add(record, 0x0202, product_data);
+
+ version_data = sdp_data_alloc(SDP_UINT16, &version);
+ sdp_attr_add(record, 0x0203, version_data);
+
+ primary_data = sdp_data_alloc(SDP_BOOL, &primary);
+ sdp_attr_add(record, 0x0204, primary_data);
+
+ source_data = sdp_data_alloc(SDP_UINT16, &source);
+ sdp_attr_add(record, 0x0205, source_data);
+
+ return record;
+}
+
+static int deviceid_adapter_probe(struct btd_profile *p,
+ struct btd_adapter *adapter)
+{
+ struct deviceid_adapter *dadapter;
+ sdp_record_t *rec;
+ int ret;
+
+ DBG("path %s", adapter_get_path(adapter));
+
+ rec = create_record(main_opts.did_source, main_opts.did_vendor,
+ main_opts.did_product, main_opts.did_version);
+
+ ret = adapter_service_add(adapter, rec);
+ if (ret < 0) {
+ sdp_record_free(rec);
+ return ret;
+ }
+
+ btd_adapter_set_did(adapter, main_opts.did_source, main_opts.did_vendor,
+ main_opts.did_product, main_opts.did_version);
+
+ dadapter = g_new0(struct deviceid_adapter, 1);
+ dadapter->adapter = btd_adapter_ref(adapter);
+ dadapter->handle = rec->handle;
+
+ deviceid_adapters = g_slist_prepend(deviceid_adapters, dadapter);
+
+ return 0;
+}
+
+static void deviceid_adapter_remove(struct btd_profile *p,
+ struct btd_adapter *adapter)
+{
+ struct deviceid_adapter *dadapter;
+
+ DBG("path %s", adapter_get_path(adapter));
+
+ dadapter = find_adapter(adapter);
+ if (!dadapter)
+ return;
+
+ adapter_service_remove(dadapter->adapter, dadapter->handle);
+
+ btd_adapter_unref(dadapter->adapter);
+ g_free(dadapter);
+}
+
+struct btd_profile deviceid_profile = {
+ .name = "deviceid",
+ .adapter_probe = deviceid_adapter_probe,
+ .adapter_remove = deviceid_adapter_remove,
+};
+
+static int deviceid_init(void)
+{
+ if (main_opts.did_source == 0) {
+ info("Device ID information disabled");
+ return -1;
+ }
+
+ return btd_profile_register(&deviceid_profile);
+}
+
+static void deviceid_exit(void)
+{
+ btd_profile_unregister(&deviceid_profile);
+}
+
+BLUETOOTH_PLUGIN_DEFINE(deviceid, VERSION,
+ BLUETOOTH_PLUGIN_PRIORITY_DEFAULT,
+ deviceid_init, deviceid_exit)
diff --git a/src/adapter.c b/src/adapter.c
index b99bff9..ed4824c 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3929,17 +3929,12 @@ static struct btd_adapter *btd_adapter_new(uint16_t index)
adapter->system_name = g_strdup(main_opts.name);
adapter->major_class = (main_opts.class & 0x001f00) >> 8;
adapter->minor_class = (main_opts.class & 0x0000fc) >> 2;
- adapter->modalias = bt_modalias(main_opts.did_source,
- main_opts.did_vendor,
- main_opts.did_product,
- main_opts.did_version);
adapter->discoverable_timeout = main_opts.discovto;
adapter->pairable_timeout = main_opts.pairto;
DBG("System name: %s", adapter->system_name);
DBG("Major class: %u", adapter->major_class);
DBG("Minor class: %u", adapter->minor_class);
- DBG("Modalias: %s", adapter->modalias);
DBG("Discoverable timeout: %u seconds", adapter->discoverable_timeout);
DBG("Pairable timeout: %u seconds", adapter->pairable_timeout);
@@ -5566,14 +5561,23 @@ void adapter_foreach(adapter_cb func, gpointer user_data)
g_slist_foreach(adapters, (GFunc) func, user_data);
}
-static int set_did(struct btd_adapter *adapter, uint16_t vendor,
- uint16_t product, uint16_t version, uint16_t source)
+int btd_adapter_set_did(struct btd_adapter *adapter,
+ uint16_t source, uint16_t vendor,
+ uint16_t product, uint16_t version)
{
struct mgmt_cp_set_device_id cp;
DBG("hci%u source %x vendor %x product %x version %x",
adapter->dev_id, source, vendor, product, version);
+ g_free(adapter->modalias);
+ adapter->modalias = bt_modalias(source, vendor, product, version);
+
+ DBG("Modalias: %s", adapter->modalias);
+
+ g_dbus_emit_property_changed(dbus_conn, adapter->path,
+ ADAPTER_INTERFACE, "Modalias");
+
memset(&cp, 0, sizeof(cp));
cp.source = htobs(source);
@@ -5638,14 +5642,6 @@ static int adapter_register(struct btd_adapter *adapter)
adapter->initialized = TRUE;
- if (main_opts.did_source) {
- /* DeviceID record is added by sdpd-server before any other
- * record is registered. */
- adapter_service_insert(adapter, sdp_record_find(0x10000));
- set_did(adapter, main_opts.did_vendor, main_opts.did_product,
- main_opts.did_version, main_opts.did_source);
- }
-
DBG("Adapter %s registered", adapter->path);
return 0;
diff --git a/src/adapter.h b/src/adapter.h
index 5d124e7..a6fb340 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -113,6 +113,9 @@ void btd_adapter_unref(struct btd_adapter *adapter);
void btd_adapter_set_class(struct btd_adapter *adapter, uint8_t major,
uint8_t minor);
+int btd_adapter_set_did(struct btd_adapter *adapter,
+ uint16_t source, uint16_t vendor,
+ uint16_t product, uint16_t version);
struct btd_adapter_driver {
const char *name;
diff --git a/src/sdpd-server.c b/src/sdpd-server.c
index 7b1351f..de5aef1 100644
--- a/src/sdpd-server.c
+++ b/src/sdpd-server.c
@@ -238,10 +238,6 @@ int start_sdp_server(uint16_t mtu, uint32_t flags)
return -1;
}
- if (main_opts.did_source > 0)
- register_device_id(main_opts.did_source, main_opts.did_vendor,
- main_opts.did_product, main_opts.did_version);
-
io = g_io_channel_unix_new(l2cap_sock);
g_io_channel_set_close_on_unref(io, TRUE);
diff --git a/src/sdpd-service.c b/src/sdpd-service.c
index 09f6c0a..2da70b5 100644
--- a/src/sdpd-service.c
+++ b/src/sdpd-service.c
@@ -176,64 +176,6 @@ void register_server_service(void)
update_db_timestamp();
}
-void register_device_id(uint16_t source, uint16_t vendor,
- uint16_t product, uint16_t version)
-{
- const uint16_t spec = 0x0103;
- const uint8_t primary = 1;
- sdp_list_t *class_list, *group_list, *profile_list;
- uuid_t class_uuid, group_uuid;
- sdp_data_t *sdp_data, *primary_data, *source_data;
- sdp_data_t *spec_data, *vendor_data, *product_data, *version_data;
- sdp_profile_desc_t profile;
- sdp_record_t *record = sdp_record_alloc();
-
- DBG("Adding device id record for %04x:%04x:%04x:%04x",
- source, vendor, product, version);
-
- record->handle = sdp_next_handle();
-
- sdp_record_add(BDADDR_ANY, record);
- sdp_data = sdp_data_alloc(SDP_UINT32, &record->handle);
- sdp_attr_add(record, SDP_ATTR_RECORD_HANDLE, sdp_data);
-
- sdp_uuid16_create(&class_uuid, PNP_INFO_SVCLASS_ID);
- class_list = sdp_list_append(0, &class_uuid);
- sdp_set_service_classes(record, class_list);
- sdp_list_free(class_list, NULL);
-
- sdp_uuid16_create(&group_uuid, PUBLIC_BROWSE_GROUP);
- group_list = sdp_list_append(NULL, &group_uuid);
- sdp_set_browse_groups(record, group_list);
- sdp_list_free(group_list, NULL);
-
- sdp_uuid16_create(&profile.uuid, PNP_INFO_PROFILE_ID);
- profile.version = spec;
- profile_list = sdp_list_append(NULL, &profile);
- sdp_set_profile_descs(record, profile_list);
- sdp_list_free(profile_list, NULL);
-
- spec_data = sdp_data_alloc(SDP_UINT16, &spec);
- sdp_attr_add(record, 0x0200, spec_data);
-
- vendor_data = sdp_data_alloc(SDP_UINT16, &vendor);
- sdp_attr_add(record, 0x0201, vendor_data);
-
- product_data = sdp_data_alloc(SDP_UINT16, &product);
- sdp_attr_add(record, 0x0202, product_data);
-
- version_data = sdp_data_alloc(SDP_UINT16, &version);
- sdp_attr_add(record, 0x0203, version_data);
-
- primary_data = sdp_data_alloc(SDP_BOOL, &primary);
- sdp_attr_add(record, 0x0204, primary_data);
-
- source_data = sdp_data_alloc(SDP_UINT16, &source);
- sdp_attr_add(record, 0x0205, source_data);
-
- update_db_timestamp();
-}
-
int add_record_to_server(const bdaddr_t *src, sdp_record_t *rec)
{
sdp_data_t *data;
diff --git a/src/sdpd.h b/src/sdpd.h
index 3c6ee01..174a4d7 100644
--- a/src/sdpd.h
+++ b/src/sdpd.h
@@ -54,8 +54,6 @@ int service_update_req(sdp_req_t *req, sdp_buf_t *rsp);
void register_public_browse_group(void);
void register_server_service(void);
-void register_device_id(uint16_t source, uint16_t vendor,
- uint16_t product, uint16_t version);
int record_sort(const void *r1, const void *r2);
void sdp_svcdb_reset(void);
--
1.8.4
^ permalink raw reply related
* [PATCH v2 7/8] sdptool: Remove support for adding and removing service records
From: Szymon Janc @ 2013-09-19 14:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1379599248-7923-1-git-send-email-szymon.janc@tieto.com>
SDP database should now be controlled only by adapters. SDP code
is no longer able to notify controllers about external changes to
database. This results in services added/removed by sdptool being
not updated properly in adapter structure.
---
tools/sdptool.1 | 16 -
tools/sdptool.c | 2595 ++-----------------------------------------------------
2 files changed, 54 insertions(+), 2557 deletions(-)
diff --git a/tools/sdptool.1 b/tools/sdptool.1
index 88ad818..ee95e67 100644
--- a/tools/sdptool.1
+++ b/tools/sdptool.1
@@ -82,18 +82,6 @@ Browse all available services on the device
specified by a Bluetooth address as a parameter.
.IP "\fBrecords [--tree] [--raw] [--xml] bdaddr\fP" 10
Retrieve all possible service records.
-.IP "\fBadd [ --handle=N --channel=N ]\fP" 10
-Add a service to the local
-SDP database.
-.IP "" 10
-You can specify a handle for this record using
-the \fB--handle\fP option.
-.IP "" 10
-You can specify a channel to add the service on
-using the \fB--channel\fP option.
-.IP "\fBdel record_handle\fP" 10
-Remove a service from the local
-SDP database.
.IP "\fBget [--tree] [--raw] [--xml] [--bdaddr bdaddr] record_handle\fP" 10
Retrieve a service from the local
SDP database.
@@ -112,10 +100,6 @@ Displays help on using sdptool.
sdptool browse 00:80:98:24:15:6D
.PP
sdptool browse local
-.PP
-sdptool add DUN
-.PP
-sdptool del 0x10000
.SH "BUGS"
.PP
Documentation needs improving.
diff --git a/tools/sdptool.c b/tools/sdptool.c
index c241655..7d1121d 100644
--- a/tools/sdptool.c
+++ b/tools/sdptool.c
@@ -1145,2148 +1145,30 @@ static void print_service_attr(sdp_record_t *rec)
}
}
-/*
- * Support for Service (de)registration
- */
-typedef struct {
- uint32_t handle;
- char *name;
- char *provider;
- char *desc;
- unsigned int class;
- unsigned int profile;
- uint16_t psm;
- uint8_t channel;
- uint8_t network;
-} svc_info_t;
-
-static int add_sp(sdp_session_t *session, svc_info_t *si)
-{
- sdp_list_t *svclass_id, *apseq, *proto[2], *profiles, *root, *aproto;
- uuid_t root_uuid, sp_uuid, l2cap, rfcomm;
- sdp_profile_desc_t profile;
- sdp_record_t record;
- uint8_t u8 = si->channel ? si->channel : 1;
- sdp_data_t *channel;
- int ret = 0;
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(0, &root_uuid);
- sdp_set_browse_groups(&record, root);
- sdp_list_free(root, 0);
-
- sdp_uuid16_create(&sp_uuid, SERIAL_PORT_SVCLASS_ID);
- svclass_id = sdp_list_append(0, &sp_uuid);
- sdp_set_service_classes(&record, svclass_id);
- sdp_list_free(svclass_id, 0);
-
- sdp_uuid16_create(&profile.uuid, SERIAL_PORT_PROFILE_ID);
- profile.version = 0x0100;
- profiles = sdp_list_append(0, &profile);
- sdp_set_profile_descs(&record, profiles);
- sdp_list_free(profiles, 0);
-
- sdp_uuid16_create(&l2cap, L2CAP_UUID);
- proto[0] = sdp_list_append(0, &l2cap);
- apseq = sdp_list_append(0, proto[0]);
-
- sdp_uuid16_create(&rfcomm, RFCOMM_UUID);
- proto[1] = sdp_list_append(0, &rfcomm);
- channel = sdp_data_alloc(SDP_UINT8, &u8);
- proto[1] = sdp_list_append(proto[1], channel);
- apseq = sdp_list_append(apseq, proto[1]);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(&record, aproto);
-
- sdp_add_lang_attr(&record);
-
- sdp_set_info_attr(&record, "Serial Port", "BlueZ", "COM Port");
-
- sdp_set_url_attr(&record, "http://www.bluez.org/",
- "http://www.bluez.org/", "http://www.bluez.org/");
-
- sdp_set_service_id(&record, sp_uuid);
- sdp_set_service_ttl(&record, 0xffff);
- sdp_set_service_avail(&record, 0xff);
- sdp_set_record_state(&record, 0x00001234);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- ret = -1;
- goto end;
- }
-
- printf("Serial Port service registered\n");
-
-end:
- sdp_data_free(channel);
- sdp_list_free(proto[0], 0);
- sdp_list_free(proto[1], 0);
- sdp_list_free(apseq, 0);
- sdp_list_free(aproto, 0);
-
- return ret;
-}
-
-static int add_dun(sdp_session_t *session, svc_info_t *si)
-{
- sdp_list_t *svclass_id, *pfseq, *apseq, *root, *aproto;
- uuid_t rootu, dun, gn, l2cap, rfcomm;
- sdp_profile_desc_t profile;
- sdp_list_t *proto[2];
- sdp_record_t record;
- uint8_t u8 = si->channel ? si->channel : 2;
- sdp_data_t *channel;
- int ret = 0;
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
-
- sdp_uuid16_create(&rootu, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(0, &rootu);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&dun, DIALUP_NET_SVCLASS_ID);
- svclass_id = sdp_list_append(0, &dun);
- sdp_uuid16_create(&gn, GENERIC_NETWORKING_SVCLASS_ID);
- svclass_id = sdp_list_append(svclass_id, &gn);
- sdp_set_service_classes(&record, svclass_id);
-
- sdp_uuid16_create(&profile.uuid, DIALUP_NET_PROFILE_ID);
- profile.version = 0x0100;
- pfseq = sdp_list_append(0, &profile);
- sdp_set_profile_descs(&record, pfseq);
-
- sdp_uuid16_create(&l2cap, L2CAP_UUID);
- proto[0] = sdp_list_append(0, &l2cap);
- apseq = sdp_list_append(0, proto[0]);
-
- sdp_uuid16_create(&rfcomm, RFCOMM_UUID);
- proto[1] = sdp_list_append(0, &rfcomm);
- channel = sdp_data_alloc(SDP_UINT8, &u8);
- proto[1] = sdp_list_append(proto[1], channel);
- apseq = sdp_list_append(apseq, proto[1]);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(&record, aproto);
-
- sdp_set_info_attr(&record, "Dial-Up Networking", 0, 0);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- ret = -1;
- goto end;
- }
-
- printf("Dial-Up Networking service registered\n");
-
-end:
- sdp_data_free(channel);
- sdp_list_free(proto[0], 0);
- sdp_list_free(proto[1], 0);
- sdp_list_free(apseq, 0);
- sdp_list_free(aproto, 0);
-
- return ret;
-}
-
-static int add_fax(sdp_session_t *session, svc_info_t *si)
-{
- sdp_list_t *svclass_id, *pfseq, *apseq, *root;
- uuid_t root_uuid, fax_uuid, tel_uuid, l2cap_uuid, rfcomm_uuid;
- sdp_profile_desc_t profile;
- sdp_list_t *aproto, *proto[2];
- sdp_record_t record;
- uint8_t u8 = si->channel? si->channel : 3;
- sdp_data_t *channel;
- int ret = 0;
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(0, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&fax_uuid, FAX_SVCLASS_ID);
- svclass_id = sdp_list_append(0, &fax_uuid);
- sdp_uuid16_create(&tel_uuid, GENERIC_TELEPHONY_SVCLASS_ID);
- svclass_id = sdp_list_append(svclass_id, &tel_uuid);
- sdp_set_service_classes(&record, svclass_id);
-
- sdp_uuid16_create(&profile.uuid, FAX_PROFILE_ID);
- profile.version = 0x0100;
- pfseq = sdp_list_append(0, &profile);
- sdp_set_profile_descs(&record, pfseq);
-
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto[0] = sdp_list_append(0, &l2cap_uuid);
- apseq = sdp_list_append(0, proto[0]);
-
- sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
- proto[1] = sdp_list_append(0, &rfcomm_uuid);
- channel = sdp_data_alloc(SDP_UINT8, &u8);
- proto[1] = sdp_list_append(proto[1], channel);
- apseq = sdp_list_append(apseq, proto[1]);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(&record, aproto);
-
- sdp_set_info_attr(&record, "Fax", 0, 0);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- ret = -1;
- goto end;
- }
- printf("Fax service registered\n");
-end:
- sdp_data_free(channel);
- sdp_list_free(proto[0], 0);
- sdp_list_free(proto[1], 0);
- sdp_list_free(apseq, 0);
- sdp_list_free(aproto, 0);
- return ret;
-}
-
-static int add_lan(sdp_session_t *session, svc_info_t *si)
-{
- sdp_list_t *svclass_id, *pfseq, *apseq, *root;
- uuid_t root_uuid, svclass_uuid, l2cap_uuid, rfcomm_uuid;
- sdp_profile_desc_t profile;
- sdp_list_t *aproto, *proto[2];
- sdp_record_t record;
- uint8_t u8 = si->channel ? si->channel : 4;
- sdp_data_t *channel;
- int ret = 0;
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(0, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&svclass_uuid, LAN_ACCESS_SVCLASS_ID);
- svclass_id = sdp_list_append(0, &svclass_uuid);
- sdp_set_service_classes(&record, svclass_id);
-
- sdp_uuid16_create(&profile.uuid, LAN_ACCESS_PROFILE_ID);
- profile.version = 0x0100;
- pfseq = sdp_list_append(0, &profile);
- sdp_set_profile_descs(&record, pfseq);
-
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto[0] = sdp_list_append(0, &l2cap_uuid);
- apseq = sdp_list_append(0, proto[0]);
-
- sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
- proto[1] = sdp_list_append(0, &rfcomm_uuid);
- channel = sdp_data_alloc(SDP_UINT8, &u8);
- proto[1] = sdp_list_append(proto[1], channel);
- apseq = sdp_list_append(apseq, proto[1]);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(&record, aproto);
-
- sdp_set_info_attr(&record, "LAN Access over PPP", 0, 0);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- ret = -1;
- goto end;
- }
-
- printf("LAN Access service registered\n");
-
-end:
- sdp_data_free(channel);
- sdp_list_free(proto[0], 0);
- sdp_list_free(proto[1], 0);
- sdp_list_free(apseq, 0);
- sdp_list_free(aproto, 0);
-
- return ret;
-}
-
-static int add_headset(sdp_session_t *session, svc_info_t *si)
-{
- sdp_list_t *svclass_id, *pfseq, *apseq, *root;
- uuid_t root_uuid, svclass_uuid, ga_svclass_uuid, l2cap_uuid, rfcomm_uuid;
- sdp_profile_desc_t profile;
- sdp_list_t *aproto, *proto[2];
- sdp_record_t record;
- uint8_t u8 = si->channel ? si->channel : 5;
- sdp_data_t *channel;
- int ret = 0;
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(0, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&svclass_uuid, HEADSET_SVCLASS_ID);
- svclass_id = sdp_list_append(0, &svclass_uuid);
- sdp_uuid16_create(&ga_svclass_uuid, GENERIC_AUDIO_SVCLASS_ID);
- svclass_id = sdp_list_append(svclass_id, &ga_svclass_uuid);
- sdp_set_service_classes(&record, svclass_id);
-
- sdp_uuid16_create(&profile.uuid, HEADSET_PROFILE_ID);
- profile.version = 0x0100;
- pfseq = sdp_list_append(0, &profile);
- sdp_set_profile_descs(&record, pfseq);
-
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto[0] = sdp_list_append(0, &l2cap_uuid);
- apseq = sdp_list_append(0, proto[0]);
-
- sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
- proto[1] = sdp_list_append(0, &rfcomm_uuid);
- channel = sdp_data_alloc(SDP_UINT8, &u8);
- proto[1] = sdp_list_append(proto[1], channel);
- apseq = sdp_list_append(apseq, proto[1]);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(&record, aproto);
-
- sdp_set_info_attr(&record, "Headset", 0, 0);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- ret = -1;
- goto end;
- }
-
- printf("Headset service registered\n");
-
-end:
- sdp_data_free(channel);
- sdp_list_free(proto[0], 0);
- sdp_list_free(proto[1], 0);
- sdp_list_free(apseq, 0);
- sdp_list_free(aproto, 0);
-
- return ret;
-}
-
-static int add_headset_ag(sdp_session_t *session, svc_info_t *si)
-{
- sdp_list_t *svclass_id, *pfseq, *apseq, *root;
- uuid_t root_uuid, svclass_uuid, ga_svclass_uuid, l2cap_uuid, rfcomm_uuid;
- sdp_profile_desc_t profile;
- sdp_list_t *aproto, *proto[2];
- sdp_record_t record;
- uint8_t u8 = si->channel ? si->channel : 7;
- sdp_data_t *channel;
- uint8_t netid = si->network ? si->network : 0x01; // ???? profile document
- sdp_data_t *network = sdp_data_alloc(SDP_UINT8, &netid);
- int ret = 0;
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(0, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&svclass_uuid, HEADSET_AGW_SVCLASS_ID);
- svclass_id = sdp_list_append(0, &svclass_uuid);
- sdp_uuid16_create(&ga_svclass_uuid, GENERIC_AUDIO_SVCLASS_ID);
- svclass_id = sdp_list_append(svclass_id, &ga_svclass_uuid);
- sdp_set_service_classes(&record, svclass_id);
-
- sdp_uuid16_create(&profile.uuid, HEADSET_PROFILE_ID);
- profile.version = 0x0100;
- pfseq = sdp_list_append(0, &profile);
- sdp_set_profile_descs(&record, pfseq);
-
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto[0] = sdp_list_append(0, &l2cap_uuid);
- apseq = sdp_list_append(0, proto[0]);
-
- sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
- proto[1] = sdp_list_append(0, &rfcomm_uuid);
- channel = sdp_data_alloc(SDP_UINT8, &u8);
- proto[1] = sdp_list_append(proto[1], channel);
- apseq = sdp_list_append(apseq, proto[1]);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(&record, aproto);
-
- sdp_set_info_attr(&record, "Voice Gateway", 0, 0);
-
- sdp_attr_add(&record, SDP_ATTR_EXTERNAL_NETWORK, network);
-
- if (sdp_record_register(session, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- ret = -1;
- goto end;
- }
-
- printf("Headset AG service registered\n");
-
-end:
- sdp_data_free(channel);
- sdp_list_free(proto[0], 0);
- sdp_list_free(proto[1], 0);
- sdp_list_free(apseq, 0);
- sdp_list_free(aproto, 0);
-
- return ret;
-}
-
-static int add_handsfree(sdp_session_t *session, svc_info_t *si)
-{
- sdp_list_t *svclass_id, *pfseq, *apseq, *root;
- uuid_t root_uuid, svclass_uuid, ga_svclass_uuid, l2cap_uuid, rfcomm_uuid;
- sdp_profile_desc_t profile;
- sdp_list_t *aproto, *proto[2];
- sdp_record_t record;
- uint8_t u8 = si->channel ? si->channel : 6;
- uint16_t u16 = 0x31;
- sdp_data_t *channel, *features;
- int ret = 0;
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(0, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&svclass_uuid, HANDSFREE_SVCLASS_ID);
- svclass_id = sdp_list_append(0, &svclass_uuid);
- sdp_uuid16_create(&ga_svclass_uuid, GENERIC_AUDIO_SVCLASS_ID);
- svclass_id = sdp_list_append(svclass_id, &ga_svclass_uuid);
- sdp_set_service_classes(&record, svclass_id);
-
- sdp_uuid16_create(&profile.uuid, HANDSFREE_PROFILE_ID);
- profile.version = 0x0101;
- pfseq = sdp_list_append(0, &profile);
- sdp_set_profile_descs(&record, pfseq);
-
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto[0] = sdp_list_append(0, &l2cap_uuid);
- apseq = sdp_list_append(0, proto[0]);
-
- sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
- proto[1] = sdp_list_append(0, &rfcomm_uuid);
- channel = sdp_data_alloc(SDP_UINT8, &u8);
- proto[1] = sdp_list_append(proto[1], channel);
- apseq = sdp_list_append(apseq, proto[1]);
-
- features = sdp_data_alloc(SDP_UINT16, &u16);
- sdp_attr_add(&record, SDP_ATTR_SUPPORTED_FEATURES, features);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(&record, aproto);
-
- sdp_set_info_attr(&record, "Handsfree", 0, 0);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- ret = -1;
- goto end;
- }
-
- printf("Handsfree service registered\n");
-
-end:
- sdp_data_free(channel);
- sdp_list_free(proto[0], 0);
- sdp_list_free(proto[1], 0);
- sdp_list_free(apseq, 0);
- sdp_list_free(aproto, 0);
-
- return ret;
-}
-
-static int add_handsfree_ag(sdp_session_t *session, svc_info_t *si)
-{
- sdp_list_t *svclass_id, *pfseq, *apseq, *root;
- uuid_t root_uuid, svclass_uuid, ga_svclass_uuid, l2cap_uuid, rfcomm_uuid;
- sdp_profile_desc_t profile;
- sdp_list_t *aproto, *proto[2];
- sdp_record_t record;
- uint8_t u8 = si->channel ? si->channel : 7;
- uint16_t u16 = 0x17;
- sdp_data_t *channel, *features;
- uint8_t netid = si->network ? si->network : 0x01; // ???? profile document
- sdp_data_t *network = sdp_data_alloc(SDP_UINT8, &netid);
- int ret = 0;
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(0, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&svclass_uuid, HANDSFREE_AGW_SVCLASS_ID);
- svclass_id = sdp_list_append(0, &svclass_uuid);
- sdp_uuid16_create(&ga_svclass_uuid, GENERIC_AUDIO_SVCLASS_ID);
- svclass_id = sdp_list_append(svclass_id, &ga_svclass_uuid);
- sdp_set_service_classes(&record, svclass_id);
-
- sdp_uuid16_create(&profile.uuid, HANDSFREE_PROFILE_ID);
- profile.version = 0x0105;
- pfseq = sdp_list_append(0, &profile);
- sdp_set_profile_descs(&record, pfseq);
-
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto[0] = sdp_list_append(0, &l2cap_uuid);
- apseq = sdp_list_append(0, proto[0]);
-
- sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
- proto[1] = sdp_list_append(0, &rfcomm_uuid);
- channel = sdp_data_alloc(SDP_UINT8, &u8);
- proto[1] = sdp_list_append(proto[1], channel);
- apseq = sdp_list_append(apseq, proto[1]);
-
- features = sdp_data_alloc(SDP_UINT16, &u16);
- sdp_attr_add(&record, SDP_ATTR_SUPPORTED_FEATURES, features);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(&record, aproto);
-
- sdp_set_info_attr(&record, "Voice Gateway", 0, 0);
-
- sdp_attr_add(&record, SDP_ATTR_EXTERNAL_NETWORK, network);
-
- if (sdp_record_register(session, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- ret = -1;
- goto end;
- }
-
- printf("Handsfree AG service registered\n");
-
-end:
- sdp_data_free(channel);
- sdp_list_free(proto[0], 0);
- sdp_list_free(proto[1], 0);
- sdp_list_free(apseq, 0);
- sdp_list_free(aproto, 0);
-
- return ret;
-}
-
-static int add_simaccess(sdp_session_t *session, svc_info_t *si)
-{
- sdp_list_t *svclass_id, *pfseq, *apseq, *root;
- uuid_t root_uuid, svclass_uuid, ga_svclass_uuid, l2cap_uuid, rfcomm_uuid;
- sdp_profile_desc_t profile;
- sdp_list_t *aproto, *proto[2];
- sdp_record_t record;
- uint8_t u8 = si->channel? si->channel : 8;
- uint16_t u16 = 0x31;
- sdp_data_t *channel, *features;
- int ret = 0;
-
- memset((void *)&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(0, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&svclass_uuid, SAP_SVCLASS_ID);
- svclass_id = sdp_list_append(0, &svclass_uuid);
- sdp_uuid16_create(&ga_svclass_uuid, GENERIC_TELEPHONY_SVCLASS_ID);
- svclass_id = sdp_list_append(svclass_id, &ga_svclass_uuid);
- sdp_set_service_classes(&record, svclass_id);
-
- sdp_uuid16_create(&profile.uuid, SAP_PROFILE_ID);
- profile.version = 0x0101;
- pfseq = sdp_list_append(0, &profile);
- sdp_set_profile_descs(&record, pfseq);
-
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto[0] = sdp_list_append(0, &l2cap_uuid);
- apseq = sdp_list_append(0, proto[0]);
-
- sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
- proto[1] = sdp_list_append(0, &rfcomm_uuid);
- channel = sdp_data_alloc(SDP_UINT8, &u8);
- proto[1] = sdp_list_append(proto[1], channel);
- apseq = sdp_list_append(apseq, proto[1]);
-
- features = sdp_data_alloc(SDP_UINT16, &u16);
- sdp_attr_add(&record, SDP_ATTR_SUPPORTED_FEATURES, features);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(&record, aproto);
-
- sdp_set_info_attr(&record, "SIM Access", 0, 0);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- ret = -1;
- goto end;
- }
-
- printf("SIM Access service registered\n");
-
-end:
- sdp_data_free(channel);
- sdp_list_free(proto[0], 0);
- sdp_list_free(proto[1], 0);
- sdp_list_free(apseq, 0);
- sdp_list_free(aproto, 0);
-
- return ret;
-}
-
-static int add_opush(sdp_session_t *session, svc_info_t *si)
-{
- sdp_list_t *svclass_id, *pfseq, *apseq, *root;
- uuid_t root_uuid, opush_uuid, l2cap_uuid, rfcomm_uuid, obex_uuid;
- sdp_profile_desc_t profile[1];
- sdp_list_t *aproto, *proto[3];
- sdp_record_t record;
- uint8_t chan = si->channel ? si->channel : 9;
- sdp_data_t *channel;
- uint8_t formats[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0xff };
- void *dtds[sizeof(formats)], *values[sizeof(formats)];
- unsigned int i;
- uint8_t dtd = SDP_UINT8;
- sdp_data_t *sflist;
- int ret = 0;
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(0, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&opush_uuid, OBEX_OBJPUSH_SVCLASS_ID);
- svclass_id = sdp_list_append(0, &opush_uuid);
- sdp_set_service_classes(&record, svclass_id);
-
- sdp_uuid16_create(&profile[0].uuid, OBEX_OBJPUSH_PROFILE_ID);
- profile[0].version = 0x0100;
- pfseq = sdp_list_append(0, profile);
- sdp_set_profile_descs(&record, pfseq);
-
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto[0] = sdp_list_append(0, &l2cap_uuid);
- apseq = sdp_list_append(0, proto[0]);
-
- sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
- proto[1] = sdp_list_append(0, &rfcomm_uuid);
- channel = sdp_data_alloc(SDP_UINT8, &chan);
- proto[1] = sdp_list_append(proto[1], channel);
- apseq = sdp_list_append(apseq, proto[1]);
-
- sdp_uuid16_create(&obex_uuid, OBEX_UUID);
- proto[2] = sdp_list_append(0, &obex_uuid);
- apseq = sdp_list_append(apseq, proto[2]);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(&record, aproto);
-
- for (i = 0; i < sizeof(formats); i++) {
- dtds[i] = &dtd;
- values[i] = &formats[i];
- }
- sflist = sdp_seq_alloc(dtds, values, sizeof(formats));
- sdp_attr_add(&record, SDP_ATTR_SUPPORTED_FORMATS_LIST, sflist);
-
- sdp_set_info_attr(&record, "OBEX Object Push", 0, 0);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- ret = -1;
- goto end;
- }
-
- printf("OBEX Object Push service registered\n");
-
-end:
- sdp_data_free(channel);
- sdp_list_free(proto[0], 0);
- sdp_list_free(proto[1], 0);
- sdp_list_free(proto[2], 0);
- sdp_list_free(apseq, 0);
- sdp_list_free(aproto, 0);
-
- return ret;
-}
-
-static int add_pbap(sdp_session_t *session, svc_info_t *si)
-{
- sdp_list_t *svclass_id, *pfseq, *apseq, *root;
- uuid_t root_uuid, pbap_uuid, l2cap_uuid, rfcomm_uuid, obex_uuid;
- sdp_profile_desc_t profile[1];
- sdp_list_t *aproto, *proto[3];
- sdp_record_t record;
- uint8_t chan = si->channel ? si->channel : 19;
- sdp_data_t *channel;
- uint8_t formats[] = {0x01};
- uint8_t dtd = SDP_UINT8;
- sdp_data_t *sflist;
- int ret = 0;
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(0, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&pbap_uuid, PBAP_PSE_SVCLASS_ID);
- svclass_id = sdp_list_append(0, &pbap_uuid);
- sdp_set_service_classes(&record, svclass_id);
-
- sdp_uuid16_create(&profile[0].uuid, PBAP_PROFILE_ID);
- profile[0].version = 0x0100;
- pfseq = sdp_list_append(0, profile);
- sdp_set_profile_descs(&record, pfseq);
-
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto[0] = sdp_list_append(0, &l2cap_uuid);
- apseq = sdp_list_append(0, proto[0]);
-
- sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
- proto[1] = sdp_list_append(0, &rfcomm_uuid);
- channel = sdp_data_alloc(SDP_UINT8, &chan);
- proto[1] = sdp_list_append(proto[1], channel);
- apseq = sdp_list_append(apseq, proto[1]);
-
- sdp_uuid16_create(&obex_uuid, OBEX_UUID);
- proto[2] = sdp_list_append(0, &obex_uuid);
- apseq = sdp_list_append(apseq, proto[2]);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(&record, aproto);
-
- sflist = sdp_data_alloc(dtd,formats);
- sdp_attr_add(&record, SDP_ATTR_SUPPORTED_REPOSITORIES, sflist);
-
- sdp_set_info_attr(&record, "OBEX Phonebook Access Server", 0, 0);
-
- if (sdp_device_record_register(session, &interface, &record,
- SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- ret = -1;
- goto end;
- }
-
- printf("PBAP service registered\n");
-
-end:
- sdp_data_free(channel);
- sdp_list_free(proto[0], 0);
- sdp_list_free(proto[1], 0);
- sdp_list_free(proto[2], 0);
- sdp_list_free(apseq, 0);
- sdp_list_free(aproto, 0);
-
- return ret;
-}
-
-static int add_ftp(sdp_session_t *session, svc_info_t *si)
-{
- sdp_list_t *svclass_id, *pfseq, *apseq, *root;
- uuid_t root_uuid, ftrn_uuid, l2cap_uuid, rfcomm_uuid, obex_uuid;
- sdp_profile_desc_t profile[1];
- sdp_list_t *aproto, *proto[3];
- sdp_record_t record;
- uint8_t u8 = si->channel ? si->channel: 10;
- sdp_data_t *channel;
- int ret = 0;
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(0, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&ftrn_uuid, OBEX_FILETRANS_SVCLASS_ID);
- svclass_id = sdp_list_append(0, &ftrn_uuid);
- sdp_set_service_classes(&record, svclass_id);
-
- sdp_uuid16_create(&profile[0].uuid, OBEX_FILETRANS_PROFILE_ID);
- profile[0].version = 0x0100;
- pfseq = sdp_list_append(0, &profile[0]);
- sdp_set_profile_descs(&record, pfseq);
-
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto[0] = sdp_list_append(0, &l2cap_uuid);
- apseq = sdp_list_append(0, proto[0]);
-
- sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
- proto[1] = sdp_list_append(0, &rfcomm_uuid);
- channel = sdp_data_alloc(SDP_UINT8, &u8);
- proto[1] = sdp_list_append(proto[1], channel);
- apseq = sdp_list_append(apseq, proto[1]);
-
- sdp_uuid16_create(&obex_uuid, OBEX_UUID);
- proto[2] = sdp_list_append(0, &obex_uuid);
- apseq = sdp_list_append(apseq, proto[2]);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(&record, aproto);
-
- sdp_set_info_attr(&record, "OBEX File Transfer", 0, 0);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- ret = -1;
- goto end;
- }
-
- printf("OBEX File Transfer service registered\n");
-
-end:
- sdp_data_free(channel);
- sdp_list_free(proto[0], 0);
- sdp_list_free(proto[1], 0);
- sdp_list_free(proto[2], 0);
- sdp_list_free(apseq, 0);
- sdp_list_free(aproto, 0);
-
- return ret;
-}
-
-static int add_directprint(sdp_session_t *session, svc_info_t *si)
-{
- sdp_list_t *svclass_id, *pfseq, *apseq, *root;
- uuid_t root_uuid, opush_uuid, l2cap_uuid, rfcomm_uuid, obex_uuid;
- sdp_profile_desc_t profile[1];
- sdp_list_t *aproto, *proto[3];
- sdp_record_t record;
- uint8_t chan = si->channel ? si->channel : 12;
- sdp_data_t *channel;
- int ret = 0;
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(0, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&opush_uuid, DIRECT_PRINTING_SVCLASS_ID);
- svclass_id = sdp_list_append(0, &opush_uuid);
- sdp_set_service_classes(&record, svclass_id);
-
- sdp_uuid16_create(&profile[0].uuid, BASIC_PRINTING_PROFILE_ID);
- profile[0].version = 0x0100;
- pfseq = sdp_list_append(0, profile);
- sdp_set_profile_descs(&record, pfseq);
-
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto[0] = sdp_list_append(0, &l2cap_uuid);
- apseq = sdp_list_append(0, proto[0]);
-
- sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
- proto[1] = sdp_list_append(0, &rfcomm_uuid);
- channel = sdp_data_alloc(SDP_UINT8, &chan);
- proto[1] = sdp_list_append(proto[1], channel);
- apseq = sdp_list_append(apseq, proto[1]);
-
- sdp_uuid16_create(&obex_uuid, OBEX_UUID);
- proto[2] = sdp_list_append(0, &obex_uuid);
- apseq = sdp_list_append(apseq, proto[2]);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(&record, aproto);
-
- sdp_set_info_attr(&record, "Direct Printing", 0, 0);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- ret = -1;
- goto end;
- }
-
- printf("Direct Printing service registered\n");
-
-end:
- sdp_data_free(channel);
- sdp_list_free(proto[0], 0);
- sdp_list_free(proto[1], 0);
- sdp_list_free(proto[2], 0);
- sdp_list_free(apseq, 0);
- sdp_list_free(aproto, 0);
-
- return ret;
-}
-
-static int add_nap(sdp_session_t *session, svc_info_t *si)
-{
- sdp_list_t *svclass_id, *pfseq, *apseq, *root;
- uuid_t root_uuid, ftrn_uuid, l2cap_uuid, bnep_uuid;
- sdp_profile_desc_t profile[1];
- sdp_list_t *aproto, *proto[2];
- sdp_record_t record;
- uint16_t lp = 0x000f, ver = 0x0100;
- sdp_data_t *psm, *version;
- int ret = 0;
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(0, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&ftrn_uuid, NAP_SVCLASS_ID);
- svclass_id = sdp_list_append(0, &ftrn_uuid);
- sdp_set_service_classes(&record, svclass_id);
-
- sdp_uuid16_create(&profile[0].uuid, NAP_PROFILE_ID);
- profile[0].version = 0x0100;
- pfseq = sdp_list_append(0, &profile[0]);
- sdp_set_profile_descs(&record, pfseq);
-
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto[0] = sdp_list_append(0, &l2cap_uuid);
- psm = sdp_data_alloc(SDP_UINT16, &lp);
- proto[0] = sdp_list_append(proto[0], psm);
- apseq = sdp_list_append(0, proto[0]);
-
- sdp_uuid16_create(&bnep_uuid, BNEP_UUID);
- proto[1] = sdp_list_append(0, &bnep_uuid);
- version = sdp_data_alloc(SDP_UINT16, &ver);
- proto[1] = sdp_list_append(proto[1], version);
-
- {
- uint16_t ptype[4] = { 0x0010, 0x0020, 0x0030, 0x0040 };
- sdp_data_t *head, *pseq;
- int p;
-
- for (p = 0, head = NULL; p < 4; p++) {
- sdp_data_t *data = sdp_data_alloc(SDP_UINT16, &ptype[p]);
- head = sdp_seq_append(head, data);
- }
- pseq = sdp_data_alloc(SDP_SEQ16, head);
- proto[1] = sdp_list_append(proto[1], pseq);
- }
-
- apseq = sdp_list_append(apseq, proto[1]);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(&record, aproto);
-
- sdp_set_info_attr(&record, "Network Access Point Service", 0, 0);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- ret = -1;
- goto end;
- }
-
- printf("NAP service registered\n");
-
-end:
- sdp_data_free(version);
- sdp_data_free(psm);
- sdp_list_free(proto[0], 0);
- sdp_list_free(proto[1], 0);
- sdp_list_free(apseq, 0);
- sdp_list_free(aproto, 0);
-
- return ret;
-}
-
-static int add_gn(sdp_session_t *session, svc_info_t *si)
-{
- sdp_list_t *svclass_id, *pfseq, *apseq, *root;
- uuid_t root_uuid, ftrn_uuid, l2cap_uuid, bnep_uuid;
- sdp_profile_desc_t profile[1];
- sdp_list_t *aproto, *proto[2];
- sdp_record_t record;
- uint16_t lp = 0x000f, ver = 0x0100;
- sdp_data_t *psm, *version;
- int ret = 0;
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(0, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&ftrn_uuid, GN_SVCLASS_ID);
- svclass_id = sdp_list_append(0, &ftrn_uuid);
- sdp_set_service_classes(&record, svclass_id);
-
- sdp_uuid16_create(&profile[0].uuid, GN_PROFILE_ID);
- profile[0].version = 0x0100;
- pfseq = sdp_list_append(0, &profile[0]);
- sdp_set_profile_descs(&record, pfseq);
-
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto[0] = sdp_list_append(0, &l2cap_uuid);
- psm = sdp_data_alloc(SDP_UINT16, &lp);
- proto[0] = sdp_list_append(proto[0], psm);
- apseq = sdp_list_append(0, proto[0]);
-
- sdp_uuid16_create(&bnep_uuid, BNEP_UUID);
- proto[1] = sdp_list_append(0, &bnep_uuid);
- version = sdp_data_alloc(SDP_UINT16, &ver);
- proto[1] = sdp_list_append(proto[1], version);
- apseq = sdp_list_append(apseq, proto[1]);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(&record, aproto);
-
- sdp_set_info_attr(&record, "Group Network Service", 0, 0);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- ret = -1;
- goto end;
- }
-
- printf("GN service registered\n");
-
-end:
- sdp_data_free(version);
- sdp_data_free(psm);
- sdp_list_free(proto[0], 0);
- sdp_list_free(proto[1], 0);
- sdp_list_free(apseq, 0);
- sdp_list_free(aproto, 0);
-
- return ret;
-}
-
-static int add_panu(sdp_session_t *session, svc_info_t *si)
-{
- sdp_list_t *svclass_id, *pfseq, *apseq, *root;
- uuid_t root_uuid, ftrn_uuid, l2cap_uuid, bnep_uuid;
- sdp_profile_desc_t profile[1];
- sdp_list_t *aproto, *proto[2];
- sdp_record_t record;
- uint16_t lp = 0x000f, ver = 0x0100;
- sdp_data_t *psm, *version;
- int ret = 0;
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(NULL, &root_uuid);
- sdp_set_browse_groups(&record, root);
- sdp_list_free(root, NULL);
-
- sdp_uuid16_create(&ftrn_uuid, PANU_SVCLASS_ID);
- svclass_id = sdp_list_append(NULL, &ftrn_uuid);
- sdp_set_service_classes(&record, svclass_id);
- sdp_list_free(svclass_id, NULL);
-
- sdp_uuid16_create(&profile[0].uuid, PANU_PROFILE_ID);
- profile[0].version = 0x0100;
- pfseq = sdp_list_append(NULL, &profile[0]);
- sdp_set_profile_descs(&record, pfseq);
- sdp_list_free(pfseq, NULL);
-
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto[0] = sdp_list_append(NULL, &l2cap_uuid);
- psm = sdp_data_alloc(SDP_UINT16, &lp);
- proto[0] = sdp_list_append(proto[0], psm);
- apseq = sdp_list_append(NULL, proto[0]);
-
- sdp_uuid16_create(&bnep_uuid, BNEP_UUID);
- proto[1] = sdp_list_append(NULL, &bnep_uuid);
- version = sdp_data_alloc(SDP_UINT16, &ver);
- proto[1] = sdp_list_append(proto[1], version);
- apseq = sdp_list_append(apseq, proto[1]);
-
- aproto = sdp_list_append(NULL, apseq);
- sdp_set_access_protos(&record, aproto);
-
- sdp_set_info_attr(&record, "PAN User", NULL, NULL);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- ret = -1;
- goto end;
- }
-
- printf("PANU service registered\n");
-
-end:
- sdp_data_free(version);
- sdp_data_free(psm);
- sdp_list_free(proto[0], 0);
- sdp_list_free(proto[1], 0);
- sdp_list_free(apseq, 0);
- sdp_list_free(aproto, 0);
-
- return ret;
-}
-
-static int add_hid_keyb(sdp_session_t *session, svc_info_t *si)
-{
- sdp_record_t record;
- sdp_list_t *svclass_id, *pfseq, *apseq, *root;
- uuid_t root_uuid, hidkb_uuid, l2cap_uuid, hidp_uuid;
- sdp_profile_desc_t profile[1];
- sdp_list_t *aproto, *proto[3];
- sdp_data_t *psm, *lang_lst, *lang_lst2, *hid_spec_lst, *hid_spec_lst2;
- unsigned int i;
- uint8_t dtd = SDP_UINT16;
- uint8_t dtd2 = SDP_UINT8;
- uint8_t dtd_data = SDP_TEXT_STR8;
- void *dtds[2];
- void *values[2];
- void *dtds2[2];
- void *values2[2];
- int leng[2];
- uint8_t hid_spec_type = 0x22;
- uint16_t hid_attr_lang[] = { 0x409, 0x100 };
- static const uint16_t ctrl = 0x11;
- static const uint16_t intr = 0x13;
- static const uint16_t hid_attr[] = { 0x100, 0x111, 0x40, 0x0d, 0x01, 0x01 };
- static const uint16_t hid_attr2[] = { 0x0, 0x01, 0x100, 0x1f40, 0x01, 0x01 };
- const uint8_t hid_spec[] = {
- 0x05, 0x01, // usage page
- 0x09, 0x06, // keyboard
- 0xa1, 0x01, // key codes
- 0x85, 0x01, // minimum
- 0x05, 0x07, // max
- 0x19, 0xe0, // logical min
- 0x29, 0xe7, // logical max
- 0x15, 0x00, // report size
- 0x25, 0x01, // report count
- 0x75, 0x01, // input data variable absolute
- 0x95, 0x08, // report count
- 0x81, 0x02, // report size
- 0x75, 0x08,
- 0x95, 0x01,
- 0x81, 0x01,
- 0x75, 0x01,
- 0x95, 0x05,
- 0x05, 0x08,
- 0x19, 0x01,
- 0x29, 0x05,
- 0x91, 0x02,
- 0x75, 0x03,
- 0x95, 0x01,
- 0x91, 0x01,
- 0x75, 0x08,
- 0x95, 0x06,
- 0x15, 0x00,
- 0x26, 0xff,
- 0x00, 0x05,
- 0x07, 0x19,
- 0x00, 0x2a,
- 0xff, 0x00,
- 0x81, 0x00,
- 0x75, 0x01,
- 0x95, 0x01,
- 0x15, 0x00,
- 0x25, 0x01,
- 0x05, 0x0c,
- 0x09, 0xb8,
- 0x81, 0x06,
- 0x09, 0xe2,
- 0x81, 0x06,
- 0x09, 0xe9,
- 0x81, 0x02,
- 0x09, 0xea,
- 0x81, 0x02,
- 0x75, 0x01,
- 0x95, 0x04,
- 0x81, 0x01,
- 0xc0 // end tag
- };
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(0, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_add_lang_attr(&record);
-
- sdp_uuid16_create(&hidkb_uuid, HID_SVCLASS_ID);
- svclass_id = sdp_list_append(0, &hidkb_uuid);
- sdp_set_service_classes(&record, svclass_id);
-
- sdp_uuid16_create(&profile[0].uuid, HID_PROFILE_ID);
- profile[0].version = 0x0100;
- pfseq = sdp_list_append(0, profile);
- sdp_set_profile_descs(&record, pfseq);
-
- /* protocols */
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto[1] = sdp_list_append(0, &l2cap_uuid);
- psm = sdp_data_alloc(SDP_UINT16, &ctrl);
- proto[1] = sdp_list_append(proto[1], psm);
- apseq = sdp_list_append(0, proto[1]);
-
- sdp_uuid16_create(&hidp_uuid, HIDP_UUID);
- proto[2] = sdp_list_append(0, &hidp_uuid);
- apseq = sdp_list_append(apseq, proto[2]);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(&record, aproto);
-
- /* additional protocols */
- proto[1] = sdp_list_append(0, &l2cap_uuid);
- psm = sdp_data_alloc(SDP_UINT16, &intr);
- proto[1] = sdp_list_append(proto[1], psm);
- apseq = sdp_list_append(0, proto[1]);
-
- sdp_uuid16_create(&hidp_uuid, HIDP_UUID);
- proto[2] = sdp_list_append(0, &hidp_uuid);
- apseq = sdp_list_append(apseq, proto[2]);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_add_access_protos(&record, aproto);
-
- sdp_set_info_attr(&record, "HID Keyboard", NULL, NULL);
-
- for (i = 0; i < sizeof(hid_attr) / 2; i++)
- sdp_attr_add_new(&record,
- SDP_ATTR_HID_DEVICE_RELEASE_NUMBER + i,
- SDP_UINT16, &hid_attr[i]);
-
- dtds[0] = &dtd2;
- values[0] = &hid_spec_type;
- dtds[1] = &dtd_data;
- values[1] = (uint8_t *) hid_spec;
- leng[0] = 0;
- leng[1] = sizeof(hid_spec);
- hid_spec_lst = sdp_seq_alloc_with_length(dtds, values, leng, 2);
- hid_spec_lst2 = sdp_data_alloc(SDP_SEQ8, hid_spec_lst);
- sdp_attr_add(&record, SDP_ATTR_HID_DESCRIPTOR_LIST, hid_spec_lst2);
-
- for (i = 0; i < sizeof(hid_attr_lang) / 2; i++) {
- dtds2[i] = &dtd;
- values2[i] = &hid_attr_lang[i];
- }
-
- lang_lst = sdp_seq_alloc(dtds2, values2, sizeof(hid_attr_lang) / 2);
- lang_lst2 = sdp_data_alloc(SDP_SEQ8, lang_lst);
- sdp_attr_add(&record, SDP_ATTR_HID_LANG_ID_BASE_LIST, lang_lst2);
-
- sdp_attr_add_new(&record, SDP_ATTR_HID_SDP_DISABLE, SDP_UINT16, &hid_attr2[0]);
-
- for (i = 0; i < sizeof(hid_attr2) / 2 - 1; i++)
- sdp_attr_add_new(&record, SDP_ATTR_HID_REMOTE_WAKEUP + i,
- SDP_UINT16, &hid_attr2[i + 1]);
-
- if (sdp_record_register(session, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- return -1;
- }
-
- printf("HID keyboard service registered\n");
-
- return 0;
-}
-
-static int add_hid_wiimote(sdp_session_t *session, svc_info_t *si)
-{
- sdp_record_t record;
- sdp_list_t *svclass_id, *pfseq, *apseq, *root;
- uuid_t root_uuid, hid_uuid, l2cap_uuid, hidp_uuid;
- sdp_profile_desc_t profile[1];
- sdp_list_t *aproto, *proto[3];
- sdp_data_t *psm, *lang_lst, *lang_lst2, *hid_spec_lst, *hid_spec_lst2;
- unsigned int i;
- uint8_t dtd = SDP_UINT16;
- uint8_t dtd2 = SDP_UINT8;
- uint8_t dtd_data = SDP_TEXT_STR8;
- void *dtds[2];
- void *values[2];
- void *dtds2[2];
- void *values2[2];
- int leng[2];
- uint8_t hid_spec_type = 0x22;
- uint16_t hid_attr_lang[] = { 0x409, 0x100 };
- uint16_t ctrl = 0x11, intr = 0x13;
- uint16_t hid_release = 0x0100, parser_version = 0x0111;
- uint8_t subclass = 0x04, country = 0x33;
- uint8_t virtual_cable = 0, reconnect = 1, sdp_disable = 0;
- uint8_t battery = 1, remote_wakeup = 1;
- uint16_t profile_version = 0x0100, superv_timeout = 0x0c80;
- uint8_t norm_connect = 0, boot_device = 0;
- const uint8_t hid_spec[] = {
- 0x05, 0x01, 0x09, 0x05, 0xa1, 0x01, 0x85, 0x10,
- 0x15, 0x00, 0x26, 0xff, 0x00, 0x75, 0x08, 0x95,
- 0x01, 0x06, 0x00, 0xff, 0x09, 0x01, 0x91, 0x00,
- 0x85, 0x11, 0x95, 0x01, 0x09, 0x01, 0x91, 0x00,
- 0x85, 0x12, 0x95, 0x02, 0x09, 0x01, 0x91, 0x00,
- 0x85, 0x13, 0x95, 0x01, 0x09, 0x01, 0x91, 0x00,
- 0x85, 0x14, 0x95, 0x01, 0x09, 0x01, 0x91, 0x00,
- 0x85, 0x15, 0x95, 0x01, 0x09, 0x01, 0x91, 0x00,
- 0x85, 0x16, 0x95, 0x15, 0x09, 0x01, 0x91, 0x00,
- 0x85, 0x17, 0x95, 0x06, 0x09, 0x01, 0x91, 0x00,
- 0x85, 0x18, 0x95, 0x15, 0x09, 0x01, 0x91, 0x00,
- 0x85, 0x19, 0x95, 0x01, 0x09, 0x01, 0x91, 0x00,
- 0x85, 0x1a, 0x95, 0x01, 0x09, 0x01, 0x91, 0x00,
- 0x85, 0x20, 0x95, 0x06, 0x09, 0x01, 0x81, 0x00,
- 0x85, 0x21, 0x95, 0x15, 0x09, 0x01, 0x81, 0x00,
- 0x85, 0x22, 0x95, 0x04, 0x09, 0x01, 0x81, 0x00,
- 0x85, 0x30, 0x95, 0x02, 0x09, 0x01, 0x81, 0x00,
- 0x85, 0x31, 0x95, 0x05, 0x09, 0x01, 0x81, 0x00,
- 0x85, 0x32, 0x95, 0x0a, 0x09, 0x01, 0x81, 0x00,
- 0x85, 0x33, 0x95, 0x11, 0x09, 0x01, 0x81, 0x00,
- 0x85, 0x34, 0x95, 0x15, 0x09, 0x01, 0x81, 0x00,
- 0x85, 0x35, 0x95, 0x15, 0x09, 0x01, 0x81, 0x00,
- 0x85, 0x36, 0x95, 0x15, 0x09, 0x01, 0x81, 0x00,
- 0x85, 0x37, 0x95, 0x15, 0x09, 0x01, 0x81, 0x00,
- 0x85, 0x3d, 0x95, 0x15, 0x09, 0x01, 0x81, 0x00,
- 0x85, 0x3e, 0x95, 0x15, 0x09, 0x01, 0x81, 0x00,
- 0x85, 0x3f, 0x95, 0x15, 0x09, 0x01, 0x81, 0x00,
- 0xc0, 0x00
- };
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(NULL, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&hid_uuid, HID_SVCLASS_ID);
- svclass_id = sdp_list_append(NULL, &hid_uuid);
- sdp_set_service_classes(&record, svclass_id);
-
- sdp_uuid16_create(&profile[0].uuid, HID_PROFILE_ID);
- profile[0].version = 0x0100;
- pfseq = sdp_list_append(NULL, profile);
- sdp_set_profile_descs(&record, pfseq);
-
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto[1] = sdp_list_append(0, &l2cap_uuid);
- psm = sdp_data_alloc(SDP_UINT16, &ctrl);
- proto[1] = sdp_list_append(proto[1], psm);
- apseq = sdp_list_append(0, proto[1]);
-
- sdp_uuid16_create(&hidp_uuid, HIDP_UUID);
- proto[2] = sdp_list_append(0, &hidp_uuid);
- apseq = sdp_list_append(apseq, proto[2]);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(&record, aproto);
-
- proto[1] = sdp_list_append(0, &l2cap_uuid);
- psm = sdp_data_alloc(SDP_UINT16, &intr);
- proto[1] = sdp_list_append(proto[1], psm);
- apseq = sdp_list_append(0, proto[1]);
-
- sdp_uuid16_create(&hidp_uuid, HIDP_UUID);
- proto[2] = sdp_list_append(0, &hidp_uuid);
- apseq = sdp_list_append(apseq, proto[2]);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_add_access_protos(&record, aproto);
-
- sdp_add_lang_attr(&record);
-
- sdp_set_info_attr(&record, "Nintendo RVL-CNT-01",
- "Nintendo", "Nintendo RVL-CNT-01");
-
- sdp_attr_add_new(&record, SDP_ATTR_HID_DEVICE_RELEASE_NUMBER,
- SDP_UINT16, &hid_release);
-
- sdp_attr_add_new(&record, SDP_ATTR_HID_PARSER_VERSION,
- SDP_UINT16, &parser_version);
-
- sdp_attr_add_new(&record, SDP_ATTR_HID_DEVICE_SUBCLASS,
- SDP_UINT8, &subclass);
-
- sdp_attr_add_new(&record, SDP_ATTR_HID_COUNTRY_CODE,
- SDP_UINT8, &country);
-
- sdp_attr_add_new(&record, SDP_ATTR_HID_VIRTUAL_CABLE,
- SDP_BOOL, &virtual_cable);
-
- sdp_attr_add_new(&record, SDP_ATTR_HID_RECONNECT_INITIATE,
- SDP_BOOL, &reconnect);
-
- dtds[0] = &dtd2;
- values[0] = &hid_spec_type;
- dtds[1] = &dtd_data;
- values[1] = (uint8_t *) hid_spec;
- leng[0] = 0;
- leng[1] = sizeof(hid_spec);
- hid_spec_lst = sdp_seq_alloc_with_length(dtds, values, leng, 2);
- hid_spec_lst2 = sdp_data_alloc(SDP_SEQ8, hid_spec_lst);
- sdp_attr_add(&record, SDP_ATTR_HID_DESCRIPTOR_LIST, hid_spec_lst2);
-
- for (i = 0; i < sizeof(hid_attr_lang) / 2; i++) {
- dtds2[i] = &dtd;
- values2[i] = &hid_attr_lang[i];
- }
-
- lang_lst = sdp_seq_alloc(dtds2, values2, sizeof(hid_attr_lang) / 2);
- lang_lst2 = sdp_data_alloc(SDP_SEQ8, lang_lst);
- sdp_attr_add(&record, SDP_ATTR_HID_LANG_ID_BASE_LIST, lang_lst2);
-
- sdp_attr_add_new(&record, SDP_ATTR_HID_SDP_DISABLE,
- SDP_BOOL, &sdp_disable);
-
- sdp_attr_add_new(&record, SDP_ATTR_HID_BATTERY_POWER,
- SDP_BOOL, &battery);
-
- sdp_attr_add_new(&record, SDP_ATTR_HID_REMOTE_WAKEUP,
- SDP_BOOL, &remote_wakeup);
-
- sdp_attr_add_new(&record, SDP_ATTR_HID_PROFILE_VERSION,
- SDP_UINT16, &profile_version);
-
- sdp_attr_add_new(&record, SDP_ATTR_HID_SUPERVISION_TIMEOUT,
- SDP_UINT16, &superv_timeout);
-
- sdp_attr_add_new(&record, SDP_ATTR_HID_NORMALLY_CONNECTABLE,
- SDP_BOOL, &norm_connect);
-
- sdp_attr_add_new(&record, SDP_ATTR_HID_BOOT_DEVICE,
- SDP_BOOL, &boot_device);
-
- if (sdp_record_register(session, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- return -1;
- }
-
- printf("Wii-Mote service registered\n");
-
- return 0;
-}
-
-static int add_cip(sdp_session_t *session, svc_info_t *si)
-{
- sdp_list_t *svclass_id, *pfseq, *apseq, *root;
- uuid_t root_uuid, l2cap, cmtp, cip;
- sdp_profile_desc_t profile[1];
- sdp_list_t *aproto, *proto[2];
- sdp_record_t record;
- uint16_t psm = si->psm ? si->psm : 0x1001;
- uint8_t netid = si->network ? si->network : 0x02; // 0x02 = ISDN, 0x03 = GSM
- sdp_data_t *network = sdp_data_alloc(SDP_UINT8, &netid);
- int ret = 0;
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(0, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&cip, CIP_SVCLASS_ID);
- svclass_id = sdp_list_append(0, &cip);
- sdp_set_service_classes(&record, svclass_id);
-
- sdp_uuid16_create(&profile[0].uuid, CIP_PROFILE_ID);
- profile[0].version = 0x0100;
- pfseq = sdp_list_append(0, &profile[0]);
- sdp_set_profile_descs(&record, pfseq);
-
- sdp_uuid16_create(&l2cap, L2CAP_UUID);
- proto[0] = sdp_list_append(0, &l2cap);
- apseq = sdp_list_append(0, proto[0]);
- proto[0] = sdp_list_append(proto[0], sdp_data_alloc(SDP_UINT16, &psm));
- apseq = sdp_list_append(apseq, proto[0]);
-
- sdp_uuid16_create(&cmtp, CMTP_UUID);
- proto[1] = sdp_list_append(0, &cmtp);
- apseq = sdp_list_append(apseq, proto[1]);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(&record, aproto);
-
- sdp_attr_add(&record, SDP_ATTR_EXTERNAL_NETWORK, network);
-
- sdp_set_info_attr(&record, "Common ISDN Access", 0, 0);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- ret = -1;
- goto end;
- }
-
- printf("CIP service registered\n");
-
-end:
- sdp_list_free(proto[0], 0);
- sdp_list_free(proto[1], 0);
- sdp_list_free(apseq, 0);
- sdp_list_free(aproto, 0);
- sdp_data_free(network);
-
- return ret;
-}
-
-static int add_ctp(sdp_session_t *session, svc_info_t *si)
-{
- sdp_list_t *svclass_id, *pfseq, *apseq, *root;
- uuid_t root_uuid, l2cap, tcsbin, ctp;
- sdp_profile_desc_t profile[1];
- sdp_list_t *aproto, *proto[2];
- sdp_record_t record;
- uint8_t netid = si->network ? si->network : 0x02; // 0x01-0x07 cf. p120 profile document
- sdp_data_t *network = sdp_data_alloc(SDP_UINT8, &netid);
- int ret = 0;
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(0, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&ctp, CORDLESS_TELEPHONY_SVCLASS_ID);
- svclass_id = sdp_list_append(0, &ctp);
- sdp_set_service_classes(&record, svclass_id);
-
- sdp_uuid16_create(&profile[0].uuid, CORDLESS_TELEPHONY_PROFILE_ID);
- profile[0].version = 0x0100;
- pfseq = sdp_list_append(0, &profile[0]);
- sdp_set_profile_descs(&record, pfseq);
-
- sdp_uuid16_create(&l2cap, L2CAP_UUID);
- proto[0] = sdp_list_append(0, &l2cap);
- apseq = sdp_list_append(0, proto[0]);
-
- sdp_uuid16_create(&tcsbin, TCS_BIN_UUID);
- proto[1] = sdp_list_append(0, &tcsbin);
- apseq = sdp_list_append(apseq, proto[1]);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(&record, aproto);
-
- sdp_attr_add(&record, SDP_ATTR_EXTERNAL_NETWORK, network);
-
- sdp_set_info_attr(&record, "Cordless Telephony", 0, 0);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- ret = -1;
- goto end;
- }
-
- printf("CTP service registered\n");
-
-end:
- sdp_list_free(proto[0], 0);
- sdp_list_free(proto[1], 0);
- sdp_list_free(apseq, 0);
- sdp_list_free(aproto, 0);
- sdp_data_free(network);
-
- return ret;
-}
-
-static int add_a2source(sdp_session_t *session, svc_info_t *si)
-{
- sdp_list_t *svclass_id, *pfseq, *apseq, *root;
- uuid_t root_uuid, l2cap, avdtp, a2src;
- sdp_profile_desc_t profile[1];
- sdp_list_t *aproto, *proto[2];
- sdp_record_t record;
- sdp_data_t *psm, *version;
- uint16_t lp = 0x0019, ver = 0x0100;
- int ret = 0;
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(0, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&a2src, AUDIO_SOURCE_SVCLASS_ID);
- svclass_id = sdp_list_append(0, &a2src);
- sdp_set_service_classes(&record, svclass_id);
-
- sdp_uuid16_create(&profile[0].uuid, ADVANCED_AUDIO_PROFILE_ID);
- profile[0].version = 0x0100;
- pfseq = sdp_list_append(0, &profile[0]);
- sdp_set_profile_descs(&record, pfseq);
-
- sdp_uuid16_create(&l2cap, L2CAP_UUID);
- proto[0] = sdp_list_append(0, &l2cap);
- psm = sdp_data_alloc(SDP_UINT16, &lp);
- proto[0] = sdp_list_append(proto[0], psm);
- apseq = sdp_list_append(0, proto[0]);
-
- sdp_uuid16_create(&avdtp, AVDTP_UUID);
- proto[1] = sdp_list_append(0, &avdtp);
- version = sdp_data_alloc(SDP_UINT16, &ver);
- proto[1] = sdp_list_append(proto[1], version);
- apseq = sdp_list_append(apseq, proto[1]);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(&record, aproto);
-
- sdp_set_info_attr(&record, "Audio Source", 0, 0);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- ret = -1;
- goto done;
- }
-
- printf("Audio source service registered\n");
-
-done:
- sdp_list_free(proto[0], 0);
- sdp_list_free(proto[1], 0);
- sdp_list_free(apseq, 0);
- sdp_list_free(aproto, 0);
-
- return ret;
-}
-
-static int add_a2sink(sdp_session_t *session, svc_info_t *si)
-{
- sdp_list_t *svclass_id, *pfseq, *apseq, *root;
- uuid_t root_uuid, l2cap, avdtp, a2snk;
- sdp_profile_desc_t profile[1];
- sdp_list_t *aproto, *proto[2];
- sdp_record_t record;
- sdp_data_t *psm, *version;
- uint16_t lp = 0x0019, ver = 0x0100;
- int ret = 0;
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(0, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&a2snk, AUDIO_SINK_SVCLASS_ID);
- svclass_id = sdp_list_append(0, &a2snk);
- sdp_set_service_classes(&record, svclass_id);
-
- sdp_uuid16_create(&profile[0].uuid, ADVANCED_AUDIO_PROFILE_ID);
- profile[0].version = 0x0100;
- pfseq = sdp_list_append(0, &profile[0]);
- sdp_set_profile_descs(&record, pfseq);
-
- sdp_uuid16_create(&l2cap, L2CAP_UUID);
- proto[0] = sdp_list_append(0, &l2cap);
- psm = sdp_data_alloc(SDP_UINT16, &lp);
- proto[0] = sdp_list_append(proto[0], psm);
- apseq = sdp_list_append(0, proto[0]);
-
- sdp_uuid16_create(&avdtp, AVDTP_UUID);
- proto[1] = sdp_list_append(0, &avdtp);
- version = sdp_data_alloc(SDP_UINT16, &ver);
- proto[1] = sdp_list_append(proto[1], version);
- apseq = sdp_list_append(apseq, proto[1]);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(&record, aproto);
-
- sdp_set_info_attr(&record, "Audio Sink", 0, 0);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- ret = -1;
- goto done;
- }
-
- printf("Audio sink service registered\n");
-
-done:
- sdp_list_free(proto[0], 0);
- sdp_list_free(proto[1], 0);
- sdp_list_free(apseq, 0);
- sdp_list_free(aproto, 0);
-
- return ret;
-}
-
-static int add_avrct(sdp_session_t *session, svc_info_t *si)
-{
- sdp_list_t *svclass_id, *pfseq, *apseq, *root;
- uuid_t root_uuid, l2cap, avctp, avrct;
- sdp_profile_desc_t profile[1];
- sdp_list_t *aproto, *proto[2];
- sdp_record_t record;
- sdp_data_t *psm, *version, *features;
- uint16_t lp = 0x0017, ver = 0x0100, feat = 0x000f;
- int ret = 0;
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(0, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&avrct, AV_REMOTE_SVCLASS_ID);
- svclass_id = sdp_list_append(0, &avrct);
- sdp_set_service_classes(&record, svclass_id);
-
- sdp_uuid16_create(&profile[0].uuid, AV_REMOTE_PROFILE_ID);
- profile[0].version = 0x0100;
- pfseq = sdp_list_append(0, &profile[0]);
- sdp_set_profile_descs(&record, pfseq);
-
- sdp_uuid16_create(&l2cap, L2CAP_UUID);
- proto[0] = sdp_list_append(0, &l2cap);
- psm = sdp_data_alloc(SDP_UINT16, &lp);
- proto[0] = sdp_list_append(proto[0], psm);
- apseq = sdp_list_append(0, proto[0]);
-
- sdp_uuid16_create(&avctp, AVCTP_UUID);
- proto[1] = sdp_list_append(0, &avctp);
- version = sdp_data_alloc(SDP_UINT16, &ver);
- proto[1] = sdp_list_append(proto[1], version);
- apseq = sdp_list_append(apseq, proto[1]);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(&record, aproto);
-
- features = sdp_data_alloc(SDP_UINT16, &feat);
- sdp_attr_add(&record, SDP_ATTR_SUPPORTED_FEATURES, features);
-
- sdp_set_info_attr(&record, "AVRCP CT", 0, 0);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- ret = -1;
- goto done;
- }
-
- printf("Remote control service registered\n");
-
-done:
- sdp_list_free(proto[0], 0);
- sdp_list_free(proto[1], 0);
- sdp_list_free(apseq, 0);
- sdp_list_free(aproto, 0);
-
- return ret;
-}
-
-static int add_avrtg(sdp_session_t *session, svc_info_t *si)
-{
- sdp_list_t *svclass_id, *pfseq, *apseq, *root;
- uuid_t root_uuid, l2cap, avctp, avrtg;
- sdp_profile_desc_t profile[1];
- sdp_list_t *aproto, *proto[2];
- sdp_record_t record;
- sdp_data_t *psm, *version, *features;
- uint16_t lp = 0x0017, ver = 0x0100, feat = 0x000f;
- int ret = 0;
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(0, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&avrtg, AV_REMOTE_TARGET_SVCLASS_ID);
- svclass_id = sdp_list_append(0, &avrtg);
- sdp_set_service_classes(&record, svclass_id);
-
- sdp_uuid16_create(&profile[0].uuid, AV_REMOTE_PROFILE_ID);
- profile[0].version = 0x0100;
- pfseq = sdp_list_append(0, &profile[0]);
- sdp_set_profile_descs(&record, pfseq);
-
- sdp_uuid16_create(&l2cap, L2CAP_UUID);
- proto[0] = sdp_list_append(0, &l2cap);
- psm = sdp_data_alloc(SDP_UINT16, &lp);
- proto[0] = sdp_list_append(proto[0], psm);
- apseq = sdp_list_append(0, proto[0]);
-
- sdp_uuid16_create(&avctp, AVCTP_UUID);
- proto[1] = sdp_list_append(0, &avctp);
- version = sdp_data_alloc(SDP_UINT16, &ver);
- proto[1] = sdp_list_append(proto[1], version);
- apseq = sdp_list_append(apseq, proto[1]);
-
- aproto = sdp_list_append(0, apseq);
- sdp_set_access_protos(&record, aproto);
-
- features = sdp_data_alloc(SDP_UINT16, &feat);
- sdp_attr_add(&record, SDP_ATTR_SUPPORTED_FEATURES, features);
-
- sdp_set_info_attr(&record, "AVRCP TG", 0, 0);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- ret = -1;
- goto done;
- }
-
- printf("Remote target service registered\n");
-
-done:
- sdp_list_free(proto[0], 0);
- sdp_list_free(proto[1], 0);
- sdp_list_free(apseq, 0);
- sdp_list_free(aproto, 0);
-
- return ret;
-}
-
-static int add_udi_ue(sdp_session_t *session, svc_info_t *si)
-{
- sdp_record_t record;
- sdp_list_t *root, *svclass, *proto;
- uuid_t root_uuid, svclass_uuid, l2cap_uuid, rfcomm_uuid;
- uint8_t channel = si->channel ? si->channel: 18;
-
- memset(&record, 0, sizeof(record));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(NULL, &root_uuid);
- sdp_set_browse_groups(&record, root);
- sdp_list_free(root, NULL);
-
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto = sdp_list_append(NULL, sdp_list_append(NULL, &l2cap_uuid));
-
- sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
- proto = sdp_list_append(proto, sdp_list_append(
- sdp_list_append(NULL, &rfcomm_uuid), sdp_data_alloc(SDP_UINT8, &channel)));
-
- sdp_set_access_protos(&record, sdp_list_append(NULL, proto));
-
- sdp_uuid16_create(&svclass_uuid, UDI_MT_SVCLASS_ID);
- svclass = sdp_list_append(NULL, &svclass_uuid);
- sdp_set_service_classes(&record, svclass);
- sdp_list_free(svclass, NULL);
-
- sdp_set_info_attr(&record, "UDI UE", NULL, NULL);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- return -1;
- }
-
- printf("UDI UE service registered\n");
-
- return 0;
-}
-
-static int add_udi_te(sdp_session_t *session, svc_info_t *si)
-{
- sdp_record_t record;
- sdp_list_t *root, *svclass, *proto;
- uuid_t root_uuid, svclass_uuid, l2cap_uuid, rfcomm_uuid;
- uint8_t channel = si->channel ? si->channel: 19;
-
- memset(&record, 0, sizeof(record));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(NULL, &root_uuid);
- sdp_set_browse_groups(&record, root);
- sdp_list_free(root, NULL);
-
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto = sdp_list_append(NULL, sdp_list_append(NULL, &l2cap_uuid));
-
- sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
- proto = sdp_list_append(proto, sdp_list_append(
- sdp_list_append(NULL, &rfcomm_uuid), sdp_data_alloc(SDP_UINT8, &channel)));
-
- sdp_set_access_protos(&record, sdp_list_append(NULL, proto));
-
- sdp_uuid16_create(&svclass_uuid, UDI_TA_SVCLASS_ID);
- svclass = sdp_list_append(NULL, &svclass_uuid);
- sdp_set_service_classes(&record, svclass);
- sdp_list_free(svclass, NULL);
-
- sdp_set_info_attr(&record, "UDI TE", NULL, NULL);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- return -1;
- }
-
- printf("UDI TE service registered\n");
-
- return 0;
-}
-
static unsigned char sr1_uuid[] = { 0xbc, 0x19, 0x9c, 0x24, 0x95, 0x8b, 0x4c, 0xc0,
0xa2, 0xcb, 0xfd, 0x8a, 0x30, 0xbf, 0x32, 0x06 };
-static int add_sr1(sdp_session_t *session, svc_info_t *si)
-{
- sdp_record_t record;
- sdp_list_t *root, *svclass;
- uuid_t root_uuid, svclass_uuid;
-
- memset(&record, 0, sizeof(record));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(NULL, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid128_create(&svclass_uuid, (void *) sr1_uuid);
- svclass = sdp_list_append(NULL, &svclass_uuid);
- sdp_set_service_classes(&record, svclass);
-
- sdp_set_info_attr(&record, "TOSHIBA SR-1", NULL, NULL);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- return -1;
- }
-
- printf("Toshiba Speech Recognition SR-1 service record registered\n");
-
- return 0;
-}
-
static unsigned char syncmls_uuid[] = { 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02 };
static unsigned char syncmlc_uuid[] = { 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x02 };
-static int add_syncml(sdp_session_t *session, svc_info_t *si)
-{
- sdp_record_t record;
- sdp_list_t *root, *svclass, *proto;
- uuid_t root_uuid, svclass_uuid, l2cap_uuid, rfcomm_uuid, obex_uuid;
- uint8_t channel = si->channel ? si->channel: 15;
-
- memset(&record, 0, sizeof(record));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(NULL, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid128_create(&svclass_uuid, (void *) syncmlc_uuid);
- svclass = sdp_list_append(NULL, &svclass_uuid);
- sdp_set_service_classes(&record, svclass);
-
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto = sdp_list_append(NULL, sdp_list_append(NULL, &l2cap_uuid));
-
- sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
- proto = sdp_list_append(proto, sdp_list_append(
- sdp_list_append(NULL, &rfcomm_uuid), sdp_data_alloc(SDP_UINT8, &channel)));
-
- sdp_uuid16_create(&obex_uuid, OBEX_UUID);
- proto = sdp_list_append(proto, sdp_list_append(NULL, &obex_uuid));
-
- sdp_set_access_protos(&record, sdp_list_append(NULL, proto));
-
- sdp_set_info_attr(&record, "SyncML Client", NULL, NULL);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- return -1;
- }
-
- printf("SyncML Client service record registered\n");
-
- return 0;
-}
-
static unsigned char async_uuid[] = { 0x03, 0x50, 0x27, 0x8F, 0x3D, 0xCA, 0x4E, 0x62,
0x83, 0x1D, 0xA4, 0x11, 0x65, 0xFF, 0x90, 0x6C };
-static int add_activesync(sdp_session_t *session, svc_info_t *si)
-{
- sdp_record_t record;
- sdp_list_t *root, *svclass, *proto;
- uuid_t root_uuid, svclass_uuid, l2cap_uuid, rfcomm_uuid;
- uint8_t channel = si->channel ? si->channel: 21;
-
- memset(&record, 0, sizeof(record));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(NULL, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto = sdp_list_append(NULL, sdp_list_append(NULL, &l2cap_uuid));
-
- sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
- proto = sdp_list_append(proto, sdp_list_append(
- sdp_list_append(NULL, &rfcomm_uuid), sdp_data_alloc(SDP_UINT8, &channel)));
-
- sdp_set_access_protos(&record, sdp_list_append(NULL, proto));
-
- sdp_uuid128_create(&svclass_uuid, (void *) async_uuid);
- svclass = sdp_list_append(NULL, &svclass_uuid);
- sdp_set_service_classes(&record, svclass);
-
- sdp_set_info_attr(&record, "Microsoft ActiveSync", NULL, NULL);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- return -1;
- }
-
- printf("ActiveSync service record registered\n");
-
- return 0;
-}
-
static unsigned char hotsync_uuid[] = { 0xD8, 0x0C, 0xF9, 0xEA, 0x13, 0x4C, 0x11, 0xD5,
0x83, 0xCE, 0x00, 0x30, 0x65, 0x7C, 0x54, 0x3C };
-static int add_hotsync(sdp_session_t *session, svc_info_t *si)
-{
- sdp_record_t record;
- sdp_list_t *root, *svclass, *proto;
- uuid_t root_uuid, svclass_uuid, l2cap_uuid, rfcomm_uuid;
- uint8_t channel = si->channel ? si->channel: 22;
-
- memset(&record, 0, sizeof(record));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(NULL, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto = sdp_list_append(NULL, sdp_list_append(NULL, &l2cap_uuid));
-
- sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
- proto = sdp_list_append(proto, sdp_list_append(
- sdp_list_append(NULL, &rfcomm_uuid), sdp_data_alloc(SDP_UINT8, &channel)));
-
- sdp_set_access_protos(&record, sdp_list_append(NULL, proto));
-
- sdp_uuid128_create(&svclass_uuid, (void *) hotsync_uuid);
- svclass = sdp_list_append(NULL, &svclass_uuid);
- sdp_set_service_classes(&record, svclass);
-
- sdp_set_info_attr(&record, "PalmOS HotSync", NULL, NULL);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- return -1;
- }
-
- printf("HotSync service record registered\n");
-
- return 0;
-}
-
static unsigned char palmos_uuid[] = { 0xF5, 0xBE, 0xB6, 0x51, 0x41, 0x71, 0x40, 0x51,
0xAC, 0xF5, 0x6C, 0xA7, 0x20, 0x22, 0x42, 0xF0 };
-static int add_palmos(sdp_session_t *session, svc_info_t *si)
-{
- sdp_record_t record;
- sdp_list_t *root, *svclass;
- uuid_t root_uuid, svclass_uuid;
-
- memset(&record, 0, sizeof(record));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(NULL, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid128_create(&svclass_uuid, (void *) palmos_uuid);
- svclass = sdp_list_append(NULL, &svclass_uuid);
- sdp_set_service_classes(&record, svclass);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- return -1;
- }
-
- printf("PalmOS service record registered\n");
-
- return 0;
-}
-
static unsigned char nokid_uuid[] = { 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x01 };
-static int add_nokiaid(sdp_session_t *session, svc_info_t *si)
-{
- sdp_record_t record;
- sdp_list_t *root, *svclass;
- uuid_t root_uuid, svclass_uuid;
- uint16_t verid = 0x005f;
- sdp_data_t *version = sdp_data_alloc(SDP_UINT16, &verid);
-
- memset(&record, 0, sizeof(record));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(NULL, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid128_create(&svclass_uuid, (void *) nokid_uuid);
- svclass = sdp_list_append(NULL, &svclass_uuid);
- sdp_set_service_classes(&record, svclass);
-
- sdp_attr_add(&record, SDP_ATTR_SERVICE_VERSION, version);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- sdp_data_free(version);
- return -1;
- }
-
- printf("Nokia ID service record registered\n");
-
- return 0;
-}
-
static unsigned char pcsuite_uuid[] = { 0x00, 0x00, 0x50, 0x02, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x01 };
-static int add_pcsuite(sdp_session_t *session, svc_info_t *si)
-{
- sdp_record_t record;
- sdp_list_t *root, *svclass, *proto;
- uuid_t root_uuid, svclass_uuid, l2cap_uuid, rfcomm_uuid;
- uint8_t channel = si->channel ? si->channel: 14;
-
- memset(&record, 0, sizeof(record));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(NULL, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto = sdp_list_append(NULL, sdp_list_append(NULL, &l2cap_uuid));
-
- sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
- proto = sdp_list_append(proto, sdp_list_append(
- sdp_list_append(NULL, &rfcomm_uuid), sdp_data_alloc(SDP_UINT8, &channel)));
-
- sdp_set_access_protos(&record, sdp_list_append(NULL, proto));
-
- sdp_uuid128_create(&svclass_uuid, (void *) pcsuite_uuid);
- svclass = sdp_list_append(NULL, &svclass_uuid);
- sdp_set_service_classes(&record, svclass);
-
- sdp_set_info_attr(&record, "Nokia PC Suite", NULL, NULL);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- return -1;
- }
-
- printf("Nokia PC Suite service registered\n");
-
- return 0;
-}
-
static unsigned char nftp_uuid[] = { 0x00, 0x00, 0x50, 0x05, 0x00, 0x00, 0x10, 0x00,
0x80, 0x00, 0x00, 0x02, 0xEE, 0x00, 0x00, 0x01 };
@@ -3302,436 +1184,69 @@ static unsigned char apple_uuid[] = { 0xf0, 0x72, 0x2e, 0x20, 0x0f, 0x8b, 0x4e,
static unsigned char iap_uuid[] = { 0x00, 0x00, 0x00, 0x00, 0xde, 0xca, 0xfa, 0xde,
0xde, 0xca, 0xde, 0xaf, 0xde, 0xca, 0xca, 0xfe };
-static int add_apple(sdp_session_t *session, svc_info_t *si)
-{
- sdp_record_t record;
- sdp_list_t *root;
- uuid_t root_uuid;
- uint32_t attr783 = 0x00000000;
- uint32_t attr785 = 0x00000002;
- uint16_t attr786 = 0x1234;
-
- memset(&record, 0, sizeof(record));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(NULL, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_attr_add_new(&record, 0x0780, SDP_UUID128, (void *) apple_uuid);
- sdp_attr_add_new(&record, 0x0781, SDP_TEXT_STR8, (void *) "Macmini");
- sdp_attr_add_new(&record, 0x0782, SDP_TEXT_STR8, (void *) "PowerMac10,1");
- sdp_attr_add_new(&record, 0x0783, SDP_UINT32, (void *) &attr783);
- sdp_attr_add_new(&record, 0x0784, SDP_TEXT_STR8, (void *) "1.6.6f22");
- sdp_attr_add_new(&record, 0x0785, SDP_UINT32, (void *) &attr785);
- sdp_attr_add_new(&record, 0x0786, SDP_UUID16, (void *) &attr786);
-
- sdp_set_info_attr(&record, "Apple Macintosh Attributes", NULL, NULL);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- return -1;
- }
-
- printf("Apple attribute service registered\n");
-
- return 0;
-}
-
-static int add_isync(sdp_session_t *session, svc_info_t *si)
-{
- sdp_record_t record;
- sdp_list_t *root, *svclass, *proto;
- uuid_t root_uuid, svclass_uuid, serial_uuid, l2cap_uuid, rfcomm_uuid;
- uint8_t channel = si->channel ? si->channel : 16;
-
- memset(&record, 0, sizeof(record));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(NULL, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto = sdp_list_append(NULL, sdp_list_append(NULL, &l2cap_uuid));
-
- sdp_uuid16_create(&rfcomm_uuid, RFCOMM_UUID);
- proto = sdp_list_append(proto, sdp_list_append(
- sdp_list_append(NULL, &rfcomm_uuid), sdp_data_alloc(SDP_UINT8, &channel)));
-
- sdp_set_access_protos(&record, sdp_list_append(NULL, proto));
-
- sdp_uuid16_create(&serial_uuid, SERIAL_PORT_SVCLASS_ID);
- svclass = sdp_list_append(NULL, &serial_uuid);
-
- sdp_uuid16_create(&svclass_uuid, APPLE_AGENT_SVCLASS_ID);
- svclass = sdp_list_append(svclass, &svclass_uuid);
-
- sdp_set_service_classes(&record, svclass);
-
- sdp_set_info_attr(&record, "AppleAgent", "Bluetooth acceptor", "Apple Computer Ltd.");
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- return -1;
- }
-
- printf("Apple iSync service registered\n");
-
- return 0;
-}
-
-static int add_semchla(sdp_session_t *session, svc_info_t *si)
-{
- sdp_record_t record;
- sdp_profile_desc_t profile;
- sdp_list_t *root, *svclass, *proto, *profiles;
- uuid_t root_uuid, service_uuid, l2cap_uuid, semchla_uuid;
- uint16_t psm = 0xf0f9;
-
- memset(&record, 0, sizeof(record));
- record.handle = si->handle;
-
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(NULL, &root_uuid);
- sdp_set_browse_groups(&record, root);
-
- sdp_uuid16_create(&l2cap_uuid, L2CAP_UUID);
- proto = sdp_list_append(NULL, sdp_list_append(
- sdp_list_append(NULL, &l2cap_uuid), sdp_data_alloc(SDP_UINT16, &psm)));
-
- sdp_uuid32_create(&semchla_uuid, 0x8e770300);
- proto = sdp_list_append(proto, sdp_list_append(NULL, &semchla_uuid));
-
- sdp_set_access_protos(&record, sdp_list_append(NULL, proto));
-
- sdp_uuid32_create(&service_uuid, 0x8e771301);
- svclass = sdp_list_append(NULL, &service_uuid);
-
- sdp_set_service_classes(&record, svclass);
-
- sdp_uuid32_create(&profile.uuid, 0x8e771302); // Headset
- //sdp_uuid32_create(&profile.uuid, 0x8e771303); // Phone
- profile.version = 0x0100;
- profiles = sdp_list_append(NULL, &profile);
- sdp_set_profile_descs(&record, profiles);
-
- sdp_set_info_attr(&record, "SEMC HLA", NULL, NULL);
-
- if (sdp_device_record_register(session, &interface, &record, SDP_RECORD_PERSIST) < 0) {
- printf("Service Record registration failed\n");
- return -1;
- }
-
- /* SEMC High Level Authentication */
- printf("SEMC HLA service registered\n");
-
- return 0;
-}
-
-static int add_gatt(sdp_session_t *session, svc_info_t *si)
-{
- sdp_list_t *svclass_id, *apseq, *proto[2], *profiles, *root, *aproto;
- uuid_t root_uuid, proto_uuid, gatt_uuid, l2cap;
- sdp_profile_desc_t profile;
- sdp_record_t record;
- sdp_data_t *psm, *sh, *eh;
- uint16_t att_psm = 27, start = 0x0001, end = 0x000f;
- int ret;
-
- memset(&record, 0, sizeof(sdp_record_t));
- record.handle = si->handle;
- sdp_uuid16_create(&root_uuid, PUBLIC_BROWSE_GROUP);
- root = sdp_list_append(NULL, &root_uuid);
- sdp_set_browse_groups(&record, root);
- sdp_list_free(root, NULL);
-
- sdp_uuid16_create(&gatt_uuid, GENERIC_ATTRIB_SVCLASS_ID);
- svclass_id = sdp_list_append(NULL, &gatt_uuid);
- sdp_set_service_classes(&record, svclass_id);
- sdp_list_free(svclass_id, NULL);
-
- sdp_uuid16_create(&profile.uuid, GENERIC_ATTRIB_PROFILE_ID);
- profile.version = 0x0100;
- profiles = sdp_list_append(NULL, &profile);
- sdp_set_profile_descs(&record, profiles);
- sdp_list_free(profiles, NULL);
-
- sdp_uuid16_create(&l2cap, L2CAP_UUID);
- proto[0] = sdp_list_append(NULL, &l2cap);
- psm = sdp_data_alloc(SDP_UINT16, &att_psm);
- proto[0] = sdp_list_append(proto[0], psm);
- apseq = sdp_list_append(NULL, proto[0]);
-
- sdp_uuid16_create(&proto_uuid, ATT_UUID);
- proto[1] = sdp_list_append(NULL, &proto_uuid);
- sh = sdp_data_alloc(SDP_UINT16, &start);
- proto[1] = sdp_list_append(proto[1], sh);
- eh = sdp_data_alloc(SDP_UINT16, &end);
- proto[1] = sdp_list_append(proto[1], eh);
- apseq = sdp_list_append(apseq, proto[1]);
-
- aproto = sdp_list_append(NULL, apseq);
- sdp_set_access_protos(&record, aproto);
-
- sdp_set_info_attr(&record, "Generic Attribute Profile", "BlueZ", NULL);
-
- sdp_set_url_attr(&record, "http://www.bluez.org/",
- "http://www.bluez.org/", "http://www.bluez.org/");
-
- sdp_set_service_id(&record, gatt_uuid);
-
- ret = sdp_device_record_register(session, &interface, &record,
- SDP_RECORD_PERSIST);
- if (ret < 0)
- printf("Service Record registration failed\n");
- else
- printf("Generic Attribute Profile Service registered\n");
-
- sdp_data_free(psm);
- sdp_data_free(sh);
- sdp_data_free(eh);
- sdp_list_free(proto[0], NULL);
- sdp_list_free(proto[1], NULL);
- sdp_list_free(apseq, NULL);
- sdp_list_free(aproto, NULL);
-
- return ret;
-}
-
struct {
char *name;
uint32_t class;
- int (*add)(sdp_session_t *sess, svc_info_t *si);
unsigned char *uuid;
} service[] = {
- { "DID", PNP_INFO_SVCLASS_ID, NULL, },
-
- { "SP", SERIAL_PORT_SVCLASS_ID, add_sp },
- { "DUN", DIALUP_NET_SVCLASS_ID, add_dun },
- { "LAN", LAN_ACCESS_SVCLASS_ID, add_lan },
- { "FAX", FAX_SVCLASS_ID, add_fax },
- { "OPUSH", OBEX_OBJPUSH_SVCLASS_ID, add_opush },
- { "FTP", OBEX_FILETRANS_SVCLASS_ID, add_ftp },
- { "PRINT", DIRECT_PRINTING_SVCLASS_ID, add_directprint },
-
- { "HS", HEADSET_SVCLASS_ID, add_headset },
- { "HSAG", HEADSET_AGW_SVCLASS_ID, add_headset_ag },
- { "HF", HANDSFREE_SVCLASS_ID, add_handsfree },
- { "HFAG", HANDSFREE_AGW_SVCLASS_ID, add_handsfree_ag},
- { "SAP", SAP_SVCLASS_ID, add_simaccess },
- { "PBAP", PBAP_SVCLASS_ID, add_pbap, },
-
- { "NAP", NAP_SVCLASS_ID, add_nap },
- { "GN", GN_SVCLASS_ID, add_gn },
- { "PANU", PANU_SVCLASS_ID, add_panu },
-
- { "HCRP", HCR_SVCLASS_ID, NULL },
- { "HID", HID_SVCLASS_ID, NULL },
- { "KEYB", HID_SVCLASS_ID, add_hid_keyb },
- { "WIIMOTE", HID_SVCLASS_ID, add_hid_wiimote },
- { "CIP", CIP_SVCLASS_ID, add_cip },
- { "CTP", CORDLESS_TELEPHONY_SVCLASS_ID, add_ctp },
-
- { "A2SRC", AUDIO_SOURCE_SVCLASS_ID, add_a2source },
- { "A2SNK", AUDIO_SINK_SVCLASS_ID, add_a2sink },
- { "AVRCT", AV_REMOTE_SVCLASS_ID, add_avrct },
- { "AVRTG", AV_REMOTE_TARGET_SVCLASS_ID, add_avrtg },
-
- { "UDIUE", UDI_MT_SVCLASS_ID, add_udi_ue },
- { "UDITE", UDI_TA_SVCLASS_ID, add_udi_te },
-
- { "SEMCHLA", 0x8e771301, add_semchla },
-
- { "SR1", 0, add_sr1, sr1_uuid },
- { "SYNCML", 0, add_syncml, syncmlc_uuid },
- { "SYNCMLSERV", 0, NULL, syncmls_uuid },
- { "ACTIVESYNC", 0, add_activesync, async_uuid },
- { "HOTSYNC", 0, add_hotsync, hotsync_uuid },
- { "PALMOS", 0, add_palmos, palmos_uuid },
- { "NOKID", 0, add_nokiaid, nokid_uuid },
- { "PCSUITE", 0, add_pcsuite, pcsuite_uuid },
- { "NFTP", 0, NULL, nftp_uuid },
- { "NSYNCML", 0, NULL, nsyncml_uuid },
- { "NGAGE", 0, NULL, ngage_uuid },
- { "APPLE", 0, add_apple, apple_uuid },
- { "IAP", 0, NULL, iap_uuid },
-
- { "ISYNC", APPLE_AGENT_SVCLASS_ID, add_isync, },
- { "GATT", GENERIC_ATTRIB_SVCLASS_ID, add_gatt, },
+ { "DID", PNP_INFO_SVCLASS_ID },
+
+ { "SP", SERIAL_PORT_SVCLASS_ID },
+ { "DUN", DIALUP_NET_SVCLASS_ID },
+ { "LAN", LAN_ACCESS_SVCLASS_ID },
+ { "FAX", FAX_SVCLASS_ID },
+ { "OPUSH", OBEX_OBJPUSH_SVCLASS_ID },
+ { "FTP", OBEX_FILETRANS_SVCLASS_ID },
+ { "PRINT", DIRECT_PRINTING_SVCLASS_ID },
+
+ { "HS", HEADSET_SVCLASS_ID },
+ { "HSAG", HEADSET_AGW_SVCLASS_ID },
+ { "HF", HANDSFREE_SVCLASS_ID },
+ { "HFAG", HANDSFREE_AGW_SVCLASS_ID },
+ { "SAP", SAP_SVCLASS_ID },
+ { "PBAP", PBAP_SVCLASS_ID },
+
+ { "NAP", NAP_SVCLASS_ID },
+ { "GN", GN_SVCLASS_ID },
+ { "PANU", PANU_SVCLASS_ID },
+
+ { "HCRP", HCR_SVCLASS_ID },
+ { "HID", HID_SVCLASS_ID },
+ { "KEYB", HID_SVCLASS_ID },
+ { "WIIMOTE", HID_SVCLASS_ID },
+ { "CIP", CIP_SVCLASS_ID },
+ { "CTP", CORDLESS_TELEPHONY_SVCLASS_ID },
+
+ { "A2SRC", AUDIO_SOURCE_SVCLASS_ID },
+ { "A2SNK", AUDIO_SINK_SVCLASS_ID },
+ { "AVRCT", AV_REMOTE_SVCLASS_ID },
+ { "AVRTG", AV_REMOTE_TARGET_SVCLASS_ID },
+
+ { "UDIUE", UDI_MT_SVCLASS_ID },
+ { "UDITE", UDI_TA_SVCLASS_ID },
+
+ { "SEMCHLA", 0x8e771301 },
+
+ { "SR1", 0, sr1_uuid },
+ { "SYNCML", 0, syncmlc_uuid },
+ { "SYNCMLSERV", 0, syncmls_uuid },
+ { "ACTIVESYNC", 0, async_uuid },
+ { "HOTSYNC", 0, hotsync_uuid },
+ { "PALMOS", 0, palmos_uuid },
+ { "NOKID", 0, nokid_uuid },
+ { "PCSUITE", 0, pcsuite_uuid },
+ { "NFTP", 0, nftp_uuid },
+ { "NSYNCML", 0, nsyncml_uuid },
+ { "NGAGE", 0, ngage_uuid },
+ { "APPLE", 0, apple_uuid },
+ { "IAP", 0, iap_uuid },
+
+ { "ISYNC", APPLE_AGENT_SVCLASS_ID },
+ { "GATT", GENERIC_ATTRIB_SVCLASS_ID },
{ 0 }
};
-/* Add local service */
-static int add_service(bdaddr_t *bdaddr, svc_info_t *si)
-{
- sdp_session_t *sess;
- int i, ret = -1;
-
- if (!si->name)
- return -1;
-
- sess = sdp_connect(&interface, BDADDR_LOCAL, SDP_RETRY_IF_BUSY);
- if (!sess)
- return -1;
-
- for (i = 0; service[i].name; i++)
- if (!strcasecmp(service[i].name, si->name)) {
- if (service[i].add)
- ret = service[i].add(sess, si);
- goto done;
- }
-
- printf("Unknown service name: %s\n", si->name);
-
-done:
- free(si->name);
- sdp_close(sess);
-
- return ret;
-}
-
-static struct option add_options[] = {
- { "help", 0, 0, 'h' },
- { "handle", 1, 0, 'r' },
- { "psm", 1, 0, 'p' },
- { "channel", 1, 0, 'c' },
- { "network", 1, 0, 'n' },
- { 0, 0, 0, 0 }
-};
-
-static const char *add_help =
- "Usage:\n"
- "\tadd [--handle=RECORD_HANDLE --channel=CHANNEL] service\n";
-
-static int cmd_add(int argc, char **argv)
-{
- svc_info_t si;
- int opt;
-
- memset(&si, 0, sizeof(si));
- si.handle = 0xffffffff;
-
- for_each_opt(opt, add_options, 0) {
- switch (opt) {
- case 'r':
- if (strncasecmp(optarg, "0x", 2))
- si.handle = atoi(optarg);
- else
- si.handle = strtol(optarg + 2, NULL, 16);
- break;
- case 'p':
- if (strncasecmp(optarg, "0x", 2))
- si.psm = atoi(optarg);
- else
- si.psm = strtol(optarg + 2, NULL, 16);
- break;
- case 'c':
- if (strncasecmp(optarg, "0x", 2))
- si.channel = atoi(optarg);
- else
- si.channel = strtol(optarg + 2, NULL, 16);
- break;
- case 'n':
- if (strncasecmp(optarg, "0x", 2))
- si.network = atoi(optarg);
- else
- si.network = strtol(optarg + 2, NULL, 16);
- break;
- default:
- printf("%s", add_help);
- return -1;
- }
- }
-
- argc -= optind;
- argv += optind;
-
- if (argc < 1) {
- printf("%s", add_help);
- return -1;
- }
-
- si.name = strdup(argv[0]);
-
- return add_service(0, &si);
-}
-
-/* Delete local service */
-static int del_service(bdaddr_t *bdaddr, void *arg)
-{
- uint32_t handle, range = 0x0000ffff;
- sdp_list_t *attr;
- sdp_session_t *sess;
- sdp_record_t *rec;
-
- if (!arg) {
- printf("Record handle was not specified.\n");
- return -1;
- }
-
- sess = sdp_connect(&interface, BDADDR_LOCAL, SDP_RETRY_IF_BUSY);
- if (!sess) {
- printf("No local SDP server!\n");
- return -1;
- }
-
- handle = strtoul((char *)arg, 0, 16);
- attr = sdp_list_append(0, &range);
- rec = sdp_service_attr_req(sess, handle, SDP_ATTR_REQ_RANGE, attr);
- sdp_list_free(attr, 0);
-
- if (!rec) {
- printf("Service Record not found.\n");
- sdp_close(sess);
- return -1;
- }
-
- if (sdp_device_record_unregister(sess, &interface, rec)) {
- printf("Failed to unregister service record: %s\n", strerror(errno));
- sdp_close(sess);
- return -1;
- }
-
- printf("Service Record deleted.\n");
- sdp_close(sess);
-
- return 0;
-}
-
-static struct option del_options[] = {
- { "help", 0, 0, 'h' },
- { 0, 0, 0, 0 }
-};
-
-static const char *del_help =
- "Usage:\n"
- "\tdel record_handle\n";
-
-static int cmd_del(int argc, char **argv)
-{
- int opt;
-
- for_each_opt(opt, del_options, 0) {
- switch (opt) {
- default:
- printf("%s", del_help);
- return -1;
- }
- }
-
- argc -= optind;
- argv += optind;
-
- if (argc < 1) {
- printf("%s", del_help);
- return -1;
- }
-
- return del_service(NULL, argv[0]);
-}
-
/*
* Perform an inquiry and search/browse all peer found.
*/
@@ -4203,8 +1718,6 @@ static struct {
{ "search", cmd_search, "Search for a service" },
{ "browse", cmd_browse, "Browse all available services" },
{ "records", cmd_records, "Request all records" },
- { "add", cmd_add, "Add local service" },
- { "del", cmd_del, "Delete local service" },
{ "get", cmd_get, "Get local service" },
{ "setattr", cmd_setattr, "Set/Add attribute to a SDP record" },
{ "setseq", cmd_setseq, "Set/Add attribute sequence to a SDP record" },
--
1.8.4
^ permalink raw reply related
* [PATCH v2 6/8] sdpd: Remove 'register' and 'remove' requests
From: Szymon Janc @ 2013-09-19 14:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1379599248-7923-1-git-send-email-szymon.janc@tieto.com>
sdpd is now controlled by adapters and should not be modified with
other means.
---
src/sdpd-request.c | 14 --------
src/sdpd-service.c | 100 -----------------------------------------------------
src/sdpd.h | 2 --
3 files changed, 116 deletions(-)
diff --git a/src/sdpd-request.c b/src/sdpd-request.c
index fbeb488..5b88a10 100644
--- a/src/sdpd-request.c
+++ b/src/sdpd-request.c
@@ -997,13 +997,6 @@ static void process_request(sdp_req_t *req)
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");
- 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");
if (req->local) {
@@ -1011,13 +1004,6 @@ static void process_request(sdp_req_t *req)
rsphdr->pdu_id = SDP_SVC_UPDATE_RSP;
}
break;
- case SDP_SVC_REMOVE_REQ:
- SDPDBG("Service removal request");
- if (req->local) {
- status = service_remove_req(req, &rsp);
- rsphdr->pdu_id = SDP_SVC_REMOVE_RSP;
- }
- break;
default:
error("Unknown PDU ID : 0x%x received", reqhdr->pdu_id);
status = SDP_INVALID_SYNTAX;
diff --git a/src/sdpd-service.c b/src/sdpd-service.c
index 38bf808..09f6c0a 100644
--- a/src/sdpd-service.c
+++ b/src/sdpd-service.c
@@ -400,75 +400,6 @@ static sdp_record_t *extract_pdu_server(bdaddr_t *device, uint8_t *p,
}
/*
- * Add the newly created service record to the service repository
- */
-int service_register_req(sdp_req_t *req, sdp_buf_t *rsp)
-{
- int scanned = 0;
- sdp_data_t *handle;
- uint8_t *p = req->buf + sizeof(sdp_pdu_hdr_t);
- int bufsize = req->len - sizeof(sdp_pdu_hdr_t);
- sdp_record_t *rec;
-
- req->flags = *p++;
- if (req->flags & SDP_DEVICE_RECORD) {
- bacpy(&req->device, (bdaddr_t *) p);
- p += sizeof(bdaddr_t);
- bufsize -= sizeof(bdaddr_t);
- }
-
- /* save image of PDU: we need it when clients request this attribute */
- rec = extract_pdu_server(&req->device, p, bufsize, 0xffffffff, &scanned);
- if (!rec)
- goto invalid;
-
- if (rec->handle == 0xffffffff) {
- rec->handle = sdp_next_handle();
- if (rec->handle < 0x10000) {
- sdp_record_free(rec);
- goto invalid;
- }
- } else {
- if (sdp_record_find(rec->handle)) {
- /* extract_pdu_server will add the record handle
- * if it is missing. So instead of failing, skip
- * the record adding to avoid duplication. */
- goto success;
- }
- }
-
- sdp_record_add(&req->device, rec);
- if (!(req->flags & SDP_RECORD_PERSIST))
- sdp_svcdb_set_collectable(rec, req->sock);
-
- handle = sdp_data_alloc(SDP_UINT32, &rec->handle);
- sdp_attr_replace(rec, SDP_ATTR_RECORD_HANDLE, handle);
-
-success:
- /* if the browse group descriptor is NULL,
- * ensure that the record belongs to the ROOT group */
- if (sdp_data_get(rec, SDP_ATTR_BROWSE_GRP_LIST) == NULL) {
- uuid_t uuid;
- sdp_uuid16_create(&uuid, PUBLIC_BROWSE_GROUP);
- sdp_pattern_add_uuid(rec, &uuid);
- }
-
- update_db_timestamp();
-
- /* Build a rsp buffer */
- bt_put_be32(rec->handle, rsp->data);
- rsp->data_size = sizeof(uint32_t);
-
- return 0;
-
-invalid:
- bt_put_be16(SDP_INVALID_SYNTAX, rsp->data);
- rsp->data_size = sizeof(uint16_t);
-
- return -1;
-}
-
-/*
* Update a service record
*/
int service_update_req(sdp_req_t *req, sdp_buf_t *rsp)
@@ -509,34 +440,3 @@ done:
rsp->data_size = sizeof(uint16_t);
return status;
}
-
-/*
- * Remove a registered service record
- */
-int service_remove_req(sdp_req_t *req, sdp_buf_t *rsp)
-{
- uint8_t *p = req->buf + sizeof(sdp_pdu_hdr_t);
- uint32_t handle = bt_get_be32(p);
- sdp_record_t *rec;
- int status = 0;
-
- /* extract service record handle */
-
- rec = sdp_record_find(handle);
- if (rec) {
- sdp_svcdb_collect(rec);
- status = sdp_record_remove(handle);
- sdp_record_free(rec);
- if (status == 0)
- update_db_timestamp();
- } else {
- status = SDP_INVALID_RECORD_HANDLE;
- SDPDBG("Could not find record : 0x%x", handle);
- }
-
- p = rsp->data;
- bt_put_be16(status, p);
- rsp->data_size = sizeof(uint16_t);
-
- return status;
-}
diff --git a/src/sdpd.h b/src/sdpd.h
index 6de0af7..3c6ee01 100644
--- a/src/sdpd.h
+++ b/src/sdpd.h
@@ -50,9 +50,7 @@ void handle_request(int sk, uint8_t *data, int len);
void set_fixed_db_timestamp(uint32_t dbts);
-int service_register_req(sdp_req_t *req, sdp_buf_t *rsp);
int service_update_req(sdp_req_t *req, sdp_buf_t *rsp);
-int service_remove_req(sdp_req_t *req, sdp_buf_t *rsp);
void register_public_browse_group(void);
void register_server_service(void);
--
1.8.4
^ permalink raw reply related
* [PATCH v2 5/8] unit: Remove not needed functions from test-sdp
From: Szymon Janc @ 2013-09-19 14:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1379599248-7923-1-git-send-email-szymon.janc@tieto.com>
SDP code no longer depends on adapter code.
---
unit/test-sdp.c | 29 -----------------------------
1 file changed, 29 deletions(-)
diff --git a/unit/test-sdp.c b/unit/test-sdp.c
index 5aa6948..6d699e2 100644
--- a/unit/test-sdp.c
+++ b/unit/test-sdp.c
@@ -134,35 +134,6 @@ void btd_debug(const char *format, ...)
{
}
-struct btd_adapter;
-
-typedef void (*adapter_cb) (struct btd_adapter *adapter, gpointer user_data);
-
-void adapter_foreach(adapter_cb func, gpointer user_data);
-
-void adapter_foreach(adapter_cb func, gpointer user_data)
-{
-}
-
-struct btd_adapter *adapter_find(const bdaddr_t *sba);
-
-struct btd_adapter *adapter_find(const bdaddr_t *sba)
-{
- return NULL;
-}
-
-void adapter_service_insert(struct btd_adapter *adapter, void *rec);
-
-void adapter_service_insert(struct btd_adapter *adapter, void *rec)
-{
-}
-
-void adapter_service_remove(struct btd_adapter *adapter, void *rec);
-
-void adapter_service_remove(struct btd_adapter *adapter, void *rec)
-{
-}
-
static void context_quit(struct context *context)
{
g_main_loop_quit(context->main_loop);
--
1.8.4
^ permalink raw reply related
* [PATCH v2 4/8] Remove not needed sdp_init_services_list function
From: Szymon Janc @ 2013-09-19 14:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1379599248-7923-1-git-send-email-szymon.janc@tieto.com>
It is doing nothing now and can be removed.
---
src/adapter.c | 2 --
src/sdpd-database.c | 21 ---------------------
src/sdpd.h | 2 --
3 files changed, 25 deletions(-)
diff --git a/src/adapter.c b/src/adapter.c
index fb005a6..b99bff9 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -5622,8 +5622,6 @@ static int adapter_register(struct btd_adapter *adapter)
agent_unref(agent);
}
- sdp_init_services_list(&adapter->bdaddr);
-
btd_adapter_gatt_server_start(adapter);
load_config(adapter);
diff --git a/src/sdpd-database.c b/src/sdpd-database.c
index e4d4f98..f65a526 100644
--- a/src/sdpd-database.c
+++ b/src/sdpd-database.c
@@ -296,24 +296,3 @@ uint32_t sdp_next_handle(void)
return handle;
}
-
-void sdp_init_services_list(bdaddr_t *device)
-{
- sdp_list_t *p;
-
- DBG("");
-
- for (p = access_db; p != NULL; p = p->next) {
- sdp_access_t *access = p->data;
- sdp_record_t *rec;
-
- if (bacmp(BDADDR_ANY, &access->device))
- continue;
-
- rec = sdp_record_find(access->handle);
- if (rec == NULL)
- continue;
-
- SDPDBG("adding record with handle %x", access->handle);
- }
-}
diff --git a/src/sdpd.h b/src/sdpd.h
index 9a0e1e9..6de0af7 100644
--- a/src/sdpd.h
+++ b/src/sdpd.h
@@ -81,5 +81,3 @@ void stop_sdp_server(void);
int add_record_to_server(const bdaddr_t *src, sdp_record_t *rec);
int remove_record_from_server(uint32_t handle);
-
-void sdp_init_services_list(bdaddr_t *device);
--
1.8.4
^ permalink raw reply related
* [PATCH v2 3/8] adapter: Handle removing of SDP records
From: Szymon Janc @ 2013-09-19 14:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1379599248-7923-1-git-send-email-szymon.janc@tieto.com>
Make adapter in charge of updating SDP database. This allow to decouple
SDP of code used for notifying adapters about SDP database change.
---
plugins/gatt-example.c | 2 +-
profiles/audio/a2dp.c | 11 +++++++----
profiles/audio/avrcp.c | 4 ++--
profiles/health/hdp.c | 2 +-
profiles/health/hdp_util.c | 3 ++-
profiles/network/server.c | 4 ++--
profiles/sap/server.c | 2 +-
src/adapter.c | 13 ++++++++-----
src/adapter.h | 2 +-
src/attrib-server.c | 9 +++++----
src/attrib-server.h | 2 +-
src/profile.c | 2 +-
src/sdpd-database.c | 8 --------
13 files changed, 32 insertions(+), 32 deletions(-)
diff --git a/plugins/gatt-example.c b/plugins/gatt-example.c
index b926947..9b4187a 100644
--- a/plugins/gatt-example.c
+++ b/plugins/gatt-example.c
@@ -72,7 +72,7 @@ static void gatt_example_adapter_free(struct gatt_example_adapter *gadapter)
while (gadapter->sdp_handles != NULL) {
uint32_t handle = GPOINTER_TO_UINT(gadapter->sdp_handles->data);
- attrib_free_sdp(handle);
+ attrib_free_sdp(gadapter->adapter, handle);
gadapter->sdp_handles = g_slist_remove(gadapter->sdp_handles,
gadapter->sdp_handles->data);
}
diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index d96a8b5..8477b5d 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -1326,7 +1326,8 @@ void a2dp_remove_sep(struct a2dp_sep *sep)
return;
server->sources = g_slist_remove(server->sources, sep);
if (server->sources == NULL && server->source_record_id) {
- remove_record_from_server(server->source_record_id);
+ adapter_service_remove(server->adapter,
+ server->source_record_id);
server->source_record_id = 0;
}
} else {
@@ -1334,7 +1335,8 @@ void a2dp_remove_sep(struct a2dp_sep *sep)
return;
server->sinks = g_slist_remove(server->sinks, sep);
if (server->sinks == NULL && server->sink_record_id) {
- remove_record_from_server(server->sink_record_id);
+ adapter_service_remove(server->adapter,
+ server->sink_record_id);
server->sink_record_id = 0;
}
}
@@ -1943,7 +1945,8 @@ static void a2dp_source_server_remove(struct btd_profile *p,
(GDestroyNotify) a2dp_unregister_sep);
if (server->source_record_id) {
- remove_record_from_server(server->source_record_id);
+ adapter_service_remove(server->adapter,
+ server->source_record_id);
server->source_record_id = 0;
}
@@ -1988,7 +1991,7 @@ static void a2dp_sink_server_remove(struct btd_profile *p,
g_slist_free_full(server->sinks, (GDestroyNotify) a2dp_unregister_sep);
if (server->sink_record_id) {
- remove_record_from_server(server->sink_record_id);
+ adapter_service_remove(server->adapter, server->sink_record_id);
server->sink_record_id = 0;
}
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index e75e804..b1b2ae6 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -3797,7 +3797,7 @@ static void avrcp_target_server_remove(struct btd_profile *p,
return;
if (server->tg_record_id != 0) {
- remove_record_from_server(server->tg_record_id);
+ adapter_service_remove(adapter, server->tg_record_id);
server->tg_record_id = 0;
}
@@ -3880,7 +3880,7 @@ static void avrcp_controller_server_remove(struct btd_profile *p,
return;
if (server->ct_record_id != 0) {
- remove_record_from_server(server->ct_record_id);
+ adapter_service_remove(adapter, server->ct_record_id);
server->ct_record_id = 0;
}
diff --git a/profiles/health/hdp.c b/profiles/health/hdp.c
index 7f24756..7b4e799 100644
--- a/profiles/health/hdp.c
+++ b/profiles/health/hdp.c
@@ -1403,7 +1403,7 @@ void hdp_adapter_unregister(struct btd_adapter *adapter)
hdp_adapter = l->data;
adapters = g_slist_remove(adapters, hdp_adapter);
if (hdp_adapter->sdp_handler > 0)
- remove_record_from_server(hdp_adapter->sdp_handler);
+ adapter_service_remove(adapter, hdp_adapter->sdp_handler);
release_adapter_instance(hdp_adapter);
btd_adapter_unref(hdp_adapter->btd_adapter);
g_free(hdp_adapter);
diff --git a/profiles/health/hdp_util.c b/profiles/health/hdp_util.c
index 7748a90..34e4671 100644
--- a/profiles/health/hdp_util.c
+++ b/profiles/health/hdp_util.c
@@ -693,7 +693,8 @@ gboolean hdp_update_sdp_record(struct hdp_adapter *adapter, GSList *app_list)
sdp_record_t *sdp_record;
if (adapter->sdp_handler > 0)
- remove_record_from_server(adapter->sdp_handler);
+ adapter_service_remove(adapter->btd_adapter,
+ adapter->sdp_handler);
if (app_list == NULL) {
adapter->sdp_handler = 0;
diff --git a/profiles/network/server.c b/profiles/network/server.c
index d537531..7b784e5 100644
--- a/profiles/network/server.c
+++ b/profiles/network/server.c
@@ -628,7 +628,7 @@ static void server_disconnect(DBusConnection *conn, void *user_data)
ns->watch_id = 0;
if (ns->record_id) {
- remove_record_from_server(ns->record_id);
+ adapter_service_remove(ns->na->adapter, ns->record_id);
ns->record_id = 0;
}
@@ -722,7 +722,7 @@ static void server_free(void *data)
server_remove_sessions(ns);
if (ns->record_id)
- remove_record_from_server(ns->record_id);
+ adapter_service_remove(ns->na->adapter, ns->record_id);
g_dbus_remove_watch(btd_get_dbus_connection(), ns->watch_id);
g_free(ns->name);
diff --git a/profiles/sap/server.c b/profiles/sap/server.c
index 089bc7a..63314a7 100644
--- a/profiles/sap/server.c
+++ b/profiles/sap/server.c
@@ -1320,7 +1320,7 @@ static void server_remove(struct sap_server *server)
sap_server_remove_conn(server);
- remove_record_from_server(server->record_id);
+ adapter_service_remove(server->adapter, server->record_id);
if (server->listen_io) {
g_io_channel_shutdown(server->listen_io, TRUE, NULL);
diff --git a/src/adapter.c b/src/adapter.c
index 678bc5d..fb005a6 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -986,18 +986,21 @@ int adapter_service_add(struct btd_adapter *adapter, sdp_record_t *rec)
return 0;
}
-void adapter_service_remove(struct btd_adapter *adapter, void *r)
+void adapter_service_remove(struct btd_adapter *adapter, uint32_t handle)
{
- sdp_record_t *rec = r;
+ sdp_record_t *rec = sdp_record_find(handle);
DBG("%s", adapter->path);
+ if (!rec)
+ return;
+
adapter->services = sdp_list_remove(adapter->services, rec);
- if (sdp_list_find(adapter->services, &rec->svclass, uuid_cmp))
- return;
+ if (sdp_list_find(adapter->services, &rec->svclass, uuid_cmp) == NULL)
+ remove_uuid(adapter, &rec->svclass);
- remove_uuid(adapter, &rec->svclass);
+ remove_record_from_server(rec->handle);
}
static struct btd_device *adapter_create_device(struct btd_adapter *adapter,
diff --git a/src/adapter.h b/src/adapter.h
index ef6d4ed..5d124e7 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -104,7 +104,7 @@ const bdaddr_t *adapter_get_address(struct btd_adapter *adapter);
int adapter_set_name(struct btd_adapter *adapter, const char *name);
int adapter_service_add(struct btd_adapter *adapter, sdp_record_t *rec);
-void adapter_service_remove(struct btd_adapter *adapter, void *rec);
+void adapter_service_remove(struct btd_adapter *adapter, uint32_t handle);
struct agent *adapter_get_agent(struct btd_adapter *adapter);
diff --git a/src/attrib-server.c b/src/attrib-server.c
index 5a76d2e..2861a00 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -139,10 +139,11 @@ static void gatt_server_free(struct gatt_server *server)
g_slist_free_full(server->clients, (GDestroyNotify) channel_free);
if (server->gatt_sdp_handle > 0)
- remove_record_from_server(server->gatt_sdp_handle);
+ adapter_service_remove(server->adapter,
+ server->gatt_sdp_handle);
if (server->gap_sdp_handle > 0)
- remove_record_from_server(server->gap_sdp_handle);
+ adapter_service_remove(server->adapter, server->gap_sdp_handle);
if (server->adapter != NULL)
btd_adapter_unref(server->adapter);
@@ -1377,9 +1378,9 @@ uint32_t attrib_create_sdp(struct btd_adapter *adapter, uint16_t handle,
return attrib_create_sdp_new(l->data, handle, name);
}
-void attrib_free_sdp(uint32_t sdp_handle)
+void attrib_free_sdp(struct btd_adapter *adapter, uint32_t sdp_handle)
{
- remove_record_from_server(sdp_handle);
+ adapter_service_remove(adapter, sdp_handle);
}
static uint16_t find_uuid16_avail(struct btd_adapter *adapter, uint16_t nitems)
diff --git a/src/attrib-server.h b/src/attrib-server.h
index 2148017..90ba17c 100644
--- a/src/attrib-server.h
+++ b/src/attrib-server.h
@@ -36,6 +36,6 @@ int attrib_gap_set(struct btd_adapter *adapter, uint16_t uuid,
const uint8_t *value, size_t len);
uint32_t attrib_create_sdp(struct btd_adapter *adapter, uint16_t handle,
const char *name);
-void attrib_free_sdp(uint32_t sdp_handle);
+void attrib_free_sdp(struct btd_adapter *adapter, uint32_t sdp_handle);
guint attrib_channel_attach(GAttrib *attrib);
gboolean attrib_channel_detach(GAttrib *attrib, guint id);
diff --git a/src/profile.c b/src/profile.c
index f2c1e6f..accd007 100644
--- a/src/profile.c
+++ b/src/profile.c
@@ -1371,7 +1371,7 @@ static void ext_remove_records(struct ext_profile *ext,
ext->records = g_slist_remove(ext->records, r);
- remove_record_from_server(r->handle);
+ adapter_service_remove(adapter, r->handle);
btd_adapter_unref(r->adapter);
g_free(r);
}
diff --git a/src/sdpd-database.c b/src/sdpd-database.c
index 600ddbf..e4d4f98 100644
--- a/src/sdpd-database.c
+++ b/src/sdpd-database.c
@@ -36,7 +36,6 @@
#include "sdpd.h"
#include "log.h"
-#include "adapter.h"
static sdp_list_t *service_db;
static sdp_list_t *access_db;
@@ -254,13 +253,6 @@ int sdp_record_remove(uint32_t handle)
a = p->data;
- if (bacmp(&a->device, BDADDR_ANY) != 0) {
- struct btd_adapter *adapter = adapter_find(&a->device);
- if (adapter)
- adapter_service_remove(adapter, r);
- } else
- adapter_foreach(adapter_service_remove, r);
-
access_db = sdp_list_remove(access_db, a);
access_free(a);
--
1.8.4
^ permalink raw reply related
* [PATCH v2 2/8] adapter: Handle adding new SDP records
From: Szymon Janc @ 2013-09-19 14:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1379599248-7923-1-git-send-email-szymon.janc@tieto.com>
Make adapter in charge of updating SDP database. This allow to decouple
SDP of code used for notifying adapters about SDP database change.
---
profiles/audio/a2dp.c | 3 +--
profiles/audio/avrcp.c | 4 ++--
profiles/health/hdp_util.c | 3 +--
profiles/network/server.c | 2 +-
profiles/sap/server.c | 2 +-
src/adapter.c | 22 +++++++++++++++++++---
src/adapter.h | 3 ++-
src/attrib-server.c | 3 +--
src/profile.c | 7 +++----
src/sdpd-database.c | 12 ------------
10 files changed, 31 insertions(+), 30 deletions(-)
diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index 3f3cc1b..d96a8b5 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -1298,8 +1298,7 @@ struct a2dp_sep *a2dp_add_sep(struct btd_adapter *adapter, uint8_t type,
return NULL;
}
- if (add_record_to_server(adapter_get_address(server->adapter),
- record) < 0) {
+ if (adapter_service_add(server->adapter, record) < 0) {
error("Unable to register A2DP service record");
sdp_record_free(record);
avdtp_unregister_sep(sep->lsep);
diff --git a/profiles/audio/avrcp.c b/profiles/audio/avrcp.c
index 9f164e4..e75e804 100644
--- a/profiles/audio/avrcp.c
+++ b/profiles/audio/avrcp.c
@@ -3829,7 +3829,7 @@ done:
return -1;
}
- if (add_record_to_server(adapter_get_address(adapter), record) < 0) {
+ if (adapter_service_add(adapter, record) < 0) {
error("Unable to register AVRCP target service record");
avrcp_target_server_remove(p, adapter);
sdp_record_free(record);
@@ -3912,7 +3912,7 @@ done:
return -1;
}
- if (add_record_to_server(adapter_get_address(adapter), record) < 0) {
+ if (adapter_service_add(adapter, record) < 0) {
error("Unable to register AVRCP service record");
avrcp_controller_server_remove(p, adapter);
sdp_record_free(record);
diff --git a/profiles/health/hdp_util.c b/profiles/health/hdp_util.c
index b53f1db..7748a90 100644
--- a/profiles/health/hdp_util.c
+++ b/profiles/health/hdp_util.c
@@ -733,8 +733,7 @@ gboolean hdp_update_sdp_record(struct hdp_adapter *adapter, GSList *app_list)
if (sdp_set_record_state(sdp_record, adapter->record_state++) < 0)
goto fail;
- if (add_record_to_server(adapter_get_address(adapter->btd_adapter),
- sdp_record) < 0)
+ if (adapter_service_add(adapter->btd_adapter, sdp_record) < 0)
goto fail;
adapter->sdp_handler = sdp_record->handle;
return TRUE;
diff --git a/profiles/network/server.c b/profiles/network/server.c
index 043e1fc..d537531 100644
--- a/profiles/network/server.c
+++ b/profiles/network/server.c
@@ -587,7 +587,7 @@ static uint32_t register_server_record(struct network_server *ns)
return 0;
}
- if (add_record_to_server(&ns->src, record) < 0) {
+ if (adapter_service_add(ns->na->adapter, record) < 0) {
error("Failed to register service record");
sdp_record_free(record);
return 0;
diff --git a/profiles/sap/server.c b/profiles/sap/server.c
index 1aacfe9..089bc7a 100644
--- a/profiles/sap/server.c
+++ b/profiles/sap/server.c
@@ -1360,7 +1360,7 @@ int sap_server_register(struct btd_adapter *adapter)
goto sdp_err;
}
- if (add_record_to_server(adapter_get_address(adapter), record) < 0) {
+ if (adapter_service_add(adapter, record) < 0) {
error("Adding SAP SDP record to the SDP server failed.");
sdp_record_free(record);
goto sdp_err;
diff --git a/src/adapter.c b/src/adapter.c
index 62783a6..678bc5d 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -934,9 +934,8 @@ static int uuid_cmp(const void *a, const void *b)
return sdp_uuid_cmp(&rec->svclass, uuid);
}
-void adapter_service_insert(struct btd_adapter *adapter, void *r)
+static void adapter_service_insert(struct btd_adapter *adapter, sdp_record_t *rec)
{
- sdp_record_t *rec = r;
sdp_list_t *browse_list = NULL;
uuid_t browse_uuid;
gboolean new_uuid;
@@ -944,8 +943,10 @@ void adapter_service_insert(struct btd_adapter *adapter, void *r)
DBG("%s", adapter->path);
/* skip record without a browse group */
- if (sdp_get_browse_groups(rec, &browse_list) < 0)
+ if (sdp_get_browse_groups(rec, &browse_list) < 0) {
+ DBG("skipping record without browse group");
return;
+ }
sdp_uuid16_create(&browse_uuid, PUBLIC_BROWSE_GROUP);
@@ -970,6 +971,21 @@ done:
sdp_list_free(browse_list, free);
}
+int adapter_service_add(struct btd_adapter *adapter, sdp_record_t *rec)
+{
+ int ret;
+
+ DBG("%s", adapter->path);
+
+ ret = add_record_to_server(&adapter->bdaddr, rec);
+ if (ret < 0)
+ return ret;
+
+ adapter_service_insert(adapter, rec);
+
+ return 0;
+}
+
void adapter_service_remove(struct btd_adapter *adapter, void *r)
{
sdp_record_t *rec = r;
diff --git a/src/adapter.h b/src/adapter.h
index 32b12c0..ef6d4ed 100644
--- a/src/adapter.h
+++ b/src/adapter.h
@@ -102,7 +102,8 @@ struct btd_device *adapter_find_device(struct btd_adapter *adapter,
const char *adapter_get_path(struct btd_adapter *adapter);
const bdaddr_t *adapter_get_address(struct btd_adapter *adapter);
int adapter_set_name(struct btd_adapter *adapter, const char *name);
-void adapter_service_insert(struct btd_adapter *adapter, void *rec);
+
+int adapter_service_add(struct btd_adapter *adapter, sdp_record_t *rec);
void adapter_service_remove(struct btd_adapter *adapter, void *rec);
struct agent *adapter_get_agent(struct btd_adapter *adapter);
diff --git a/src/attrib-server.c b/src/attrib-server.c
index 3f629b0..5a76d2e 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -326,8 +326,7 @@ static uint32_t attrib_create_sdp_new(struct gatt_server *server,
"http://www.bluez.org/");
}
- if (add_record_to_server(adapter_get_address(server->adapter), record)
- == 0)
+ if (adapter_service_add(server->adapter, record) == 0)
return record->handle;
sdp_record_free(record);
diff --git a/src/profile.c b/src/profile.c
index 523e119..f2c1e6f 100644
--- a/src/profile.c
+++ b/src/profile.c
@@ -1179,7 +1179,7 @@ static void ext_direct_connect(GIOChannel *io, GError *err, gpointer user_data)
static uint32_t ext_register_record(struct ext_profile *ext,
struct ext_io *l2cap,
struct ext_io *rfcomm,
- const bdaddr_t *src)
+ struct btd_adapter *a)
{
sdp_record_t *rec;
char *dyn_record = NULL;
@@ -1202,7 +1202,7 @@ static uint32_t ext_register_record(struct ext_profile *ext,
return 0;
}
- if (add_record_to_server(src, rec) < 0) {
+ if (adapter_service_add(a, rec) < 0) {
error("Failed to register service record");
sdp_record_free(rec);
return 0;
@@ -1304,8 +1304,7 @@ static uint32_t ext_start_servers(struct ext_profile *ext,
}
}
- return ext_register_record(ext, l2cap, rfcomm,
- adapter_get_address(adapter));
+ return ext_register_record(ext, l2cap, rfcomm, adapter);
failed:
if (l2cap) {
diff --git a/src/sdpd-database.c b/src/sdpd-database.c
index cf33f19..600ddbf 100644
--- a/src/sdpd-database.c
+++ b/src/sdpd-database.c
@@ -168,7 +168,6 @@ void sdp_svcdb_set_collectable(sdp_record_t *record, int sock)
*/
void sdp_record_add(const bdaddr_t *device, sdp_record_t *rec)
{
- struct btd_adapter *adapter;
sdp_access_t *dev;
SDPDBG("Adding rec : 0x%lx", (long) rec);
@@ -184,15 +183,6 @@ void sdp_record_add(const bdaddr_t *device, sdp_record_t *rec)
dev->handle = rec->handle;
access_db = sdp_list_insert_sorted(access_db, dev, access_sort);
-
- if (bacmp(device, BDADDR_ANY) == 0) {
- adapter_foreach(adapter_service_insert, rec);
- return;
- }
-
- adapter = adapter_find(device);
- if (adapter)
- adapter_service_insert(adapter, rec);
}
static sdp_list_t *record_locate(uint32_t handle)
@@ -333,7 +323,5 @@ void sdp_init_services_list(bdaddr_t *device)
continue;
SDPDBG("adding record with handle %x", access->handle);
-
- adapter_foreach(adapter_service_insert, rec);
}
}
--
1.8.4
^ permalink raw reply related
* [PATCH v2 1/8] adapter: Insert DeviceID record if setting DeviceID data to controller
From: Szymon Janc @ 2013-09-19 14:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1379599248-7923-1-git-send-email-szymon.janc@tieto.com>
DeviceID is special since its record is registered on start by
sdpd-server and always has handle 0x10000.
---
src/adapter.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/adapter.c b/src/adapter.c
index 17f5508..62783a6 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -5621,9 +5621,13 @@ static int adapter_register(struct btd_adapter *adapter)
adapter->initialized = TRUE;
- if (main_opts.did_source)
+ if (main_opts.did_source) {
+ /* DeviceID record is added by sdpd-server before any other
+ * record is registered. */
+ adapter_service_insert(adapter, sdp_record_find(0x10000));
set_did(adapter, main_opts.did_vendor, main_opts.did_product,
main_opts.did_version, main_opts.did_source);
+ }
DBG("Adapter %s registered", adapter->path);
--
1.8.4
^ permalink raw reply related
* [PATCH v2 0/8] decoupling adapter code from sdp
From: Szymon Janc @ 2013-09-19 14:00 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
This includes code removal from sdptool that is no longer fully usable
with this serie.
Since Marcel had some objections about Device ID plugin patch it is moved
to end to not interfere with rest of patches. This plugin now also handles
setting proper DID values to adapter. Yet, main_opts are still accessed
directly and that should be worked out later.
With those patches sdp server is fully controlled by adapters and there
is no mutual adapter<->sdp code invocations.
BR
Szymon
Szymon Janc (8):
adapter: Insert DeviceID record if setting DeviceID data to controller
adapter: Handle adding new SDP records
adapter: Handle removing of SDP records
Remove not needed sdp_init_services_list function
unit: Remove not needed functions from test-sdp
sdpd: Remove 'register' and 'remove' requests
sdptool: Remove support for adding and removing service records
sdp: Decouple Device ID profile implementation
Makefile.plugins | 3 +
plugins/gatt-example.c | 2 +-
profiles/audio/a2dp.c | 14 +-
profiles/audio/avrcp.c | 8 +-
profiles/deviceid/deviceid.c | 187 +++
profiles/health/hdp.c | 2 +-
profiles/health/hdp_util.c | 6 +-
profiles/network/server.c | 6 +-
profiles/sap/server.c | 4 +-
src/adapter.c | 59 +-
src/adapter.h | 8 +-
src/attrib-server.c | 12 +-
src/attrib-server.h | 2 +-
src/profile.c | 9 +-
src/sdpd-database.c | 41 -
src/sdpd-request.c | 14 -
src/sdpd-server.c | 4 -
src/sdpd-service.c | 158 ---
src/sdpd.h | 6 -
tools/sdptool.1 | 16 -
tools/sdptool.c | 2595 +-----------------------------------------
unit/test-sdp.c | 29 -
22 files changed, 321 insertions(+), 2864 deletions(-)
create mode 100644 profiles/deviceid/deviceid.c
--
1.8.4
^ permalink raw reply
* Re: [PATCH] sdp: Check correct number of bytes received in recv
From: Johan Hedberg @ 2013-09-19 3:10 UTC (permalink / raw)
To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1379428820-6952-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>
Hi Andrei,
On Tue, Sep 17, 2013, Andrei Emeltchenko wrote:
> Instead of checking for error check that correct number of bytes received.
> ---
> src/sdpd-server.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Applied. Thanks.
Johan
^ permalink raw reply
* Re: [PATCH v3 2/2] Bluetooth: Fix rfkill functionality during the HCI setup stage
From: Gustavo Padovan @ 2013-09-18 22:06 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
In-Reply-To: <1379051898-2630-3-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
2013-09-13 johan.hedberg@gmail.com <johan.hedberg@gmail.com>:
> From: Johan Hedberg <johan.hedberg@intel.com>
>
> We need to let the setup stage complete cleanly even when the HCI device
> is rfkilled. Otherwise the HCI device will stay in an undefined state
> and never get notified to user space through mgmt (even when it gets
> unblocked through rfkill).
>
> This patch makes sure that hci_dev_open() can be called in the HCI_SETUP
> stage, that blocking the device doesn't abort the setup stage, and that
> the device gets proper powered down as soon as the setup stage completes
> in case it was blocked meanwhile.
>
> The bug that this patch fixed can be very easily reproduced using e.g.
> the rfkill command line too. By running "rfkill block all" before
> inserting a Bluetooth dongle the resulting HCI device goes into a state
> where it is never announced over mgmt, not even when "rfkill unblock all"
> is run.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> Cc: stable@vger.kernel.org
> ---
> v3: Use "else if" instead of separate if-statement
>
> net/bluetooth/hci_core.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
Both patches have been applied to bluetooth.git. Thanks.
Gustavo
^ permalink raw reply
* Re: [PATCH v5 8/8] Bluetooth: Fix waiting for clearing of BT_SK_SUSPEND flag
From: Gustavo Padovan @ 2013-09-18 22:04 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
In-Reply-To: <1379325919-19003-9-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
2013-09-16 johan.hedberg@gmail.com <johan.hedberg@gmail.com>:
> From: Johan Hedberg <johan.hedberg@intel.com>
>
> In the case of blocking sockets we should not proceed with sendmsg() if
> the socket has the BT_SK_SUSPEND flag set. So far the code was only
> ensuring that POLLOUT doesn't get set for non-blocking sockets using
> poll() but there was no code in place to ensure that blocking sockets do
> the right thing when writing to them.
>
> This patch adds a new bt_sock_wait_ready helper function to sleep in the
> sendmsg call if the BT_SK_SUSPEND flag is set, and wake up as soon as it
> is unset. It also updates the L2CAP and RFCOMM sendmsg callbacks to take
> advantage of this new helper function.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/bluetooth.h | 1 +
> net/bluetooth/af_bluetooth.c | 40 +++++++++++++++++++++++++++++++++++++++
> net/bluetooth/l2cap_sock.c | 6 ++++++
> net/bluetooth/rfcomm/sock.c | 7 ++++++-
> 4 files changed, 53 insertions(+), 1 deletion(-)
All patches have been applied to bluetooth-next. Thanks.
Gustavo
^ permalink raw reply
* Re: [PATCH] rfcomm: don't release the port in rfcomm_dev_state_change()
From: Peter Hurley @ 2013-09-18 1:19 UTC (permalink / raw)
To: Gianluca Anzolin; +Cc: gustavo, marcel, linux-bluetooth, gregkh, jslaby
In-Reply-To: <1377620926-23370-1-git-send-email-gianluca@sottospazio.it>
On 08/27/2013 12:28 PM, Gianluca Anzolin wrote:
> When the dlc is closed, rfcomm_dev_state_change() tries to release the
> port in the case it cannot get a reference to the tty. However this is
> racy and not even needed.
>
> Infact as Peter Hurley points out:
>
> 1. Only consider dlcs that are 'stolen' from a connected socket, ie.
> reused. Allocated dlcs cannot have been closed prior to port
> activate and so for these dlcs a tty reference will always be avail
> in rfcomm_dev_state_change() -- except for the conditions covered by
> #2b below.
> 2. If a tty was at some point previously created for this rfcomm, then
> either
> (a) the tty reference is still avail, so rfcomm_dev_state_change()
> will perform a hangup. So nothing to do, or,
> (b) the tty reference is no longer avail, and the tty_port will be
> destroyed by the last tty_port_put() in rfcomm_tty_cleanup.
> Again, no action required.
> 3. Prior to obtaining the dlc lock in rfcomm_dev_add(),
> rfcomm_dev_state_change() will not 'see' a rfcomm_dev so nothing to
> do here.
> 4. After releasing the dlc lock in rfcomm_dev_add(),
> rfcomm_dev_state_change() will 'see' an incomplete rfcomm_dev if a
> tty reference could not be obtained. Again, the best thing to do here
> is nothing. Any future attempted open() will block on
> rfcomm_dev_carrier_raised(). The unconnected device will exist until
> released by ioctl(RFCOMMRELEASEDEV).
>
> The patch removes the aforementioned code and uses the
> tty_port_tty_hangup() helper to hangup the tty.
Sorry for the delay in reviewing.
Reviewed-by: Peter Hurley <peter@hurleysoftware.com>
^ permalink raw reply
* [PATCH] sdp: Check correct number of bytes received in recv
From: Andrei Emeltchenko @ 2013-09-17 14:40 UTC (permalink / raw)
To: linux-bluetooth
From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
Instead of checking for error check that correct number of bytes received.
---
src/sdpd-server.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/sdpd-server.c b/src/sdpd-server.c
index 181d248..7b1351f 100644
--- a/src/sdpd-server.c
+++ b/src/sdpd-server.c
@@ -177,7 +177,7 @@ static gboolean io_session_event(GIOChannel *chan, GIOCondition cond, gpointer d
return TRUE;
len = recv(sk, buf, size, 0);
- if (len <= 0) {
+ if (len != size) {
sdp_svcdb_collect_all(sk);
free(buf);
return FALSE;
--
1.7.10.4
^ permalink raw reply related
* RE: [PATCH v4] Bluetooth: btmrvl: add calibration data download support
From: Bing Zhao @ 2013-09-16 21:17 UTC (permalink / raw)
To: Marcel Holtmann
Cc: linux-bluetooth@vger.kernel.org, Gustavo Padovan, Johan Hedberg,
linux-wireless@vger.kernel.org, Mike Frysinger, Hyuckjoo Lee,
Amitkumar Karwar
In-Reply-To: <525C3DAD-2AD3-468F-8309-630EEE54A3CE@holtmann.org>
Hi Marcel,
Thanks for your comment.
> > + bt_cb(skb)->pkt_type =3D MRVL_VENDOR_PKT;
> > + skb_put(skb, sizeof(*cmd));
> > + skb->dev =3D (void *)priv->btmrvl_dev.hcidev;
> > + skb_queue_head(&priv->adapter->tx_queue, skb);
> > + priv->btmrvl_dev.sendcmdflag =3D true;
> > + priv->adapter->cmd_complete =3D false;
>=20
> since the Bluetooth HCI core got ->setup() support with proper synchronou=
s HCI request handling
> available for every single driver (see the Intel support in btusb.c), why=
not start using that with
> this driver as well.
We will convert btmrvl driver to use ->setup() callback.
Thanks,
Bing
^ permalink raw reply
* RE: [PATCH v4] Bluetooth: btmrvl: add calibration data download support
From: Amitkumar Karwar @ 2013-09-16 15:51 UTC (permalink / raw)
To: 'Mike Frysinger', Bing Zhao
Cc: linux-bluetooth@vger.kernel.org, Marcel Holtmann, Gustavo Padovan,
Johan Hedberg, linux-wireless@vger.kernel.org, Hyuckjoo Lee
In-Reply-To: <CAAbOScnG8RHWbPdjq6=e=EBJPr_f6+R4o36f3h0T=NxGgQt7AQ@mail.gmail.com>
Hi Mike,
Thanks for your comments. We will take care of them in updated version.
>=20
> On Fri, Sep 13, 2013 at 7:32 PM, Bing Zhao wrote:
> > --- a/drivers/bluetooth/btmrvl_main.c
> > +++ b/drivers/bluetooth/btmrvl_main.c
> >
> > +static int btmrvl_parse_cal_cfg(const u8 *src, u32 len, u8 *dst, u32
> dst_size)
>=20
> would be nice if you put a comment above this func explaining the
> expected format. otherwise, we see arbitrary parsing with no idea if
> it's correct.
Sure. We will add below information.
Calibrated input data should contain hex bytes separated by space or
new line character. Here is an example
00 1C 01 37 FF FF FF FF 02 04 7F 01
CE BA 00 00 00 2D C6 C0 00 00 00 00
00 F0 00 00
>=20
> > + while ((s - src) < len) {
> > + if (isspace(*s)) {
> > + s++;
> > + continue;
> > + }
> > +
> > + if (isxdigit(*s)) {
> > + if ((d - dst) >=3D dst_size) {
> > + BT_ERR("calibration data file too
> big!!!");
> > + return -EINVAL;
> > + }
> > +
> > + memcpy(tmp, s, 2);
> > +
> > + ret =3D kstrtou8(tmp, 16, d++);
> > + if (ret < 0)
> > + return ret;
> > +
> > + s +=3D 2;
> > + } else {
> > + s++;
> > + }
> > + }
>=20
> so if it's a space, you skip it. if it's a hexdigit, you parse two
> bytes. if it's anything else, you skip it. i'd imagine the "non
> space and non hexdigit" case should throw a warning if not reject the
> file out right. otherwise, if you want to keep this logic, punt the
> explicit "isspace" check.
You are right. Rejecting the file containing non space, non new line and no=
n hexdigit character makes sense.
>=20
> you might also copy one more byte than you should ? your limit is "(s
> - src) < len", yet the isxdigit code always copies two bytes.
Thanks for pointing this out. We will replace "(s - src) < len" with "(s -s=
rc) <=3D (len - 2)".=20
>=20
> > +static int btmrvl_load_cal_data(struct btmrvl_private *priv,
> > + u8 *config_data)
> > +{
> > + struct sk_buff *skb;
> > + struct btmrvl_cmd *cmd;
> > + int i;
> > +
> > + skb =3D bt_skb_alloc(sizeof(*cmd), GFP_ATOMIC);
>=20
> maybe i'm unfamiliar with bluetooth and this is common, but why is
> your code so special as to require GFP_ATOMIC allocations ?
GFP_ATOMIC was used to match other usages in bluetooth code.
I just found that as per commit "Remove GFP_ATOMIC usage from l2cap_core.c"=
(commit id: 8bcde1f2ab..), since bluetooth core is now running in process c=
ontext, we don't need to use GFP_ATOMIC.
We will replace it with GFP_KERNEL in updated version.
>=20
> > + for (i =3D 4; i < BT_CMD_DATA_SIZE; i++)
> > + cmd->data[i] =3D config_data[(i/4)*8 - 1 - i];
>=20
> style nit, but there should be spacing around those math operators.
> ignoring the fact that this is some funky funky buffer offsets.
>=20
> i =3D 4
> config_data[(4 / 4) * 8 - 1 - 4] ->
> config_data[8 - 1 - 4] ->
> config_data[3]
>=20
> i =3D 5
> config_data[(5 / 4) * 8 - 1 - 5] ->
> config_data[8 - 1 - 5] ->
> config_data[2]
>=20
> i =3D 6
> config_data[(6 / 4) * 8 - 1 - 6] ->
> config_data[8 - 1 - 6] ->
> config_data[1]
>=20
> i =3D 7
> config_data[(7 / 4) * 8 - 1 - 7] ->
> config_data[8 - 1 - 7] ->
> config_data[0]
>=20
> i =3D 8
> config_data[(8 / 4) * 8 - 1 - 8] ->
> config_data[16 - 1 - 8] ->
> config_data[7]
>=20
> i =3D {4,5,6,7} -> config_data[{3,2,1,0}]
> i =3D {8,9,10,11} -> config_data[{7,6,5,4}]
>=20
> that really could do with a comment explaining the mapping of input
> bytes to output bytes.
Sure. We add a comment here.
Actually each 4 bytes are being swapped. Considering 4 byte SDIO header off=
set, it becomes
input{3, 2, 1, 0} -> output{0+4, 1+4, 2+4, 3+4}
Regards,
Amitkumar Karwar
> -mike
^ permalink raw reply
* Re: [PATCH v2 1/5] Bluetooth: Fix hci_add_sysfs
From: Gustavo Padovan @ 2013-09-16 15:06 UTC (permalink / raw)
To: Andre Guedes; +Cc: linux-bluetooth
In-Reply-To: <1377288071-3664-1-git-send-email-andre.guedes@openbossa.org>
Hi Andre,
2013-08-23 Andre Guedes <andre.guedes@openbossa.org>:
> The inquiry_cache and auto_accept_delay files should be added to
> debugfs only if controller is BR/EDR capable.
>
> Since in hci_register_dev() hdev has not been initialized yet,
> we are not able to check if the controller is BR/EDR capable.
> Thus, we postpone exporting those two files to just after
> controller's initialization.
>
> Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
> ---
> include/net/bluetooth/hci_core.h | 1 +
> net/bluetooth/hci_core.c | 17 ++++++++++++-----
> net/bluetooth/hci_sysfs.c | 16 +++++++++++-----
> 3 files changed, 24 insertions(+), 10 deletions(-)
>
> diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
> index 3ede820..879bf45 100644
> --- a/include/net/bluetooth/hci_core.h
> +++ b/include/net/bluetooth/hci_core.h
> @@ -775,6 +775,7 @@ int hci_recv_stream_fragment(struct hci_dev *hdev, void *data, int count);
> void hci_init_sysfs(struct hci_dev *hdev);
> int hci_add_sysfs(struct hci_dev *hdev);
> void hci_del_sysfs(struct hci_dev *hdev);
> +void hci_sysfs_export_info(struct hci_dev *hdev);
> void hci_conn_init_sysfs(struct hci_conn *conn);
> void hci_conn_add_sysfs(struct hci_conn *conn);
> void hci_conn_del_sysfs(struct hci_conn *conn);
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 8d9b87d..e8be6ec 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -1184,11 +1184,18 @@ int hci_dev_open(__u16 dev)
> hci_dev_hold(hdev);
> set_bit(HCI_UP, &hdev->flags);
> hci_notify(hdev, HCI_DEV_UP);
> - if (!test_bit(HCI_SETUP, &hdev->dev_flags) &&
> - mgmt_valid_hdev(hdev)) {
> - hci_dev_lock(hdev);
> - mgmt_powered(hdev, 1);
> - hci_dev_unlock(hdev);
> + if (mgmt_valid_hdev(hdev)) {
> + /* If we are in HCI_SETUP phase, meaning the device
> + * has just been registered, we should export the
> + * remaining infos to debugfs.
> + */
> + if (test_bit(HCI_SETUP, &hdev->dev_flags)) {
> + hci_sysfs_export_info(hdev);
> + } else {
> + hci_dev_lock(hdev);
> + mgmt_powered(hdev, 1);
> + hci_dev_unlock(hdev);
> + }
These patches doesn't apply cleanly on bluetooth-next anymore. Please rebase
the set and resend. Thanks.
Gustavo
^ permalink raw reply
* Re: [PATCH 1/1 v4] Bluetooth: Fix ACL alive for long in case of non pariable devices
From: Gustavo Padovan @ 2013-09-16 14:52 UTC (permalink / raw)
To: Syam Sidhardhan; +Cc: linux-bluetooth, Syam Sidhardhan
In-Reply-To: <1375721952-3601-1-git-send-email-syamsidhardh@gmail.com>
Hi Syam,
2013-08-06 Syam Sidhardhan <syamsidhardh@gmail.com>:
> From: Syam Sidhardhan <s.syam@samsung.com>
>
> For certain devices (ex: HID mouse), support for authentication,
> pairing and bonding is optional. For such devices, the ACL alive
> for too long after the L2CAP disconnection.
>
> To avoid the ACL alive for too long after L2CAP disconnection, reset the
> ACL disconnect timeout back to HCI_DISCONN_TIMEOUT during L2CAP connect.
>
> While merging the commit id:a9ea3ed9b71cc3271dd59e76f65748adcaa76422
> this issue might have introduced.
>
> Hcidump info:
> sh-4.1# /opt/hcidump -Xt
> HCI sniffer - Bluetooth packet analyzer ver 2.4
> device: hci0 snap_len: 1500 filter: 0xffffffff
> 2013-08-05 16:48:47.847053 > HCI Event: Connect Request (0x04) plen 10
> bdaddr 00:12:A1:65:E5:B2 class 0x002580 type ACL
> 2013-08-05 16:48:47.847310 < HCI Command: Accept Connection Request (0x01
> |0x0009) plen 7
> bdaddr 00:12:A1:65:E5:B2 role 0x00
> Role: Master
> 2013-08-05 16:48:47.848436 > HCI Event: Command Status (0x0f) plen 4
> Accept Connection Request (0x01|0x0009) status 0x00 ncmd 1
> 2013-08-05 16:48:48.007120 > HCI Event: Role Change (0x12) plen 8
> status 0x00 bdaddr 00:12:A1:65:E5:B2 role 0x00
> Role: Master
> 2013-08-05 16:48:48.050475 > HCI Event: Connect Complete (0x03) plen 11
> status 0x00 handle 12 bdaddr 00:12:A1:65:E5:B2 type ACL encrypt 0x00
> 2013-08-05 16:48:48.051235 < HCI Command: Read Remote Supported Features
> (0x01|0x001b) plen 2
> handle 12
> 2013-08-05 16:48:48.051691 > HCI Event: Command Status (0x0f) plen 4
> Read Remote Supported Features (0x01|0x001b) status 0x00 ncmd 1
> 2013-08-05 16:48:48.051864 > HCI Event: Read Remote Supported Features
> (0x0b) plen 11
> status 0x00 handle 12
> Features: 0xbc 0x02 0x04 0x38 0x08 0x00 0x00 0x00
> 2013-08-05 16:48:48.051899 < HCI Command: Remote Name Request (0x01|
> 0x0019) plen 10
> bdaddr 00:12:A1:65:E5:B2 mode 2 clkoffset 0x0000
> 2013-08-05 16:48:48.052530 > HCI Event: Command Status (0x0f) plen 4
> Remote Name Request (0x01|0x0019) status 0x00 ncmd 1
> 2013-08-05 16:48:48.056407 > ACL data: handle 12 flags 0x02 dlen 12
> L2CAP(s): Connect req: psm 17 scid 0x0049
> 2013-08-05 16:48:48.056492 < ACL data: handle 12 flags 0x00 dlen 16
> L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0049 result 1 status 0
> Connection pending - No futher information available
> 2013-08-05 16:48:48.056510 < ACL data: handle 12 flags 0x00 dlen 10
> L2CAP(s): Info req: type 2
> 2013-08-05 16:48:48.061404 > HCI Event: Number of Completed Packets
> (0x13) plen 5
> handle 12 packets 2
> 2013-08-05 16:48:48.064019 > ACL data: handle 12 flags 0x02 dlen 16
> L2CAP(s): Info rsp: type 2 result 0
> Extended feature mask 0x0004
> Bi-directional QoS
> 2013-08-05 16:48:48.064059 < ACL data: handle 12 flags 0x00 dlen 16
> L2CAP(s): Connect rsp: dcid 0x0040 scid 0x0049 result 0 status 0
> Connection successful
> 2013-08-05 16:48:48.064071 < ACL data: handle 12 flags 0x00 dlen 12
> L2CAP(s): Config req: dcid 0x0049 flags 0x00 clen 0
> 2013-08-05 16:48:48.067220 > HCI Event: Remote Name Req Complete (0x07)
> plen 255
> status 0x00 bdaddr 00:12:A1:65:E5:B2 name 'Bluetooth Mouse'
> 2013-08-05 16:48:48.067627 > HCI Event: Number of Completed Packets
> (0x13) plen 5
> handle 12 packets 2
> 2013-08-05 16:48:48.070114 > ACL data: handle 12 flags 0x02 dlen 16
> L2CAP(s): Config req: dcid 0x0040 flags 0x00 clen 4
> MTU 185
> 2013-08-05 16:48:48.070148 < ACL data: handle 12 flags 0x00 dlen 18
> L2CAP(s): Config rsp: scid 0x0049 flags 0x00 result 0 clen 4
> MTU 185
> 2013-08-05 16:48:48.072642 > ACL data: handle 12 flags 0x02 dlen 18
> L2CAP(s): Config rsp: scid 0x0040 flags 0x00 result 0 clen 4
> MTU 185
> 2013-08-05 16:48:48.075123 > ACL data: handle 12 flags 0x02 dlen 12
> L2CAP(s): Connect req: psm 19 scid 0x004a
> 2013-08-05 16:48:48.075196 < ACL data: handle 12 flags 0x00 dlen 16
> L2CAP(s): Connect rsp: dcid 0x0041 scid 0x004a result 1 status 2
> Connection pending - Authorization pending
> 2013-08-05 16:48:48.075364 < ACL data: handle 12 flags 0x00 dlen 16
> L2CAP(s): Connect rsp: dcid 0x0041 scid 0x004a result 0 status 0
> Connection successful
> 2013-08-05 16:48:48.075403 < ACL data: handle 12 flags 0x00 dlen 12
> L2CAP(s): Config req: dcid 0x004a flags 0x00 clen 0
> 2013-08-05 16:48:48.077633 > HCI Event: Number of Completed Packets
> (0x13) plen 5
> handle 12 packets 2
> 2013-08-05 16:48:48.080127 > HCI Event: Number of Completed Packets
> (0x13) plen 5
> handle 12 packets 2
> 2013-08-05 16:48:48.081355 > ACL data: handle 12 flags 0x02 dlen 16
> L2CAP(s): Config req: dcid 0x0041 flags 0x00 clen 4
> MTU 185
> 2013-08-05 16:48:48.081402 < ACL data: handle 12 flags 0x00 dlen 18
> L2CAP(s): Config rsp: scid 0x004a flags 0x00 result 0 clen 4
> MTU 185
> 2013-08-05 16:48:48.082633 > ACL data: handle 12 flags 0x02 dlen 18
> L2CAP(s): Config rsp: scid 0x0041 flags 0x00 result 0 clen 4
> MTU 185
> 2013-08-05 16:48:48.084838 < ACL data: handle 12 flags 0x00 dlen 12
> L2CAP(d): cid 0x004a len 8 [psm 19]
> HIDP: Data: Output report
> 0000: 02 00 00 00 00 00 00 .......
> ...
> ...
>
> 2013-08-05 16:49:00.894129 < ACL data: handle 12 flags 0x00 dlen 12
> L2CAP(s): Disconn req: dcid 0x004a scid 0x0041
> 2013-08-05 16:49:00.894195 < HCI Command: Exit Sniff Mode (0x02|0x0004)
> plen 2
> handle 12
> 2013-08-05 16:49:00.894269 < ACL data: handle 12 flags 0x00 dlen 12
> L2CAP(s): Disconn req: dcid 0x0049 scid 0x0040
> 2013-08-05 16:49:00.895645 > HCI Event: Command Status (0x0f) plen 4
> Exit Sniff Mode (0x02|0x0004) status 0x00 ncmd 1
> 2013-08-05 16:49:00.934391 > HCI Event: Mode Change (0x14) plen 6
> status 0x00 handle 12 mode 0x00 interval 0
> Mode: Active
> 2013-08-05 16:49:00.936592 > HCI Event: Number of Completed Packets
> (0x13) plen 5
> handle 12 packets 2
> 2013-08-05 16:49:00.951577 > ACL data: handle 12 flags 0x02 dlen 12
> L2CAP(s): Disconn rsp: dcid 0x004a scid 0x0041
> 2013-08-05 16:49:00.952820 > ACL data: handle 12 flags 0x02 dlen 12
> L2CAP(s): Disconn rsp: dcid 0x0049 scid 0x0040
> 2013-08-05 16:49:00.969165 > HCI Event: Mode Change (0x14) plen 6
> status 0x00 handle 12 mode 0x02 interval 50
> Mode: Sniff
>
> 2013-08-05 16:49:48.175533 > HCI Event: Mode Change (0x14) plen 6
> status 0x00 handle 12 mode 0x00 interval 0
> Mode: Active
> 2013-08-05 16:49:48.219045 > HCI Event: Mode Change (0x14) plen 6
> status 0x00 handle 12 mode 0x02 interval 108
> Mode: Sniff
>
> 2013-08-05 16:51:00.968209 < HCI Command: Disconnect (0x01|0x0006) plen 3
> handle 12 reason 0x13
> Reason: Remote User Terminated Connection
> 2013-08-05 16:51:00.969056 > HCI Event: Command Status (0x0f) plen 4
> Disconnect (0x01|0x0006) status 0x00 ncmd 1
> 2013-08-05 16:51:01.013495 > HCI Event: Mode Change (0x14) plen 6
> status 0x00 handle 12 mode 0x00 interval 0
> Mode: Active
> 2013-08-05 16:51:01.073777 > HCI Event: Disconn Complete (0x05) plen 4
> status 0x00 handle 12 reason 0x16
> Reason: Connection Terminated by Local Host
>
> ========================= Conn status =================================
> sh-4.1# date; hcitool con
> Mon Aug 5 16:49:16 KST 2013
> Connections:
> > ACL 00:12:A1:65:E5:B2 handle 12 state 1 lm MASTER
> sh-4.1# date; hcitool con
> Mon Aug 5 16:50:32 KST 2013
> Connections:
> > ACL 00:12:A1:65:E5:B2 handle 12 state 1 lm MASTER
> sh-4.1# date; hcitool con
> Mon Aug 5 16:50:59 KST 2013
> Connections:
> > ACL 00:12:A1:65:E5:B2 handle 12 state 1 lm MASTER
> sh-4.1# date; hcitool con
> Mon Aug 5 16:51:01 KST 2013
> Connections:
> sh-4.1#
>
> ============================ After fix ================================
>
> 2013-08-05 16:57:35.986648 < ACL data: handle 11 flags 0x00 dlen 12
> L2CAP(s): Disconn req: dcid 0x004c scid 0x0041
> 2013-08-05 16:57:35.986713 < HCI Command: Exit Sniff Mode (0x02|0x0004)
> plen 2
> handle 11
> 2013-08-05 16:57:35.986785 < ACL data: handle 11 flags 0x00 dlen 12
> L2CAP(s): Disconn req: dcid 0x004b scid 0x0040
> 2013-08-05 16:57:35.988110 > HCI Event: Command Status (0x0f) plen 4
> Exit Sniff Mode (0x02|0x0004) status 0x00 ncmd 1
> 2013-08-05 16:57:36.030714 > HCI Event: Mode Change (0x14) plen 6
> status 0x00 handle 11 mode 0x00 interval 0
> Mode: Active
> 2013-08-05 16:57:36.032950 > HCI Event: Number of Completed Packets
> (0x13) plen 5
> handle 11 packets 2
> 2013-08-05 16:57:36.047926 > ACL data: handle 11 flags 0x02 dlen 12
> L2CAP(s): Disconn rsp: dcid 0x004c scid 0x0041
> 2013-08-05 16:57:36.049200 > ACL data: handle 11 flags 0x02 dlen 12
> L2CAP(s): Disconn rsp: dcid 0x004b scid 0x0040
> 2013-08-05 16:57:36.065509 > HCI Event: Mode Change (0x14) plen 6
> status 0x00 handle 11 mode 0x02 interval 50
> Mode: Sniff
>
> 2013-08-05 16:57:40.052006 < HCI Command: Disconnect (0x01|0x0006) plen 3
> handle 11 reason 0x13
> Reason: Remote User Terminated Connection
> 2013-08-05 16:57:40.052869 > HCI Event: Command Status (0x0f) plen 4
> Disconnect (0x01|0x0006) status 0x00 ncmd 1
> 2013-08-05 16:57:40.104731 > HCI Event: Mode Change (0x14) plen 6
> status 0x00 handle 11 mode 0x00 interval 0
> Mode: Active
> 2013-08-05 16:57:40.146935 > HCI Event: Disconn Complete (0x05) plen 4
> status 0x00 handle 11 reason 0x16
> Reason: Connection Terminated by Local Host
>
> Signed-off-by: Sang-Ki Park <sangki79.park@samsung.com>
> Signed-off-by: Chan-yeol Park <chanyeol.park@samsung.com>
> Signed-off-by: Jaganath Kanakkassery <jaganath.k@samsung.com>
> Signed-off-by: Szymon Janc <szymon.janc@tieto.com>
> Signed-off-by: Syam Sidhardhan <s.syam@samsung.com>
> ---
>
> v1 -> Modified the code as per the latest code.
> v2 -> Add descriptive comment as per Marcel request.
> v3 -> Moved from l2cap_conn_ready() to l2cap_connect() inorder to fix remote
> non ssp pairing timeout. Generated the patch based on bluetooth.git tree.
> v4 -> Include hcidump logs showing the conn status before and after fix.
>
> This patch is generated the patch based on bluetooth.git tree.
>
> net/bluetooth/l2cap_core.c | 7 +++++++
> 1 file changed, 7 insertions(+)
Patch has been applied to bluetooth.git. Thanks.
Gustavo
^ permalink raw reply
* Re: [RFC SBC] build: Add configure option --disable-high-precision
From: Luiz Augusto von Dentz @ 2013-09-16 14:43 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <ACAC771F-74CD-40BF-BFB7-4CC92B588415@holtmann.org>
Hi Marcel,
On Mon, Sep 16, 2013 at 5:19 PM, Marcel Holtmann <marcel@holtmann.org> wrote:
> Hi Luiz,
>
>> This enables high precision using 64 bits accumulators by default which
>> can be disabled with --disable-high-precision.
>> ---
>> configure.ac | 8 ++++++++
>> sbc/sbc_tables.h | 2 --
>> 2 files changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/configure.ac b/configure.ac
>> index c052616..5f994d1 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -58,4 +58,12 @@ if (test "${enable_tester}" != "no"); then
>> fi
>> AM_CONDITIONAL(TESTER, test "${enable_tester}" != "no")
>>
>> +AC_ARG_ENABLE(high-precision, AC_HELP_STRING([--disable-high-precision],
>> + [disable high precision support]),
>> + [enable_high_precision=${enableval}])
>> +if (test "${enable_high_precision}" != "no"); then
>> + AC_DEFINE(SBC_HIGH_PRECISION, 1,
>> + [Define to 1 to enable high precision build of SBC encoder])
>> +fi
>> +
>> AC_OUTPUT(Makefile sbc/sbc.pc)
>> diff --git a/sbc/sbc_tables.h b/sbc/sbc_tables.h
>> index 25e24e6..3fd80e1 100644
>> --- a/sbc/sbc_tables.h
>> +++ b/sbc/sbc_tables.h
>> @@ -136,8 +136,6 @@ static const int32_t synmatrix8[16][8] = {
>> SN8(0xfb8e3130), SN8(0xf8275a10), SN8(0xfe70747c), SN8(0x06a6d988) }
>> };
>>
>> -/* Uncomment the following line to enable high precision build of SBC encoder */
>> -
>> /* #define SBC_HIGH_PRECISION */
>
> the comment with the define should also be removed.
>
> Is there any impact on using 64-bit integers compared to 32-bit integers. When would you use one or the other. I think this needs to be documented in README as well.
The use of 64-bit apparently makes the encoder 'better' in term of
dynamic range, but I will probably check with the tools that Siarhei
uses for testing the exact amount of 'better', the drawback is that
for 32-bits systems it might have an impact in performance so it is
good to keep --disable-high-precision and document it in the README as
you suggested.
Maybe this will be useful to kick start some unit tests for sbc as well.
--
Luiz Augusto von Dentz
^ permalink raw reply
* Re: [RFC SBC] build: Add configure option --disable-high-precision
From: Marcel Holtmann @ 2013-09-16 14:19 UTC (permalink / raw)
To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <1379323375-21540-1-git-send-email-luiz.dentz@gmail.com>
Hi Luiz,
> This enables high precision using 64 bits accumulators by default which
> can be disabled with --disable-high-precision.
> ---
> configure.ac | 8 ++++++++
> sbc/sbc_tables.h | 2 --
> 2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index c052616..5f994d1 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -58,4 +58,12 @@ if (test "${enable_tester}" != "no"); then
> fi
> AM_CONDITIONAL(TESTER, test "${enable_tester}" != "no")
>
> +AC_ARG_ENABLE(high-precision, AC_HELP_STRING([--disable-high-precision],
> + [disable high precision support]),
> + [enable_high_precision=${enableval}])
> +if (test "${enable_high_precision}" != "no"); then
> + AC_DEFINE(SBC_HIGH_PRECISION, 1,
> + [Define to 1 to enable high precision build of SBC encoder])
> +fi
> +
> AC_OUTPUT(Makefile sbc/sbc.pc)
> diff --git a/sbc/sbc_tables.h b/sbc/sbc_tables.h
> index 25e24e6..3fd80e1 100644
> --- a/sbc/sbc_tables.h
> +++ b/sbc/sbc_tables.h
> @@ -136,8 +136,6 @@ static const int32_t synmatrix8[16][8] = {
> SN8(0xfb8e3130), SN8(0xf8275a10), SN8(0xfe70747c), SN8(0x06a6d988) }
> };
>
> -/* Uncomment the following line to enable high precision build of SBC encoder */
> -
> /* #define SBC_HIGH_PRECISION */
the comment with the define should also be removed.
Is there any impact on using 64-bit integers compared to 32-bit integers. When would you use one or the other. I think this needs to be documented in README as well.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH v4 8/8] Bluetooth: Fix waiting for clearing of BT_SK_SUSPEND flag
From: Marcel Holtmann @ 2013-09-16 14:14 UTC (permalink / raw)
To: Johan Hedberg; +Cc: linux-bluetooth
In-Reply-To: <20130916081926.GA13593@x220.p-661hnu-f1>
Hi Johan,
>>> @@ -525,6 +525,45 @@ int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo)
>>> }
>>> EXPORT_SYMBOL(bt_sock_wait_state);
>>>
>>
>> add a small comment here that this needs to be called with sk lock held.
>
> I suppose I should do that to the old bt_sock_wait_state function too?
> (which btw my wait_ready function is essentially a copy of, with the
> exception of which condition it looks for)
good idea.
>>> +int bt_sock_wait_ready(struct sock *sk, unsigned long flags)
>>> +{
>>> + DECLARE_WAITQUEUE(wait, current);
>>> + unsigned long timeo;
>>> + int err = 0;
>>> +
>>> + BT_DBG("sk %p", sk);
>>> +
>>> + timeo = sock_sndtimeo(sk, flags & O_NONBLOCK);
>>> +
>>> + add_wait_queue(sk_sleep(sk), &wait);
>>> + set_current_state(TASK_INTERRUPTIBLE);
>>> + while (test_bit(BT_SK_SUSPEND, &bt_sk(sk)->flags)) {
>>> + if (!timeo) {
>>> + err = -EAGAIN;
>>> + break;
>>> + }
>>> +
>>> + if (signal_pending(current)) {
>>> + err = sock_intr_errno(timeo);
>>> + break;
>>> + }
>>> +
>>> + release_sock(sk);
>>> + timeo = schedule_timeout(timeo);
>>> + lock_sock(sk);
>>> + set_current_state(TASK_INTERRUPTIBLE);
>>> +
>>> + err = sock_error(sk);
>>> + if (err)
>>> + break;
>>> + }
>>> + __set_current_state(TASK_RUNNING);
>>> + remove_wait_queue(sk_sleep(sk), &wait);
>>> +
>>> + return err;
>>> +}
>>> +EXPORT_SYMBOL(bt_sock_wait_ready);
>>> +
>>> #ifdef CONFIG_PROC_FS
>>> struct bt_seq_state {
>>> struct bt_sock_list *l;
>>> diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
>>> index 0098af8..ad95b42 100644
>>> --- a/net/bluetooth/l2cap_sock.c
>>> +++ b/net/bluetooth/l2cap_sock.c
>>> @@ -777,6 +777,12 @@ static int l2cap_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
>>> if (sk->sk_state != BT_CONNECTED)
>>> return -ENOTCONN;
>>>
>>> + lock_sock(sk);
>>> + err = bt_sock_wait_ready(sk, msg->msg_flags);
>>> + release_sock(sk);
>>> + if (err)
>>> + return err;
>>> +
>>
>> After starting to look into this now, I am not sure we have proper
>> locking in that function in the first place. Can you check that it is
>> actually fine not holding the socket lock for the send operation
>> itself.
>
> What procedure did you have in mind for checking what's fine and what's
> not? Some quick googling and trying to look at the code of other address
> families didn't help me getting much wiser about this.
>
> This is the way that RFCOMM and L2CAP sockets seem to always have done
> locking and we haven't seen any obvious breakage because of it. The
> RFCOMM side does indeed use lock_sock for the send operation and L2CAP
> doesn't. However, I think the reason it works is that l2cap_chan_lock
> (which is used before calling l2cap_chan_send) serves a similar purpose.
Then lets leave it as is.
Regards
Marcel
^ permalink raw reply
* Re: [PATCH v5 8/8] Bluetooth: Fix waiting for clearing of BT_SK_SUSPEND flag
From: Marcel Holtmann @ 2013-09-16 14:13 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
In-Reply-To: <1379325919-19003-9-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> In the case of blocking sockets we should not proceed with sendmsg() if
> the socket has the BT_SK_SUSPEND flag set. So far the code was only
> ensuring that POLLOUT doesn't get set for non-blocking sockets using
> poll() but there was no code in place to ensure that blocking sockets do
> the right thing when writing to them.
>
> This patch adds a new bt_sock_wait_ready helper function to sleep in the
> sendmsg call if the BT_SK_SUSPEND flag is set, and wake up as soon as it
> is unset. It also updates the L2CAP and RFCOMM sendmsg callbacks to take
> advantage of this new helper function.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> include/net/bluetooth/bluetooth.h | 1 +
> net/bluetooth/af_bluetooth.c | 40 +++++++++++++++++++++++++++++++++++++++
> net/bluetooth/l2cap_sock.c | 6 ++++++
> net/bluetooth/rfcomm/sock.c | 7 ++++++-
> 4 files changed, 53 insertions(+), 1 deletion(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply
* Re: [PATCH v5 3/8] Bluetooth: Fix L2CAP error return used for failed channel lookups
From: Marcel Holtmann @ 2013-09-16 14:12 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
In-Reply-To: <1379325919-19003-4-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> The EFAULT error should only be used for memory address related errors
> and ENOENT might be needed for other purposes than invalid CID errors.
> This patch fixes the l2cap_config_req, l2cap_connect_create_rsp and
> l2cap_create_channel_req handlers to use the unique EBADSLT error to
> indicate failed lookups on a given CID.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/l2cap_core.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply
* Re: [PATCH v5 5/8] Bluetooth: Fix L2CAP command reject reason
From: Marcel Holtmann @ 2013-09-16 14:11 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
In-Reply-To: <1379325919-19003-6-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> There are several possible reason codes that can be sent in the command
> reject L2CAP packet. Before this patch the code has used a hard-coded
> single response code ("command not understood"). This patch adds a
> helper function to map the return value of an L2CAP handler function to
> the correct command reject reason.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/l2cap_core.c | 20 ++++++++++++++++----
> 1 file changed, 16 insertions(+), 4 deletions(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply
* Re: [PATCH v5 4/8] Bluetooth: Fix L2CAP Disconnect response for unknown CID
From: Marcel Holtmann @ 2013-09-16 14:10 UTC (permalink / raw)
To: johan.hedberg; +Cc: linux-bluetooth
In-Reply-To: <1379325919-19003-5-git-send-email-johan.hedberg@gmail.com>
Hi Johan,
> If we receive an L2CAP Disconnect Request for an unknown CID we should
> not just silently drop it but reply with a proper Command Reject
> response. This patch fixes this by ensuring that the disconnect handler
> returns a proper error instead of 0 and will cause the function caller
> to send the right response.
>
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/l2cap_core.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Regards
Marcel
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox