diff options
Diffstat (limited to 'include/net/bluetooth')
-rw-r--r-- | include/net/bluetooth/hci.h | 51 | ||||
-rw-r--r-- | include/net/bluetooth/hci_core.h | 42 | ||||
-rw-r--r-- | include/net/bluetooth/l2cap.h | 182 | ||||
-rw-r--r-- | include/net/bluetooth/mgmt.h | 57 |
4 files changed, 228 insertions, 104 deletions
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h index 2c0d309c7381..0c20227e57f6 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 | ||
441 | struct 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 | ||
448 | struct 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 |
432 | struct hci_cp_io_capability_neg_reply { | 453 | struct 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 |
541 | struct hci_cp_write_local_name { | 564 | struct 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 |
546 | struct hci_rp_read_local_name { | 569 | struct 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 | ||
631 | struct 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 |
606 | struct hci_rp_read_ssp_mode { | 637 | struct 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 | ||
648 | struct 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 { | |||
747 | struct hci_ev_remote_name { | 785 | struct 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 | ||
997 | struct 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 |
959 | struct hci_ev_simple_pair_complete { | 1002 | struct 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> |
1038 | static inline struct hci_event_hdr *hci_event_hdr(const struct sk_buff *skb) | 1080 | static 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 441dadbf6a89..6c994c004d15 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 | ||
85 | struct 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 |
86 | struct hci_dev { | 93 | struct 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 | ||
409 | struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 sec_level, __u8 auth_type); | 423 | struct hci_conn *hci_connect(struct hci_dev *hdev, int type, bdaddr_t *dst, __u8 sec_level, __u8 auth_type); |
410 | int hci_conn_check_link_mode(struct hci_conn *conn); | 424 | int hci_conn_check_link_mode(struct hci_conn *conn); |
425 | int hci_conn_check_secure(struct hci_conn *conn, __u8 sec_level); | ||
411 | int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type); | 426 | int hci_conn_security(struct hci_conn *conn, __u8 sec_level, __u8 auth_type); |
412 | int hci_conn_change_link_key(struct hci_conn *conn); | 427 | int hci_conn_change_link_key(struct hci_conn *conn); |
413 | int hci_conn_switch_role(struct hci_conn *conn, __u8 role); | 428 | int hci_conn_switch_role(struct hci_conn *conn, __u8 role); |
@@ -501,10 +516,17 @@ int hci_uuids_clear(struct hci_dev *hdev); | |||
501 | 516 | ||
502 | int hci_link_keys_clear(struct hci_dev *hdev); | 517 | int hci_link_keys_clear(struct hci_dev *hdev); |
503 | struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); | 518 | struct link_key *hci_find_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); |
504 | int hci_add_link_key(struct hci_dev *hdev, int new_key, bdaddr_t *bdaddr, | 519 | int 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); |
506 | int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); | 521 | int hci_remove_link_key(struct hci_dev *hdev, bdaddr_t *bdaddr); |
507 | 522 | ||
523 | int hci_remote_oob_data_clear(struct hci_dev *hdev); | ||
524 | struct oob_data *hci_find_remote_oob_data(struct hci_dev *hdev, | ||
525 | bdaddr_t *bdaddr); | ||
526 | int hci_add_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr, u8 *hash, | ||
527 | u8 *randomizer); | ||
528 | int hci_remove_remote_oob_data(struct hci_dev *hdev, bdaddr_t *bdaddr); | ||
529 | |||
508 | void hci_del_off_timer(struct hci_dev *hdev); | 530 | void hci_del_off_timer(struct hci_dev *hdev); |
509 | 531 | ||
510 | void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); | 532 | void hci_event_packet(struct hci_dev *hdev, struct sk_buff *skb); |
@@ -754,19 +776,27 @@ int mgmt_index_removed(u16 index); | |||
754 | int mgmt_powered(u16 index, u8 powered); | 776 | int mgmt_powered(u16 index, u8 powered); |
755 | int mgmt_discoverable(u16 index, u8 discoverable); | 777 | int mgmt_discoverable(u16 index, u8 discoverable); |
756 | int mgmt_connectable(u16 index, u8 connectable); | 778 | int mgmt_connectable(u16 index, u8 connectable); |
757 | int mgmt_new_key(u16 index, struct link_key *key, u8 old_key_type); | 779 | int mgmt_new_key(u16 index, struct link_key *key, u8 persistent); |
758 | int mgmt_connected(u16 index, bdaddr_t *bdaddr); | 780 | int mgmt_connected(u16 index, bdaddr_t *bdaddr); |
759 | int mgmt_disconnected(u16 index, bdaddr_t *bdaddr); | 781 | int mgmt_disconnected(u16 index, bdaddr_t *bdaddr); |
760 | int mgmt_disconnect_failed(u16 index); | 782 | int mgmt_disconnect_failed(u16 index); |
761 | int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 status); | 783 | int mgmt_connect_failed(u16 index, bdaddr_t *bdaddr, u8 status); |
762 | int mgmt_pin_code_request(u16 index, bdaddr_t *bdaddr); | 784 | int mgmt_pin_code_request(u16 index, bdaddr_t *bdaddr, u8 secure); |
763 | int mgmt_pin_code_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); | 785 | int mgmt_pin_code_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); |
764 | int mgmt_pin_code_neg_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); | 786 | int mgmt_pin_code_neg_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); |
765 | int mgmt_user_confirm_request(u16 index, bdaddr_t *bdaddr, __le32 value); | 787 | int mgmt_user_confirm_request(u16 index, bdaddr_t *bdaddr, __le32 value, |
788 | u8 confirm_hint); | ||
766 | int mgmt_user_confirm_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); | 789 | int mgmt_user_confirm_reply_complete(u16 index, bdaddr_t *bdaddr, u8 status); |
767 | int mgmt_user_confirm_neg_reply_complete(u16 index, bdaddr_t *bdaddr, | 790 | int mgmt_user_confirm_neg_reply_complete(u16 index, bdaddr_t *bdaddr, |
768 | u8 status); | 791 | u8 status); |
769 | int mgmt_auth_failed(u16 index, bdaddr_t *bdaddr, u8 status); | 792 | int mgmt_auth_failed(u16 index, bdaddr_t *bdaddr, u8 status); |
793 | int mgmt_set_local_name_complete(u16 index, u8 *name, u8 status); | ||
794 | int mgmt_read_local_oob_data_reply_complete(u16 index, u8 *hash, u8 *randomizer, | ||
795 | u8 status); | ||
796 | int mgmt_device_found(u16 index, bdaddr_t *bdaddr, u8 *dev_class, s8 rssi, | ||
797 | u8 *eir); | ||
798 | int mgmt_remote_name(u16 index, bdaddr_t *bdaddr, u8 *name); | ||
799 | int 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 4f4bff1eaed6..d09c9b1118e3 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 ----- */ |
280 | struct l2cap_chan_list { | ||
281 | struct sock *head; | ||
282 | rwlock_t lock; | ||
283 | long num; | ||
284 | }; | ||
285 | |||
286 | struct 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 | |||
313 | struct 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 | |||
329 | struct srej_list { | 280 | struct srej_list { |
330 | __u8 tx_seq; | 281 | __u8 tx_seq; |
331 | struct list_head list; | 282 | struct list_head list; |
332 | }; | 283 | }; |
333 | 284 | ||
334 | struct l2cap_pinfo { | 285 | struct 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 | |||
356 | struct 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 | |||
390 | struct 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 | ||
429 | static inline int l2cap_tx_window_full(struct sock *sk) | 426 | static 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 | ||
448 | extern int disable_ertm; | 444 | extern int disable_ertm; |
449 | extern const struct proto_ops l2cap_sock_ops; | ||
450 | extern struct bt_sock_list l2cap_sk_list; | ||
451 | 445 | ||
452 | int l2cap_init_sockets(void); | 446 | int l2cap_init_sockets(void); |
453 | void l2cap_cleanup_sockets(void); | 447 | void l2cap_cleanup_sockets(void); |
454 | 448 | ||
455 | u8 l2cap_get_ident(struct l2cap_conn *conn); | ||
456 | void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data); | 449 | void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data); |
457 | int l2cap_build_conf_req(struct sock *sk, void *data); | 450 | void __l2cap_connect_rsp_defer(struct l2cap_chan *chan); |
458 | int __l2cap_wait_ack(struct sock *sk); | 451 | int __l2cap_wait_ack(struct sock *sk); |
459 | 452 | ||
460 | struct sk_buff *l2cap_create_connless_pdu(struct sock *sk, struct msghdr *msg, size_t len); | 453 | struct sk_buff *l2cap_create_connless_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len); |
461 | struct sk_buff *l2cap_create_basic_pdu(struct sock *sk, struct msghdr *msg, size_t len); | 454 | struct sk_buff *l2cap_create_basic_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len); |
462 | struct sk_buff *l2cap_create_iframe_pdu(struct sock *sk, struct msghdr *msg, size_t len, u16 control, u16 sdulen); | 455 | struct sk_buff *l2cap_create_iframe_pdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len, u16 control, u16 sdulen); |
463 | int l2cap_sar_segment_sdu(struct sock *sk, struct msghdr *msg, size_t len); | 456 | int l2cap_sar_segment_sdu(struct l2cap_chan *chan, struct msghdr *msg, size_t len); |
464 | void l2cap_do_send(struct sock *sk, struct sk_buff *skb); | 457 | void l2cap_do_send(struct l2cap_chan *chan, struct sk_buff *skb); |
465 | void l2cap_streaming_send(struct sock *sk); | 458 | void l2cap_streaming_send(struct l2cap_chan *chan); |
466 | int l2cap_ertm_send(struct sock *sk); | 459 | int l2cap_ertm_send(struct l2cap_chan *chan); |
460 | |||
461 | int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm); | ||
462 | int l2cap_add_scid(struct l2cap_chan *chan, __u16 scid); | ||
467 | 463 | ||
468 | void l2cap_sock_set_timer(struct sock *sk, long timeout); | 464 | void l2cap_sock_set_timer(struct sock *sk, long timeout); |
469 | void l2cap_sock_clear_timer(struct sock *sk); | 465 | void l2cap_sock_clear_timer(struct sock *sk); |
@@ -472,8 +468,10 @@ void l2cap_sock_kill(struct sock *sk); | |||
472 | void l2cap_sock_init(struct sock *sk, struct sock *parent); | 468 | void l2cap_sock_init(struct sock *sk, struct sock *parent); |
473 | struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, | 469 | struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, |
474 | int proto, gfp_t prio); | 470 | int proto, gfp_t prio); |
475 | void l2cap_send_disconn_req(struct l2cap_conn *conn, struct sock *sk, int err); | 471 | void l2cap_send_disconn_req(struct l2cap_conn *conn, struct l2cap_chan *chan, int err); |
476 | void l2cap_chan_del(struct sock *sk, int err); | 472 | struct l2cap_chan *l2cap_chan_create(struct sock *sk); |
477 | int l2cap_do_connect(struct sock *sk); | 473 | void l2cap_chan_del(struct l2cap_chan *chan, int err); |
474 | void l2cap_chan_destroy(struct l2cap_chan *chan); | ||
475 | int 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 5fabfa886b3e..4899286ed4e4 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 |
45 | struct mgmt_rp_read_info { | 49 | struct 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 | ||
60 | struct mgmt_mode { | 65 | struct 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 | ||
176 | struct mgmt_cp_set_local_name { | ||
177 | __u8 name[MGMT_MAX_NAME_LENGTH]; | ||
178 | } __packed; | ||
179 | |||
180 | #define MGMT_OP_READ_LOCAL_OOB_DATA 0x0018 | ||
181 | struct 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 | ||
187 | struct 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 | ||
194 | struct 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 |
171 | struct mgmt_ev_cmd_complete { | 203 | struct 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 |
200 | struct mgmt_ev_new_key { | 232 | struct 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 |
222 | struct mgmt_ev_pin_code_request { | 254 | struct 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 |
227 | struct mgmt_ev_user_confirm_request { | 260 | struct 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 | ||
273 | struct mgmt_ev_local_name_changed { | ||
274 | __u8 name[MGMT_MAX_NAME_LENGTH]; | ||
275 | } __packed; | ||
276 | |||
277 | #define MGMT_EV_DEVICE_FOUND 0x0012 | ||
278 | struct 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 | ||
286 | struct mgmt_ev_remote_name { | ||
287 | bdaddr_t bdaddr; | ||
288 | __u8 name[MGMT_MAX_NAME_LENGTH]; | ||
289 | } __packed; | ||
290 | |||
291 | #define MGMT_EV_DISCOVERING 0x0014 | ||