Skip to content

Commit

Permalink
ng_hci: add support for Bluetooth Secure Simple Pairing
Browse files Browse the repository at this point in the history
Add additional messages that allow for secure simple pairing.

PR:		265066
MFC after:	2 weeks
Sponsored by:	The FreeBSD Foundation (review and commit)
  • Loading branch information
andkem authored and Bjoern A. Zeeb committed Jan 27, 2025
1 parent c6767dc commit 4ae0fa8
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
2 changes: 2 additions & 0 deletions sys/netgraph/bluetooth/hci/ng_hci_cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 2 additions & 0 deletions sys/netgraph/bluetooth/hci/ng_hci_evnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
78 changes: 78 additions & 0 deletions sys/netgraph/bluetooth/include/ng_hci.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 */
Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 4ae0fa8

Please sign in to comment.