Commit 26872595 authored by Maksim Krasnyanskiy's avatar Maksim Krasnyanskiy

Just like many other parts of the kernel Bluetooth code was abusing

typedefs for non opaque objects. This Changeset cleanups Bluetoth HCI
code and headers.
parent 781e3f1e
...@@ -149,9 +149,9 @@ static int h4_recv(struct hci_uart *hu, void *data, int count) ...@@ -149,9 +149,9 @@ static int h4_recv(struct hci_uart *hu, void *data, int count)
{ {
struct h4_struct *h4 = hu->priv; struct h4_struct *h4 = hu->priv;
register char *ptr; register char *ptr;
hci_event_hdr *eh; struct hci_event_hdr *eh;
hci_acl_hdr *ah; struct hci_acl_hdr *ah;
hci_sco_hdr *sh; struct hci_sco_hdr *sh;
register int len, type, dlen; register int len, type, dlen;
BT_DBG("hu %p count %d rx_state %ld rx_count %ld", BT_DBG("hu %p count %d rx_state %ld rx_count %ld",
...@@ -180,7 +180,7 @@ static int h4_recv(struct hci_uart *hu, void *data, int count) ...@@ -180,7 +180,7 @@ static int h4_recv(struct hci_uart *hu, void *data, int count)
continue; continue;
case H4_W4_EVENT_HDR: case H4_W4_EVENT_HDR:
eh = (hci_event_hdr *) h4->rx_skb->data; eh = (struct hci_event_hdr *) h4->rx_skb->data;
BT_DBG("Event header: evt 0x%2.2x plen %d", eh->evt, eh->plen); BT_DBG("Event header: evt 0x%2.2x plen %d", eh->evt, eh->plen);
...@@ -188,7 +188,7 @@ static int h4_recv(struct hci_uart *hu, void *data, int count) ...@@ -188,7 +188,7 @@ static int h4_recv(struct hci_uart *hu, void *data, int count)
continue; continue;
case H4_W4_ACL_HDR: case H4_W4_ACL_HDR:
ah = (hci_acl_hdr *) h4->rx_skb->data; ah = (struct hci_acl_hdr *) h4->rx_skb->data;
dlen = __le16_to_cpu(ah->dlen); dlen = __le16_to_cpu(ah->dlen);
BT_DBG("ACL header: dlen %d", dlen); BT_DBG("ACL header: dlen %d", dlen);
...@@ -197,7 +197,7 @@ static int h4_recv(struct hci_uart *hu, void *data, int count) ...@@ -197,7 +197,7 @@ static int h4_recv(struct hci_uart *hu, void *data, int count)
continue; continue;
case H4_W4_SCO_HDR: case H4_W4_SCO_HDR:
sh = (hci_sco_hdr *) h4->rx_skb->data; sh = (struct hci_sco_hdr *) h4->rx_skb->data;
BT_DBG("SCO header: dlen %d", sh->dlen); BT_DBG("SCO header: dlen %d", sh->dlen);
......
...@@ -434,7 +434,7 @@ static void hci_usb_interrupt(struct urb *urb) ...@@ -434,7 +434,7 @@ static void hci_usb_interrupt(struct urb *urb)
struct hci_usb *husb = (void *) urb->context; struct hci_usb *husb = (void *) urb->context;
struct hci_usb_scb *scb; struct hci_usb_scb *scb;
struct sk_buff *skb; struct sk_buff *skb;
hci_event_hdr *eh; struct hci_event_hdr *eh;
__u8 *data = urb->transfer_buffer; __u8 *data = urb->transfer_buffer;
int count = urb->actual_length; int count = urb->actual_length;
int len = HCI_EVENT_HDR_SIZE; int len = HCI_EVENT_HDR_SIZE;
...@@ -459,7 +459,7 @@ static void hci_usb_interrupt(struct urb *urb) ...@@ -459,7 +459,7 @@ static void hci_usb_interrupt(struct urb *urb)
if (count < HCI_EVENT_HDR_SIZE) if (count < HCI_EVENT_HDR_SIZE)
goto bad_len; goto bad_len;
eh = (hci_event_hdr *) data; eh = (struct hci_event_hdr *) data;
len = eh->plen + HCI_EVENT_HDR_SIZE; len = eh->plen + HCI_EVENT_HDR_SIZE;
if (count > len) if (count > len)
...@@ -545,7 +545,7 @@ static void hci_usb_rx_complete(struct urb *urb) ...@@ -545,7 +545,7 @@ static void hci_usb_rx_complete(struct urb *urb)
struct hci_dev *hdev = (struct hci_dev *) skb->dev; struct hci_dev *hdev = (struct hci_dev *) skb->dev;
struct hci_usb *husb = (struct hci_usb *) hdev->driver_data; struct hci_usb *husb = (struct hci_usb *) hdev->driver_data;
int status, count = urb->actual_length; int status, count = urb->actual_length;
hci_acl_hdr *ah; struct hci_acl_hdr *ah;
int dlen, size; int dlen, size;
BT_DBG("%s urb %p status %d count %d flags %x", husb->hdev.name, urb, BT_DBG("%s urb %p status %d count %d flags %x", husb->hdev.name, urb,
...@@ -561,7 +561,7 @@ static void hci_usb_rx_complete(struct urb *urb) ...@@ -561,7 +561,7 @@ static void hci_usb_rx_complete(struct urb *urb)
husb->hdev.stat.byte_rx += count; husb->hdev.stat.byte_rx += count;
ah = (hci_acl_hdr *) skb->data; ah = (struct hci_acl_hdr *) skb->data;
dlen = __le16_to_cpu(ah->dlen); dlen = __le16_to_cpu(ah->dlen);
size = HCI_ACL_HDR_SIZE + dlen; size = HCI_ACL_HDR_SIZE + dlen;
......
...@@ -160,43 +160,42 @@ enum { ...@@ -160,43 +160,42 @@ enum {
#define HCI_LM_ENCRYPT 0x0004 #define HCI_LM_ENCRYPT 0x0004
#define HCI_LM_TRUSTED 0x0008 #define HCI_LM_TRUSTED 0x0008
/* ----- HCI Commands ----- */ /* ----- HCI Commands ---- */
/* OGF & OCF values */ /* OGF & OCF values */
/* Informational Parameters */ /* Informational Parameters */
#define OGF_INFO_PARAM 0x04 #define OGF_INFO_PARAM 0x04
#define OCF_READ_LOCAL_VERSION 0x0001 #define OCF_READ_LOCAL_VERSION 0x0001
typedef struct { struct read_local_version_rp {
__u8 status; __u8 status;
__u8 hci_ver; __u8 hci_ver;
__u16 hci_rev; __u16 hci_rev;
__u8 lmp_ver; __u8 lmp_ver;
__u16 manufacturer; __u16 manufacturer;
__u16 lmp_subver; __u16 lmp_subver;
} __attribute__ ((packed)) read_local_version_rp; } __attribute__ ((packed));
#define READ_LOCAL_VERSION_RP_SIZE 9
#define OCF_READ_LOCAL_FEATURES 0x0003 #define OCF_READ_LOCAL_FEATURES 0x0003
typedef struct { struct read_local_features_rp {
__u8 status; __u8 status;
__u8 features[8]; __u8 features[8];
} __attribute__ ((packed)) read_local_features_rp; } __attribute__ ((packed));
#define OCF_READ_BUFFER_SIZE 0x0005 #define OCF_READ_BUFFER_SIZE 0x0005
typedef struct { struct read_buffer_size_rp {
__u8 status; __u8 status;
__u16 acl_mtu; __u16 acl_mtu;
__u8 sco_mtu; __u8 sco_mtu;
__u16 acl_max_pkt; __u16 acl_max_pkt;
__u16 sco_max_pkt; __u16 sco_max_pkt;
} __attribute__ ((packed)) read_buffer_size_rp; } __attribute__ ((packed));
#define OCF_READ_BD_ADDR 0x0009 #define OCF_READ_BD_ADDR 0x0009
typedef struct { struct read_bd_addr_rp {
__u8 status; __u8 status;
bdaddr_t bdaddr; bdaddr_t bdaddr;
} __attribute__ ((packed)) read_bd_addr_rp; } __attribute__ ((packed));
/* Host Controller and Baseband */ /* Host Controller and Baseband */
#define OGF_HOST_CTL 0x03 #define OGF_HOST_CTL 0x03
...@@ -221,12 +220,11 @@ typedef struct { ...@@ -221,12 +220,11 @@ typedef struct {
#define SCAN_PAGE 0x02 #define SCAN_PAGE 0x02
#define OCF_SET_EVENT_FLT 0x0005 #define OCF_SET_EVENT_FLT 0x0005
typedef struct { struct set_event_flt_cp {
__u8 flt_type; __u8 flt_type;
__u8 cond_type; __u8 cond_type;
__u8 condition[0]; __u8 condition[0];
} __attribute__ ((packed)) set_event_flt_cp; } __attribute__ ((packed));
#define SET_EVENT_FLT_CP_SIZE 2
/* Filter types */ /* Filter types */
#define FLT_CLEAR_ALL 0x00 #define FLT_CLEAR_ALL 0x00
...@@ -242,198 +240,147 @@ typedef struct { ...@@ -242,198 +240,147 @@ typedef struct {
#define CONN_SETUP_AUTO_OFF 0x01 #define CONN_SETUP_AUTO_OFF 0x01
#define CONN_SETUP_AUTO_ON 0x02 #define CONN_SETUP_AUTO_ON 0x02
#define OCF_CHANGE_LOCAL_NAME 0x0013
typedef struct {
__u8 name[248];
} __attribute__ ((packed)) change_local_name_cp;
#define CHANGE_LOCAL_NAME_CP_SIZE 248
#define OCF_READ_LOCAL_NAME 0x0014
typedef struct {
__u8 status;
__u8 name[248];
} __attribute__ ((packed)) read_local_name_rp;
#define READ_LOCAL_NAME_RP_SIZE 249
#define OCF_READ_CLASS_OF_DEV 0x0023 #define OCF_READ_CLASS_OF_DEV 0x0023
typedef struct { struct read_class_of_dev_rp {
__u8 status; __u8 status;
__u8 dev_class[3]; __u8 dev_class[3];
} __attribute__ ((packed)) read_class_of_dev_rp; } __attribute__ ((packed));
#define READ_CLASS_OF_DEV_RP_SIZE 4
#define OCF_WRITE_CLASS_OF_DEV 0x0024 #define OCF_WRITE_CLASS_OF_DEV 0x0024
typedef struct { struct write_class_of_dev_cp {
__u8 dev_class[3]; __u8 dev_class[3];
} __attribute__ ((packed)) write_class_of_dev_cp; } __attribute__ ((packed));
#define WRITE_CLASS_OF_DEV_CP_SIZE 3
#define OCF_HOST_BUFFER_SIZE 0x0033 #define OCF_HOST_BUFFER_SIZE 0x0033
typedef struct { struct host_buffer_size_cp {
__u16 acl_mtu; __u16 acl_mtu;
__u8 sco_mtu; __u8 sco_mtu;
__u16 acl_max_pkt; __u16 acl_max_pkt;
__u16 sco_max_pkt; __u16 sco_max_pkt;
} __attribute__ ((packed)) host_buffer_size_cp; } __attribute__ ((packed));
#define HOST_BUFFER_SIZE_CP_SIZE 7
/* Link Control */ /* Link Control */
#define OGF_LINK_CTL 0x01 #define OGF_LINK_CTL 0x01
#define OCF_CREATE_CONN 0x0005 #define OCF_CREATE_CONN 0x0005
typedef struct { struct create_conn_cp {
bdaddr_t bdaddr; bdaddr_t bdaddr;
__u16 pkt_type; __u16 pkt_type;
__u8 pscan_rep_mode; __u8 pscan_rep_mode;
__u8 pscan_mode; __u8 pscan_mode;
__u16 clock_offset; __u16 clock_offset;
__u8 role_switch; __u8 role_switch;
} __attribute__ ((packed)) create_conn_cp; } __attribute__ ((packed));
#define CREATE_CONN_CP_SIZE 13
#define OCF_ACCEPT_CONN_REQ 0x0009 #define OCF_ACCEPT_CONN_REQ 0x0009
typedef struct { struct accept_conn_req_cp {
bdaddr_t bdaddr; bdaddr_t bdaddr;
__u8 role; __u8 role;
} __attribute__ ((packed)) accept_conn_req_cp; } __attribute__ ((packed));
#define ACCEPT_CONN_REQ_CP_SIZE 7
#define OCF_REJECT_CONN_REQ 0x000a #define OCF_REJECT_CONN_REQ 0x000a
typedef struct { struct reject_conn_req_cp {
bdaddr_t bdaddr; bdaddr_t bdaddr;
__u8 reason; __u8 reason;
} __attribute__ ((packed)) reject_conn_req_cp; } __attribute__ ((packed));
#define REJECT_CONN_REQ_CP_SIZE 7
#define OCF_DISCONNECT 0x0006 #define OCF_DISCONNECT 0x0006
typedef struct { struct disconnect_cp {
__u16 handle; __u16 handle;
__u8 reason; __u8 reason;
} __attribute__ ((packed)) disconnect_cp; } __attribute__ ((packed));
#define DISCONNECT_CP_SIZE 3
#define OCF_ADD_SCO 0x0007 #define OCF_ADD_SCO 0x0007
typedef struct { struct add_sco_cp {
__u16 handle; __u16 handle;
__u16 pkt_type; __u16 pkt_type;
} __attribute__ ((packed)) add_sco_cp; } __attribute__ ((packed));
#define ADD_SCO_CP_SIZE 4
#define OCF_INQUIRY 0x0001 #define OCF_INQUIRY 0x0001
typedef struct { struct inquiry_cp {
__u8 lap[3]; __u8 lap[3];
__u8 length; __u8 length;
__u8 num_rsp; __u8 num_rsp;
} __attribute__ ((packed)) inquiry_cp; } __attribute__ ((packed));
#define INQUIRY_CP_SIZE 5
typedef struct {
__u8 status;
bdaddr_t bdaddr;
} __attribute__ ((packed)) status_bdaddr_rp;
#define STATUS_BDADDR_RP_SIZE 7
#define OCF_LINK_KEY_REPLY 0x000B #define OCF_LINK_KEY_REPLY 0x000B
#define OCF_LINK_KEY_NEG_REPLY 0x000C #define OCF_LINK_KEY_NEG_REPLY 0x000C
typedef struct { struct link_key_reply_cp {
bdaddr_t bdaddr; bdaddr_t bdaddr;
__u8 link_key[16]; __u8 link_key[16];
} __attribute__ ((packed)) link_key_reply_cp; } __attribute__ ((packed));
#define LINK_KEY_REPLY_CP_SIZE 22
#define OCF_PIN_CODE_REPLY 0x000D #define OCF_PIN_CODE_REPLY 0x000D
#define OCF_PIN_CODE_NEG_REPLY 0x000E #define OCF_PIN_CODE_NEG_REPLY 0x000E
typedef struct { struct pin_code_reply_cp {
bdaddr_t bdaddr; bdaddr_t bdaddr;
__u8 pin_len; __u8 pin_len;
__u8 pin_code[16]; __u8 pin_code[16];
} __attribute__ ((packed)) pin_code_reply_cp; } __attribute__ ((packed));
#define PIN_CODE_REPLY_CP_SIZE 23
#define OCF_CHANGE_CONN_PTYPE 0x000F #define OCF_CHANGE_CONN_PTYPE 0x000F
typedef struct { struct change_conn_ptype_cp {
__u16 handle; __u16 handle;
__u16 pkt_type; __u16 pkt_type;
} __attribute__ ((packed)) change_conn_ptype_cp; } __attribute__ ((packed));
#define CHANGE_CONN_PTYPE_CP_SIZE 4
#define OCF_AUTH_REQUESTED 0x0011 #define OCF_AUTH_REQUESTED 0x0011
typedef struct { struct auth_requested_cp {
__u16 handle; __u16 handle;
} __attribute__ ((packed)) auth_requested_cp; } __attribute__ ((packed));
#define AUTH_REQUESTED_CP_SIZE 2
#define OCF_SET_CONN_ENCRYPT 0x0013 #define OCF_SET_CONN_ENCRYPT 0x0013
typedef struct { struct set_conn_encrypt_cp {
__u16 handle; __u16 handle;
__u8 encrypt; __u8 encrypt;
} __attribute__ ((packed)) set_conn_encrypt_cp; } __attribute__ ((packed));
#define SET_CONN_ENCRYPT_CP_SIZE 3
#define OCF_REMOTE_NAME_REQ 0x0019
typedef struct {
bdaddr_t bdaddr;
__u8 pscan_rep_mode;
__u8 pscan_mode;
__u16 clock_offset;
} __attribute__ ((packed)) remote_name_req_cp;
#define REMOTE_NAME_REQ_CP_SIZE 10
#define OCF_READ_REMOTE_FEATURES 0x001B #define OCF_READ_REMOTE_FEATURES 0x001B
typedef struct { struct read_remote_features_cp {
__u16 handle; __u16 handle;
} __attribute__ ((packed)) read_remote_features_cp; } __attribute__ ((packed));
#define READ_REMOTE_FEATURES_CP_SIZE 2
#define OCF_READ_REMOTE_VERSION 0x001D #define OCF_READ_REMOTE_VERSION 0x001D
typedef struct { struct read_remote_version_cp {
__u16 handle; __u16 handle;
} __attribute__ ((packed)) read_remote_version_cp; } __attribute__ ((packed));
#define READ_REMOTE_VERSION_CP_SIZE 2
/* Link Policy */ /* Link Policy */
#define OGF_LINK_POLICY 0x02 #define OGF_LINK_POLICY 0x02
#define OCF_ROLE_DISCOVERY 0x0009 #define OCF_ROLE_DISCOVERY 0x0009
typedef struct { struct role_discovery_cp {
__u16 handle; __u16 handle;
} __attribute__ ((packed)) role_discovery_cp; } __attribute__ ((packed));
#define ROLE_DISCOVERY_CP_SIZE 2 struct role_discovery_rp {
typedef struct {
__u8 status; __u8 status;
__u16 handle; __u16 handle;
__u8 role; __u8 role;
} __attribute__ ((packed)) role_discovery_rp; } __attribute__ ((packed));
#define ROLE_DISCOVERY_RP_SIZE 4
#define OCF_READ_LINK_POLICY 0x000C #define OCF_READ_LINK_POLICY 0x000C
typedef struct { struct read_link_policy_cp {
__u16 handle; __u16 handle;
} __attribute__ ((packed)) read_link_policy_cp; } __attribute__ ((packed));
#define READ_LINK_POLICY_CP_SIZE 2 struct read_link_policy_rp {
typedef struct {
__u8 status; __u8 status;
__u16 handle; __u16 handle;
__u16 policy; __u16 policy;
} __attribute__ ((packed)) read_link_policy_rp; } __attribute__ ((packed));
#define READ_LINK_POLICY_RP_SIZE 5
#define OCF_SWITCH_ROLE 0x000B #define OCF_SWITCH_ROLE 0x000B
typedef struct { struct switch_role_cp {
bdaddr_t bdaddr; bdaddr_t bdaddr;
__u8 role; __u8 role;
} __attribute__ ((packed)) switch_role_cp; } __attribute__ ((packed));
#define SWITCH_ROLE_CP_SIZE 7
#define OCF_WRITE_LINK_POLICY 0x000D #define OCF_WRITE_LINK_POLICY 0x000D
typedef struct { struct write_link_policy_cp {
__u16 handle; __u16 handle;
__u16 policy; __u16 policy;
} __attribute__ ((packed)) write_link_policy_cp; } __attribute__ ((packed));
#define WRITE_LINK_POLICY_CP_SIZE 4 struct write_link_policy_rp {
typedef struct {
__u8 status; __u8 status;
__u16 handle; __u16 handle;
} __attribute__ ((packed)) write_link_policy_rp; } __attribute__ ((packed));
#define WRITE_LINK_POLICY_RP_SIZE 3
/* Status params */ /* Status params */
#define OGF_STATUS_PARAM 0x05 #define OGF_STATUS_PARAM 0x05
...@@ -442,197 +389,170 @@ typedef struct { ...@@ -442,197 +389,170 @@ typedef struct {
#define EVT_INQUIRY_COMPLETE 0x01 #define EVT_INQUIRY_COMPLETE 0x01
#define EVT_INQUIRY_RESULT 0x02 #define EVT_INQUIRY_RESULT 0x02
typedef struct { struct inquiry_info {
bdaddr_t bdaddr; bdaddr_t bdaddr;
__u8 pscan_rep_mode; __u8 pscan_rep_mode;
__u8 pscan_period_mode; __u8 pscan_period_mode;
__u8 pscan_mode; __u8 pscan_mode;
__u8 dev_class[3]; __u8 dev_class[3];
__u16 clock_offset; __u16 clock_offset;
} __attribute__ ((packed)) inquiry_info; } __attribute__ ((packed));
#define INQUIRY_INFO_SIZE 14
#define EVT_CONN_COMPLETE 0x03 #define EVT_CONN_COMPLETE 0x03
typedef struct { struct evt_conn_complete {
__u8 status; __u8 status;
__u16 handle; __u16 handle;
bdaddr_t bdaddr; bdaddr_t bdaddr;
__u8 link_type; __u8 link_type;
__u8 encr_mode; __u8 encr_mode;
} __attribute__ ((packed)) evt_conn_complete; } __attribute__ ((packed));
#define EVT_CONN_COMPLETE_SIZE 13
#define EVT_CONN_REQUEST 0x04 #define EVT_CONN_REQUEST 0x04
typedef struct { struct evt_conn_request {
bdaddr_t bdaddr; bdaddr_t bdaddr;
__u8 dev_class[3]; __u8 dev_class[3];
__u8 link_type; __u8 link_type;
} __attribute__ ((packed)) evt_conn_request; } __attribute__ ((packed));
#define EVT_CONN_REQUEST_SIZE 10
#define EVT_DISCONN_COMPLETE 0x05 #define EVT_DISCONN_COMPLETE 0x05
typedef struct { struct evt_disconn_complete {
__u8 status; __u8 status;
__u16 handle; __u16 handle;
__u8 reason; __u8 reason;
} __attribute__ ((packed)) evt_disconn_complete; } __attribute__ ((packed));
#define EVT_DISCONN_COMPLETE_SIZE 4
#define EVT_AUTH_COMPLETE 0x06 #define EVT_AUTH_COMPLETE 0x06
typedef struct { struct evt_auth_complete {
__u8 status; __u8 status;
__u16 handle; __u16 handle;
} __attribute__ ((packed)) evt_auth_complete; } __attribute__ ((packed));
#define EVT_AUTH_COMPLETE_SIZE 3
#define EVT_REMOTE_NAME_REQ_COMPLETE 0x07
typedef struct {
__u8 status;
bdaddr_t bdaddr;
__u8 name[248];
} __attribute__ ((packed)) evt_remote_name_req_complete;
#define EVT_REMOTE_NAME_REQ_COMPLETE_SIZE 255
#define EVT_ENCRYPT_CHANGE 0x08 #define EVT_ENCRYPT_CHANGE 0x08
typedef struct { struct evt_encrypt_change {
__u8 status; __u8 status;
__u16 handle; __u16 handle;
__u8 encrypt; __u8 encrypt;
} __attribute__ ((packed)) evt_encrypt_change; } __attribute__ ((packed));
#define EVT_ENCRYPT_CHANGE_SIZE 5
#define EVT_QOS_SETUP_COMPLETE 0x0D #define EVT_QOS_SETUP_COMPLETE 0x0D
typedef struct { struct hci_qos {
__u8 service_type; __u8 service_type;
__u32 token_rate; __u32 token_rate;
__u32 peak_bandwidth; __u32 peak_bandwidth;
__u32 latency; __u32 latency;
__u32 delay_variation; __u32 delay_variation;
} __attribute__ ((packed)) hci_qos; } __attribute__ ((packed));
typedef struct { struct evt_qos_setup_complete {
__u8 status; __u8 status;
__u16 handle; __u16 handle;
hci_qos qos; struct hci_qos qos;
} __attribute__ ((packed)) evt_qos_setup_complete; } __attribute__ ((packed));
#define EVT_QOS_SETUP_COMPLETE_SIZE 20
#define EVT_CMD_COMPLETE 0x0e #define EVT_CMD_COMPLETE 0x0e
typedef struct { struct evt_cmd_complete {
__u8 ncmd; __u8 ncmd;
__u16 opcode; __u16 opcode;
} __attribute__ ((packed)) evt_cmd_complete; } __attribute__ ((packed));
#define EVT_CMD_COMPLETE_SIZE 3
#define EVT_CMD_STATUS 0x0f #define EVT_CMD_STATUS 0x0f
typedef struct { struct evt_cmd_status {
__u8 status; __u8 status;
__u8 ncmd; __u8 ncmd;
__u16 opcode; __u16 opcode;
} __attribute__ ((packed)) evt_cmd_status; } __attribute__ ((packed));
#define EVT_CMD_STATUS_SIZE 4
#define EVT_NUM_COMP_PKTS 0x13 #define EVT_NUM_COMP_PKTS 0x13
typedef struct { struct evt_num_comp_pkts {
__u8 num_hndl; __u8 num_hndl;
/* variable length part */ /* variable length part */
} __attribute__ ((packed)) evt_num_comp_pkts; } __attribute__ ((packed));
#define EVT_NUM_COMP_PKTS_SIZE 1
#define EVT_ROLE_CHANGE 0x12 #define EVT_ROLE_CHANGE 0x12
typedef struct { struct evt_role_change {
__u8 status; __u8 status;
bdaddr_t bdaddr; bdaddr_t bdaddr;
__u8 role; __u8 role;
} __attribute__ ((packed)) evt_role_change; } __attribute__ ((packed));
#define EVT_ROLE_CHANGE_SIZE 8
#define EVT_PIN_CODE_REQ 0x16 #define EVT_PIN_CODE_REQ 0x16
typedef struct { struct evt_pin_code_req {
bdaddr_t bdaddr; bdaddr_t bdaddr;
} __attribute__ ((packed)) evt_pin_code_req; } __attribute__ ((packed));
#define EVT_PIN_CODE_REQ_SIZE 6
#define EVT_LINK_KEY_REQ 0x17 #define EVT_LINK_KEY_REQ 0x17
typedef struct { struct evt_link_key_req {
bdaddr_t bdaddr; bdaddr_t bdaddr;
} __attribute__ ((packed)) evt_link_key_req; } __attribute__ ((packed));
#define EVT_LINK_KEY_REQ_SIZE 6
#define EVT_LINK_KEY_NOTIFY 0x18 #define EVT_LINK_KEY_NOTIFY 0x18
typedef struct { struct evt_link_key_notify {
bdaddr_t bdaddr; bdaddr_t bdaddr;
__u8 link_key[16]; __u8 link_key[16];
__u8 key_type; __u8 key_type;
} __attribute__ ((packed)) evt_link_key_notify; } __attribute__ ((packed));
#define EVT_LINK_KEY_NOTIFY_SIZE 23
#define EVT_READ_REMOTE_FEATURES_COMPLETE 0x0B #define EVT_READ_REMOTE_FEATURES_COMPLETE 0x0B
typedef struct { struct evt_read_remote_features_complete {
__u8 status; __u8 status;
__u16 handle; __u16 handle;
__u8 features[8]; __u8 features[8];
} __attribute__ ((packed)) evt_read_remote_features_complete; } __attribute__ ((packed));
#define EVT_READ_REMOTE_FEATURES_COMPLETE_SIZE 11
#define EVT_READ_REMOTE_VERSION_COMPLETE 0x0C #define EVT_READ_REMOTE_VERSION_COMPLETE 0x0C
typedef struct { struct evt_read_remote_version_complete {
__u8 status; __u8 status;
__u16 handle; __u16 handle;
__u8 lmp_ver; __u8 lmp_ver;
__u16 manufacturer; __u16 manufacturer;
__u16 lmp_subver; __u16 lmp_subver;
} __attribute__ ((packed)) evt_read_remote_version_complete; } __attribute__ ((packed));
#define EVT_READ_REMOTE_VERSION_COMPLETE_SIZE 8
/* Internal events generated by Bluetooth stack */ /* Internal events generated by Bluetooth stack */
#define EVT_STACK_INTERNAL 0xfd #define EVT_STACK_INTERNAL 0xfd
typedef struct { struct evt_stack_internal {
__u16 type; __u16 type;
__u8 data[0]; __u8 data[0];
} __attribute__ ((packed)) evt_stack_internal; } __attribute__ ((packed));
#define EVT_STACK_INTERNAL_SIZE 2
#define EVT_SI_DEVICE 0x01 #define EVT_SI_DEVICE 0x01
typedef struct { struct evt_si_device {
__u16 event; __u16 event;
__u16 dev_id; __u16 dev_id;
} __attribute__ ((packed)) evt_si_device; } __attribute__ ((packed));
#define EVT_SI_DEVICE_SIZE 4
#define EVT_SI_SECURITY 0x02 #define EVT_SI_SECURITY 0x02
typedef struct { struct evt_si_security {
__u16 event; __u16 event;
__u16 proto; __u16 proto;
__u16 subproto; __u16 subproto;
__u8 incomming; __u8 incoming;
} __attribute__ ((packed)) evt_si_security; } __attribute__ ((packed));
/* -------- HCI Packet structures -------- */ /* ---- HCI Packet structures ---- */
#define HCI_TYPE_LEN 1 #define HCI_COMMAND_HDR_SIZE 3
#define HCI_EVENT_HDR_SIZE 2
#define HCI_ACL_HDR_SIZE 4
#define HCI_SCO_HDR_SIZE 3
typedef struct { struct hci_command_hdr {
__u16 opcode; /* OCF & OGF */ __u16 opcode; /* OCF & OGF */
__u8 plen; __u8 plen;
} __attribute__ ((packed)) hci_command_hdr; } __attribute__ ((packed));
#define HCI_COMMAND_HDR_SIZE 3
typedef struct { struct hci_event_hdr {
__u8 evt; __u8 evt;
__u8 plen; __u8 plen;
} __attribute__ ((packed)) hci_event_hdr; } __attribute__ ((packed));
#define HCI_EVENT_HDR_SIZE 2
typedef struct { struct hci_acl_hdr {
__u16 handle; /* Handle & Flags(PB, BC) */ __u16 handle; /* Handle & Flags(PB, BC) */
__u16 dlen; __u16 dlen;
} __attribute__ ((packed)) hci_acl_hdr; } __attribute__ ((packed));
#define HCI_ACL_HDR_SIZE 4
typedef struct { struct hci_sco_hdr {
__u16 handle; __u16 handle;
__u8 dlen; __u8 dlen;
} __attribute__ ((packed)) hci_sco_hdr; } __attribute__ ((packed));
#define HCI_SCO_HDR_SIZE 3
/* Command opcode pack/unpack */ /* Command opcode pack/unpack */
#define cmd_opcode_pack(ogf, ocf) (__u16)((ocf & 0x03ff)|(ogf << 10)) #define cmd_opcode_pack(ogf, ocf) (__u16)((ocf & 0x03ff)|(ogf << 10))
...@@ -644,12 +564,14 @@ typedef struct { ...@@ -644,12 +564,14 @@ typedef struct {
#define acl_handle(h) (h & 0x0fff) #define acl_handle(h) (h & 0x0fff)
#define acl_flags(h) (h >> 12) #define acl_flags(h) (h >> 12)
/* HCI Socket options */ /* ---- HCI Sockets ---- */
/* Socket options */
#define HCI_DATA_DIR 1 #define HCI_DATA_DIR 1
#define HCI_FILTER 2 #define HCI_FILTER 2
#define HCI_TIME_STAMP 3 #define HCI_TIME_STAMP 3
/* HCI CMSG flags */ /* CMSG flags */
#define HCI_CMSG_DIR 0x0001 #define HCI_CMSG_DIR 0x0001
#define HCI_CMSG_TSTAMP 0x0002 #define HCI_CMSG_TSTAMP 0x0002
...@@ -676,7 +598,7 @@ struct hci_ufilter { ...@@ -676,7 +598,7 @@ struct hci_ufilter {
#define HCI_FLT_OGF_BITS 63 #define HCI_FLT_OGF_BITS 63
#define HCI_FLT_OCF_BITS 127 #define HCI_FLT_OCF_BITS 127
/* Ioctl requests structures */ /* ---- HCI Ioctl requests structures ---- */
struct hci_dev_stats { struct hci_dev_stats {
__u32 err_rx; __u32 err_rx;
__u32 err_tx; __u32 err_tx;
...@@ -753,11 +675,4 @@ struct hci_inquiry_req { ...@@ -753,11 +675,4 @@ struct hci_inquiry_req {
}; };
#define IREQ_CACHE_FLUSH 0x0001 #define IREQ_CACHE_FLUSH 0x0001
struct hci_remotename_req {
__u16 dev_id;
__u16 flags;
bdaddr_t bdaddr;
__u8 name[248];
};
#endif /* __HCI_H */ #endif /* __HCI_H */
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
struct inquiry_entry { struct inquiry_entry {
struct inquiry_entry *next; struct inquiry_entry *next;
__u32 timestamp; __u32 timestamp;
inquiry_info info; struct inquiry_info info;
}; };
struct inquiry_cache { struct inquiry_cache {
...@@ -179,7 +179,7 @@ static inline long inquiry_entry_age(struct inquiry_entry *e) ...@@ -179,7 +179,7 @@ static inline long inquiry_entry_age(struct inquiry_entry *e)
} }
struct inquiry_entry *inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr); struct inquiry_entry *inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *bdaddr);
void inquiry_cache_update(struct hci_dev *hdev, inquiry_info *info); void inquiry_cache_update(struct hci_dev *hdev, struct inquiry_info *info);
void inquiry_cache_flush(struct hci_dev *hdev); void inquiry_cache_flush(struct hci_dev *hdev);
int inquiry_cache_dump(struct hci_dev *hdev, int num, __u8 *buf); int inquiry_cache_dump(struct hci_dev *hdev, int num, __u8 *buf);
......
...@@ -61,7 +61,7 @@ void hci_acl_connect(struct hci_conn *conn) ...@@ -61,7 +61,7 @@ void hci_acl_connect(struct hci_conn *conn)
{ {
struct hci_dev *hdev = conn->hdev; struct hci_dev *hdev = conn->hdev;
struct inquiry_entry *ie; struct inquiry_entry *ie;
create_conn_cp cp; struct create_conn_cp cp;
BT_DBG("%p", conn); BT_DBG("%p", conn);
...@@ -85,13 +85,12 @@ void hci_acl_connect(struct hci_conn *conn) ...@@ -85,13 +85,12 @@ void hci_acl_connect(struct hci_conn *conn)
else else
cp.role_switch = 0x00; cp.role_switch = 0x00;
hci_send_cmd(hdev, OGF_LINK_CTL, OCF_CREATE_CONN, hci_send_cmd(hdev, OGF_LINK_CTL, OCF_CREATE_CONN, sizeof(cp), &cp);
CREATE_CONN_CP_SIZE, &cp);
} }
void hci_acl_disconn(struct hci_conn *conn, __u8 reason) void hci_acl_disconn(struct hci_conn *conn, __u8 reason)
{ {
disconnect_cp cp; struct disconnect_cp cp;
BT_DBG("%p", conn); BT_DBG("%p", conn);
...@@ -99,14 +98,13 @@ void hci_acl_disconn(struct hci_conn *conn, __u8 reason) ...@@ -99,14 +98,13 @@ void hci_acl_disconn(struct hci_conn *conn, __u8 reason)
cp.handle = __cpu_to_le16(conn->handle); cp.handle = __cpu_to_le16(conn->handle);
cp.reason = reason; cp.reason = reason;
hci_send_cmd(conn->hdev, OGF_LINK_CTL, OCF_DISCONNECT, hci_send_cmd(conn->hdev, OGF_LINK_CTL, OCF_DISCONNECT, sizeof(cp), &cp);
DISCONNECT_CP_SIZE, &cp);
} }
void hci_add_sco(struct hci_conn *conn, __u16 handle) void hci_add_sco(struct hci_conn *conn, __u16 handle)
{ {
struct hci_dev *hdev = conn->hdev; struct hci_dev *hdev = conn->hdev;
add_sco_cp cp; struct add_sco_cp cp;
BT_DBG("%p", conn); BT_DBG("%p", conn);
...@@ -116,7 +114,7 @@ void hci_add_sco(struct hci_conn *conn, __u16 handle) ...@@ -116,7 +114,7 @@ void hci_add_sco(struct hci_conn *conn, __u16 handle)
cp.pkt_type = __cpu_to_le16(hdev->pkt_type & SCO_PTYPE_MASK); cp.pkt_type = __cpu_to_le16(hdev->pkt_type & SCO_PTYPE_MASK);
cp.handle = __cpu_to_le16(handle); cp.handle = __cpu_to_le16(handle);
hci_send_cmd(hdev, OGF_LINK_CTL, OCF_ADD_SCO, ADD_SCO_CP_SIZE, &cp); hci_send_cmd(hdev, OGF_LINK_CTL, OCF_ADD_SCO, sizeof(cp), &cp);
} }
static void hci_conn_timeout(unsigned long arg) static void hci_conn_timeout(unsigned long arg)
...@@ -300,10 +298,9 @@ int hci_conn_auth(struct hci_conn *conn) ...@@ -300,10 +298,9 @@ int hci_conn_auth(struct hci_conn *conn)
return 1; return 1;
if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->pend)) { if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->pend)) {
auth_requested_cp ar; struct auth_requested_cp cp;
ar.handle = __cpu_to_le16(conn->handle); cp.handle = __cpu_to_le16(conn->handle);
hci_send_cmd(conn->hdev, OGF_LINK_CTL, OCF_AUTH_REQUESTED, hci_send_cmd(conn->hdev, OGF_LINK_CTL, OCF_AUTH_REQUESTED, sizeof(cp), &cp);
AUTH_REQUESTED_CP_SIZE, &ar);
} }
return 0; return 0;
} }
...@@ -320,11 +317,10 @@ int hci_conn_encrypt(struct hci_conn *conn) ...@@ -320,11 +317,10 @@ int hci_conn_encrypt(struct hci_conn *conn)
return 0; return 0;
if (hci_conn_auth(conn)) { if (hci_conn_auth(conn)) {
set_conn_encrypt_cp ce; struct set_conn_encrypt_cp cp;
ce.handle = __cpu_to_le16(conn->handle); cp.handle = __cpu_to_le16(conn->handle);
ce.encrypt = 1; cp.encrypt = 1;
hci_send_cmd(conn->hdev, OGF_LINK_CTL, OCF_SET_CONN_ENCRYPT, hci_send_cmd(conn->hdev, OGF_LINK_CTL, OCF_SET_CONN_ENCRYPT, sizeof(cp), &cp);
SET_CONN_ENCRYPT_CP_SIZE, &ce);
} }
return 0; return 0;
} }
......
...@@ -210,7 +210,6 @@ static void hci_reset_req(struct hci_dev *hdev, unsigned long opt) ...@@ -210,7 +210,6 @@ static void hci_reset_req(struct hci_dev *hdev, unsigned long opt)
static void hci_init_req(struct hci_dev *hdev, unsigned long opt) static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
{ {
set_event_flt_cp ef;
__u16 param; __u16 param;
BT_DBG("%s %ld", hdev->name, opt); BT_DBG("%s %ld", hdev->name, opt);
...@@ -226,13 +225,12 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt) ...@@ -226,13 +225,12 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
#if 0 #if 0
/* Host buffer size */ /* Host buffer size */
{ {
host_buffer_size_cp bs; struct host_buffer_size_cp cp;
bs.acl_mtu = __cpu_to_le16(HCI_MAX_ACL_SIZE); cp.acl_mtu = __cpu_to_le16(HCI_MAX_ACL_SIZE);
bs.sco_mtu = HCI_MAX_SCO_SIZE; cp.sco_mtu = HCI_MAX_SCO_SIZE;
bs.acl_max_pkt = __cpu_to_le16(0xffff); cp.acl_max_pkt = __cpu_to_le16(0xffff);
bs.sco_max_pkt = __cpu_to_le16(0xffff); cp.sco_max_pkt = __cpu_to_le16(0xffff);
hci_send_cmd(hdev, OGF_HOST_CTL, OCF_HOST_BUFFER_SIZE, hci_send_cmd(hdev, OGF_HOST_CTL, OCF_HOST_BUFFER_SIZE, sizeof(cp), &cp);
HOST_BUFFER_SIZE_CP_SIZE, &bs);
} }
#endif #endif
...@@ -242,8 +240,11 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt) ...@@ -242,8 +240,11 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
/* Optional initialization */ /* Optional initialization */
/* Clear Event Filters */ /* Clear Event Filters */
ef.flt_type = FLT_CLEAR_ALL; {
hci_send_cmd(hdev, OGF_HOST_CTL, OCF_SET_EVENT_FLT, 1, &ef); struct set_event_flt_cp cp;
cp.flt_type = FLT_CLEAR_ALL;
hci_send_cmd(hdev, OGF_HOST_CTL, OCF_SET_EVENT_FLT, sizeof(cp), &cp);
}
/* Page timeout ~20 secs */ /* Page timeout ~20 secs */
param = __cpu_to_le16(0x8000); param = __cpu_to_le16(0x8000);
...@@ -338,7 +339,7 @@ struct inquiry_entry *inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *bdadd ...@@ -338,7 +339,7 @@ struct inquiry_entry *inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *bdadd
return e; return e;
} }
void inquiry_cache_update(struct hci_dev *hdev, inquiry_info *info) void inquiry_cache_update(struct hci_dev *hdev, struct inquiry_info *info)
{ {
struct inquiry_cache *cache = &hdev->inq_cache; struct inquiry_cache *cache = &hdev->inq_cache;
struct inquiry_entry *e; struct inquiry_entry *e;
...@@ -354,7 +355,7 @@ void inquiry_cache_update(struct hci_dev *hdev, inquiry_info *info) ...@@ -354,7 +355,7 @@ void inquiry_cache_update(struct hci_dev *hdev, inquiry_info *info)
cache->list = e; cache->list = e;
} }
memcpy(&e->info, info, sizeof(inquiry_info)); memcpy(&e->info, info, sizeof(*info));
e->timestamp = jiffies; e->timestamp = jiffies;
cache->timestamp = jiffies; cache->timestamp = jiffies;
} }
...@@ -362,12 +363,12 @@ void inquiry_cache_update(struct hci_dev *hdev, inquiry_info *info) ...@@ -362,12 +363,12 @@ void inquiry_cache_update(struct hci_dev *hdev, inquiry_info *info)
int inquiry_cache_dump(struct hci_dev *hdev, int num, __u8 *buf) int inquiry_cache_dump(struct hci_dev *hdev, int num, __u8 *buf)
{ {
struct inquiry_cache *cache = &hdev->inq_cache; struct inquiry_cache *cache = &hdev->inq_cache;
inquiry_info *info = (inquiry_info *) buf; struct inquiry_info *info = (struct inquiry_info *) buf;
struct inquiry_entry *e; struct inquiry_entry *e;
int copied = 0; int copied = 0;
for (e = cache->list; e && copied < num; e = e->next, copied++) for (e = cache->list; e && copied < num; e = e->next, copied++)
memcpy(info++, &e->info, sizeof(inquiry_info)); memcpy(info++, &e->info, sizeof(*info));
BT_DBG("cache %p, copied %d", cache, copied); BT_DBG("cache %p, copied %d", cache, copied);
return copied; return copied;
...@@ -376,7 +377,7 @@ int inquiry_cache_dump(struct hci_dev *hdev, int num, __u8 *buf) ...@@ -376,7 +377,7 @@ int inquiry_cache_dump(struct hci_dev *hdev, int num, __u8 *buf)
static void hci_inq_req(struct hci_dev *hdev, unsigned long opt) static void hci_inq_req(struct hci_dev *hdev, unsigned long opt)
{ {
struct hci_inquiry_req *ir = (struct hci_inquiry_req *) opt; struct hci_inquiry_req *ir = (struct hci_inquiry_req *) opt;
inquiry_cp ic; struct inquiry_cp cp;
BT_DBG("%s", hdev->name); BT_DBG("%s", hdev->name);
...@@ -384,10 +385,10 @@ static void hci_inq_req(struct hci_dev *hdev, unsigned long opt) ...@@ -384,10 +385,10 @@ static void hci_inq_req(struct hci_dev *hdev, unsigned long opt)
return; return;
/* Start Inquiry */ /* Start Inquiry */
memcpy(&ic.lap, &ir->lap, 3); memcpy(&cp.lap, &ir->lap, 3);
ic.length = ir->length; cp.length = ir->length;
ic.num_rsp = ir->num_rsp; cp.num_rsp = ir->num_rsp;
hci_send_cmd(hdev, OGF_LINK_CTL, OCF_INQUIRY, INQUIRY_CP_SIZE, &ic); hci_send_cmd(hdev, OGF_LINK_CTL, OCF_INQUIRY, sizeof(cp), &cp);
} }
int hci_inquiry(unsigned long arg) int hci_inquiry(unsigned long arg)
...@@ -420,7 +421,7 @@ int hci_inquiry(unsigned long arg) ...@@ -420,7 +421,7 @@ int hci_inquiry(unsigned long arg)
/* cache_dump can't sleep. Therefore we allocate temp buffer and then /* cache_dump can't sleep. Therefore we allocate temp buffer and then
* copy it to the user space. * copy it to the user space.
*/ */
if (!(buf = kmalloc(sizeof(inquiry_info) * ir.num_rsp, GFP_KERNEL))) { if (!(buf = kmalloc(sizeof(struct inquiry_info) * ir.num_rsp, GFP_KERNEL))) {
err = -ENOMEM; err = -ENOMEM;
goto done; goto done;
} }
...@@ -432,10 +433,10 @@ int hci_inquiry(unsigned long arg) ...@@ -432,10 +433,10 @@ int hci_inquiry(unsigned long arg)
BT_DBG("num_rsp %d", ir.num_rsp); BT_DBG("num_rsp %d", ir.num_rsp);
if (!verify_area(VERIFY_WRITE, ptr, sizeof(ir) + if (!verify_area(VERIFY_WRITE, ptr, sizeof(ir) +
(sizeof(inquiry_info) * ir.num_rsp))) { (sizeof(struct inquiry_info) * ir.num_rsp))) {
copy_to_user(ptr, &ir, sizeof(ir)); copy_to_user(ptr, &ir, sizeof(ir));
ptr += sizeof(ir); ptr += sizeof(ir);
copy_to_user(ptr, buf, sizeof(inquiry_info) * ir.num_rsp); copy_to_user(ptr, buf, sizeof(struct inquiry_info) * ir.num_rsp);
} else } else
err = -EFAULT; err = -EFAULT;
...@@ -1012,19 +1013,20 @@ int hci_send_raw(struct sk_buff *skb) ...@@ -1012,19 +1013,20 @@ int hci_send_raw(struct sk_buff *skb)
int hci_send_cmd(struct hci_dev *hdev, __u16 ogf, __u16 ocf, __u32 plen, void *param) int hci_send_cmd(struct hci_dev *hdev, __u16 ogf, __u16 ocf, __u32 plen, void *param)
{ {
int len = HCI_COMMAND_HDR_SIZE + plen; int len = HCI_COMMAND_HDR_SIZE + plen;
hci_command_hdr *hc; struct hci_command_hdr *hdr;
struct sk_buff *skb; struct sk_buff *skb;
BT_DBG("%s ogf 0x%x ocf 0x%x plen %d", hdev->name, ogf, ocf, plen); BT_DBG("%s ogf 0x%x ocf 0x%x plen %d", hdev->name, ogf, ocf, plen);
if (!(skb = bt_skb_alloc(len, GFP_ATOMIC))) { skb = bt_skb_alloc(len, GFP_ATOMIC);
if (!skb) {
BT_ERR("%s Can't allocate memory for HCI command", hdev->name); BT_ERR("%s Can't allocate memory for HCI command", hdev->name);
return -ENOMEM; return -ENOMEM;
} }
hc = (hci_command_hdr *) skb_put(skb, HCI_COMMAND_HDR_SIZE); hdr = (struct hci_command_hdr *) skb_put(skb, HCI_COMMAND_HDR_SIZE);
hc->opcode = __cpu_to_le16(cmd_opcode_pack(ogf, ocf)); hdr->opcode = __cpu_to_le16(cmd_opcode_pack(ogf, ocf));
hc->plen = plen; hdr->plen = plen;
if (plen) if (plen)
memcpy(skb_put(skb, plen), param, plen); memcpy(skb_put(skb, plen), param, plen);
...@@ -1042,14 +1044,14 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 ogf, __u16 ocf, __u32 plen, void *p ...@@ -1042,14 +1044,14 @@ int hci_send_cmd(struct hci_dev *hdev, __u16 ogf, __u16 ocf, __u32 plen, void *p
/* Get data from the previously sent command */ /* Get data from the previously sent command */
void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 ogf, __u16 ocf) void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 ogf, __u16 ocf)
{ {
hci_command_hdr *hc; struct hci_command_hdr *hdr;
if (!hdev->sent_cmd) if (!hdev->sent_cmd)
return NULL; return NULL;
hc = (void *) hdev->sent_cmd->data; hdr = (void *) hdev->sent_cmd->data;
if (hc->opcode != __cpu_to_le16(cmd_opcode_pack(ogf, ocf))) if (hdr->opcode != __cpu_to_le16(cmd_opcode_pack(ogf, ocf)))
return NULL; return NULL;
BT_DBG("%s ogf 0x%x ocf 0x%x", hdev->name, ogf, ocf); BT_DBG("%s ogf 0x%x ocf 0x%x", hdev->name, ogf, ocf);
...@@ -1060,14 +1062,14 @@ void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 ogf, __u16 ocf) ...@@ -1060,14 +1062,14 @@ void *hci_sent_cmd_data(struct hci_dev *hdev, __u16 ogf, __u16 ocf)
/* Send ACL data */ /* Send ACL data */
static void hci_add_acl_hdr(struct sk_buff *skb, __u16 handle, __u16 flags) static void hci_add_acl_hdr(struct sk_buff *skb, __u16 handle, __u16 flags)
{ {
struct hci_acl_hdr *hdr;
int len = skb->len; int len = skb->len;
hci_acl_hdr *ah;
ah = (hci_acl_hdr *) skb_push(skb, HCI_ACL_HDR_SIZE); hdr = (struct hci_acl_hdr *) skb_push(skb, HCI_ACL_HDR_SIZE);
ah->handle = __cpu_to_le16(acl_handle_pack(handle, flags)); hdr->handle = __cpu_to_le16(acl_handle_pack(handle, flags));
ah->dlen = __cpu_to_le16(len); hdr->dlen = __cpu_to_le16(len);
skb->h.raw = (void *) ah; skb->h.raw = (void *) hdr;
} }
int hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags) int hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags)
...@@ -1119,7 +1121,7 @@ int hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags) ...@@ -1119,7 +1121,7 @@ int hci_send_acl(struct hci_conn *conn, struct sk_buff *skb, __u16 flags)
int hci_send_sco(struct hci_conn *conn, struct sk_buff *skb) int hci_send_sco(struct hci_conn *conn, struct sk_buff *skb)
{ {
struct hci_dev *hdev = conn->hdev; struct hci_dev *hdev = conn->hdev;
hci_sco_hdr hs; struct hci_sco_hdr hdr;
BT_DBG("%s len %d", hdev->name, skb->len); BT_DBG("%s len %d", hdev->name, skb->len);
...@@ -1128,11 +1130,11 @@ int hci_send_sco(struct hci_conn *conn, struct sk_buff *skb) ...@@ -1128,11 +1130,11 @@ int hci_send_sco(struct hci_conn *conn, struct sk_buff *skb)
return -EINVAL; return -EINVAL;
} }
hs.handle = __cpu_to_le16(conn->handle); hdr.handle = __cpu_to_le16(conn->handle);
hs.dlen = skb->len; hdr.dlen = skb->len;
skb->h.raw = skb_push(skb, HCI_SCO_HDR_SIZE); skb->h.raw = skb_push(skb, HCI_SCO_HDR_SIZE);
memcpy(skb->h.raw, &hs, HCI_SCO_HDR_SIZE); memcpy(skb->h.raw, &hdr, HCI_SCO_HDR_SIZE);
skb->dev = (void *) hdev; skb->dev = (void *) hdev;
skb->pkt_type = HCI_SCODATA_PKT; skb->pkt_type = HCI_SCODATA_PKT;
...@@ -1271,13 +1273,13 @@ static void hci_tx_task(unsigned long arg) ...@@ -1271,13 +1273,13 @@ static void hci_tx_task(unsigned long arg)
/* ACL data packet */ /* ACL data packet */
static inline void hci_acldata_packet(struct hci_dev *hdev, struct sk_buff *skb) static inline void hci_acldata_packet(struct hci_dev *hdev, struct sk_buff *skb)
{ {
hci_acl_hdr *ah = (void *) skb->data; struct hci_acl_hdr *hdr = (void *) skb->data;
struct hci_conn *conn; struct hci_conn *conn;
__u16 handle, flags; __u16 handle, flags;
skb_pull(skb, HCI_ACL_HDR_SIZE); skb_pull(skb, HCI_ACL_HDR_SIZE);
handle = __le16_to_cpu(ah->handle); handle = __le16_to_cpu(hdr->handle);
flags = acl_flags(handle); flags = acl_flags(handle);
handle = acl_handle(handle); handle = acl_handle(handle);
...@@ -1308,13 +1310,13 @@ static inline void hci_acldata_packet(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -1308,13 +1310,13 @@ static inline void hci_acldata_packet(struct hci_dev *hdev, struct sk_buff *skb)
/* SCO data packet */ /* SCO data packet */
static inline void hci_scodata_packet(struct hci_dev *hdev, struct sk_buff *skb) static inline void hci_scodata_packet(struct hci_dev *hdev, struct sk_buff *skb)
{ {
hci_sco_hdr *sh = (void *) skb->data; struct hci_sco_hdr *hdr = (void *) skb->data;
struct hci_conn *conn; struct hci_conn *conn;
__u16 handle; __u16 handle;
skb_pull(skb, HCI_SCO_HDR_SIZE); skb_pull(skb, HCI_SCO_HDR_SIZE);
handle = __le16_to_cpu(sh->handle); handle = __le16_to_cpu(hdr->handle);
BT_DBG("%s len %d handle 0x%x", hdev->name, skb->len, handle); BT_DBG("%s len %d handle 0x%x", hdev->name, skb->len, handle);
......
...@@ -75,7 +75,7 @@ static void hci_cc_link_ctl(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb ...@@ -75,7 +75,7 @@ static void hci_cc_link_ctl(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb
static void hci_cc_link_policy(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb) static void hci_cc_link_policy(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb)
{ {
struct hci_conn *conn; struct hci_conn *conn;
role_discovery_rp *rd; struct role_discovery_rp *rd;
BT_DBG("%s ocf 0x%x", hdev->name, ocf); BT_DBG("%s ocf 0x%x", hdev->name, ocf);
...@@ -219,15 +219,15 @@ static void hci_cc_host_ctl(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb ...@@ -219,15 +219,15 @@ static void hci_cc_host_ctl(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb
/* Command Complete OGF INFO_PARAM */ /* Command Complete OGF INFO_PARAM */
static void hci_cc_info_param(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb) static void hci_cc_info_param(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb)
{ {
read_local_features_rp *lf; struct read_local_features_rp *lf;
read_buffer_size_rp *bs; struct read_buffer_size_rp *bs;
read_bd_addr_rp *ba; struct read_bd_addr_rp *ba;
BT_DBG("%s ocf 0x%x", hdev->name, ocf); BT_DBG("%s ocf 0x%x", hdev->name, ocf);
switch (ocf) { switch (ocf) {
case OCF_READ_LOCAL_FEATURES: case OCF_READ_LOCAL_FEATURES:
lf = (read_local_features_rp *) skb->data; lf = (struct read_local_features_rp *) skb->data;
if (lf->status) { if (lf->status) {
BT_DBG("%s READ_LOCAL_FEATURES failed %d", hdev->name, lf->status); BT_DBG("%s READ_LOCAL_FEATURES failed %d", hdev->name, lf->status);
...@@ -255,7 +255,7 @@ static void hci_cc_info_param(struct hci_dev *hdev, __u16 ocf, struct sk_buff *s ...@@ -255,7 +255,7 @@ static void hci_cc_info_param(struct hci_dev *hdev, __u16 ocf, struct sk_buff *s
break; break;
case OCF_READ_BUFFER_SIZE: case OCF_READ_BUFFER_SIZE:
bs = (read_buffer_size_rp *) skb->data; bs = (struct read_buffer_size_rp *) skb->data;
if (bs->status) { if (bs->status) {
BT_DBG("%s READ_BUFFER_SIZE failed %d", hdev->name, bs->status); BT_DBG("%s READ_BUFFER_SIZE failed %d", hdev->name, bs->status);
...@@ -273,7 +273,7 @@ static void hci_cc_info_param(struct hci_dev *hdev, __u16 ocf, struct sk_buff *s ...@@ -273,7 +273,7 @@ static void hci_cc_info_param(struct hci_dev *hdev, __u16 ocf, struct sk_buff *s
break; break;
case OCF_READ_BD_ADDR: case OCF_READ_BD_ADDR:
ba = (read_bd_addr_rp *) skb->data; ba = (struct read_bd_addr_rp *) skb->data;
if (!ba->status) { if (!ba->status) {
bacpy(&hdev->bdaddr, &ba->bdaddr); bacpy(&hdev->bdaddr, &ba->bdaddr);
...@@ -294,14 +294,14 @@ static void hci_cc_info_param(struct hci_dev *hdev, __u16 ocf, struct sk_buff *s ...@@ -294,14 +294,14 @@ static void hci_cc_info_param(struct hci_dev *hdev, __u16 ocf, struct sk_buff *s
static inline void hci_cs_create_conn(struct hci_dev *hdev, __u8 status) static inline void hci_cs_create_conn(struct hci_dev *hdev, __u8 status)
{ {
struct hci_conn *conn; struct hci_conn *conn;
create_conn_cp *cc = hci_sent_cmd_data(hdev, OGF_LINK_CTL, OCF_CREATE_CONN); struct create_conn_cp *cp = hci_sent_cmd_data(hdev, OGF_LINK_CTL, OCF_CREATE_CONN);
if (!cc) if (!cp)
return; return;
hci_dev_lock(hdev); hci_dev_lock(hdev);
conn = conn_hash_lookup_ba(hdev, ACL_LINK, &cc->bdaddr); conn = conn_hash_lookup_ba(hdev, ACL_LINK, &cp->bdaddr);
BT_DBG("%s status 0x%x bdaddr %s conn %p", hdev->name, BT_DBG("%s status 0x%x bdaddr %s conn %p", hdev->name,
status, batostr(&cc->bdaddr), conn); status, batostr(&cc->bdaddr), conn);
...@@ -314,7 +314,7 @@ static inline void hci_cs_create_conn(struct hci_dev *hdev, __u8 status) ...@@ -314,7 +314,7 @@ static inline void hci_cs_create_conn(struct hci_dev *hdev, __u8 status)
} }
} else { } else {
if (!conn) { if (!conn) {
conn = hci_conn_add(hdev, ACL_LINK, &cc->bdaddr); conn = hci_conn_add(hdev, ACL_LINK, &cp->bdaddr);
if (conn) { if (conn) {
conn->out = 1; conn->out = 1;
conn->link_mode |= HCI_LM_MASTER; conn->link_mode |= HCI_LM_MASTER;
...@@ -338,8 +338,7 @@ static void hci_cs_link_ctl(struct hci_dev *hdev, __u16 ocf, __u8 status) ...@@ -338,8 +338,7 @@ static void hci_cs_link_ctl(struct hci_dev *hdev, __u16 ocf, __u8 status)
case OCF_ADD_SCO: case OCF_ADD_SCO:
if (status) { if (status) {
struct hci_conn *acl, *sco; struct hci_conn *acl, *sco;
add_sco_cp *cp = hci_sent_cmd_data(hdev, struct add_sco_cp *cp = hci_sent_cmd_data(hdev, OGF_LINK_CTL, OCF_ADD_SCO);
OGF_LINK_CTL, OCF_ADD_SCO);
__u16 handle; __u16 handle;
if (!cp) if (!cp)
...@@ -429,7 +428,7 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff ...@@ -429,7 +428,7 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff
/* Inquiry Result */ /* Inquiry Result */
static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb) static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *skb)
{ {
inquiry_info *info = (inquiry_info *) (skb->data + 1); struct inquiry_info *info = (struct inquiry_info *) (skb->data + 1);
int num_rsp = *((__u8 *) skb->data); int num_rsp = *((__u8 *) skb->data);
BT_DBG("%s num_rsp %d", hdev->name, num_rsp); BT_DBG("%s num_rsp %d", hdev->name, num_rsp);
...@@ -443,23 +442,23 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff * ...@@ -443,23 +442,23 @@ static inline void hci_inquiry_result_evt(struct hci_dev *hdev, struct sk_buff *
/* Connect Request */ /* Connect Request */
static inline void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb) static inline void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
{ {
evt_conn_request *cr = (evt_conn_request *) skb->data; struct evt_conn_request *ev = (struct evt_conn_request *) skb->data;
int mask = hdev->link_mode; int mask = hdev->link_mode;
BT_DBG("%s Connection request: %s type 0x%x", hdev->name, BT_DBG("%s Connection request: %s type 0x%x", hdev->name,
batostr(&cr->bdaddr), cr->link_type); batostr(&ev->bdaddr), ev->link_type);
mask |= hci_proto_connect_ind(hdev, &cr->bdaddr, cr->link_type); mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, ev->link_type);
if (mask & HCI_LM_ACCEPT) { if (mask & HCI_LM_ACCEPT) {
/* Connection accepted */ /* Connection accepted */
struct hci_conn *conn; struct hci_conn *conn;
accept_conn_req_cp ac; struct accept_conn_req_cp cp;
hci_dev_lock(hdev); hci_dev_lock(hdev);
conn = conn_hash_lookup_ba(hdev, cr->link_type, &cr->bdaddr); conn = conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr);
if (!conn) { if (!conn) {
if (!(conn = hci_conn_add(hdev, cr->link_type, &cr->bdaddr))) { if (!(conn = hci_conn_add(hdev, ev->link_type, &ev->bdaddr))) {
BT_ERR("No memmory for new connection"); BT_ERR("No memmory for new connection");
hci_dev_unlock(hdev); hci_dev_unlock(hdev);
return; return;
...@@ -468,44 +467,42 @@ static inline void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *sk ...@@ -468,44 +467,42 @@ static inline void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *sk
conn->state = BT_CONNECT; conn->state = BT_CONNECT;
hci_dev_unlock(hdev); hci_dev_unlock(hdev);
bacpy(&ac.bdaddr, &cr->bdaddr); bacpy(&cp.bdaddr, &ev->bdaddr);
if (lmp_rswitch_capable(hdev) && (mask & HCI_LM_MASTER)) if (lmp_rswitch_capable(hdev) && (mask & HCI_LM_MASTER))
ac.role = 0x00; /* Become master */ cp.role = 0x00; /* Become master */
else else
ac.role = 0x01; /* Remain slave */ cp.role = 0x01; /* Remain slave */
hci_send_cmd(hdev, OGF_LINK_CTL, OCF_ACCEPT_CONN_REQ, hci_send_cmd(hdev, OGF_LINK_CTL, OCF_ACCEPT_CONN_REQ, sizeof(cp), &cp);
ACCEPT_CONN_REQ_CP_SIZE, &ac);
} else { } else {
/* Connection rejected */ /* Connection rejected */
reject_conn_req_cp rc; struct reject_conn_req_cp cp;
bacpy(&rc.bdaddr, &cr->bdaddr); bacpy(&cp.bdaddr, &ev->bdaddr);
rc.reason = 0x0f; cp.reason = 0x0f;
hci_send_cmd(hdev, OGF_LINK_CTL, OCF_REJECT_CONN_REQ, hci_send_cmd(hdev, OGF_LINK_CTL, OCF_REJECT_CONN_REQ, sizeof(cp), &cp);
REJECT_CONN_REQ_CP_SIZE, &rc);
} }
} }
/* Connect Complete */ /* Connect Complete */
static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
{ {
evt_conn_complete *cc = (evt_conn_complete *) skb->data; struct evt_conn_complete *ev = (struct evt_conn_complete *) skb->data;
struct hci_conn *conn = NULL; struct hci_conn *conn = NULL;
BT_DBG("%s", hdev->name); BT_DBG("%s", hdev->name);
hci_dev_lock(hdev); hci_dev_lock(hdev);
conn = conn_hash_lookup_ba(hdev, cc->link_type, &cc->bdaddr); conn = conn_hash_lookup_ba(hdev, ev->link_type, &ev->bdaddr);
if (!conn) { if (!conn) {
hci_dev_unlock(hdev); hci_dev_unlock(hdev);
return; return;
} }
if (!cc->status) { if (!ev->status) {
conn->handle = __le16_to_cpu(cc->handle); conn->handle = __le16_to_cpu(ev->handle);
conn->state = BT_CONNECTED; conn->state = BT_CONNECTED;
if (test_bit(HCI_AUTH, &hdev->flags)) if (test_bit(HCI_AUTH, &hdev->flags))
...@@ -517,23 +514,21 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s ...@@ -517,23 +514,21 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s
/* Set link policy */ /* Set link policy */
if (conn->type == ACL_LINK && hdev->link_policy) { if (conn->type == ACL_LINK && hdev->link_policy) {
write_link_policy_cp lp; struct write_link_policy_cp cp;
lp.handle = cc->handle; cp.handle = ev->handle;
lp.policy = __cpu_to_le16(hdev->link_policy); cp.policy = __cpu_to_le16(hdev->link_policy);
hci_send_cmd(hdev, OGF_LINK_POLICY, OCF_WRITE_LINK_POLICY, hci_send_cmd(hdev, OGF_LINK_POLICY, OCF_WRITE_LINK_POLICY, sizeof(cp), &cp);
WRITE_LINK_POLICY_CP_SIZE, &lp);
} }
/* Set packet type for incomming connection */ /* Set packet type for incomming connection */
if (!conn->out) { if (!conn->out) {
change_conn_ptype_cp cp; struct change_conn_ptype_cp cp;
cp.handle = cc->handle; cp.handle = ev->handle;
cp.pkt_type = (conn->type == ACL_LINK) ? cp.pkt_type = (conn->type == ACL_LINK) ?
__cpu_to_le16(hdev->pkt_type & ACL_PTYPE_MASK): __cpu_to_le16(hdev->pkt_type & ACL_PTYPE_MASK):
__cpu_to_le16(hdev->pkt_type & SCO_PTYPE_MASK); __cpu_to_le16(hdev->pkt_type & SCO_PTYPE_MASK);
hci_send_cmd(hdev, OGF_LINK_CTL, OCF_CHANGE_CONN_PTYPE, hci_send_cmd(hdev, OGF_LINK_CTL, OCF_CHANGE_CONN_PTYPE, sizeof(cp), &cp);
CHANGE_CONN_PTYPE_CP_SIZE, &cp);
} }
} else } else
conn->state = BT_CLOSED; conn->state = BT_CLOSED;
...@@ -541,17 +536,17 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s ...@@ -541,17 +536,17 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s
if (conn->type == ACL_LINK) { if (conn->type == ACL_LINK) {
struct hci_conn *sco = conn->link; struct hci_conn *sco = conn->link;
if (sco) { if (sco) {
if (!cc->status) if (!ev->status)
hci_add_sco(sco, conn->handle); hci_add_sco(sco, conn->handle);
else { else {
hci_proto_connect_cfm(sco, cc->status); hci_proto_connect_cfm(sco, ev->status);
hci_conn_del(sco); hci_conn_del(sco);
} }
} }
} }
hci_proto_connect_cfm(conn, cc->status); hci_proto_connect_cfm(conn, ev->status);
if (cc->status) if (ev->status)
hci_conn_del(conn); hci_conn_del(conn);
hci_dev_unlock(hdev); hci_dev_unlock(hdev);
...@@ -560,13 +555,13 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s ...@@ -560,13 +555,13 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s
/* Disconnect Complete */ /* Disconnect Complete */
static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
{ {
evt_disconn_complete *dc = (evt_disconn_complete *) skb->data; struct evt_disconn_complete *ev = (struct evt_disconn_complete *) skb->data;
struct hci_conn *conn = NULL; struct hci_conn *conn = NULL;
__u16 handle = __le16_to_cpu(dc->handle); __u16 handle = __le16_to_cpu(ev->handle);
BT_DBG("%s status %d", hdev->name, dc->status); BT_DBG("%s status %d", hdev->name, ev->status);
if (dc->status) if (ev->status)
return; return;
hci_dev_lock(hdev); hci_dev_lock(hdev);
...@@ -574,7 +569,7 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff ...@@ -574,7 +569,7 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff
conn = conn_hash_lookup_handle(hdev, handle); conn = conn_hash_lookup_handle(hdev, handle);
if (conn) { if (conn) {
conn->state = BT_CLOSED; conn->state = BT_CLOSED;
hci_proto_disconn_ind(conn, dc->reason); hci_proto_disconn_ind(conn, ev->reason);
hci_conn_del(conn); hci_conn_del(conn);
} }
...@@ -584,22 +579,22 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff ...@@ -584,22 +579,22 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff
/* Number of completed packets */ /* Number of completed packets */
static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *skb) static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *skb)
{ {
evt_num_comp_pkts *nc = (evt_num_comp_pkts *) skb->data; struct evt_num_comp_pkts *ev = (struct evt_num_comp_pkts *) skb->data;
__u16 *ptr; __u16 *ptr;
int i; int i;
skb_pull(skb, EVT_NUM_COMP_PKTS_SIZE); skb_pull(skb, sizeof(*ev));
BT_DBG("%s num_hndl %d", hdev->name, nc->num_hndl); BT_DBG("%s num_hndl %d", hdev->name, ev->num_hndl);
if (skb->len < nc->num_hndl * 4) { if (skb->len < ev->num_hndl * 4) {
BT_DBG("%s bad parameters", hdev->name); BT_DBG("%s bad parameters", hdev->name);
return; return;
} }
tasklet_disable(&hdev->tx_task); tasklet_disable(&hdev->tx_task);
for (i = 0, ptr = (__u16 *) skb->data; i < nc->num_hndl; i++) { for (i = 0, ptr = (__u16 *) skb->data; i < ev->num_hndl; i++) {
struct hci_conn *conn; struct hci_conn *conn;
__u16 handle, count; __u16 handle, count;
...@@ -627,19 +622,19 @@ static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *s ...@@ -627,19 +622,19 @@ static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *s
/* Role Change */ /* Role Change */
static inline void hci_role_change_evt(struct hci_dev *hdev, struct sk_buff *skb) static inline void hci_role_change_evt(struct hci_dev *hdev, struct sk_buff *skb)
{ {
evt_role_change *rc = (evt_role_change *) skb->data; struct evt_role_change *ev = (struct evt_role_change *) skb->data;
struct hci_conn *conn = NULL; struct hci_conn *conn = NULL;
BT_DBG("%s status %d", hdev->name, rc->status); BT_DBG("%s status %d", hdev->name, ev->status);
if (rc->status) if (ev->status)
return; return;
hci_dev_lock(hdev); hci_dev_lock(hdev);
conn = conn_hash_lookup_ba(hdev, ACL_LINK, &rc->bdaddr); conn = conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
if (conn) { if (conn) {
if (rc->role) if (ev->role)
conn->link_mode &= ~HCI_LM_MASTER; conn->link_mode &= ~HCI_LM_MASTER;
else else
conn->link_mode |= HCI_LM_MASTER; conn->link_mode |= HCI_LM_MASTER;
...@@ -651,33 +646,33 @@ static inline void hci_role_change_evt(struct hci_dev *hdev, struct sk_buff *skb ...@@ -651,33 +646,33 @@ static inline void hci_role_change_evt(struct hci_dev *hdev, struct sk_buff *skb
/* Authentication Complete */ /* Authentication Complete */
static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *skb) static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
{ {
evt_auth_complete *ac = (evt_auth_complete *) skb->data; struct evt_auth_complete *ev = (struct evt_auth_complete *) skb->data;
struct hci_conn *conn = NULL; struct hci_conn *conn = NULL;
__u16 handle = __le16_to_cpu(ac->handle); __u16 handle = __le16_to_cpu(ev->handle);
BT_DBG("%s status %d", hdev->name, ac->status); BT_DBG("%s status %d", hdev->name, ev->status);
hci_dev_lock(hdev); hci_dev_lock(hdev);
conn = conn_hash_lookup_handle(hdev, handle); conn = conn_hash_lookup_handle(hdev, handle);
if (conn) { if (conn) {
if (!ac->status) if (!ev->status)
conn->link_mode |= HCI_LM_AUTH; conn->link_mode |= HCI_LM_AUTH;
clear_bit(HCI_CONN_AUTH_PEND, &conn->pend); clear_bit(HCI_CONN_AUTH_PEND, &conn->pend);
hci_proto_auth_cfm(conn, ac->status); hci_proto_auth_cfm(conn, ev->status);
if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) { if (test_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend)) {
if (!ac->status) { if (!ev->status) {
set_conn_encrypt_cp ce; struct set_conn_encrypt_cp cp;
ce.handle = __cpu_to_le16(conn->handle); cp.handle = __cpu_to_le16(conn->handle);
ce.encrypt = 1; cp.encrypt = 1;
hci_send_cmd(conn->hdev, OGF_LINK_CTL, hci_send_cmd(conn->hdev, OGF_LINK_CTL,
OCF_SET_CONN_ENCRYPT, OCF_SET_CONN_ENCRYPT,
SET_CONN_ENCRYPT_CP_SIZE, &ce); sizeof(cp), &cp);
} else { } else {
clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend); clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend);
hci_proto_encrypt_cfm(conn, ac->status); hci_proto_encrypt_cfm(conn, ev->status);
} }
} }
} }
...@@ -688,25 +683,25 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s ...@@ -688,25 +683,25 @@ static inline void hci_auth_complete_evt(struct hci_dev *hdev, struct sk_buff *s
/* Encryption Change */ /* Encryption Change */
static inline void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb) static inline void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *skb)
{ {
evt_encrypt_change *ec = (evt_encrypt_change *) skb->data; struct evt_encrypt_change *ev = (struct evt_encrypt_change *) skb->data;
struct hci_conn *conn = NULL; struct hci_conn *conn = NULL;
__u16 handle = __le16_to_cpu(ec->handle); __u16 handle = __le16_to_cpu(ev->handle);
BT_DBG("%s status %d", hdev->name, ec->status); BT_DBG("%s status %d", hdev->name, ev->status);
hci_dev_lock(hdev); hci_dev_lock(hdev);
conn = conn_hash_lookup_handle(hdev, handle); conn = conn_hash_lookup_handle(hdev, handle);
if (conn) { if (conn) {
if (!ec->status) { if (!ev->status) {
if (ec->encrypt) if (ev->encrypt)
conn->link_mode |= HCI_LM_ENCRYPT; conn->link_mode |= HCI_LM_ENCRYPT;
else else
conn->link_mode &= ~HCI_LM_ENCRYPT; conn->link_mode &= ~HCI_LM_ENCRYPT;
} }
clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend); clear_bit(HCI_CONN_ENCRYPT_PEND, &conn->pend);
hci_proto_encrypt_cfm(conn, ec->status); hci_proto_encrypt_cfm(conn, ev->status);
} }
hci_dev_unlock(hdev); hci_dev_unlock(hdev);
...@@ -714,16 +709,16 @@ static inline void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff * ...@@ -714,16 +709,16 @@ static inline void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *
void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
{ {
hci_event_hdr *he = (hci_event_hdr *) skb->data; struct hci_event_hdr *hdr = (struct hci_event_hdr *) skb->data;
evt_cmd_status *cs; struct evt_cmd_complete *ec;
evt_cmd_complete *ec; struct evt_cmd_status *cs;
__u16 opcode, ocf, ogf; u16 opcode, ocf, ogf;
skb_pull(skb, HCI_EVENT_HDR_SIZE); skb_pull(skb, HCI_EVENT_HDR_SIZE);
BT_DBG("%s evt 0x%x", hdev->name, he->evt); BT_DBG("%s evt 0x%x", hdev->name, hdr->evt);
switch (he->evt) { switch (hdr->evt) {
case EVT_NUM_COMP_PKTS: case EVT_NUM_COMP_PKTS:
hci_num_comp_pkts_evt(hdev, skb); hci_num_comp_pkts_evt(hdev, skb);
break; break;
...@@ -761,8 +756,8 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -761,8 +756,8 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
break; break;
case EVT_CMD_STATUS: case EVT_CMD_STATUS:
cs = (evt_cmd_status *) skb->data; cs = (struct evt_cmd_status *) skb->data;
skb_pull(skb, EVT_CMD_STATUS_SIZE); skb_pull(skb, sizeof(cs));
opcode = __le16_to_cpu(cs->opcode); opcode = __le16_to_cpu(cs->opcode);
ogf = cmd_opcode_ogf(opcode); ogf = cmd_opcode_ogf(opcode);
...@@ -788,7 +783,7 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -788,7 +783,7 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
default: default:
BT_DBG("%s Command Status OGF %x", hdev->name, ogf); BT_DBG("%s Command Status OGF %x", hdev->name, ogf);
break; break;
}; }
if (cs->ncmd) { if (cs->ncmd) {
atomic_set(&hdev->cmd_cnt, 1); atomic_set(&hdev->cmd_cnt, 1);
...@@ -798,8 +793,8 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -798,8 +793,8 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
break; break;
case EVT_CMD_COMPLETE: case EVT_CMD_COMPLETE:
ec = (evt_cmd_complete *) skb->data; ec = (struct evt_cmd_complete *) skb->data;
skb_pull(skb, EVT_CMD_COMPLETE_SIZE); skb_pull(skb, sizeof(*ec));
opcode = __le16_to_cpu(ec->opcode); opcode = __le16_to_cpu(ec->opcode);
ogf = cmd_opcode_ogf(opcode); ogf = cmd_opcode_ogf(opcode);
...@@ -825,7 +820,7 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -825,7 +820,7 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
default: default:
BT_DBG("%s Command Completed OGF %x", hdev->name, ogf); BT_DBG("%s Command Completed OGF %x", hdev->name, ogf);
break; break;
}; }
if (ec->ncmd) { if (ec->ncmd) {
atomic_set(&hdev->cmd_cnt, 1); atomic_set(&hdev->cmd_cnt, 1);
...@@ -833,36 +828,30 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -833,36 +828,30 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
hci_sched_cmd(hdev); hci_sched_cmd(hdev);
} }
break; break;
}; }
kfree_skb(skb); kfree_skb(skb);
hdev->stat.evt_rx++; hdev->stat.evt_rx++;
} }
/* General internal stack event */ /* Generate internal stack event */
void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data) void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data)
{ {
hci_event_hdr *eh; struct hci_event_hdr *hdr;
evt_stack_internal *si; struct evt_stack_internal *ev;
struct sk_buff *skb; struct sk_buff *skb;
int size;
void *ptr;
size = HCI_EVENT_HDR_SIZE + EVT_STACK_INTERNAL_SIZE + dlen; skb = bt_skb_alloc(HCI_EVENT_HDR_SIZE + sizeof(*ev) + dlen, GFP_ATOMIC);
skb = bt_skb_alloc(size, GFP_ATOMIC);
if (!skb) if (!skb)
return; return;
ptr = skb_put(skb, size); hdr = (void *) skb_put(skb, HCI_EVENT_HDR_SIZE);
hdr->evt = EVT_STACK_INTERNAL;
eh = ptr; hdr->plen = sizeof(*ev) + dlen;
eh->evt = EVT_STACK_INTERNAL;
eh->plen = EVT_STACK_INTERNAL_SIZE + dlen;
ptr += HCI_EVENT_HDR_SIZE;
si = ptr; ev = (void *) skb_put(skb, sizeof(*ev) + dlen);
si->type = type; ev->type = type;
memcpy(si->data, data, dlen); memcpy(ev->data, data, dlen);
skb->pkt_type = HCI_EVENT_PKT; skb->pkt_type = HCI_EVENT_PKT;
skb->dev = (void *) hdev; skb->dev = (void *) hdev;
......
...@@ -584,14 +584,14 @@ static int hci_sock_create(struct socket *sock, int protocol) ...@@ -584,14 +584,14 @@ static int hci_sock_create(struct socket *sock, int protocol)
static int hci_sock_dev_event(struct notifier_block *this, unsigned long event, void *ptr) static int hci_sock_dev_event(struct notifier_block *this, unsigned long event, void *ptr)
{ {
struct hci_dev *hdev = (struct hci_dev *) ptr; struct hci_dev *hdev = (struct hci_dev *) ptr;
evt_si_device sd; struct evt_si_device ev;
BT_DBG("hdev %s event %ld", hdev->name, event); BT_DBG("hdev %s event %ld", hdev->name, event);
/* Send event to sockets */ /* Send event to sockets */
sd.event = event; ev.event = event;
sd.dev_id = hdev->id; ev.dev_id = hdev->id;
hci_si_event(NULL, EVT_SI_DEVICE, EVT_SI_DEVICE_SIZE, &sd); hci_si_event(NULL, EVT_SI_DEVICE, sizeof(ev), &ev);
if (event == HCI_DEV_UNREG) { if (event == HCI_DEV_UNREG) {
struct sock *sk; struct sock *sk;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment