All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/4] HCI command to remove device from LE White List
@ 2011-01-24  9:58 Sumit Kumar BAJPAI
  2011-01-24 11:42 ` Anderson Lizardo
  0 siblings, 1 reply; 6+ messages in thread
From: Sumit Kumar BAJPAI @ 2011-01-24  9:58 UTC (permalink / raw)
  To: linux-bluetooth

---
 lib/hci.c       |   29 +++++++++++++++++++++++++++++
 lib/hci_lib.h   |    1 +
 tools/hcitool.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 77 insertions(+), 0 deletions(-)

diff --git a/lib/hci.c b/lib/hci.c
index b75f612..11b47b3 100755
--- a/lib/hci.c
+++ b/lib/hci.c
@@ -1320,6 +1320,35 @@ int hci_le_add_to_white_list(int dd, const bdaddr_t* bdaddr, uint8_t type)
 	return 0;
 }
 
+int hci_le_remove_from_white_list(int dd, const bdaddr_t* bdaddr, uint8_t type)
+{
+	struct hci_request rq;
+	le_remove_device_from_white_list_cp cp;
+	uint8_t status;
+
+	memset(&cp, 0, sizeof(cp));
+	cp.bdaddr_type = type;
+	bacpy(&cp.bdaddr,bdaddr);
+
+	memset(&rq, 0, sizeof(rq));
+	rq.ogf = OGF_LE_CTL;
+	rq.ocf = OCF_LE_REMOVE_DEVICE_FROM_WHITE_LIST;
+	rq.cparam = &cp;
+	rq.clen = LE_REMOVE_DEVICE_FROM_WHITE_LIST_CP_SIZE;
+	rq.rparam = &status;
+	rq.rlen = 1;
+
+	if (hci_send_req(dd, &rq, 1000) < 0)
+		return -1;
+
+	if (status) {
+		errno = EIO;
+		return -1;
+	}
+
+	return 0;
+}
+
 int hci_read_local_name(int dd, int len, char *name, int to)
 {
 	read_local_name_rp rp;
diff --git a/lib/hci_lib.h b/lib/hci_lib.h
index dd995dd..e64a431 100755
--- a/lib/hci_lib.h
+++ b/lib/hci_lib.h
@@ -128,6 +128,7 @@ int hci_le_create_conn(int dd, uint16_t interval, uint16_t window,
 		uint16_t min_ce_length, uint16_t max_ce_length,
 		uint16_t *handle, int to);
 int hci_le_add_to_white_list(int dd, const bdaddr_t* bdaddr, uint8_t type);
+int hci_le_remove_from_white_list(int dd, const bdaddr_t* bdaddr, uint8_t type);
 
 int hci_for_each_dev(int flag, int(*func)(int dd, int dev_id, long arg), long arg);
 int hci_get_route(bdaddr_t *bdaddr);
diff --git a/tools/hcitool.c b/tools/hcitool.c
index 9147995..038d05e 100755
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -2517,6 +2517,52 @@ static void cmd_leaddwl(int dev_id, int argc, char **argv)
 	}
 }
 
+static struct option lermwl_options[] = {
+	{ "help",	0, 0, 'h' },
+	{ 0, 0, 0, 0 }
+};
+
+static const char *lermwl_help =
+	"Usage:\n"
+	"\tlermwl <bdaddr>\n";
+
+static void cmd_lermwl(int dev_id, int argc, char **argv)
+{
+	int err, opt, dd;
+	bdaddr_t bdaddr;
+	le_device_addr_type bdaddr_type;
+
+	for_each_opt(opt, lermwl_options, NULL) {
+		switch (opt) {
+		default:
+			printf("%s", lermwl_help);
+			return;
+		}
+	}
+
+	helper_arg(1, 1, &argc, &argv, lermwl_help);
+	
+	if (dev_id < 0)
+		dev_id = hci_get_route(NULL);
+
+	dd = hci_open_dev(dev_id);
+	if (dd < 0) {
+		perror("Could not open device");
+		exit(1);
+	}
+	
+	str2ba(argv[0], &bdaddr);
+	bdaddr_type = LE_PUBLIC_DEVICE_ADDR;
+
+	err = hci_le_remove_from_white_list(dd, &bdaddr, bdaddr_type);
+	hci_close_dev(dd);
+
+	if (err < 0) {
+		perror("Cant remove from white list");
+		exit(1);
+	}
+}
+
 static struct option ledc_options[] = {
 	{ "help",	0, 0, 'h' },
 	{ 0, 0, 0, 0 }
@@ -2594,6 +2640,7 @@ static struct {
 	{ "clock",  cmd_clock,  "Read local or remote clock"           },
 	{ "lescan", cmd_lescan, "Start LE scan"                        },
 	{ "leaddwl", cmd_leaddwl, "Add this device to white list"	   },
+	{ "lermwl", cmd_lermwl, "Remove this device from white list"   },
 	{ "lecc",   cmd_lecc,   "Create a LE Connection",              },
 	{ "ledc",   cmd_ledc,   "Disconnect a LE Connection",          },
 	{ NULL, NULL, 0 }
-- 
1.6.5

^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [PATCH 2/4] HCI command to remove device from LE White List
@ 2011-02-23  7:09 Arun Kumar SINGH
  0 siblings, 0 replies; 6+ messages in thread
From: Arun Kumar SINGH @ 2011-02-23  7:09 UTC (permalink / raw)
  To: linux-bluetooth

>From 2c5038477842b3b73eea161d9610b2bd4100f338 Mon Sep 17 00:00:00 2001
From: ArunKumarSingh <arunkr.singh@stericsson.com>
Date: Wed, 23 Feb 2011 12:03:36 +0530
Subject: [PATCH] Command to remove device from Whitelist


Signed-off-by: ArunKumarSingh <arunkr.singh@stericsson.com>
---
 lib/hci.c       |   29 +++++++++++++++++++++++++++++
 lib/hci_lib.h   |    1 +
 tools/hcitool.c |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 77 insertions(+), 0 deletions(-)

diff --git a/lib/hci.c b/lib/hci.c
index a85f193..1ae2dc6 100755
--- a/lib/hci.c
+++ b/lib/hci.c
@@ -1320,6 +1320,35 @@ int hci_le_add_to_white_list(int dd, const bdaddr_t *bdaddr, uint8_t type)
 	return 0;
 }
 
+int hci_le_remove_from_white_list(int dd, const bdaddr_t *bdaddr, uint8_t type)
+{
+	struct hci_request rq;
+	le_remove_device_from_white_list_cp cp;
+	uint8_t status;
+
+	memset(&cp, 0, sizeof(cp));
+	cp.bdaddr_type = type;
+	bacpy(&cp.bdaddr, bdaddr);
+
+	memset(&rq, 0, sizeof(rq));
+	rq.ogf = OGF_LE_CTL;
+	rq.ocf = OCF_LE_REMOVE_DEVICE_FROM_WHITE_LIST;
+	rq.cparam = &cp;
+	rq.clen = LE_REMOVE_DEVICE_FROM_WHITE_LIST_CP_SIZE;
+	rq.rparam = &status;
+	rq.rlen = 1;
+
+	if (hci_send_req(dd, &rq, 1000) < 0)
+		return -1;
+
+	if (status) {
+		errno = EIO;
+		return -1;
+	}
+
+	return 0;
+}
+
 int hci_read_local_name(int dd, int len, char *name, int to)
 {
 	read_local_name_rp rp;
diff --git a/lib/hci_lib.h b/lib/hci_lib.h
index 7127d70..b42a91b 100755
--- a/lib/hci_lib.h
+++ b/lib/hci_lib.h
@@ -128,6 +128,7 @@ int hci_le_create_conn(int dd, uint16_t interval, uint16_t window,
 		uint16_t min_ce_length, uint16_t max_ce_length,
 		uint16_t *handle, int to);
 int hci_le_add_to_white_list(int dd, const bdaddr_t *bdaddr, uint8_t type);
+int hci_le_remove_from_white_list(int dd, const bdaddr_t *bdaddr, uint8_t type);
 
 int hci_for_each_dev(int flag, int(*func)(int dd, int dev_id, long arg), long arg);
 int hci_get_route(bdaddr_t *bdaddr);
diff --git a/tools/hcitool.c b/tools/hcitool.c
index b5109b8..1118b07 100755
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -2533,6 +2533,52 @@ static void cmd_leaddwl(int dev_id, int argc, char **argv)
 	}
 }
 
+static struct option lermwl_options[] = {
+	{ "help",	0, 0, 'h' },
+	{ 0, 0, 0, 0 }
+};
+
+static const char *lermwl_help =
+	"Usage:\n"
+	"\tlermwl <bdaddr>\n";
+
+static void cmd_lermwl(int dev_id, int argc, char **argv)
+{
+	int err, opt, dd;
+	bdaddr_t bdaddr;
+	le_device_addr_type bdaddr_type;
+
+	for_each_opt(opt, lermwl_options, NULL) {
+		switch (opt) {
+		default:
+			printf("%s", lermwl_help);
+			return;
+		}
+	}
+
+	helper_arg(1, 1, &argc, &argv, lermwl_help);
+	
+	if (dev_id < 0)
+		dev_id = hci_get_route(NULL);
+
+	dd = hci_open_dev(dev_id);
+	if (dd < 0) {
+		perror("Could not open device");
+		exit(1);
+	}
+	
+	str2ba(argv[0], &bdaddr);
+	bdaddr_type = LE_PUBLIC_DEVICE_ADDR;
+
+	err = hci_le_remove_from_white_list(dd, &bdaddr, bdaddr_type);
+	hci_close_dev(dd);
+
+	if (err < 0) {
+		perror("Cant remove from white list");
+		exit(1);
+	}
+}
+
 static struct option ledc_options[] = {
 	{ "help",	0, 0, 'h' },
 	{ 0, 0, 0, 0 }
@@ -2610,6 +2656,7 @@ static struct {
 	{ "clock",  cmd_clock,  "Read local or remote clock"           },
 	{ "lescan", cmd_lescan, "Start LE scan"                        },
 	{ "leaddwl", cmd_leaddwl, "Add this device to white list"	   },
+	{ "lermwl", cmd_lermwl, "Remove this device from white list"   },
 	{ "lecc",   cmd_lecc,   "Create a LE Connection",              },
 	{ "ledc",   cmd_ledc,   "Disconnect a LE Connection",          },
 	{ NULL, NULL, 0 }
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-02-23  7:09 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-24  9:58 [PATCH 2/4] HCI command to remove device from LE White List Sumit Kumar BAJPAI
2011-01-24 11:42 ` Anderson Lizardo
2011-01-25  5:19   ` Sumit Kumar BAJPAI
2011-01-31  8:28     ` Johan Hedberg
2011-02-21 13:29       ` Claudio Takahasi
2011-02-23  7:09 Arun Kumar SINGH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.