summaryrefslogtreecommitdiff
path: root/tools/hciconfig.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2010-05-17 17:30:35 +0200
committerJohan Hedberg <johan.hedberg@nokia.com>2010-05-17 17:30:35 +0200
commit38a7ef119c1ee1637a4f334dd055b8a171cdf148 (patch)
tree3469724db13d54e4eba65cf5298ff36984be501e /tools/hciconfig.c
parent4fae65509dc7d9e1856fe0b0454f881885049867 (diff)
downloadbluez-38a7ef119c1ee1637a4f334dd055b8a171cdf148.tar.gz
Add hciconfig support for blacklisting
This patch implements hciconfig support for the new HCIBLOCKADDR and HCIUNBLOCKADDR ioctls.
Diffstat (limited to 'tools/hciconfig.c')
-rw-r--r--tools/hciconfig.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/tools/hciconfig.c b/tools/hciconfig.c
index 06c94593a..87dd12703 100644
--- a/tools/hciconfig.c
+++ b/tools/hciconfig.c
@@ -1577,6 +1577,59 @@ static void cmd_revision(int ctl, int hdev, char *opt)
return;
}
+static void cmd_block(int ctl, int hdev, char *opt)
+{
+ bdaddr_t bdaddr;
+ int dd;
+
+ if (!opt)
+ return;
+
+ dd = hci_open_dev(hdev);
+ if (dd < 0) {
+ fprintf(stderr, "Can't open device hci%d: %s (%d)\n",
+ hdev, strerror(errno), errno);
+ exit(1);
+ }
+
+ str2ba(opt, &bdaddr);
+
+ if (ioctl(dd, HCIBLOCKADDR, &bdaddr) < 0) {
+ perror("ioctl(HCIBLOCKADDR)");
+ exit(1);
+ }
+
+ hci_close_dev(dd);
+}
+
+static void cmd_unblock(int ctl, int hdev, char *opt)
+{
+ bdaddr_t bdaddr;
+ int dd;
+
+ if (!opt)
+ return;
+
+ dd = hci_open_dev(hdev);
+ if (dd < 0) {
+ fprintf(stderr, "Can't open device hci%d: %s (%d)\n",
+ hdev, strerror(errno), errno);
+ exit(1);
+ }
+
+ if (!strcasecmp(opt, "all"))
+ bacpy(&bdaddr, BDADDR_ANY);
+ else
+ str2ba(opt, &bdaddr);
+
+ if (ioctl(dd, HCIUNBLOCKADDR, &bdaddr) < 0) {
+ perror("ioctl(HCIUNBLOCKADDR)");
+ exit(1);
+ }
+
+ hci_close_dev(dd);
+}
+
static void print_dev_hdr(struct hci_dev_info *di)
{
static int hdr = -1;
@@ -1673,6 +1726,8 @@ static struct {
{ "features", cmd_features, 0, "Display device features" },
{ "version", cmd_version, 0, "Display version information" },
{ "revision", cmd_revision, 0, "Display revision information" },
+ { "block", cmd_block, "<bdaddr>", "Add a device to the blacklist" },
+ { "unblock", cmd_unblock, "<bdaddr>", "Remove a device from the blacklist" },
{ NULL, NULL, 0 }
};