aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kempe <kempe@lysator.liu.se>2025-01-27 13:20:27 +0000
committerBjoern A. Zeeb <bz@FreeBSD.org>2025-01-27 13:27:28 +0000
commit4ae0fa8a2f8bff9a5e96dbfd862b03172c88e697 (patch)
tree63db0c773b1b1f153cfc825fca4dcc010bd85ceb
parentc6767dc1f236f20eecd75790afd42829345153da (diff)
ng_hci: add support for Bluetooth Secure Simple Pairing
Add additional messages that allow for secure simple pairing. PR: 265066 MFC after: 2 weeks Sponsored by: The FreeBSD Foundation (review and commit)
-rw-r--r--sys/netgraph/bluetooth/hci/ng_hci_cmds.c2
-rw-r--r--sys/netgraph/bluetooth/hci/ng_hci_evnt.c2
-rw-r--r--sys/netgraph/bluetooth/include/ng_hci.h78
3 files changed, 82 insertions, 0 deletions
diff --git a/sys/netgraph/bluetooth/hci/ng_hci_cmds.c b/sys/netgraph/bluetooth/hci/ng_hci_cmds.c
index 897a8ed2e917..489ad3a01ee3 100644
--- a/sys/netgraph/bluetooth/hci/ng_hci_cmds.c
+++ b/sys/netgraph/bluetooth/hci/ng_hci_cmds.c
@@ -614,8 +614,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 7d7e1688dcbf..b6836b8843d7 100644
--- a/sys/netgraph/bluetooth/hci/ng_hci_evnt.c
+++ b/sys/netgraph/bluetooth/hci/ng_hci_evnt.c
@@ -120,6 +120,8 @@ 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:
+ case NG_HCI_EVENT_SIMPLE_PAIRING_COMPLETE:
/* 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 e4d33d8661ba..44a14e62f4ed 100644
--- a/sys/netgraph/bluetooth/include/ng_hci.h
+++ b/sys/netgraph/bluetooth/include/ng_hci.h
@@ -114,6 +114,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_SECURE_SIMPLE_PAIRING 0x08
/* Link types */
#define NG_HCI_LINK_SCO 0x00 /* Voice */
@@ -860,6 +862,50 @@ 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;
+
+#define NG_HCI_USER_CONFIRMATION_REQUEST_NEGATIVE_REPLY 0x002d
+typedef struct {
+ bdaddr_t bdaddr;
+} __attribute__((packed)) ng_hci_user_confirmation_request_negative_reply_cp;
+
+typedef struct {
+ u_int8_t status;
+ bdaddr_t bdaddr;
+} __attribute__ ((packed)) ng_hci_user_confirmation_request_negative_reply_rp;
+
+#define NG_HCI_IO_CAPABILITY_REQUEST_NEGATIVE_REPLY 0x0034
+typedef struct {
+ bdaddr_t bdaddr;
+ u_int8_t reason;
+} __attribute__ ((packed)) ng_hci_io_capability_request_negative_reply_cp;
+
+typedef struct {
+ u_int8_t status;
+ bdaddr_t bdaddr;
+} __attribute__ ((packed)) ng_hci_io_capability_request_negative_reply_rp;
+
/**************************************************************************
**************************************************************************
** Link policy commands and return parameters
@@ -1374,6 +1420,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_hci_write_simple_pairing_rp;
+
#define NG_HCI_OCF_READ_LE_HOST_SUPPORTED 0x6c
typedef struct {
u_int8_t status; /* 0x00 - success */
@@ -1389,6 +1442,13 @@ typedef struct {
typedef ng_hci_status_rp ng_hci_write_le_host_supported_rp;
+#define NG_HCI_OCF_WRITE_SECURE_CONNECTIONS_HOST_SUPPORT 0x007a
+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
@@ -2025,6 +2085,24 @@ 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_SIMPLE_PAIRING_COMPLETE 0x36
+typedef struct {
+ u_int8_t status;
+ bdaddr_t bdaddr;
+} __attribute__ ((packed)) ng_hci_simple_pairing_complete_ep;
+
#define NG_HCI_EVENT_LE 0x3e
typedef struct {
u_int8_t subevent_code;