Most set functions have a get function as well, add the missing
function to get the set gateway IPv4 address.
Signed-off-by: Bas van Loon <basvanloon@betronic.nl>
Refactor. The deferred work is rescheduled just after it's canceled.
This is hopefully equivalent to just the reschedule, so the cancel can
be removed.
Signed-off-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Refactor shell output macros to minimize caller overhead by eliminating
direct `color` parameter passing:
- Introduce wrapper functions: `shell_info_impl`, `shell_print_impl`,
`shell_warn_impl`, `shell_error_impl`.
- Replace `shell_fprintf` in macros with these new wrappers.
- Update `shell_hexdump_line` to use the new wrappers,
minimizing caller overhead.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
If we receive multiple DNS servers via DHCP only the first one is used,
regardless of CONFIG_DNS_RESOLVER_MAX_SERVERS constant.
Parse DHCP option and save addresses that fit
Signed-off-by: Andrey Dodonov <Andrey.Dodonov@endress.com>
The broadcast assistant will only be able to send
BT_BAP_BASS_PA_REQ_SYNC_PAST if
CONFIG_BT_PER_ADV_SYNC_TRANSFER_SENDER is enabled.
Similarly the scan delegator will only set
past_supported = true if
CONFIG_BT_PER_ADV_SYNC_TRANSFER_RECEIVER is enabled.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Refactors teh BIS bitfield values used for ISO
and BAP.
Previously BIT(1) meant BIS index 1, which was a Zephyr choice
in the early days of ISO, as the BT Core spec did not use
a bitfield for BIS indexes.
Later the BASS specification came along and defined that
BIT(0) meant BIS index 1, which meant that we had to shift BIS
bitfields between BAP and ISO.
This commit refactors the ISO layer to use BIT(0) for Index 1 now,
which means that there is no longer a need for conversion
between the BAP and ISO layers, and that we can use a value
range defined by a BT Core spec (BASS).
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
The Softdevice Controller now sends the disconnect event only after
receiving all Host Num Completes for the packets it sent to the host.
This is done for security reasons.
In our current reassembly logic, it does not really matter when we
withhold the num complete.
Before this patch, it's the first fragment that is withheld, and after
the patch it will be the last fragment that is withheld until the host
is done processing.
The flow control properties are maintained, just in a different way.
Co-authored-by: Aleksander Wasaznik <aleksander.wasaznik@nordicsemi.no>
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
The functionality is moved in preparation of the next commit which will
re-use this function from somewhere else.
Also add (default-on) asserts that we are able to allocate and send the
command. If that is not the case, we will leak buffers from the PoV of
the controller, leading to a stall in data transfer.
Depending on the error, we could probably recover using a disconnection.
For now, do the safe thing and stop the whole stack.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
The spec only guarantees the connection complete event parameters
are valid if the status is BT_HCI_ERR_SUCCESS. When the status is
not BT_HCI_ERR_SUCCESS, the host shall ignore the other parameters.
See Vol 4, Part E, 4.5 Command error handling:
"""
If an error occurs for a command for which an HCI_Command_Complete event
is returned, the Return Parameters field may only contain some of the
return parameters specified for the command.
...
The above also applies to commands that have associated command specific
completion events with a Status parameter in their completion event, with
the exceptions shown in Table 4.1, Event Valid parameters
...
Event | Valid parameters
------------------------------------------------------------
LE_Connection_Complete | none
LE_Enhanced_Connection_Complete | none
"""
Refactor `le_legacy_conn_complete`, `le_enh_conn_complete_v2` and
`le_enh_conn_complete` to check and handle the status before handling
any other parameters.
An issue was seen where SDC returned event with status
`BT_HCI_ERR_UNKNOWN_CONN_ID`, but because adv_handle and sync_handle
were not invalid the event was not handled.
Signed-off-by: Sean Madigan <sean.madigan@nordicsemi.no>
Several refactors and improvements for `net_bytes_from_str` as follows:
- Replaced manual hex digit checks with `isxdigit()`.
- Changed variable `i` from unsigned int to size_t for consistency with
the `strlen()` return type.
- Added `src_len` to store the result of `strlen(src)` to avoid
multiple calls to `strlen` in the `for-loop`.
- Ensured casting to `unsigned char` before passing to `isxdigit()` to
prevent undefined behavior.
- Explicitly cast the result of `strtol()` to `uint8_t` to match
the buffer type.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
In case POLLIN is set, and no new application data has been detected,
the ztls_poll_update_ctx() should only return -EAGAIN if no other events
are available for the socket. Otherwise, the function may end up
busy-looping, in case for example POLLOUT is also monitored for the
socket.
Current check verifying that was wrong, as it caused to function to
return -EAGAIN even if some other events could've been reported for the
socket.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
If the application is not explicitly scanning, then there is not
really any need to parse advertising reports nor send them to the
application.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Fix Advertising PDU memory allocation for redundant Periodic
Advertising related PDU allocations. The buffer count
related to Periodic Advertising was included twice.
Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
Fix the NM iface type check error, should use (1 << WIFI_TYPE_STA),
instead of WIFI_TYPE_STA. Same for WIFI_TYPE_SAP.
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
When implementing vendor specific HCI APIs and events,
we want to be able to convert between host objects,
handles and back again.
Exposing this API makes that possible
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
When implementing vendor specific HCI APIs and events,
we want to be able to convert between host objects,
handles and back again.
Exposing this API makes that possible.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
When implementing vendor specific HCI APIs and events,
we want to be able to convert between host objects,
handles and back again.
Exposing this API makes that possible.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Fix compilation error implicit declaration of function 'free'
in case of `CONFIG_NEWLIB_LIBC`.
Signed-off-by: Dmitrii Golovanov <dmitrii.golovanov@intel.com>
Change USBD_CONFIGURATION_DEFINE macro to take the address of a string
descriptor node as an argument. This is a breaking change for macro
users, but quite convenient and easy to implement.
Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
TBS had 2 cases where 16-bit values were not properly
converted to LE before being sent over air.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
Changes include:
- Introducing a local `ctx` variable to replace multiple
`sock_ctx[i]` references.
- Using a local `revents` variable to simplify repeated
`sock_fds[i].revents` checks.
- Consolidating conditional checks for socket events
(ZSOCK_POLLERR, ZSOCK_POLLNVAL, and ZSOCK_POLLHUP) as they are
individual bit definitions, allowing them to be checked simultaneously.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
In the send_ipv4_fragment function, if net_pkt_get_data returns
fail, a tx_pkts slab leak will occur. If leak exceeds the
maximum number CONFIG_NET_PKT_TX_COUNT of tx_pkts slab, tx_ptks
will be used up, and the related modules(dhcp, ping and so on)
of net cannot alloc tx_pkt slab, and will sleep and can not
return successfully until available slab.
dhcp work or ping work cannot be executed beacause can't alloc
memory, and ping command cannot return, console also fails to
input commands, and the console hang problem occurs.
Signed-off-by: Gaofeng Zhang <gaofeng.zhang@nxp.com>
When IPv6 packet is received, there is a check of the packet's source
address to verify that it is not interface's non-tentative address.
This commit moves this check to the later stages of processing as
packets that can be routed are dropped in the early stage otherwise.
Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
If the packet was routed between interfaces by IPv6 module it should
not be looped back but has to be passed to the destination interface
instead.
Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
When a packet's transmission is prepared and Neighbor Solicitation is
sent its souce address is always the same as of a packet awaiting -
also for packets routed from an other interface.
Quote from the RFC:
If the source address of the packet prompting the solicitation is the
same as one of the addresses assigned to the outgoing interface, that
address SHOULD be placed in the IP Source Address of the outgoing
solicitation. Otherwise, any one of the addresses assigned to the
interface should be used.
This commit fixes the behavior.
Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
Before packet is routed there is a check verifying if the destination
address is not the device's one. However, the check should be limited
to the packet's original interface. Otherwise, packet cannot be routed
if it is destined for an other interface of the device.
Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
Enable hostname verification in DTLS handshake when server URI contains
valid hostname.
When URI is given just as IP address, don't fill up the
ctx->desthosname or enable hostname verification.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
The memory allocation for socketpairs is not conformant to the new
MEM_POOL_ADD_SIZE_ mechanism for allocating heap memory.
Specifically CONFIG_NET_SOCKETPAIR_HEAP can not be selected unless
the user has specified CONFIG_HEAP_MEM_POOL_SIZE. We should be
using MEM_POOL_ADD_SIZE_ to add to the heap if the user wants to
use it for socketpair allocation.
Additionally increase the size of pre-allocated sockets to 8 from 1
to support larger devices by default, taking into consideration the
required socketpairs and buffer sizes when using
WIFI_NM_WPA_SUPPLICANT.
Signed-off-by: Bjarki Arge Andreasen <bjarki.andreasen@nordicsemi.no>
Introduce a more generic mutex for protecting coap_client structure.
This allows to avoid a certain race condition when sending consecutive
CoAP requests. The case was, that when a CoAP receive thread notified
the application that a complete response was received, and the
application wanted to send another request from the application thread,
the consecutive call to coap_client_req() might've failed if the
application thread has higher priority than the CoAP receive thread
because of the request context cleanup is done after calling the
application callback.
Having a mutex, which is locked while processing the response, and when
attempting to send a new request allows to synchronize threads as
expected.
As this new mutex seemed redundant with the more specialized send_mutex
already present in the coap_client, the latter was removed (i. e.
transmission is also protected with the new mutex).
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The standard does allow for a optional beacon payload, which gets lost
during scan, that could be interesting for the application to access
in the NET_EVENT_IEEE802154_SCAN_RESULT callback.
See section 7.3.1.6 in IEEE Std 802.15.4 for more information about
the beacon payload field. And section 7.3.1 and figure 7-5 about general
beacon frame format.
Signed-off-by: Fabian Pflug <fabian.pflug@grandcentrix.net>
Add a zephyr/printk.h header for the __printk_hook functions, these are
currently manually declared by all console drivers for no good reason.
Move the documentation into the header and also unify the way that
console drivers call the function.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
When running dhcp, it was not assigning gateway/router
address to the client devices. It is fixed in this PR.
Signed-off-by: Muhammad Munir <muhammad.munir@zintechnologies.com>
Make sure we are not accessing NULL pointer when checking
if the IPv4 mapping to IPv6 is enabled.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The BR SMP fixed channel BR/EDR Security Manager
(CID 0x0007) cannot be set in L2CAP Information
Response. It is caused by the invalid fix channel
definition used.
Move macro `BT_L2CAP_BR_CHANNEL_DEFINE` to
`l2cap_br_interface.h`, that the macro can be
accessed in smp.c. And remove duplicated
header file include `#include "classic/l2cap_
br_interface.h"` from smp.c.
Define fixed channel, BR/EDR Security Manager
(CID 0x0007), by using `BT_L2CAP_BR_CHANNEL_DEFINE`.
Fix the smp L2CAP channel of BR cannot be found
issue. Use `bt_l2cap_br_lookup_tx_cid` to get
the BR SMP L2CAP channel instead of using
`bt_l2cap_le_lookup_tx_cid`.
Fix the invalid SMP L2CAP channel used when
the BR smp failed.
Signed-off-by: Lyle Zhu <lyle.zhu@nxp.com>
The function `bt_hci_le_past_received_v2()` is not compiled
in for this configuration, so the reference needs to be removed.
Fixes#76268.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
Some HCI drivers issue HCI reset when disabling, like the IPC HCI
driver. We need to keep the RX thread running to allow receiving
the command complete.
This commit postpones aborting the RX thread until this is done.
The issue happens started occuring after commit
d0e75ab87c4b53d66008c941c38709a2fca9dbea.
Fixes#76202.
Signed-off-by: Rubin Gerritsen <rubin.gerritsen@nordicsemi.no>
PM_DEVICE_RUNTIME_EXCLUSIVE was deprecated and its behavior
is achived with PM_DEVICE_SYSTEM_MANAGED=n.
Fixes#76037
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
As the items come from the memory slab, their initialization state
can't be guaranteed. This is causing some devices triggering an assert
in p4wq where the item's thread is not null (not zero).
Signed-off-by: Luis Ubieda <luisf@croxel.com>
`struct acl_data` is used even when Host flow control is not enabled.
It is written to through the `acl(buf)` accessor in `conn.c:hci_acl()`.
Hopefully no netbufs were harmed by that :/
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within the `subsys/net/lib` directory.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within the `subsys/net/l2` directory.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within the `subsys/net/lib/lwm2m` directory.
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
Add missing documentation for some defintions in tbs.h
Moved some internal definitions to tbs_internal.h
Removed invalid TBS technology BT_TBS_TECHNOLOGY_IP that
doesn't exist.
Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>