The work in Ethernet send in commit 2f10d7d816
("net: ethernet: Set the ptype by the caller in send")
introduced a bug because we could try to do ARP resolving
for ARP packets too. This is clearly a wrong thing to do.
So before trying to do ARP resolving, make sure the the
packet type is IP packet.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Only reserve L2 header for TX case when allocating net buffer,
as for RX case, all the received headers are already in linear
buffer when the driver receives the data, and reserve extra L2
header for RX case may exceed the default buffer size.
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
When defined both CONFIG_NET_BUF_POOL_USAGE and
CONFIG_MEM_SLAB_TRACE_MAX_UTILIZATION, support using 'net mem' cmd
to get the maximum count of used buffers and net packets.
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
Allow user to specify protocol extensions when receiving data
from Ethernet network. This means that user can register L3
protocol handler using NET_L3_REGISTER() with the desired
protocol type. Ethernet code will then call the handler if
such a protocol type packet is received. This is currently
only implemented for Ethernet. The original IPv4 and IPv6
handling is left intact even if they can be considered to
be L3 layer protocol. This could be changed in the future
if needed so that IPv4 and IPv6 handling could be made
pluggable protocols.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Replaced the k_pipe-based implementation in sockpair with ring_buffer
based implementation instead.
The move to ring_buffer is done to avoid overhead of k_pipe and to align
with the new k_pipe API.
This does not pose any added risk to concurrency as the read and write
functions are protected by semaphores for both spairs.
Signed-off-by: Måns Ansgariusson <Mansgariusson@gmail.com>
Content-Range functionality added in recent commits has been propagated
to http_client module. If "Content-Range" string is detected on header
field, Content-Range are returned via http_response structure.
Signed-off-by: Piotr Radecki <piotr.radecki@jrdltd.co.uk>
Content-Range hasn't been supported in zephyr. This change adds
Content-Range header parsing to http_parser module. Range start,
range end, and total size are supported. All units are currently
interpreted as bytes.
This is much needed change, because many applications responsible
for http data download are based on Content-Range approach.
Signed-off-by: Piotr Radecki <piotr.radecki@jrdltd.co.uk>
Instead of setting the upper protocol type in ethernet_send()
by checking the protocol type bits, use the ptype that is already
set by the caller. This allows new protocol types to be supported
and makes the system extensible.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Template string for HTTP 1.0 500 response expects content length as a %d
but was getting passed a 'long unsigned int' instead of an 'int'.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
In case of errors during HTTP2 request processing (or after the HTTP1
upgrade response was sent), send 500 Internal Server Error response
before shutting down the connection.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Since there is a helper function to generate/send headers frame, the
flag can be set there instead of being set separately in various places.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case of internal server errors during HTTP1 request processing,
send 500 Internal Server Error response before shutting down the
connection.
Make sure http1_headers_sent is set whenever sever starts replying, to
avoid duplicate response in case of errors, as that would be protocol
violation.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Reply with 405 Method not allowed not only for static FS resource types,
but also for others. Also, the method checking for for static resources
was messed up - those resource types only support GET by design, so no
need to compare resource method bitmask - it should be checked that the
request was actually GET instead.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Remove unused family variable from receive function in ethernet layer 2.
It is checked only once under such conditions, that do not allow the
variable to be different.
Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com>
The net_pkt_clone() did not cloned all needed fields.
Added what was missing from the clone.
Fixes#83157
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
When serving a static file to the HTTP client, we need to supply also
content length field so that the connection can be closed immediately
when the file is fully sent.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If the CoAP server receives a message that doesn't fit into the receive
buffer, we should stop processing the message and respond to the client
with 4.13 "Request Entity too large".
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
This macro is defined in a few places which leads to macro redefinition
error e.g. when compiling prometheus network sample for NPCX boards.
Provide one definition of IS_BIT_SET() in util_macro.h to fix the
problem.
Signed-off-by: Patryk Duda <patrykd@google.com>
Mostly a revert of commit b1def7145f ("arch: deprecate `_current`").
This commit was part of PR #80716 whose initial purpose was about providing
an architecture specific optimization for _current. The actual deprecation
was sneaked in later on without proper discussion.
The Zephyr core always used _current before and that was fine. It is quite
prevalent as well and the alternative is proving rather verbose.
Furthermore, as a concept, the "current thread" is not something that is
necessarily architecture specific. Therefore the primary abstraction
should not carry the arch_ prefix.
Hence this revert.
Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
Add check that should enable MFP when connect to WPA3 network,
as MFP required is mandatory for WPA3 network.
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
Support printing WPA3 enterprise type in scan result for more
accurate display, including the suiteb, suiteb-192 and WPA3
enterprise only.
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
For 'wifi status' and 'wifi ap status' cmd of the hostap case,
originally only support getting 'EAP-TLS' for the enterprise
mode, which is not correct. Now support getting the specific
enterprise mode, including the WPA3 enterprise mode and
the EAP method type.
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
Change Wi-Fi suiteb type into WPA3 enterprise security type, it
includes suiteB, suiteB-192 and WPA3 enterprise only mode.
Support setting WPA3 enterprise only mode, which should use
cipher_config->key_mgmt as WPA-EAP-SHA256, and the AKM in RSN
IE will show 00-0F-AC:5.
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
Remove EAP TLS SHA256 security, as it was added to support the AKM
of 00-0F-AC:5 in RSN IE, but actually this AKM is used by WPA3
enterprise only mode.
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
Ensure that HTTP resources can only be served to a client connected on
the specific service(s) that the resource was registered against using
the HTTP_RESOURCE_DEFINE macro.
This allows different resources to be registered to different services,
for example to make some resources only available via an HTTPS service
and not via unencrypted HTTP.
Signed-off-by: Matt Rodgers <mrodgers@witekio.com>
Passing HTTP upgrade request context to the user callback allows the
user to decide whether to accept or reject the websocket connection
based on the HTTP headers in the request. The primary reason for this is
to enable authentication of the websocket connection (e.g. via cookies
or Authorization header).
Signed-off-by: Matt Rodgers <mrodgers@witekio.com>
RFC6455 section 5.1 specifies that "A server MUST NOT mask any frames
that it sends to the client". Implement this for websocket write calls
via ZVFS, by storing in the websocket_context whether a socket is acting
in the client or server role, and using this to determine if sent data
should be masked.
Signed-off-by: Matt Rodgers <mrodgers@witekio.com>
The DHCPv4 options always assigns the DNS address if the router
provides one through the DHCP callback. There are times a developer
may not always want to assign the server from the router, but only
manually assign them. Adding a Kconfig option for assigning the DNS
address and defaulting to true to not interfere with previously
expected functionality.
Signed-off-by: Kris Wolff <kwolff@wavelynx.com>
Latest supplicant uses 1K buffer size for sending control message via
socketpair, so reducing the NET_SOCKETPAIR_BUFFER_SIZE to save memory
footprint. There are 4 socketpairs for supplicant only case, and 6
socketpairs for hostapd case, update the heap size correspondingly.
Signed-off-by: Maochen Wang <maochen.wang@nxp.com>
For waking up the poll() use eventfd() instead of socketpair()
so we save some buffer space and one file descriptor.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Previously added type casting was still causing coverity to complain.
This time casting multiplication before bitshift operation.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Retreiving IP address from the networking interface assigned to
a PTP port could result in NULL dereference or undefined behaviour
when passing NULL to `memcpy()` function. Added check on addresses
returned from functions retreiving IP address from an interface.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Use the net_icmp_send_echo_request_no_wait() when sending
ICMP Echo-Req so that we can avoid the warning message from
system workqueue handler.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Create a net_icmp_send_echo_request_no_wait() variant that will
not wait when allocating net_buf to be sent. This variant will avoid
a warning to be printed when sending Echo-Req from a system workqueue
because the work cannot sleep in this case.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If Ethernet based network device driver is advertizing
ETHERNET_EMBEDDED_LL_HEADER, then the L2 driver will can
return the proper L2 header size for the network interface.
This info is then used in TX to determine whether to have a
separate net_buf for the link level header, or to embed the
header to the same net_buf as the L2 payload.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Allow network device driver to configure the system so that
when a network packet is sent to it, the link layer header
is stored just before the L2 payload in the same packet.
Currently the link layer header is stored in a separate
net_buf that is linked in front of the L2 payload.
This option can typically save one net_buf when sending
a network packet. Note that if you are using variable data
size buffers (CONFIG_NET_BUF_VARIABLE_DATA_SIZE) then this
embedding is not needed because one can allocate just the
right size network buffers and not waste any memory.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If network interface goes operative down, then re-join user defined
IPv4 multicast groups that where joined earlier when the interface comes
up again. If user takes the network interface down manually (admin down),
then the user specific groups are not re-joined. This works now the same
way as IPv6 re-joining.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Extend the list of methods supported by dynamic resources with
PUT/PATCH/DELETE. The methods does not require any extra handling
from the server perspective, so the existing method handlers could be
reused.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>