Without this fix is it not possible to terminate pppd and restart
pppd afterwards without restarting the firmware, too.
Signed-off-by: Christian Taedcke <christian.taedcke@lemonbeat.com>
Unifies the Mesh CCM implementation parts for encryption and decryption
into a crypt and an auth step, reducing stack usage and code size.
This change also brings several performance improvements, most notably
reducing copying of the nonce and unrolling the 16 byte XOR operations.
Performance for the Mesh worst case of a 382 byte payload with 16 bytes
of additional data (full transport encrypt with virtual address) goes
from an average of 889us to 780us on nRF52840 with default optimization
flags.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Remove leading/trailing blank lines in .c, .h, .py, .rst, .yml, and
.yaml files.
Will avoid failures with the new CI test in
https://github.com/zephyrproject-rtos/ci-tools/pull/112, though it only
checks changed files.
Move the 'target-notes' target in boards/xtensa/odroid_go/doc/index.rst
to get rid of the trailing blank line there. It was probably misplaced.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Handle invalid ACL flags in HCI transport.
Only Point to Point is supported over HCI in both directions.
Fix flushable start HCI ACL packets not allowed on LE-U connections
from Host to controller.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
In bt_l2cap_br_chan, rx.cid is the local cid and tx.cid is the
remote cid. According to Core-5.0 Vol3.Part A 4.6-4.7,
l2cap_br_remove_tx_cid should be searched using tx.cid
Signed-off-by: ZhongYao Luo <LuoZhongYao@gmail.com>
According to BT Spec v5.1 Vol 2 Part E Section 7.8.16, if the
device is already in the White List, the controller should not
add the device to the White List and should return success.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
According to BT Spec v5.1 Vol 2 Part E Section 7.8.16, if the
device is already in the White List, the controller should not
add the device to the White List and should return success.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
If the whitelist already exists in the controller then the controller
should not add the device tot the whitelist and should return success.
In that case the counting of entries in the whitelist in the host will
be wrong.
Remove all whitelist counting in the host, and instead rely on the error
reported by the controller for this.
The controller should return error if the whitelist is full.
The controller should return error if use of whitelist was requested but
the whitelist was empty.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This adds net_bug_simple_init_with_data which can be used to initialize
a net_buf_simple pointer with an external data pointer.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Added leak suppression, by implementing __lsan_default_suppressions
function, for SDL2 and X11 library which are used by the SDL display
driver.
Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
When Friend node tries to send Friend Clear message to other
Friend nodes, it should use the subnet information based on
the net_idx from friendship.
Fixes#21165
Signed-off-by: Maximus Liu <maximus.liu@gmail.com>
Before we try to set IP addresses to the network interface,
make sure that the interface is up.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit renames two defines:
CS_INTERFACE -> USB_CS_INTERFACE_DESC
CS_ENDPOINT -> USB_CS_ENDPOINT_DESC
in order to match current naming convention when it comes
to descriptors fields.
All relevant files are updated to match renamed macros.
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
Some of defines are present in several header files.
Those defines are the same with value but with different naming.
Common defines are brought to usb_common.h
Signed-off-by: Emil Obalski <emil.obalski@nordicsemi.no>
Allow to select Sleepy End Device, and configure it during OpenThread
initialization.
According to Thread Specification, Sleepy End Devices should always
attach to the network as SED, to indicate increased buffer requirement
to a parent. Therefore, we reconfigure the Link Mode on each boot.
Note, that Poll Period value is not stored in the persistent storage,
hence we also need to initialize it on each boot.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
OpenThread radio layer did not implement `ieee802154_radio_handle_ack`
API and provided fake ACK frame to the OpenThread.
This prevented proper Sleepy End Device operation, as it expects to
receive information in the ACK whether it should wait for more data to
come or should it put the radio to sleep.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The start/stop functions do a whole pile of supervisor-
only stuff; resolve this by making them ztest-specific
system calls.
Fixes: #20927
Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
Expose the bt_uuid_to_str function as an API to the application.
This aligns this function with the bt_addr_to_str function call. This
allows the application to use this function without having to enable
the BT_DEBUG option.
Move the in-place bt_uuid_str to internal logging, this is mainly done
due to the limitation in the log_strdup that shouldn't be exposed to the
application.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Bool symbols implicitly default to 'n'.
A 'default n' can make sense e.g. in a Kconfig.defconfig file, if you
want to override a 'default y' on the base definition of the symbol. It
isn't used like that on any of these symbols though.
Also replace some
config
prompt "foo"
bool/int
with the more common shorthand
config
bool/int "foo"
See the 'Style recommendations and shorthands' section in
https://docs.zephyrproject.org/latest/guides/kconfig/index.html.
Signed-off-by: Ulf Magnusson <Ulf.Magnusson@nordicsemi.no>
Check that the bluetooth device has in fact been initialized before
continuing with public API calls. This could lead to crashes when using
state that has not yet been initialized.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When set, the BT_GATT_SUBSCRIBE_FLAG_NO_RESUB flag indicates that the
subscription should not be renewed when reconnecting with the server.
This is useful if the application layer knows that the GATT server
persists subscription information.
Signed-off-by: François Delawarde <fnde@oticon.com>
Added configuration for accepting pairing requests only if both devices
has bonding flag set in order to reject other devices at an early stage,
thus leaving more chance for devices expected to bond.
With the CONFIG_BT_BONDING_REQUIRED flag the device only accept pairing
requests if it has CONFIG_BT_BONMDABLE set and the device requesting
pairing has Bonding_Flags field set to Bonding (0x01) in its AuthReq.
Note: When using bt_set_bondable(false) pairing requests will be
rejected when CONFIG_BT_BONDING_REQUIRED is set.
Signed-off-by: Martin Rieva <mrrv@demant.com>
flash_sector_from_off fetched sector data of page
in relation to the flash memory beginning instead of the flash
area beginning.
Issue was invisible as on most devices all sectors looks similar.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Fix issues that surfaced when trying out GCC 9.2, official release name
gcc-arm-none-eabi-9-2019-q4-major, both related to invalid pointers in
GATT when declaring UUIDs in if-scope.
1. Fix the discovery callback giving an invalid pointer in the discovery
callback in two instances.
2. Fix gatt_find_type sending invalid data during discovery procedure.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Send connection parameter update request only if it contains the valid
range of values for connection intervals, latency and timeout.
Signed-off-by: Kiran Paramaswaran <kipm@oticon.com>
Fix ATT MTU size of length variables resulting in wrong length values
reported to the user. Communicating with an Android device using an MTU
of 517 resulted in write commands reported as length 2 instead.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Deep sleep states are documented to include SoC-level power gating,
i.e. the SoC loses context. In practice entering a deep sleep state
requires an external wakeup mechanism that may need to restart the
application.
Such states are too dangerous to enter automatically based on an
expected duration of sleep, especially since a "forever" sleep that
would normally be woken as a result of a peripheral event would select
the deepest sleep state available. Limit the sleep levels selected by
a residency policy to ones in which the CPU may be stopped, but will
not lose execution context.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Since bt_conn_send_cb can fail to send buffer causing it to unref this
may cause buffer leaks as the caller is not aware of the error assuming
the buffer could be sent.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Add support for Zero Latency IRQs, which avoids any Zephyr
OS or application influenced ISR latencies on the
controller's ISRs.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The time difference calculation did not check if the result
value would be < 0 which means really large value when converted
to unsigned.
Fixes#20100
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
Processing of data received on dynamic channels is still done via syswq
so the buffer shall not be unrefed when they are queued.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Now that the TX callbacks happen from the system workqueue but fixed
channels get processed from the RX thread there's a risk that the
ordering of these gets messed up. This is particularly bad for ATT
when it's trying to enforce flow control.
To fix the issue store the completed TX packet information in a
per-connection list and process this list before processing any new
packets for the same connection. We still also schedule a workqueue
callback, which will simply do nothing for this list if bt_recv()
already took care of it.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
For 32-bit architecture Bluetooth only requires 4 bytes for the user
data. There are places that store a pointer in it, so we need to make
an exception for 64-bit architecture. The code contains relevant build
asserts, so it's sufficient to set a conditional default in Kconfig
but let the range definition be simpler (unconditional).
Also simplify & fix the conditional defaults & ranges. E.g. separately
mentioning X86_64 is redundant since that option explicitly selects
the 64BIT option.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This define is not of use anymore since there's a global net_buf user
data Kconfig variable and its definition already guarantees a
sufficient minimum for Bluetooth.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The "sent" tracking doesn't have to be a signed integer. Use a fixed
size so that the consumed size doesn't change between different
architectures. Use a u16_t since bigger sizes are needed and because
this is mapped to an int function return higher up in the stack.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fixed handling of HCI events in the HCI driver over RPMsg. Now,
the driver makes use of discardable buffer pool when allocating
memory for certain HCI event types (e.g. Advertising Report Event).
Applications that are flooded with Advertising Reports will run
much better after this change (e.g. Mesh applications).
Signed-off-by: Kamil Piszczek <Kamil.Piszczek@nordicsemi.no>
If LL Connection Parameter Request or LL Connection Update
or LL PHY Update procedure is started by the local device
while a LL Length Update Request PDU has been sent by peer
then a Rx node has been stored in the llcp_rx place holder
for generation of Length Update procedure complete.
The failing assert check is incorrect in the above scenario
hence remove. Instead a missing append of the allocated Rx
node to the llcp_rx list has been added to the controller
implementation.
This issue relates to commit d12c53f89f ("Bluetooth:
controller: split: Fix missing data len update event").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Add an implementation for `sendmsg`, so secure sockets can be used
together with the WebSocket module to implement secure WebSockets
("wss").
Fixes#20431
Signed-off-by: Markus Fuchs <markus.fuchs@de.sauter-bc.com>
Now that the TX path and TX context (bt_conn_tx) has been redesigned
to free the contexts always in the system workqueue, it means the
system workqueue is the only context where their allocation may also
fail. This is particularly problematic with us having all L2CAP
channels (fixed & CoC alike) deferred to the system workqueue. It is
especially bad for fixed channels where being able to send responses
for SM, L2CAP signaling and ATT is critical to avoid timeouts for the
connection.
This patch moves the processing of all fixed L2CAP channels back to
the RX thread, thereby making it possible (and safe) to block while
waiting for a TX context to become available.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Now that we've removed the TX allocation dependency from the TX thread
we no longer have the need to do special-casing for the system
workqueue when allocating buffers. Instead, we do have to special-case
the system workqueue when allocating TX contexts since the system
workqueue is the only place where they get freed up.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This is a moderate redesign of the pending TX packet handling that
aims to eliminate potential deadlocks between the TX thread and the
system workqueue thread. The main changes are:
- TX context (bt_conn_tx) is allocated during buffer allocation, i.e.
not in the TX thread.
- We don't allocate a TX context unless there's an associated
callback. When there's no callback simple integer counters are used
for tracking.
- The TX thread is no longer responsible for TX callbacks or
scheduling of TX callbacks. Instead, the callbacks get directly
scheduled (k_work_submit) from the RX priority thread.
- CONFIG_BT_CONN_TX_MAX defaults to CONFIG_BT_L2CAP_TX_BUF_COUNT,
and in most cases wont need changing. The value now only indicates
how many pending packets with a callback are possible.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The `node` and `work` members are never used simultaneously.
Additionally k_work already has built-in support for being in a linked
list, however a union makes this change a bit cleaner.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
In seg_tx_reset() in transport.c, set the busy flag to 0U
before doing adv buf unref, which will avoid sending
unnecessary adv packets in case the adv buf is already put
in the mesh adv_queue.
Fixes#20970
Signed-off-by: Maximus Liu <maximus.liu@gmail.com>
Use malloc/free instead of k_malloc/k_free in operator new/delete
implementation or use libstdc++ implementation when available.
Further updated cpp_synchronization sample to enable minimal libc heap
as virtual destructor requires operator delete which depends on free.
Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
A recent patch increased struct cmd_data from 8 to 12 bytes, which is
more than the default user data for Bluetooth. We generally don't want
the core stack to require more than 8, so instead of increasing the
requirement, move the data out from the buffer into its own array with
the help of the net_buf_id() API.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
The instructions for samples/usb/dfu fail on Nordic platforms if the
erase is not progressive. Default to enable that on Nordic.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Fix race condition in bt_conn_create_le for the state of the scanner in
the Host. This leads to the host issuing a create connection command
without stopping the scanner first. This leads to command disallowed and
failing to establish connection. As well as inconsistent state in the
host which does not allow to stop the running scanner.
The race condition exists because the processing of le_adv_report
handler is done before the thread that called bt_conn_create_le was
woken up to continue after the command_complete event.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
In nvs writing addresses are u32_t. Coverty reports two situations
where the address could be converted (unwanted) to a signed value.
Both have been corrected.
There is however a general problem with flash API where the addresses
are defined as off_t which is a s32_t. These are converted in the flash
hal to u32_t. As a result of this only half of the possible range can
be used.
Solves #20867 and #20866
Signed-off-by: Laczen JMS <laczenjms@gmail.com>
Fix the initiator so that connection request PDU is not abort
mid-air by preemption by the overalapping first connection
event.
If the connection establishment is in progress, then the
first connection event trying to abort the initiator will
wait the connection request to be transmited completely.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Enable ticker job mayfly as soon as possible when
establishing connection. This is required so as to not miss
the first connection event in slow CPU like in nRF51 series.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Size argument must be smaller than strTo buffer size since
strncpy terminates string with NULL.
Signed-off-by: Krzysztof Chruscinski <krzysztof.chruscinski@nordicsemi.no>
Fix command status for LE Command Param Update HCI command silently
dropped by the host without notifying the application that this command
has failed. This happens because the host does not wait for the command
status event to check the status code returned.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix deadlock in Bluetooth Host. Deadlock could happen from the SMP
callbacks when calling Bluetooth API functions. This is because the
callbacks was given directly from the HCI TX thread. If the calling
API function resulted in trying to send a new HCI command it would post
this HCI command to the HCI TX thread and then wait for command complete
event. This would result in the HCI TX thread blocked waiting for the
itself to process the command.
Example:
Calling bt_conn_le_conn_param_update from pairing_complete callback.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit adds a NULL pointer check for the destination
context pointer. The pointer is NULL in case the context
does not exist.
Signed-off-by: Alexander Wachter <alexander@wachter.cloud>
There are some changes that were introduced to the Nordic SW LL,
and as such, in order to maintain compatibility, propragate them
to the OpenISA SW LL as well.
Signed-off-by: Alex Porosanu <alexandru.porosanu@nxp.com>
In nRF51 which uses CONFIG_BT_CTLR_LOW_LAT, the advertising
PDU tend to get aborted in directed advertising at event slot
durations.
Dont not use continuous directed advertising event in nRF51
where CONFIG_BT_CTLR_LOW_LAT scheduling design alternative
is used. Instead close the event after each triplet of PDU
has been tx-ed.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the directed advertising event interval calculation.
When CONFIG_BT_CTLR_LOW_LAT is used then prepare duration
has to be included in the event slot reservation.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The HCI transport implemented by an application using the HCI raw
interface may have its own buffer headroom requirements. Currently the
available headroom gets completely determined by the selected HCI
driver. E.g. most of the time this is the native controller driver
which doesn't reserve any headroom at all.
To cover for the needs of HCI raw users, add a new Kconfig variable
for the apps to set to whatever they need. Correspondingly, use the
maximum of the HCI driver and HCI raw headroom requirements for the
buffer pool definitions and the headroom initializations.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Fix the implementation of slow encryption setup design
alternative to send ENC_RSP PDU before sending REJECT_IND
or REJECT_EXT_IND PDU.
Fixes#19917.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix dependency on the Host to include the PHY update procedure and the
data length update procedure. In a host-only build this feature should
be possible to select without relying on the supported features of the
controller. The host will check support using HCI command to read
attached controller features and commands supported.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix GCC9 warning "warning: taking address of packed member of
'struct sc_data' may result in an unaligned pointer value"
Issue is that the on-air structure of sc_data was re-used for the gatt
service changed data.
Added build assert because data is stored in settings, so the structure
should be the same size to be compatible.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
We already returned out of the function if err is nonzero, therefore it
is impossible to reach this return statement.
Coverity-CID: 205612
Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
The routine to read the image from the device and upload it to the
host stored data in a buffer unrelated to the one transferred to the
host, resulting in a corrupt image.
Signed-off-by: Peter A. Bigot <pab@pabigot.com>
Linux btusb driver do not relies on ZLP to determine the
end of a transfer. Instead the data is transmitted
continuously and the driver obtains the length of a event
from the HCI Event Packet header.
Fixes: #20250
Signed-off-by: Johann Fischer <j.fischer@phytec.de>
Fix the regression introduced as part of
commit 57d9411837 ("bluetooth: kconfig: disable some
options for openisa/RV32M1").
Also, prior to PR that introduced this regression, the Coded
PHY support selection was incorrectly depending on PHY update
support Kconfig BT_PHY_UPDATE. This was already fixed as part
the previous PR.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit fixes the settings_call_set_handler function
in a situation where the user calls settings_load_subtree_direct
with NULL as a subtree parameter.
Fixes: #20514
Signed-off-by: Radoslaw Koppel <radoslaw.koppel@nordicsemi.no>
The BT_HCI_TX_STACK_SIZE is carefully calculated from other
options. When those options change, e.g. from a menuconfig update, it
is important that the stack size is re-calculated, but it is not when
there is a prompt.
Therefore, make the prompt conditional such that the previously set
value is only used when it has been explicitly configured to be so.
Now users can still change the value through menuconfig and prj.conf,
by also enabling <option>_WITH_PROMPT, but when the value is
calculated by the defaults, it will continue to be calculated by
defaults instead of inheriting the intial value.
This is AFAIK a novel approach, but testing has shown that it gives
the users the behaviour they want, at the cost of some boilerplate of
course. This pattern can be applied to other options if it proves to
work as intended.
Alternatively one could remove the prompt, but then it would no longer
be possible to override the value through menuconfig.
Signed-off-by: Sebastian Bøe <sebastian.boe@nordicsemi.no>
Fix for not served error code in fcb_offset_last_n()
implementation.
Issue was reported by static code analyze scan.
Looks like the function might have failed silently
if aggressive access to the fcb instance
from another thread have been occurring while the function
have been processing the fcb storage.
fixes#20512
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
When Config client model send publish message, app_idx will
be need, however, currently code clear this value use `&`,
this will be generate error when app_idx not zero.
Signed-off-by: Lingao Meng <mengabc1086@gmail.com>
In settings write NVS errors were not handled
in a few places.
This patch improve that.
fixes#20515
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>