Don't send IGMP report on join if the address was already joined,
only increase the ref count by calling net_if_ipv6_maddr_add().
On leave, only send report if the address was removed from the system
(i.e. is no longer in use).
For IGMPv3 specifically, if the address with non-empty include/exclude
list was already registered, return an error as registering lists from
different sources is currently not supported.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add ref counting for multicast addresses, so that if a multicast address
is registered from different subsystems, they won't interfere with each
other. That way, if one subsystem decides to remove a multicast address,
it won't affect other subsystems that may still need it.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Modify bt_ccp_call_control_server_get_bearer_provider_name to
store the bearer provider name in an output buffer, instead of just
providing the pointer.
The reason for this is to make the result thread safe, and
avoid the user/application having a direct pointer to
internal storage.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Currently the other of the ACL and CIS disconnect callbacks
depend on the order of the HCI events received. Since this
order is not specified by the core spec, it means that any
users/applications of ISO will need to wait for all CIS
disconnects callbacks and the ACL disconnect callback before
attempting to reuse any of them.
From an API perspective this is not ideal, and the API will
be much simpler if the order of ACL and ISO disconnect
callbacks were deterministic, regardless of the controller.
This change postpones the finalization of the ACL disconnect
until all the CIS associated with it has been disconnected.
This will also make the API more similar to e.g. the L2CAP
disconnect order.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Add a new callback for when the broadcast source has been
created. This callback is useful for the application to
configure the periodic advertising with the BASE of the
broadcast source. Configuring and starting the
periodic advertising with the BASE at that point in time
may optimize how quickly the procedure can be completed.
A callback was chosen, rather than having the stack set
up the data itself, because that the application may
want to add additional data in the periodic advertising,
and thus the owner of the data should be the application,
and not the stack.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The comment definition for pm_policy_latency_request_add
states: states that exceed the given latency are unavailable.
However, the implementation in pm_policy_latency_update_locked
does not use the greater-than operator, so according to the
semantics, it should be changed to > to be consistent.
Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
Fix OBEX abort response handling when no active client exists by
tracking the last executing client and its previous opcode.
- Add _last_client pointer to track the most recent executing client
- Add _pre_opcode to store the opcode before clearing _opcode
- Save client state before clearing opcode in all operation handlers
- Implement obex_get_last_client() to recover client context for abort
- Handle abort responses even when _active_client is already cleared
- Clear last client tracking on transport connect/disconnect
This ensures abort responses are properly delivered to the correct
client callback even if the operation has already completed.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Add validation to detect and handle zero-length data elements during
SDP attribute parsing. When the parsed data element length is zero,
log a debug message and return early to avoid unnecessary processing.
This check is placed after parsing the data element length but before
the nesting level validation, ensuring that:
- Empty data elements are gracefully handled without errors
- The parser doesn't attempt to process or skip zero bytes of data
- Subsequent attribute parsing continues normally
This prevents potential issues when SDP records contain empty data
elements and improves parser robustness when handling malformed or
edge-case SDP attribute structures.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Move the nesting level check to occur after parsing the data element
length instead of before. This ensures that when the maximum nesting
level is exceeded, the parser can properly skip the nested data by
pulling the correct length from the buffer.
Previously, checking the nesting level before parsing the length meant
the parser would return early without consuming the nested data,
potentially causing parsing errors for subsequent attributes.
The updated logic:
- Parses the data element type and length first
- Checks if maximum nesting level is exceeded
- If exceeded, logs a warning and skips the data element entirely
- Otherwise, proceeds with recursive parsing as normal
This prevents buffer misalignment when deeply nested sequences are
encountered in SDP attribute records.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Fix SDP attribute parsing to properly handle nested sequences within
attribute values. Previously, when an attribute value itself contained
a sequence, the parser would not recursively parse the nested sequence,
potentially missing nested attribute data.
Add recursive parsing logic that:
- Detects if the current value buffer contains a sequence type
- Recursively calls sdp_attr_parse() with incremented nest level
- Properly handles nested sequence structures in SDP records
This ensures complete parsing of complex SDP attribute structures that
contain sequences within sequences, such as protocol descriptor lists
or service class ID lists with nested elements.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Extract common GOEP RFCOMM initialization logic into a separate function
to eliminate code duplication between accept and connect paths.
- Add new goep_rfcomm_init() function containing shared initialization:
* MTU calculation and validation
* Transport operations registration
* RFCOMM DLC configuration
* GOEP state setup
- Update goep_rfcomm_accept() to use the new init function
- Update bt_goep_transport_rfcomm_connect() to use the new init function
This refactoring reduces code duplication and ensures consistent
initialization behavior for both server (accept) and client (connect)
code paths.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
Extract common GOEP L2CAP initialization logic into a separate function
to eliminate code duplication between accept and connect paths.
- Add new goep_l2cap_init() function containing shared initialization:
* MTU calculation and validation
* Transport operations registration
* L2CAP channel configuration
* GOEP state setup
- Update goep_l2cap_accept() to use the new init function
- Update bt_goep_transport_l2cap_connect() to use the new init function
This refactoring reduces code duplication and ensures consistent
initialization behavior for both server (accept) and client (connect)
code paths.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
This change ensure that TBS bearers promote dialing -> alerting
independently of GTBS. GTBS no longer blocks the state transitions,
promotion only waits for the bearer's own pending notifications to
clear, preserving notification ordering. GTBS continues to aggregate
the updated state correctly
Signed-off-by: Alex Ciascai <alexandru.ciascai@nordicsemi.no>
If we receive a control point notification with an ASE ID that
does not match any existing streams, i.e. audio_stream_by_ep_id
returns NULL, we should not continue by calling the subsequent
functions like unicast_client_notify_ep_config with a NULL stream.
A single notification may contain multiple ASE IDs; if any of them
are unknown, we can either reject the entire notification, or
we can ignore the specific ASE ID. For now, ignore the
specific ASE ID to do a best effort to continue with
any other changes.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Remove calls to atomic_clear_bit on reads. Even if a characterstic
is read while there is a pending notification, we shall
(as per the MCS spec) still send the notification.
There are 3 special cases for long (string) values, where we
need to know the difference between a changed value (pending
for notification), and a value that has changed since last
read. To support this, these 3 cases now have _DIRTY flags
to indicate that the values are dirty and must be read from
the beginning again.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Mark `settings_nvs_itf` and `settings_zms_itf` as `const` since
they are statically defined interface tables that are never
modified at runtime.
This lets the compiler place them in read-only storage and
trims RAM usage.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Add bounds checking to PTP management interval parameters to prevent
undefined behavior from bitwise shift operations.
The port_timer_set_timeout() and port_timer_set_timeout_random()
functions perform left and right shift operations using the
log_announce_interval and log_sync_interval values as shift counts.
Without bounds validation, these int8_t parameters could be set to
extreme values (e.g., via PTP management messages) that exceed the
valid shift range, causing undefined behavior.
(C11, 6.5.7p3)
> If the value of the right operand is negative or is greater than
or equal to the width of the promoted left operand,
the behavior is undefined
(C++11, 5.8p1)
> The behavior is undefined if the right operand is negative,
or greater than or equal to the length in bits of the promoted
left operand.
Limit both log_announce_interval and log_sync_interval to the range
[-63, 63] using MIN/MAX macros when accepting values from PTP management
frames. This range is preventing shift operations outside
the 64-bit width used in the timeout calculations.
Fixes: GHSA-3v98-458v-388r
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Fix nRF54Lx DTM implementation when using GRTC. The Radio
start needs to be offset by a maximum ISR latency value that
is less than inter-frame switching, plus minimum counter
compare offset that can be set, plus minimum CPU latency to
set the counter compare register.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Use clock startup time from devicetree.
Relates to commit 72dac165d8 ("Bluetooth: Controller: Use
OVERHEAD_XTAL_US from devicetree").
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
The comment for the API pm_policy_latency_changed_subscribe
states: "NULL to disable", but the function implementation
directly saves and subscribes to this node, and subsequently
calls it directly without null checking when changes occur.
This actually poses a risk of calling a null function pointer.
This commit fixes this issue to make the function implementation
consistent with the API description.
Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
Use ARRAY_SIZE macro to determine the size of the pm_constraints
array instead of DT_PROP_LEN. Because a practical issue is that
'zephyr, disabling-power-states' may contain multiple power states,
but one of the power states is in a disabled status. In this case,
the size obtained by DT_PROP_LEN is larger than the actual size.
Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
1. Updated event-related API docs to fix wording and clarify
semantics ("earliest/soonest event", ticks vs cycles).
2. Improve the event implementation to prevent list corruption on misuse:
- pm_policy_event_register() is now idempotent: re-registering
the same evt updates its time instead of appending a duplicate node.
- pm_policy_event_update() / pm_policy_event_unregister() become clean
no-ops if evt is not currently registered.
- Kept a basic evt != NULL assertion.
Signed-off-by: Zhaoxiang Jin <Zhaoxiang.Jin_1@nxp.com>
This file fails to compile since commit ef7b132bfd ("Bluetooth:
Classic: Fix initialization to support re-initialization"), which added
a LOG_ERR() invocation but didn't setup logging for the file.
Fixes#101810
Signed-off-by: Thomas Hebb <tommyhebb@gmail.com>
Align the net_if_ipv6_router_add() behavior with its IPv4 counterpart,
where it is possible to specify whether the router is a default one
instead of making assumptions based on the lifetime value.
The current behavior was likely inspired by the Neighbor Discovery RFC,
where the lifetime parameter of 0 received in the Router Advertisement
message indicates that the router should not be treated as a default
router, however this is an implementation detail of the Neighbor
Discovery protocol and does not need to be enforced at the router API
level, as this can be used outside of this protocol (for example when
router is added manually from the application).
Therefore, allow to specify the "is_default" parameter separately just
like in the IPv4 case.The Router Advertisement handling routine will
just specify the "is_default" value based on the received lifetime
value.
Also, clarify in the function documentation what does it mean to specify
lifetime to 0 (which means the router never expires according to current
implementation).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This change addresses an alignment problem reported by UBSAN by
using a copy of the address. This avoids the need for extensive
rework to support net_if_ipv4_maddr_lookup_raw variant.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
In
d45cd6716bf27a26f9ec
the mayority of this code was changed to use the new native networking
API naming, but one macro was forgotten.
Let's change it now so this code builds also without
CONFIG_NET_NAMESPACE_COMPAT_MODE
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
In d45cd6716b the mayority of the
Zephyr codebased was changed to use the Zephyr native net_ prefixed
types, but some were forgotten.
Without this fix/change the code still builds as we are by now setting
CONFIG_NET_NAMESPACE_COMPAT_MODE. But when this is not set, things
fail to build.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
In d45cd6716b the mayority of this code
was changed to use the Zephyr native net_/zsock_ prefixed types/functions
but some were forgotten.
Let's fix it.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Use the ZTESTABLE_STATIC macro to define symbols which need to be
accessible from ztests, instead of redefining STATIC which causes
trouble with some hals.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Use the ZTESTABLE_STATIC macro to define symbols which need to be
accessible from ztests, instead of redefining STATIC which causes
trouble with some hals.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Use the ZTESTABLE_STATIC macro to define symbols which need to be
accessible from ztests, instead of redefining STATIC which causes
trouble with some hals.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Run the user provided callback for the ISR stacks, instead of ignoring
the callback and printing the summary.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Just for consistency with the code and to avoid finding them on searches,
use the actually used macro names in the log messages.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Add support for CS IPT (Channel Sounding Inline PCT Transfer)
in the Bluetooth host stack.
Changes include:
* definition of new CS IPT HCI opcodes;
* handling of CS IPT control procedures;
* integration with existing CS infrastructure;
* necessary updates to public headers.
Signed-off-by: Aleksandr Mirlenko <aleksandr.mirlenko@nordicsemi.no>
This was a leftover from the previous commit that removed usage of
legacy crypto in favor of PSA API.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
Before this we have a memory leak in the prep_pool when reassembly fails
in :c:func:`att_exec_write_rsp`. Now on error the buffer is dequeued and
freed, as are remaining queued prepare buffers.
Signed-off-by: Kyra Lengfeld <kyra.lengfeld@nordicsemi.no>
The send scheduler formatted LwM2M paths with `lwm2m_path_log_buf()` even
when debug logging was not enabled for the module, causing build issues
with CONFIG_LOG off.
Signed-off-by: Julien Vermillard <julien@clunkymachines.com>
zms_mount_force() behaves like zms_mount() but automatically wipes and
reinitializes the partition if the initial mount attempt fails.
A corresponding Kconfig option SETTINGS_ZMS_FORCE_MOUNT is added to the
settings subsystem to enable this behavior when using ZMS as the
settings backend.
Signed-off-by: Andreas Anderberg <andreas.anderberg@u-blox.com>
Rename it to USB buffers so we can use it in host support without
confusion. Keep the UDC_* macros for now, we can deprecate and remove
them later.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
The implementation only used the receive state's PA sync state
to determine whether to call the PA sync req or PA sync term req,
but that state does not include the syncing state.
Rather than using the receive state's PA sync state, we add a local
boolean to keep track of whether the PA sync was requested, so if
we receive a mod_src with PA sync == BT_BAP_BASS_PA_REQ_NO_SYNC then
we request a termination, even if the PA sync was not established yet.
Some cleanup in the mutex handling was also done as part of this.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Make sure to check packet length check before starting the
IPv4 fragmentation reassembly process. This way we can drop the
malformed packet without consuming resources.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Delete entries in NVS are represented by an ATE with len == 0 and
no associated data.
However, when GC is triggered by a delete operation, the
propagated ATE length may become non-zero due to unconditional CRC
addition, leading to inconsistent semantics and potential mount or
space calculation issues.
Introduce nvs_data_len_with_crc() to centralize the logic of
conditionally adding the data CRC size. This ensures that delete
entries always retain len == 0 and restores consistency across write,
GC and space calculation paths.
Signed-off-by: Lingao Meng <menglingao@xiaomi.com>