Date: Tue, 5 Jul 2022 17:35:21 +0200 From: Andreas Kempe <kempe@lysator.liu.se> To: freebsd-bluetooth@freebsd.org Subject: [PATCH]: securesimplepairing@shipon.lysator.liu.se; Message-ID: <YsRaOSK5Kh%2BITc27@shipon.lysator.liu.se>
index | next in thread | raw e-mail
[-- Attachment #1 --]
Hello everyone,
For my bluetooth daemon project, called blued, I wrote a patch that
adds some HCI commands to netgraph to allow for secure simple pairing
to work. I would like to upstream my patch so my software can be used
without the end-user having to patch the kernel. I've attached my
patch for review.
If I need to create an account on Phabricator and supply my patch that
way, I can look into that instead.
Thank you for any feedback on the matter!
Cordially,
Andreas Kempe
[-- Attachment #2 --]
diff --git a/sys/netgraph/bluetooth/hci/ng_hci_cmds.c b/sys/netgraph/bluetooth/hci/ng_hci_cmds.c
index 9bef544cc98..2934206e634 100644
--- a/sys/netgraph/bluetooth/hci/ng_hci_cmds.c
+++ b/sys/netgraph/bluetooth/hci/ng_hci_cmds.c
@@ -615,8 +615,10 @@ process_hc_baseband_params(ng_hci_unit_p unit, u_int16_t ocf,
case NG_HCI_OCF_READ_LOCAL_NAME:
case NG_HCI_OCF_READ_UNIT_CLASS:
case NG_HCI_OCF_WRITE_UNIT_CLASS:
+ case NG_HCI_OCF_WRITE_SIMPLE_PAIRING:
case NG_HCI_OCF_READ_LE_HOST_SUPPORTED:
case NG_HCI_OCF_WRITE_LE_HOST_SUPPORTED:
+ case NG_HCI_OCF_WRITE_SECURE_CONNECTIONS_HOST_SUPPORT:
/* These do not need post processing */
break;
diff --git a/sys/netgraph/bluetooth/hci/ng_hci_evnt.c b/sys/netgraph/bluetooth/hci/ng_hci_evnt.c
index b0dae0e18ec..6bd8f3b7e8c 100644
--- a/sys/netgraph/bluetooth/hci/ng_hci_evnt.c
+++ b/sys/netgraph/bluetooth/hci/ng_hci_evnt.c
@@ -121,6 +121,7 @@ ng_hci_process_event(ng_hci_unit_p unit, struct mbuf *event)
case NG_HCI_EVENT_VENDOR:
case NG_HCI_EVENT_REMOTE_NAME_REQ_COMPL:
case NG_HCI_EVENT_READ_REMOTE_VER_INFO_COMPL:
+ case NG_HCI_EVENT_IO_CAPABILITY_REQUEST:
/* These do not need post processing */
NG_FREE_M(event);
break;
diff --git a/sys/netgraph/bluetooth/include/ng_hci.h b/sys/netgraph/bluetooth/include/ng_hci.h
index ba23ba0563c..3effff8071b 100644
--- a/sys/netgraph/bluetooth/include/ng_hci.h
+++ b/sys/netgraph/bluetooth/include/ng_hci.h
@@ -115,6 +115,8 @@
#define NG_HCI_LMP_FLOW_CONTROL_LAG0 0x10
#define NG_HCI_LMP_FLOW_CONTROL_LAG1 0x20
#define NG_HCI_LMP_FLOW_CONTROL_LAG2 0x40
+/* ------------------- byte 6 --------------------*/
+#define NG_HCI_LMP_SIMPLE_SECURE_CONNECT 0x08
/* Link types */
#define NG_HCI_LINK_SCO 0x00 /* Voice */
@@ -797,6 +799,30 @@ typedef struct {
} __attribute__ ((packed)) ng_hci_read_clock_offset_cp;
/* No return parameter(s) */
+#define NG_HCI_IO_CAPABILITY_REQUEST_REPLY 0x002b
+typedef struct {
+ bdaddr_t bdaddr;
+ u_int8_t io_capability;
+ u_int8_t oob_data_present;
+ u_int8_t authentication_requirements;
+} __attribute__ ((packed)) ng_hci_io_capability_request_reply_cp;
+
+typedef struct {
+ u_int8_t status;
+ bdaddr_t bdaddr;
+} __attribute__ ((packed)) ng_hci_io_capability_request_reply_rp;
+
+#define NG_HCI_USER_CONFIRMATION_REQUEST_REPLY 0x002c
+typedef struct {
+ bdaddr_t bdaddr;
+} __attribute__ ((packed)) ng_hci_user_confirmation_request_reply_cp;
+
+typedef struct {
+ u_int8_t status;
+ bdaddr_t bdaddr;
+} __attribute__ ((packed)) ng_hci_user_confirmation_request_reply_rp;
+
+
/**************************************************************************
**************************************************************************
** Link policy commands and return parameters
@@ -1311,6 +1337,13 @@ typedef struct {
typedef ng_hci_status_rp ng_hci_write_page_scan_rp;
+#define NG_HCI_OCF_WRITE_SIMPLE_PAIRING 0x0056
+typedef struct {
+ u_int8_t simple_pairing; /* 1 -> enabled, 0 -> disabled */
+} __attribute__ ((packed)) ng_hci_write_simple_pairing_cp;
+
+typedef ng_hci_status_rp ng_hcy_write_simple_pairing_rp;
+
#define NG_HCI_OCF_READ_LE_HOST_SUPPORTED 0x6c
typedef struct {
u_int8_t status; /* 0x00 - success */
@@ -1326,6 +1359,13 @@ typedef struct {
typedef ng_hci_status_rp ng_hci_write_le_host_supported_rp;
+#define NG_HCI_OCF_WRITE_SECURE_CONNECTIONS_HOST_SUPPORT 0x7a
+typedef struct {
+ u_int8_t support; /* 0 - disabled, 1 - enabled */
+} __attribute__ ((packed)) ng_hci_write_secure_connections_host_support_cp;
+
+typedef ng_hci_status_rp ng_hci_write_secure_connections_host_support_rp;
+
/**************************************************************************
**************************************************************************
** Informational commands and return parameters
@@ -1800,6 +1840,7 @@ typedef struct {
u_int8_t features[NG_HCI_FEATURES_SIZE]; /* LMP features bitmsk*/
} __attribute__ ((packed)) ng_hci_read_remote_features_compl_ep;
+
#define NG_HCI_EVENT_READ_REMOTE_VER_INFO_COMPL 0x0c
typedef struct {
u_int8_t status; /* 0x00 - success */
@@ -1939,6 +1980,18 @@ typedef struct {
bdaddr_t bdaddr; /* destination address */
u_int8_t page_scan_rep_mode; /* page scan repetition mode */
} __attribute__ ((packed)) ng_hci_page_scan_rep_mode_change_ep;
+
+#define NG_HCI_EVENT_IO_CAPABILITY_REQUEST 0x31
+typedef struct {
+ bdaddr_t bdaddr;
+} __attribute__ ((packed)) ng_hci_io_capability_request_ep;
+
+#define NG_HCI_EVENT_USER_CONFIRMATION_REQUEST 0x33
+typedef struct {
+ bdaddr_t bdaddr;
+ u_int32_t numeric_value;
+} __attribute__ ((packed)) ng_hci_user_confirmation_request_ep;
+
#define NG_HCI_EVENT_LE 0x3e
typedef struct {
u_int8_t subevent_code;
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?YsRaOSK5Kh%2BITc27>
