char *str;
gsize length = 0;
gboolean discoverable;
-#ifdef __TIZEN_PATCH__
- char key_str[35];
- static const char testblock[MGMT_IRK_SIZE];
- int i;
-#endif
key_file = g_key_file_new();
g_key_file_set_string(key_file, "General", "Alias",
adapter->stored_alias);
#ifdef __TIZEN_PATCH__
- if (memcmp(adapter->local_irk, testblock , MGMT_IRK_SIZE)) {
- key_str[0] = '0';
- key_str[1] = 'x';
- for (i = 0; i < MGMT_IRK_SIZE; i++)
- sprintf(key_str + 2 + (i * 2), "%2.2X",
- adapter->local_irk[i]);
- g_key_file_set_string(key_file, "General",
- "LocalIrk", key_str);
+ if (adapter->local_irk) {
+ int i;
+ char key_str[35];
+ char *ptr = key_str;
+
+ ptr[0] = '0';
+ ptr[1] = 'x';
+ ptr += 2;
+ for (i = 0; i < MGMT_IRK_SIZE; i++, ptr += 2)
+ snprintf(ptr, 3, "%2.2X", adapter->local_irk[i]);
+
+ g_key_file_set_string(key_file, "General", "LocalIrk", key_str);
}
#endif
struct device_addr_type addr;
struct btd_device *device;
GSList *list;
+#ifdef __TIZEN_PATCH__
+ bool exact_match = false;
+#endif
+ char addr_str[18];
if (!adapter)
return NULL;
bacpy(&addr.bdaddr, dst);
addr.bdaddr_type = bdaddr_type;
- list = g_slist_find_custom(adapter->devices, &addr,
- device_addr_type_cmp);
+ ba2str(dst, addr_str);
+ DBG("find device %s %d", addr_str, bdaddr_type);
-/* Find the device based on RPA */
#ifdef __TIZEN_PATCH__
- if (!list) {
- uint8_t msb = 0x00;
- char address[18];
-
- ba2str(&addr.bdaddr, address);
-
- msb = addr.bdaddr.b[5] >> 6;
-
- /* Check whether address is RPA */
- if (msb == 0x00 || msb == 0x01) {
- list = g_slist_find_custom(adapter->devices,
- address, (GCompareFunc) device_rpa_cmp);
- }
- } else {
+ list = g_slist_find_custom(adapter->devices, &addr,
+ device_addr_type_strict_cmp);
+ if (list) {
device = list->data;
-
- if (device_get_rpa_exist(device) == true) {
- GSList *rpa_list;
-
- rpa_list = g_slist_find_custom(adapter->devices,
- device_get_address(device),
- device_addr_cmp);
- if (rpa_list) {
- list = rpa_list;
- bdaddr_type = BDADDR_LE_RANDOM;
- }
+ DBG("Exact matched");
+ device_print_addr(device);
+ exact_match = true;
+ } else {
+#endif
+ list = g_slist_find_custom(adapter->devices, &addr,
+ device_addr_type_cmp);
+ if (list) {
+ device = list->data;
+ DBG("Soft matched");
+ device_print_addr(device);
}
}
-#endif
if (!list)
return NULL;
device = list->data;
+#ifdef __TIZEN_PATCH__
+ if (exact_match)
+ return device;
+#endif
+
/*
* If we're looking up based on public address and the address
* was not previously used over this bearer we may need to
remove_record_from_server(rec->handle);
}
+#ifdef __TIZEN_PATCH__
+static void adapter_print_devices(struct btd_adapter *adapter)
+{
+ GSList *dev;
+
+ dev = adapter->devices;
+ for (; dev; dev = dev->next) {
+ device_print_addr(dev->data);
+ }
+}
+#endif
+
static struct btd_device *adapter_create_device(struct btd_adapter *adapter,
const bdaddr_t *bdaddr,
uint8_t bdaddr_type)
adapter->devices = g_slist_append(adapter->devices, device);
+#ifdef __TIZEN_PATCH__
+ adapter_print_devices(adapter);
+#endif
+
return device;
}
DBusMessage *msg, void *data)
{
struct btd_adapter *adapter = data;
- dbus_bool_t err;
dbus_int32_t client_if, action, filt_index;
dbus_int32_t feat_seln, list_logic_type, filt_logic_type;
dbus_int32_t rssi_high_thres, rssi_low_thres, dely_mode;
dbus_int32_t found_timeout, lost_timeout, found_timeout_cnt;
adapter_le_scan_filter_param_t params;
+ gboolean err;
DBG("adapter_le_scan_filter_param_setup");
DBusMessage *msg, void *data)
{
struct btd_adapter *adapter = data;
- struct btd_device *dev;
- bdaddr_t bdaddr;
- dbus_bool_t err;
+ struct btd_device *dev = NULL;
dbus_int32_t client_if, action, filt_type, filt_index;
dbus_int32_t company_id, company_id_mask;
- gchar *string;
+ gchar *address = NULL;
+ dbus_uint32_t address_type = 0;
+ uint8_t addr_type;
+ GSList *list;
char ida_string[18];
- dbus_uint32_t address_type;
uint8_t *p_uuid, *p_uuid_mask, *p_data, *p_mask;
int32_t uuid_len = 0, uuid_mask_len = 0, data_len = 0, mask_len = 0;
+ gboolean err;
DBG("adapter_le_scan_filter_add_remove");
DBUS_TYPE_INT32, &company_id_mask,
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &p_uuid, &uuid_len,
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &p_uuid_mask, &uuid_mask_len,
- DBUS_TYPE_STRING, &string,
+ DBUS_TYPE_STRING, &address,
DBUS_TYPE_UINT32, &address_type,
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &p_data, &data_len,
DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE, &p_mask, &mask_len,
DBUS_TYPE_INVALID))
return btd_error_invalid_args(msg);
- DBG("addr %s, type %d", string, address_type);
-
- str2ba(string, &bdaddr);
-
- dev = btd_adapter_find_device(adapter, &bdaddr, address_type);
+ list = g_slist_find_custom(adapter->devices, address, device_rpa_cmp);
+ if (!list)
+ list = g_slist_find_custom(adapter->devices, address,
+ device_address_cmp);
+ if (list)
+ dev = list->data;
if (dev && device_get_rpa_exist(dev) == true) {
ba2str(device_get_address(dev), ida_string);
if (btd_device_get_bdaddr_type(dev) == BDADDR_LE_PUBLIC)
- address_type = 0x0;
+ addr_type = 0x00;
else
- address_type = 0x1;
+ addr_type = 0x01;
} else {
- memcpy(ida_string, string, sizeof(ida_string));
+ memcpy(ida_string, address, sizeof(ida_string));
+ addr_type = 0x00;
}
+ DBG("addr %s, type %d", ida_string, addr_type);
+
err = adapter_le_set_scan_filter_data(client_if, action, filt_type,
filt_index, company_id, company_id_mask,
uuid_len, p_uuid, uuid_mask_len, p_uuid_mask,
- ida_string, address_type, data_len, p_data, mask_len, p_mask);
+ ida_string, addr_type, data_len, p_data, mask_len, p_mask);
if (!err)
return btd_error_failed(msg, "Failed to add/remove filter");
DBusMessage *msg, void *data)
{
struct btd_adapter *adapter = data;
- dbus_bool_t err;
- dbus_int32_t client_if;
- dbus_int32_t filt_index;
+ dbus_int32_t client_if = 0;
+ dbus_int32_t filt_index = 0;
+ gboolean err;
DBG("adapter_le_scan_filter_clear");
DBusMessage *msg, void *data)
{
struct btd_adapter *adapter = data;
- dbus_bool_t err;
dbus_bool_t enable = FALSE;
- dbus_int32_t client_if;
+ dbus_int32_t client_if = 0;
+ gboolean err;
DBG("adapter_le_scan_filter_enable");
const gchar *address;
bdaddr_t bdaddr;
dbus_uint32_t address_type;
+ uint8_t addr_type;
struct btd_device *dev;
DBG("Add device whie list");
if (!(adapter->current_settings & MGMT_SETTING_POWERED))
return btd_error_not_ready(msg);
+ if (address_type == 0)
+ addr_type = BDADDR_LE_PUBLIC;
+ else
+ addr_type = BDADDR_LE_RANDOM;
- DBG("addr %s, type %d", address, address_type);
+ DBG("addr %s, type %d", address, addr_type);
str2ba(address, &bdaddr);
- dev = btd_adapter_find_device(adapter, &bdaddr, address_type);
+ dev = btd_adapter_find_device(adapter, &bdaddr, addr_type);
if (dev && device_get_rpa_exist(dev) == true) {
if (adapter_le_is_supported_offloading() == FALSE) {
error("Spec based command is not supported yet");
/* Add IRK value to list */
if (adapter_le_add_irk_to_list(device_get_irk_value(dev),
- device_get_address(dev),
- btd_device_get_bdaddr_type(dev))) {
+ device_get_address(dev),
+ btd_device_get_bdaddr_type(dev))) {
return dbus_message_new_method_return(msg);
} else {
return btd_error_failed(msg, "Add LE IRK to list failed");
memset(&cp, 0, sizeof(cp));
- cp.bdaddr_type = address_type;
+ cp.bdaddr_type = addr_type;
memcpy(&cp.bdaddr, &bdaddr, sizeof(bdaddr_t));
if (mgmt_send(adapter->mgmt, MGMT_OP_ADD_DEV_WHITE_LIST,
const gchar *address;
bdaddr_t bdaddr;
dbus_uint32_t address_type;
+ uint8_t addr_type;
struct btd_device *dev;
DBG("Remove device whie list");
if (check_address(address) < 0)
return btd_error_invalid_args(msg);
- DBG("addr %s, type %d", address, address_type);
+ if (address_type == 0)
+ addr_type = BDADDR_LE_PUBLIC;
+ else
+ addr_type = BDADDR_LE_RANDOM;
+
+ DBG("addr %s, type %d", address, addr_type);
str2ba(address, &bdaddr);
- dev = btd_adapter_find_device(adapter, &bdaddr, address_type);
+ dev = btd_adapter_find_device(adapter, &bdaddr, addr_type);
if (dev && device_get_rpa_exist(dev) == true) {
if (adapter_le_is_supported_offloading() == FALSE) {
error("Spec based command is not supported yet");
/* Remove IRK value to list */
if (adapter_le_remove_irk_to_list(device_get_address(dev),
- btd_device_get_bdaddr_type(dev))) {
+ btd_device_get_bdaddr_type(dev))) {
return dbus_message_new_method_return(msg);
} else {
- return btd_error_failed(msg, "Remove LE IRK to list failed");
+ return btd_error_failed(msg, "Remove IRK is failed");
}
}
memset(&cp, 0, sizeof(cp));
- cp.bdaddr_type = address_type;
+ cp.bdaddr_type = addr_type;
memcpy(&cp.bdaddr, &bdaddr, sizeof(bdaddr_t));
if (mgmt_send(adapter->mgmt, MGMT_OP_REMOVE_DEV_FROM_WHITE_LIST,
const gchar *address;
GSList *l;
const gchar *dev_path;
- bdaddr_t rpa;
- uint8_t msb = 0x00;
if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &address,
- DBUS_TYPE_INVALID))
- return btd_error_invalid_args(msg);
-
- str2ba(address, &rpa);
-
- l = g_slist_find_custom(adapter->devices,
- address, (GCompareFunc) device_address_cmp);
-
- if (!l) {
- msb = rpa.b[5] >> 6;
-
- /* Check whether address is RPA */
- if (msb == 0x00 || msb == 0x01)
- l = g_slist_find_custom(adapter->devices,
- address, (GCompareFunc) device_rpa_cmp);
- }
+ DBUS_TYPE_INVALID))
+ return btd_error_invalid_args(msg);
+ l = g_slist_find_custom(adapter->devices, address, device_rpa_cmp);
+ if (!l)
+ l = g_slist_find_custom(adapter->devices, address,
+ device_address_cmp);
if (!l)
return btd_error_does_not_exist(msg);
reply = dbus_message_new_method_return(msg);
if (!reply)
- return NULL;
+ return NULL;
dev_path = device_get_path(device);
dbus_message_append_args(reply,
- DBUS_TYPE_OBJECT_PATH, &dev_path,
- DBUS_TYPE_INVALID);
+ DBUS_TYPE_OBJECT_PATH, &dev_path,
+ DBUS_TYPE_INVALID);
return reply;
}
return addr_type;
}
+#ifdef __TIZEN_PATCH__
+static uint8_t get_addr_type(GKeyFile *keyfile)
+{
+ char **techno, **t;
+ char *str;
+ uint8_t bdaddr_type = BDADDR_BREDR;
+ bool le = false;
+
+ /* Load device technology */
+ techno = g_key_file_get_string_list(keyfile, "General",
+ "SupportedTechnologies", NULL, NULL);
+ if (!techno)
+ return BDADDR_BREDR;
+
+ for (t = techno; *t; t++) {
+ if (g_str_equal(*t, "LE"))
+ le = true;
+ }
+
+ if (!le) {
+ bdaddr_type = BDADDR_BREDR;
+ } else {
+ str = g_key_file_get_string(keyfile, "General",
+ "AddressType", NULL);
+
+ if (str && g_str_equal(str, "public"))
+ bdaddr_type = BDADDR_LE_PUBLIC;
+ else if (str && g_str_equal(str, "static"))
+ bdaddr_type = BDADDR_LE_RANDOM;
+ else
+ error("Unknown LE device technology");
+
+ g_free(str);
+ }
+
+ g_strfreev(techno);
+
+ return bdaddr_type;
+}
+#endif
+
static void probe_devices(void *user_data)
{
struct btd_device *device = user_data;
#ifdef __TIZEN_PATCH__
struct link_key_info *key_info = NULL;
GSList *list, *ltk_info = NULL;
+ struct device_addr_type addr;
#else
struct link_key_info *key_info;
GSList *list, *ltk_info;
if (param)
params = g_slist_append(params, param);
+#ifdef __TIZEN_PATCH__
+ str2ba(entry->d_name, &addr.bdaddr);
+ addr.bdaddr_type = get_addr_type(key_file);
+
+ list = g_slist_find_custom(adapter->devices, &addr,
+ device_addr_type_strict_cmp);
+#else
list = g_slist_find_custom(adapter->devices, entry->d_name,
device_address_cmp);
+#endif
if (list) {
+#ifdef __TIZEN_PATCH__
+ DBG("Skip already loaded device [%s] [%d]",
+ entry->d_name, addr.bdaddr_type);
+#endif
device = list->data;
goto device_exist;
}
-#ifdef __TIZEN_PATCH__
-{
- char **techno;
-
- techno = g_key_file_get_string_list(key_file, "General",
- "SupportedTechnologies", NULL, NULL);
-
- /* KITT: Encryption fail with MIC Failure error
- Problem happend when two LTK is stored on both RPA and IDA address folder
- Here, if IDA dev info is loaded before RPA info, both RPA dev and IDA dev
- are created and problem happend.(If RPA info is loaded first, IDA is not
- loaded. (upper device_exist case))
- Fix: skip a loadding info in case of 'no technologies' */
-
- if (!techno) {
- DBG("No SupportedTechnologies. Skipping");
- goto free;
- }
-
- g_strfreev(techno);
-}
-#endif
-
device = device_create_from_storage(adapter, entry->d_name,
key_file);
if (!device)
#ifdef __TIZEN_PATCH__
{
- char irk_addr[18];
+ char idaddr[18];
- /* After load IRK information from file, store it into device->bdaddr
- RPA is stored in device->rpa_addr */
- ba2str(device_get_address(device), irk_addr);
+ /*
+ * After loading IRK information from file,
+ * store it into device->bdaddr.
+ * RPA is stored in device->rpa_addr
+ */
+ ba2str(device_get_address(device), idaddr);
- DBG("irk address: %s, rpa_exist %d", irk_addr, device_get_rpa_exist(device));
+ DBG("irk address: %s, rpa_exist %d",
+ idaddr, device_get_rpa_exist(device));
if (device_get_rpa_exist(device) == true) {
if (key_info)
- str2ba(irk_addr, &key_info->bdaddr);
+ str2ba(idaddr, &key_info->bdaddr);
if (ltk_info) {
ltks = g_slist_remove(ltks, ltk_info);
- ltk_info = get_ltk_info(key_file, irk_addr, bdaddr_type);
+ ltk_info = get_ltk_info(key_file,
+ idaddr, bdaddr_type);
ltks = g_slist_concat(ltks, ltk_info);
}
if (irk_info) {
- str2ba(irk_addr, &irk_info->bdaddr);
+ str2ba(idaddr, &irk_info->bdaddr);
device_set_irk_value(device, irk_info->val);
}
if (param)
- str2ba(irk_addr, ¶m->bdaddr);
+ str2ba(idaddr, ¶m->bdaddr);
}
}
#endif
{
struct btd_device *device;
char dst[18];
+#ifdef __TIZEN_PATCH__
+ struct device_addr_type t_addr;
+#endif
ba2str(&addr->bdaddr, dst);
#ifdef __TIZEN_PATCH__
if (device) {
+ device_get_tizen_addr(device, &t_addr);
device_set_disconnect_reason(device, reason);
- adapter_remove_connection(adapter, device, addr->type);
+ adapter_remove_connection(adapter, device, t_addr.bdaddr_type);
disconnect_notify(device, reason);
- if (device_is_bonded(device, addr->type)) {
- DBG("addr type %d, bonded", addr->type);
+ if (device_is_bonded(device, t_addr.bdaddr_type)) {
+ DBG("addr type %d, bonded", t_addr.bdaddr_type);
return;
}
+
+ bonding_attempt_complete(adapter, &t_addr.bdaddr,
+ t_addr.bdaddr_type, MGMT_STATUS_DISCONNECTED);
+ return;
}
#else
if (device) {
ba2str(btd_adapter_get_address(adapter), adapter_addr);
ba2str(device_get_address(device), device_addr);
-#ifdef __TIZEN_PATCH__
- if (device_get_rpa_exist(device) == true)
- ba2str(device_get_rpa(device), device_addr);
-#endif
-
snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/info", adapter_addr,
device_addr);
key_file = g_key_file_new();
g_key_file_free(key_file);
}
-#ifdef __TIZEN_PATCH__
-static struct link_key_info *load_link_key(struct btd_adapter *adapter,
- const char *peer)
-{
- struct link_key_info *key_info;
- GKeyFile *key_file;
- char filename[PATH_MAX];
- char srcaddr[18];
-
- ba2str(&adapter->bdaddr, srcaddr);
-
- snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/info", srcaddr, peer);
-
- key_file = g_key_file_new();
- g_key_file_load_from_file(key_file, filename, 0, NULL);
-
- key_info = get_key_info(key_file, peer);
-
- return key_info;
-}
-#endif
-
static void new_link_key_callback(uint16_t index, uint16_t length,
const void *param, void *user_data)
{
}
#endif
- /* If BR/EDR linkkey exists in previous, update the linkkey into RPA based folder info */
-#ifdef __TIZEN_PATCH__
- if (device_get_rpa_exist(device) == true) {
- struct link_key_info *key_info;
-
- key_info = load_link_key(adapter, dst);
- if (key_info && key_info->type == 0x05) {
- DBG("Replace linkkey!");
-
- /* #define HCI_LK_AUTH_COMBINATION_P192 0x05
- Replace the linkkey as the orginal one
- */
- store_link_key(adapter, device, key_info->key,
- key_info->type, key_info->pin_len);
-
- /* Delete irk based folder */
- device_remove_stored_folder(device);
- } else {
- DBG("There is no original linkkey or type is not 0x05");
- }
- }
-#endif
-
bonding_complete(adapter, &addr->bdaddr, addr->type, 0);
}
struct btd_device *device;
bool persistent;
char dst[18];
+#ifdef __TIZEN_PATCH__
+ struct device_addr_type t_addr;
+#endif
if (length < sizeof(*ev)) {
btd_error(adapter->dev_id, "Too small long term key event");
rand = le64_to_cpu(key->rand);
#ifdef __TIZEN_PATCH__
- if (device_get_rpa_exist(device) == true) {
- store_longtermkey(bdaddr, device_get_rpa(device),
- key->addr.type, key->val, key->master,
- key->type, key->enc_size, ediv, rand);
- } else {
- store_longtermkey(bdaddr, &key->addr.bdaddr,
- key->addr.type, key->val, key->master,
- key->type, key->enc_size, ediv, rand);
- }
+ device_get_tizen_addr(device, &t_addr);
+ store_longtermkey(bdaddr, &t_addr.bdaddr, t_addr.bdaddr_type,
+ key->val, key->master, key->type,
+ key->enc_size, ediv, rand);
#else
store_longtermkey(bdaddr, &key->addr.bdaddr,
key->addr.type, key->val, key->master,
const bdaddr_t *bdaddr = btd_adapter_get_address(adapter);
struct btd_device *device;
char dst[18];
+#ifdef __TIZEN_PATCH__
+ struct device_addr_type t_addr;
+#endif
if (length < sizeof(*ev)) {
btd_error(adapter->dev_id, "Too small CSRK event");
if (!ev->store_hint)
return;
+#ifdef __TIZEN_PATCH__
+ device_get_tizen_addr(device, &t_addr);
+ store_csrk(bdaddr, &t_addr.bdaddr, t_addr.bdaddr_type, key->val, 0,
+ key->type);
+#else
store_csrk(bdaddr, &key->addr.bdaddr, key->addr.type, key->val, 0,
key->type);
+#endif
btd_device_set_temporary(device, false);
}
struct btd_device *device, *duplicate;
bool persistent;
char dst[18], rpa[18];
+#ifdef __TIZEN_PATCH__
+ struct device_addr_type t_addr;
+#endif
if (length < sizeof(*ev)) {
btd_error(adapter->dev_id, "Too small New IRK event");
DBG("hci%u new IRK for %s RPA %s", adapter->dev_id, dst, rpa);
if (bacmp(&ev->rpa, BDADDR_ANY)) {
-#ifdef __TIZEN_PATCH__
- /*
- * With new RPA, existing device can be found only when bonding is
- * initiated from local side using remote RPA; so first find the device
- * with RPA. If device is not found then find the device with IDA.
- */
-
- device = btd_adapter_find_device(adapter, &ev->rpa,
- BDADDR_LE_RANDOM);
- if (device == NULL)
- device = btd_adapter_find_device(adapter, &addr->bdaddr,
- addr->type);
- if (device == NULL)
- device = btd_adapter_get_device(adapter, &ev->rpa,
- BDADDR_LE_RANDOM);
-#else
-
device = btd_adapter_get_device(adapter, &ev->rpa,
BDADDR_LE_RANDOM);
-#endif
-
+#ifndef __TIZEN_PATCH__
duplicate = btd_adapter_find_device(adapter, &addr->bdaddr,
addr->type);
if (duplicate == device)
duplicate = NULL;
+#else
+ device_set_rpa(device, &ev->rpa);
+ duplicate = NULL;
+#endif
} else {
device = btd_adapter_get_device(adapter, &addr->bdaddr,
addr->type);
return;
}
-#ifdef __TIZEN_PATCH__
- if (bacmp(&ev->rpa, BDADDR_ANY) != 0) {
- device_set_rpa(device, &ev->rpa);
-
- if (duplicate)
- device_set_rpa(duplicate, &ev->rpa);
- }
-#endif
-
device_update_addr(device, &addr->bdaddr, addr->type);
-#ifdef __TIZEN_PATCH__
- if (duplicate) {
- device_merge_duplicate(device, duplicate);
- device_set_irk_value(duplicate, irk->val);
-
- /* If BR/EDR linkkey exists in previous, update the linkkey into RPA based folder info */
- if (device_get_rpa_exist(device) == true) {
- struct link_key_info *key_info;
-
- key_info = load_link_key(adapter, dst);
- if (key_info && key_info->type == 0x05) {
- DBG("Add linkkey of BR/EDR");
-
- /* #define HCI_LK_AUTH_COMBINATION_P192 0x05 */
- store_link_key(adapter, device, key_info->key,
- key_info->type, key_info->pin_len);
-
- /* Delete IDA based folder */
- device_remove_stored_folder(duplicate);
- } else {
- DBG("There is no original linkkey or type is not 0x05");
- }
- }
- }
-#else
if (duplicate)
device_merge_duplicate(device, duplicate);
+
+#ifdef __TIZEN_PATCH__
+ device_set_irk_value(device, irk->val);
#endif
persistent = !!ev->store_hint;
return;
#ifdef __TIZEN_PATCH__
- if (bacmp(&ev->rpa, BDADDR_ANY) != 0)
- store_irk(adapter, device_get_rpa(device), addr->type, irk->val);
- else
- store_irk(adapter, &addr->bdaddr, addr->type, irk->val);
-
- device_set_irk_value(device, irk->val);
+ device_get_tizen_addr(device, &t_addr);
+ store_irk(adapter, &t_addr.bdaddr, t_addr.bdaddr_type, irk->val);
#else
store_irk(adapter, &addr->bdaddr, addr->type, irk->val);
#endif
uint16_t min, max, latency, timeout;
struct btd_device *dev;
char dst[18];
-
+#ifdef __TIZEN_PATCH__
+ struct device_addr_type t_addr;
+#endif
if (length < sizeof(*ev)) {
btd_error(adapter->dev_id,
if (!ev->store_hint)
return;
+#ifdef __TIZEN_PATCH__
+ device_get_tizen_addr(dev, &t_addr);
+ store_conn_param(adapter, &t_addr.bdaddr, t_addr.bdaddr_type,
+ ev->min_interval, ev->max_interval,
+ ev->latency, ev->timeout);
+#else
store_conn_param(adapter, &ev->addr.bdaddr, ev->addr.type,
ev->min_interval, ev->max_interval,
ev->latency, ev->timeout);
+#endif
}
int adapter_set_io_capability(struct btd_adapter *adapter, uint8_t io_cap)
load_devices(adapter);
#ifdef __TIZEN_PATCH__
+ adapter_print_devices(adapter);
+
if (adapter->le_privacy_enabled &&
(adapter->supported_settings & MGMT_SETTING_PRIVACY))
set_privacy(adapter, true);
gboolean ipsp_connected; /* IPSP Connection state */
char if_name[16 + 1]; /* BT interface UP after IPSP connection */
uint8_t rpa_res_support; /* RPA Resolution capability of device */
- uint16_t max_tx_octets;
- uint16_t max_tx_time;
- uint16_t max_rx_octets;
- uint16_t max_rx_time;
- bdaddr_t rpa;
- bool rpa_exist;
- bool duplicate;
+ uint16_t max_tx_octets;
+ uint16_t max_tx_time;
+ uint16_t max_rx_octets;
+ uint16_t max_rx_time;
+ bdaddr_t *rpa;
DBusMessage *req_att_mtu; /* Attribute MTU request message */
uint8_t irk_val[16];
bool pending_conn_update;
ba2str(&device->bdaddr, device_addr);
#ifdef __TIZEN_PATCH__
- if (device->rpa_exist)
- ba2str(&device->rpa, device_addr);
+ if (device->rpa)
+ ba2str(device->rpa, device_addr);
#endif
snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/info", adapter_addr,
device_addr);
"ManufacturerDataLen", NULL);
}
- if (device->rpa_exist) {
+ if (device->rpa) {
char irk_addr[18];
ba2str(&device->bdaddr, irk_addr);
ba2str(&dev->bdaddr, d_addr);
#ifdef __TIZEN_PATCH__
- if (dev->rpa_exist)
- ba2str(&dev->rpa, d_addr);
+ if (dev->rpa)
+ ba2str(dev->rpa, d_addr);
#endif
snprintf(filename, PATH_MAX, STORAGEDIR "/%s/cache/%s", s_addr, d_addr);
if (device->eir_uuids)
g_slist_free_full(device->eir_uuids, g_free);
+#ifdef __TIZEN_PATCH__
+ g_free(device->rpa);
+#endif
g_free(device->local_csrk);
g_free(device->remote_csrk);
g_free(device->path);
char dstaddr[18];
const char *ptr = dstaddr;
- ba2str(&device->bdaddr, dstaddr);
+#ifdef __TIZEN_PATCH__
+ if (device->rpa)
+ ba2str(device->rpa, dstaddr);
+ else
+#endif
+ ba2str(&device->bdaddr, dstaddr);
dbus_message_iter_append_basic(iter, DBUS_TYPE_STRING, &ptr);
return TRUE;
ba2str(&device->bdaddr, dst_addr);
#ifdef __TIZEN_PATCH__
- if (device->rpa_exist)
- ba2str(&device->rpa, dst_addr);
+ if (device->rpa)
+ ba2str(device->rpa, dst_addr);
#endif
snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s/attributes", src_addr,
struct btd_device *device = user_data;
char device_idaddr[18] = { 0 };
DBusMessage *reply;
- const gchar *id_address;
+ const gchar *id_address = device_idaddr;
DBG("");
- if (device == NULL) {
- error("device is NULL");
+ if (device == NULL)
return btd_error_invalid_args(msg);
- }
- if (!device->le) {
- error("le is not supported");
+ if (!device->le)
return btd_error_not_supported(msg);
- }
- DBG("bdaddr_type %d", device->bdaddr_type);
-
- /* Device will have its IDA only if device has RPA */
- if (device->rpa_exist) {
- DBG("device->rpa_exist");
+ if (device->rpa)
ba2str(&device->bdaddr, device_idaddr);
- }
- else {
- DBG("device->rpa_exist does not exist");
+ else
return btd_error_does_not_exist(msg);
- }
reply = dbus_message_new_method_return(msg);
if (!reply)
- return NULL;
-
- id_address = g_strdup(device_idaddr);
+ return NULL;
dbus_message_append_args(reply, DBUS_TYPE_STRING, &id_address,
- DBUS_TYPE_INVALID);
+ DBUS_TYPE_INVALID);
+
return reply;
}
str = g_key_file_get_string(key_file, "General", "IdentityAddress",
NULL);
- /* Folder name is RPA(Resolvable Private Address), So we need to swap it */
if (str) {
- memcpy(&device->rpa, &device->bdaddr, sizeof(bdaddr_t));
+ device->rpa = g_malloc0(sizeof(bdaddr_t));
+ bacpy(device->rpa, &device->bdaddr);
str2ba(str, &device->bdaddr);
- device->rpa_exist = true;
+ g_free(str);
}
#endif
return btd_device_ref(device);
}
+#ifdef __TIZEN_PATCH__
+void device_print_addr(struct btd_device *dev)
+{
+ char addr[18];
+
+ ba2str(&dev->bdaddr, addr);
+ DBG("IDA : %s %d", addr, dev->bdaddr_type);
+
+ if (dev->rpa) {
+ ba2str(dev->rpa, addr);
+ DBG("RPA : %s", addr);
+ } else {
+ DBG("No RPA");
+ }
+
+ if (dev->bredr)
+ DBG("BREDR Support");
+ else
+ DBG("BREDR Not Support");
+
+ if (dev->le)
+ DBG("LE Support");
+ else
+ DBG("LE Not Support");
+
+ DBG("***");
+}
+#endif
+
struct btd_device *device_create_from_storage(struct btd_adapter *adapter,
const char *address, GKeyFile *key_file)
{
else
device->le = true;
-#ifdef __TIZEN_PATCH__
- if (bdaddr_type == BDADDR_LE_RANDOM)
- bacpy(&device->rpa, bdaddr);
-#endif
-
sba = btd_adapter_get_address(adapter);
ba2str(sba, src);
ba2str(&device->bdaddr, dstaddr);
#ifdef __TIZEN_PATCH__
- if (device->rpa_exist)
- ba2str(&device->rpa, dstaddr);
+ if (device->rpa)
+ ba2str(device->rpa, dstaddr);
#endif
if (!filename)
void device_set_bredr_support(struct btd_device *device)
{
+#ifdef __TIZEN_PATCH__
+ char addr_str[18];
+
+ if (device->rpa) {
+ ba2str(device->rpa, addr_str);
+ error("Cannot set bredr support to RPA device [%s]", addr_str);
+ return;
+ }
+
+ if (device->bdaddr_type == BDADDR_LE_RANDOM) {
+ ba2str(&device->bdaddr, addr_str);
+ error("Cannot set bredr support to LE random device [%s]",
+ addr_str);
+ return;
+ }
+#endif
+
if (device->bredr)
return;
#ifdef __TIZEN_PATCH__
void device_set_rpa(struct btd_device *device, const bdaddr_t *rpa)
{
- DBG("rpa exist: %d", device->rpa_exist);
-
- if (device->rpa_exist == false) {
- /* Only use first RPA value even if the device was re-paired */
- bacpy(&device->rpa, rpa);
- device->rpa_exist = true;
- }
+ if (device->rpa == NULL) {
+ device->rpa = g_malloc0(sizeof(bdaddr_t));
+ bacpy(device->rpa, rpa);
+ } else
+ error("RPA is already set");
}
void device_set_irk_value(struct btd_device *device, const uint8_t *val)
dev->vendor = dup->vendor;
dev->product = dup->product;
dev->version = dup->version;
-
-#ifdef __TIZEN_PATCH__
- for (l = dup->services; l; l = g_slist_next(l)) {
- struct btd_service *svc = l->data;
- dev->services = g_slist_append(dev->services, btd_service_ref(svc));
- }
-
- dup->duplicate = true;
-#endif
}
uint32_t btd_device_get_class(struct btd_device *device)
ba2str(&device->bdaddr, device_addr);
#ifdef __TIZEN_PATCH__
- if (device->rpa_exist)
- ba2str(&device->rpa, device_addr);
+ if (device->rpa)
+ ba2str(device->rpa, device_addr);
#endif
snprintf(filename, PATH_MAX, STORAGEDIR "/%s/%s", adapter_addr,
gatt_db_clear(device->db);
- if (device->rpa_exist) {
- bacpy(&device->bdaddr, &device->rpa);
+ if (device->rpa) {
+ bacpy(&device->bdaddr, device->rpa);
device->bdaddr_type = BDADDR_LE_RANDOM;
- bacpy(&device->rpa, BDADDR_ANY);
- device->rpa_exist = false;
+ g_free(device->rpa);
+ device->rpa = NULL;
}
device->bredr_state.paired = 0;
const char *address = b;
char addr[18];
- ba2str(&device->rpa, addr);
+ if (!device->rpa)
+ return -1;
+
+ ba2str(device->rpa, addr);
+
return strcasecmp(addr, address);
}
const struct btd_device *device = a;
const bdaddr_t *bdaddr = b;
- if (device->duplicate)
- return -1;
-
return bacmp(&device->bdaddr, bdaddr);
}
#endif
return false;
}
+#ifdef __TIZEN_PATCH__
+int device_addr_type_strict_cmp(gconstpointer a, gconstpointer b)
+{
+ const struct btd_device *dev = a;
+ const struct device_addr_type *addr = b;
+ int cmp;
+
+ cmp = bacmp(&dev->bdaddr, &addr->bdaddr);
+
+ if (addr->bdaddr_type == BDADDR_BREDR) {
+ if (!dev->bredr)
+ return -1;
+
+ return cmp;
+ }
+
+ if (!dev->le)
+ return -1;
+
+ if (cmp && dev->rpa && addr->bdaddr_type == BDADDR_LE_RANDOM &&
+ (addr->bdaddr.b[5] >> 6) == 0x01)
+ return bacmp(dev->rpa, &addr->bdaddr);
+
+ if (addr->bdaddr_type != dev->bdaddr_type)
+ return -1;
+
+ return cmp;
+}
+#endif
+
int device_addr_type_cmp(gconstpointer a, gconstpointer b)
{
const struct btd_device *dev = a;
*/
if (!cmp && addr_is_public(addr->bdaddr_type) &&
addr_is_public(dev->bdaddr_type))
+#ifdef __TIZEN_PATCH__
+ {
+ if (dev->rpa && addr->bdaddr_type == BDADDR_BREDR) {
+ char addr_str[18];
+
+ ba2str(&dev->bdaddr, addr_str);
+ DBG("Don't match. LE Only device [%s]", addr_str);
+ return -1;
+ }
+ return 0;
+ }
+#else
return 0;
+#endif
if (addr->bdaddr_type == BDADDR_BREDR) {
if (!dev->bredr)
ba2str(btd_adapter_get_address(device->adapter), srcaddr);
ba2str(&device->bdaddr, dstaddr);
-#ifdef __TIZEN_PATCH__
- if (device->rpa_exist)
- ba2str(&device->rpa, dstaddr);
-#endif
-
snprintf(sdp_file, PATH_MAX, STORAGEDIR "/%s/cache/%s", srcaddr,
dstaddr);
const bdaddr_t *device_get_rpa(struct btd_device *device)
{
- return &device->rpa;
+ return device->rpa;
}
const uint8_t *device_get_irk_value(struct btd_device *device)
bool device_get_rpa_exist(struct btd_device *device)
{
- return device->rpa_exist;
+ return device->rpa ? true : false;
}
void device_set_auth_addr_type(struct btd_device *device, uint8_t type)
device->auth_bdaddr_type = type;
}
+
+void device_get_tizen_addr(struct btd_device *device,
+ struct device_addr_type *addr)
+{
+ if (!device || !addr)
+ return;
+
+ if (device->rpa) {
+ bacpy(&addr->bdaddr, device->rpa);
+ addr->bdaddr_type = BDADDR_LE_RANDOM;
+ return;
+ }
+
+ bacpy(&addr->bdaddr, &device->bdaddr);
+ addr->bdaddr_type = device->bdaddr_type;
+}
#endif
int device_discover_services(struct btd_device *device)
#ifdef TIZEN_WEARABLE
if (bdaddr_type == BDADDR_BREDR && state->svc_resolved) {
DBG("Link key has been changed. Report it");
- if (device->rpa_exist == false)
- g_dbus_emit_property_changed(dbus_conn, device->path,
- DEVICE_INTERFACE, "Paired");
+ if (!device->rpa)
+ g_dbus_emit_property_changed(dbus_conn,
+ device->path, DEVICE_INTERFACE,
+ "Paired");
else
DBG("Just overwrite Link key");
} else if (bdaddr_type == BDADDR_LE_RANDOM ||
ba2str(&device->bdaddr, peer);
#ifdef __TIZEN_PATCH__
- if (device->rpa_exist)
- ba2str(&device->rpa, peer);
+ if (device->rpa)
+ ba2str(device->rpa, peer);
#endif
snprintf(filename, PATH_MAX, STORAGEDIR "/%s/cache/%s", local, peer);
ba2str(&device->bdaddr, peer_addr);
/* Replace address type for paired RPA device since IDA passed from controller */
- if(device_get_rpa_exist(device) == true)
+ if (device->rpa)
addr_type = BDADDR_LE_RANDOM;
else
addr_type = device->bdaddr_type;