Original code developed as a GSoC 2023 project by Emna Rekik.
Code refactored in order to provide better bisectability
as the origical commits were not bisectable.
The server supports static and dynamic resources, managed by
HTTP_SERVICE/HTTP_RESOURCE macros.
Fixes#59685Fixes#59686Fixes#59688Fixes#59690Fixes#59670Fixes#59700Fixes#59684Fixes#59693Fixes#59693Fixes#59694Fixes#59699Fixes#59696Fixes#59688Fixes#59690Fixes#59670Fixes#59700Fixes#59685Fixes#59686Fixes#59688Fixes#59691
Signed-off-by: Emna Rekik <emna.rekik007@gmail.com>
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Add HTTP/2 helper libraries to encode and decode HPACK encoded headers,
according to RFC7541.
HPACK string encoding requires to support certain set of Huffman codes,
therefore implement Huffman encoder/decoder as well.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case of successful submission, the reference shouldn't be put down,
this only should done on error cases.
As reference is put down on success, during the buffer unref, no action
is taken due to an uint8 overflow (ref is now 255), so, the buf->frags
isn't cleared properly and the next time the frags is used and when L2
inserts a second frag, the first head frag and next frag are same (due
to buffer re-use) causing an infinite loop in either net_buf_frag_last
or net_pkt_get_len.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Unicast RX stats
It represents total number of unicast (any type data, action or
any other unicast frames) frames received at firmware level.
The actual frames passed to host will be different as firmware
may drop packets or some packets may be dropped because of
errors.
Unicast TX stats
Transmission side the unicast packets count states the packets
handed over to firmware. The stats taken at firmware level.
Actual packets transmission may vary depending upon various factors.
Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
We were missing a helper function that can be used to check
whether the given function is the virtual VLAN interface.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Use lock while accessing nm data.
One of the use case is while setting regulatory, it accesses nm data,
while from some other place also it can be accessed same time.
Protected the nm data processing.
Signed-off-by: Ajay Parida <ajay.parida@nordicsemi.no>
Work items on the syswq should always run-to-completion.
Override the timeout value to always be K_NO_WAIT.
Allocating with K_FOREVER leads to deadlocks if the freeing also happens
from the syswq. Non-zero timeouts are also not nice for the other users
of the syswq.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
Even though we are passing mandatory args from the shell registration,
due to use of getopt the check can be bypassed without the hyphenated
options.
So, enforce and fail if mandatory parameters aren't passed through
getopt.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Adds a config that enables sending the object version for all objects.
According to LwM2M specification v1.0 and v1.1, non-core object versions
other than 1.0 'must' be provided, while all other versions 'may' be
provided. With specification v1.2, a client 'can always attach Object
Version Information'. Or in other words, it is OK to always report the
object version with all specifications.
Signed-off-by: Andreas Rudolf <andreas.rudolf@husqvarnagroup.com>
Updates the linker script fragments under 'subsys' to use
Z_LINK_ITERABLE_SUBALIGN for the subalignment instead of
a hardcoded value of 4.
Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
The IPv6 address lifetime timers are kept in a slist, but
the code that adds the entry to the list does not check
whether the item is already in the list. This will cause
problems when trying to remove the address from the list.
Normally this is not causing issues, but if the function
net_if_ipv6_addr_update_lifetime() is called multiple times
before the address expires, then the item was added to the
slist multiple times.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Applications need to run a scan to identify the security
mode before attempting the connection which adds to the time
taken for connection to be established.
To avoid the initial scan, support auto security mode which will
enable STA to choose between WPA, WPA2 and WPA3, based on the
network configuration.
Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
Since `NONE` is a valid option for key management in `connect`
command, we should remove the part in help text which says:
"valid only for secure SSIDs".
Signed-off-by: Ravi Dondaputi <ravi.dondaputi@nordicsemi.no>
This commit change a method of printing multicast routes by showing
all interfaces per entry instead of aggregating them by interface.
Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
In order to save memory, a single multicast routing entry now
contains configurable number of network interfaces.
Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
This commit adds a check to determine if the packet wasn't already
forwarded to a given interface.
Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
This commmit changes the way of iterating over multicast routing
entries from explicit for-loop to ARRAY_FOR_EACH_PTR().
Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
The commit 8256d02d3a introduced
getopt parsing for the wifi connect command
This needs to be updated for the wifi ap enable since ap
enable also uses the same parsing as connect.
The use of getopt removes the parameter ordering restrictions
Signed-off-by: Brad Kemp <brad@beechwoods.com>
In case FIN packet included data bytes, Zephyr would ignore the
data. It wasn't passed to the application, and it wasn't considered
when bumping the ACK counter. This ended out in connection timing out,
instead of being properly terminated.
Fix this, by refactoring FIN processing in TCP_ESTABLISHED state.
Instead of handling FIN/FIN,ACK/FIN,ACK,PSH cases separately, have a
common handler when FIN flag is present, and when ACK flag is present
along with FIN. When FIN is present, take any potentially incoming data
into account.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Allow changing the CoAP Block-wise transfers block-size
for subsequent GET requests.
It looks like Leshan switches block size back to its
configured value, if it is smaller.
So even when we send block N=0 with size of 512, Leshan
seem to handle that properly but still asks N=2 with
block size 256(if that is configured).
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Minor improvements to usage of zperf_shell upload.
Added common defaults for the upload commands arguments.
Print defaults in cmd help.
Throw warning when user sets baud rate for TCP upload.
Signed-off-by: Adam Matus <adam.matus@nxp.com>
The network interface parameter for net_eth_get_vlan_tag() should
be the VLAN interface so use the search loop properly.
Earlier the main interface could be checked.
Add also test cases for this so that we can catch that the func
works properly.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add more error logs in case of (mostly) mbed TLS errors, so it's easier
to get an initial idea of what went wrong based on logs only. Getting
an information on an actual mbed TLS error code is quite helpful in such
cases.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Block size is a 3-bit value mapping values [0, 6] to powers of 2 in the
range [16, 1024]. Value 7 is invalid.
The previous formula was not working in case the client's preferred size
was 4 (or more) times bigger than the server's.
This commit takes into account also the case the client's preferred size
is smaller than the server's.
Signed-off-by: Marco Argiolas <marco.argiolas@ftpsolutions.com.au>
Remove IPSP support from the tree.
It has no maintainers, and is regularly broken. The fact that it's
nontrivial to set-up in linux makes it hard to fix reported issues.
Signed-off-by: Jonathan Rico <jonathan.rico@nordicsemi.no>
The "struct sockaddr" should only be used in casts and never
as a standalone variable because it might not have enough
space allocated for all the protocol specific fields.
So refactor the port_in_use() function to reflect that.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
errno values are positive, therefore they should be negated when
assigned as return values for net_dhcpv4_server_start().
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The commit adds dependency on Kconfig FLASH_PAGE_LAYOUT to subsystems
that really require it:
FCB, NVS, LittleFS
and removes direct selection from '*.conf' files where no longer
needed.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
Check if the interface is down before joining IPv4 mDNS multicast
group. This avoids warning later when the network packet cannot be sent.
Fixes#71121
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Commit e99b5228a1 changed the default
networking behavior on qemu platforms, as the SLIP_TAP driver no longer
selected Ethernet L2. In results, qemu platforms in default
configuration had no network interface to work with.
Fix this, by restoring select for NET_L2_ETHERNET, but this time in
NET_SLIP_TAP. The difference is that SLIP_TAP is a generic driver
config, which could be enabled on any platform, so not changing the
behavior here, while NET_SLIP_TAP is a config dedicated for qemu only,
so it's reasonable to enable all that's needed to get SLIP to work with
qemu by default.
As there were circular Kconfig dependencies, move the respective qemu
configs outside of NET_RAW_MODE if block (as this caused the circular
dependency with ETH_DRIVER_RAW_MODE). Also, remove dependency to
NET_L2_BT, as it made little sense there, and also caused dependency
problems.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
There is no limitations for dwell time. Just add
valid condition for positive value. So , it's better
to remove those constraints.
Signed-off-by: Kapil Bhatt <kapil.bhatt@nordicsemi.no>
Running out of connection contexts is most likely due to app
misconfiguration, therefore it's useful to get an explicit information
that context allocation failed.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Correct various small edge-case behaviors that have been accidentally
introduced in the http_client.
- http_client_req no longer incorrectly returns -ETIMEDOUT on NULL HTTP
resonse. -ETIMEDOUT is now only returned when the underlying TLS
socket times out.
- http_client_req now returns -ECONRESET upon incomplete (but non-NULL)
HTTP response. The request callback is no longer called in this case
(as with any other error state).
- http_wait_data has been refactored slightly to increase clarity.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
If the packet cloning fails (can easily happen when working with
loopback interface and when having low net_buf count), then
print a warning to the user. Error could also be possible but
as the situation might correct itself in this case, the warning
should be enough.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If we fail to join all nodes or solicit node multicast groups
when the interface is down, then there is no need to print an
error message. The groups are automatically re-joined when the
interface comes up.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If user created the capture device using the API and not via
the shell, then the device name was not set. Use the default
capture device in this case.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The event NET_EVENT_CAPTURE_STARTED is generated when the
capture is enabled, and NET_EVENT_CAPTURE_STOPPED when capture
is disabled.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The net_capture_pkt() does not return information what happened
to the net_pkt because the packet was always cloned. With cooked
capture we can avoid the cloning in which case we need to know
the capture status in order to unref the packet if needed.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add support for capturing arbitrary data via the cooked mode (sll)
capture API. The actual packet capture is done using net_capture_data()
function, the packet capture infrastructure does not need any changes.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Allow user to create a kitchen sink pseudo a.k.a any network
interface that one is only able to write to. This might seem
unnecessary, but it is possible to attach virtual network
interfaces on top of this pseudo interface. These virtual
interfaces could then process the data for example for
packet capture purposes.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
For debugging purposes it would be nice to see the verdict
printed as a string instead of number.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add a recv callback to dummy API. After this it is possible to
receive data by a dummy network interface. This is only useful
if one attaches a virtual interface on top of the dummy one.
One such example is the cooked mode capture interface.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit fixes an issue where due to inverted logic (static function
returned 0 on success but the caller expected true/false) the MLDv2
reports were silently dropped.
Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>