.. | .. |
---|
29 | 29 | |
---|
30 | 30 | #include <asm/unaligned.h> |
---|
31 | 31 | #include <linux/atomic.h> |
---|
| 32 | +#include <linux/android_kabi.h> |
---|
32 | 33 | |
---|
33 | 34 | /* L2CAP defaults */ |
---|
34 | 35 | #define L2CAP_DEFAULT_MTU 672 |
---|
.. | .. |
---|
47 | 48 | #define L2CAP_DEFAULT_ACC_LAT 0xFFFFFFFF |
---|
48 | 49 | #define L2CAP_BREDR_MAX_PAYLOAD 1019 /* 3-DH5 packet */ |
---|
49 | 50 | #define L2CAP_LE_MIN_MTU 23 |
---|
| 51 | +#define L2CAP_ECRED_CONN_SCID_MAX 5 |
---|
50 | 52 | |
---|
51 | 53 | #define L2CAP_DISC_TIMEOUT msecs_to_jiffies(100) |
---|
52 | 54 | #define L2CAP_DISC_REJ_TIMEOUT msecs_to_jiffies(5000) |
---|
.. | .. |
---|
119 | 121 | #define L2CAP_LE_CONN_REQ 0x14 |
---|
120 | 122 | #define L2CAP_LE_CONN_RSP 0x15 |
---|
121 | 123 | #define L2CAP_LE_CREDITS 0x16 |
---|
| 124 | +#define L2CAP_ECRED_CONN_REQ 0x17 |
---|
| 125 | +#define L2CAP_ECRED_CONN_RSP 0x18 |
---|
| 126 | +#define L2CAP_ECRED_RECONF_REQ 0x19 |
---|
| 127 | +#define L2CAP_ECRED_RECONF_RSP 0x1a |
---|
122 | 128 | |
---|
123 | 129 | /* L2CAP extended feature mask */ |
---|
124 | 130 | #define L2CAP_FEAT_FLOWCTL 0x00000001 |
---|
.. | .. |
---|
277 | 283 | #define L2CAP_CR_SEC_BLOCK 0x0003 |
---|
278 | 284 | #define L2CAP_CR_NO_MEM 0x0004 |
---|
279 | 285 | #define L2CAP_CR_BAD_AMP 0x0005 |
---|
280 | | -#define L2CAP_CR_AUTHENTICATION 0x0005 |
---|
281 | | -#define L2CAP_CR_AUTHORIZATION 0x0006 |
---|
282 | | -#define L2CAP_CR_BAD_KEY_SIZE 0x0007 |
---|
283 | | -#define L2CAP_CR_ENCRYPTION 0x0008 |
---|
284 | | -#define L2CAP_CR_INVALID_SCID 0x0009 |
---|
285 | | -#define L2CAP_CR_SCID_IN_USE 0x000A |
---|
| 286 | +#define L2CAP_CR_INVALID_SCID 0x0006 |
---|
| 287 | +#define L2CAP_CR_SCID_IN_USE 0x0007 |
---|
| 288 | + |
---|
| 289 | +/* credit based connect results */ |
---|
| 290 | +#define L2CAP_CR_LE_SUCCESS 0x0000 |
---|
| 291 | +#define L2CAP_CR_LE_BAD_PSM 0x0002 |
---|
| 292 | +#define L2CAP_CR_LE_NO_MEM 0x0004 |
---|
| 293 | +#define L2CAP_CR_LE_AUTHENTICATION 0x0005 |
---|
| 294 | +#define L2CAP_CR_LE_AUTHORIZATION 0x0006 |
---|
| 295 | +#define L2CAP_CR_LE_BAD_KEY_SIZE 0x0007 |
---|
| 296 | +#define L2CAP_CR_LE_ENCRYPTION 0x0008 |
---|
| 297 | +#define L2CAP_CR_LE_INVALID_SCID 0x0009 |
---|
| 298 | +#define L2CAP_CR_LE_SCID_IN_USE 0X000A |
---|
| 299 | +#define L2CAP_CR_LE_UNACCEPT_PARAMS 0X000B |
---|
| 300 | +#define L2CAP_CR_LE_INVALID_PARAMS 0X000C |
---|
286 | 301 | |
---|
287 | 302 | /* connect/create channel status */ |
---|
288 | 303 | #define L2CAP_CS_NO_INFO 0x0000 |
---|
.. | .. |
---|
292 | 307 | struct l2cap_conf_req { |
---|
293 | 308 | __le16 dcid; |
---|
294 | 309 | __le16 flags; |
---|
295 | | - __u8 data[0]; |
---|
| 310 | + __u8 data[]; |
---|
296 | 311 | } __packed; |
---|
297 | 312 | |
---|
298 | 313 | struct l2cap_conf_rsp { |
---|
299 | 314 | __le16 scid; |
---|
300 | 315 | __le16 flags; |
---|
301 | 316 | __le16 result; |
---|
302 | | - __u8 data[0]; |
---|
| 317 | + __u8 data[]; |
---|
303 | 318 | } __packed; |
---|
304 | 319 | |
---|
305 | 320 | #define L2CAP_CONF_SUCCESS 0x0000 |
---|
.. | .. |
---|
315 | 330 | struct l2cap_conf_opt { |
---|
316 | 331 | __u8 type; |
---|
317 | 332 | __u8 len; |
---|
318 | | - __u8 val[0]; |
---|
| 333 | + __u8 val[]; |
---|
319 | 334 | } __packed; |
---|
320 | 335 | #define L2CAP_CONF_OPT_SIZE 2 |
---|
321 | 336 | |
---|
.. | .. |
---|
352 | 367 | * ever be used in the BR/EDR configuration phase. |
---|
353 | 368 | */ |
---|
354 | 369 | #define L2CAP_MODE_LE_FLOWCTL 0x80 |
---|
| 370 | +#define L2CAP_MODE_EXT_FLOWCTL 0x81 |
---|
355 | 371 | |
---|
356 | 372 | struct l2cap_conf_efs { |
---|
357 | 373 | __u8 id; |
---|
.. | .. |
---|
385 | 401 | struct l2cap_info_rsp { |
---|
386 | 402 | __le16 type; |
---|
387 | 403 | __le16 result; |
---|
388 | | - __u8 data[0]; |
---|
| 404 | + __u8 data[]; |
---|
389 | 405 | } __packed; |
---|
390 | 406 | |
---|
391 | 407 | struct l2cap_create_chan_req { |
---|
.. | .. |
---|
455 | 471 | #define L2CAP_CONN_PARAM_ACCEPTED 0x0000 |
---|
456 | 472 | #define L2CAP_CONN_PARAM_REJECTED 0x0001 |
---|
457 | 473 | |
---|
458 | | -#define L2CAP_LE_MAX_CREDITS 10 |
---|
459 | | -#define L2CAP_LE_DEFAULT_MPS 230 |
---|
460 | | - |
---|
461 | 474 | struct l2cap_le_conn_req { |
---|
462 | 475 | __le16 psm; |
---|
463 | 476 | __le16 scid; |
---|
.. | .. |
---|
477 | 490 | struct l2cap_le_credits { |
---|
478 | 491 | __le16 cid; |
---|
479 | 492 | __le16 credits; |
---|
| 493 | +} __packed; |
---|
| 494 | + |
---|
| 495 | +#define L2CAP_ECRED_MIN_MTU 64 |
---|
| 496 | +#define L2CAP_ECRED_MIN_MPS 64 |
---|
| 497 | + |
---|
| 498 | +struct l2cap_ecred_conn_req { |
---|
| 499 | + __le16 psm; |
---|
| 500 | + __le16 mtu; |
---|
| 501 | + __le16 mps; |
---|
| 502 | + __le16 credits; |
---|
| 503 | + __le16 scid[]; |
---|
| 504 | +} __packed; |
---|
| 505 | + |
---|
| 506 | +struct l2cap_ecred_conn_rsp { |
---|
| 507 | + __le16 mtu; |
---|
| 508 | + __le16 mps; |
---|
| 509 | + __le16 credits; |
---|
| 510 | + __le16 result; |
---|
| 511 | + __le16 dcid[]; |
---|
| 512 | +}; |
---|
| 513 | + |
---|
| 514 | +struct l2cap_ecred_reconf_req { |
---|
| 515 | + __le16 mtu; |
---|
| 516 | + __le16 mps; |
---|
| 517 | + __le16 scid[]; |
---|
| 518 | +} __packed; |
---|
| 519 | + |
---|
| 520 | +#define L2CAP_RECONF_SUCCESS 0x0000 |
---|
| 521 | +#define L2CAP_RECONF_INVALID_MTU 0x0001 |
---|
| 522 | +#define L2CAP_RECONF_INVALID_MPS 0x0002 |
---|
| 523 | + |
---|
| 524 | +struct l2cap_ecred_reconf_rsp { |
---|
| 525 | + __le16 result; |
---|
480 | 526 | } __packed; |
---|
481 | 527 | |
---|
482 | 528 | /* ----- L2CAP channels and connections ----- */ |
---|
.. | .. |
---|
598 | 644 | void *data; |
---|
599 | 645 | const struct l2cap_ops *ops; |
---|
600 | 646 | struct mutex lock; |
---|
| 647 | + |
---|
| 648 | + ANDROID_KABI_RESERVE(1); |
---|
| 649 | + ANDROID_KABI_RESERVE(2); |
---|
601 | 650 | }; |
---|
602 | 651 | |
---|
603 | 652 | struct l2cap_ops { |
---|
.. | .. |
---|
616 | 665 | void (*suspend) (struct l2cap_chan *chan); |
---|
617 | 666 | void (*set_shutdown) (struct l2cap_chan *chan); |
---|
618 | 667 | long (*get_sndtimeo) (struct l2cap_chan *chan); |
---|
| 668 | + struct pid *(*get_peer_pid) (struct l2cap_chan *chan); |
---|
619 | 669 | struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan, |
---|
620 | 670 | unsigned long hdr_len, |
---|
621 | 671 | unsigned long len, int nb); |
---|
622 | 672 | int (*filter) (struct l2cap_chan * chan, |
---|
623 | 673 | struct sk_buff *skb); |
---|
| 674 | + |
---|
| 675 | + ANDROID_KABI_RESERVE(1); |
---|
| 676 | + ANDROID_KABI_RESERVE(2); |
---|
624 | 677 | }; |
---|
625 | 678 | |
---|
626 | 679 | struct l2cap_conn { |
---|
.. | .. |
---|
656 | 709 | struct mutex chan_lock; |
---|
657 | 710 | struct kref ref; |
---|
658 | 711 | struct list_head users; |
---|
| 712 | + |
---|
| 713 | + ANDROID_KABI_RESERVE(1); |
---|
| 714 | + ANDROID_KABI_RESERVE(2); |
---|
659 | 715 | }; |
---|
660 | 716 | |
---|
661 | 717 | struct l2cap_user { |
---|
.. | .. |
---|
722 | 778 | FLAG_EFS_ENABLE, |
---|
723 | 779 | FLAG_DEFER_SETUP, |
---|
724 | 780 | FLAG_LE_CONN_REQ_SENT, |
---|
| 781 | + FLAG_ECRED_CONN_REQ_SENT, |
---|
725 | 782 | FLAG_PENDING_SECURITY, |
---|
726 | 783 | FLAG_HOLD_HCI_CONN, |
---|
727 | 784 | }; |
---|
.. | .. |
---|
798 | 855 | }; |
---|
799 | 856 | |
---|
800 | 857 | void l2cap_chan_hold(struct l2cap_chan *c); |
---|
| 858 | +struct l2cap_chan *l2cap_chan_hold_unless_zero(struct l2cap_chan *c); |
---|
801 | 859 | void l2cap_chan_put(struct l2cap_chan *c); |
---|
802 | 860 | |
---|
803 | 861 | static inline void l2cap_chan_lock(struct l2cap_chan *chan) |
---|
.. | .. |
---|
915 | 973 | } |
---|
916 | 974 | |
---|
917 | 975 | extern bool disable_ertm; |
---|
| 976 | +extern bool enable_ecred; |
---|
918 | 977 | |
---|
919 | 978 | int l2cap_init_sockets(void); |
---|
920 | 979 | void l2cap_cleanup_sockets(void); |
---|
921 | 980 | bool l2cap_is_socket(struct socket *sock); |
---|
922 | 981 | |
---|
923 | 982 | void __l2cap_le_connect_rsp_defer(struct l2cap_chan *chan); |
---|
| 983 | +void __l2cap_ecred_conn_rsp_defer(struct l2cap_chan *chan); |
---|
924 | 984 | void __l2cap_connect_rsp_defer(struct l2cap_chan *chan); |
---|
925 | 985 | |
---|
926 | 986 | int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm); |
---|
.. | .. |
---|
930 | 990 | void l2cap_chan_close(struct l2cap_chan *chan, int reason); |
---|
931 | 991 | int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid, |
---|
932 | 992 | bdaddr_t *dst, u8 dst_type); |
---|
| 993 | +int l2cap_chan_reconfigure(struct l2cap_chan *chan, __u16 mtu); |
---|
933 | 994 | int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len); |
---|
934 | 995 | void l2cap_chan_busy(struct l2cap_chan *chan, int busy); |
---|
935 | 996 | int l2cap_chan_check_security(struct l2cap_chan *chan, bool initiator); |
---|
.. | .. |
---|
937 | 998 | int l2cap_ertm_init(struct l2cap_chan *chan); |
---|
938 | 999 | void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan); |
---|
939 | 1000 | void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan); |
---|
| 1001 | +typedef void (*l2cap_chan_func_t)(struct l2cap_chan *chan, void *data); |
---|
| 1002 | +void l2cap_chan_list(struct l2cap_conn *conn, l2cap_chan_func_t func, |
---|
| 1003 | + void *data); |
---|
940 | 1004 | void l2cap_chan_del(struct l2cap_chan *chan, int err); |
---|
941 | 1005 | void l2cap_send_conn_req(struct l2cap_chan *chan); |
---|
942 | 1006 | void l2cap_move_start(struct l2cap_chan *chan); |
---|