diff options
author | Takanori Watanabe <takawata@FreeBSD.org> | 2020-07-08 03:57:47 +0000 |
---|---|---|
committer | Takanori Watanabe <takawata@FreeBSD.org> | 2020-07-08 03:57:47 +0000 |
commit | 21056112363fe9baf4ce69b9b4d53ea31bfba17e (patch) | |
tree | e9b63f5d68f79604da447c82b7409d850f595af8 /usr.sbin/bluetooth | |
parent | 3eaf03766e0b56263c55750eaee4b7b74f91c99a (diff) | |
download | src-test2-21056112363fe9baf4ce69b9b4d53ea31bfba17e.tar.gz src-test2-21056112363fe9baf4ce69b9b4d53ea31bfba17e.zip |
Add le_rand command.
PR: 247808
Submitted by: Marc Veldman
Notes
Notes:
svn path=/head/; revision=363002
Diffstat (limited to 'usr.sbin/bluetooth')
-rw-r--r-- | usr.sbin/bluetooth/hccontrol/hccontrol.8 | 1 | ||||
-rw-r--r-- | usr.sbin/bluetooth/hccontrol/le.c | 32 |
2 files changed, 33 insertions, 0 deletions
diff --git a/usr.sbin/bluetooth/hccontrol/hccontrol.8 b/usr.sbin/bluetooth/hccontrol/hccontrol.8 index 95ad885624ea..24b8028adba8 100644 --- a/usr.sbin/bluetooth/hccontrol/hccontrol.8 +++ b/usr.sbin/bluetooth/hccontrol/hccontrol.8 @@ -164,6 +164,7 @@ are: .It Cm LE_Connect .It Cm LE_Read_Channel_Map .It Cm LE_Read_Remote_Features +.It Cm LE_Rand .El .Pp The currently supported node commands in diff --git a/usr.sbin/bluetooth/hccontrol/le.c b/usr.sbin/bluetooth/hccontrol/le.c index 6b3d3a2b3fe1..ba8809213c06 100644 --- a/usr.sbin/bluetooth/hccontrol/le.c +++ b/usr.sbin/bluetooth/hccontrol/le.c @@ -71,6 +71,7 @@ static int le_connect(int s, int argc, char *argv[]); static void handle_le_connection_event(ng_hci_event_pkt_t* e, bool verbose); static int le_read_channel_map(int s, int argc, char *argv[]); static void handle_le_remote_features_event(ng_hci_event_pkt_t* e); +static int le_rand(int s, int argc, char *argv[]); static int le_set_scan_param(int s, int argc, char *argv[]) @@ -1211,6 +1212,31 @@ static void handle_le_remote_features_event(ng_hci_event_pkt_t* e) return; } /* handle_le_remote_features_event */ +static int le_rand(int s, int argc, char *argv[]) +{ + ng_hci_le_rand_rp rp; + int n; + + n = sizeof(rp); + + if (hci_simple_request(s, NG_HCI_OPCODE(NG_HCI_OGF_LE, + NG_HCI_OCF_LE_RAND), + (void *)&rp, &n) == ERROR) + return (ERROR); + + if (rp.status != 0x00) { + fprintf(stdout, "Status: %s [%#02x]\n", + hci_status2str(rp.status), rp.status); + return (FAILED); + } + + fprintf(stdout, + "Random number : %08llx\n", + (unsigned long long)le64toh(rp.random_number)); + + return (OK); +} + struct hci_command le_commands[] = { @@ -1336,4 +1362,10 @@ struct hci_command le_commands[] = { "identified by the connection handle", &le_read_remote_features }, + { + "le_rand", + "le_rand\n" + "Generate 64 bits of random data", + &le_rand + }, }; |