This refactorer fixed channel data so that the channel itself carries
any extra context necessary.
Change-Id: Iea0f29fb7913a29dccdcbef72d92ec4cf4711bf3
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This is in preparation for supporting different encryption key sizes.
Change-Id: I36ed61a35fbe4988ce863127ae318c63f9298dd3
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
Change all the Intel and Wind River code license from BSD-3 to Apache 2.
Change-Id: Id8be2c1c161a06ea8a0b9f38e17660e11dbb384b
Signed-off-by: Javier B Perez Hernandez <javier.b.perez.hernandez@linux.intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Benjamin Walsh <benjamin.walsh@windriver.com>
Delaying only connected callback resulted in races where security
or pairing callback could be called before bt_conn connected.
Currently only procedure that relies on read features is connection
parameters update and that should not conflict with other traffic.
Change-Id: I835535abbff21ea8d86b728f5681f90ef9fd337c
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
Gather SMP related code together so that it can be placed under
single blocks of ifdefs.
Change-Id: I3c2e71243b694e9984ae8e88025a6ead7969e020
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This allows to not compile SMP support for devices that don't
require pairing. It is required to support SMP channel and reply
with error for any command received even if pairing is not supported.
To handle this cleanly a null smp implementation is used that case.
Change-Id: I656a52dac882839db904eee65f25a4e29ea2d8c2
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
The core specification says the following about the treatment of
unacknowledged packets when a disconnection occurs (page 773 in core
spec 4.2):
"When the Host receives a Disconnection Complete, Disconnection Physical
Link Complete or Disconnection Logical Link Complete event, the Host shall
assume that all unacknowledged HCI Data Packets that have been sent to the
Controller for the returned Handle have been flushed, and that the
corresponding data buffers have been freed. A Primary Controller does not
have to notify the Host about this in a Number Of Completed Packets event"
This patch adds tracking of unacknowledged packets on a per-connection
basis and makes sure the semaphore that counts controller buffers is
given back the appropriate amount when a disconnection occurs.
Change-Id: I2ff4d12ffa50d4dda5b3e8c75fc75b4c0927e609
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
All required includes should be placed in source file that includes
internal header.
Change-Id: I161e7ebe2e62377ea4cf03f759d48f5900103076
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
This callback is called if security level of a connection was changed.
Change-Id: I268da245cf4b7f6d2bfbd57969ce2da6c34fc69f
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
bt_conn role can be set when LE Connection Complete event is received.
Controller indicates to both Hosts forming the connection their role
in this connection.
Change-Id: I35455eff54afa30665611415ac52e19089f2e649
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
This callback is called if identity was resolved for remote device
that was using Resolvable Private Address while connection. From
now on only Identity Address is used.
Change-Id: I5976be575a8e4ad8c13f56d7bc274d751ae37511
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
Since initiator and responder addresses are already tracked it is
no longer needed to store source address in bt_conn structure.
Change-Id: I048e4d4659f4b7d29b101f9f3c5708f66c773906
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
When remote device initiate pairing but its IRK is already known
identity address was used to calculate confirmation value. This
resulted in 'Confirm Value Failed' error and pairing failure.
To avoid any confusion simply track initiator and responder addresses
used for connection.
This fix re-enabling security with iPhone if device was unpaired
only on iPhone side.
Change-Id: I07d9589bee5fea7f6b028472b1709090a5755e31
Signed-off-by: Szymon Janc <ext.szymon.janc@tieto.com>
Since then bt_conn_connected as well as bt_l2cap_disconnected callback
can be called from bt_conn_set_state directly.
Also connected cb could be called from there, however
eg. introduction of some additional state is required TBD.
Change-Id: Ida6906272e1468ef5b41ba8dba2a936db049d308
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
Prepare room in connection object for result of LE read remote
features procedure.
Change-Id: I30a557656d44a6c35a2a022e8e6e574b52d257be
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Adds fiber which starts with some specified delay.
If the fiber is not cancelled, bt_disconnect is called to
cancel creation of connection.
Change-Id: I06667d970ba3398f205f19f1d2e76ab6c283f274
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
Rename the hci_core.c (previously internal) variable 'dev' to 'bt_dev'
and export it through hci_core.h. This way e.g. bt_conn doesn't need
to store an internal reference to it.
Change-Id: Ic1368c8f20d307c6a13a412f80d8183b56d7a76b
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Calling bt_conn_set_auto_conn one can decide if auto connect shall
be used. If so, everytime the connection is lost, passive scanning
will be enabled to listen for connectable advertisements from
remote device and re-establish the connection.
Auto connect can be disabled if one decide to disconnect from
this device using bt_disconnect or call bt_conn_set_auto_conn
with auto_conn flag set to false.
Change-Id: Ic9952e313cb8612ea6c72838be0755805daeffcf
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
This state will be used for connection establishment during passive scan.
This additional state is necessary, because only one connection can be
in BT_CONN_CONNECT state (LE Create Connection has been sent).
It's because the LE Create Connection Cancel looks for connection in this
state (we cannot look by address, if some controllers respond with
LE Create Connection with address set to 00:00:00:00:00:00).
If connection is BT_CONN_CONNECT_SCAN state it means that we wait for
an advertisement from remote to send LE Create Connection and then we
can change the bt_conn state to BT_CONN_CONNECT.
Change-Id: I48b0352fe08e438f7bfbb1dd12de3d1719f994d8
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
bt_conn_lookup_state looks up for connection with "peer" in specific
state "state". Returns NULL if there is no connection with peer or
connection state differs from the given one.
Passing BT_ADDR_LE_ANY will return the first connection with the
specific state.
Change-Id: Iaa3bb22c9aa31192b8782adb6b11c5051b403758
Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
This makes it possible to perform these operations without
locking once per-conn locking is added in the future.
Change-Id: I342d55856116d9c87daeda4088b65e78e8ef0768
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Delegates connection object to new connection when there exists
in pool of available connections an object with zeroed destination
LE address.
When there's no reference to the active connection object resets its
peer LE address member.
Replaces routine's input connection handle parameter with LE address.
Moves to the caller setting connection state, connection handle and
call to bt_l2cap_update_conn_param() since connection handle needs
to be valid when such update going to be made.
Change-Id: I81743a915da6cb008f9593dd1940c186a357be6b
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Applies new bt_conn_set_state() internal API that now participate in
tracking connections. It concerns only connected and disconnected
events from controller.
Remove bt_conn_del() internal API.
Change-Id: Ic8da46785a7b5e19cae2186047e84e1a5a45a78a
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Adds new possible transitions in tracking connection state.
Reorder available transition value set.
Change-Id: I4f5959c7f98f7a39d8405c23bff9af330e12fcaa
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
Typedef so far anonymous enum values allowable connection states
to be set.
Adds interface to allow track connection state.
Update struct bt_conn definition using introduced enum's typedef.
Change-Id: Id91f5a814e4801438f1dcef36fff058faab7beda
Signed-off-by: Arkadiusz Lichwa <arkadiusz.lichwa@tieto.com>
This API is useful for applications wanting to monitor and disconnect
connections.
Change-Id: Ib1a98ece364f137262515fbb1163c6b08ddf792c
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This one should be used for all public connection related APIs. Right
now it includes the reference counting and connection callback APIs.
Change-Id: Ib9b67e6115bb2e51322644757da1170851c3ca17
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
We'll have a public conn.h header file soon, so to avoid confusion
rename the existing conn.h to conn_internal.h.
Change-Id: I5e5c89ec184a0a2de63e244b034c55a3d97af9dc
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>