From owner-svn-src-all@freebsd.org Mon Apr 27 02:48:50 2020 Return-Path: Delivered-To: svn-src-all@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 98A7F2C5365; Mon, 27 Apr 2020 02:48:50 +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) server-signature RSA-PSS (4096 bits) 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 499TkB3DClz4HP9; Mon, 27 Apr 2020 02:48:50 +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 657273461; Mon, 27 Apr 2020 02:48:50 +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 03R2moBg085097; Mon, 27 Apr 2020 02:48:50 GMT (envelope-from takawata@FreeBSD.org) Received: (from takawata@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 03R2mo4S085096; Mon, 27 Apr 2020 02:48:50 GMT (envelope-from takawata@FreeBSD.org) Message-Id: <202004270248.03R2mo4S085096@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: takawata set sender to takawata@FreeBSD.org using -f From: Takanori Watanabe Date: Mon, 27 Apr 2020 02:48:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r360360 - 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: 360360 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Apr 2020 02:48:50 -0000 Author: takawata Date: Mon Apr 27 02:48:49 2020 New Revision: 360360 URL: https://svnweb.freebsd.org/changeset/base/360360 Log: Fix advertise packet parsing. Differential Revision: https://reviews.freebsd.org/D21779 Modified: head/usr.sbin/bluetooth/hccontrol/node.c Modified: head/usr.sbin/bluetooth/hccontrol/node.c ============================================================================== --- head/usr.sbin/bluetooth/hccontrol/node.c Mon Apr 27 02:01:48 2020 (r360359) +++ head/usr.sbin/bluetooth/hccontrol/node.c Mon Apr 27 02:48:49 2020 (r360360) @@ -40,6 +40,7 @@ #include #include #include +#include #include "hccontrol.h" /* Send Read_Node_State command to the node */ @@ -222,23 +223,53 @@ static int hci_dump_adv(uint8_t *data, int length) elemlen = *data; data++; length --; - elemlen--; if(length<=0) break; type = *data; data++; length --; elemlen--; - if(length<=0) + if(length <= 0) break; switch(type){ case 0x1: printf("NDflag:%x\n", *data); break; + case 0x8: case 0x9: printf("LocalName:"); for(i = 0; i < MIN(length,elemlen); i++){ putchar(data[i]); + } + printf("\n"); + break; + case 0x6: + case 0x7: + { + uuid_t uuid; + char *uuidstr; + uint32_t ustatus; + if (elemlen < 16) + break; + uuid.time_low = le32dec(data+12); + uuid.time_mid = le16dec(data+10); + uuid.time_hi_and_version = le16dec(data+8); + uuid.clock_seq_hi_and_reserved = data[7]; + uuid.clock_seq_low = data[6]; + for(i = 0; i < _UUID_NODE_LEN; i++){ + uuid.node[i] = data[5 - i]; + } + uuid_to_string(&uuid, &uuidstr, &ustatus); + + printf("ServiceUUID: %s\n", uuidstr); + break; + } + case 0xff: + if (elemlen < 2) + break; + printf("Vendor:%04x:", data[0]|data[1]<<8); + for (i = 2; i < MIN(length,elemlen); i++) { + printf("%02x ",data[i]); } printf("\n"); break;