Fix indicate without func not working properly, when sent as a
non-req by GATT this has two propblems:
- The indicate would not be treated as a transaction, and back
to back indicate would be sent without waiting for the confirm
- The destroy callback would not be called on the indicate parameters
since the indicate_rsp callback would not be called.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
ATT channels do support queueing buffer so it no longer need to block
waiting the tx_sem besides the buffer allocation already serves the
same purpose as the application will not be able to have more requests
than there are buffers available.
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Allow to request a higher security level during the key distribution
phase.
This is required by ATT and L2CAP since they only react to the encrypt
change event where they resend the current request.
The current request might require a higher security level still and
might have to request a higher security level before the pairing
procedure has been finished.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
When ATT resends an ATT request it is sent as a "response" instead of
as a request. This causes the ATT request buffer to be released and
the ATT request cannot be resent one more time.
This causes a problem when the ATT request requires authentication
but the elevation of security is not enforcing MITM protection.
In this case the ATT will first require security level 2 and then resend
the request once this has been reached.
This will lead to a new ATT error response and ATT will require security
level L3.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix the update keys check allowing to overwrite the keys when using
debug keys. Instead the check disallowed overwriting keys made using
debug keys.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix gatt write command returned "write in progress" when either
hex2bin or bt_gatt_write returned an error.
The write_params.func should not be set if the write command was not
successful.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Sets the sequence number when re-encrypting messages from the friend to
the lpn.
This is a regression from #28511.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Set app_idx and net_idx in the msg_ctx before calling
bt_mesh_keys_resolve when re-encrypting friend messages, as they'll be
referenced inside the function.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Move the public network request command from the end of `lorawan_start`
to the start of `lorawan_join`. This MAC command interacts with the
radio driver, bringing it out of sleep mode, and doesn't put it back.
The public network setting is only needed when joining a network, and
`lorawan_start` can be called well before `lorawan_join`. By moving the
command we save ~600uA before joining (for sx1262).
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Fix missing advertising PDU length initialization which
prevented advertising PDU to be transmitted by Radio. This
issue was reproduced when connectable undirected advertising
was enabled without setting an advertising data.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
llvm 11 doesn't like having preprocessor directives in the expansion
of a macro used as a preprocessor conditional expression.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
After #31176, the network would get stored immediately in
bt_mesh_net_create, causing the address and devicekey to get stored as
their zero-initialized version, as they're only being set in the
bt_mesh_comp_provision call, which fires after.
Fixes#32067.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Fixes problem when fs_opendir invoked on fs_dir_t object,
which is already holding information on opened directory,
overwrites references to other memory objects within
the fs_dir_t object causing resource leak.
If fs_opendir is invoked on already used fs_dir_t object,
it will return
-EBUSY.
Note: The change requires that all fs_dir_t objects should be
initialized to 0.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
The commit adds initializations of fs_dir_t variables in preparation
for fs_opendir function change that will require fs_dir_t object, passed
to the function, to be initialized before first usage.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
Reduces some user confusion regarding whether it is related
to "Connection ID", "Channel ID", or "Company ID" for the
uninitiated.
Signed-off-by: Emil Hammarstrom <emil.hammarstrom@assaabloy.com>
Current 6lo implementation is unable to deal with scattered headers
(which should not happen usually, though it's a valid use case), so
let's just fail uncompressing such packet then.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Bogus fragmented packet could be sent without a FRAG1 fragment and hit
reassembly. Let's make sure this does not happen.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
In case the current packet is the same as the cached one, let's not
unreference it while clearing the cache.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Though ACK frames are not meant to reach L2 (drivers must ensure this
never happens), let's "re-enforce" the L2 by dropping them.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
All addressing mode but IEEE802154_ADDR_MODE_NONE should have a valid
address. If not, the frame is invalid.
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Fix OpenISA port to include compiler memory barrier as in
commit 1a14f8b3a6 ("Bluetooth: controller: Use DMB instead
of DSB").
Relates to commit 1af2b91c23 ("Bluetooth: controller: Fix
Tx Buffer Overflow") and to commit ef2ece82c0 ("Bluetooth:
controller: openisa: Fix sanitycheck failures") and to
commit c2fc629dd2 ("Bluetooth: controller: 255 byte AD
payload support").
Fixes#31937.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix for OpenISA rv32m1_vega_ri5cy board not supporting
different IRQ Priority levels for LLL, ULL_HIGH and ULL_LOW
execution contexts.
Fixes#31937.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix BT_CTLR_ULL_HIGH_PRIO default value to equal
BT_CTLR_LLL_PRIO value if BT_CTLR_LOW_LAT is enabled, else
default ULL_HIGH to lower IRQ priority level in comparison
to LLL IRQ priority level. If BT_CTLR_ZLI is enabled,
BT_CTLR_ULL_HIGH_PRIO can default to a priority level value
of 0 and still be lower priority level than the LLL which
is placed at Zero Latency IRQ priority level (highest
priority in the CPU).
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
As network_decode needs a target buffer for decoding, the max PDU length
must be checked to prevent overflow on the target buffer. When receiving
a proxy configuration message with excessive length, there's no previous
check for this.
Also pulls the NET PDU length defines out into net.h, so they can be
used when defining the target buffers.
Signed-off-by: Trond Einar Snekvik <Trond.Einar.Snekvik@nordicsemi.no>
Restore the user requested datarate upon a successful join. Several
regions overwrite the configured datarate through `RegionAlternateDr`,
which means that for these regions, `LoRaMacQueryTxPossible` will not
be evaluating the requested datarate for the first transmission after
joining.
Fixes#31551.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Validate datarates requested by users. As a side effect of this change
the MAC layer is immediately aware of updated datarates. Therefore
`LoRaMacQueryTxPossible` in `lorawan_send` will be using the same
datarate to evaluate the payload length as `LoRaMacMcpsRequest` is
requesting.
Fixes#31551.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Query the default datarate for the configured region, instead of
assuming that the default is DR_0.
Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Use BOS header structure directly we have access to
instead of casting extern const pointers.
Fixes: #30330
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
Attempts to disable PM_STATE_SOFT_OFF would index past the end of the
count array. Increase the array length to allow operations on
PM_STATE_SOFT_OFF.
Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
This patch replaces magic numbers with COAP_TOKEN_MAX_LEN value and
removes unnecessary castings of token buffer type.
Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
RFC 7252 (CoAP) specifies value of the Version (Ver) field in the
protocol header to value 1. This patch defines value of the Version
field to make packet initialization easier. All samples and tests
are updated to use the new COAP_VERSION_1 field when initializing
a CoAP packet.
Signed-off-by: Hubert Miś <hubert.mis@nordicsemi.no>
Fix Tx Buffer Overflow caused by uninitialized node_tx
memory being used by ULL ISR context due to Compiler
Instructions Reordering in the use of MFIFO_ENQUEUE.
The MFIFO last index was committed before the data element
was stored in the MFIFO due to Compiler Instructions
Reordering.
This is fixed now by adding a Data Memory Barrier
instruction alongwith a compiler memory clobber.
Fixes#30378.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use of Data Memory Barrier instruction with memory clobber
in ARM Cortex M architectures is sufficient in the
controller implementation to keep compiler data access
instructions in order so that an ISR vectoring has memory
accesses in the correct order as intented by design.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Mark the option BT_FIXED_PASSKEY as an insecure option.
During Legacy pairing the passkey is used as encryption key, and
brute-forcing this is easy.
During LE Secure Connections the passkey is checked one bit at a time,
so when it is fixed the passkey can be deduced with series of pairing
attempts.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
The Bluetooth SMP protocol depends on the BT_ECC for the LE Secure
Connections pairing. Since this feature cannot be disabled we must
select this dependency.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix fixed passkey for legacy pairing. The pairing procedure fails
because the temporary key (TK) has not been set for this pairing
procedure.
Fix this by always requesting the legacy TK.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix misleading message in the bluetooth shell when the id-create
command returns en error code. In this case both failure and success
messages are printed.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Add options to control the behavior of the init command.
Option no-settings-load allows the user to create identities
with the id-create command after bt_enable() but before settings_load().
Option no-ready-cb allows the user to test using synchronous enable,
since this sometimes leads to different behavior of the stack.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Prevent the bt_rand function from being called before bt_enable.
Depending on the implementation of bt_rand this function cannot
be called before bluetooth has been initialized. With host supplied
crypto functions the HCI LE rand command is used for example.
The use case for calling bt_id_create before bt_enable is meant for
when the application has storage for the identity instead of the stack.
So we add the requirement that the application has to have storage
for the identity resolving key (IRK) in addition when the local
device is privacy-enabled.
Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
Fix the default ULL_HIGH execution priority to be lower than
LLL execution priority to reduce Radio ISR service latency.
Also, default to Zero Latency IRQ for Radio ISR if enabled
in the kernel.
Fixes#29994.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>