From: DoHyun Pyun Date: Wed, 2 Nov 2016 05:05:49 +0000 (+0900) Subject: Merge the code from private X-Git-Tag: accepted/tizen/ivi/20161108.001310^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F07%2F95807%2F1;p=platform%2Fupstream%2Fbluez.git Merge the code from private branch:devel/bluetooth/master ================================================= commit ecfa1d0dd2543caa510f1692ae06e40df77f30f1 Author: Biman Paul Date: Wed Jun 29 16:27:07 2016 +0530 pbap: clear cache if name header is present ================================================= Change-Id: I3694ac497121e02759427669843a13d61a4af875 Signed-off-by: DoHyun Pyun --- diff --git a/attrib/gatt.c b/attrib/gatt.c index de537ad..b9596c4 100644 --- a/attrib/gatt.c +++ b/attrib/gatt.c @@ -867,7 +867,7 @@ guint gatt_read_char_by_offset(GAttrib *attrib, uint16_t handle, uint16_t offset if (long_read == NULL) return 0; - long_read->attrib = attrib; + long_read->attrib = g_attrib_ref(attrib); long_read->func = func; long_read->user_data = user_data; long_read->handle = handle; diff --git a/attrib/interactive.c b/attrib/interactive.c index 0880585..20cb58f 100644 --- a/attrib/interactive.c +++ b/attrib/interactive.c @@ -808,8 +808,13 @@ static struct { "Characteristics Discovery" }, { "char-desc", cmd_char_desc, "[start hnd] [end hnd]", "Characteristics Descriptor Discovery" }, +#ifdef __TIZEN_PATCH__ + { "char-read-hnd", cmd_read_hnd, " [offset]", + "Characteristics Value/Descriptor Read by handle" }, +#else { "char-read-hnd", cmd_read_hnd, "", "Characteristics Value/Descriptor Read by handle" }, +#endif { "char-read-uuid", cmd_read_uuid, " [start hnd] [end hnd]", "Characteristics Value/Descriptor Read by UUID" }, { "char-write-req", cmd_char_write, " ", diff --git a/lib/hci.c b/lib/hci.c index 70f4cd4..780b967 100644 --- a/lib/hci.c +++ b/lib/hci.c @@ -1639,7 +1639,11 @@ int hci_write_local_name(int dd, const char *name, int to) struct hci_request rq; memset(&cp, 0, sizeof(cp)); +#ifdef __TIZEN_PATCH__ + strncpy((char *) cp.name, name, sizeof(cp.name) - 1); +#else strncpy((char *) cp.name, name, sizeof(cp.name)); +#endif memset(&rq, 0, sizeof(rq)); rq.ogf = OGF_HOST_CTL; diff --git a/monitor/broadcom.c b/monitor/broadcom.c index 58ac37d..91a2b25 100644 --- a/monitor/broadcom.c +++ b/monitor/broadcom.c @@ -940,7 +940,59 @@ void broadcom_lm_diag(const void *data, uint8_t size) } } +#ifdef __TIZEN_PATCH__ +struct hci_vse_sec_brcm_link_loss_dbg_info{ + unsigned char linklost_status; + unsigned char conn_handle; + char trans_pwr; + char rssi; + unsigned char ch_map[10]; + unsigned char lmp_cmd[4]; +} __packed; + +static void linkloss_evt(const void *data, uint8_t size) +{ + + struct hci_vse_sec_brcm_link_loss_dbg_info *ev = (void *) data; + char *status = NULL; + switch (ev->linklost_status) { + case 0: + status = "BT_Link_Supervision_Timeout"; + break; + case 1: + status = "LE_Link_Supervision_Timeout"; + break; + case 2: + status = "BT_LMP_Timeout_Local"; + break; + case 3: + status = "BT_LMP_Timeout_Remote"; + break; + case 4: + status = "LE_LMP_Timeout"; + break; + case 5: + status = "Page_Timeout"; + break; + default : + break; + } + + print_field("Status:%s,Handle:%02x,Trans_Pwr:%d,RSSI:%d" + " Ch_map:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" + " LMP_cmd:0x%x%x%x%x", + status, ev->conn_handle, ev->trans_pwr, ev->rssi, + ev->ch_map[0], ev->ch_map[1], ev->ch_map[2], ev->ch_map[3], + ev->ch_map[4], ev->ch_map[5], ev->ch_map[6], ev->ch_map[7], + ev->ch_map[8], ev->ch_map[9], ev->lmp_cmd[0], ev->lmp_cmd[1], + ev->lmp_cmd[2], ev->lmp_cmd[3]); +} +#endif + static const struct vendor_evt vendor_evt_table[] = { +#ifdef __TIZEN_PATCH__ + { 0x76, "SEC Link Loss", linkloss_evt, 18, true }, +#endif { } }; diff --git a/monitor/packet.c b/monitor/packet.c index 7b7822f..52e5ef7 100644 --- a/monitor/packet.c +++ b/monitor/packet.c @@ -7300,6 +7300,10 @@ static const char *current_vendor_str(void) return "Intel"; case 15: return "Broadcom"; +#ifdef __TIZEN_PATCH__ + default: + return "Unknown"; +#endif } return NULL; @@ -7319,6 +7323,10 @@ static const struct vendor_ocf *current_vendor_ocf(uint16_t ocf) return intel_vendor_ocf(ocf); case 15: return broadcom_vendor_ocf(ocf); +#ifdef __TIZEN_PATCH__ + default: + return broadcom_vendor_ocf(ocf); +#endif } return NULL; @@ -7338,6 +7346,10 @@ static const struct vendor_evt *current_vendor_evt(uint8_t evt) return intel_vendor_evt(evt); case 15: return broadcom_vendor_evt(evt); +#ifdef __TIZEN_PATCH__ + default: + return broadcom_vendor_evt(evt); +#endif } return NULL; diff --git a/profiles/input/device.c b/profiles/input/device.c index 99abadb..c84445a 100644 --- a/profiles/input/device.c +++ b/profiles/input/device.c @@ -1371,7 +1371,6 @@ static struct input_device *input_device_new(struct btd_service *service) static struct input_device *input_device_role_new(struct btd_service *service) { struct btd_device *device = btd_service_get_device(service); - struct btd_profile *p = btd_service_get_profile(service); const char *path = device_get_path(device); struct btd_adapter *adapter = device_get_adapter(device); struct input_device *idev; diff --git a/profiles/network/server.c b/profiles/network/server.c index 214bc21..6e1023d 100644 --- a/profiles/network/server.c +++ b/profiles/network/server.c @@ -474,7 +474,7 @@ static gboolean bnep_setup(GIOChannel *chan, error("BNEP server cannot be added"); #ifdef __TIZEN_PATCH__ -{ +if (ns) { /* Emit connected signal to BT application */ const gchar *adapter_path = adapter_get_path(na->adapter); const char *pdev = na->setup->dev; diff --git a/src/adapter.c b/src/adapter.c index 619df2a..b3bf564 100644 --- a/src/adapter.c +++ b/src/adapter.c @@ -11497,7 +11497,8 @@ static void dev_disconnected(struct btd_adapter *adapter, #ifdef __TIZEN_PATCH__ if (device) { - device_get_tizen_addr(device, &t_addr); + device_get_tizen_addr(device, addr->type, &t_addr); + device_set_disconnect_reason(device, reason); adapter_remove_connection(adapter, device, t_addr.bdaddr_type); disconnect_notify(device, reason); @@ -11796,7 +11797,7 @@ static void new_long_term_key_callback(uint16_t index, uint16_t length, rand = le64_to_cpu(key->rand); #ifdef __TIZEN_PATCH__ - device_get_tizen_addr(device, &t_addr); + device_get_tizen_addr(device, addr->type, &t_addr); store_longtermkey(bdaddr, &t_addr.bdaddr, t_addr.bdaddr_type, key->val, key->master, key->type, key->enc_size, ediv, rand); @@ -11909,7 +11910,7 @@ static void new_csrk_callback(uint16_t index, uint16_t length, return; #ifdef __TIZEN_PATCH__ - device_get_tizen_addr(device, &t_addr); + device_get_tizen_addr(device, addr->type, &t_addr); store_csrk(bdaddr, &t_addr.bdaddr, t_addr.bdaddr_type, key->val, 0, key->type); #else @@ -12016,7 +12017,7 @@ static void new_irk_callback(uint16_t index, uint16_t length, return; #ifdef __TIZEN_PATCH__ - device_get_tizen_addr(device, &t_addr); + device_get_tizen_addr(device, addr->type, &t_addr); store_irk(adapter, &t_addr.bdaddr, t_addr.bdaddr_type, irk->val); #else store_irk(adapter, &addr->bdaddr, addr->type, irk->val); @@ -12104,7 +12105,7 @@ static void new_conn_param(uint16_t index, uint16_t length, return; #ifdef __TIZEN_PATCH__ - device_get_tizen_addr(dev, &t_addr); + device_get_tizen_addr(dev, ev->addr.type, &t_addr); store_conn_param(adapter, &t_addr.bdaddr, t_addr.bdaddr_type, ev->min_interval, ev->max_interval, ev->latency, ev->timeout); diff --git a/src/device.c b/src/device.c index bffe36a..6d11526 100644 --- a/src/device.c +++ b/src/device.c @@ -2049,10 +2049,20 @@ done: g_dbus_send_message(dbus_conn, btd_error_failed(dev->connect, strerror(-err))); else { +#ifdef __TIZEN_PATCH__ + /* SDP is not required for Samsung TV Power on */ + if (g_strcmp0(profile->name, "hid-device") == 0) { + DBG("Skip SDP discovery."); + } else { +#endif /* Start passive SDP discovery to update known services */ if (dev->bredr && !dev->svc_refreshed) device_browse_sdp(dev, NULL); #ifdef __TIZEN_PATCH__ + } +#endif + +#ifdef __TIZEN_PATCH__ if (err) g_dbus_send_message(dbus_conn, btd_error_failed(dev->connect, strerror(-err))); @@ -4008,8 +4018,13 @@ void device_remove_connection(struct btd_device *device, uint8_t bdaddr_type) #ifdef __TIZEN_PATCH__ if (device->browse) { - /* clear browse info */ - device->browse = NULL; + struct browse_req *req = device->browse; + + if ((bdaddr_type == BDADDR_BREDR && req->search_uuid != 0) || + (bdaddr_type != BDADDR_BREDR && req->search_uuid == 0)) + device->browse = NULL; + else + DBG("device->browse is for other link"); } #endif @@ -5053,29 +5068,17 @@ static struct btd_device *device_new(struct btd_adapter *adapter, #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); + char ida[18]; + char rpa[18]; - if (dev->rpa) { - ba2str(dev->rpa, addr); - DBG("RPA : %s", addr); - } else { - DBG("No RPA"); - } + ba2str(&dev->bdaddr, ida); - if (dev->bredr) - DBG("BREDR Support"); - else - DBG("BREDR Not Support"); - - if (dev->le) - DBG("LE Support"); - else - DBG("LE Not Support"); + if (dev->rpa) + ba2str(dev->rpa, rpa); - DBG("***"); + DBG("IDA %s [%d] : RPA [%s], BREDR [%d], LE [%d]", + ida, dev->bdaddr_type, dev->rpa ? rpa : "0", + dev->bredr ? 1 : 0, dev->le ? 1 : 0); } #endif @@ -6560,10 +6563,16 @@ bool device_attach_att(struct btd_device *dev, GIOChannel *io) struct btd_gatt_database *database; const bdaddr_t *src, *dst; char srcaddr[18], dstaddr[18]; +#ifdef __TIZEN_PATCH__ + uint8_t dst_type = BDADDR_BREDR; +#endif bt_io_get(io, &gerr, BT_IO_OPT_SEC_LEVEL, &sec_level, BT_IO_OPT_IMTU, &mtu, BT_IO_OPT_CID, &cid, +#ifdef __TIZEN_PATCH__ + BT_IO_OPT_DEST_TYPE, &dst_type, +#endif BT_IO_OPT_INVALID); if (gerr) { @@ -6611,6 +6620,16 @@ bool device_attach_att(struct btd_device *dev, GIOChannel *io) bt_att_set_remote_key(dev->att, dev->remote_csrk->key, remote_counter, dev); +#ifdef __TIZEN_PATCH__ + if (dst_type != BDADDR_BREDR && device_get_rpa_exist(dev) == true) { + bt_att_set_remote_addr(dev->att, + device_get_rpa(dev), BDADDR_LE_RANDOM); + } else { + bt_att_set_remote_addr(dev->att, + &dev->bdaddr, dev->bdaddr_type); + } +#endif + database = btd_adapter_get_database(dev->adapter); src = btd_adapter_get_address(dev->adapter); @@ -7030,12 +7049,18 @@ 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) +void device_get_tizen_addr(struct btd_device *device, uint8_t type, + struct device_addr_type *addr) { if (!device || !addr) return; + if (type == BDADDR_BREDR) { + bacpy(&addr->bdaddr, &device->bdaddr); + addr->bdaddr_type = BDADDR_BREDR; + return; + } + if (device->rpa) { bacpy(&addr->bdaddr, device->rpa); addr->bdaddr_type = BDADDR_LE_RANDOM; @@ -8447,6 +8472,13 @@ struct btd_service *btd_device_get_service(struct btd_device *dev, if (g_str_equal(p->remote_uuid, remote_uuid)) return service; + +#ifdef TIZEN_BT_HID_DEVICE_ENABLE + if (g_str_equal(HID_UUID, remote_uuid)) { + if (strcmp(p->name, "hid-device") == 0) + return service; + } +#endif } return NULL; diff --git a/src/device.h b/src/device.h index 22583d9..5fec33e 100644 --- a/src/device.h +++ b/src/device.h @@ -184,8 +184,8 @@ void device_set_rpa_res_char_value(struct btd_device *device, uint8_t value); void device_le_data_length_changed(struct btd_device *device, uint16_t max_tx_octets, uint16_t max_tx_time, uint16_t max_rx_octets, uint16_t max_rx_time); -void device_get_tizen_addr(struct btd_device *device, - struct device_addr_type *addr); +void device_get_tizen_addr(struct btd_device *device, uint8_t type, + struct device_addr_type *addr); #ifdef TIZEN_FEATURE_PLATFROM_SCAN_FILTER void device_set_ibeacon_report_info(struct btd_device *device, void *data, uint8_t data_len, uint8_t adv_type, int8_t rssi); diff --git a/src/gatt-database.c b/src/gatt-database.c index 8b7b83e..a75fc47 100644 --- a/src/gatt-database.c +++ b/src/gatt-database.c @@ -836,27 +836,19 @@ static void populate_gap_service(struct btd_gatt_database *database) static bool get_dst_info(struct bt_att *att, bdaddr_t *dst, uint8_t *dst_type) { +#ifdef __TIZEN_PATCH__ + return bt_att_get_remote_addr(att, dst, dst_type); +#else GIOChannel *io = NULL; GError *gerr = NULL; -#ifdef __TIZEN_PATCH__ - struct btd_adapter *adapter; - bdaddr_t src; -#endif io = g_io_channel_unix_new(bt_att_get_fd(att)); if (!io) return false; -#ifdef __TIZEN_PATCH__ - bt_io_get(io, &gerr, BT_IO_OPT_SOURCE_BDADDR, &src, - BT_IO_OPT_DEST_BDADDR, dst, - BT_IO_OPT_DEST_TYPE, dst_type, - BT_IO_OPT_INVALID); -#else bt_io_get(io, &gerr, BT_IO_OPT_DEST_BDADDR, dst, BT_IO_OPT_DEST_TYPE, dst_type, BT_IO_OPT_INVALID); -#endif if (gerr) { error("gatt: bt_io_get: %s", gerr->message); g_error_free(gerr); @@ -866,42 +858,8 @@ static bool get_dst_info(struct bt_att *att, bdaddr_t *dst, uint8_t *dst_type) g_io_channel_unref(io); -#ifdef __TIZEN_PATCH__ - adapter = adapter_find(&src); - if (adapter == NULL) { - DBG("Cannot get adapter"); - return true; - } - - if (*dst_type == BDADDR_LE_PUBLIC) { - struct btd_device *device; - char addr[18] = { 0 }; - char addr_rpa[18] = { 0 }; - const bdaddr_t *rpa; - - device = btd_adapter_find_device(adapter, dst, *dst_type); - if (device == NULL) { - DBG("Cannot find device"); - return true; - } - - if (device_get_rpa_exist(device) == false) - return true; - - rpa = device_get_rpa(device); - if (rpa == NULL) - return true; - - ba2str(dst, addr); - ba2str(rpa, addr_rpa); - DBG("Convert IDA [%s] to RPA [%s]", addr, addr_rpa); - - bacpy(dst, rpa); - *dst_type = BDADDR_LE_RANDOM; - } -#endif - return true; +#endif } static void gatt_ccc_read_cb(struct gatt_db_attribute *attrib, diff --git a/src/profile.c b/src/profile.c index 2bceb77..b4f2d34 100644 --- a/src/profile.c +++ b/src/profile.c @@ -2153,6 +2153,14 @@ static char *get_pce_record(struct ext_profile *ext, struct ext_io *l2cap, static char *get_pse_record(struct ext_profile *ext, struct ext_io *l2cap, struct ext_io *rfcomm) { +#ifdef __TIZEN_PATCH__ + uint8_t chan = 0; + + if (rfcomm) + chan = rfcomm->chan; + + return g_strdup_printf(PSE_RECORD, chan, ext->version, ext->name); +#else uint16_t psm = 0; uint8_t chan = 0; @@ -2161,9 +2169,6 @@ static char *get_pse_record(struct ext_profile *ext, struct ext_io *l2cap, if (rfcomm) chan = rfcomm->chan; -#ifdef __TIZEN_PATCH__ - return g_strdup_printf(PSE_RECORD, chan, ext->version, ext->name); -#else return g_strdup_printf(PSE_RECORD, chan, ext->version, ext->name, psm); #endif } diff --git a/src/shared/att.c b/src/shared/att.c index a139660..ec61ec0 100644 --- a/src/shared/att.c +++ b/src/shared/att.c @@ -68,6 +68,8 @@ struct bt_att { bool in_req; /* There's a pending incoming request */ #ifdef __TIZEN_PATCH__ + bdaddr_t bdaddr; + uint8_t bdaddr_type; bool service_change_indication; /* Service changed indication status */ #endif @@ -1479,6 +1481,33 @@ bool bt_att_has_crypto(struct bt_att *att) } #ifdef __TIZEN_PATCH__ +bool bt_att_set_remote_addr(struct bt_att *att, + const bdaddr_t *bdaddr, uint8_t bdaddr_type) +{ + if (!att) + return false; + + bacpy(&att->bdaddr, bdaddr); + att->bdaddr_type = bdaddr_type; + + return true; +} + +bool bt_att_get_remote_addr(struct bt_att *att, + bdaddr_t *bdaddr, uint8_t *bdaddr_type) +{ + if (!att) + return false; + + if (!bacmp(&att->bdaddr, BDADDR_ANY)) + return false; + + bacpy(bdaddr, &att->bdaddr); + *bdaddr_type = att->bdaddr_type; + + return true; +} + bool bt_att_set_svc_changed_indication_registered(struct bt_att *att, bool value) { if (!att) diff --git a/src/shared/att.h b/src/shared/att.h index 727d48d..de45fc4 100644 --- a/src/shared/att.h +++ b/src/shared/att.h @@ -25,6 +25,9 @@ #include #include "src/shared/att-types.h" +#ifdef __TIZEN_PATCH__ +#include "lib/bluetooth.h" +#endif struct bt_att; @@ -92,6 +95,10 @@ bool bt_att_set_remote_key(struct bt_att *att, uint8_t sign_key[16], bt_att_counter_func_t func, void *user_data); bool bt_att_has_crypto(struct bt_att *att); #ifdef __TIZEN_PATCH__ +bool bt_att_set_remote_addr(struct bt_att *att, + const bdaddr_t *bdaddr, uint8_t bdaddr_type); +bool bt_att_get_remote_addr(struct bt_att *att, + bdaddr_t *bdaddr, uint8_t *bdaddr_type); bool bt_att_set_svc_changed_indication_registered(struct bt_att *att, bool value); bool bt_att_get_svc_changed_indication_registered(struct bt_att *att); #endif \ No newline at end of file diff --git a/src/shared/crypto.c b/src/shared/crypto.c index aa66dac..0e103ec 100644 --- a/src/shared/crypto.c +++ b/src/shared/crypto.c @@ -213,7 +213,11 @@ static int alg_new(int fd, const void *keyval, socklen_t keylen) return -1; /* FIXME: This should use accept4() with SOCK_CLOEXEC */ +#ifdef __TIZEN_PATCH__ + return accept(fd, NULL, NULL); +#else return accept(fd, NULL, 0); +#endif } static bool alg_encrypt(int fd, const void *inbuf, size_t inlen, @@ -387,7 +391,7 @@ bool bt_crypto_e(struct bt_crypto *crypto, const uint8_t key[16], * r' = padding || r * * The least significant octet of r becomes the least significant octet - * of r’ and the most significant octet of padding becomes the most + * of r??and the most significant octet of padding becomes the most * significant octet of r'. * * For example, if the 24-bit value r is 0x423456 then r' is diff --git a/tools/btgatt-client.c b/tools/btgatt-client.c index 0f6a1bd..6698eba 100644 --- a/tools/btgatt-client.c +++ b/tools/btgatt-client.c @@ -363,8 +363,13 @@ static void ready_cb(bool success, uint8_t att_ecode, void *user_data) struct client *cli = user_data; if (!success) { +#ifndef __TIZEN_PATCH__ PRLOG("GATT discovery procedures failed - error code: 0x%02x\n", att_ecode); +#else + PRLOG("GATT discovery procedures failed: %s (0x%02x)\n", + ecode_to_string(att_ecode), att_ecode); +#endif return; } @@ -478,7 +483,12 @@ static void read_multiple_cb(bool success, uint8_t att_ecode, int i; if (!success) { +#ifndef __TIZEN_PATCH__ PRLOG("\nRead multiple request failed: 0x%02x\n", att_ecode); +#else + PRLOG("\nRead multiple request failed: %s (0x%02x)\n", + ecode_to_string(att_ecode), att_ecode); +#endif return; } @@ -1122,8 +1132,13 @@ static void notify_cb(uint16_t value_handle, const uint8_t *value, static void register_notify_cb(uint16_t att_ecode, void *user_data) { if (att_ecode) { +#ifndef __TIZEN_PATCH__ PRLOG("Failed to register notify handler " "- error code: 0x%02x\n", att_ecode); +#else + PRLOG("Failed to register notify handler: %s (0x%02x)\n", + ecode_to_string(att_ecode), att_ecode); +#endif return; } diff --git a/tools/hciconfig.c b/tools/hciconfig.c index 9029f7d..3f8a715 100644 --- a/tools/hciconfig.c +++ b/tools/hciconfig.c @@ -93,7 +93,14 @@ static void print_pkt_type(struct hci_dev_info *di) static void print_link_policy(struct hci_dev_info *di) { +#ifdef __TIZEN_PATCH__ + char *str; + str = hci_lptostr(di->link_policy); + printf("\tLink policy: %s\n", str); + bt_free(str); +#else printf("\tLink policy: %s\n", hci_lptostr(di->link_policy)); +#endif } static void print_link_mode(struct hci_dev_info *di) diff --git a/tools/test-runner.c b/tools/test-runner.c index 42c2c1a..4b087f0 100644 --- a/tools/test-runner.c +++ b/tools/test-runner.c @@ -544,7 +544,11 @@ static const char *test_table[] = { static void run_command(char *cmdname, char *home) { +#ifdef __TIZEN_PATCH__ + char *argv[10], *envp[3]; +#else char *argv[9], *envp[3]; +#endif int pos = 0, idx = 0; int serial_fd; pid_t pid, dbus_pid, daemon_pid;