Commit 1d49f2e7 authored by David S. Miller's avatar David S. Miller

Merge http://linux-mh.bkbits.net/bluetooth-2.6

into nuts.davemloft.net:/disk1/BK/net-2.6
parents 846cd60b 957389f9
......@@ -264,7 +264,7 @@ static void bcm203x_disconnect(struct usb_interface *intf)
BT_DBG("intf %p", intf);
usb_unlink_urb(data->urb);
usb_kill_urb(data->urb);
usb_set_intfdata(intf, NULL);
......
......@@ -123,7 +123,7 @@ static void bfusb_unlink_urbs(struct bfusb *bfusb)
while ((skb = skb_dequeue(&bfusb->pending_q))) {
urb = ((struct bfusb_scb *) skb->cb)->urb;
usb_unlink_urb(urb);
usb_kill_urb(urb);
skb_queue_tail(&bfusb->completed_q, skb);
}
......
......@@ -92,14 +92,14 @@ typedef struct bluecard_info_t {
} bluecard_info_t;
void bluecard_config(dev_link_t *link);
void bluecard_release(dev_link_t *link);
int bluecard_event(event_t event, int priority, event_callback_args_t *args);
static void bluecard_config(dev_link_t *link);
static void bluecard_release(dev_link_t *link);
static int bluecard_event(event_t event, int priority, event_callback_args_t *args);
static dev_info_t dev_info = "bluecard_cs";
dev_link_t *bluecard_attach(void);
void bluecard_detach(dev_link_t *);
static dev_link_t *bluecard_attach(void);
static void bluecard_detach(dev_link_t *);
static dev_link_t *dev_list = NULL;
......@@ -172,7 +172,7 @@ static dev_link_t *dev_list = NULL;
/* ======================== LED handling routines ======================== */
void bluecard_activity_led_timeout(u_long arg)
static void bluecard_activity_led_timeout(u_long arg)
{
bluecard_info_t *info = (bluecard_info_t *)arg;
unsigned int iobase = info->link.io.BasePort1;
......@@ -721,7 +721,7 @@ static int bluecard_hci_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned l
/* ======================== Card services HCI interaction ======================== */
int bluecard_open(bluecard_info_t *info)
static int bluecard_open(bluecard_info_t *info)
{
unsigned int iobase = info->link.io.BasePort1;
struct hci_dev *hdev;
......@@ -839,7 +839,7 @@ int bluecard_open(bluecard_info_t *info)
}
int bluecard_close(bluecard_info_t *info)
static int bluecard_close(bluecard_info_t *info)
{
unsigned int iobase = info->link.io.BasePort1;
struct hci_dev *hdev = info->hdev;
......@@ -866,7 +866,7 @@ int bluecard_close(bluecard_info_t *info)
return 0;
}
dev_link_t *bluecard_attach(void)
static dev_link_t *bluecard_attach(void)
{
bluecard_info_t *info;
client_reg_t client_reg;
......@@ -924,7 +924,7 @@ dev_link_t *bluecard_attach(void)
}
void bluecard_detach(dev_link_t *link)
static void bluecard_detach(dev_link_t *link)
{
bluecard_info_t *info = link->priv;
dev_link_t **linkp;
......@@ -969,7 +969,7 @@ static int first_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse
return pcmcia_parse_tuple(handle, tuple, parse);
}
void bluecard_config(dev_link_t *link)
static void bluecard_config(dev_link_t *link)
{
client_handle_t handle = link->handle;
bluecard_info_t *info = link->priv;
......@@ -1044,7 +1044,7 @@ void bluecard_config(dev_link_t *link)
}
void bluecard_release(dev_link_t *link)
static void bluecard_release(dev_link_t *link)
{
bluecard_info_t *info = link->priv;
......@@ -1063,7 +1063,7 @@ void bluecard_release(dev_link_t *link)
}
int bluecard_event(event_t event, int priority, event_callback_args_t *args)
static int bluecard_event(event_t event, int priority, event_callback_args_t *args)
{
dev_link_t *link = args->client_data;
bluecard_info_t *info = link->priv;
......
......@@ -96,14 +96,14 @@ typedef struct bt3c_info_t {
} bt3c_info_t;
void bt3c_config(dev_link_t *link);
void bt3c_release(dev_link_t *link);
int bt3c_event(event_t event, int priority, event_callback_args_t *args);
static void bt3c_config(dev_link_t *link);
static void bt3c_release(dev_link_t *link);
static int bt3c_event(event_t event, int priority, event_callback_args_t *args);
static dev_info_t dev_info = "bt3c_cs";
dev_link_t *bt3c_attach(void);
void bt3c_detach(dev_link_t *);
static dev_link_t *bt3c_attach(void);
static void bt3c_detach(dev_link_t *);
static dev_link_t *dev_list = NULL;
......@@ -132,28 +132,28 @@ static dev_link_t *dev_list = NULL;
#define CONTROL 4
inline void bt3c_address(unsigned int iobase, unsigned short addr)
static inline void bt3c_address(unsigned int iobase, unsigned short addr)
{
outb(addr & 0xff, iobase + ADDR_L);
outb((addr >> 8) & 0xff, iobase + ADDR_H);
}
inline void bt3c_put(unsigned int iobase, unsigned short value)
static inline void bt3c_put(unsigned int iobase, unsigned short value)
{
outb(value & 0xff, iobase + DATA_L);
outb((value >> 8) & 0xff, iobase + DATA_H);
}
inline void bt3c_io_write(unsigned int iobase, unsigned short addr, unsigned short value)
static inline void bt3c_io_write(unsigned int iobase, unsigned short addr, unsigned short value)
{
bt3c_address(iobase, addr);
bt3c_put(iobase, value);
}
inline unsigned short bt3c_get(unsigned int iobase)
static inline unsigned short bt3c_get(unsigned int iobase)
{
unsigned short value = inb(iobase + DATA_L);
......@@ -163,7 +163,7 @@ inline unsigned short bt3c_get(unsigned int iobase)
}
inline unsigned short bt3c_read(unsigned int iobase, unsigned short addr)
static inline unsigned short bt3c_read(unsigned int iobase, unsigned short addr)
{
bt3c_address(iobase, addr);
......@@ -587,7 +587,7 @@ static int bt3c_load_firmware(bt3c_info_t *info, unsigned char *firmware, int co
}
int bt3c_open(bt3c_info_t *info)
static int bt3c_open(bt3c_info_t *info)
{
const struct firmware *firmware;
struct hci_dev *hdev;
......@@ -657,7 +657,7 @@ int bt3c_open(bt3c_info_t *info)
}
int bt3c_close(bt3c_info_t *info)
static int bt3c_close(bt3c_info_t *info)
{
struct hci_dev *hdev = info->hdev;
......@@ -674,7 +674,7 @@ int bt3c_close(bt3c_info_t *info)
return 0;
}
dev_link_t *bt3c_attach(void)
static dev_link_t *bt3c_attach(void)
{
bt3c_info_t *info;
client_reg_t client_reg;
......@@ -732,7 +732,7 @@ dev_link_t *bt3c_attach(void)
}
void bt3c_detach(dev_link_t *link)
static void bt3c_detach(dev_link_t *link)
{
bt3c_info_t *info = link->priv;
dev_link_t **linkp;
......@@ -786,7 +786,7 @@ static int next_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
return get_tuple(handle, tuple, parse);
}
void bt3c_config(dev_link_t *link)
static void bt3c_config(dev_link_t *link)
{
static ioaddr_t base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
client_handle_t handle = link->handle;
......@@ -899,7 +899,7 @@ void bt3c_config(dev_link_t *link)
}
void bt3c_release(dev_link_t *link)
static void bt3c_release(dev_link_t *link)
{
bt3c_info_t *info = link->priv;
......@@ -916,7 +916,7 @@ void bt3c_release(dev_link_t *link)
}
int bt3c_event(event_t event, int priority, event_callback_args_t *args)
static int bt3c_event(event_t event, int priority, event_callback_args_t *args)
{
dev_link_t *link = args->client_data;
bt3c_info_t *info = link->priv;
......
......@@ -92,14 +92,14 @@ typedef struct btuart_info_t {
} btuart_info_t;
void btuart_config(dev_link_t *link);
void btuart_release(dev_link_t *link);
int btuart_event(event_t event, int priority, event_callback_args_t *args);
static void btuart_config(dev_link_t *link);
static void btuart_release(dev_link_t *link);
static int btuart_event(event_t event, int priority, event_callback_args_t *args);
static dev_info_t dev_info = "btuart_cs";
dev_link_t *btuart_attach(void);
void btuart_detach(dev_link_t *);
static dev_link_t *btuart_attach(void);
static void btuart_detach(dev_link_t *);
static dev_link_t *dev_list = NULL;
......@@ -492,7 +492,7 @@ static int btuart_hci_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned lon
/* ======================== Card services HCI interaction ======================== */
int btuart_open(btuart_info_t *info)
static int btuart_open(btuart_info_t *info)
{
unsigned long flags;
unsigned int iobase = info->link.io.BasePort1;
......@@ -561,7 +561,7 @@ int btuart_open(btuart_info_t *info)
}
int btuart_close(btuart_info_t *info)
static int btuart_close(btuart_info_t *info)
{
unsigned long flags;
unsigned int iobase = info->link.io.BasePort1;
......@@ -590,7 +590,7 @@ int btuart_close(btuart_info_t *info)
return 0;
}
dev_link_t *btuart_attach(void)
static dev_link_t *btuart_attach(void)
{
btuart_info_t *info;
client_reg_t client_reg;
......@@ -648,7 +648,7 @@ dev_link_t *btuart_attach(void)
}
void btuart_detach(dev_link_t *link)
static void btuart_detach(dev_link_t *link)
{
btuart_info_t *info = link->priv;
dev_link_t **linkp;
......@@ -702,7 +702,7 @@ static int next_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
return get_tuple(handle, tuple, parse);
}
void btuart_config(dev_link_t *link)
static void btuart_config(dev_link_t *link)
{
static ioaddr_t base[5] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, 0x0 };
client_handle_t handle = link->handle;
......@@ -816,7 +816,7 @@ void btuart_config(dev_link_t *link)
}
void btuart_release(dev_link_t *link)
static void btuart_release(dev_link_t *link)
{
btuart_info_t *info = link->priv;
......@@ -833,7 +833,7 @@ void btuart_release(dev_link_t *link)
}
int btuart_event(event_t event, int priority, event_callback_args_t *args)
static int btuart_event(event_t event, int priority, event_callback_args_t *args)
{
dev_link_t *link = args->client_data;
btuart_info_t *info = link->priv;
......
......@@ -95,14 +95,14 @@ typedef struct dtl1_info_t {
} dtl1_info_t;
void dtl1_config(dev_link_t *link);
void dtl1_release(dev_link_t *link);
int dtl1_event(event_t event, int priority, event_callback_args_t *args);
static void dtl1_config(dev_link_t *link);
static void dtl1_release(dev_link_t *link);
static int dtl1_event(event_t event, int priority, event_callback_args_t *args);
static dev_info_t dev_info = "dtl1_cs";
dev_link_t *dtl1_attach(void);
void dtl1_detach(dev_link_t *);
static dev_link_t *dtl1_attach(void);
static void dtl1_detach(dev_link_t *);
static dev_link_t *dev_list = NULL;
......@@ -469,7 +469,7 @@ static int dtl1_hci_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long
/* ======================== Card services HCI interaction ======================== */
int dtl1_open(dtl1_info_t *info)
static int dtl1_open(dtl1_info_t *info)
{
unsigned long flags;
unsigned int iobase = info->link.io.BasePort1;
......@@ -540,7 +540,7 @@ int dtl1_open(dtl1_info_t *info)
}
int dtl1_close(dtl1_info_t *info)
static int dtl1_close(dtl1_info_t *info)
{
unsigned long flags;
unsigned int iobase = info->link.io.BasePort1;
......@@ -569,7 +569,7 @@ int dtl1_close(dtl1_info_t *info)
return 0;
}
dev_link_t *dtl1_attach(void)
static dev_link_t *dtl1_attach(void)
{
dtl1_info_t *info;
client_reg_t client_reg;
......@@ -627,7 +627,7 @@ dev_link_t *dtl1_attach(void)
}
void dtl1_detach(dev_link_t *link)
static void dtl1_detach(dev_link_t *link)
{
dtl1_info_t *info = link->priv;
dev_link_t **linkp;
......@@ -681,7 +681,7 @@ static int next_tuple(client_handle_t handle, tuple_t *tuple, cisparse_t *parse)
return get_tuple(handle, tuple, parse);
}
void dtl1_config(dev_link_t *link)
static void dtl1_config(dev_link_t *link)
{
client_handle_t handle = link->handle;
dtl1_info_t *info = link->priv;
......@@ -768,7 +768,7 @@ void dtl1_config(dev_link_t *link)
}
void dtl1_release(dev_link_t *link)
static void dtl1_release(dev_link_t *link)
{
dtl1_info_t *info = link->priv;
......@@ -785,7 +785,7 @@ void dtl1_release(dev_link_t *link)
}
int dtl1_event(event_t event, int priority, event_callback_args_t *args)
static int dtl1_event(event_t event, int priority, event_callback_args_t *args)
{
dev_link_t *link = args->client_data;
dtl1_info_t *info = link->priv;
......
......@@ -120,7 +120,7 @@ static struct usb_device_id blacklist_ids[] = {
{ } /* Terminating entry */
};
struct _urb *_urb_alloc(int isoc, int gfp)
static struct _urb *_urb_alloc(int isoc, int gfp)
{
struct _urb *_urb = kmalloc(sizeof(struct _urb) +
sizeof(struct usb_iso_packet_descriptor) * isoc, gfp);
......@@ -131,7 +131,7 @@ struct _urb *_urb_alloc(int isoc, int gfp)
return _urb;
}
struct _urb *_urb_dequeue(struct _urb_queue *q)
static struct _urb *_urb_dequeue(struct _urb_queue *q)
{
struct _urb *_urb = NULL;
unsigned long flags;
......@@ -805,7 +805,7 @@ static void hci_usb_notify(struct hci_dev *hdev, unsigned int evt)
BT_DBG("%s evt %d", hdev->name, evt);
}
int hci_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
static int hci_usb_probe(struct usb_interface *intf, const struct usb_device_id *id)
{
struct usb_device *udev = interface_to_usbdev(intf);
struct usb_host_endpoint *bulk_out_ep = NULL;
......
......@@ -56,8 +56,6 @@ struct _urb {
struct urb urb;
};
struct _urb *_urb_alloc(int isoc, int gfp);
static inline void _urb_free(struct _urb *_urb)
{
kfree(_urb);
......@@ -96,8 +94,6 @@ static inline void _urb_unlink(struct _urb *_urb)
}
}
struct _urb *_urb_dequeue(struct _urb_queue *q);
struct hci_usb {
struct hci_dev *hdev;
......
......@@ -338,7 +338,7 @@ static struct miscdevice hci_vhci_miscdev=
&hci_vhci_fops
};
int __init hci_vhci_init(void)
static int __init hci_vhci_init(void)
{
BT_INFO("VHCI driver ver %s", VERSION);
......@@ -350,7 +350,7 @@ int __init hci_vhci_init(void)
return 0;
}
void hci_vhci_cleanup(void)
static void hci_vhci_cleanup(void)
{
misc_deregister(&hci_vhci_miscdev);
}
......
......@@ -366,6 +366,11 @@ struct hci_cp_set_conn_encrypt {
__u8 encrypt;
} __attribute__ ((packed));
#define OCF_CHANGE_CONN_LINK_KEY 0x0015
struct hci_cp_change_conn_link_key {
__u16 handle;
} __attribute__ ((packed));
#define OCF_READ_REMOTE_FEATURES 0x001B
struct hci_cp_read_rmt_features {
__u16 handle;
......@@ -482,6 +487,12 @@ struct hci_ev_encrypt_change {
__u8 encrypt;
} __attribute__ ((packed));
#define HCI_EV_CHANGE_CONN_LINK_KEY_COMPLETE 0x09
struct hci_ev_change_conn_link_key_complete {
__u8 status;
__u16 handle;
} __attribute__ ((packed));
#define HCI_EV_QOS_SETUP_COMPLETE 0x0D
struct hci_qos {
__u8 service_type;
......@@ -522,6 +533,14 @@ struct hci_ev_role_change {
__u8 role;
} __attribute__ ((packed));
#define HCI_EV_MODE_CHANGE 0x14
struct hci_ev_mode_change {
__u8 status;
__u16 handle;
__u8 mode;
__u16 interval;
} __attribute__ ((packed));
#define HCI_EV_PIN_CODE_REQ 0x16
struct hci_ev_pin_code_req {
bdaddr_t bdaddr;
......
......@@ -277,6 +277,7 @@ void hci_conn_hash_flush(struct hci_dev *hdev);
struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *src);
int hci_conn_auth(struct hci_conn *conn);
int hci_conn_encrypt(struct hci_conn *conn);
int hci_conn_change_link_key(struct hci_conn *conn);
static inline void hci_conn_set_timer(struct hci_conn *conn, unsigned long timeout)
{
......
......@@ -333,6 +333,20 @@ int hci_conn_encrypt(struct hci_conn *conn)
}
EXPORT_SYMBOL(hci_conn_encrypt);
/* Change link key */
int hci_conn_change_link_key(struct hci_conn *conn)
{
BT_DBG("conn %p", conn);
if (!test_and_set_bit(HCI_CONN_AUTH_PEND, &conn->pend)) {
struct hci_cp_change_conn_link_key cp;
cp.handle = __cpu_to_le16(conn->handle);
hci_send_cmd(conn->hdev, OGF_LINK_CTL, OCF_CHANGE_CONN_LINK_KEY, sizeof(cp), &cp);
}
return 0;
}
EXPORT_SYMBOL(hci_conn_change_link_key);
/* Drop all connection on the device */
void hci_conn_hash_flush(struct hci_dev *hdev)
{
......
......@@ -786,6 +786,11 @@ static inline void hci_encrypt_change_evt(struct hci_dev *hdev, struct sk_buff *
hci_dev_unlock(hdev);
}
/* Change Connection Link Key Complete */
static inline void hci_change_conn_link_key_complete_evt(struct hci_dev *hdev, struct sk_buff *skb)
{
}
/* Pin Code Request*/
static inline void hci_pin_code_request_evt(struct hci_dev *hdev, struct sk_buff *skb)
{
......@@ -853,6 +858,10 @@ void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb)
hci_encrypt_change_evt(hdev, skb);
break;
case HCI_EV_CHANGE_CONN_LINK_KEY_COMPLETE:
hci_change_conn_link_key_complete_evt(hdev, skb);
break;
case HCI_EV_PIN_CODE_REQ:
hci_pin_code_request_evt(hdev, skb);
break;
......
......@@ -114,7 +114,8 @@ static struct class bt_class = {
int hci_register_sysfs(struct hci_dev *hdev)
{
struct class_device *cdev = &hdev->class_dev;
int i, err;
unsigned int i;
int err;
BT_DBG("%p name %s type %d", hdev, hdev->name, hdev->type);
......
......@@ -57,7 +57,7 @@
#define BT_DBG(D...)
#endif
#define VERSION "2.4"
#define VERSION "2.5"
static struct proto_ops l2cap_sock_ops;
......@@ -74,8 +74,8 @@ static void __l2cap_sock_close(struct sock *sk, int reason);
static void l2cap_sock_close(struct sock *sk);
static void l2cap_sock_kill(struct sock *sk);
static int l2cap_send_req(struct l2cap_conn *conn, u8 code, u16 len, void *data);
static int l2cap_send_rsp(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data);
static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn,
u8 code, u8 ident, u16 dlen, void *data);
/* ---- L2CAP timers ---- */
static void l2cap_sock_timeout(unsigned long arg)
......@@ -174,6 +174,40 @@ static inline void l2cap_chan_add(struct l2cap_conn *conn, struct sock *sk, stru
write_unlock(&l->lock);
}
static inline u8 l2cap_get_ident(struct l2cap_conn *conn)
{
u8 id;
/* Get next available identificator.
* 1 - 128 are used by kernel.
* 129 - 199 are reserved.
* 200 - 254 are used by utilities like l2ping, etc.
*/
spin_lock(&conn->lock);
if (++conn->tx_ident > 128)
conn->tx_ident = 1;
id = conn->tx_ident;
spin_unlock(&conn->lock);
return id;
}
static inline int l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data)
{
struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data);
BT_DBG("code 0x%2.2x", code);
if (!skb)
return -ENOMEM;
return hci_send_acl(conn->hcon, skb, 0);
}
/* ---- Socket interface ---- */
static struct sock *__l2cap_get_sock_by_addr(u16 psm, bdaddr_t *src)
{
......@@ -286,7 +320,8 @@ static void __l2cap_sock_close(struct sock *sk, int reason)
req.dcid = __cpu_to_le16(l2cap_pi(sk)->dcid);
req.scid = __cpu_to_le16(l2cap_pi(sk)->scid);
l2cap_send_req(conn, L2CAP_DISCONN_REQ, sizeof(req), &req);
l2cap_send_cmd(conn, l2cap_get_ident(conn),
L2CAP_DISCONN_REQ, sizeof(req), &req);
} else {
l2cap_chan_del(sk, reason);
}
......@@ -365,7 +400,8 @@ static int l2cap_sock_create(struct socket *sock, int protocol)
sock->state = SS_UNCONNECTED;
if (sock->type != SOCK_SEQPACKET && sock->type != SOCK_DGRAM && sock->type != SOCK_RAW)
if (sock->type != SOCK_SEQPACKET &&
sock->type != SOCK_DGRAM && sock->type != SOCK_RAW)
return -ESOCKTNOSUPPORT;
if (sock->type == SOCK_RAW && !capable(CAP_NET_RAW))
......@@ -459,9 +495,11 @@ static int l2cap_do_connect(struct sock *sk)
if (hcon->state == BT_CONNECTED) {
if (sk->sk_type == SOCK_SEQPACKET) {
struct l2cap_conn_req req;
l2cap_pi(sk)->ident = l2cap_get_ident(conn);
req.scid = __cpu_to_le16(l2cap_pi(sk)->scid);
req.psm = l2cap_pi(sk)->psm;
l2cap_send_req(conn, L2CAP_CONN_REQ, sizeof(req), &req);
l2cap_send_cmd(conn, l2cap_pi(sk)->ident,
L2CAP_CONN_REQ, sizeof(req), &req);
} else {
l2cap_sock_clear_timer(sk);
sk->sk_state = BT_CONNECTED;
......@@ -911,6 +949,25 @@ static inline struct sock *l2cap_get_chan_by_scid(struct l2cap_chan_list *l, u16
return s;
}
static struct sock *__l2cap_get_chan_by_ident(struct l2cap_chan_list *l, u8 ident)
{
struct sock *s;
for (s = l->head; s; s = l2cap_pi(s)->next_c) {
if (l2cap_pi(s)->ident == ident)
break;
}
return s;
}
static inline struct sock *l2cap_get_chan_by_ident(struct l2cap_chan_list *l, u8 ident)
{
struct sock *s;
read_lock(&l->lock);
s = __l2cap_get_chan_by_ident(l, ident);
read_unlock(&l->lock);
return s;
}
static u16 l2cap_alloc_cid(struct l2cap_chan_list *l)
{
u16 cid = 0x0040;
......@@ -1030,9 +1087,10 @@ static void l2cap_conn_ready(struct l2cap_conn *conn)
sk->sk_state_change(sk);
} else if (sk->sk_state == BT_CONNECT) {
struct l2cap_conn_req req;
l2cap_pi(sk)->ident = l2cap_get_ident(conn);
req.scid = __cpu_to_le16(l2cap_pi(sk)->scid);
req.psm = l2cap_pi(sk)->psm;
l2cap_send_req(conn, L2CAP_CONN_REQ, sizeof(req), &req);
l2cap_send_cmd(conn, l2cap_pi(sk)->ident, L2CAP_CONN_REQ, sizeof(req), &req);
}
bh_unlock_sock(sk);
......@@ -1092,27 +1150,6 @@ static void l2cap_raw_recv(struct l2cap_conn *conn, struct sk_buff *skb)
}
/* ---- L2CAP signalling commands ---- */
static inline u8 l2cap_get_ident(struct l2cap_conn *conn)
{
u8 id;
/* Get next available identificator.
* 1 - 199 are used by kernel.
* 200 - 254 are used by utilities like l2ping, etc
*/
spin_lock(&conn->lock);
if (++conn->tx_ident > 199)
conn->tx_ident = 1;
id = conn->tx_ident;
spin_unlock(&conn->lock);
return id;
}
static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn,
u8 code, u8 ident, u16 dlen, void *data)
{
......@@ -1171,29 +1208,6 @@ static struct sk_buff *l2cap_build_cmd(struct l2cap_conn *conn,
return NULL;
}
static int l2cap_send_req(struct l2cap_conn *conn, u8 code, u16 len, void *data)
{
u8 ident = l2cap_get_ident(conn);
struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data);
BT_DBG("code 0x%2.2x", code);
if (!skb)
return -ENOMEM;
return hci_send_acl(conn->hcon, skb, 0);
}
static int l2cap_send_rsp(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data)
{
struct sk_buff *skb = l2cap_build_cmd(conn, code, ident, len, data);
BT_DBG("code 0x%2.2x", code);
if (!skb)
return -ENOMEM;
return hci_send_acl(conn->hcon, skb, 0);
}
static inline int l2cap_get_conf_opt(void **ptr, int *type, int *olen, unsigned long *val)
{
struct l2cap_conf_opt *opt = *ptr;
......@@ -1412,7 +1426,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
status = L2CAP_CS_AUTHEN_PEND;
sk->sk_state = BT_CONNECT2;
l2cap_pi(sk)->ident = cmd->ident;
if (l2cap_pi(sk)->link_mode & L2CAP_LM_ENCRYPT) {
if (!hci_conn_encrypt(conn->hcon))
goto done;
......@@ -1435,7 +1449,7 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
rsp.dcid = __cpu_to_le16(dcid);
rsp.result = __cpu_to_le16(result);
rsp.status = __cpu_to_le16(status);
l2cap_send_rsp(conn, cmd->ident, L2CAP_CONN_RSP, sizeof(rsp), &rsp);
l2cap_send_cmd(conn, cmd->ident, L2CAP_CONN_RSP, sizeof(rsp), &rsp);
return 0;
}
......@@ -1453,16 +1467,23 @@ static inline int l2cap_connect_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hd
BT_DBG("dcid 0x%4.4x scid 0x%4.4x result 0x%2.2x status 0x%2.2x", dcid, scid, result, status);
if (!(sk = l2cap_get_chan_by_scid(&conn->chan_list, scid)))
return 0;
if (scid) {
if (!(sk = l2cap_get_chan_by_scid(&conn->chan_list, scid)))
return 0;
} else {
if (!(sk = l2cap_get_chan_by_ident(&conn->chan_list, cmd->ident)))
return 0;
}
switch (result) {
case L2CAP_CR_SUCCESS:
sk->sk_state = BT_CONFIG;
l2cap_pi(sk)->ident = 0;
l2cap_pi(sk)->dcid = dcid;
l2cap_pi(sk)->conf_state |= L2CAP_CONF_REQ_SENT;
l2cap_send_req(conn, L2CAP_CONF_REQ, l2cap_build_conf_req(sk, req), req);
l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ,
l2cap_build_conf_req(sk, req), req);
break;
case L2CAP_CR_PEND:
......@@ -1497,12 +1518,14 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr
if (flags & 0x0001) {
/* Incomplete config. Send empty response. */
l2cap_send_rsp(conn, cmd->ident, L2CAP_CONF_RSP, l2cap_build_conf_rsp(sk, rsp, NULL), rsp);
l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP,
l2cap_build_conf_rsp(sk, rsp, NULL), rsp);
goto unlock;
}
/* Complete config. */
l2cap_send_rsp(conn, cmd->ident, L2CAP_CONF_RSP, l2cap_build_conf_rsp(sk, rsp, &result), rsp);
l2cap_send_cmd(conn, cmd->ident, L2CAP_CONF_RSP,
l2cap_build_conf_rsp(sk, rsp, &result), rsp);
if (result)
goto unlock;
......@@ -1515,7 +1538,8 @@ static inline int l2cap_config_req(struct l2cap_conn *conn, struct l2cap_cmd_hdr
l2cap_chan_ready(sk);
} else if (!(l2cap_pi(sk)->conf_state & L2CAP_CONF_REQ_SENT)) {
u8 req[64];
l2cap_send_req(conn, L2CAP_CONF_REQ, l2cap_build_conf_req(sk, req), req);
l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ,
l2cap_build_conf_req(sk, req), req);
}
unlock:
......@@ -1550,8 +1574,8 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
* resend config request that we sent earlier. It is
* stupid, but it helps qualification testing which
* expects at least some response from us. */
l2cap_send_req(conn, L2CAP_CONF_REQ,
l2cap_build_conf_req(sk, req), req);
l2cap_send_cmd(conn, l2cap_get_ident(conn), L2CAP_CONF_REQ,
l2cap_build_conf_req(sk, req), req);
goto done;
}
......@@ -1563,7 +1587,8 @@ static inline int l2cap_config_rsp(struct l2cap_conn *conn, struct l2cap_cmd_hdr
struct l2cap_disconn_req req;
req.dcid = __cpu_to_le16(l2cap_pi(sk)->dcid);
req.scid = __cpu_to_le16(l2cap_pi(sk)->scid);
l2cap_send_req(conn, L2CAP_DISCONN_REQ, sizeof(req), &req);
l2cap_send_cmd(conn, l2cap_get_ident(conn),
L2CAP_DISCONN_REQ, sizeof(req), &req);
}
goto done;
}
......@@ -1601,7 +1626,7 @@ static inline int l2cap_disconnect_req(struct l2cap_conn *conn, struct l2cap_cmd
rsp.dcid = __cpu_to_le16(l2cap_pi(sk)->scid);
rsp.scid = __cpu_to_le16(l2cap_pi(sk)->dcid);
l2cap_send_rsp(conn, cmd->ident, L2CAP_DISCONN_RSP, sizeof(rsp), &rsp);
l2cap_send_cmd(conn, cmd->ident, L2CAP_DISCONN_RSP, sizeof(rsp), &rsp);
sk->sk_shutdown = SHUTDOWN_MASK;
......@@ -1645,7 +1670,7 @@ static inline int l2cap_information_req(struct l2cap_conn *conn, struct l2cap_cm
rsp.type = __cpu_to_le16(type);
rsp.result = __cpu_to_le16(L2CAP_IR_NOTSUPP);
l2cap_send_rsp(conn, cmd->ident, L2CAP_INFO_RSP, sizeof(rsp), &rsp);
l2cap_send_cmd(conn, cmd->ident, L2CAP_INFO_RSP, sizeof(rsp), &rsp);
return 0;
}
......@@ -1716,7 +1741,7 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn, struct sk_buff *sk
break;
case L2CAP_ECHO_REQ:
l2cap_send_rsp(conn, cmd.ident, L2CAP_ECHO_RSP, cmd.len, data);
l2cap_send_cmd(conn, cmd.ident, L2CAP_ECHO_RSP, cmd.len, data);
break;
case L2CAP_ECHO_RSP:
......@@ -1742,7 +1767,7 @@ static inline void l2cap_sig_channel(struct l2cap_conn *conn, struct sk_buff *sk
/* FIXME: Map err to a valid reason */
rej.reason = __cpu_to_le16(0);
l2cap_send_rsp(conn, cmd.ident, L2CAP_COMMAND_REJ, sizeof(rej), &rej);
l2cap_send_cmd(conn, cmd.ident, L2CAP_COMMAND_REJ, sizeof(rej), &rej);
}
data += cmd.len;
......@@ -1939,7 +1964,8 @@ static int l2cap_auth_cfm(struct hci_conn *hcon, u8 status)
rsp.dcid = __cpu_to_le16(l2cap_pi(sk)->scid);
rsp.result = __cpu_to_le16(result);
rsp.status = __cpu_to_le16(0);
l2cap_send_rsp(conn, l2cap_pi(sk)->ident, L2CAP_CONN_RSP, sizeof(rsp), &rsp);
l2cap_send_cmd(conn, l2cap_pi(sk)->ident,
L2CAP_CONN_RSP, sizeof(rsp), &rsp);
bh_unlock_sock(sk);
}
......@@ -1985,7 +2011,8 @@ static int l2cap_encrypt_cfm(struct hci_conn *hcon, u8 status)
rsp.dcid = __cpu_to_le16(l2cap_pi(sk)->scid);
rsp.result = __cpu_to_le16(result);
rsp.status = __cpu_to_le16(0);
l2cap_send_rsp(conn, l2cap_pi(sk)->ident, L2CAP_CONN_RSP, sizeof(rsp), &rsp);
l2cap_send_cmd(conn, l2cap_pi(sk)->ident,
L2CAP_CONN_RSP, sizeof(rsp), &rsp);
bh_unlock_sock(sk);
}
......@@ -2237,7 +2264,7 @@ static void __exit l2cap_exit(void)
void l2cap_load(void)
{
/* Dummy function to trigger automatic L2CAP module loading by
* other modules that use L2CAP sockets but don not use any othe
* other modules that use L2CAP sockets but don't use any other
* symbols from it. */
return;
}
......
......@@ -38,13 +38,13 @@ void bt_dump(char *pref, __u8 *buf, int count)
{
char *ptr;
char line[100];
int i;
unsigned int i;
printk(KERN_INFO "%s: dump, len %d\n", pref, count);
ptr = line;
*ptr = 0;
for (i = 0; i<count; i++) {
for (i = 0; i < count; i++) {
ptr += sprintf(ptr, " %2.2X", buf[i]);
if (i && !((i + 1) % 20)) {
......@@ -63,7 +63,7 @@ void baswap(bdaddr_t *dst, bdaddr_t *src)
{
unsigned char *d = (unsigned char *) dst;
unsigned char *s = (unsigned char *) src;
int i;
unsigned int i;
for (i = 0; i < 6; i++)
d[i] = s[5 - i];
......
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