aboutsummaryrefslogtreecommitdiff
path: root/attrib
diff options
context:
space:
mode:
authorSheldon Demario <sheldon.demario@openbossa.org>2011-02-24 17:38:30 -0300
committerJohan Hedberg <johan.hedberg@nokia.com>2011-02-24 18:34:34 -0300
commit28d393d7a2c381132eff76771c6d740fcf05bbfc (patch)
tree263b64dd571cdc9755405f012b792030a39d77ee /attrib
parent6904e0f13709e1fe7addc231cf6775c7262fca07 (diff)
downloadbluez-28d393d7a2c381132eff76771c6d740fcf05bbfc.tar.gz
Add sec-level option to interactive gattool
Diffstat (limited to 'attrib')
-rw-r--r--attrib/interactive.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/attrib/interactive.c b/attrib/interactive.c
index e5817ab3..ff676b47 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -551,6 +551,48 @@ static void cmd_char_write_req(int argcp, char **argvp)
g_free(value);
}
+static void cmd_sec_level(int argcp, char **argvp)
+{
+ GError *gerr = NULL;
+ BtIOSecLevel sec_level;
+
+ if (argcp < 2) {
+ printf("sec-level: %s\n", opt_sec_level);
+ return;
+ }
+
+ if (strcasecmp(argvp[1], "medium") == 0)
+ sec_level = BT_IO_SEC_MEDIUM;
+ else if (strcasecmp(argvp[1], "high") == 0)
+ sec_level = BT_IO_SEC_HIGH;
+ else if (strcasecmp(argvp[1], "low") == 0)
+ sec_level = BT_IO_SEC_LOW;
+ else {
+ printf("Allowed values: low | medium | high\n");
+ return;
+ }
+
+ g_free(opt_sec_level);
+ opt_sec_level = strdup(argvp[1]);
+
+ if (conn_state != STATE_CONNECTED)
+ return;
+
+ if (opt_psm) {
+ printf("It must be reconnected to this change take effect\n");
+ return;
+ }
+
+ bt_io_set(iochannel, BT_IO_L2CAP, &gerr,
+ BT_IO_OPT_SEC_LEVEL, sec_level,
+ BT_IO_OPT_INVALID);
+
+ if (gerr) {
+ printf("Error: %s\n", gerr->message);
+ g_error_free(gerr);
+ }
+}
+
static struct {
const char *cmd;
void (*func)(int argcp, char **argvp);
@@ -577,6 +619,8 @@ static struct {
"Characteristics Value/Descriptor Read by UUID" },
{ "char-write-req", cmd_char_write_req, "<handle> <new value>",
"Characteristic Value Write (Write Request)" },
+ { "sec-level", cmd_sec_level, "[low | medium | high]",
+ "Set security level. Default: low" },
{ NULL, NULL, NULL}
};