hc
2024-01-31 f9004dbfff8a3fbbd7e2a88c8a4327c7f2f8e5b2
kernel/include/net/bluetooth/l2cap.h
....@@ -29,6 +29,7 @@
2929
3030 #include <asm/unaligned.h>
3131 #include <linux/atomic.h>
32
+#include <linux/android_kabi.h>
3233
3334 /* L2CAP defaults */
3435 #define L2CAP_DEFAULT_MTU 672
....@@ -47,6 +48,7 @@
4748 #define L2CAP_DEFAULT_ACC_LAT 0xFFFFFFFF
4849 #define L2CAP_BREDR_MAX_PAYLOAD 1019 /* 3-DH5 packet */
4950 #define L2CAP_LE_MIN_MTU 23
51
+#define L2CAP_ECRED_CONN_SCID_MAX 5
5052
5153 #define L2CAP_DISC_TIMEOUT msecs_to_jiffies(100)
5254 #define L2CAP_DISC_REJ_TIMEOUT msecs_to_jiffies(5000)
....@@ -119,6 +121,10 @@
119121 #define L2CAP_LE_CONN_REQ 0x14
120122 #define L2CAP_LE_CONN_RSP 0x15
121123 #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
122128
123129 /* L2CAP extended feature mask */
124130 #define L2CAP_FEAT_FLOWCTL 0x00000001
....@@ -277,12 +283,21 @@
277283 #define L2CAP_CR_SEC_BLOCK 0x0003
278284 #define L2CAP_CR_NO_MEM 0x0004
279285 #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
286301
287302 /* connect/create channel status */
288303 #define L2CAP_CS_NO_INFO 0x0000
....@@ -292,14 +307,14 @@
292307 struct l2cap_conf_req {
293308 __le16 dcid;
294309 __le16 flags;
295
- __u8 data[0];
310
+ __u8 data[];
296311 } __packed;
297312
298313 struct l2cap_conf_rsp {
299314 __le16 scid;
300315 __le16 flags;
301316 __le16 result;
302
- __u8 data[0];
317
+ __u8 data[];
303318 } __packed;
304319
305320 #define L2CAP_CONF_SUCCESS 0x0000
....@@ -315,7 +330,7 @@
315330 struct l2cap_conf_opt {
316331 __u8 type;
317332 __u8 len;
318
- __u8 val[0];
333
+ __u8 val[];
319334 } __packed;
320335 #define L2CAP_CONF_OPT_SIZE 2
321336
....@@ -352,6 +367,7 @@
352367 * ever be used in the BR/EDR configuration phase.
353368 */
354369 #define L2CAP_MODE_LE_FLOWCTL 0x80
370
+#define L2CAP_MODE_EXT_FLOWCTL 0x81
355371
356372 struct l2cap_conf_efs {
357373 __u8 id;
....@@ -385,7 +401,7 @@
385401 struct l2cap_info_rsp {
386402 __le16 type;
387403 __le16 result;
388
- __u8 data[0];
404
+ __u8 data[];
389405 } __packed;
390406
391407 struct l2cap_create_chan_req {
....@@ -455,9 +471,6 @@
455471 #define L2CAP_CONN_PARAM_ACCEPTED 0x0000
456472 #define L2CAP_CONN_PARAM_REJECTED 0x0001
457473
458
-#define L2CAP_LE_MAX_CREDITS 10
459
-#define L2CAP_LE_DEFAULT_MPS 230
460
-
461474 struct l2cap_le_conn_req {
462475 __le16 psm;
463476 __le16 scid;
....@@ -477,6 +490,40 @@
477490 struct l2cap_le_credits {
478491 __le16 cid;
479492 __le16 credits;
493
+} __packed;
494
+
495
+#define L2CAP_ECRED_MIN_MTU 64
496
+#define L2CAP_ECRED_MIN_MPS 64
497
+#define L2CAP_ECRED_MAX_CID 5
498
+
499
+struct l2cap_ecred_conn_req {
500
+ __le16 psm;
501
+ __le16 mtu;
502
+ __le16 mps;
503
+ __le16 credits;
504
+ __le16 scid[];
505
+} __packed;
506
+
507
+struct l2cap_ecred_conn_rsp {
508
+ __le16 mtu;
509
+ __le16 mps;
510
+ __le16 credits;
511
+ __le16 result;
512
+ __le16 dcid[];
513
+};
514
+
515
+struct l2cap_ecred_reconf_req {
516
+ __le16 mtu;
517
+ __le16 mps;
518
+ __le16 scid[];
519
+} __packed;
520
+
521
+#define L2CAP_RECONF_SUCCESS 0x0000
522
+#define L2CAP_RECONF_INVALID_MTU 0x0001
523
+#define L2CAP_RECONF_INVALID_MPS 0x0002
524
+
525
+struct l2cap_ecred_reconf_rsp {
526
+ __le16 result;
480527 } __packed;
481528
482529 /* ----- L2CAP channels and connections ----- */
....@@ -598,6 +645,9 @@
598645 void *data;
599646 const struct l2cap_ops *ops;
600647 struct mutex lock;
648
+
649
+ ANDROID_KABI_RESERVE(1);
650
+ ANDROID_KABI_RESERVE(2);
601651 };
602652
603653 struct l2cap_ops {
....@@ -616,11 +666,15 @@
616666 void (*suspend) (struct l2cap_chan *chan);
617667 void (*set_shutdown) (struct l2cap_chan *chan);
618668 long (*get_sndtimeo) (struct l2cap_chan *chan);
669
+ struct pid *(*get_peer_pid) (struct l2cap_chan *chan);
619670 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
620671 unsigned long hdr_len,
621672 unsigned long len, int nb);
622673 int (*filter) (struct l2cap_chan * chan,
623674 struct sk_buff *skb);
675
+
676
+ ANDROID_KABI_RESERVE(1);
677
+ ANDROID_KABI_RESERVE(2);
624678 };
625679
626680 struct l2cap_conn {
....@@ -656,6 +710,9 @@
656710 struct mutex chan_lock;
657711 struct kref ref;
658712 struct list_head users;
713
+
714
+ ANDROID_KABI_RESERVE(1);
715
+ ANDROID_KABI_RESERVE(2);
659716 };
660717
661718 struct l2cap_user {
....@@ -722,6 +779,7 @@
722779 FLAG_EFS_ENABLE,
723780 FLAG_DEFER_SETUP,
724781 FLAG_LE_CONN_REQ_SENT,
782
+ FLAG_ECRED_CONN_REQ_SENT,
725783 FLAG_PENDING_SECURITY,
726784 FLAG_HOLD_HCI_CONN,
727785 };
....@@ -798,6 +856,7 @@
798856 };
799857
800858 void l2cap_chan_hold(struct l2cap_chan *c);
859
+struct l2cap_chan *l2cap_chan_hold_unless_zero(struct l2cap_chan *c);
801860 void l2cap_chan_put(struct l2cap_chan *c);
802861
803862 static inline void l2cap_chan_lock(struct l2cap_chan *chan)
....@@ -915,12 +974,14 @@
915974 }
916975
917976 extern bool disable_ertm;
977
+extern bool enable_ecred;
918978
919979 int l2cap_init_sockets(void);
920980 void l2cap_cleanup_sockets(void);
921981 bool l2cap_is_socket(struct socket *sock);
922982
923983 void __l2cap_le_connect_rsp_defer(struct l2cap_chan *chan);
984
+void __l2cap_ecred_conn_rsp_defer(struct l2cap_chan *chan);
924985 void __l2cap_connect_rsp_defer(struct l2cap_chan *chan);
925986
926987 int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm);
....@@ -930,6 +991,7 @@
930991 void l2cap_chan_close(struct l2cap_chan *chan, int reason);
931992 int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
932993 bdaddr_t *dst, u8 dst_type);
994
+int l2cap_chan_reconfigure(struct l2cap_chan *chan, __u16 mtu);
933995 int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len);
934996 void l2cap_chan_busy(struct l2cap_chan *chan, int busy);
935997 int l2cap_chan_check_security(struct l2cap_chan *chan, bool initiator);
....@@ -937,6 +999,9 @@
937999 int l2cap_ertm_init(struct l2cap_chan *chan);
9381000 void l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan);
9391001 void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan);
1002
+typedef void (*l2cap_chan_func_t)(struct l2cap_chan *chan, void *data);
1003
+void l2cap_chan_list(struct l2cap_conn *conn, l2cap_chan_func_t func,
1004
+ void *data);
9401005 void l2cap_chan_del(struct l2cap_chan *chan, int err);
9411006 void l2cap_send_conn_req(struct l2cap_chan *chan);
9421007 void l2cap_move_start(struct l2cap_chan *chan);