summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorSudha Bheemanna <b.sudha@samsung.com>2016-09-15 10:12:09 +0530
committerSeung-Woo Kim <sw0312.kim@samsung.com>2016-12-14 13:53:23 +0900
commit6cf64e5f18a973023fec47bcf47ce79aa4035cc4 (patch)
tree6e528a24f147a961e3213a44ec84c0725cfc8dbc /net
parentf0195c746d672d073327406328a46fda954a5cdd (diff)
Bluetooth: Add support to enable/disable IPSP
This patch supports MGMT commands and code to enable or disable IPSP 6LowPan features. Change-Id: Ia866ecfa517c7d7e4320f17d94d80dfeb9261e59 Signed-off-by: Sudha Bheemanna <b.sudha@samsung.com>
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/6lowpan.c34
-rw-r--r--net/bluetooth/mgmt.c35
2 files changed, 69 insertions, 0 deletions
diff --git a/net/bluetooth/6lowpan.c b/net/bluetooth/6lowpan.c
index 1742b849fcff..593034eb897a 100644
--- a/net/bluetooth/6lowpan.c
+++ b/net/bluetooth/6lowpan.c
@@ -1445,6 +1445,40 @@ static int __init bt_6lowpan_init(void)
return register_netdevice_notifier(&bt_6lowpan_dev_notifier);
}
+#ifdef TIZEN_BT
+void bt_6lowpan_enable(void)
+{
+ if (!enable_6lowpan) {
+ disconnect_all_peers();
+
+ enable_6lowpan = true;
+
+ if (listen_chan) {
+ l2cap_chan_close(listen_chan, 0);
+ l2cap_chan_put(listen_chan);
+ }
+
+ listen_chan = bt_6lowpan_listen();
+
+ register_netdevice_notifier(&bt_6lowpan_dev_notifier);
+ }
+}
+
+void bt_6lowpan_disable(void)
+{
+ if (enable_6lowpan) {
+ if (listen_chan) {
+ l2cap_chan_close(listen_chan, 0);
+ l2cap_chan_put(listen_chan);
+ listen_chan = NULL;
+ }
+ disconnect_devices();
+ unregister_netdevice_notifier(&bt_6lowpan_dev_notifier);
+ enable_6lowpan = false;
+ }
+}
+#endif
+
static void __exit bt_6lowpan_exit(void)
{
debugfs_remove(lowpan_enable_debugfs);
diff --git a/net/bluetooth/mgmt.c b/net/bluetooth/mgmt.c
index f16c3d5484d0..f5b40ccfd2d9 100644
--- a/net/bluetooth/mgmt.c
+++ b/net/bluetooth/mgmt.c
@@ -7294,6 +7294,40 @@ void mgmt_multi_adv_state_change_evt(struct hci_dev *hdev, u8 adv_instance,
sizeof(struct mgmt_ev_vendor_specific_multi_adv_state_changed),
NULL);
}
+
+static int enable_bt_6lowpan(struct sock *sk, struct hci_dev *hdev,
+ void *data, u16 len)
+{
+ int err;
+ struct mgmt_cp_enable_6lowpan *cp = data;
+
+ BT_DBG("%s", hdev->name);
+
+ hci_dev_lock(hdev);
+
+ if (!hdev_is_powered(hdev)) {
+ err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ENABLE_6LOWPAN,
+ MGMT_STATUS_NOT_POWERED);
+ goto unlocked;
+ }
+
+ if (!lmp_le_capable(hdev)) {
+ err = mgmt_cmd_status(sk, hdev->id, MGMT_OP_ENABLE_6LOWPAN,
+ MGMT_STATUS_NOT_SUPPORTED);
+ goto unlocked;
+ }
+
+ if (cp->enable_6lowpan)
+ bt_6lowpan_enable();
+ else
+ bt_6lowpan_disable();
+
+ err = mgmt_cmd_complete(sk, hdev->id, MGMT_OP_ENABLE_6LOWPAN,
+ MGMT_STATUS_SUCCESS, NULL, 0);
+unlocked:
+ hci_dev_unlock(hdev);
+ return err;
+}
#endif /* TIZEN_BT */
static bool ltk_is_valid(struct mgmt_ltk_info *key)
@@ -9184,6 +9218,7 @@ static const struct hci_mgmt_handler tizen_mgmt_handlers[] = {
{ le_set_scan_params, MGMT_LE_SET_SCAN_PARAMS_SIZE },
{ set_voice_setting, MGMT_SET_VOICE_SETTING_SIZE },
{ get_adv_tx_power, MGMT_GET_ADV_TX_POWER_SIZE },
+ { enable_bt_6lowpan, MGMT_ENABLE_BT_6LOWPAN_SIZE },
};
#endif