| Andrei Emeltchenko | be21871 | 2010-12-01 16:58:26 +0200 | [diff] [blame] | 1 | /* | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | BlueZ - Bluetooth protocol stack for Linux | 
| Srinivas Krovvidi | 1073419 | 2011-12-29 07:29:11 +0530 | [diff] [blame] | 3 | Copyright (c) 2000-2001, 2010-2012 Code Aurora Forum.  All rights reserved. | 
| Gustavo F. Padovan | ce5706b | 2010-07-13 11:57:11 -0300 | [diff] [blame] | 4 | Copyright (C) 2009-2010 Gustavo F. Padovan <gustavo@padovan.org> | 
| Gustavo F. Padovan | 5d8868f | 2010-07-16 16:18:39 -0300 | [diff] [blame] | 5 | Copyright (C) 2010 Google Inc. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 |  | 
|  | 7 | Written 2000,2001 by Maxim Krasnyansky <maxk@qualcomm.com> | 
|  | 8 |  | 
|  | 9 | This program is free software; you can redistribute it and/or modify | 
|  | 10 | it under the terms of the GNU General Public License version 2 as | 
|  | 11 | published by the Free Software Foundation; | 
|  | 12 |  | 
|  | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS | 
|  | 14 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | 
|  | 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. | 
|  | 16 | IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) AND AUTHOR(S) BE LIABLE FOR ANY | 
| Andrei Emeltchenko | be21871 | 2010-12-01 16:58:26 +0200 | [diff] [blame] | 17 | CLAIM, OR ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES | 
|  | 18 | WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | 
|  | 19 | ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 
|  | 21 |  | 
| Andrei Emeltchenko | be21871 | 2010-12-01 16:58:26 +0200 | [diff] [blame] | 22 | ALL LIABILITY, INCLUDING LIABILITY FOR INFRINGEMENT OF ANY PATENTS, | 
|  | 23 | COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS, RELATING TO USE OF THIS | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | SOFTWARE IS DISCLAIMED. | 
|  | 25 | */ | 
|  | 26 |  | 
|  | 27 | #ifndef __L2CAP_H | 
|  | 28 | #define __L2CAP_H | 
|  | 29 |  | 
|  | 30 | /* L2CAP defaults */ | 
| Marcel Holtmann | 47ec1dcd | 2009-05-02 18:57:55 -0700 | [diff] [blame] | 31 | #define L2CAP_DEFAULT_MTU		672 | 
| Gustavo F. Padovan | f2fcfcd | 2009-07-04 15:06:24 -0300 | [diff] [blame] | 32 | #define L2CAP_DEFAULT_MIN_MTU		48 | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 33 | #define L2CAP_DEFAULT_MAX_SDU_SIZE	0xffff | 
| Marcel Holtmann | 47ec1dcd | 2009-05-02 18:57:55 -0700 | [diff] [blame] | 34 | #define L2CAP_DEFAULT_FLUSH_TO		0xffff | 
| Srinivas Krovvidi | 1073419 | 2011-12-29 07:29:11 +0530 | [diff] [blame] | 35 | #define L2CAP_MAX_FLUSH_TO		0x7ff | 
| Gustavo F. Padovan | 1c2acff | 2009-08-20 22:25:57 -0300 | [diff] [blame] | 36 | #define L2CAP_DEFAULT_TX_WINDOW		63 | 
| Gustavo F. Padovan | e90bac0 | 2009-08-20 22:26:00 -0300 | [diff] [blame] | 37 | #define L2CAP_DEFAULT_MAX_TX		3 | 
| Mat Martineau | fa23556 | 2010-08-05 15:54:20 -0700 | [diff] [blame] | 38 | #define L2CAP_DEFAULT_RETRANS_TO	2000    /* 2 seconds */ | 
| Gustavo F. Padovan | e90bac0 | 2009-08-20 22:26:00 -0300 | [diff] [blame] | 39 | #define L2CAP_DEFAULT_MONITOR_TO	12000   /* 12 seconds */ | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 40 | #define L2CAP_DEFAULT_MAX_PDU_SIZE	1482    /* Sized for AMP or BR/EDR */ | 
| Gustavo F. Padovan | c1b4f43 | 2010-05-01 16:15:39 -0300 | [diff] [blame] | 41 | #define L2CAP_DEFAULT_ACK_TO		200 | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 42 | #define L2CAP_BREDR_MAX_PAYLOAD		1019    /* 3-DH5 packet */ | 
|  | 43 | #define L2CAP_MAX_ERTM_QUEUED		5 | 
|  | 44 | #define L2CAP_MIN_ERTM_QUEUED		2 | 
|  | 45 |  | 
|  | 46 | #define L2CAP_A2MP_DEFAULT_MTU		670 | 
|  | 47 |  | 
|  | 48 | #define L2CAP_TX_WIN_MAX_ENHANCED	0x3f | 
|  | 49 | #define L2CAP_TX_WIN_MAX_EXTENDED	0x3fff | 
| Ville Tervo | b62f328 | 2011-02-10 22:38:50 -0300 | [diff] [blame] | 50 | #define L2CAP_LE_DEFAULT_MTU		23 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 |  | 
| Marcel Holtmann | 4e8402a | 2007-10-20 13:37:56 +0200 | [diff] [blame] | 52 | #define L2CAP_CONN_TIMEOUT	(40000) /* 40 seconds */ | 
|  | 53 | #define L2CAP_INFO_TIMEOUT	(4000)  /*  4 seconds */ | 
| Peter Krystad | 4d97723 | 2012-02-07 15:00:37 -0800 | [diff] [blame] | 54 | #define L2CAP_MOVE_TIMEOUT		(4*HZ)  /*  4 seconds */ | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 55 | #define L2CAP_MOVE_ERTX_TIMEOUT		(60*HZ) /* 60 seconds */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 |  | 
|  | 57 | /* L2CAP socket address */ | 
|  | 58 | struct sockaddr_l2 { | 
|  | 59 | sa_family_t	l2_family; | 
| Al Viro | 8e036fc | 2007-07-29 00:16:36 -0700 | [diff] [blame] | 60 | __le16		l2_psm; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | bdaddr_t	l2_bdaddr; | 
| Marcel Holtmann | f29972d | 2009-02-12 05:07:45 +0100 | [diff] [blame] | 62 | __le16		l2_cid; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | }; | 
|  | 64 |  | 
|  | 65 | /* L2CAP socket options */ | 
|  | 66 | #define L2CAP_OPTIONS	0x01 | 
|  | 67 | struct l2cap_options { | 
|  | 68 | __u16 omtu; | 
|  | 69 | __u16 imtu; | 
|  | 70 | __u16 flush_to; | 
|  | 71 | __u8  mode; | 
| Gustavo F. Padovan | fcc203c | 2009-08-20 22:26:02 -0300 | [diff] [blame] | 72 | __u8  fcs; | 
| Gustavo F. Padovan | 68d7f0c | 2010-05-01 16:15:41 -0300 | [diff] [blame] | 73 | __u8  max_tx; | 
| Gustavo F. Padovan | 14b5aa7 | 2010-05-01 16:15:40 -0300 | [diff] [blame] | 74 | __u16 txwin_size; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | }; | 
|  | 76 |  | 
|  | 77 | #define L2CAP_CONNINFO	0x02 | 
|  | 78 | struct l2cap_conninfo { | 
|  | 79 | __u16 hci_handle; | 
|  | 80 | __u8  dev_class[3]; | 
|  | 81 | }; | 
|  | 82 |  | 
|  | 83 | #define L2CAP_LM	0x03 | 
|  | 84 | #define L2CAP_LM_MASTER		0x0001 | 
|  | 85 | #define L2CAP_LM_AUTH		0x0002 | 
|  | 86 | #define L2CAP_LM_ENCRYPT	0x0004 | 
|  | 87 | #define L2CAP_LM_TRUSTED	0x0008 | 
|  | 88 | #define L2CAP_LM_RELIABLE	0x0010 | 
|  | 89 | #define L2CAP_LM_SECURE		0x0020 | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 90 | #define L2CAP_LM_FLUSHABLE	0x0040 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 |  | 
|  | 92 | /* L2CAP command codes */ | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 93 | #define L2CAP_COMMAND_REJ		0x01 | 
|  | 94 | #define L2CAP_CONN_REQ			0x02 | 
|  | 95 | #define L2CAP_CONN_RSP			0x03 | 
|  | 96 | #define L2CAP_CONF_REQ			0x04 | 
|  | 97 | #define L2CAP_CONF_RSP			0x05 | 
|  | 98 | #define L2CAP_DISCONN_REQ		0x06 | 
|  | 99 | #define L2CAP_DISCONN_RSP		0x07 | 
|  | 100 | #define L2CAP_ECHO_REQ			0x08 | 
|  | 101 | #define L2CAP_ECHO_RSP			0x09 | 
|  | 102 | #define L2CAP_INFO_REQ			0x0a | 
|  | 103 | #define L2CAP_INFO_RSP			0x0b | 
|  | 104 | #define L2CAP_CREATE_CHAN_REQ	0x0c | 
|  | 105 | #define L2CAP_CREATE_CHAN_RSP	0x0d | 
|  | 106 | #define L2CAP_MOVE_CHAN_REQ		0x0e | 
|  | 107 | #define L2CAP_MOVE_CHAN_RSP		0x0f | 
|  | 108 | #define L2CAP_MOVE_CHAN_CFM		0x10 | 
|  | 109 | #define L2CAP_MOVE_CHAN_CFM_RSP	0x11 | 
| Claudio Takahasi | 3300d9a | 2011-02-11 19:28:54 -0200 | [diff] [blame] | 110 | #define L2CAP_CONN_PARAM_UPDATE_REQ	0x12 | 
|  | 111 | #define L2CAP_CONN_PARAM_UPDATE_RSP	0x13 | 
| Marcel Holtmann | 47ec1dcd | 2009-05-02 18:57:55 -0700 | [diff] [blame] | 112 |  | 
|  | 113 | /* L2CAP feature mask */ | 
|  | 114 | #define L2CAP_FEAT_FLOWCTL	0x00000001 | 
|  | 115 | #define L2CAP_FEAT_RETRANS	0x00000002 | 
|  | 116 | #define L2CAP_FEAT_ERTM		0x00000008 | 
|  | 117 | #define L2CAP_FEAT_STREAMING	0x00000010 | 
|  | 118 | #define L2CAP_FEAT_FCS		0x00000020 | 
|  | 119 | #define L2CAP_FEAT_FIXED_CHAN	0x00000080 | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 120 | #define L2CAP_FEAT_EXT_WINDOW	0x00000100 | 
|  | 121 | #define L2CAP_FEAT_UCD		0x00000200 | 
| Marcel Holtmann | 47ec1dcd | 2009-05-02 18:57:55 -0700 | [diff] [blame] | 122 |  | 
|  | 123 | /* L2CAP checksum option */ | 
|  | 124 | #define L2CAP_FCS_NONE		0x00 | 
|  | 125 | #define L2CAP_FCS_CRC16		0x01 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 127 | /* L2CAP fixed channels */ | 
|  | 128 | #define L2CAP_FC_L2CAP		0x02 | 
|  | 129 | #define L2CAP_FC_A2MP		0x08 | 
|  | 130 |  | 
|  | 131 | /* L2CAP Control Field */ | 
| Gustavo F. Padovan | 1c2acff | 2009-08-20 22:25:57 -0300 | [diff] [blame] | 132 | #define L2CAP_CTRL_SAR               0xC000 | 
|  | 133 | #define L2CAP_CTRL_REQSEQ            0x3F00 | 
|  | 134 | #define L2CAP_CTRL_TXSEQ             0x007E | 
| Gustavo F. Padovan | 1c2acff | 2009-08-20 22:25:57 -0300 | [diff] [blame] | 135 | #define L2CAP_CTRL_FINAL             0x0080 | 
|  | 136 | #define L2CAP_CTRL_POLL              0x0010 | 
|  | 137 | #define L2CAP_CTRL_SUPERVISE         0x000C | 
|  | 138 | #define L2CAP_CTRL_FRAME_TYPE        0x0001 /* I- or S-Frame */ | 
|  | 139 |  | 
|  | 140 | #define L2CAP_CTRL_TXSEQ_SHIFT      1 | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 141 | #define L2CAP_CTRL_SUPERVISE_SHIFT  2 | 
|  | 142 | #define L2CAP_CTRL_POLL_SHIFT       4 | 
|  | 143 | #define L2CAP_CTRL_FINAL_SHIFT      7 | 
| Gustavo F. Padovan | 1c2acff | 2009-08-20 22:25:57 -0300 | [diff] [blame] | 144 | #define L2CAP_CTRL_REQSEQ_SHIFT     8 | 
| Gustavo F. Padovan | 8f17154 | 2009-08-20 22:26:03 -0300 | [diff] [blame] | 145 | #define L2CAP_CTRL_SAR_SHIFT       14 | 
| Gustavo F. Padovan | 1c2acff | 2009-08-20 22:25:57 -0300 | [diff] [blame] | 146 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 147 | #define L2CAP_EXT_CTRL_SAR           0x00030000 | 
|  | 148 | #define L2CAP_EXT_CTRL_REQSEQ        0x0000FFFC | 
|  | 149 | #define L2CAP_EXT_CTRL_TXSEQ         0xFFFC0000 | 
|  | 150 | #define L2CAP_EXT_CTRL_FINAL         0x00000002 | 
|  | 151 | #define L2CAP_EXT_CTRL_POLL          0x00040000 | 
|  | 152 | #define L2CAP_EXT_CTRL_SUPERVISE     0x00030000 | 
|  | 153 | #define L2CAP_EXT_CTRL_FRAME_TYPE    0x00000001 /* I- or S-Frame */ | 
|  | 154 |  | 
|  | 155 | #define L2CAP_EXT_CTRL_FINAL_SHIFT      1 | 
|  | 156 | #define L2CAP_EXT_CTRL_REQSEQ_SHIFT     2 | 
|  | 157 | #define L2CAP_EXT_CTRL_SAR_SHIFT       16 | 
|  | 158 | #define L2CAP_EXT_CTRL_SUPERVISE_SHIFT 16 | 
|  | 159 | #define L2CAP_EXT_CTRL_POLL_SHIFT      18 | 
|  | 160 | #define L2CAP_EXT_CTRL_TXSEQ_SHIFT     18 | 
|  | 161 |  | 
|  | 162 | /* L2CAP Supervisory Frame Types */ | 
|  | 163 | #define L2CAP_SFRAME_RR            0x00 | 
|  | 164 | #define L2CAP_SFRAME_REJ           0x01 | 
|  | 165 | #define L2CAP_SFRAME_RNR           0x02 | 
|  | 166 | #define L2CAP_SFRAME_SREJ          0x03 | 
| Gustavo F. Padovan | 1c2acff | 2009-08-20 22:25:57 -0300 | [diff] [blame] | 167 |  | 
|  | 168 | /* L2CAP Segmentation and Reassembly */ | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 169 | #define L2CAP_SAR_UNSEGMENTED      0x00 | 
|  | 170 | #define L2CAP_SAR_START            0x01 | 
|  | 171 | #define L2CAP_SAR_END              0x02 | 
|  | 172 | #define L2CAP_SAR_CONTINUE         0x03 | 
|  | 173 |  | 
|  | 174 | /* L2CAP ERTM / Streaming extra field lengths */ | 
|  | 175 | #define L2CAP_SDULEN_SIZE       2 | 
|  | 176 | #define L2CAP_FCS_SIZE          2 | 
| Gustavo F. Padovan | 1c2acff | 2009-08-20 22:25:57 -0300 | [diff] [blame] | 177 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 178 | /* L2CAP structures */ | 
|  | 179 | struct l2cap_hdr { | 
| Al Viro | 8e036fc | 2007-07-29 00:16:36 -0700 | [diff] [blame] | 180 | __le16     len; | 
|  | 181 | __le16     cid; | 
| Gustavo F. Padovan | 66c853c | 2010-07-19 02:00:13 -0300 | [diff] [blame] | 182 | } __packed; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 | #define L2CAP_HDR_SIZE		4 | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 184 | #define L2CAP_ENHANCED_HDR_SIZE	6 | 
|  | 185 | #define L2CAP_EXTENDED_HDR_SIZE	8 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 |  | 
|  | 187 | struct l2cap_cmd_hdr { | 
|  | 188 | __u8       code; | 
|  | 189 | __u8       ident; | 
| Al Viro | 8e036fc | 2007-07-29 00:16:36 -0700 | [diff] [blame] | 190 | __le16     len; | 
| Gustavo F. Padovan | 66c853c | 2010-07-19 02:00:13 -0300 | [diff] [blame] | 191 | } __packed; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 192 | #define L2CAP_CMD_HDR_SIZE	4 | 
|  | 193 |  | 
|  | 194 | struct l2cap_cmd_rej { | 
| Al Viro | 8e036fc | 2007-07-29 00:16:36 -0700 | [diff] [blame] | 195 | __le16     reason; | 
| Gustavo F. Padovan | 66c853c | 2010-07-19 02:00:13 -0300 | [diff] [blame] | 196 | } __packed; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 |  | 
|  | 198 | struct l2cap_conn_req { | 
| Al Viro | 8e036fc | 2007-07-29 00:16:36 -0700 | [diff] [blame] | 199 | __le16     psm; | 
|  | 200 | __le16     scid; | 
| Gustavo F. Padovan | 66c853c | 2010-07-19 02:00:13 -0300 | [diff] [blame] | 201 | } __packed; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 |  | 
|  | 203 | struct l2cap_conn_rsp { | 
| Al Viro | 8e036fc | 2007-07-29 00:16:36 -0700 | [diff] [blame] | 204 | __le16     dcid; | 
|  | 205 | __le16     scid; | 
|  | 206 | __le16     result; | 
|  | 207 | __le16     status; | 
| Gustavo F. Padovan | 66c853c | 2010-07-19 02:00:13 -0300 | [diff] [blame] | 208 | } __packed; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 |  | 
| Gustavo F. Padovan | 8db4dc4 | 2009-04-20 01:31:05 -0300 | [diff] [blame] | 210 | /* channel indentifier */ | 
|  | 211 | #define L2CAP_CID_SIGNALING	0x0001 | 
|  | 212 | #define L2CAP_CID_CONN_LESS	0x0002 | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 213 | #define L2CAP_CID_A2MP		0x0003 | 
| Ville Tervo | acd7d37 | 2011-02-10 22:38:49 -0300 | [diff] [blame] | 214 | #define L2CAP_CID_LE_DATA	0x0004 | 
|  | 215 | #define L2CAP_CID_LE_SIGNALING	0x0005 | 
|  | 216 | #define L2CAP_CID_SMP		0x0006 | 
| Gustavo F. Padovan | 8db4dc4 | 2009-04-20 01:31:05 -0300 | [diff] [blame] | 217 | #define L2CAP_CID_DYN_START	0x0040 | 
|  | 218 | #define L2CAP_CID_DYN_END	0xffff | 
|  | 219 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 220 | /* connect result */ | 
| Marcel Holtmann | 47ec1dcd | 2009-05-02 18:57:55 -0700 | [diff] [blame] | 221 | #define L2CAP_CR_SUCCESS	0x0000 | 
|  | 222 | #define L2CAP_CR_PEND		0x0001 | 
|  | 223 | #define L2CAP_CR_BAD_PSM	0x0002 | 
|  | 224 | #define L2CAP_CR_SEC_BLOCK	0x0003 | 
|  | 225 | #define L2CAP_CR_NO_MEM		0x0004 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 226 |  | 
|  | 227 | /* connect status */ | 
| Marcel Holtmann | 47ec1dcd | 2009-05-02 18:57:55 -0700 | [diff] [blame] | 228 | #define L2CAP_CS_NO_INFO	0x0000 | 
|  | 229 | #define L2CAP_CS_AUTHEN_PEND	0x0001 | 
|  | 230 | #define L2CAP_CS_AUTHOR_PEND	0x0002 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 |  | 
|  | 232 | struct l2cap_conf_req { | 
| Al Viro | 8e036fc | 2007-07-29 00:16:36 -0700 | [diff] [blame] | 233 | __le16     dcid; | 
|  | 234 | __le16     flags; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | __u8       data[0]; | 
| Gustavo F. Padovan | 66c853c | 2010-07-19 02:00:13 -0300 | [diff] [blame] | 236 | } __packed; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 |  | 
|  | 238 | struct l2cap_conf_rsp { | 
| Al Viro | 8e036fc | 2007-07-29 00:16:36 -0700 | [diff] [blame] | 239 | __le16     scid; | 
|  | 240 | __le16     flags; | 
|  | 241 | __le16     result; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | __u8       data[0]; | 
| Gustavo F. Padovan | 66c853c | 2010-07-19 02:00:13 -0300 | [diff] [blame] | 243 | } __packed; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 244 |  | 
| Marcel Holtmann | 5dee9e7 | 2007-05-24 14:27:19 +0200 | [diff] [blame] | 245 | #define L2CAP_CONF_SUCCESS	0x0000 | 
|  | 246 | #define L2CAP_CONF_UNACCEPT	0x0001 | 
|  | 247 | #define L2CAP_CONF_REJECT	0x0002 | 
|  | 248 | #define L2CAP_CONF_UNKNOWN	0x0003 | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 249 | #define L2CAP_CONF_PENDING	0x0004 | 
|  | 250 | #define L2CAP_CONF_FLOW_SPEC_REJECT	0x0005 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 251 |  | 
|  | 252 | struct l2cap_conf_opt { | 
|  | 253 | __u8       type; | 
|  | 254 | __u8       len; | 
|  | 255 | __u8       val[0]; | 
| Gustavo F. Padovan | 66c853c | 2010-07-19 02:00:13 -0300 | [diff] [blame] | 256 | } __packed; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | #define L2CAP_CONF_OPT_SIZE	2 | 
|  | 258 |  | 
| Gustavo F. Padovan | 589d274 | 2009-04-20 01:31:07 -0300 | [diff] [blame] | 259 | #define L2CAP_CONF_HINT		0x80 | 
| Marcel Holtmann | 47ec1dcd | 2009-05-02 18:57:55 -0700 | [diff] [blame] | 260 | #define L2CAP_CONF_MASK		0x7f | 
| Gustavo F. Padovan | 589d274 | 2009-04-20 01:31:07 -0300 | [diff] [blame] | 261 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 262 | #define L2CAP_CONF_MTU		0x01 | 
|  | 263 | #define L2CAP_CONF_FLUSH_TO	0x02 | 
|  | 264 | #define L2CAP_CONF_QOS		0x03 | 
|  | 265 | #define L2CAP_CONF_RFC		0x04 | 
| Marcel Holtmann | 47ec1dcd | 2009-05-02 18:57:55 -0700 | [diff] [blame] | 266 | #define L2CAP_CONF_FCS		0x05 | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 267 | #define L2CAP_CONF_EXT_FS	0x06 | 
|  | 268 | #define L2CAP_CONF_EXT_WINDOW	0x07 | 
|  | 269 |  | 
|  | 270 | /* QOS Service type */ | 
|  | 271 | #define L2CAP_SERVICE_NO_TRAFFIC		0x00 | 
|  | 272 | #define L2CAP_SERVICE_BEST_EFFORT		0x01 | 
|  | 273 | #define L2CAP_SERVICE_GUARANTEED		0x02 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 |  | 
|  | 275 | #define L2CAP_CONF_MAX_SIZE	22 | 
|  | 276 |  | 
| Marcel Holtmann | 6464f35 | 2007-10-20 13:39:51 +0200 | [diff] [blame] | 277 | struct l2cap_conf_rfc { | 
|  | 278 | __u8       mode; | 
|  | 279 | __u8       txwin_size; | 
|  | 280 | __u8       max_transmit; | 
|  | 281 | __le16     retrans_timeout; | 
|  | 282 | __le16     monitor_timeout; | 
|  | 283 | __le16     max_pdu_size; | 
| Gustavo F. Padovan | 66c853c | 2010-07-19 02:00:13 -0300 | [diff] [blame] | 284 | } __packed; | 
| Marcel Holtmann | 6464f35 | 2007-10-20 13:39:51 +0200 | [diff] [blame] | 285 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 286 | struct l2cap_conf_ext_fs { | 
|  | 287 | __u8       id; | 
|  | 288 | __u8       type; | 
|  | 289 | __le16     max_sdu; | 
|  | 290 | __le32     sdu_arr_time; | 
|  | 291 | __le32     acc_latency; | 
|  | 292 | __le32     flush_to; | 
|  | 293 | } __packed; | 
|  | 294 |  | 
|  | 295 | struct l2cap_conf_prm { | 
|  | 296 | __u8       fcs; | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 297 | __le32     flush_to; | 
|  | 298 | }; | 
|  | 299 |  | 
| Marcel Holtmann | 6464f35 | 2007-10-20 13:39:51 +0200 | [diff] [blame] | 300 | #define L2CAP_MODE_BASIC	0x00 | 
|  | 301 | #define L2CAP_MODE_RETRANS	0x01 | 
|  | 302 | #define L2CAP_MODE_FLOWCTL	0x02 | 
| Marcel Holtmann | 47ec1dcd | 2009-05-02 18:57:55 -0700 | [diff] [blame] | 303 | #define L2CAP_MODE_ERTM		0x03 | 
| Marcel Holtmann | c6b03cf | 2009-05-02 22:31:10 -0700 | [diff] [blame] | 304 | #define L2CAP_MODE_STREAMING	0x04 | 
| Marcel Holtmann | 6464f35 | 2007-10-20 13:39:51 +0200 | [diff] [blame] | 305 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | struct l2cap_disconn_req { | 
| Al Viro | 8e036fc | 2007-07-29 00:16:36 -0700 | [diff] [blame] | 307 | __le16     dcid; | 
|  | 308 | __le16     scid; | 
| Gustavo F. Padovan | 66c853c | 2010-07-19 02:00:13 -0300 | [diff] [blame] | 309 | } __packed; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 |  | 
|  | 311 | struct l2cap_disconn_rsp { | 
| Al Viro | 8e036fc | 2007-07-29 00:16:36 -0700 | [diff] [blame] | 312 | __le16     dcid; | 
|  | 313 | __le16     scid; | 
| Gustavo F. Padovan | 66c853c | 2010-07-19 02:00:13 -0300 | [diff] [blame] | 314 | } __packed; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 |  | 
|  | 316 | struct l2cap_info_req { | 
| Al Viro | 8e036fc | 2007-07-29 00:16:36 -0700 | [diff] [blame] | 317 | __le16      type; | 
| Gustavo F. Padovan | 66c853c | 2010-07-19 02:00:13 -0300 | [diff] [blame] | 318 | } __packed; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 |  | 
|  | 320 | struct l2cap_info_rsp { | 
| Al Viro | 8e036fc | 2007-07-29 00:16:36 -0700 | [diff] [blame] | 321 | __le16      type; | 
|  | 322 | __le16      result; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | __u8        data[0]; | 
| Gustavo F. Padovan | 66c853c | 2010-07-19 02:00:13 -0300 | [diff] [blame] | 324 | } __packed; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 326 | struct l2cap_create_chan_req { | 
|  | 327 | __le16      psm; | 
|  | 328 | __le16      scid; | 
|  | 329 | __u8        amp_id; | 
|  | 330 | } __attribute__ ((packed)); | 
|  | 331 |  | 
|  | 332 | struct l2cap_create_chan_rsp { | 
|  | 333 | __le16      dcid; | 
|  | 334 | __le16      scid; | 
|  | 335 | __le16      result; | 
|  | 336 | __le16      status; | 
|  | 337 | } __attribute__ ((packed)); | 
|  | 338 |  | 
|  | 339 | #define L2CAP_CREATE_CHAN_SUCCESS				(0x0000) | 
|  | 340 | #define L2CAP_CREATE_CHAN_PENDING				(0x0001) | 
|  | 341 | #define L2CAP_CREATE_CHAN_REFUSED_PSM			(0x0002) | 
|  | 342 | #define L2CAP_CREATE_CHAN_REFUSED_SECURITY		(0x0003) | 
|  | 343 | #define L2CAP_CREATE_CHAN_REFUSED_RESOURCES		(0x0004) | 
|  | 344 | #define L2CAP_CREATE_CHAN_REFUSED_CONTROLLER	(0x0005) | 
|  | 345 |  | 
|  | 346 | #define L2CAP_CREATE_CHAN_STATUS_NONE			(0x0000) | 
|  | 347 | #define L2CAP_CREATE_CHAN_STATUS_AUTHENTICATION	(0x0001) | 
|  | 348 | #define L2CAP_CREATE_CHAN_STATUS_AUTHORIZATION	(0x0002) | 
|  | 349 |  | 
|  | 350 | struct l2cap_move_chan_req { | 
|  | 351 | __le16      icid; | 
|  | 352 | __u8        dest_amp_id; | 
|  | 353 | } __attribute__ ((packed)); | 
|  | 354 |  | 
|  | 355 | struct l2cap_move_chan_rsp { | 
|  | 356 | __le16      icid; | 
|  | 357 | __le16      result; | 
|  | 358 | } __attribute__ ((packed)); | 
|  | 359 |  | 
|  | 360 | #define L2CAP_MOVE_CHAN_SUCCESS				(0x0000) | 
|  | 361 | #define L2CAP_MOVE_CHAN_PENDING				(0x0001) | 
|  | 362 | #define L2CAP_MOVE_CHAN_REFUSED_CONTROLLER	(0x0002) | 
|  | 363 | #define L2CAP_MOVE_CHAN_REFUSED_SAME_ID		(0x0003) | 
|  | 364 | #define L2CAP_MOVE_CHAN_REFUSED_CONFIG		(0x0004) | 
|  | 365 | #define L2CAP_MOVE_CHAN_REFUSED_COLLISION	(0x0005) | 
|  | 366 | #define L2CAP_MOVE_CHAN_REFUSED_NOT_ALLOWED	(0x0006) | 
|  | 367 |  | 
|  | 368 | struct l2cap_move_chan_cfm { | 
|  | 369 | __le16      icid; | 
|  | 370 | __le16      result; | 
|  | 371 | } __attribute__ ((packed)); | 
|  | 372 |  | 
|  | 373 | #define L2CAP_MOVE_CHAN_CONFIRMED	(0x0000) | 
|  | 374 | #define L2CAP_MOVE_CHAN_UNCONFIRMED	(0x0001) | 
|  | 375 |  | 
|  | 376 | struct l2cap_move_chan_cfm_rsp { | 
|  | 377 | __le16      icid; | 
|  | 378 | } __attribute__ ((packed)); | 
|  | 379 |  | 
|  | 380 | struct l2cap_amp_signal_work { | 
|  | 381 | struct work_struct work; | 
|  | 382 | struct l2cap_cmd_hdr cmd; | 
|  | 383 | struct l2cap_conn *conn; | 
|  | 384 | struct sk_buff *skb; | 
|  | 385 | u8 *data; | 
|  | 386 | }; | 
|  | 387 |  | 
|  | 388 | struct l2cap_resegment_work { | 
|  | 389 | struct work_struct work; | 
|  | 390 | struct sock *sk; | 
|  | 391 | }; | 
|  | 392 |  | 
|  | 393 | struct l2cap_logical_link_work { | 
|  | 394 | struct work_struct work; | 
|  | 395 | struct hci_chan *chan; | 
|  | 396 | u8 status; | 
|  | 397 | }; | 
|  | 398 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 399 | /* info type */ | 
|  | 400 | #define L2CAP_IT_CL_MTU     0x0001 | 
|  | 401 | #define L2CAP_IT_FEAT_MASK  0x0002 | 
| Marcel Holtmann | e1027a7 | 2009-02-09 09:18:02 +0100 | [diff] [blame] | 402 | #define L2CAP_IT_FIXED_CHAN 0x0003 | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 403 |  | 
|  | 404 | /* info result */ | 
|  | 405 | #define L2CAP_IR_SUCCESS    0x0000 | 
|  | 406 | #define L2CAP_IR_NOTSUPP    0x0001 | 
|  | 407 |  | 
| Claudio Takahasi | de73115 | 2011-02-11 19:28:55 -0200 | [diff] [blame] | 408 | struct l2cap_conn_param_update_req { | 
|  | 409 | __le16      min; | 
|  | 410 | __le16      max; | 
|  | 411 | __le16      latency; | 
|  | 412 | __le16      to_multiplier; | 
|  | 413 | } __packed; | 
|  | 414 |  | 
|  | 415 | struct l2cap_conn_param_update_rsp { | 
|  | 416 | __le16      result; | 
|  | 417 | } __packed; | 
|  | 418 |  | 
|  | 419 | /* Connection Parameters result */ | 
|  | 420 | #define L2CAP_CONN_PARAM_ACCEPTED	0x0000 | 
|  | 421 | #define L2CAP_CONN_PARAM_REJECTED	0x0001 | 
|  | 422 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 423 | /* ----- L2CAP connections ----- */ | 
|  | 424 | struct l2cap_chan_list { | 
|  | 425 | struct sock	*head; | 
|  | 426 | rwlock_t	lock; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 427 | }; | 
|  | 428 |  | 
|  | 429 | struct l2cap_conn { | 
|  | 430 | struct hci_conn	*hcon; | 
|  | 431 |  | 
|  | 432 | bdaddr_t	*dst; | 
|  | 433 | bdaddr_t	*src; | 
|  | 434 |  | 
|  | 435 | unsigned int	mtu; | 
|  | 436 |  | 
| Marcel Holtmann | 4e8402a | 2007-10-20 13:37:56 +0200 | [diff] [blame] | 437 | __u32		feat_mask; | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 438 | __u8		fc_mask; | 
|  | 439 | struct amp_mgr *mgr; | 
| Marcel Holtmann | 4e8402a | 2007-10-20 13:37:56 +0200 | [diff] [blame] | 440 |  | 
|  | 441 | __u8		info_state; | 
|  | 442 | __u8		info_ident; | 
|  | 443 |  | 
|  | 444 | struct timer_list info_timer; | 
|  | 445 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | spinlock_t	lock; | 
|  | 447 |  | 
|  | 448 | struct sk_buff *rx_skb; | 
|  | 449 | __u32		rx_len; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | __u8		tx_ident; | 
|  | 451 |  | 
| Marcel Holtmann | 2950f21 | 2009-02-12 14:02:50 +0100 | [diff] [blame] | 452 | __u8		disc_reason; | 
|  | 453 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 454 | struct l2cap_chan_list chan_list; | 
|  | 455 | }; | 
|  | 456 |  | 
|  | 457 | struct sock_del_list { | 
|  | 458 | struct sock *sk; | 
|  | 459 | struct list_head list; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 460 | }; | 
|  | 461 |  | 
| Marcel Holtmann | 4e8402a | 2007-10-20 13:37:56 +0200 | [diff] [blame] | 462 | #define L2CAP_INFO_CL_MTU_REQ_SENT	0x01 | 
| Marcel Holtmann | 984947d | 2009-02-06 23:35:19 +0100 | [diff] [blame] | 463 | #define L2CAP_INFO_FEAT_MASK_REQ_SENT	0x04 | 
|  | 464 | #define L2CAP_INFO_FEAT_MASK_REQ_DONE	0x08 | 
| Marcel Holtmann | 4e8402a | 2007-10-20 13:37:56 +0200 | [diff] [blame] | 465 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 466 | /* ----- L2CAP channel and socket info ----- */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 467 | #define l2cap_pi(sk) ((struct l2cap_pinfo *) sk) | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 468 | #define TX_QUEUE(sk) (&l2cap_pi(sk)->tx_queue) | 
|  | 469 | #define SREJ_QUEUE(sk) (&l2cap_pi(sk)->srej_queue) | 
|  | 470 |  | 
|  | 471 | struct l2cap_seq_list { | 
|  | 472 | __u16 head; | 
|  | 473 | __u16 tail; | 
|  | 474 | __u16 size; | 
|  | 475 | __u16 mask; | 
|  | 476 | __u16 *list; | 
|  | 477 | }; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 478 |  | 
|  | 479 | struct l2cap_pinfo { | 
|  | 480 | struct bt_sock	bt; | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 481 | __le16		psm; | 
|  | 482 | __u16		dcid; | 
|  | 483 | __u16		scid; | 
|  | 484 |  | 
|  | 485 | __u16		imtu; | 
|  | 486 | __u16		omtu; | 
|  | 487 | __u16		flush_to; | 
|  | 488 | __u8		mode; | 
|  | 489 | __u8		fixed_channel; | 
|  | 490 | __u8		num_conf_req; | 
|  | 491 | __u8		num_conf_rsp; | 
| Brian Gix | 20de7cf | 2012-02-02 14:56:51 -0800 | [diff] [blame] | 492 | __u8		incoming; | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 493 |  | 
|  | 494 | __u8		fcs; | 
|  | 495 | __u8		sec_level; | 
|  | 496 | __u8		role_switch; | 
|  | 497 | __u8		force_reliable; | 
|  | 498 | __u8		flushable; | 
|  | 499 | __u8		force_active; | 
|  | 500 |  | 
|  | 501 | __u8		conf_req[64]; | 
|  | 502 | __u8		conf_len; | 
|  | 503 | __u8		conf_ident; | 
|  | 504 | __u16		conf_state; | 
|  | 505 | __u8		conn_state; | 
|  | 506 | __u8		tx_state; | 
|  | 507 | __u8		rx_state; | 
|  | 508 | __u8		reconf_state; | 
|  | 509 |  | 
|  | 510 | __u8		amp_id; | 
|  | 511 | __u8		amp_move_id; | 
|  | 512 | __u8		amp_move_state; | 
|  | 513 | __u8		amp_move_role; | 
|  | 514 | __u8		amp_move_cmd_ident; | 
|  | 515 | __u16		amp_move_reqseq; | 
|  | 516 | __u16		amp_move_event; | 
|  | 517 |  | 
|  | 518 | __u16		next_tx_seq; | 
|  | 519 | __u16		expected_ack_seq; | 
|  | 520 | __u16		expected_tx_seq; | 
|  | 521 | __u16		buffer_seq; | 
|  | 522 | __u16		srej_save_reqseq; | 
|  | 523 | __u16		last_acked_seq; | 
|  | 524 | __u32		frames_sent; | 
|  | 525 | __u16		unacked_frames; | 
|  | 526 | __u8		retry_count; | 
|  | 527 | __u16		srej_queue_next; | 
|  | 528 | __u16		sdu_len; | 
|  | 529 | struct sk_buff	*sdu; | 
|  | 530 | struct sk_buff	*sdu_last_frag; | 
|  | 531 | atomic_t	ertm_queued; | 
|  | 532 |  | 
|  | 533 | __u8		ident; | 
|  | 534 |  | 
|  | 535 | __u16		tx_win; | 
|  | 536 | __u16		tx_win_max; | 
|  | 537 | __u8		max_tx; | 
|  | 538 | __u8		amp_pref; | 
|  | 539 | __u16		remote_tx_win; | 
|  | 540 | __u8		remote_max_tx; | 
|  | 541 | __u8		extended_control; | 
|  | 542 | __u16		retrans_timeout; | 
|  | 543 | __u16		monitor_timeout; | 
|  | 544 | __u16		remote_mps; | 
|  | 545 | __u16		mps; | 
|  | 546 |  | 
|  | 547 | __le16		sport; | 
|  | 548 |  | 
|  | 549 | struct delayed_work	retrans_work; | 
|  | 550 | struct delayed_work	monitor_work; | 
|  | 551 | struct delayed_work	ack_work; | 
|  | 552 | struct work_struct	tx_work; | 
|  | 553 | struct sk_buff_head	tx_queue; | 
|  | 554 | struct sk_buff_head	srej_queue; | 
|  | 555 | struct l2cap_seq_list srej_list; | 
|  | 556 | struct l2cap_seq_list retrans_list; | 
|  | 557 | struct hci_conn	*ampcon; | 
|  | 558 | struct hci_chan	*ampchan; | 
|  | 559 | struct l2cap_conn	*conn; | 
|  | 560 | struct l2cap_conf_prm local_conf; | 
|  | 561 | struct l2cap_conf_prm remote_conf; | 
|  | 562 | struct l2cap_conf_ext_fs local_fs; | 
|  | 563 | struct l2cap_conf_ext_fs remote_fs; | 
|  | 564 | struct sock		*next_c; | 
|  | 565 | struct sock		*prev_c; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 566 | }; | 
|  | 567 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 568 | #define L2CAP_CONF_REQ_SENT       0x0001 | 
|  | 569 | #define L2CAP_CONF_INPUT_DONE     0x0002 | 
|  | 570 | #define L2CAP_CONF_OUTPUT_DONE    0x0004 | 
|  | 571 | #define L2CAP_CONF_MTU_DONE       0x0008 | 
|  | 572 | #define L2CAP_CONF_MODE_DONE      0x0010 | 
|  | 573 | #define L2CAP_CONF_CONNECT_PEND   0x0020 | 
|  | 574 | #define L2CAP_CONF_NO_FCS_RECV    0x0040 | 
|  | 575 | #define L2CAP_CONF_STATE2_DEVICE  0x0080 | 
|  | 576 | #define L2CAP_CONF_EXT_WIN_RECV   0x0100 | 
|  | 577 | #define L2CAP_CONF_LOCKSTEP       0x0200 | 
|  | 578 | #define L2CAP_CONF_LOCKSTEP_PEND  0x0400 | 
|  | 579 | #define L2CAP_CONF_PEND_SENT      0x0800 | 
|  | 580 | #define L2CAP_CONF_EFS_RECV       0x1000 | 
| Marcel Holtmann | 861d688 | 2007-10-20 13:37:06 +0200 | [diff] [blame] | 581 |  | 
| Gustavo F. Padovan | f2fcfcd | 2009-07-04 15:06:24 -0300 | [diff] [blame] | 582 | #define L2CAP_CONF_MAX_CONF_REQ 2 | 
|  | 583 | #define L2CAP_CONF_MAX_CONF_RSP 2 | 
|  | 584 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 585 | #define L2CAP_RECONF_NONE          0x00 | 
|  | 586 | #define L2CAP_RECONF_INT           0x01 | 
|  | 587 | #define L2CAP_RECONF_ACC           0x02 | 
| Gustavo F. Padovan | e90bac0 | 2009-08-20 22:26:00 -0300 | [diff] [blame] | 588 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 589 | #define L2CAP_CONN_SREJ_ACT        0x01 | 
|  | 590 | #define L2CAP_CONN_REJ_ACT         0x02 | 
|  | 591 | #define L2CAP_CONN_REMOTE_BUSY     0x04 | 
|  | 592 | #define L2CAP_CONN_LOCAL_BUSY      0x08 | 
|  | 593 | #define L2CAP_CONN_SEND_FBIT       0x10 | 
|  | 594 | #define L2CAP_CONN_SENT_RNR        0x20 | 
| Gustavo F. Padovan | c74e560 | 2009-08-20 22:25:58 -0300 | [diff] [blame] | 595 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 596 | #define L2CAP_SEQ_LIST_CLEAR       0xFFFF | 
|  | 597 | #define L2CAP_SEQ_LIST_TAIL        0x8000 | 
| Gustavo F. Padovan | 1c2acff | 2009-08-20 22:25:57 -0300 | [diff] [blame] | 598 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 599 | #define L2CAP_ERTM_TX_STATE_XMIT          0x01 | 
|  | 600 | #define L2CAP_ERTM_TX_STATE_WAIT_F        0x02 | 
| Gustavo F. Padovan | 1c2acff | 2009-08-20 22:25:57 -0300 | [diff] [blame] | 601 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 602 | #define L2CAP_ERTM_RX_STATE_RECV                    0x01 | 
|  | 603 | #define L2CAP_ERTM_RX_STATE_SREJ_SENT               0x02 | 
|  | 604 | #define L2CAP_ERTM_RX_STATE_AMP_MOVE                0x03 | 
|  | 605 | #define L2CAP_ERTM_RX_STATE_WAIT_P_FLAG             0x04 | 
|  | 606 | #define L2CAP_ERTM_RX_STATE_WAIT_P_FLAG_RECONFIGURE 0x05 | 
|  | 607 | #define L2CAP_ERTM_RX_STATE_WAIT_F_FLAG             0x06 | 
| Gustavo F. Padovan | 1c2acff | 2009-08-20 22:25:57 -0300 | [diff] [blame] | 608 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 609 | #define L2CAP_ERTM_TXSEQ_EXPECTED        0x00 | 
|  | 610 | #define L2CAP_ERTM_TXSEQ_EXPECTED_SREJ   0x01 | 
|  | 611 | #define L2CAP_ERTM_TXSEQ_UNEXPECTED      0x02 | 
|  | 612 | #define L2CAP_ERTM_TXSEQ_UNEXPECTED_SREJ 0x03 | 
|  | 613 | #define L2CAP_ERTM_TXSEQ_DUPLICATE       0x04 | 
|  | 614 | #define L2CAP_ERTM_TXSEQ_DUPLICATE_SREJ  0x05 | 
|  | 615 | #define L2CAP_ERTM_TXSEQ_INVALID         0x06 | 
|  | 616 | #define L2CAP_ERTM_TXSEQ_INVALID_IGNORE  0x07 | 
| Gustavo F. Padovan | 1c2acff | 2009-08-20 22:25:57 -0300 | [diff] [blame] | 617 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 618 | #define L2CAP_ERTM_EVENT_DATA_REQUEST          0x01 | 
|  | 619 | #define L2CAP_ERTM_EVENT_LOCAL_BUSY_DETECTED   0x02 | 
|  | 620 | #define L2CAP_ERTM_EVENT_LOCAL_BUSY_CLEAR      0x03 | 
|  | 621 | #define L2CAP_ERTM_EVENT_RECV_REQSEQ_AND_FBIT  0x04 | 
|  | 622 | #define L2CAP_ERTM_EVENT_RECV_FBIT             0x05 | 
|  | 623 | #define L2CAP_ERTM_EVENT_RETRANS_TIMER_EXPIRES 0x06 | 
|  | 624 | #define L2CAP_ERTM_EVENT_MONITOR_TIMER_EXPIRES 0x07 | 
|  | 625 | #define L2CAP_ERTM_EVENT_EXPLICIT_POLL         0x08 | 
|  | 626 | #define L2CAP_ERTM_EVENT_RECV_IFRAME           0x09 | 
|  | 627 | #define L2CAP_ERTM_EVENT_RECV_RR               0x0a | 
|  | 628 | #define L2CAP_ERTM_EVENT_RECV_REJ              0x0b | 
|  | 629 | #define L2CAP_ERTM_EVENT_RECV_RNR              0x0c | 
|  | 630 | #define L2CAP_ERTM_EVENT_RECV_SREJ             0x0d | 
|  | 631 | #define L2CAP_ERTM_EVENT_RECV_FRAME            0x0e | 
|  | 632 |  | 
|  | 633 | #define L2CAP_AMP_MOVE_NONE      0 | 
|  | 634 | #define L2CAP_AMP_MOVE_INITIATOR 1 | 
|  | 635 | #define L2CAP_AMP_MOVE_RESPONDER 2 | 
|  | 636 |  | 
|  | 637 | #define L2CAP_AMP_STATE_STABLE			0 | 
|  | 638 | #define L2CAP_AMP_STATE_WAIT_CREATE		1 | 
|  | 639 | #define L2CAP_AMP_STATE_WAIT_CREATE_RSP		2 | 
|  | 640 | #define L2CAP_AMP_STATE_WAIT_MOVE		3 | 
|  | 641 | #define L2CAP_AMP_STATE_WAIT_MOVE_RSP		4 | 
|  | 642 | #define L2CAP_AMP_STATE_WAIT_MOVE_RSP_SUCCESS	5 | 
|  | 643 | #define L2CAP_AMP_STATE_WAIT_MOVE_CONFIRM	6 | 
|  | 644 | #define L2CAP_AMP_STATE_WAIT_MOVE_CONFIRM_RSP	7 | 
|  | 645 | #define L2CAP_AMP_STATE_WAIT_LOGICAL_COMPLETE	8 | 
|  | 646 | #define L2CAP_AMP_STATE_WAIT_LOGICAL_CONFIRM	9 | 
|  | 647 | #define L2CAP_AMP_STATE_WAIT_LOCAL_BUSY		10 | 
|  | 648 | #define L2CAP_AMP_STATE_WAIT_PREPARE		11 | 
|  | 649 | #define L2CAP_AMP_STATE_RESEGMENT		12 | 
|  | 650 |  | 
| Brian Gix | 7eaa64d | 2011-10-19 13:17:42 -0700 | [diff] [blame] | 651 | #define L2CAP_ATT_ERROR				0x01 | 
| Brian Gix | 8217b26 | 2012-01-31 07:56:04 -0800 | [diff] [blame] | 652 | #define L2CAP_ATT_MTU_REQ			0x02 | 
|  | 653 | #define L2CAP_ATT_MTU_RSP			0x03 | 
| Brian Gix | 7eaa64d | 2011-10-19 13:17:42 -0700 | [diff] [blame] | 654 | #define L2CAP_ATT_RESPONSE_BIT			0x01 | 
|  | 655 | #define L2CAP_ATT_INDICATE			0x1D | 
|  | 656 | #define L2CAP_ATT_NOT_SUPPORTED			0x06 | 
|  | 657 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 658 | #define __delta_seq(x, y, pi) ((x) >= (y) ? (x) - (y) : \ | 
|  | 659 | (pi)->tx_win_max + 1 - (y) + (x)) | 
|  | 660 | #define __next_seq(x, pi) ((x + 1) & ((pi)->tx_win_max)) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 661 |  | 
| Gustavo F. Padovan | bb58f74 | 2011-02-03 20:50:35 -0200 | [diff] [blame] | 662 | extern int disable_ertm; | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 663 | extern const struct proto_ops l2cap_sock_ops; | 
|  | 664 | extern struct bt_sock_list l2cap_sk_list; | 
| Gustavo F. Padovan | bb58f74 | 2011-02-03 20:50:35 -0200 | [diff] [blame] | 665 |  | 
|  | 666 | int l2cap_init_sockets(void); | 
|  | 667 | void l2cap_cleanup_sockets(void); | 
|  | 668 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 669 | u8 l2cap_get_ident(struct l2cap_conn *conn); | 
|  | 670 | void l2cap_send_cmd(struct l2cap_conn *conn, u8 ident, u8 code, u16 len, void *data); | 
|  | 671 | int l2cap_build_conf_req(struct sock *sk, void *data); | 
| Gustavo F. Padovan | dcba0db | 2011-02-04 03:08:36 -0200 | [diff] [blame] | 672 | int __l2cap_wait_ack(struct sock *sk); | 
| Gustavo F. Padovan | 6898325 | 2011-02-04 03:02:31 -0200 | [diff] [blame] | 673 |  | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 674 | struct sk_buff *l2cap_create_connless_pdu(struct sock *sk, struct msghdr *msg, size_t len); | 
|  | 675 | struct sk_buff *l2cap_create_basic_pdu(struct sock *sk, struct msghdr *msg, size_t len); | 
|  | 676 | struct sk_buff *l2cap_create_iframe_pdu(struct sock *sk, struct msghdr *msg, | 
|  | 677 | size_t len, u16 sdulen, int reseg); | 
|  | 678 | int l2cap_segment_sdu(struct sock *sk, struct sk_buff_head* seg_queue, | 
|  | 679 | struct msghdr *msg, size_t len, int reseg); | 
|  | 680 | int l2cap_resegment_queue(struct sock *sk, struct sk_buff_head *queue); | 
|  | 681 | void l2cap_do_send(struct sock *sk, struct sk_buff *skb); | 
|  | 682 | void l2cap_streaming_send(struct sock *sk); | 
|  | 683 | int l2cap_ertm_send(struct sock *sk); | 
|  | 684 | int l2cap_strm_tx(struct sock *sk, struct sk_buff_head *skbs); | 
|  | 685 | int l2cap_ertm_tx(struct sock *sk, struct bt_l2cap_control *control, | 
|  | 686 | struct sk_buff_head *skbs, u8 event); | 
| Gustavo F. Padovan | 9e4425f | 2011-04-18 18:38:43 -0300 | [diff] [blame] | 687 |  | 
| Brian Gix | a94b612 | 2012-02-23 16:07:10 -0800 | [diff] [blame] | 688 | int l2cap_sock_le_params_valid(struct bt_le_params *le_params); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 689 | void l2cap_sock_set_timer(struct sock *sk, long timeout); | 
|  | 690 | void l2cap_sock_clear_timer(struct sock *sk); | 
|  | 691 | void __l2cap_sock_close(struct sock *sk, int reason); | 
|  | 692 | void l2cap_sock_kill(struct sock *sk); | 
|  | 693 | void l2cap_sock_init(struct sock *sk, struct sock *parent); | 
|  | 694 | struct sock *l2cap_sock_alloc(struct net *net, struct socket *sock, | 
|  | 695 | int proto, gfp_t prio); | 
| Brian Gix | 20de7cf | 2012-02-02 14:56:51 -0800 | [diff] [blame] | 696 | struct sock *l2cap_find_sock_by_fixed_cid_and_dir(__le16 cid, bdaddr_t *src, | 
|  | 697 | bdaddr_t *dst, int server); | 
| Bryan Huntsman | 3f2bc4d | 2011-08-16 17:27:22 -0700 | [diff] [blame] | 698 | void l2cap_send_disconn_req(struct l2cap_conn *conn, struct sock *sk, int err); | 
|  | 699 | void l2cap_chan_del(struct sock *sk, int err); | 
|  | 700 | int l2cap_do_connect(struct sock *sk); | 
|  | 701 | int l2cap_data_channel(struct sock *sk, struct sk_buff *skb); | 
|  | 702 | void l2cap_amp_move_init(struct sock *sk); | 
|  | 703 | void l2cap_ertm_destruct(struct sock *sk); | 
|  | 704 | void l2cap_ertm_shutdown(struct sock *sk); | 
|  | 705 | void l2cap_ertm_recv_done(struct sock *sk); | 
|  | 706 |  | 
|  | 707 | void l2cap_fixed_channel_config(struct sock *sk, struct l2cap_options *opt); | 
|  | 708 |  | 
|  | 709 | void l2cap_recv_deferred_frame(struct sock *sk, struct sk_buff *skb); | 
|  | 710 |  | 
|  | 711 | void l2cap_amp_physical_complete(int result, u8 remote_id, u8 local_id, | 
|  | 712 | struct sock *sk); | 
|  | 713 |  | 
|  | 714 | void l2cap_amp_logical_complete(int result, struct hci_conn *ampcon, | 
|  | 715 | struct hci_chan *ampchan, struct sock *sk); | 
|  | 716 |  | 
|  | 717 | void l2cap_amp_logical_destroyed(struct hci_conn *ampcon); | 
| Gustavo F. Padovan | bb58f74 | 2011-02-03 20:50:35 -0200 | [diff] [blame] | 718 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 719 | #endif /* __L2CAP_H */ |