📄 hci.h
字号:
} __attribute__ ((packed));struct hci_rp_role_discovery { __u8 status; __le16 handle; __u8 role;} __attribute__ ((packed));#define OCF_READ_LINK_POLICY 0x000Cstruct hci_cp_read_link_policy { __le16 handle;} __attribute__ ((packed));struct hci_rp_read_link_policy { __u8 status; __le16 handle; __le16 policy;} __attribute__ ((packed));#define OCF_SWITCH_ROLE 0x000Bstruct hci_cp_switch_role { bdaddr_t bdaddr; __u8 role;} __attribute__ ((packed));#define OCF_WRITE_LINK_POLICY 0x000Dstruct hci_cp_write_link_policy { __le16 handle; __le16 policy;} __attribute__ ((packed));struct hci_rp_write_link_policy { __u8 status; __le16 handle;} __attribute__ ((packed));/* Status params */#define OGF_STATUS_PARAM 0x05/* Testing commands */#define OGF_TESTING_CMD 0x3E/* Vendor specific commands */#define OGF_VENDOR_CMD 0x3F/* ---- HCI Events ---- */#define HCI_EV_INQUIRY_COMPLETE 0x01#define HCI_EV_INQUIRY_RESULT 0x02struct inquiry_info { bdaddr_t bdaddr; __u8 pscan_rep_mode; __u8 pscan_period_mode; __u8 pscan_mode; __u8 dev_class[3]; __le16 clock_offset;} __attribute__ ((packed));#define HCI_EV_INQUIRY_RESULT_WITH_RSSI 0x22struct inquiry_info_with_rssi { bdaddr_t bdaddr; __u8 pscan_rep_mode; __u8 pscan_period_mode; __u8 dev_class[3]; __le16 clock_offset; __s8 rssi;} __attribute__ ((packed));struct inquiry_info_with_rssi_and_pscan_mode { bdaddr_t bdaddr; __u8 pscan_rep_mode; __u8 pscan_period_mode; __u8 pscan_mode; __u8 dev_class[3]; __le16 clock_offset; __s8 rssi;} __attribute__ ((packed));#define HCI_EV_EXTENDED_INQUIRY_RESULT 0x2Fstruct extended_inquiry_info { bdaddr_t bdaddr; __u8 pscan_rep_mode; __u8 pscan_period_mode; __u8 dev_class[3]; __le16 clock_offset; __s8 rssi; __u8 data[240];} __attribute__ ((packed));#define HCI_EV_CONN_COMPLETE 0x03struct hci_ev_conn_complete { __u8 status; __le16 handle; bdaddr_t bdaddr; __u8 link_type; __u8 encr_mode;} __attribute__ ((packed));#define HCI_EV_CONN_REQUEST 0x04struct hci_ev_conn_request { bdaddr_t bdaddr; __u8 dev_class[3]; __u8 link_type;} __attribute__ ((packed));#define HCI_EV_DISCONN_COMPLETE 0x05struct hci_ev_disconn_complete { __u8 status; __le16 handle; __u8 reason;} __attribute__ ((packed));#define HCI_EV_AUTH_COMPLETE 0x06struct hci_ev_auth_complete { __u8 status; __le16 handle;} __attribute__ ((packed));#define HCI_EV_ENCRYPT_CHANGE 0x08struct hci_ev_encrypt_change { __u8 status; __le16 handle; __u8 encrypt;} __attribute__ ((packed));#define HCI_EV_CHANGE_CONN_LINK_KEY_COMPLETE 0x09struct hci_ev_change_conn_link_key_complete { __u8 status; __le16 handle;} __attribute__ ((packed));#define HCI_EV_QOS_SETUP_COMPLETE 0x0Dstruct hci_qos { __u8 service_type; __u32 token_rate; __u32 peak_bandwidth; __u32 latency; __u32 delay_variation;} __attribute__ ((packed));struct hci_ev_qos_setup_complete { __u8 status; __le16 handle; struct hci_qos qos;} __attribute__ ((packed));#define HCI_EV_CMD_COMPLETE 0x0Estruct hci_ev_cmd_complete { __u8 ncmd; __le16 opcode;} __attribute__ ((packed));#define HCI_EV_CMD_STATUS 0x0Fstruct hci_ev_cmd_status { __u8 status; __u8 ncmd; __le16 opcode;} __attribute__ ((packed));#define HCI_EV_NUM_COMP_PKTS 0x13struct hci_ev_num_comp_pkts { __u8 num_hndl; /* variable length part */} __attribute__ ((packed));#define HCI_EV_ROLE_CHANGE 0x12struct hci_ev_role_change { __u8 status; bdaddr_t bdaddr; __u8 role;} __attribute__ ((packed));#define HCI_EV_MODE_CHANGE 0x14struct hci_ev_mode_change { __u8 status; __le16 handle; __u8 mode; __le16 interval;} __attribute__ ((packed));#define HCI_EV_PIN_CODE_REQ 0x16struct hci_ev_pin_code_req { bdaddr_t bdaddr;} __attribute__ ((packed));#define HCI_EV_LINK_KEY_REQ 0x17struct hci_ev_link_key_req { bdaddr_t bdaddr;} __attribute__ ((packed));#define HCI_EV_LINK_KEY_NOTIFY 0x18struct hci_ev_link_key_notify { bdaddr_t bdaddr; __u8 link_key[16]; __u8 key_type;} __attribute__ ((packed));#define HCI_EV_RMT_FEATURES 0x0Bstruct hci_ev_rmt_features { __u8 status; __le16 handle; __u8 features[8];} __attribute__ ((packed));#define HCI_EV_RMT_VERSION 0x0Cstruct hci_ev_rmt_version { __u8 status; __le16 handle; __u8 lmp_ver; __le16 manufacturer; __le16 lmp_subver;} __attribute__ ((packed));#define HCI_EV_CLOCK_OFFSET 0x01Cstruct hci_ev_clock_offset { __u8 status; __le16 handle; __le16 clock_offset;} __attribute__ ((packed));#define HCI_EV_PSCAN_REP_MODE 0x20struct hci_ev_pscan_rep_mode { bdaddr_t bdaddr; __u8 pscan_rep_mode;} __attribute__ ((packed));/* Internal events generated by Bluetooth stack */#define HCI_EV_STACK_INTERNAL 0xFDstruct hci_ev_stack_internal { __u16 type; __u8 data[0];} __attribute__ ((packed));#define HCI_EV_SI_DEVICE 0x01struct hci_ev_si_device { __u16 event; __u16 dev_id;} __attribute__ ((packed));#define HCI_EV_SI_SECURITY 0x02struct hci_ev_si_security { __u16 event; __u16 proto; __u16 subproto; __u8 incoming;} __attribute__ ((packed));/* ---- HCI Packet structures ---- */#define HCI_COMMAND_HDR_SIZE 3#define HCI_EVENT_HDR_SIZE 2#define HCI_ACL_HDR_SIZE 4#define HCI_SCO_HDR_SIZE 3struct hci_command_hdr { __le16 opcode; /* OCF & OGF */ __u8 plen;} __attribute__ ((packed));struct hci_event_hdr { __u8 evt; __u8 plen;} __attribute__ ((packed));struct hci_acl_hdr { __le16 handle; /* Handle & Flags(PB, BC) */ __le16 dlen;} __attribute__ ((packed));struct hci_sco_hdr { __le16 handle; __u8 dlen;} __attribute__ ((packed));/* Command opcode pack/unpack */#define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10))#define hci_opcode_ogf(op) (op >> 10)#define hci_opcode_ocf(op) (op & 0x03ff)/* ACL handle and flags pack/unpack */#define hci_handle_pack(h, f) (__u16) ((h & 0x0fff)|(f << 12))#define hci_handle(h) (h & 0x0fff)#define hci_flags(h) (h >> 12)/* ---- HCI Sockets ---- *//* Socket options */#define HCI_DATA_DIR 1#define HCI_FILTER 2#define HCI_TIME_STAMP 3/* CMSG flags */#define HCI_CMSG_DIR 0x0001#define HCI_CMSG_TSTAMP 0x0002struct sockaddr_hci { sa_family_t hci_family; unsigned short hci_dev;};#define HCI_DEV_NONE 0xffffstruct hci_filter { unsigned long type_mask; unsigned long event_mask[2]; __u16 opcode;};struct hci_ufilter { __u32 type_mask; __u32 event_mask[2]; __u16 opcode;};#define HCI_FLT_TYPE_BITS 31#define HCI_FLT_EVENT_BITS 63#define HCI_FLT_OGF_BITS 63#define HCI_FLT_OCF_BITS 127/* ---- HCI Ioctl requests structures ---- */struct hci_dev_stats { __u32 err_rx; __u32 err_tx; __u32 cmd_tx; __u32 evt_rx; __u32 acl_tx; __u32 acl_rx; __u32 sco_tx; __u32 sco_rx; __u32 byte_rx; __u32 byte_tx;};struct hci_dev_info { __u16 dev_id; char name[8]; bdaddr_t bdaddr; __u32 flags; __u8 type; __u8 features[8]; __u32 pkt_type; __u32 link_policy; __u32 link_mode; __u16 acl_mtu; __u16 acl_pkts; __u16 sco_mtu; __u16 sco_pkts; struct hci_dev_stats stat;};struct hci_conn_info { __u16 handle; bdaddr_t bdaddr; __u8 type; __u8 out; __u16 state; __u32 link_mode;};struct hci_dev_req { __u16 dev_id; __u32 dev_opt;};struct hci_dev_list_req { __u16 dev_num; struct hci_dev_req dev_req[0]; /* hci_dev_req structures */};struct hci_conn_list_req { __u16 dev_id; __u16 conn_num; struct hci_conn_info conn_info[0];};struct hci_conn_info_req { bdaddr_t bdaddr; __u8 type; struct hci_conn_info conn_info[0];};struct hci_inquiry_req { __u16 dev_id; __u16 flags; __u8 lap[3]; __u8 length; __u8 num_rsp;};#define IREQ_CACHE_FLUSH 0x0001#endif /* __HCI_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -