aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/bluetooth
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/bluetooth')
-rw-r--r--include/net/bluetooth/hci.h51
-rw-r--r--include/net/bluetooth/hci_core.h42
-rw-r--r--include/net/bluetooth/l2cap.h182
-rw-r--r--include/net/bluetooth/mgmt.h57
4 files changed, 228 insertions, 104 deletions
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 2c0d309c738..0c20227e57f 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -246,6 +246,15 @@ enum {
246#define HCI_AT_GENERAL_BONDING 0x04 246#define HCI_AT_GENERAL_BONDING 0x04
247#define HCI_AT_GENERAL_BONDING_MITM 0x05 247#define HCI_AT_GENERAL_BONDING_MITM 0x05
248 248
249/* Link Key types */
250#define HCI_LK_COMBINATION 0x00
251#define HCI_LK_LOCAL_UNIT 0x01
252#define HCI_LK_REMOTE_UNIT 0x02
253#define HCI_LK_DEBUG_COMBINATION 0x03
254#define HCI_LK_UNAUTH_COMBINATION 0x04
255#define HCI_LK_AUTH_COMBINATION 0x05
256#define HCI_LK_CHANGED_COMBINATION 0x06
257
249/* ----- HCI Commands ---- */ 258/* ----- HCI Commands ---- */
250#define HCI_OP_NOP 0x0000 259#define HCI_OP_NOP 0x0000
251 260
@@ -428,6 +437,18 @@ struct hci_rp_user_confirm_reply {
428 437
429#define HCI_OP_USER_CONFIRM_NEG_REPLY 0x042d 438#define HCI_OP_USER_CONFIRM_NEG_REPLY 0x042d
430 439
440#define HCI_OP_REMOTE_OOB_DATA_REPLY 0x0430
441struct hci_cp_remote_oob_data_reply {
442 bdaddr_t bdaddr;
443 __u8 hash[16];
444 __u8 randomizer[16];
445} __packed;
446
447#define HCI_OP_REMOTE_OOB_DATA_NEG_REPLY 0x0433
448struct hci_cp_remote_oob_data_neg_reply {
449 bdaddr_t bdaddr;
450} __packed;
451
431#define HCI_OP_IO_CAPABILITY_NEG_REPLY 0x0434 452#define HCI_OP_IO_CAPABILITY_NEG_REPLY 0x0434
432struct hci_cp_io_capability_neg_reply { 453struct hci_cp_io_capability_neg_reply {
433 bdaddr_t bdaddr; 454 bdaddr_t bdaddr;
@@ -537,15 +558,17 @@ struct hci_cp_delete_stored_link_key {
537 __u8 delete_all; 558 __u8 delete_all;
538} __packed; 559} __packed;
539 560
561#define HCI_MAX_NAME_LENGTH 248
562
540#define HCI_OP_WRITE_LOCAL_NAME 0x0c13 563#define HCI_OP_WRITE_LOCAL_NAME 0x0c13
541struct hci_cp_write_local_name { 564struct hci_cp_write_local_name {
542 __u8 name[248]; 565 __u8 name[HCI_MAX_NAME_LENGTH];
543} __packed; 566} __packed;
544 567
545#define HCI_OP_READ_LOCAL_NAME 0x0c14 568#define HCI_OP_READ_LOCAL_NAME 0x0c14
546struct hci_rp_read_local_name { 569struct hci_rp_read_local_name {
547 __u8 status; 570 __u8 status;
548 __u8 name[248]; 571 __u8 name[HCI_MAX_NAME_LENGTH];
549} __packed; 572} __packed;
550 573
551#define HCI_OP_WRITE_CA_TIMEOUT 0x0c16 574#define HCI_OP_WRITE_CA_TIMEOUT 0x0c16
@@ -602,6 +625,14 @@ struct hci_cp_host_buffer_size {
602 625
603#define HCI_OP_WRITE_INQUIRY_MODE 0x0c45 626#define HCI_OP_WRITE_INQUIRY_MODE 0x0c45
604 627
628#define HCI_MAX_EIR_LENGTH 240
629
630#define HCI_OP_WRITE_EIR 0x0c52
631struct hci_cp_write_eir {
632 uint8_t fec;
633 uint8_t data[HCI_MAX_EIR_LENGTH];
634} __packed;
635
605#define HCI_OP_READ_SSP_MODE 0x0c55 636#define HCI_OP_READ_SSP_MODE 0x0c55
606struct hci_rp_read_ssp_mode { 637struct hci_rp_read_ssp_mode {
607 __u8 status; 638 __u8 status;
@@ -613,6 +644,13 @@ struct hci_cp_write_ssp_mode {
613 __u8 mode; 644 __u8 mode;
614} __packed; 645} __packed;
615 646
647#define HCI_OP_READ_LOCAL_OOB_DATA 0x0c57
648struct hci_rp_read_local_oob_data {
649 __u8 status;
650 __u8 hash[16];
651 __u8 randomizer[16];
652} __packed;
653
616#define HCI_OP_READ_INQ_RSP_TX_POWER 0x0c58 654#define HCI_OP_READ_INQ_RSP_TX_POWER 0x0c58
617 655
618#define HCI_OP_READ_LOCAL_VERSION 0x1001 656#define HCI_OP_READ_LOCAL_VERSION 0x1001
@@ -747,7 +785,7 @@ struct hci_ev_auth_complete {
747struct hci_ev_remote_name { 785struct hci_ev_remote_name {
748 __u8 status; 786 __u8 status;
749 bdaddr_t bdaddr; 787 bdaddr_t bdaddr;
750 __u8 name[248]; 788 __u8 name[HCI_MAX_NAME_LENGTH];
751} __packed; 789} __packed;
752 790
753#define HCI_EV_ENCRYPT_CHANGE 0x08 791#define HCI_EV_ENCRYPT_CHANGE 0x08
@@ -955,6 +993,11 @@ struct hci_ev_user_confirm_req {
955 __le32 passkey; 993 __le32 passkey;
956} __packed; 994} __packed;
957 995
996#define HCI_EV_REMOTE_OOB_DATA_REQUEST 0x35
997struct hci_ev_remote_oob_data_request {
998 bdaddr_t bdaddr;
999} __packed;
1000
958#define HCI_EV_SIMPLE_PAIR_COMPLETE 0x36 1001#define HCI_EV_SIMPLE_PAIR_COMPLETE 0x36
959struct hci_ev_simple_pair_complete { 1002struct hci_ev_simple_pair_complete {
960 __u8 status; 1003 __u8 status;
@@ -1033,7 +1076,6 @@ struct hci_sco_hdr {
1033 __u8 dlen; 1076 __u8 dlen;
1034} __packed; 1077} __packed;
1035 1078
1036#ifdef __KERNEL__
1037#include <linux/skbuff.h> 1079#include <linux/skbuff.h>
1038static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb) 1080static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb)
1039{ 1081{
@@ -1049,7 +1091,6 @@ static inline struct hci_sco_hdr *hci_sco_hdr(const struct sk_buff *skb)
1049{ 1091{
1050 return (struct hci_sco_hdr *) skb->data; 1092 return (struct hci_sco_hdr *) skb->data;
1051} 1093}
1052#endif
1053 1094
1054/* Command opcode pack/unpack */ 1095/* Command opcode pack/unpack */
1055#define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10)) 1096#define hci_opcode_pack(ogf, ocf) (__u16) ((ocf & 0x03ff)|(ogf << 10))
diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 441dadbf6a8..6c994c004d1 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -82,6 +82,13 @@ struct link_key {
82 u8 pin_len; 82 u8 pin_len;
83}; 83};
84 84
85struct oob_data {
86 struct list_head list;
87 bdaddr_t bdaddr;
88 u8 hash[16];
89 u8 randomizer[16];
90};
91
85#define NUM_REASSEMBLY 4 92#define NUM_REASSEMBLY 4
86struct hci_dev { 93struct hci_dev {
87 struct list_head list; 94 struct list_head list;
@@ -94,7 +101,8 @@ struct hci_dev {
94 __u8 bus; 101 __u8 bus;
95 __u8 dev_type; 102 __u8 dev_type;
96 bdaddr_t bdaddr; 103 bdaddr_t bdaddr;
97 __u8 dev_name[248]; 104 __u8 dev_name[HCI_MAX_NAME_LENGTH];
105 __u8 eir[HCI_MAX_EIR_LENGTH];
98 __u8 dev_class[3]; 106 __u8 dev_class[3];
99 __u8 major_class; 107 __u8 major_class;
100 __u8 minor_class; 108 __u8 minor_class;
@@ -118,6 +126,8 @@ struct hci_dev {
118 __u16 sniff_min_interval; 126 __u16 sniff_min_interval;
119 __u16 sniff_max_interval; 127 __u16 sniff_max_interval;
120 128
129 unsigned int auto_accept_delay;
130
121 unsigned long quirks; 131 unsigned long quirks;
122 132
123 atomic_t cmd_cnt; 133 atomic_t cmd_cnt;
@@ -169,6 +179,8 @@ struct hci_dev {
169 179
170 struct list_head link_keys; 180 struct list_head link_keys;
171 181
182 struct list_head remote_oob_data;
183
172 struct hci_dev_stats stat; 184 struct hci_dev_stats stat;
173 185
174 struct sk_buff_head driver_init; 186 struct sk_buff_head driver_init;
@@ -216,6 +228,7 @@ struct hci_conn {
216 __u16 pkt_type; 228 __u16 pkt_type;
217 __u16 link_policy; 229 __u16 link_policy;
218 __u32 link_mode; 230 __u32 link_mode;
231 __u8 key_type;
219 __u8 auth_type; 232 __u8 auth_type;
220 __u8 sec_level; 233 __u8 sec_level;
221 __u8 pending_sec_level; 234 __u8 pending_sec_level;
@@ -235,6 +248,7 @@ struct hci_conn {
235 248
236 struct timer_list disc_timer; 249 struct timer_list disc_timer;
237 struct timer_list idle_timer; 250 struct timer_list idle_timer;
251 struct timer_list auto_accept_timer;
238 252
239 struct work_struct work_add; 253 struct work_struct work_add;
240 struct work_struct work_del; 254 struct work_struct work_del;
@@ -408,6 +422,7 @@ void hci_conn_check_pending(struct hci_dev *hdev);
408 422
409struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 sec_level, __u8 auth_type); 423struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 sec_level, __u8 auth_type);
410int hci_conn_check_link_mode(struct hci_conn *conn); 424int hci_conn_check_link_mode(struct hci_conn *conn);
425int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level);
411int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type); 426int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type);
412int hci_conn_change_link_key(struct hci_conn *conn); 427int hci_conn_change_link_key(struct hci_conn *conn);
413int hci_conn_switch_role(struct hci_conn *conn, __u8 role); 428int hci_conn_switch_role(struct hci_conn *conn, __u8 role);
@@ -501,10 +516,17 @@ int hci_uuids_clear(struct hci_dev *hdev);
501 516
502int hci_link_keys_clear(struct hci_dev *hdev); 517int hci_link_keys_clear(struct hci_dev *hdev);
503struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); 518struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr);
504int hci_add_link_key(struct hci_dev *hdev, int new_key, bdaddr_t *bdaddr, 519int hci_add_link_key(struct hci_dev *hdev, struct hci_conn *conn, int new_key,
505 u8 *key, u8 type, u8 pin_len); 520 bdaddr_t *bdaddr, u8 *val, u8 type, u8 pin_len);
506int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); 521int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr);
507 522
523int hci_remote_oob_data_clear(struct hci_dev *hdev);
524struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev,
525 bdaddr_t *bdaddr);
526int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash,
527 u8 *randomizer);
528int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr);
529
508void hci_del_off_timer(struct hci_dev *hdev); 530void hci_del_off_timer(struct hci_dev *hdev);
509 531
510void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); 532void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb);
@@ -754,19 +776,27 @@ int mgmt_index_removed(u16 index);
754int mgmt_powered(u16 index, u8 powered); 776int mgmt_powered(u16 index, u8 powered);
755int mgmt_discoverable(u16 index, u8 discoverable); 777int mgmt_discoverable(u16 index, u8 discoverable);
756int mgmt_connectable(u16 index, u8 connectable); 778int mgmt_connectable(u16 index, u8 connectable);
757int mgmt_new_key(u16 index, struct link_key *key, u8 old_key_type); 779int mgmt_new_key(u16 index, struct link_key *key, u8 persistent);
758int mgmt_connected(u16 index, bdaddr_t *bdaddr); 780int mgmt_connected(u16 index, bdaddr_t *bdaddr);
759int mgmt_disconnected(u16 index, bdaddr_t *bdaddr); 781int mgmt_disconnected(u16 index, bdaddr_t *bdaddr);
760int mgmt_disconnect_failed(u16 index); 782int mgmt_disconnect_failed(u16 index);
761int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 status); 783int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 status);
762int mgmt_pin_code_request(u16 index, bdaddr_t *bdaddr); 784int mgmt_pin_code_request(u16 index, bdaddr_t *bdaddr, u8 secure);
763int mgmt_pin_code_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); 785int mgmt_pin_code_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status);
764int mgmt_pin_code_neg_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); 786int mgmt_pin_code_neg_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status);
765int mgmt_user_confirm_request(u16 index, bdaddr_t *bdaddr, __le32 value); 787int mgmt_user_confirm_request(u16 index, bdaddr_t *bdaddr, __le32 value,
788 u8 confirm_hint);
766int mgmt_user_confirm_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); 789int mgmt_user_confirm_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status);
767int mgmt_user_confirm_neg_reply_complete(u16 index, bdaddr_t *bdaddr, 790int mgmt_user_confirm_neg_reply_complete(u16 index, bdaddr_t *bdaddr,
768 u8 status); 791 u8 status);
769int mgmt_auth_failed(u16 index, bdaddr_t *bdaddr, u8 status); 792int mgmt_auth_failed(u16 index, bdaddr_t *bdaddr, u8 status);
793int mgmt_set_local_name_complete(u16 index, u8 *name, u8 status);
794int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer,
795 u8 status);
796int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi,
797 u8 *eir);
798int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name);
799int mgmt_discovering(u16 index, u8 discovering);
770 800
771/* HCI info for socket */ 801/* HCI info for socket */
772#define hci_pi(sk) ((struct hci_pinfo *) sk) 802#define hci_pi(sk) ((struct hci_pinfo *) sk)
diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index 4f4bff1eaed..d09c9b1118e 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -276,63 +276,17 @@ struct l2cap_conn_param_update_rsp {
276#define L2CAP_CONN_PARAM_ACCEPTED 0x0000 276#define L2CAP_CONN_PARAM_ACCEPTED 0x0000
277#define L2CAP_CONN_PARAM_REJECTED 0x0001 277#define L2CAP_CONN_PARAM_REJECTED 0x0001
278 278
279/* ----- L2CAP connections ----- */ 279/* ----- L2CAP channels and connections ----- */
280struct l2cap_chan_list {
281 struct sock *head;
282 rwlock_t lock;
283 long num;
284};
285
286struct l2cap_conn {
287 struct hci_conn *hcon;
288
289 bdaddr_t *dst;
290 bdaddr_t *src;
291
292 unsigned int mtu;
293
294 __u32 feat_mask;
295
296 __u8 info_state;
297 __u8 info_ident;
298
299 struct timer_list info_timer;
300
301 spinlock_t lock;
302
303 struct sk_buff *rx_skb;
304 __u32 rx_len;
305 __u8 rx_ident;
306 __u8 tx_ident;
307
308 __u8 disc_reason;
309
310 struct l2cap_chan_list chan_list;
311};
312
313struct sock_del_list {
314 struct sock *sk;
315 struct list_head list;
316};
317
318#define L2CAP_INFO_CL_MTU_REQ_SENT 0x01
319#define L2CAP_INFO_FEAT_MASK_REQ_SENT 0x04
320#define L2CAP_INFO_FEAT_MASK_REQ_DONE 0x08
321
322/* ----- L2CAP channel and socket info ----- */
323#define l2cap_pi(sk) ((struct l2cap_pinfo *) sk)
324#define TX_QUEUE(sk) (&l2cap_pi(sk)->tx_queue)
325#define SREJ_QUEUE(sk) (&l2cap_pi(sk)->srej_queue)
326#define BUSY_QUEUE(sk) (&l2cap_pi(sk)->busy_queue)
327#define SREJ_LIST(sk) (&l2cap_pi(sk)->srej_l.list)
328
329struct srej_list { 280struct srej_list {
330 __u8 tx_seq; 281 __u8 tx_seq;
331 struct list_head list; 282 struct list_head list;
332}; 283};
333 284
334struct l2cap_pinfo { 285struct l2cap_chan {
335 struct bt_sock bt; 286 struct sock *sk;
287
288 struct l2cap_conn *conn;
289
336 __le16 psm; 290 __le16 psm;
337 __u16 dcid; 291 __u16 dcid;
338 __u16 scid; 292 __u16 scid;
@@ -341,17 +295,29 @@ struct l2cap_pinfo {
341 __u16 omtu; 295 __u16 omtu;
342 __u16 flush_to; 296 __u16 flush_to;
343 __u8 mode; 297 __u8 mode;
344 __u8 num_conf_req;
345 __u8 num_conf_rsp;
346 298
347 __u8 fcs; 299 __le16 sport;
300
348 __u8 sec_level; 301 __u8 sec_level;
349 __u8 role_switch; 302 __u8 role_switch;
350 __u8 force_reliable; 303 __u8 force_reliable;
351 __u8 flushable; 304 __u8 flushable;
352 305
306 __u8 ident;
307
353 __u8 conf_req[64]; 308 __u8 conf_req[64];
354 __u8 conf_len; 309 __u8 conf_len;
310 __u8 num_conf_req;
311 __u8 num_conf_rsp;
312
313 __u8 fcs;
314
315 __u8 tx_win;
316 __u8 max_tx;
317 __u16 retrans_timeout;
318 __u16 monitor_timeout;
319 __u16 mps;
320
355 __u8 conf_state; 321 __u8 conf_state;
356 __u16 conn_state; 322 __u16 conn_state;
357 323
@@ -369,30 +335,61 @@ struct l2cap_pinfo {
369 __u16 partial_sdu_len; 335 __u16 partial_sdu_len;
370 struct sk_buff *sdu; 336 struct sk_buff *sdu;
371 337
372 __u8 ident;
373
374 __u8 tx_win;
375 __u8 max_tx;
376 __u8 remote_tx_win; 338 __u8 remote_tx_win;
377 __u8 remote_max_tx; 339 __u8 remote_max_tx;
378 __u16 retrans_timeout;
379 __u16 monitor_timeout;
380 __u16 remote_mps; 340 __u16 remote_mps;
381 __u16 mps;
382
383 __le16 sport;
384 341
385 struct timer_list retrans_timer; 342 struct timer_list retrans_timer;
386 struct timer_list monitor_timer; 343 struct timer_list monitor_timer;
387 struct timer_list ack_timer; 344 struct timer_list ack_timer;
388 struct sk_buff_head tx_queue; 345 struct sk_buff *tx_send_head;
389 struct sk_buff_head srej_queue; 346 struct sk_buff_head tx_q;
390 struct sk_buff_head busy_queue; 347 struct sk_buff_head srej_q;
348 struct sk_buff_head busy_q;
391 struct work_struct busy_work; 349 struct work_struct busy_work;
392 struct srej_list srej_l; 350 struct list_head srej_l;
393 struct l2cap_conn *conn; 351
394 struct sock *next_c; 352 struct list_head list;
395 struct sock *prev_c; 353 struct list_head global_l;
354};
355
356struct l2cap_conn {
357 struct hci_conn *hcon;
358
359 bdaddr_t *dst;
360 bdaddr_t *src;
361
362 unsigned int mtu;
363
364 __u32 feat_mask;
365
366 __u8 info_state;
367 __u8 info_ident;
368
369 struct timer_list info_timer;
370
371 spinlock_t lock;
372
373 struct sk_buff *rx_skb;
374 __u32 rx_len;
375 __u8 tx_ident;
376
377 __u8 disc_reason;
378
379 struct list_head chan_l;
380 rwlock_t chan_lock;
381};
382
383#define L2CAP_INFO_CL_MTU_REQ_SENT 0x01
384#define L2CAP_INFO_FEAT_MASK_REQ_SENT 0x04
385#define L2CAP_INFO_FEAT_MASK_REQ_DONE 0x08
386
387/* ----- L2CAP socket info ----- */
388#define l2cap_pi(sk) ((struct l2cap_pinfo *) sk)
389
390struct l2cap_pinfo {
391 struct bt_sock bt;
392 struct l2cap_chan *chan;
396}; 393};
397 394
398#define L2CAP_CONF_REQ_SENT 0x01 395#define L2CAP_CONF_REQ_SENT 0x01
@@ -419,24 +416,23 @@ struct l2cap_pinfo {
419#define L2CAP_CONN_RNR_SENT 0x0200 416#define L2CAP_CONN_RNR_SENT 0x0200
420#define L2CAP_CONN_SAR_RETRY 0x0400 417#define L2CAP_CONN_SAR_RETRY 0x0400
421 418
422#define __mod_retrans_timer() mod_timer(&l2cap_pi(sk)->retrans_timer, \ 419#define __mod_retrans_timer() mod_timer(&chan->retrans_timer, \
423 jiffies + msecs_to_jiffies(L2CAP_DEFAULT_RETRANS_TO)); 420 jiffies + msecs_to_jiffies(L2CAP_DEFAULT_RETRANS_TO));
424#define __mod_monitor_timer() mod_timer(&l2cap_pi(sk)->monitor_timer, \ 421#define __mod_monitor_timer() mod_timer(&chan->monitor_timer, \
425 jiffies + msecs_to_jiffies(L2CAP_DEFAULT_MONITOR_TO)); 422 jiffies + msecs_to_jiffies(L2CAP_DEFAULT_MONITOR_TO));
426#define __mod_ack_timer() mod_timer(&l2cap_pi(sk)->ack_timer, \ 423#define __mod_ack_timer() mod_timer(&chan->ack_timer, \
427 jiffies + msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO)); 424 jiffies + msecs_to_jiffies(L2CAP_DEFAULT_ACK_TO));
428 425
429static inline int l2cap_tx_window_full(struct sock *sk) 426static inline int l2cap_tx_window_full(struct l2cap_chan *ch)
430{ 427{
431 struct l2cap_pinfo *pi = l2cap_pi(sk);
432 int sub; 428 int sub;
433 429
434 sub = (pi->next_tx_seq - pi->expected_ack_seq) % 64; 430 sub = (ch->next_tx_seq - ch->expected_ack_seq) % 64;
435 431
436 if (sub < 0) 432 if (sub < 0)
437 sub += 64; 433 sub += 64;
438 434
439 return sub == pi->remote_tx_win; 435 return sub == ch->remote_tx_win;
440} 436}
441 437
442#define __get_txseq(ctrl) (((ctrl) & L2CAP_CTRL_TXSEQ) >> 1) 438#define __get_txseq(ctrl) (((ctrl) & L2CAP_CTRL_TXSEQ) >> 1)
@@ -446,24 +442,24 @@ static inline int l2cap_tx_window_full(struct sock *sk)
446#define __is_sar_start(ctrl) (((ctrl) & L2CAP_CTRL_SAR) == L2CAP_SDU_START) 442#define __is_sar_start(ctrl) (((ctrl) & L2CAP_CTRL_SAR) == L2CAP_SDU_START)
447 443
448extern int disable_ertm; 444extern int disable_ertm;
449extern const struct proto_ops l2cap_sock_ops;
450extern struct bt_sock_list l2cap_sk_list;
451 445
452int l2cap_init_sockets(void); 446int l2cap_init_sockets(void);
453void l2cap_cleanup_sockets(void); 447void l2cap_cleanup_sockets(void);
454 448
455u8 l2cap_get_ident(struct l2cap_conn *conn);
456void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data); 449void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data);
457int l2cap_build_conf_req(struct sock *sk, void *data); 450void __l2cap_connect_rsp_defer(struct l2cap_chan *chan);
458int __l2cap_wait_ack(struct sock *sk); 451int __l2cap_wait_ack(struct sock *sk);
459 452
460struct sk_buff *l2cap_create_connless_pdu(struct sock *sk, struct msghdr *msg, size_t len); 453struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len);
461struct sk_buff *l2cap_create_basic_pdu(struct sock *sk, struct msghdr *msg, size_t len); 454struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len);
462struct sk_buff *l2cap_create_iframe_pdu(struct sock *sk, struct msghdr *msg, size_t len, u16 control, u16 sdulen); 455struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len, u16 control, u16 sdulen);
463int l2cap_sar_segment_sdu(struct sock *sk, struct msghdr *msg, size_t len); 456int l2cap_sar_segment_sdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len);
464void l2cap_do_send(struct sock *sk, struct sk_buff *skb); 457void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb);
465void l2cap_streaming_send(struct sock *sk); 458void l2cap_streaming_send(struct l2cap_chan *chan);
466int l2cap_ertm_send(struct sock *sk); 459int l2cap_ertm_send(struct l2cap_chan *chan);
460
461int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm);
462int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid);
467 463
468void l2cap_sock_set_timer(struct sock *sk, long timeout); 464void l2cap_sock_set_timer(struct sock *sk, long timeout);
469void l2cap_sock_clear_timer(struct sock *sk); 465void l2cap_sock_clear_timer(struct sock *sk);
@@ -472,8 +468,10 @@ void l2cap_sock_kill(struct sock *sk);
472void l2cap_sock_init(struct sock *sk, struct sock *parent); 468void l2cap_sock_init(struct sock *sk, struct sock *parent);
473struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, 469struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock,
474 int proto, gfp_t prio); 470 int proto, gfp_t prio);
475void l2cap_send_disconn_req(struct l2cap_conn *conn, struct sock *sk, int err); 471void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *chan, int err);
476void l2cap_chan_del(struct sock *sk, int err); 472struct l2cap_chan *l2cap_chan_create(struct sock *sk);
477int l2cap_do_connect(struct sock *sk); 473void l2cap_chan_del(struct l2cap_chan *chan, int err);
474void l2cap_chan_destroy(struct l2cap_chan *chan);
475int l2cap_chan_connect(struct l2cap_chan *chan);
478 476
479#endif /* __L2CAP_H */ 477#endif /* __L2CAP_H */
diff --git a/include/net/bluetooth/mgmt.h b/include/net/bluetooth/mgmt.h
index 5fabfa886b3..4899286ed4e 100644
--- a/include/net/bluetooth/mgmt.h
+++ b/include/net/bluetooth/mgmt.h
@@ -41,6 +41,10 @@ struct mgmt_rp_read_index_list {
41 __le16 index[0]; 41 __le16 index[0];
42} __packed; 42} __packed;
43 43
44/* Reserve one extra byte for names in management messages so that they
45 * are always guaranteed to be nul-terminated */
46#define MGMT_MAX_NAME_LENGTH (HCI_MAX_NAME_LENGTH + 1)
47
44#define MGMT_OP_READ_INFO 0x0004 48#define MGMT_OP_READ_INFO 0x0004
45struct mgmt_rp_read_info { 49struct mgmt_rp_read_info {
46 __u8 type; 50 __u8 type;
@@ -55,6 +59,7 @@ struct mgmt_rp_read_info {
55 __u16 manufacturer; 59 __u16 manufacturer;
56 __u8 hci_ver; 60 __u8 hci_ver;
57 __u16 hci_rev; 61 __u16 hci_rev;
62 __u8 name[MGMT_MAX_NAME_LENGTH];
58} __packed; 63} __packed;
59 64
60struct mgmt_mode { 65struct mgmt_mode {
@@ -167,6 +172,33 @@ struct mgmt_rp_user_confirm_reply {
167 172
168#define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x0016 173#define MGMT_OP_USER_CONFIRM_NEG_REPLY 0x0016
169 174
175#define MGMT_OP_SET_LOCAL_NAME 0x0017
176struct mgmt_cp_set_local_name {
177 __u8 name[MGMT_MAX_NAME_LENGTH];
178} __packed;
179
180#define MGMT_OP_READ_LOCAL_OOB_DATA 0x0018
181struct mgmt_rp_read_local_oob_data {
182 __u8 hash[16];
183 __u8 randomizer[16];
184} __packed;
185
186#define MGMT_OP_ADD_REMOTE_OOB_DATA 0x0019
187struct mgmt_cp_add_remote_oob_data {
188 bdaddr_t bdaddr;
189 __u8 hash[16];
190 __u8 randomizer[16];
191} __packed;
192
193#define MGMT_OP_REMOVE_REMOTE_OOB_DATA 0x001A
194struct mgmt_cp_remove_remote_oob_data {
195 bdaddr_t bdaddr;
196} __packed;
197
198#define MGMT_OP_START_DISCOVERY 0x001B
199
200#define MGMT_OP_STOP_DISCOVERY 0x001C
201
170#define MGMT_EV_CMD_COMPLETE 0x0001 202#define MGMT_EV_CMD_COMPLETE 0x0001
171struct mgmt_ev_cmd_complete { 203struct mgmt_ev_cmd_complete {
172 __le16 opcode; 204 __le16 opcode;
@@ -198,8 +230,8 @@ struct mgmt_ev_controller_error {
198 230
199#define MGMT_EV_NEW_KEY 0x000A 231#define MGMT_EV_NEW_KEY 0x000A
200struct mgmt_ev_new_key { 232struct mgmt_ev_new_key {
233 __u8 store_hint;
201 struct mgmt_key_info key; 234 struct mgmt_key_info key;
202 __u8 old_key_type;
203} __packed; 235} __packed;
204 236
205#define MGMT_EV_CONNECTED 0x000B 237#define MGMT_EV_CONNECTED 0x000B
@@ -221,11 +253,13 @@ struct mgmt_ev_connect_failed {
221#define MGMT_EV_PIN_CODE_REQUEST 0x000E 253#define MGMT_EV_PIN_CODE_REQUEST 0x000E
222struct mgmt_ev_pin_code_request { 254struct mgmt_ev_pin_code_request {
223 bdaddr_t bdaddr; 255 bdaddr_t bdaddr;
256 __u8 secure;
224} __packed; 257} __packed;
225 258
226#define MGMT_EV_USER_CONFIRM_REQUEST 0x000F 259#define MGMT_EV_USER_CONFIRM_REQUEST 0x000F
227struct mgmt_ev_user_confirm_request { 260struct mgmt_ev_user_confirm_request {
228 bdaddr_t bdaddr; 261 bdaddr_t bdaddr;
262 __u8 confirm_hint;
229 __le32 value; 263 __le32 value;
230} __packed; 264} __packed;
231 265
@@ -234,3 +268,24 @@ struct mgmt_ev_auth_failed {
234 bdaddr_t bdaddr; 268 bdaddr_t bdaddr;
235 __u8 status; 269 __u8 status;
236} __packed; 270} __packed;
271
272#define MGMT_EV_LOCAL_NAME_CHANGED 0x0011
273struct mgmt_ev_local_name_changed {
274 __u8 name[MGMT_MAX_NAME_LENGTH];
275} __packed;
276
277#define MGMT_EV_DEVICE_FOUND 0x0012
278struct mgmt_ev_device_found {
279 bdaddr_t bdaddr;
280 __u8 dev_class[3];
281 __s8 rssi;
282 __u8 eir[HCI_MAX_EIR_LENGTH];
283} __packed;
284
285#define MGMT_EV_REMOTE_NAME 0x0013
286struct mgmt_ev_remote_name {
287 bdaddr_t bdaddr;
288 __u8 name[MGMT_MAX_NAME_LENGTH];
289} __packed;
290
291#define MGMT_EV_DISCOVERING 0x0014