diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2005-07-07 16:50:07 +0000 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2005-07-07 16:50:07 +0000 |
commit | 20f65cf4e0ab67ac3e528d84a877a5fe6161904a (patch) | |
tree | 65def04cf7021baf8b72013dcfb320ed9fa79cef /hcid/security.c | |
parent | e2a54220b404119a2516a3cac5edc5b2bcf6089a (diff) |
Send D-Bus messages for inquiry results and remote name resolves
Diffstat (limited to 'hcid/security.c')
-rw-r--r-- | hcid/security.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/hcid/security.c b/hcid/security.c index 04f5b9b8..148c3237 100644 --- a/hcid/security.c +++ b/hcid/security.c @@ -471,6 +471,8 @@ static void remote_name_information(int dev, bdaddr_t *sba, void *ptr) if (evt->status) return; + hcid_dbus_remote_name(sba, dba, (char *) evt->name); + write_device_name(sba, dba, (char *) evt->name); } @@ -489,6 +491,47 @@ static void remote_version_information(int dev, bdaddr_t *sba, void *ptr) evt->lmp_ver, btohs(evt->lmp_subver)); } +static void inquiry_result(int dev, bdaddr_t *sba, int plen, void *ptr) +{ + uint8_t num = *(uint8_t *)ptr++; + int i; + + for (i = 0; i < num; i++) { + inquiry_info *info = ptr; + + hcid_dbus_inquiry_result(sba, &info->bdaddr); + + ptr += INQUIRY_INFO_SIZE; + } +} + +static void inquiry_result_with_rssi(int dev, bdaddr_t *sba, int plen, void *ptr) +{ + uint8_t num = *(uint8_t *)ptr++; + int i; + + if (!num) + return; + + if ((plen - 1) / num == INQUIRY_INFO_WITH_RSSI_AND_PSCAN_MODE_SIZE) { + for (i = 0; i < num; i++) { + inquiry_info_with_rssi_and_pscan_mode *info = ptr; + + hcid_dbus_inquiry_result(sba, &info->bdaddr); + + ptr += INQUIRY_INFO_WITH_RSSI_AND_PSCAN_MODE_SIZE; + } + } else { + for (i = 0; i < num; i++) { + inquiry_info_with_rssi *info = ptr; + + hcid_dbus_inquiry_result(sba, &info->bdaddr); + + ptr += INQUIRY_INFO_WITH_RSSI_SIZE; + } + } +} + static void remote_features_information(int dev, bdaddr_t *sba, void *ptr) { evt_read_remote_features_complete *evt = ptr; @@ -553,6 +596,14 @@ static gboolean io_security_event(GIOChannel *chan, GIOCondition cond, gpointer case EVT_READ_REMOTE_FEATURES_COMPLETE: remote_features_information(dev, &di->bdaddr, ptr); break; + + case EVT_INQUIRY_RESULT: + inquiry_result(dev, &di->bdaddr, eh->plen, ptr); + break; + + case EVT_INQUIRY_RESULT_WITH_RSSI: + inquiry_result_with_rssi(dev, &di->bdaddr, eh->plen, ptr); + break; } if (hci_test_bit(HCI_SECMGR, &di->flags)) @@ -608,6 +659,8 @@ void start_security_manager(int hdev) hci_filter_set_event(EVT_REMOTE_NAME_REQ_COMPLETE, &flt); hci_filter_set_event(EVT_READ_REMOTE_VERSION_COMPLETE, &flt); hci_filter_set_event(EVT_READ_REMOTE_FEATURES_COMPLETE, &flt); + hci_filter_set_event(EVT_INQUIRY_RESULT, &flt); + hci_filter_set_event(EVT_INQUIRY_RESULT_WITH_RSSI, &flt); if (setsockopt(dev, SOL_HCI, HCI_FILTER, &flt, sizeof(flt)) < 0) { syslog(LOG_ERR, "Can't set filter on hci%d: %s (%d)", hdev, strerror(errno), errno); |