summaryrefslogtreecommitdiff
path: root/net
AgeCommit message (Collapse)Author
2016-10-26net: buf: Make net_buf_frag_add take ownership of the bufferLuiz Augusto von Dentz
This simplify buffer handling so that no extra references are needed. Change-Id: Id99a0a75b39ca8db2216668f76c5a672713075ae Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-10-26net: buf: Add SYS_LOG supportLuiz Augusto von Dentz
This adds support for using SYS_LOG macros instead of prinf when logging. Change-Id: I4611bfe3b541b6e323dd50e587994a57dcd477f7 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-10-26net: buf: Add separate Kconfig for net_buf_simple debugLuiz Augusto von Dentz
This makes CONFIG_NET_BUF_DEBUG a lot less verbose if the purpose is not to debug memory operations but just references and fragmentation. Change-Id: Ie034c2c66715470d8d6d7d29d055678c65a519e5 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-10-21Bluetooth: Fix build with unified kernelSzymon Janc
zephyr.h includes required headers and has guards for unified kernel config. Change-Id: I40b5d95218cee5594c06e5ba3de496a0aca16f2c Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-10-21Bluetooth: ATT: Fix handling of insufficient authenticationLuiz Augusto von Dentz
Insufficient authentication can be used with almost any security level to indicate the security need to be escalated not only to high but to medium and fips depending on the current security level. Jira: ZEP-1074 Change-Id: Iea261f2814caf5b290997beedcbb0aa7f5a9e890 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-10-21Bluetooth: L2CAP: Factor out repeatable cleanup callsArkadiusz Lichwa
Adds helper cleanup procedure containing common code resetting channel context internals. Change-Id: I679fb7ca68158327493cd362ae8c5c6c44973776 Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-10-21Bluetooth: L2CAP: Cleanup l2cap_br_conn_req()Arkadiusz Lichwa
Removes the code responsible for reset channel object internals. These internals will be reset automatically on chan 'destroy' ops as a result of disconnection that taking place in this case. Change-Id: I7bb3aaf225797a7c4b17ed2b578f6825114307c9 Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-10-21Bluetooth: L2CAP: Refactor BR/EDR connection request handlerArkadiusz Lichwa
Reduces code in main handler servicing connection request by use of helper routine l2cap_br_conn_req_reply() to send connection response. It involves moving the helper up in code to skip forward declaration and also makes slight refactor of it to adjust 'pending result' condition in response. Change-Id: I0a51d908b14ed3b5d6c497d57a99422fc9c44573 Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-10-21Bluetooth: L2CAP: Fix 'result' values in BR/EDR connection responseArkadiusz Lichwa
Applies proper for BR/EDR CoC values dealing with 'result' field in connection response signaling handlers. Change-Id: I8e2237123a904f5764a0873d8bdf369b3b9edd7a Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-10-21Bluetooth: L2CAP: Add valid BR/EDR connection response errorsArkadiusz Lichwa
Since for LE CoC connection response 'result' errors can have different values and semantics this adds proper, according to Core Spec 4.2 [Vol 3, Part A, 4.3], values relevant for BR/EDR L2CAP CoC 'result' field in connection response protocol package. Change-Id: Ie43c87466aaaf47e16520795f3cb7335d86aa57d Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-10-21Bluetooth: HCI UART app to run Zephyr as a BLE ControllerCarles Cufi
Add a new sample application in sample/bluetooth/hci-uart that acts as a bridge between a UART and the BLE Controller. It receives commands and ACL data in H4 format over the UART and passes them on to the BLE Controller to be processed. It also conversely forwards all events and incoming ACL data generated by the BLE Controller to the UART. The application uses the hci_raw interface to pipe the data to and from the BLE Controller and UART. Change-Id: Iff7696166a82fe363b2ad4e1abea40103899f927 Signed-off-by: Carles Cufi <carles.cufi@nordicsemi.no>
2016-10-21Bluetooth: L2CAP: Handle security procedure non successful pathArkadiusz Lichwa
When getting non-zero status from security procedure on BR/EDR connection, make sure to react properly based on connection path (in or out) by sending in first case security block response if needed and in second case release hanging channel if exists in CONNECT context. > ACL Data RX: Handle 11 flags 0x02 dlen 12 [hci1] 130.819662 L2CAP: Connection Request (0x02) ident 5 len 4 PSM: 5 (0x0005) Source CID: 65 < HCI Command: Authentication Requested (0x01|0x0011) plen 2 [hci1] 130.825611 Handle: 11 > HCI Event: Command Status (0x0f) plen 4 [hci1] 130.826519 Authentication Requested (0x01|0x0011) ncmd 1 Status: Success (0x00) > HCI Event: Link Key Request (0x17) plen 6 [hci1] 130.827516 Address: 00:1A:7D:DA:71:0B (cyber-blue(HK)Ltd) < HCI Command: Host Number of Complet.. (0x03|0x0035) plen 5 [hci1] 130.828348 Num handles: 1 Handle: 11 Count: 1 < ACL Data TX: Handle 11 flags 0x00 dlen 16 [hci1] 130.829717 L2CAP: Connection Response (0x03) ident 5 len 8 Destination CID: 65 Source CID: 65 Result: Connection pending (0x0001) Status: Authentication pending (0x0001) < HCI Command: Link Key Request Reply (0x01|0x000b) plen 22 [hci1] 130.830594 Address: 00:1A:7D:DA:71:0B (cyber-blue(HK)Ltd) Link key: fa087afc920ffe07199c803005fc5b5f > HCI Event: Command Complete (0x0e) plen 10 [hci1] 130.833513 Link Key Request Reply (0x01|0x000b) ncmd 1 Status: Success (0x00) Address: 00:1A:7D:DA:71:0B (cyber-blue(HK)Ltd) > HCI Event: PIN Code Request (0x16) plen 6 [hci1] 130.852526 Address: 00:1A:7D:DA:71:0B (cyber-blue(HK)Ltd) > HCI Event: Number of Completed Packets (0x13) plen 5 [hci1] 131.071542 Num handles: 1 Handle: 11 Count: 1 < HCI Command: PIN Code Request Negat.. (0x01|0x000e) plen 6 [hci1] 154.501040 Address: 00:1A:7D:DA:71:0B (cyber-blue(HK)Ltd) > HCI Event: Command Complete (0x0e) plen 10 [hci1] 154.502365 PIN Code Request Negative Reply (0x01|0x000e) ncmd 1 Status: Success (0x00) Address: 00:1A:7D:DA:71:0B (cyber-blue(HK)Ltd) > HCI Event: Auth Complete (0x06) plen 3 [hci1] 154.503360 Status: PIN or Key Missing (0x06) Handle: 11 < ACL Data TX: Handle 11 flags 0x00 dlen 16 [hci1] 154.506130 L2CAP: Connection Response (0x03) ident 5 len 8 Destination CID: 65 Source CID: 65 Result: Connection refused - security block (0x0003) Status: No further information available (0x0000) > HCI Event: Number of Completed Packets (0x13) plen 5 [hci1] 154.699369 Num handles: 1 Handle: 11 Count: 1 Change-Id: I9e9a9b456c00452efb4f5303aa1b1fd1fa81b758 Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-10-21Bluetooth: L2CAP: Refactor handling connection responseArkadiusz Lichwa
Adds internal helper routine sending response to connection request when BR/EDR CoC channel operates in acceptor role. The routine additionally can drive the response 'result' value for failure reasons. Use it then to adjust 'l2cap_br_conn_pend' function to accept remote's connection request. Change-Id: I906e07e30939c57b206e9806426897f6e4f2b3dd Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-10-21Bluetooth: RFCOMM: Handle security for incoming connectionsJaganath Kanakkassery
Added required_sec_level in dlc struct so that user can set it. If current security level is greater than or equal to the required security level then connection will be accepted right away, otherwise security elevation will be reqiested and connection will be accepted once it is done. > ACL Data RX: Handle 256 flags 0x02 dlen 8 Channel: 64 len 4 [PSM 3 mode 0] {chan 0} RFCOMM: Set Async Balance Mode (SABM) (0x2f) Address: 0x0b cr 1 dlci 0x02 Control: 0x3f poll/final 1 Length: 0 FCS: 0x59 < HCI Command: Authentication Requested (0x01|0x0011) plen 2 Handle: 256 > HCI Event: Command Status (0x0f) plen 4 Authentication Requested (0x01|0x0011) ncmd 1 Status: Success (0x00) > HCI Event: Link Key Request (0x17) plen 6 Address: A0:A8:CD:40:99:98 (OUI A0-A8-CD) < HCI Command: Link Key Request Negative Reply (0x01|0x000c) plen 6 Address: A0:A8:CD:40:99:98 (OUI A0-A8-CD) > HCI Event: Command Complete (0x0e) plen 10 Link Key Request Negative Reply (0x01|0x000c) ncmd 1 Status: Success (0x00) Address: A0:A8:CD:40:99:98 (OUI A0-A8-CD) > HCI Event: IO Capability Request (0x31) plen 6 Address: A0:A8:CD:40:99:98 (OUI A0-A8-CD) < HCI Command: IO Capability Request Reply (0x01|0x002b) plen 9 Address: A0:A8:CD:40:99:98 (OUI A0-A8-CD) IO capability: DisplayYesNo (0x01) OOB data: Authentication data not present (0x00) Authentication: Dedicated Bonding - MITM required (0x03) > HCI Event: Command Complete (0x0e) plen 10 IO Capability Request Reply (0x01|0x002b) ncmd 1 Status: Success (0x00) Address: A0:A8:CD:40:99:98 (OUI A0-A8-CD) > HCI Event: IO Capability Response (0x32) plen 9 Address: A0:A8:CD:40:99:98 (OUI A0-A8-CD) IO capability: DisplayYesNo (0x01) OOB data: Authentication data not present (0x00) Authentication: Dedicated Bonding - MITM required (0x03) > HCI Event: User Confirmation Request (0x33) plen 10 Address: A0:A8:CD:40:99:98 (OUI A0-A8-CD) Passkey: 104251 < HCI Command: User Confirmation Request Reply (0x01|0x002c) plen 6 Address: A0:A8:CD:40:99:98 (OUI A0-A8-CD) > HCI Event: Command Complete (0x0e) plen 10 User Confirmation Request Reply (0x01|0x002c) ncmd 1 Status: Success (0x00) Address: A0:A8:CD:40:99:98 (OUI A0-A8-CD) > HCI Event: Simple Pairing Complete (0x36) plen 7 Status: Success (0x00) Address: A0:A8:CD:40:99:98 (OUI A0-A8-CD) > HCI Event: Link Key Notification (0x18) plen 23 Address: A0:A8:CD:40:99:98 (OUI A0-A8-CD) Link key: 7c5e5bbc67268293202913902fd0d5fe Key type: Authenticated Combination key from P-192 (0x05) > HCI Event: Auth Complete (0x06) plen 3 Status: Success (0x00) Handle: 256 > HCI Event: Encryption Key Refresh Complete (0x30) plen 3 Status: Success (0x00) Handle: 256 < HCI Command: Set Connection Encryption (0x01|0x0013) plen 3 Handle: 256 Encryption: Enabled (0x01) > HCI Event: Command Status (0x0f) plen 4 Set Connection Encryption (0x01|0x0013) ncmd 1 Status: Success (0x00) > HCI Event: Encryption Change (0x08) plen 4 Status: Success (0x00) Handle: 256 Encryption: Enabled with E0 (0x01) < ACL Data TX: Handle 256 flags 0x00 dlen 8 Channel: 64 len 4 [PSM 3 mode 0] {chan 0} RFCOMM: Unnumbered Ack (UA) (0x63) Address: 0x0b cr 1 dlci 0x02 Control: 0x73 poll/final 1 Length: 0 FCS: 0x92 Change-Id: Ia01f2984dda77d58b724f869eb526734f1846ad6 Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-10-21Bluetooth: L2CAP: Use MPS for outgoing segmentsLuiz Augusto von Dentz
BT_L2CAP_MAX_LE_MPS tracks exactly how big a single buffer can be so use that as size for outgoing segment pool instead of the minimun MTU. Change-Id: I48cfba0e2c4c88f390f2f8a1ce63ff6adfce7c7a Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-10-21Bluetooth: L2CAP: Drop extra reference to fragmentsLuiz Augusto von Dentz
net_buf_frag_add already adds a reference to the fragment. Change-Id: I28c6bde862c09d1dea0182bc0d08bfc1f4565d06 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-10-21Bluetooth: L2CAP: Fix reusing buffer with fragmentsLuiz Augusto von Dentz
Buffer with fragments shall not be reused as they may free unprocessed fragments on unref. Change-Id: I09bdc84ccaef03a99d53d87b2b70c8c3a32b5e90 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-10-21Bluetooth: L2CAP: Simplify allocation of buffer fragmentsLuiz Augusto von Dentz
Instead of requesting the full length just request one buffer at time. Change-Id: I8f97ecf0a959316e1fadfdedf9e500e61ed26c27 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-10-21Bluetooth: SDP: Server: Support service record registrationKaustav Dey Biswas
This change adds support for registering new service records. Change-Id: I0ff2264d08787fe5f8edf6300259961c3ca52fbb Signed-off-by: Kaustav Dey Biswas <kaustav.d.biswas@intel.com>
2016-10-21Bluetooth: L2CAP: Protect fixed channelsArkadiusz Lichwa
During connection fixed channels need to be operational all the time on the link. Remote malicious user can tailor control packet with proper CID using disconnection request or response that can cause fixed channel removal from connection context. > HCI Event: Number of Completed Packets (0x13) plen 5 [hci0] 16:34:56.157666 Num handles: 1 Handle: 77 Count: 1 > ACL Data RX: Handle 77 flags 0x02 dlen 12 [hci0] 16:34:56.161162 L2CAP: Disconnection Response (0x07) ident 236 len 4 Destination CID: 1 Source CID: 1605 > ACL Data RX: Handle 77 flags 0x02 dlen 12 [hci0] 16:34:56.164916 L2CAP: Disconnection Request (0x06) ident 237 len 4 Destination CID: 0 Source CID: 0 < HCI Command: Host Number of Completed Packets (0x03|0x0035) plen 5 [hci0] 16:34:56.166326 Num handles: 1 Handle: 77 Count: 1 < HCI Command: Host Number of Completed Packets (0x03|0x0035) plen 5 [hci0] 16:34:56.167380 Num handles: 1 Handle: 77 Count: 1 > ACL Data RX: Handle 77 flags 0x02 dlen 10 [hci0] 16:34:56.168660 L2CAP: Information Request (0x0a) ident 238 len 2 Type: Extended features supported (0x0002) < HCI Command: Host Number of Completed Packets (0x03|0x0035) plen 5 [hci0] 16:34:56.170475 Num handles: 1 Handle: 77 Count: 1 > ACL Data RX: Handle 77 flags 0x02 dlen 10 [hci0] 16:34:58.671203 L2CAP: Information Request (0x0a) ident 239 len 2 Type: Extended features supported (0x0002) < HCI Command: Host Number of Completed Packets (0x03|0x0035) plen 5 [hci0] 16:34:58.674439 Num handles: 1 Handle: 77 Count: 1 Change-Id: I3df3ec987c7abab8657349a2d5fe67831f528214 Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-10-21Bluetooth: L2CAP: Refactor CoC CID rangesArkadiusz Lichwa
Adds helper defines to mark valid CID values and ranges for CoC on BR/EDR and LE. Change-Id: Ib2db3a6a8f4b6565920f47b520e27e3b8cc6c85c Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-10-21Bluetooth: GATT: Fix code styleLuiz Augusto von Dentz
Change-Id: Ia96c0498c1833f19d9252e2b782f87a26137e973 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-10-21Bluetooth: GATT: Pass CCC attribute to changed callbackLuiz Augusto von Dentz
This way the application can reuse the same callback for multiple CCC since it can track what CCC is affect by checking the attribute pointer. Change-Id: I608da643aea07de26b65d67e6db3268d717d0f53 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-10-16Bluetooth: SMP: Take advantage of new byte swap helpersJohan Hedberg
There's no need to keep the custom swap_buf & swap_in_place helpers anymore since system-wide helpers are now available. Change-Id: I424e3592ab955410455c4226e5bf03df6f522c52 Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-10-16Bluetooth: HCI: Set the Page timeoutItankar, Piyush T
The Bluetooth initialization now also sets the page timeout value. Change-Id: I367591c587bdfe135befc07b637af4cf532f55e2 Signed-off-by: Itankar, Piyush T <piyush.t.itankar@intel.com>
2016-10-16Bluetooth: Kconfig: Option to set page timeout valueItankar, Piyush T
Added an option to set the page timeout value. Default the timeout is set to 5.12 sec. Change-Id: I196b59f18b9cbf0aaa226ffd85e0bb1699667af2 Signed-off-by: Itankar, Piyush T <piyush.t.itankar@intel.com>
2016-10-16Bluetooth: SMP: Check for connection role before BR/EDR pairingSzymon Janc
Master is starting SMP over BR/EDR and it may not be a device that started BR/EDR pairing. Although specification isn't very clear in this it seems to be the case when checking TS for cross-transport tests. Change-Id: I7b0a42ab0123fa444b06a4986f6b1410bf1f2789 Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-10-16Bluetooth: L2CAP: Allow receiving fragmented buffersLuiz Augusto von Dentz
This enabled L2CAP CoC to store data in fragmented buffers, due to increase in memory init_17 test has to be disabled ARC for Arduino 101 otherwise sanity test would not pass. Change-Id: If04289a03e591473de4e722031c1687a14420fc2 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-10-16Bluetooth: Track role change for BR/EDR connectionsSzymon Janc
This make sure conn object is using correct role. < HCI Command: Create Connection (0x01|0x0005) plen 13 Address: 20:68:9D:60:A1:E4 (Liteon Technology Corporation) Packet type: 0xcc18 DM1 may be used DH1 may be used DM3 may be used DH3 may be used DM5 may be used DH5 may be used Page scan repetition mode: R2 (0x02) Page scan mode: Mandatory (0x00) Clock offset: 0x0000 Role switch: Allow slave (0x01) > HCI Event: Command Status (0x0f) plen 4 Create Connection (0x01|0x0005) ncmd 1 Status: Success (0x00) > HCI Event: Role Change (0x12) plen 8 Status: Success (0x00) Address: 20:68:9D:60:A1:E4 (Liteon Technology Corporation) Role: Slave (0x01) > HCI Event: Connect Complete (0x03) plen 11 Status: Success (0x00) Handle: 11 Address: 20:68:9D:60:A1:E4 (Liteon Technology Corporation) Link type: ACL (0x01) Change-Id: I65cd8ba36f0e5317d79d7e4d884ee530e1f8b2a3 Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-10-16Bluetooth: SMP: Fix build without signing supportSzymon Janc
Fix following error if BR/EDR support was build without signing support enabled. CC net/bluetooth/smp.o zephyr/net/bluetooth/smp.c: In function 'smp_br_signing_info': zephyr/net/bluetooth/smp.c:1166:13: error: 'struct bt_keys' has no member named 'remote_csrk' memcpy(keys->remote_csrk.val, req->csrk, sizeof(keys->remote_csrk.val)); ^ zephyr/net/bluetooth/smp.c:1166:54: error: 'struct bt_keys' has no member named 'remote_csrk' memcpy(keys->remote_csrk.val, req->csrk, sizeof(keys->remote_csrk.val)); ^ Change-Id: I05393c1b2e12c9a66d8ad3e7906d3aa94a57b193 Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-10-16Bluetooth: SMP: Fix build without central role supportSzymon Janc
If BR/EDR is enabled Pairing Request can also be sent without support for LE central role. zephyr/net/bluetooth/smp.c:1326:12: warning: 'smp_br_send_pairing_req' defined but not used [-Wunused-function] static int smp_br_send_pairing_req(struct bt_conn *conn) ^ net/built-in.o: In function `hci_encrypt_change': zephyr/net/bluetooth/hci_core.c:2006: undefined reference to `bt_smp_send_pairing_req' net/built-in.o: In function `bt_smp_br_connected': zephyr/net/bluetooth/smp.c:738: undefined reference to `bt_smp_send_pairing_req' Change-Id: I1b68d2412b49f02f42aa146a327252ce107523ca Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-10-16Bluetooth: L2CAP: Allow sending fragmented buffersLuiz Augusto von Dentz
This enabled L2CAP CoC to send buffers that contains fragments. Change-Id: I898b8375f634d3f0652ec1e7f5a206aa47dd232d Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-10-16Bluetooth: L2CAP: Fix sending buffer with not enough spaceLuiz Augusto von Dentz
l2cap_chan_create_seg attempts to reuse the original buffer but it did not check if there is enough space in the user_data in order to send the buffer with bt_conn_send. Change-Id: Iad54f5868dfce299903f5e392b3ea3b908d1e533 Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-10-16Bluetooth: Fix Kconfig typoFlavio Santes
Fix typo found at net/bluetooth/Kconfig. Change-Id: If606f9911681246162c8ccacd86aa2262883e584 Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-10-16Bluetooth: Start SMP over BR/EDR on pairing completeSzymon Janc
When BR/EDR pairing is completed and we are pairing initiator start SMP over BR/EDR if supported. Change-Id: I9ff095cb89524693ea0e50a94db41bc1b3ab161f Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-10-16Bluetooth: SMP: Use separate pool for BR/EDR connectionsSzymon Janc
For SMP over BR/EDR we need BR specific channel context. This doesn't cost as much as LE context since BR/EDR context is much simpler. Also this make sure that we have enough contexts for devices that support concurent LE and BR/EDR connections. Change-Id: Ied4e3421a29c2fd20643598972dba2ccac5ce82e Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-10-16Bluetooth: SMP: Fix getting context for BR/EDR pairingSzymon Janc
BR/EDR context should be look-up with BR CID. Change-Id: Id9cdce89b86a9c13015dc71a3a395a02f3d29a9a Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-10-16Bluetooth: L2CAP: Treat fixed channel as connected on incoming dataSzymon Janc
This allows to correctly handle race when remote is sending fixed channel data before response to Informatino Request was received. Change-Id: I62e0daa744e11503d31b27f25952ae4ae23d5934 Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-10-16Bluetooth: L2CAP: Connect optional fixed channel only if supportedSzymon Janc
Only connect BR/EDR fixed channel if remote indicates support for it. Core Specification Vol 3. Part A. 4.11: "An L2CAP entity shall not transmit on any fixed channel (with the exception of the L2CAP signaling channel) until it has received a Fixed Channels Supported InfoType from the peer L2CAP entity indicating support for the channel, or has received a valid signaling packet from the remote device on the Fixed channel." If data on fixed channel was received before Information Response then we connect this channel immediately. Change-Id: Ifef142c4eb3c14ecffb4abe4836912e2f2aba3c9 Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-10-16Bluetooth: L2CAP: Move BR/EDR specific code to l2cap_br.cSzymon Janc
This is in preparation for proper handling of fixed channels over BR/EDR. Change-Id: I506c365377d5d6bc74f3cf6d257be43c17f22437 Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-10-16Bluetooth: Use proper const type for bt_storage_clear()Johan Hedberg
The bt_storage_clear() function doesn't modify the data behind the addr parameter, so the pointer should be decared const. Change-Id: Icce676f9df80bac26ba4877bb63752559a43339f Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-10-16Bluetooth: L2CAP: Build fixed channels mask on runtimeSzymon Janc
Build Information Response with fixed channels mask based on registered channels. Change-Id: I47bd3255bd000d3721c77a34c6ea84bbb888630d Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-10-16Bluetooth: L2CAP: Initialize iterator inside for statementSzymon Janc
This is more common code convention. Change-Id: I9283d5a535378ff64f984a6681c9de1fca5f06a5 Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-10-14Revert "net: fetch valid conn. to determine MSS in data_is_sent_and_acked()"Anas Nashif
This reverts commit 627feb92d4b01556891e232db6b9c9181899965b. This patch breaks TCP/IPv4 support in echo_server. Change-Id: Ia1e2cf8dfa94f845d3a8282c83bba40b36ee782c Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-10-08net: fix a potential refcount leak of SYN buffersRohit Grover
net_send() is meant to release the refcount for the SYN buffer once a connection is established, but this assumes that the application uses net_send() for all outgoing buffers. It is possible to setup a connection (and therefore generate an outgoing SYN) by calling net_context_tcp_init(), which has the side-effect of overwriting connection_status . Using such an API would then break the assumption around net_send() reclaiming the refcount of the SYN buf. A test case which exposes the problem: * As a client, setup a connection with an HTTP server. * Send an HTTP request contained in a buf using net_send() * The server responds, and then tears down the connection. * The test client then re-establishes another connection using net_context_tcp_init()--this overwrites connection_status, causing a refcount leak. With this change, we remove the dependency on net_send() being called. Change-Id: I96516cbca3e231ed7fb509a7c03c0ceebf80e03a Signed-off-by: Rohit Grover <rohit.grover@arm.com>
2016-10-08net: fetch valid conn. to determine MSS in data_is_sent_and_acked()Rohit Grover
Packets sent out through net_tx_fiber go through psock_send() where they wait for data_is_sent_and_acked() to process them. data_is_sent_and_acked() looks at the underlying connection's MSS (maximum segment size) before putting them on the wire through uip_send(). The trouble is that that linkage between the outgoing buffer and the connection hasn't been established at the point data_is_sent_and_acked() is called--this normally happens through a call to uip_set_conn(). So data_is_sent_and_acked() fetches an invalid connection handle and makes its choice using an arbitrary MSS. In my particular case, this arbitrary value was 0, and so packets weren't being sent out. Change-Id: I42e8ae104ac20f8df8780c8aee6964ed37113ba0 Signed-off-by: Rohit Grover <rohit.grover@arm.com>
2016-10-04Bluetooth: L2CAP: Rename br_channels to br_fixed_channelsSzymon Janc
This clarify what this list holds making code more readable. Change-Id: Ia212cf611cbf2c2deab139324120b993bf14d06f Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-10-04Bluetooth: Refactor distribution of security procedure statusArkadiusz Lichwa
Layers (modules) above HCI like L2CAP need to know status of applied security procedure when it's triggered on existing connection. It gives them possibility to make action in layer specific context on post-security-procedure conditions. Change-Id: Ia10078469847b29bb7eb3b1fb376ac305dd0b0fc Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-10-04Bluetooth: Fix compiler warnings/errors related to string castsJohan Hedberg
Fix the following compiler warnings/errors that show up with llvm: tests/bluetooth/shell/src/main.c:594:2: error: initializing 'const uint8_t *' (aka 'const unsigned char *') with an expression of type 'char [11]' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN), ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/bluetooth/bluetooth.h:93:11: note: expanded from macro 'BT_DATA' .data = (_data), \ ^~~~~~~ 1 error generated. net/bluetooth/hci_core.c:1759:22: error: passing 'uint8_t [248]' to parameter of type 'const char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] name_len = strlen(evt->name); ^~~~~~~~~ lib/libc/minimal/include/string.h:32:34: note: passing argument to parameter 's' here extern size_t strlen(const char *s); ^ CC net/bluetooth/log.o net/bluetooth/hci_core.c:3136:10: error: passing 'uint8_t [248]' to parameter of type 'char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] strncpy(name_cp->local_name, CONFIG_BLUETOOTH_BREDR_NAME, ^~~~~~~~~~~~~~~~~~~ lib/libc/minimal/include/string.h:30:39: note: passing argument to parameter 'd' here extern char *strncpy(char *_Restrict d, const char *_Restrict s, size_t n); net/bluetooth/conn.c:301:10: error: passing 'uint8_t [16]' to parameter of type 'char *' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] strncpy(cp->pin_code, pin, sizeof(cp->pin_code)); ^~~~~~~~~~~~ lib/libc/minimal/include/string.h:30:39: note: passing argument to parameter 'd' here extern char *strncpy(char *_Restrict d, const char *_Restrict s, size_t n); Change-Id: I342131c6c2b25445382b2317d673561c4087096b Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-10-04Bluetooth: A2DP: Added Connect APIItankar, Piyush T
API Implemented Connect API. This can be used to establish A2DP connection. Change-Id: I8cf714283a452c40b33fd46de442514a1341264c Signed-off-by: Itankar, Piyush T <piyush.t.itankar@intel.com>