summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaudio Takahasi <claudio.takahasi@openbossa.org>2008-03-20 20:10:49 +0000
committerClaudio Takahasi <claudio.takahasi@openbossa.org>2008-03-20 20:10:49 +0000
commitd504a0767e08b04f2af78c10db79d8e35f0c3e92 (patch)
treef184a4a0ecb024ed2758f7f21bec72e9ca44b448
parent1f84f3545e276c9086a865e18ded06eb50c2f41e (diff)
Add records based on the adapter address
-rw-r--r--daemon/database.c2
-rw-r--r--hcid/adapter.c6
-rw-r--r--hcid/dbus-common.c4
-rw-r--r--hcid/dbus-common.h2
-rw-r--r--hcid/dbus-database.c18
-rw-r--r--hcid/dbus-database.h2
-rw-r--r--sdpd/sdpd.h2
-rw-r--r--sdpd/service.c4
8 files changed, 21 insertions, 19 deletions
diff --git a/daemon/database.c b/daemon/database.c
index e72af209..23c9381c 100644
--- a/daemon/database.c
+++ b/daemon/database.c
@@ -132,7 +132,7 @@ static DBusHandlerResult add_service_record_from_xml(DBusConnection *conn,
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
}
- if (add_record_to_server(sdp_record) < 0) {
+ if (add_record_to_server(BDADDR_ANY, sdp_record) < 0) {
error("Failed to register service record");
free(user_record);
sdp_record_free(sdp_record);
diff --git a/hcid/adapter.c b/hcid/adapter.c
index 62b17334..fc1608d5 100644
--- a/hcid/adapter.c
+++ b/hcid/adapter.c
@@ -3882,9 +3882,11 @@ static DBusHandlerResult unregister_agent(DBusConnection *conn,
static DBusHandlerResult add_service_record(DBusConnection *conn,
DBusMessage *msg, void *data)
{
+ struct adapter *adapter = data;
DBusMessage *reply;
const char *sender, *record;
dbus_uint32_t handle;
+ bdaddr_t src;
int err;
if (dbus_message_get_args(msg, NULL,
@@ -3892,8 +3894,8 @@ static DBusHandlerResult add_service_record(DBusConnection *conn,
return error_invalid_arguments(conn, msg, NULL);
sender = dbus_message_get_sender(msg);
-
- err = add_xml_record(conn, sender, record, &handle);
+ str2ba(adapter->address, &src);
+ err = add_xml_record(conn, sender, &src, record, &handle);
if (err < 0)
return error_failed_errno(conn, msg, err);
diff --git a/hcid/dbus-common.c b/hcid/dbus-common.c
index 6c1601fb..38e11665 100644
--- a/hcid/dbus-common.c
+++ b/hcid/dbus-common.c
@@ -398,14 +398,14 @@ int register_sdp_binary(uint8_t *data, uint32_t size, uint32_t *handle)
return err;
}
-int register_sdp_record(sdp_record_t *rec)
+int register_sdp_record(bdaddr_t *src, sdp_record_t *rec)
{
int err;
if (!get_sdp_session())
return -1;
- err = sdp_device_record_register(sess, BDADDR_ANY, rec, 0);
+ err = sdp_device_record_register(sess, src, rec, 0);
if (err < 0)
cleanup_sdp_session();
diff --git a/hcid/dbus-common.h b/hcid/dbus-common.h
index 61782dfe..baccfb59 100644
--- a/hcid/dbus-common.h
+++ b/hcid/dbus-common.h
@@ -52,7 +52,7 @@ void hcid_dbus_exit(void);
int hcid_dbus_init(void);
int register_sdp_binary(uint8_t *data, uint32_t size, uint32_t *handle);
-int register_sdp_record(sdp_record_t *rec);
+int register_sdp_record(bdaddr_t *src, sdp_record_t *rec);
int unregister_sdp_record(uint32_t handle);
int update_sdp_record(uint32_t handle, sdp_record_t *rec);
void cleanup_sdp_session(void);
diff --git a/hcid/dbus-database.c b/hcid/dbus-database.c
index a2330940..e6e1de06 100644
--- a/hcid/dbus-database.c
+++ b/hcid/dbus-database.c
@@ -129,7 +129,7 @@ static DBusHandlerResult add_service_record(DBusConnection *conn,
return error_failed_errno(conn, msg, EIO);
}
- if (add_record_to_server(sdp_record) < 0) {
+ if (add_record_to_server(BDADDR_ANY, sdp_record) < 0) {
error("Failed to register service record");
g_free(user_record);
sdp_record_free(sdp_record);
@@ -166,7 +166,7 @@ static DBusHandlerResult add_service_record(DBusConnection *conn,
return send_message_and_unref(conn, reply);
}
-int add_xml_record(DBusConnection *conn, const char *sender,
+int add_xml_record(DBusConnection *conn, const char *sender, bdaddr_t *src,
const char *record, dbus_uint32_t *handle)
{
struct record_data *user_record;
@@ -182,7 +182,7 @@ int add_xml_record(DBusConnection *conn, const char *sender,
}
if (sdp_server_enable) {
- if (add_record_to_server(sdp_record) < 0) {
+ if (add_record_to_server(src, sdp_record) < 0) {
error("Failed to register service record");
g_free(user_record);
sdp_record_free(sdp_record);
@@ -191,7 +191,7 @@ int add_xml_record(DBusConnection *conn, const char *sender,
user_record->handle = sdp_record->handle;
} else {
- if (register_sdp_record(sdp_record) < 0) {
+ if (register_sdp_record(src, sdp_record) < 0) {
error("Failed to register service record");
g_free(user_record);
sdp_record_free(sdp_record);
@@ -232,7 +232,7 @@ static DBusHandlerResult add_service_record_from_xml(DBusConnection *conn,
if (!reply)
return DBUS_HANDLER_RESULT_NEED_MEMORY;
- err = add_xml_record(conn, sender, record, &handle);
+ err = add_xml_record(conn, sender, BDADDR_ANY, record, &handle);
if (err < 0)
return error_failed_errno(conn, msg, err);
@@ -243,7 +243,7 @@ static DBusHandlerResult add_service_record_from_xml(DBusConnection *conn,
}
static DBusHandlerResult update_record(DBusConnection *conn, DBusMessage *msg,
- dbus_uint32_t handle, sdp_record_t *sdp_record)
+ bdaddr_t *src, dbus_uint32_t handle, sdp_record_t *sdp_record)
{
int err;
@@ -254,7 +254,7 @@ static DBusHandlerResult update_record(DBusConnection *conn, DBusMessage *msg,
}
sdp_record->handle = handle;
- err = add_record_to_server(sdp_record);
+ err = add_record_to_server(src, sdp_record);
if (err < 0) {
sdp_record_free(sdp_record);
error("Failed to update the service record");
@@ -311,7 +311,7 @@ static DBusHandlerResult update_service_record(DBusConnection *conn,
return error_invalid_arguments(conn, msg, NULL);
}
- return update_record(conn, msg, handle, sdp_record);
+ return update_record(conn, msg, BDADDR_ANY, handle, sdp_record);
}
DBusHandlerResult update_xml_record(DBusConnection *conn,
@@ -344,7 +344,7 @@ DBusHandlerResult update_xml_record(DBusConnection *conn,
return error_failed_errno(conn, msg, EIO);
}
- return update_record(conn, msg, handle, sdp_record);
+ return update_record(conn, msg, src, handle, sdp_record);
}
static DBusHandlerResult update_service_record_from_xml(DBusConnection *conn,
diff --git a/hcid/dbus-database.h b/hcid/dbus-database.h
index 9ca7ce6c..c5450c8c 100644
--- a/hcid/dbus-database.h
+++ b/hcid/dbus-database.h
@@ -29,7 +29,7 @@ dbus_bool_t database_init(DBusConnection *conn, const char *path);
DBusHandlerResult database_message(DBusConnection *conn,
DBusMessage *msg, void *data);
-int add_xml_record(DBusConnection *conn, const char *sender,
+int add_xml_record(DBusConnection *conn, const char *sender, bdaddr_t *src,
const char *record, dbus_uint32_t *handle);
DBusHandlerResult update_xml_record(DBusConnection *conn,
DBusMessage *msg, bdaddr_t *src);
diff --git a/sdpd/sdpd.h b/sdpd/sdpd.h
index ae1245d8..30f05df4 100644
--- a/sdpd/sdpd.h
+++ b/sdpd/sdpd.h
@@ -84,7 +84,7 @@ uint32_t sdp_get_time();
int start_sdp_server(uint16_t mtu, const char *did, uint32_t flags);
void stop_sdp_server(void);
-int add_record_to_server(sdp_record_t *rec);
+int add_record_to_server(bdaddr_t *src, sdp_record_t *rec);
int remove_record_from_server(uint32_t handle);
typedef void (*service_classes_callback_t) (const bdaddr_t *bdaddr, uint8_t value);
diff --git a/sdpd/service.c b/sdpd/service.c
index e156cdc4..57a272db 100644
--- a/sdpd/service.c
+++ b/sdpd/service.c
@@ -359,7 +359,7 @@ void register_device_id(const uint16_t vendor, const uint16_t product,
update_svclass_list();
}
-int add_record_to_server(sdp_record_t *rec)
+int add_record_to_server(bdaddr_t *src, sdp_record_t *rec)
{
sdp_data_t *data;
@@ -374,7 +374,7 @@ int add_record_to_server(sdp_record_t *rec)
debug("Adding record with handle 0x%05x", rec->handle);
- sdp_record_add(BDADDR_ANY, rec);
+ sdp_record_add(src, rec);
data = sdp_data_alloc(SDP_UINT32, &rec->handle);
sdp_attr_replace(rec, SDP_ATTR_RECORD_HANDLE, data);