From owner-svn-src-head@freebsd.org Wed Jul 8 03:57:48 2020 Return-Path: Delivered-To: svn-src-head@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 2668E355275; Wed, 8 Jul 2020 03:57:48 +0000 (UTC) (envelope-from takawata@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4B1lrX0Crfz4SRh; Wed, 8 Jul 2020 03:57:48 +0000 (UTC) (envelope-from takawata@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DE1F91A70A; Wed, 8 Jul 2020 03:57:47 +0000 (UTC) (envelope-from takawata@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0683vldG000596; Wed, 8 Jul 2020 03:57:47 GMT (envelope-from takawata@FreeBSD.org) Received: (from takawata@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0683vlm5000595; Wed, 8 Jul 2020 03:57:47 GMT (envelope-from takawata@FreeBSD.org) Message-Id: <202007080357.0683vlm5000595@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: takawata set sender to takawata@FreeBSD.org using -f From: Takanori Watanabe Date: Wed, 8 Jul 2020 03:57:47 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r363002 - head/usr.sbin/bluetooth/hccontrol X-SVN-Group: head X-SVN-Commit-Author: takawata X-SVN-Commit-Paths: head/usr.sbin/bluetooth/hccontrol X-SVN-Commit-Revision: 363002 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Jul 2020 03:57:48 -0000 Author: takawata Date: Wed Jul 8 03:57:47 2020 New Revision: 363002 URL: https://svnweb.freebsd.org/changeset/base/363002 Log: Add le_rand command. PR: 247808 Submitted by: Marc Veldman Modified: head/usr.sbin/bluetooth/hccontrol/hccontrol.8 head/usr.sbin/bluetooth/hccontrol/le.c Modified: head/usr.sbin/bluetooth/hccontrol/hccontrol.8 ============================================================================== --- head/usr.sbin/bluetooth/hccontrol/hccontrol.8 Wed Jul 8 02:28:08 2020 (r363001) +++ head/usr.sbin/bluetooth/hccontrol/hccontrol.8 Wed Jul 8 03:57:47 2020 (r363002) @@ -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 Modified: head/usr.sbin/bluetooth/hccontrol/le.c ============================================================================== --- head/usr.sbin/bluetooth/hccontrol/le.c Wed Jul 8 02:28:08 2020 (r363001) +++ head/usr.sbin/bluetooth/hccontrol/le.c Wed Jul 8 03:57:47 2020 (r363002) @@ -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,8 +1212,33 @@ static void handle_le_remote_features_event(ng_hci_eve 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[] = { { "le_enable", @@ -1335,5 +1361,11 @@ struct hci_command le_commands[] = { "Read supported features for the device\n" "identified by the connection handle", &le_read_remote_features + }, + { + "le_rand", + "le_rand\n" + "Generate 64 bits of random data", + &le_rand }, };