Commit graph

1992 commits

Author SHA1 Message Date
Luiz Augusto von Dentz
485d0264fd Bluetooth: GATT: Fix code style
Change-Id: Ia96c0498c1833f19d9252e2b782f87a26137e973
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
2016-10-21 07:47:31 +03:00
Luiz Augusto von Dentz
ee9f5c1784 Bluetooth: GATT: Pass CCC attribute to changed callback
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-21 07:47:31 +03:00
Johan Hedberg
eeee8a7e87 Bluetooth: SMP: Take advantage of new byte swap helpers
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-16 09:01:28 +03:00
Itankar, Piyush T
5ec55f9387 Bluetooth: HCI: Set the Page timeout
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-16 09:01:28 +03:00
Itankar, Piyush T
5599da97f9 Bluetooth: Kconfig: Option to set page timeout value
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-16 09:01:28 +03:00
Szymon Janc
059e271859 Bluetooth: SMP: Check for connection role before BR/EDR pairing
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-16 09:01:28 +03:00
Luiz Augusto von Dentz
d6acfcf6a0 Bluetooth: L2CAP: Allow receiving fragmented buffers
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-16 09:01:28 +03:00
Szymon Janc
2caa5f1442 Bluetooth: Track role change for BR/EDR connections
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-16 09:00:57 +03:00
Szymon Janc
c4c55465d5 Bluetooth: SMP: Fix build without signing support
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-16 09:00:57 +03:00
Szymon Janc
f4c2bdeec4 Bluetooth: SMP: Fix build without central role support
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-16 09:00:57 +03:00
Luiz Augusto von Dentz
0817b05203 Bluetooth: L2CAP: Allow sending fragmented buffers
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-16 09:00:57 +03:00
Luiz Augusto von Dentz
aca8700f92 Bluetooth: L2CAP: Fix sending buffer with not enough space
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-16 09:00:57 +03:00
Flavio Santes
3c99454f1e Bluetooth: Fix Kconfig typo
Fix typo found at net/bluetooth/Kconfig.

Change-Id: If606f9911681246162c8ccacd86aa2262883e584
Signed-off-by: Flavio Santes <flavio.santes@intel.com>
2016-10-16 09:00:57 +03:00
Szymon Janc
b3e1059063 Bluetooth: Start SMP over BR/EDR on pairing complete
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-16 09:00:57 +03:00
Szymon Janc
c63a50dd4c Bluetooth: SMP: Use separate pool for BR/EDR connections
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-16 09:00:57 +03:00
Szymon Janc
6530535327 Bluetooth: SMP: Fix getting context for BR/EDR pairing
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-16 09:00:57 +03:00
Szymon Janc
0856ef3511 Bluetooth: L2CAP: Treat fixed channel as connected on incoming data
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-16 09:00:57 +03:00
Szymon Janc
cb24f7d53b Bluetooth: L2CAP: Connect optional fixed channel only if supported
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-16 09:00:57 +03:00
Szymon Janc
27731ce222 Bluetooth: L2CAP: Move BR/EDR specific code to l2cap_br.c
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-16 09:00:57 +03:00
Johan Hedberg
7d0eef5f96 Bluetooth: Use proper const type for bt_storage_clear()
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-16 09:00:57 +03:00
Szymon Janc
7d4c746093 Bluetooth: L2CAP: Build fixed channels mask on runtime
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-16 09:00:57 +03:00
Szymon Janc
d84397a27c Bluetooth: L2CAP: Initialize iterator inside for statement
This is more common code convention.

Change-Id: I9283d5a535378ff64f984a6681c9de1fca5f06a5
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-10-16 09:00:57 +03:00
Anas Nashif
45616f24e7 Revert "net: fetch valid conn. to determine MSS in data_is_sent_and_acked()"
This reverts commit 627feb92d4.

This patch breaks TCP/IPv4 support in echo_server.

Change-Id: Ia1e2cf8dfa94f845d3a8282c83bba40b36ee782c
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2016-10-14 07:12:06 +00:00
Rohit Grover
f809c84de2 net: fix a potential refcount leak of SYN buffers
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-08 21:20:28 +00:00
Rohit Grover
627feb92d4 net: fetch valid conn. to determine MSS in data_is_sent_and_acked()
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-08 21:20:28 +00:00
Szymon Janc
6526e66b62 Bluetooth: L2CAP: Rename br_channels to br_fixed_channels
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-04 15:44:45 +00:00
Arkadiusz Lichwa
f30b3debc6 Bluetooth: Refactor distribution of security procedure status
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-04 15:15:40 +00:00
Johan Hedberg
a8de2de1f2 Bluetooth: Fix compiler warnings/errors related to string casts
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-04 12:44:24 +00:00
Itankar, Piyush T
76947d7fe6 Bluetooth: A2DP: Added Connect API
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>
2016-10-04 10:55:04 +00:00
Johan Hedberg
a8df6cd14b Bluetooth: Adjust maximum connections & paired devices range
The maximum allowed values in Kconfig were quite conservative.

Change-Id: Icd2d09a2d52fbbaf03671147f08e08385c6776c7
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-10-04 10:46:30 +00:00
Johan Hedberg
9adfb4af17 Bluetooth: RFCOMM: Fix some remaining white-space issues
Change-Id: I56f3ffc9dc9dd18ff204224d1a3166f9dbdc4c3f
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-10-04 08:12:14 +03:00
Arkadiusz Lichwa
dde0737f1a Bluetooth: L2CAP: Fix sending double connection request
HCI events 'encryption change' and 'encryption key refresh' can trigger
channel ops 'encrypt_change'. For BR/EDR outgoing channel connection setup,
when new security needs to be set over existing one, CoC channel connection
request to remote is on hold since security got precedence. Then when
security procedure ends controller emits these 2 HCI event one by one.
In such case channel ops 'encrypt_change' is called 2 times causing
indirectly resume held request that can in consequence sent two subsequent
connection requests for the same target channel.

> HCI Event: Simple Pairing Complete (0x36) plen 7	[hci1] 132.169432
        Status: Success (0x00)
        Address: 68:17:29:CF:5D:86 (Intel Corporate)
> HCI Event: Link Key Notification (0x18) plen 23	[hci1] 132.191364
        Address: 68:17:29:CF:5D:86 (Intel Corporate)
        Link key: 949749ea9f6e91cae22bbfdeada2f333
        Key type: Authenticated Combination key from P-192 (0x05)
> HCI Event: Encryption Key Refresh Complete (0x30) plen 3	[hci1] 132.222430
        Status: Success (0x00)
        Handle: 72
> HCI Event: Auth Complete (0x06) plen 3	[hci1] 132.224365
        Status: Success (0x00)
        Handle: 72
< ACL Data TX: Handle 72 flags 0x00 dlen 12	[hci1] 132.229865
      L2CAP: Connection Request (0x02) ident 7 len 4
        PSM: 5 (0x0005)
        Source CID: 65
< HCI Command: Set Connection Encryption (0x01|0x0013) plen 3	[hci1] 132.230340
        Handle: 72
        Encryption: Enabled (0x01)
> HCI Event: Number of Completed Packets (0x13) plen 5	[hci1] 132.232363
        Num handles: 1
        Handle: 72
        Count: 1
> HCI Event: Command Status (0x0f) plen 4	[hci1] 132.234361
      Set Connection Encryption (0x01|0x0013) ncmd 1
        Status: Success (0x00)
> HCI Event: Encryption Change (0x08) plen 4	[hci1] 132.235362
        Status: Success (0x00)
        Handle: 72
        Encryption: Enabled with E0 (0x01)
< ACL Data TX: Handle 72 flags 0x00 dlen 12	[hci1] 132.240960
      L2CAP: Connection Request (0x02) ident 8 len 4
        PSM: 5 (0x0005)
        Source CID: 65
> ACL Data RX: Handle 72 flags 0x02 dlen 16	[hci1] 132.245765
      L2CAP: Connection Response (0x03) ident 7 len 8
        Destination CID: 65
        Source CID: 65
        Result: Connection pending (0x0001)
        Status: Authentication pending (0x0001)
> HCI Event: Number of Completed Packets (0x13) plen 5	[hci1] 132.246360
        Num handles: 1
        Handle: 72
        Count: 1
> ACL Data RX: Handle 72 flags 0x02 dlen 16	[hci1] 132.246987
      L2CAP: Connection Response (0x03) ident 8 len 8
        Destination CID: 0
        Source CID: 65
        Result: Connection refused - no resources available (0x0004)
        Status: No further information available (0x0000)

Change-Id: Ib417b0e701d6ac09c988f3aff0276cd488ed9115
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-10-04 08:12:14 +03:00
Jaganath Kanakkassery
5f2d121cf1 Bluetooth: RFCOMM: Replace tabs with spaces
As per the coding guidelines spaces should be used for allignment
of macros.

Change-Id: I8947af32ec64ef3791a88bc3ff151f2fbb3c8480
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-10-04 08:12:14 +03:00
Johan Hedberg
ea5576145a Bluetooth: RFCOMM: Remove reference counting
The reference counting has been an internal trick to handle the TX
fiber, but it's not really needed since we can do the same thing with
the help of the state value.

Change-Id: I9cdaed9afb0b0c07e23d599637328cb863c123b3
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-10-04 08:12:14 +03:00
Jaganath Kanakkassery
7fb0894565 Bluetooth: RFCOMM: Introduce dlc destroy
dlc will be destroyed when ref count reaches 0.
This also moves calling user disconnected callback to destroy
since disocnneted callback will be called whenever dlc is
destroyed regardless of dlc previously been in connected state
or not.

Change-Id: I4a13f8118704c59a88923b74e538063c0db11d77
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-10-04 08:12:14 +03:00
Jaganath Kanakkassery
5743879d85 Bluetooth: RFCOMM: Introduce rfcomm_send_dm()
DM (Disconnect mode) response is to inform the peer that dlc
is in logically disconnected state. It can be used to reject
an incoming SABM or PN request as well.

For example if a PN request comes to a server channel which is
not registered, a DM response can be sent.

> ACL Data RX: Handle 256 flags 0x02 dlen 18
      Channel: 64 len 14 [PSM 3 mode 0] {chan 0}
      RFCOMM: Unnumbered Info with Header Check (UIH) (0xef)
         Address: 0x03 cr 1 dlci 0x00
         Control: 0xef poll/final 0
         Length: 10
         FCS: 0x70
         MCC Message type: DLC Parameter Negotiation CMD (0x20)
           Length: 8
           dlci 2 frame_type 0 credit_flow 15 pri 7
           ack_timer 0 frame_size 195 max_retrans 0 credits 7

< ACL Data TX: Handle 256 flags 0x00 dlen 8
      Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
      RFCOMM: Disconnect Mode (DM) (0x0f)
         Address: 0x0b cr 1 dlci 0x02
         Control: 0x1f poll/final 1
         Length: 0
         FCS: 0x73

Change-Id: I1f7576ad97590eed147505802f59faadacc790ea
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-10-04 08:12:14 +03:00
Arun Jagadish
2b583eac63 Bluetooth: AVDTP: Connect and Disconnect API
- Connect/Disconnect API
- L2CAP Connected/Disconnected Callback

Change-Id: I852b748adb9825541904dbb43bdb169e7125749f
Signed-off-by: Arun Jagadish <arun.jagadish@intel.com>
2016-10-04 08:12:14 +03:00
Arkadiusz Lichwa
ab0b3a8303 Bluetooth: AVDTP: Fix getting inaccessible internal
conn->handle belongs to core stack space. Apps shouldn't get access to
it. This fixes build/compiler error when Kconfig's DEBUG_AVDTP is defined.

Change-Id: Id188b367e1e4b7d377a7ef59c0f672229ad98fd8
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-10-04 08:12:14 +03:00
Arkadiusz Lichwa
13ac9cc9c6 Bluetooth: AVDTP: Remove internal headers
The protocol for audio distribution shouldn't have references to internal
core stack space.

Change-Id: Ifce00856dfb8e48d406f815d54cf4b493a7a2770
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-10-04 08:12:14 +03:00
Arkadiusz Lichwa
fdfad74bca Bluetooth: A2DP: Remove internal stack headers
The profile code as sort of user application shouldn't use internal core
stack headers.

Change-Id: I3c6aabf0ee8e1bedac0bd99ebc8526d735219369
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-10-04 08:12:14 +03:00
Kaustav Dey Biswas
ab30160708 Bluetooth: SDP: Server: Initialize and accept incoming connections
Initialize SDP, register to L2CAP and accept incoming connections

Change-Id: I568db63910d9e6ff418581b9943d528d4260b859
Signed-off-by: Kaustav Dey Biswas <kaustav.d.biswas@intel.com>
2016-10-04 08:12:14 +03:00
Johan Hedberg
49d2bb13cd Bluetooth: L2CAP: Extend bt_l2cap_create_pdu() with 'reserve' parameter
This makes it possible for protocols to reserve headroom for their own
headers.

Change-Id: I64530febc4b86b45a379660197f0ff63671fab6e
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
2016-10-04 08:12:14 +03:00
Jaganath Kanakkassery
58d47f0b99 Bluetooth: RFCOMM: Handle session disconnection from peer
UA response will be sent and session will be cleaned up.
Session will also be cleaned up if l2cap channel is disconnected.

> ACL Data RX: Handle 256 flags 0x02 dlen 8
      Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
      RFCOMM: Disconnect (DISC) (0x43)
         Address: 0x03 cr 1 dlci 0x00
         Control: 0x53 poll/final 1
         Length: 0
         FCS: 0xfd

< 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: 0x03 cr 1 dlci 0x00
         Control: 0x73 poll/final 1
         Length: 0
         FCS: 0xd7

Change-Id: I44997d7d13c90a2a0814520ea11e6f14bc60271f
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-10-04 08:12:14 +03:00
Arkadiusz Lichwa
ef1a5527e7 Bluetooth: HFP HF: Enforce Kconfig's HFP_HF relation to RFCOMM
Whenever turning on HFP HF support there's a need to toggle on 
automatically RFCOMM support.

Change-Id: I2fb75c09534d0b6e49a403a527e1caa7d6f9ffaf
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-10-04 08:12:14 +03:00
Arkadiusz Lichwa
97b32a0468 Bluetooth: HFP HF: Fix getting inaccessible internal
The profile (application layer) shouldn't use direct (de)references
to internal stack context members.

Change-Id: I772134a5016de6706c30f058545b3c64c0894202
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-10-04 08:12:14 +03:00
Szymon Janc
7ea426a8f1 Bluetooth: L2CAP: Cleanup flags names for BR/EDR channels
This makes all flags used for BR/EDR L2CAP be stored in single place.
Connection oriented flags and signaling flags are now sharing same
atomic.

Change-Id: If01b29009f9c60ed529338122992b9b5e31f883a
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-10-04 08:12:14 +03:00
Jaganath Kanakkassery
5c1ce90926 Bluetooth: RFCOMM: Handle dlc disconnection from peer
Sends UA response for the DISC request from peer and clean up
dlc. Disconnected callback will be called to profile. Dummy
buf and credit will be used to wake up the tx fiber for exit
and cleanup.

> ACL Data RX: Handle 256 flags 0x02 dlen 8
      Channel: 64 len 4 [PSM 3 mode 0] {chan 0}
      RFCOMM: Disconnect (DISC) (0x43)
         Address: 0x0b cr 1 dlci 0x02
         Control: 0x53 poll/final 1
         Length: 0
         FCS: 0xb8

< 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: I4ec19a93d13a95a9cf4fc5a9beaf48ba8c98689d
Signed-off-by: Jaganath Kanakkassery <jaganathx.kanakkassery@intel.com>
2016-10-04 08:12:14 +03:00
Arkadiusz Lichwa
e3506ca120 Bluetooth: RFCOMM: Shuffle up Kconfig's RFCOMM_L2CAP_MTU
Moves RFCOMM frames max length settings directly under the main RFCOMM
selector for better relations readability. It uses 'depends on' clause
for RFCOMM dependency and proper indentation.

Change-Id: Ic4dc0ffddaf8b438ace1f455191b7a707c0e9ed6
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
2016-10-04 08:12:14 +03:00
Szymon Janc
36b8e8cdc8 Bluetooth: Add debug keys support to HCI ECC emulation code
This was initialy done in SMP code but was lost when moved to HCI ECC
emulation. With this patch if CONFIG_BLUETOOTH_USE_DEBUG_KEYS is set
ECC emulation code uses debug public and private keys as specified
in Core Specifitation 4.2 Vol 3. Part H 2.3.5.6.1.

Change-Id: I626e7e1c6bde2baeae642d6f2c60c324fdd0369f
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-10-04 08:12:14 +03:00
Szymon Janc
f4d75398ca Bluetooth: SMP: Fix unused static variable
gen_method_legacy is used only if SMP SC only mode is not enabled.
This fix compilation warning on some GCC version.

Change-Id: I183c5d0072c2f76da78bf0d2b1077c8d0620f688
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
2016-10-04 08:12:14 +03:00