diff --git a/src/adapter.c b/src/adapter.c
index 0231a08..4aa2243 100644
--- a/src/adapter.c
+++ b/src/adapter.c
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)
+{
+ 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);
+
+ memset(&cp, 0, sizeof(cp));
+
+ cp.source = htobs(source);
+ cp.vendor = htobs(vendor);
+ cp.product = htobs(product);
+ cp.version = htobs(version);
+
+ if (mgmt_send(adapter->mgmt, MGMT_OP_SET_DEVICE_ID,
+ adapter->dev_id, sizeof(cp), &cp,
+ NULL, NULL, NULL) > 0)
+ return 0;
+
+ return -EIO;
+}
+
static int adapter_register(struct btd_adapter *adapter)
{
struct agent *agent;
default_adapter_id = adapter->dev_id;
if (main_opts.did_source)
- mgmt_set_did(adapter->dev_id, main_opts.did_vendor,
- main_opts.did_product,
- main_opts.did_version,
- main_opts.did_source);
+ 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);
diff --git a/src/mgmt.c b/src/mgmt.c
index 685d376..5d2197a 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
}
}
-int mgmt_set_did(int index, uint16_t vendor, uint16_t product,
- uint16_t version, uint16_t source)
-{
- char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_set_device_id)];
- struct mgmt_hdr *hdr = (void *) buf;
- struct mgmt_cp_set_device_id *cp = (void *) &buf[sizeof(*hdr)];
-
- DBG("index %d source %x vendor %x product %x version %x",
- index, source, vendor, product, version);
-
- memset(buf, 0, sizeof(buf));
- hdr->opcode = htobs(MGMT_OP_SET_DEVICE_ID);
- hdr->len = htobs(sizeof(*cp));
- hdr->index = htobs(index);
-
- cp->source = htobs(source);
- cp->vendor = htobs(vendor);
- cp->product = htobs(product);
- cp->version = htobs(version);
-
- if (write(mgmt_sock, buf, sizeof(buf)) < 0)
- return -errno;
-
- return 0;
-}
-
int mgmt_load_link_keys(int index, GSList *keys, gboolean debug_keys)
{
char *buf;
diff --git a/src/mgmt.h b/src/mgmt.h
index 24f7e1d..5c0755c 100644
--- a/src/mgmt.h
+++ b/src/mgmt.h
int mgmt_setup(void);
void mgmt_cleanup(void);
-int mgmt_set_did(int index, uint16_t vendor, uint16_t product,
- uint16_t version, uint16_t source);
-
int mgmt_load_link_keys(int index, GSList *keys, gboolean debug_keys);
int mgmt_load_ltks(int index, GSList *keys);