When the response has been sent completely to the client, the server
reports the new `HTTP_SERVER_TRANSACTION_COMPLETE` status. Together with
the existing `HTTP_SERVER_TRANSACTION_ABORTED` status, the application
can now also for successful completions of requests clean up any
resources allocated for handling the request.
This especially allows to dynamically allocate the response buffer
passed to the server in the request callback and free it when the
request is done.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Rename enum http_data_status to enum http_transaction_status
to better reflect its purpose, which is to indicate the status of the
overall HTTP transaction, not just data transfer.
Signed-off-by: Tim Pambor <tim.pambor@codewrights.de>
Per RFC9112 (REF #1), HTTP/1.1 server is expected to be backward
compatible with HTTP1.0 request. Mainly HTTP/1.0 does
not support
1) Transfer Encoding : chunked
2) KeepAlives
So, this change will identify the HTTP protocol
version in the request and respond accordingly.
REF#
1) https://httpwg.org/specs/rfc9112.html
Tested:
1) Verified that HTTP/1.1 requests are served as usual
i.e. with chunked transfer encoding and the connection
is a Keep Alive connection
Query exits after 10s, indicating that the client connection to
the HTTP server is a Keep Alive.
```
time printf "GET /telem HTTP/1.1\r\nHost: 192.0.3.11\r\n\r\n" |
nc 192.0.3.11 80
real 0m10.185s <- Indicates connection was kept active for 10s
user 0m0.023s
sys 0m0.023s
```
`Transfer Encoding : chunked` header and chunked encoding
metadata (chunk size hex bytes, crlf, termination byte 0)
are present in the response.
```
HTTP/1.1 200 OK
Transfer-Encoding: chunked <- Chunked encoding header
Content-Type: text/html
3e8 <- Chunk size hex bytes
:
/health/secondsdevice_ae:9a:22:48:0f:70"seconds0
+
/health/locatedevice_ae:9a:22:48:0f:70"0
/
/network/mac-addressdevice_ae:9a:22:48:0f:70"
.
.
.
3e8 <- Chunk size hex byte
_PLUS_rawdevice_ae:9a:22:48:0f:70"0
6
/dev/ISHARE_CBU_MINUS_rawdevice_ae:9a:22:48:0f:70"0
.
.
.
/dev/part_iddevice_ae:9a:22:48:0f:70"0���������
,
/dev/part_typedevice_ae:9a:22:48:0f:70"0
7
/dev/part_telemetry_disabledevice_ae:9a:22:48:0f:70"0
0 <- Termination Byte 0
```
2) Verfied that HTTP/1.0 requests are served with
response without chunked transfer encoding and the
connection is closed immediately.
Query exits immediately indicating the connection is closed immediately
```
time printf "GET /telem HTTP/1.0\r\nHost: 192.0.3.11\r\n\r\n" |
nc 192.0.3.11 80
real 0m0.186s <- Indicates connection was terminated immediately.
user 0m0.018s
sys 0m0.030s
```
`Transfer Encoding : chunked` header and chunked encoding
metadata (chunk size hex bytes, crlf) not present in the
response
```
HTTP/1.1 200 OK
Content-Type: text/html
:
/health/uptimedevice_ae:9a:22:48:0f:70"seconds0
+
/health/locatedevice_ae:9a:22:48:0f:70"0
/
/network/mac-addressdevice_ae:9a:22:48:0f:70"
.
.
.
3
/dev/part_iddevice_ae:9a:22:48:0f:70"0���������
,
/dev/part_typedevice_ae:9a:22:48:0f:70"0
7
/dev/can_telemetry_disabledevice_ae:9a:22:48:0f:70"0
```
Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
This commit aims to declare and call NAT64 functions used by Border
Router application only if corresponding flag is also set.
Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
Add a check to drop ipv4 multicast packets that are not matching any
currently registered multicast group for the interface that received
them.
Signed-off-by: Fabio Baltieri <fabiobaltieri@google.com>
After iface was link up, the IPv4 multicast address was added to iface
repeatly. This patch is to fix this.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Disable the automatic handling of the `NET_EVENT_IF_UP` event when the
WPA supplicant is enabled, as the supplicant already explicitly calls
`net_dhcpv4_restart` when the interface is ready for use. This fixes
the DHCP binding process being restarted before the interface is ready
(after `NET_EVENT_IF_UP`, before authorization), which always fails.
Signed-off-by: Jordan Yates <jordan@embeint.com>
Use the same function to parse all records. The main difference is that
answer record handling matches the answer with the initial query, i.e.
AAAA query will have AAAA answer record. Additional records do not have
any matching with the original query.
Also just warns if an additional record parsing fails. But answer record
parsing is an error.
Tested on BeagleConnect Freedom
Signed-off-by: Ayush Singh <ayush@beagleboard.org>
As described in Section 12 of RFC 6763 [0], DNS-SD responses can contain
SRV, TXT and A/AAAA under additional records. This is done even in the
zephyr DNS service advertisement. So these additional records should be
passed to the user for handling.
Most of the code for additional records is taken from normal dns answer
unpacking. However, I have split the handling into a separate function
since I have only added additional records handling for DNS-SD. The same
code should be usable for answer record as well if required. The main
thing missing from additional record code is that we do not need to
match the query type to the response type.
Tested on BeagleConnect Freedom.
[0]: https://datatracker.ietf.org/doc/html/rfc6763.html#section-12
Signed-off-by: Ayush Singh <ayush@beagleboard.org>
The hard coded 2s timeout might be too small for LTE and Nb-IoT
networks.
Instead use already existing CONFIG_NET_SOCKETS_DNS_TIMEOUT
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Add a parameter to MQTT TLS configuration that allows to force native
TLS on a socket if offload dispatcher is used. This allows for MQTT to
use native TLS implementation with an offloaded TCP socket.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Since d45cd6716b this code does not use
types defined in the POSIX_API and therefore we do not need to work
around header include issues.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
The DNS-based Service Discovery has the following abstract:
This document specifies how DNS resource records are named and
structured to facilitate service discovery. Given a type of service
that a client is looking for, and a domain in which the client is
looking for that service, this mechanism allows clients to discover
a list of named instances of that desired service, using standard
DNS queries. This mechanism is referred to as DNS-based Service
Discovery, or DNS-SD.
As is stated here, DNS-based service discovery is designed to find all
instances implementing a service, not just the first one.
Currently, zephyr `dns_resolve_service` will call the callback for only
the first client instance found. It still does receive the responses
from other instances, but those are dropped since the query is already
marked as finished. The seems incorrect behavior.
With that said, the changes in this commit are API breaking, since even
the docs already state that only the first response is currently used.
So I am fine with creating a new function for discovering all instances
if that is more acceptable.
Since DNS-SD queries expect multiple responses, timeout or manual
cancellation are the only methods to stop an in-flight request. When a
timeout happens, the callback is called with one of the following
responses:
- `DNS_EAI_ALLDONE`: If at least one successful response was received.
- `DNS_EAI_CANCELED`: If no successful response was received.
Tested with 3 BeagleConnect Freedoms (2 running mdns_responder and 1
running dns_resolve sample).
Signed-off-by: Ayush Singh <ayush@beagleboard.org>
Adds CONFIG_ETH_NET_IF_NO_AUTO_START to allow
pre-configuration of Ethernet interfaces (e.g., filters, mac)
before they become operational. When enabled, net_if_up() must be
explicitly called by the application.
Signed-off-by: Jeremy Truttmann <jetstreeam.code@outlook.com>
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 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 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>
Remove duplicated #include directives within the same
preprocessor scope across the Zephyr tree.
Duplicates inside different #ifdef branches are preserved
as they may be intentional.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
The CONFIG_DNS_RESOLVER_MAX_NAME_LEN should be large enough so that
IPv6 address can be stored into it. So increase the max name length
to 46 if IPv6 is enabled.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The MQTT-SN v1.2 [0] specification specified the GwAddr as follows:
The GwAdd field has a variable length and contains the address of a GW. Its
depends on the network over which MQTT-SN operates and is indicated in the
first octet of this field. For example, in a ZigBee network the network
address is 2-octet long.
It specifies neither the possible values for the first octet, nor the
format of the network-specific address that follows. Thus, the
specification is incomplete and this functionality unusable.
I also wasn't able to find any implementation which implements a gwinfo
message where the address length is not zero. This includes
https://github.com/eclipse-paho/paho.mqtt-sn.embedded-c .
The current implementation in Zephyr simply copies a `struct sockaddr`
into GwAddr. This is a bad idea for many reasons, the most important one
being that the format is not even specified by POSIX [1]. They only say,
which defines must exist, not what their values are. And in fact, these
even differ between Zephyr and Linux.
Thus, I think it's best to remove the implementation to prevent people from
using this, which may even lead to memory safety issues, depending on the
length of CONFIG_MQTT_SN_LIB_MAX_ADDR_SIZE. If we were to receive an
updated specification, all we'd have to do is to convert between `struct
sockaddr` and mqtt-sn addresses both ways.
[0] https://groups.oasis-open.org/higherlogic/ws/public/download/66091/MQTT-SN_spec_v1.2.pdf
[1] https://pubs.opengroup.org/onlinepubs/9799919799/basedefs/sys_socket.h.html
Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
Honor the comment in the code and make sure RX is started
before TX so that we can receive responses to any data we
are sending.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
When Ethernet is enabled, `net_config_init_app` function will use the
first found interface that has auto start enabled. In this particular
case, backbone interface will not be able to perform dhcp request
because OpenThread interface gets to be the first interface found
and chose. Openthread will fail this procedure, as it has no
direct connectivity to backbone.
This is why, ethernet app has `CONFIG_IEEE802154_NET_IF_NO_AUTO_START`
set.
In this case, make sure to call net_if_up for OpenThread interface from
border router code when backbone events are triggered.
Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
Use the newly added API to get specific type of stats (if supported) but
also keep the backwards compatibility.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
Add a new API that takes stat type, the networking stack only needs
NATIVE stats per-packet, it doesn't need to update vendor stats
per-packet. This saves unncessary exchanges in case driver needs to
query the firmware for the vendor stats.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
In d45cd6716b the mayority of the Zephyr
networking code was changed to use the Zephyr native net_/zsock_
prefixed types, but some symbols were forgotten.
Let's change them.
Without these fixes/changes the code still builds in most cases as we are
by now setting CONFIG_NET_NAMESPACE_COMPAT_MODE.
But when this is not set, things will fail to build.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
802.15.4 specifies that a device may send a DATA_REQUEST command to the
coordinator after waiting for "macResponseWaitTime", starting after the
acknowledgment to the association request command.
This change adds support to generate DATA_REQUEST frames and sends one
for the association usecase only. The two other usecases, for MLME-POLL
or for beacon-enabled PAN, are not yet supported.
Signed-off-by: Simon Piriou <spiriou31@gmail.com>
WS_MAGIC is a constant string and when calculating lengths for copying
we always exclude the NULL terminator. In result, using strncpy() for
copying can generate a warning about truncated string, as WS_MAGIC will
always be truncated from the NULL terminator. Therefore replace
strncpy() with memcpy() as it seems more appropriate for this case.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commit aims to make use of sin6_scope_id field of net_sockaddr_in6
structure to correctly choose the network interface when destination
address in link-local.
Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
Introduce the optional OMA 10523/10524 send scheduler extension to manage
cached resources, including control and sampling rule objects, cache
filter with gt/lt/st and pmin/pmax handling, max-age/max-sample limits,
and registration flush helper.
Add an overlay to the LWM2M client sample.
Add a fake humidity sensor.
Signed-off-by: Julien Vermillard <julien@clunkymachines.com>
Allow passing some context to the shell bypass callback function by
providing a void pointer user data argument.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
A race condition was observed with concurrent net_context_get()
and net_context_unref() calls: If net_context_unref() is interrupted
just after clearing the NET_CONTEXT_IN_USE flag, net_context_get() may
try to reuse the context and reinitialize its mutex through
k_mutex_init(). Once net_context_unref() resumes, it calls
k_mutex_unlock() on the newly initialized mutex, which may lead to the
following assertion:
ASSERTION FAIL [mutex->lock_count > 0U] @ zephyr/kernel/mutex.c
Fix this by unlocking the context mutex before clearing the
NET_CONTEXT_IN_USE flag.
Signed-off-by: Marco Widmer <marco.widmer@bytesatwork.ch>
The variable 'unspec_addr' in net_dhcpv6_init() is implicitly
initialized on some platforms and optimization levels, but not
guaranteed to be initialized on all code paths when built with
compiler instrumentation.
This leads to a build failure with the strict
'-Werror=maybe-uninitialized' warning when code coverage flags are
enabled (e.g., via twister --coverage).
```
zephyr/subsys/net/lib/dhcpv6/dhcpv6.c:2325:26: error: ‘unspec_addr’
may be used uninitialized [-Werror=maybe-uninitialized]
net_ipaddr_copy(&net_sin6(&unspec_addr)->sin6_addr,
```
Signed-off-by: Nikhil Namjoshi <nikhilnamjoshi@google.com>
Verify that the interface is in operational UP state before attempting
to send the packet with net_send_data() / net_try_send_data().
So far there's only been an NET_IF_LOWER_UP check in a lower level
function, net_if_try_send_data(), however that didn't work well with
interface like Wi-Fi, whouch could have carrier state set to ON, but
was still not associated with the network (so the interface was no
operational UP). Protocols like ICMP or DHCP, which use net_send_data()
directly, should not be able to send packets in such case.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Dropping packet is normal operation when iface is down.
So, we don't have to use warning here for much noise.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Ethernet bridge performs L2 forwarding between bridged interfaces.
But for the virtual bridge interface, we could make it perform as
normal Ethernet interface with IP address to use.
This is useful allowing applications to communicate with network,
like LAN router or switch with a host IP.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Current bridge function is very simple which does forwarding for all
packets. There will be more and more features of bridge RX handling.
Let's move bridge RX handling to bridge_input.c for next IPv4/IPv6
protocols support for virtual bridge interface.
And currently there is no path to call bridge_iface_recv function.
Let's rework it for proper function returning NET_CONTINUE.
Also fixed another issue of link local address checking. Because
net_linkaddr structure changed. So fixed
is_link_local_addr((struct net_eth_addr *)net_pkt_lladdr_dst(pkt))
to
is_link_local_addr((struct net_eth_addr *)(net_pkt_lladdr_dst(pkt)->addr))
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>