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)
{
struct h4_struct *h4 = hu->priv;
register char *ptr;
hci_event_hdr *eh;
hci_acl_hdr *ah;
hci_sco_hdr *sh;
struct hci_event_hdr *eh;
struct hci_acl_hdr *ah;
struct hci_sco_hdr *sh;
register int len, type, dlen;
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)
continue;
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);
......@@ -188,7 +188,7 @@ static int h4_recv(struct hci_uart *hu, void *data, int count)
continue;
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);
BT_DBG("ACL header: dlen %d", dlen);
......@@ -197,7 +197,7 @@ static int h4_recv(struct hci_uart *hu, void *data, int count)
continue;
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);
......
......@@ -434,7 +434,7 @@ static void hci_usb_interrupt(struct urb *urb)
struct hci_usb *husb = (void *) urb->context;
struct hci_usb_scb *scb;
struct sk_buff *skb;
hci_event_hdr *eh;
struct hci_event_hdr *eh;
__u8 *data = urb->transfer_buffer;
int count = urb->actual_length;
int len = HCI_EVENT_HDR_SIZE;
......@@ -459,7 +459,7 @@ static void hci_usb_interrupt(struct urb *urb)
if (count < HCI_EVENT_HDR_SIZE)
goto bad_len;
eh = (hci_event_hdr *) data;
eh = (struct hci_event_hdr *) data;
len = eh->plen + HCI_EVENT_HDR_SIZE;
if (count > len)
......@@ -545,7 +545,7 @@ static void hci_usb_rx_complete(struct urb *urb)
struct hci_dev *hdev = (struct hci_dev *) skb->dev;
struct hci_usb *husb = (struct hci_usb *) hdev->driver_data;
int status, count = urb->actual_length;
hci_acl_hdr *ah;
struct hci_acl_hdr *ah;
int dlen, size;
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)
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);
size = HCI_ACL_HDR_SIZE + dlen;
......
......@@ -160,43 +160,42 @@ enum {
#define HCI_LM_ENCRYPT 0x0004
#define HCI_LM_TRUSTED 0x0008
/* ----- HCI Commands ----- */
/* ----- HCI Commands ---- */
/* OGF & OCF values */
/* Informational Parameters */
#define OGF_INFO_PARAM 0x04
#define OCF_READ_LOCAL_VERSION 0x0001
typedef struct {
__u8 status;
__u8 hci_ver;
__u16 hci_rev;
__u8 lmp_ver;
__u16 manufacturer;
__u16 lmp_subver;
} __attribute__ ((packed)) read_local_version_rp;
#define READ_LOCAL_VERSION_RP_SIZE 9
struct read_local_version_rp {
__u8 status;
__u8 hci_ver;
__u16 hci_rev;
__u8 lmp_ver;
__u16 manufacturer;
__u16 lmp_subver;
} __attribute__ ((packed));
#define OCF_READ_LOCAL_FEATURES 0x0003
typedef struct {
struct read_local_features_rp {
__u8 status;
__u8 features[8];
} __attribute__ ((packed)) read_local_features_rp;
} __attribute__ ((packed));
#define OCF_READ_BUFFER_SIZE 0x0005
typedef struct {
__u8 status;
__u16 acl_mtu;
__u8 sco_mtu;
__u16 acl_max_pkt;
__u16 sco_max_pkt;
} __attribute__ ((packed)) read_buffer_size_rp;
struct read_buffer_size_rp {
__u8 status;
__u16 acl_mtu;
__u8 sco_mtu;
__u16 acl_max_pkt;
__u16 sco_max_pkt;
} __attribute__ ((packed));
#define OCF_READ_BD_ADDR 0x0009
typedef struct {
__u8 status;
struct read_bd_addr_rp {
__u8 status;
bdaddr_t bdaddr;
} __attribute__ ((packed)) read_bd_addr_rp;
} __attribute__ ((packed));
/* Host Controller and Baseband */
#define OGF_HOST_CTL 0x03
......@@ -221,12 +220,11 @@ typedef struct {
#define SCAN_PAGE 0x02
#define OCF_SET_EVENT_FLT 0x0005
typedef struct {
__u8 flt_type;
__u8 cond_type;
__u8 condition[0];
} __attribute__ ((packed)) set_event_flt_cp;
#define SET_EVENT_FLT_CP_SIZE 2
struct set_event_flt_cp {
__u8 flt_type;
__u8 cond_type;
__u8 condition[0];
} __attribute__ ((packed));
/* Filter types */
#define FLT_CLEAR_ALL 0x00
......@@ -242,198 +240,147 @@ typedef struct {
#define CONN_SETUP_AUTO_OFF 0x01
#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
typedef struct {
__u8 status;
__u8 dev_class[3];
} __attribute__ ((packed)) read_class_of_dev_rp;
#define READ_CLASS_OF_DEV_RP_SIZE 4
struct read_class_of_dev_rp {
__u8 status;
__u8 dev_class[3];
} __attribute__ ((packed));
#define OCF_WRITE_CLASS_OF_DEV 0x0024
typedef struct {
__u8 dev_class[3];
} __attribute__ ((packed)) write_class_of_dev_cp;
#define WRITE_CLASS_OF_DEV_CP_SIZE 3
struct write_class_of_dev_cp {
__u8 dev_class[3];
} __attribute__ ((packed));
#define OCF_HOST_BUFFER_SIZE 0x0033
typedef struct {
__u16 acl_mtu;
__u8 sco_mtu;
__u16 acl_max_pkt;
__u16 sco_max_pkt;
} __attribute__ ((packed)) host_buffer_size_cp;
#define HOST_BUFFER_SIZE_CP_SIZE 7
struct host_buffer_size_cp {
__u16 acl_mtu;
__u8 sco_mtu;
__u16 acl_max_pkt;
__u16 sco_max_pkt;
} __attribute__ ((packed));
/* Link Control */
#define OGF_LINK_CTL 0x01
#define OCF_CREATE_CONN 0x0005
typedef struct {
struct create_conn_cp {
bdaddr_t bdaddr;
__u16 pkt_type;
__u8 pscan_rep_mode;
__u8 pscan_mode;
__u16 clock_offset;
__u8 role_switch;
} __attribute__ ((packed)) create_conn_cp;
#define CREATE_CONN_CP_SIZE 13
__u16 pkt_type;
__u8 pscan_rep_mode;
__u8 pscan_mode;
__u16 clock_offset;
__u8 role_switch;
} __attribute__ ((packed));
#define OCF_ACCEPT_CONN_REQ 0x0009
typedef struct {
struct accept_conn_req_cp {
bdaddr_t bdaddr;
__u8 role;
} __attribute__ ((packed)) accept_conn_req_cp;
#define ACCEPT_CONN_REQ_CP_SIZE 7
__u8 role;
} __attribute__ ((packed));
#define OCF_REJECT_CONN_REQ 0x000a
typedef struct {
struct reject_conn_req_cp {
bdaddr_t bdaddr;
__u8 reason;
} __attribute__ ((packed)) reject_conn_req_cp;
#define REJECT_CONN_REQ_CP_SIZE 7
__u8 reason;
} __attribute__ ((packed));
#define OCF_DISCONNECT 0x0006
typedef struct {
__u16 handle;
__u8 reason;
} __attribute__ ((packed)) disconnect_cp;
#define DISCONNECT_CP_SIZE 3
struct disconnect_cp {
__u16 handle;
__u8 reason;
} __attribute__ ((packed));
#define OCF_ADD_SCO 0x0007
typedef struct {
__u16 handle;
__u16 pkt_type;
} __attribute__ ((packed)) add_sco_cp;
#define ADD_SCO_CP_SIZE 4
struct add_sco_cp {
__u16 handle;
__u16 pkt_type;
} __attribute__ ((packed));
#define OCF_INQUIRY 0x0001
typedef struct {
__u8 lap[3];
__u8 length;
__u8 num_rsp;
} __attribute__ ((packed)) inquiry_cp;
#define INQUIRY_CP_SIZE 5
typedef struct {
__u8 status;
bdaddr_t bdaddr;
} __attribute__ ((packed)) status_bdaddr_rp;
#define STATUS_BDADDR_RP_SIZE 7
struct inquiry_cp {
__u8 lap[3];
__u8 length;
__u8 num_rsp;
} __attribute__ ((packed));
#define OCF_LINK_KEY_REPLY 0x000B
#define OCF_LINK_KEY_NEG_REPLY 0x000C
typedef struct {
struct link_key_reply_cp {
bdaddr_t bdaddr;
__u8 link_key[16];
} __attribute__ ((packed)) link_key_reply_cp;
#define LINK_KEY_REPLY_CP_SIZE 22
} __attribute__ ((packed));
#define OCF_PIN_CODE_REPLY 0x000D
#define OCF_PIN_CODE_NEG_REPLY 0x000E
typedef struct {
struct pin_code_reply_cp {
bdaddr_t bdaddr;
__u8 pin_len;
__u8 pin_code[16];
} __attribute__ ((packed)) pin_code_reply_cp;
#define PIN_CODE_REPLY_CP_SIZE 23
__u8 pin_len;
__u8 pin_code[16];
} __attribute__ ((packed));
#define OCF_CHANGE_CONN_PTYPE 0x000F
typedef struct {
__u16 handle;
__u16 pkt_type;
} __attribute__ ((packed)) change_conn_ptype_cp;
#define CHANGE_CONN_PTYPE_CP_SIZE 4
struct change_conn_ptype_cp {
__u16 handle;
__u16 pkt_type;
} __attribute__ ((packed));
#define OCF_AUTH_REQUESTED 0x0011
typedef struct {
__u16 handle;
} __attribute__ ((packed)) auth_requested_cp;
#define AUTH_REQUESTED_CP_SIZE 2
struct auth_requested_cp {
__u16 handle;
} __attribute__ ((packed));
#define OCF_SET_CONN_ENCRYPT 0x0013
typedef struct {
__u16 handle;
__u8 encrypt;
} __attribute__ ((packed)) set_conn_encrypt_cp;
#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
struct set_conn_encrypt_cp {
__u16 handle;
__u8 encrypt;
} __attribute__ ((packed));
#define OCF_READ_REMOTE_FEATURES 0x001B
typedef struct {
__u16 handle;
} __attribute__ ((packed)) read_remote_features_cp;
#define READ_REMOTE_FEATURES_CP_SIZE 2
struct read_remote_features_cp {
__u16 handle;
} __attribute__ ((packed));
#define OCF_READ_REMOTE_VERSION 0x001D
typedef struct {
__u16 handle;
} __attribute__ ((packed)) read_remote_version_cp;
#define READ_REMOTE_VERSION_CP_SIZE 2
struct read_remote_version_cp {
__u16 handle;
} __attribute__ ((packed));
/* Link Policy */
#define OGF_LINK_POLICY 0x02
#define OCF_ROLE_DISCOVERY 0x0009
typedef struct {
__u16 handle;
} __attribute__ ((packed)) role_discovery_cp;
#define ROLE_DISCOVERY_CP_SIZE 2
typedef struct {
__u8 status;
__u16 handle;
__u8 role;
} __attribute__ ((packed)) role_discovery_rp;
#define ROLE_DISCOVERY_RP_SIZE 4
struct role_discovery_cp {
__u16 handle;
} __attribute__ ((packed));
struct role_discovery_rp {
__u8 status;
__u16 handle;
__u8 role;
} __attribute__ ((packed));
#define OCF_READ_LINK_POLICY 0x000C
typedef struct {
__u16 handle;
} __attribute__ ((packed)) read_link_policy_cp;
#define READ_LINK_POLICY_CP_SIZE 2
typedef struct {
__u8 status;
__u16 handle;
__u16 policy;
} __attribute__ ((packed)) read_link_policy_rp;
#define READ_LINK_POLICY_RP_SIZE 5
struct read_link_policy_cp {
__u16 handle;
} __attribute__ ((packed));
struct read_link_policy_rp {
__u8 status;
__u16 handle;
__u16 policy;
} __attribute__ ((packed));
#define OCF_SWITCH_ROLE 0x000B
typedef struct {
struct switch_role_cp {
bdaddr_t bdaddr;
__u8 role;
} __attribute__ ((packed)) switch_role_cp;
#define SWITCH_ROLE_CP_SIZE 7
} __attribute__ ((packed));
#define OCF_WRITE_LINK_POLICY 0x000D
typedef struct {
__u16 handle;
__u16 policy;
} __attribute__ ((packed)) write_link_policy_cp;
#define WRITE_LINK_POLICY_CP_SIZE 4
typedef struct {
__u8 status;
__u16 handle;
} __attribute__ ((packed)) write_link_policy_rp;
#define WRITE_LINK_POLICY_RP_SIZE 3
struct write_link_policy_cp {
__u16 handle;
__u16 policy;
} __attribute__ ((packed));
struct write_link_policy_rp {
__u8 status;
__u16 handle;
} __attribute__ ((packed));
/* Status params */
#define OGF_STATUS_PARAM 0x05
......@@ -442,197 +389,170 @@ typedef struct {
#define EVT_INQUIRY_COMPLETE 0x01
#define EVT_INQUIRY_RESULT 0x02
typedef struct {
bdaddr_t bdaddr;
__u8 pscan_rep_mode;
__u8 pscan_period_mode;
__u8 pscan_mode;
__u8 dev_class[3];
__u16 clock_offset;
} __attribute__ ((packed)) inquiry_info;
#define INQUIRY_INFO_SIZE 14
struct inquiry_info {
bdaddr_t bdaddr;
__u8 pscan_rep_mode;
__u8 pscan_period_mode;
__u8 pscan_mode;
__u8 dev_class[3];
__u16 clock_offset;
} __attribute__ ((packed));
#define EVT_CONN_COMPLETE 0x03
typedef struct {
__u8 status;
__u16 handle;
bdaddr_t bdaddr;
__u8 link_type;
__u8 encr_mode;
} __attribute__ ((packed)) evt_conn_complete;
#define EVT_CONN_COMPLETE_SIZE 13
struct evt_conn_complete {
__u8 status;
__u16 handle;
bdaddr_t bdaddr;
__u8 link_type;
__u8 encr_mode;
} __attribute__ ((packed));
#define EVT_CONN_REQUEST 0x04
typedef struct {
bdaddr_t bdaddr;
__u8 dev_class[3];
__u8 link_type;
} __attribute__ ((packed)) evt_conn_request;
#define EVT_CONN_REQUEST_SIZE 10
struct evt_conn_request {
bdaddr_t bdaddr;
__u8 dev_class[3];
__u8 link_type;
} __attribute__ ((packed));
#define EVT_DISCONN_COMPLETE 0x05
typedef struct {
__u8 status;
__u16 handle;
__u8 reason;
} __attribute__ ((packed)) evt_disconn_complete;
#define EVT_DISCONN_COMPLETE_SIZE 4
struct evt_disconn_complete {
__u8 status;
__u16 handle;
__u8 reason;
} __attribute__ ((packed));
#define EVT_AUTH_COMPLETE 0x06
typedef struct {
__u8 status;
__u16 handle;
} __attribute__ ((packed)) evt_auth_complete;
#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
struct evt_auth_complete {
__u8 status;
__u16 handle;
} __attribute__ ((packed));
#define EVT_ENCRYPT_CHANGE 0x08
typedef struct {
__u8 status;
__u16 handle;
__u8 encrypt;
} __attribute__ ((packed)) evt_encrypt_change;
#define EVT_ENCRYPT_CHANGE_SIZE 5
#define EVT_QOS_SETUP_COMPLETE 0x0D
typedef struct {
__u8 service_type;
__u32 token_rate;
__u32 peak_bandwidth;
__u32 latency;
__u32 delay_variation;
} __attribute__ ((packed)) hci_qos;
typedef struct {
__u8 status;
__u16 handle;
hci_qos qos;
} __attribute__ ((packed)) evt_qos_setup_complete;
#define EVT_QOS_SETUP_COMPLETE_SIZE 20
struct evt_encrypt_change {
__u8 status;
__u16 handle;
__u8 encrypt;
} __attribute__ ((packed));
#define EVT_QOS_SETUP_COMPLETE 0x0D
struct hci_qos {
__u8 service_type;
__u32 token_rate;
__u32 peak_bandwidth;
__u32 latency;
__u32 delay_variation;
} __attribute__ ((packed));
struct evt_qos_setup_complete {
__u8 status;
__u16 handle;
struct hci_qos qos;
} __attribute__ ((packed));
#define EVT_CMD_COMPLETE 0x0e
typedef struct {
__u8 ncmd;
__u16 opcode;
} __attribute__ ((packed)) evt_cmd_complete;
#define EVT_CMD_COMPLETE_SIZE 3
struct evt_cmd_complete {
__u8 ncmd;
__u16 opcode;
} __attribute__ ((packed));
#define EVT_CMD_STATUS 0x0f
typedef struct {
__u8 status;
__u8 ncmd;
__u16 opcode;
} __attribute__ ((packed)) evt_cmd_status;
#define EVT_CMD_STATUS_SIZE 4
struct evt_cmd_status {
__u8 status;
__u8 ncmd;
__u16 opcode;
} __attribute__ ((packed));
#define EVT_NUM_COMP_PKTS 0x13
typedef struct {
__u8 num_hndl;
struct evt_num_comp_pkts {
__u8 num_hndl;
/* variable length part */
} __attribute__ ((packed)) evt_num_comp_pkts;
#define EVT_NUM_COMP_PKTS_SIZE 1
} __attribute__ ((packed));
#define EVT_ROLE_CHANGE 0x12
typedef struct {
__u8 status;
struct evt_role_change {
__u8 status;
bdaddr_t bdaddr;
__u8 role;
} __attribute__ ((packed)) evt_role_change;
#define EVT_ROLE_CHANGE_SIZE 8
} __attribute__ ((packed));
#define EVT_PIN_CODE_REQ 0x16
typedef struct {
struct evt_pin_code_req {
bdaddr_t bdaddr;
} __attribute__ ((packed)) evt_pin_code_req;
#define EVT_PIN_CODE_REQ_SIZE 6
} __attribute__ ((packed));
#define EVT_LINK_KEY_REQ 0x17
typedef struct {
struct evt_link_key_req {
bdaddr_t bdaddr;
} __attribute__ ((packed)) evt_link_key_req;
#define EVT_LINK_KEY_REQ_SIZE 6
} __attribute__ ((packed));
#define EVT_LINK_KEY_NOTIFY 0x18
typedef struct {
struct evt_link_key_notify {
bdaddr_t bdaddr;
__u8 link_key[16];
__u8 key_type;
} __attribute__ ((packed)) evt_link_key_notify;
#define EVT_LINK_KEY_NOTIFY_SIZE 23
} __attribute__ ((packed));
#define EVT_READ_REMOTE_FEATURES_COMPLETE 0x0B
typedef struct {
__u8 status;
__u16 handle;
__u8 features[8];
} __attribute__ ((packed)) evt_read_remote_features_complete;
#define EVT_READ_REMOTE_FEATURES_COMPLETE_SIZE 11
struct evt_read_remote_features_complete {
__u8 status;
__u16 handle;
__u8 features[8];
} __attribute__ ((packed));
#define EVT_READ_REMOTE_VERSION_COMPLETE 0x0C
typedef struct {
__u8 status;
__u16 handle;
__u8 lmp_ver;
__u16 manufacturer;
__u16 lmp_subver;
} __attribute__ ((packed)) evt_read_remote_version_complete;
#define EVT_READ_REMOTE_VERSION_COMPLETE_SIZE 8
struct evt_read_remote_version_complete {
__u8 status;
__u16 handle;
__u8 lmp_ver;
__u16 manufacturer;
__u16 lmp_subver;
} __attribute__ ((packed));
/* Internal events generated by Bluetooth stack */
#define EVT_STACK_INTERNAL 0xfd
typedef struct {
__u16 type;
__u8 data[0];
} __attribute__ ((packed)) evt_stack_internal;
#define EVT_STACK_INTERNAL_SIZE 2
struct evt_stack_internal {
__u16 type;
__u8 data[0];
} __attribute__ ((packed));
#define EVT_SI_DEVICE 0x01
typedef struct {
__u16 event;
__u16 dev_id;
} __attribute__ ((packed)) evt_si_device;
#define EVT_SI_DEVICE_SIZE 4
struct evt_si_device {
__u16 event;
__u16 dev_id;
} __attribute__ ((packed));
#define EVT_SI_SECURITY 0x02
typedef struct {
__u16 event;
__u16 proto;
__u16 subproto;
__u8 incomming;
} __attribute__ ((packed)) evt_si_security;
/* -------- HCI Packet structures -------- */
#define HCI_TYPE_LEN 1
typedef struct {
struct evt_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 3
struct hci_command_hdr {
__u16 opcode; /* OCF & OGF */
__u8 plen;
} __attribute__ ((packed)) hci_command_hdr;
#define HCI_COMMAND_HDR_SIZE 3
} __attribute__ ((packed));
typedef struct {
struct hci_event_hdr {
__u8 evt;
__u8 plen;
} __attribute__ ((packed)) hci_event_hdr;
#define HCI_EVENT_HDR_SIZE 2
} __attribute__ ((packed));
typedef struct {
struct hci_acl_hdr {
__u16 handle; /* Handle & Flags(PB, BC) */
__u16 dlen;
} __attribute__ ((packed)) hci_acl_hdr;
#define HCI_ACL_HDR_SIZE 4
} __attribute__ ((packed));
typedef struct {
struct hci_sco_hdr {
__u16 handle;
__u8 dlen;
} __attribute__ ((packed)) hci_sco_hdr;
#define HCI_SCO_HDR_SIZE 3
} __attribute__ ((packed));
/* Command opcode pack/unpack */
#define cmd_opcode_pack(ogf, ocf) (__u16)((ocf & 0x03ff)|(ogf << 10))
......@@ -644,12 +564,14 @@ typedef struct {
#define acl_handle(h) (h & 0x0fff)
#define acl_flags(h) (h >> 12)
/* HCI Socket options */
/* ---- HCI Sockets ---- */
/* Socket options */
#define HCI_DATA_DIR 1
#define HCI_FILTER 2
#define HCI_TIME_STAMP 3
/* HCI CMSG flags */
/* CMSG flags */
#define HCI_CMSG_DIR 0x0001
#define HCI_CMSG_TSTAMP 0x0002
......@@ -676,7 +598,7 @@ struct hci_ufilter {
#define HCI_FLT_OGF_BITS 63
#define HCI_FLT_OCF_BITS 127
/* Ioctl requests structures */
/* ---- HCI Ioctl requests structures ---- */
struct hci_dev_stats {
__u32 err_rx;
__u32 err_tx;
......@@ -753,11 +675,4 @@ struct hci_inquiry_req {
};
#define IREQ_CACHE_FLUSH 0x0001
struct hci_remotename_req {
__u16 dev_id;
__u16 flags;
bdaddr_t bdaddr;
__u8 name[248];
};
#endif /* __HCI_H */
......@@ -42,7 +42,7 @@
struct inquiry_entry {
struct inquiry_entry *next;
__u32 timestamp;
inquiry_info info;
struct inquiry_info info;
};
struct inquiry_cache {
......@@ -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);
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);
int inquiry_cache_dump(struct hci_dev *hdev, int num, __u8 *buf);
......
......@@ -61,7 +61,7 @@ void hci_acl_connect(struct hci_conn *conn)
{
struct hci_dev *hdev = conn->hdev;
struct inquiry_entry *ie;
create_conn_cp cp;
struct create_conn_cp cp;
BT_DBG("%p", conn);
......@@ -85,13 +85,12 @@ void hci_acl_connect(struct hci_conn *conn)
else
cp.role_switch = 0x00;
hci_send_cmd(hdev, OGF_LINK_CTL, OCF_CREATE_CONN,
CREATE_CONN_CP_SIZE, &cp);
hci_send_cmd(hdev, OGF_LINK_CTL, OCF_CREATE_CONN, sizeof(cp), &cp);
}
void hci_acl_disconn(struct hci_conn *conn, __u8 reason)
{
disconnect_cp cp;
struct disconnect_cp cp;
BT_DBG("%p", conn);
......@@ -99,14 +98,13 @@ void hci_acl_disconn(struct hci_conn *conn, __u8 reason)
cp.handle = __cpu_to_le16(conn->handle);
cp.reason = reason;
hci_send_cmd(conn->hdev, OGF_LINK_CTL, OCF_DISCONNECT,
DISCONNECT_CP_SIZE, &cp);
hci_send_cmd(conn->hdev, OGF_LINK_CTL, OCF_DISCONNECT, sizeof(cp), &cp);
}
void hci_add_sco(struct hci_conn *conn, __u16 handle)
{
struct hci_dev *hdev = conn->hdev;
add_sco_cp cp;
struct add_sco_cp cp;
BT_DBG("%p", conn);
......@@ -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.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)
......@@ -300,10 +298,9 @@ int hci_conn_auth(struct hci_conn *conn)
return 1;
if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->pend)) {
auth_requested_cp ar;
ar.handle = __cpu_to_le16(conn->handle);
hci_send_cmd(conn->hdev, OGF_LINK_CTL, OCF_AUTH_REQUESTED,
AUTH_REQUESTED_CP_SIZE, &ar);
struct auth_requested_cp cp;
cp.handle = __cpu_to_le16(conn->handle);
hci_send_cmd(conn->hdev, OGF_LINK_CTL, OCF_AUTH_REQUESTED, sizeof(cp), &cp);
}
return 0;
}
......@@ -320,11 +317,10 @@ int hci_conn_encrypt(struct hci_conn *conn)
return 0;
if (hci_conn_auth(conn)) {
set_conn_encrypt_cp ce;
ce.handle = __cpu_to_le16(conn->handle);
ce.encrypt = 1;
hci_send_cmd(conn->hdev, OGF_LINK_CTL, OCF_SET_CONN_ENCRYPT,
SET_CONN_ENCRYPT_CP_SIZE, &ce);
struct set_conn_encrypt_cp cp;
cp.handle = __cpu_to_le16(conn->handle);
cp.encrypt = 1;
hci_send_cmd(conn->hdev, OGF_LINK_CTL, OCF_SET_CONN_ENCRYPT, sizeof(cp), &cp);
}
return 0;
}
......
......@@ -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)
{
set_event_flt_cp ef;
__u16 param;
BT_DBG("%s %ld", hdev->name, opt);
......@@ -226,13 +225,12 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
#if 0
/* Host buffer size */
{
host_buffer_size_cp bs;
bs.acl_mtu = __cpu_to_le16(HCI_MAX_ACL_SIZE);
bs.sco_mtu = HCI_MAX_SCO_SIZE;
bs.acl_max_pkt = __cpu_to_le16(0xffff);
bs.sco_max_pkt = __cpu_to_le16(0xffff);
hci_send_cmd(hdev, OGF_HOST_CTL, OCF_HOST_BUFFER_SIZE,
HOST_BUFFER_SIZE_CP_SIZE, &bs);
struct host_buffer_size_cp cp;
cp.acl_mtu = __cpu_to_le16(HCI_MAX_ACL_SIZE);
cp.sco_mtu = HCI_MAX_SCO_SIZE;
cp.acl_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, sizeof(cp), &cp);
}
#endif
......@@ -242,8 +240,11 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
/* Optional initialization */
/* 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 */
param = __cpu_to_le16(0x8000);
......@@ -338,7 +339,7 @@ struct inquiry_entry *inquiry_cache_lookup(struct hci_dev *hdev, bdaddr_t *bdadd
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_entry *e;
......@@ -354,7 +355,7 @@ void inquiry_cache_update(struct hci_dev *hdev, inquiry_info *info)
cache->list = e;
}
memcpy(&e->info, info, sizeof(inquiry_info));
memcpy(&e->info, info, sizeof(*info));
e->timestamp = jiffies;
cache->timestamp = jiffies;
}
......@@ -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)
{
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;
int copied = 0;
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);
return copied;
......@@ -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)
{
struct hci_inquiry_req *ir = (struct hci_inquiry_req *) opt;
inquiry_cp ic;
struct inquiry_cp cp;
BT_DBG("%s", hdev->name);
......@@ -384,10 +385,10 @@ static void hci_inq_req(struct hci_dev *hdev, unsigned long opt)
return;
/* Start Inquiry */
memcpy(&ic.lap, &ir->lap, 3);
ic.length = ir->length;
ic.num_rsp = ir->num_rsp;
hci_send_cmd(hdev, OGF_LINK_CTL, OCF_INQUIRY, INQUIRY_CP_SIZE, &ic);
memcpy(&cp.lap, &ir->lap, 3);
cp.length = ir->length;
cp.num_rsp = ir->num_rsp;
hci_send_cmd(hdev, OGF_LINK_CTL, OCF_INQUIRY, sizeof(cp), &cp);
}
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
* 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;
goto done;
}
......@@ -432,10 +433,10 @@ int hci_inquiry(unsigned long arg)
BT_DBG("num_rsp %d", ir.num_rsp);
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));
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
err = -EFAULT;
......@@ -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 len = HCI_COMMAND_HDR_SIZE + plen;
hci_command_hdr *hc;
struct hci_command_hdr *hdr;
struct sk_buff *skb;
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);
return -ENOMEM;
}
hc = (hci_command_hdr *) skb_put(skb, HCI_COMMAND_HDR_SIZE);
hc->opcode = __cpu_to_le16(cmd_opcode_pack(ogf, ocf));
hc->plen = plen;
hdr = (struct hci_command_hdr *) skb_put(skb, HCI_COMMAND_HDR_SIZE);
hdr->opcode = __cpu_to_le16(cmd_opcode_pack(ogf, ocf));
hdr->plen = plen;
if (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
/* Get data from the previously sent command */
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)
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;
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)
/* Send ACL data */
static void hci_add_acl_hdr(struct sk_buff *skb, __u16 handle, __u16 flags)
{
struct hci_acl_hdr *hdr;
int len = skb->len;
hci_acl_hdr *ah;
ah = (hci_acl_hdr *) skb_push(skb, HCI_ACL_HDR_SIZE);
ah->handle = __cpu_to_le16(acl_handle_pack(handle, flags));
ah->dlen = __cpu_to_le16(len);
hdr = (struct hci_acl_hdr *) skb_push(skb, HCI_ACL_HDR_SIZE);
hdr->handle = __cpu_to_le16(acl_handle_pack(handle, flags));
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)
......@@ -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)
{
struct hci_dev *hdev = conn->hdev;
hci_sco_hdr hs;
struct hci_sco_hdr hdr;
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)
return -EINVAL;
}
hs.handle = __cpu_to_le16(conn->handle);
hs.dlen = skb->len;
hdr.handle = __cpu_to_le16(conn->handle);
hdr.dlen = skb->len;
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->pkt_type = HCI_SCODATA_PKT;
......@@ -1271,13 +1273,13 @@ static void hci_tx_task(unsigned long arg)
/* ACL data packet */
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;
__u16 handle, flags;
skb_pull(skb, HCI_ACL_HDR_SIZE);
handle = __le16_to_cpu(ah->handle);
handle = __le16_to_cpu(hdr->handle);
flags = acl_flags(handle);
handle = acl_handle(handle);
......@@ -1308,13 +1310,13 @@ static inline void hci_acldata_packet(struct hci_dev *hdev, struct sk_buff *skb)
/* SCO data packet */
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;
__u16 handle;
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);
......
......@@ -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)
{
struct hci_conn *conn;
role_discovery_rp *rd;
struct role_discovery_rp *rd;
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
/* Command Complete OGF INFO_PARAM */
static void hci_cc_info_param(struct hci_dev *hdev, __u16 ocf, struct sk_buff *skb)
{
read_local_features_rp *lf;
read_buffer_size_rp *bs;
read_bd_addr_rp *ba;
struct read_local_features_rp *lf;
struct read_buffer_size_rp *bs;
struct read_bd_addr_rp *ba;
BT_DBG("%s ocf 0x%x", hdev->name, ocf);
switch (ocf) {
case OCF_READ_LOCAL_FEATURES:
lf = (read_local_features_rp *) skb->data;
lf = (struct read_local_features_rp *) skb->data;
if (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
break;
case OCF_READ_BUFFER_SIZE:
bs = (read_buffer_size_rp *) skb->data;
bs = (struct read_buffer_size_rp *) skb->data;
if (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
break;
case OCF_READ_BD_ADDR:
ba = (read_bd_addr_rp *) skb->data;
ba = (struct read_bd_addr_rp *) skb->data;
if (!ba->status) {
bacpy(&hdev->bdaddr, &ba->bdaddr);
......@@ -294,16 +294,16 @@ 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)
{
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;
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);
if (status) {
......@@ -314,7 +314,7 @@ static inline void hci_cs_create_conn(struct hci_dev *hdev, __u8 status)
}
} else {
if (!conn) {
conn = hci_conn_add(hdev, ACL_LINK, &cc->bdaddr);
conn = hci_conn_add(hdev, ACL_LINK, &cp->bdaddr);
if (conn) {
conn->out = 1;
conn->link_mode |= HCI_LM_MASTER;
......@@ -338,8 +338,7 @@ static void hci_cs_link_ctl(struct hci_dev *hdev, __u16 ocf, __u8 status)
case OCF_ADD_SCO:
if (status) {
struct hci_conn *acl, *sco;
add_sco_cp *cp = hci_sent_cmd_data(hdev,
OGF_LINK_CTL, OCF_ADD_SCO);
struct add_sco_cp *cp = hci_sent_cmd_data(hdev, OGF_LINK_CTL, OCF_ADD_SCO);
__u16 handle;
if (!cp)
......@@ -429,7 +428,7 @@ static inline void hci_inquiry_complete_evt(struct hci_dev *hdev, struct sk_buff
/* Inquiry Result */
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);
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 *
/* Connect Request */
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;
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) {
/* Connection accepted */
struct hci_conn *conn;
accept_conn_req_cp ac;
struct accept_conn_req_cp cp;
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 = 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");
hci_dev_unlock(hdev);
return;
......@@ -468,44 +467,42 @@ static inline void hci_conn_request_evt(struct hci_dev *hdev, struct sk_buff *sk
conn->state = BT_CONNECT;
hci_dev_unlock(hdev);
bacpy(&ac.bdaddr, &cr->bdaddr);
bacpy(&cp.bdaddr, &ev->bdaddr);
if (lmp_rswitch_capable(hdev) && (mask & HCI_LM_MASTER))
ac.role = 0x00; /* Become master */
cp.role = 0x00; /* Become master */
else
ac.role = 0x01; /* Remain slave */
cp.role = 0x01; /* Remain slave */
hci_send_cmd(hdev, OGF_LINK_CTL, OCF_ACCEPT_CONN_REQ,
ACCEPT_CONN_REQ_CP_SIZE, &ac);
hci_send_cmd(hdev, OGF_LINK_CTL, OCF_ACCEPT_CONN_REQ, sizeof(cp), &cp);
} else {
/* Connection rejected */
reject_conn_req_cp rc;
struct reject_conn_req_cp cp;
bacpy(&rc.bdaddr, &cr->bdaddr);
rc.reason = 0x0f;
hci_send_cmd(hdev, OGF_LINK_CTL, OCF_REJECT_CONN_REQ,
REJECT_CONN_REQ_CP_SIZE, &rc);
bacpy(&cp.bdaddr, &ev->bdaddr);
cp.reason = 0x0f;
hci_send_cmd(hdev, OGF_LINK_CTL, OCF_REJECT_CONN_REQ, sizeof(cp), &cp);
}
}
/* Connect Complete */
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;
BT_DBG("%s", hdev->name);
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) {
hci_dev_unlock(hdev);
return;
}
if (!cc->status) {
conn->handle = __le16_to_cpu(cc->handle);
if (!ev->status) {
conn->handle = __le16_to_cpu(ev->handle);
conn->state = BT_CONNECTED;
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
/* Set link policy */
if (conn->type == ACL_LINK && hdev->link_policy) {
write_link_policy_cp lp;
lp.handle = cc->handle;
lp.policy = __cpu_to_le16(hdev->link_policy);
hci_send_cmd(hdev, OGF_LINK_POLICY, OCF_WRITE_LINK_POLICY,
WRITE_LINK_POLICY_CP_SIZE, &lp);
struct write_link_policy_cp cp;
cp.handle = ev->handle;
cp.policy = __cpu_to_le16(hdev->link_policy);
hci_send_cmd(hdev, OGF_LINK_POLICY, OCF_WRITE_LINK_POLICY, sizeof(cp), &cp);
}
/* Set packet type for incomming connection */
if (!conn->out) {
change_conn_ptype_cp cp;
cp.handle = cc->handle;
struct change_conn_ptype_cp cp;
cp.handle = ev->handle;
cp.pkt_type = (conn->type == ACL_LINK) ?
__cpu_to_le16(hdev->pkt_type & ACL_PTYPE_MASK):
__cpu_to_le16(hdev->pkt_type & SCO_PTYPE_MASK);
hci_send_cmd(hdev, OGF_LINK_CTL, OCF_CHANGE_CONN_PTYPE,
CHANGE_CONN_PTYPE_CP_SIZE, &cp);
hci_send_cmd(hdev, OGF_LINK_CTL, OCF_CHANGE_CONN_PTYPE, sizeof(cp), &cp);
}
} else
conn->state = BT_CLOSED;
......@@ -541,17 +536,17 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s
if (conn->type == ACL_LINK) {
struct hci_conn *sco = conn->link;
if (sco) {
if (!cc->status)
if (!ev->status)
hci_add_sco(sco, conn->handle);
else {
hci_proto_connect_cfm(sco, cc->status);
hci_proto_connect_cfm(sco, ev->status);
hci_conn_del(sco);
}
}
}
hci_proto_connect_cfm(conn, cc->status);
if (cc->status)
hci_proto_connect_cfm(conn, ev->status);
if (ev->status)
hci_conn_del(conn);
hci_dev_unlock(hdev);
......@@ -560,13 +555,13 @@ static inline void hci_conn_complete_evt(struct hci_dev *hdev, struct sk_buff *s
/* Disconnect Complete */
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;
__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;
hci_dev_lock(hdev);
......@@ -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);
if (conn) {
conn->state = BT_CLOSED;
hci_proto_disconn_ind(conn, dc->reason);
hci_proto_disconn_ind(conn, ev->reason);
hci_conn_del(conn);
}
......@@ -584,22 +579,22 @@ static inline void hci_disconn_complete_evt(struct hci_dev *hdev, struct sk_buff
/* Number of completed packets */
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;
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);
return;
}
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;
__u16 handle, count;
......@@ -627,19 +622,19 @@ static inline void hci_num_comp_pkts_evt(struct hci_dev *hdev, struct sk_buff *s
/* Role Change */
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;
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;
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 (rc->role)
if (ev->role)
conn->link_mode &= ~HCI_LM_MASTER;
else
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
/* Authentication Complete */
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;
__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);
conn = conn_hash_lookup_handle(hdev, handle);
if (conn) {
if (!ac->status)
if (!ev->status)
conn->link_mode |= HCI_LM_AUTH;
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 (!ac->status) {
set_conn_encrypt_cp ce;
ce.handle = __cpu_to_le16(conn->handle);
ce.encrypt = 1;
if (!ev->status) {
struct set_conn_encrypt_cp cp;
cp.handle = __cpu_to_le16(conn->handle);
cp.encrypt = 1;
hci_send_cmd(conn->hdev, OGF_LINK_CTL,
OCF_SET_CONN_ENCRYPT,
SET_CONN_ENCRYPT_CP_SIZE, &ce);
sizeof(cp), &cp);
} else {
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
/* Encryption Change */
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;
__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);
conn = conn_hash_lookup_handle(hdev, handle);
if (conn) {
if (!ec->status) {
if (ec->encrypt)
if (!ev->status) {
if (ev->encrypt)
conn->link_mode |= HCI_LM_ENCRYPT;
else
conn->link_mode &= ~HCI_LM_ENCRYPT;
}
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);
......@@ -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)
{
hci_event_hdr *he = (hci_event_hdr *) skb->data;
evt_cmd_status *cs;
evt_cmd_complete *ec;
__u16 opcode, ocf, ogf;
struct hci_event_hdr *hdr = (struct hci_event_hdr *) skb->data;
struct evt_cmd_complete *ec;
struct evt_cmd_status *cs;
u16 opcode, ocf, ogf;
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:
hci_num_comp_pkts_evt(hdev, skb);
break;
......@@ -761,8 +756,8 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
break;
case EVT_CMD_STATUS:
cs = (evt_cmd_status *) skb->data;
skb_pull(skb, EVT_CMD_STATUS_SIZE);
cs = (struct evt_cmd_status *) skb->data;
skb_pull(skb, sizeof(cs));
opcode = __le16_to_cpu(cs->opcode);
ogf = cmd_opcode_ogf(opcode);
......@@ -788,7 +783,7 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
default:
BT_DBG("%s Command Status OGF %x", hdev->name, ogf);
break;
};
}
if (cs->ncmd) {
atomic_set(&hdev->cmd_cnt, 1);
......@@ -798,8 +793,8 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
break;
case EVT_CMD_COMPLETE:
ec = (evt_cmd_complete *) skb->data;
skb_pull(skb, EVT_CMD_COMPLETE_SIZE);
ec = (struct evt_cmd_complete *) skb->data;
skb_pull(skb, sizeof(*ec));
opcode = __le16_to_cpu(ec->opcode);
ogf = cmd_opcode_ogf(opcode);
......@@ -825,7 +820,7 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
default:
BT_DBG("%s Command Completed OGF %x", hdev->name, ogf);
break;
};
}
if (ec->ncmd) {
atomic_set(&hdev->cmd_cnt, 1);
......@@ -833,36 +828,30 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
hci_sched_cmd(hdev);
}
break;
};
}
kfree_skb(skb);
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)
{
hci_event_hdr *eh;
evt_stack_internal *si;
struct hci_event_hdr *hdr;
struct evt_stack_internal *ev;
struct sk_buff *skb;
int size;
void *ptr;
size = HCI_EVENT_HDR_SIZE + EVT_STACK_INTERNAL_SIZE + dlen;
skb = bt_skb_alloc(size, GFP_ATOMIC);
skb = bt_skb_alloc(HCI_EVENT_HDR_SIZE + sizeof(*ev) + dlen, GFP_ATOMIC);
if (!skb)
return;
ptr = skb_put(skb, size);
eh = ptr;
eh->evt = EVT_STACK_INTERNAL;
eh->plen = EVT_STACK_INTERNAL_SIZE + dlen;
ptr += HCI_EVENT_HDR_SIZE;
hdr = (void *) skb_put(skb, HCI_EVENT_HDR_SIZE);
hdr->evt = EVT_STACK_INTERNAL;
hdr->plen = sizeof(*ev) + dlen;
si = ptr;
si->type = type;
memcpy(si->data, data, dlen);
ev = (void *) skb_put(skb, sizeof(*ev) + dlen);
ev->type = type;
memcpy(ev->data, data, dlen);
skb->pkt_type = HCI_EVENT_PKT;
skb->dev = (void *) hdev;
......
......@@ -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)
{
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);
/* Send event to sockets */
sd.event = event;
sd.dev_id = hdev->id;
hci_si_event(NULL, EVT_SI_DEVICE, EVT_SI_DEVICE_SIZE, &sd);
ev.event = event;
ev.dev_id = hdev->id;
hci_si_event(NULL, EVT_SI_DEVICE, sizeof(ev), &ev);
if (event == HCI_DEV_UNREG) {
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