This will save flash memory by 1489 bytes and make usage help look
uniform in different commands.
Re-order the shell commands to alphabetical order. This has been
done before but has bitrotted over time.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This will save flash memory by 646 bytes and make usage help look
uniform in different commands.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Make sure to check packet length check before starting the
IPv6 fragmentation reassembly process. This way we can drop the
malformed packet without consuming resources.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Previously the name was only set when CONFIG_NET_L2_PPP_LOG_LEVEL >=
LOG_LEVEL_DBG. NET_ERR/NET_WRN in ipv6cp (and others) use fsm->name
as %s at any log level, which could pass NULL into the logger and
crash in cbprintf/strlen. Always assign the name so logging is safe.
Signed-off-by: Jani Hirsimäki <jani.hirsimaki@nordicsemi.no>
Add the 'net dns browse <service>' command to resolve multiple hosts of a
certain service type.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Add an entry to the DNS cache for DNS_RESPONSE_DATA messages, and return
dns_read with DNS_EAI_ALLDONE instead of DNS_EAI_NODATA.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
In large networks there can be many DNS responses, make the DNS info queue
size configurable to prevent dropping messages
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
The mutex should be held when calling dns_resolve_init_locked as mentioned
in a comment above the function.
Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
CoAP response code 2.00 is not defined anywhere in the spec nor
assigned in the IANA registry, therefore it should not be defined
in Zephyr either. Remove the invalid response code and its usage
in tests.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Allow applications to respond to HTTP OPTIONS requests (e.g. CORS pre-
flight) by routing OPTIONS through the same dynamic handler path
as GET/DELETE.
This enables OPTIONS handling for both HTTP/1.1 and HTTP/2.
Signed-off-by: Robert Eichinger <robert.eichinger@bshg.com>
As per Zephyr coding guideline #59, "operands shall not be of an
inappropriate essential type". This makes sure boolean variables are
assigned true/false values, not 1/0.
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
When building with CONFIG_NO_OPTIMIZATIONS the compiler will not
optimize create_answer() based on the caller, and will try to call
ipv4/6 code even if not built.
Let's add an extra check in the if before those possibly unavailable
calls to ensure those branches are dropped in this case.
Signed-off-by: Alberto Escolar Piedras <alberto.escolar.piedras@nordicsemi.no>
Extend the Wi-Fi shell connect command to allow passing an SAE
password separately from PSK. Previously, the shell stored all
passwords in the PSK field, preventing proper use of SAE credentials
required for WPA3 connections.
This change adds a dedicated option to populate the SAE password
field so that SAE authentication paths can be exercised correctly
from the shell.
Signed-off-by: Somil Gupta <somil24559@iiitd.ac.in>
Add helpers for sending all the data in a buffer. This is
only useful for stream sockets like TCP.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
CoAP .well-known/core handling routine assumed that the "user_data"
pointer in struct coap_resource will be set to a valid struct
coap_core_metadata pointer, or left NULL. This approach is error
prone (application cannot use "user_data" field freely) and renders the
"user_data" field useless for other cases.
Therefore, introduce a separate "metadata" pointer within the struct
coap_resource specifically to configure the resource-related metadata,
and leave "user_data" for the applications to use freely.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Sender address and address length were not set in recvfrom() when called
for TCP socket. Fix this by reusing the code used to set source address
on accept().
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Increasing FD count in the system for the network stack (native sockets)
only makes sense if native network stack is enabled. Otherwise, just
make it 0. This makes a difference for example when socket offloading is
used and the offloaded implementation makes its own reservation.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
This commits splits the border router services initialization by
separating the ipv6 related services from ipv4 ones.
As there are cases in which a DHCPv4 server is not present in the
network setup, there is no reason to wait for an IPV4 address before
starting the border router. In this case, only IPV6 functionalities
would be exposed.
Signed-off-by: Cristian Bulacu <cristian.bulacu@nxp.com>
The length is an input parameter, which tells the kernel how big the
storage is. Depending on the socket implementation in use, not setting this
properly can (and should) fail depending on the value of the stack
variable.
Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
5f5db5bf3c added support for IPV6_MULTICAST_HOPS by adding both IPv4 and
IPv6 variants in place where they are used. This made the code a bit
complicated, though. This commit introduces helper functions to solve this.
Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
The whole TCP Kconfig options block is already behind "if NET_TCP",
therefore "depends on NET_TCP" on certain options was redundant.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Zephyr by default closes all TCP contexts associated with a given
network interface when the interface goes down. This leads to
reporting an error on the associated network socket, allowing the
application to reopen sockets (for example in case of a network or
an IP address change).
It's been reported however that in certain cases this behavior is
undesirable. If this option is enabled, the TCP stack won't
close any TCP contexts when the network interface is going down.
Therefore, it is the application's responsibility to monitor the IP
address or network interface state changes, and restart the TCP
sockets when needed. Enable this option only if you can guarantee
that the application handles that properly.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Contexts bound to any address are not associated with any specifc IP
address (sockets not connected yet or listening sockets bound to any),
therefore there's no need to shut down the connection context on the
interface down event. Hence, check the local address binding before
shutting down the context.
Note, that there's some extra logic involved when reading the TCP local
address, implemented in net_tcp_endpoint_copy(), therefore I've simply
reused that function for the purpose.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Moved forward decision debug messages ahead of interface TX/RX
operations. That's proper to see forward decision debug messages
first, and then interface TX/RX debug messages.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
Added FDB (Forward Database) table support for bridge.
Implemented very basic functions for adding/deleting
static <MAC + iface> FDB entry.
The dynamic FDB entry and hardware FDB configuration is
still TODO work.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
struct dns_header is packed therefore it fields need to be accessed with
respective helper macro to avoid warnings with clang.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Returning negative values which are not -1, isn't what POSIX would do and
the API is specifically designed to behave like recvfrom.
Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
- gw_id is an uint8_t in the protocol, so neither char, nor uint16_t are
the correct type to use.
- addr is an array of bytes, not a string (of characters).
This also corrects related log messages and makes them more consistent, by
using hex for all gw_id's.
Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
The address is only used for gateway discovery, but using a truncated
`struct sockaddr` can lead to out of bounds reads.
Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
I don't know, why this was added originally, but there are many issues with
it:
- You can't really return NULL, because src_addr is a `void*`, not a
`void**`. The `src_addr = NULL` didn't do anything.
- The code was checking if the src_addr equals to the broadcast address,
but under normal conditions, that's always a unicast address.
- Even if we would check if the destination address was the bcaddr, I don't
see how that's useful. Currently, the address is only used for messages
of types advertise and gwinfo, which use it to create a new entry in the
gateway list. In that list, you always need the unicast address, never
the broadcast address.
Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
According to RFC 6763, chapter 12.1, PTR responses SHOULD include
"All address records (type "A" and "AAAA") named in the SRV rdata.".
This was not the case, as only one IPv6 and one IPv4 address was added
in the response by Zephyr. This commit changes this behavior, Zephyr
DNS SD responder will now try to include all IPv4/6 addresses configured
on a given network interface. The current approach of choosing one IPv6
and one IPv4 address first to include in the message is retained - this
is to prevent situation where for example IPv6 addresses will consume
all buffer space, leaving no place for IPv4 ones. The DNS responder will
encode those selected IPv6 and IPv4 addresses first, and then attempt to
include remaining IPv6/4 addresses with "best effort" approach, if there
still is a space in the buffer to add those.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
IPv4/IPv6 source address lookups may return unspecified address in case
there's no valid match (like for example LL address for global
destination). As it makes no sense to include unspecified addresses in
DNS SD replies, verify if that's not the case before adding A/AAAA
record in the response.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
Instead of manipulating net_buf's data buffer directly, use net_buf APIs
to reduce complexity when creating mDNS response.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
RFC 6762 Section 6.2 "Responding to Address Queries" specifies that mDNS
responses must include all valid addresses on the interface that is
sending the response. That was not the case for Zephyr's implementation,
which sent only on address in the response (and in some corner cases no
address at all).
This commit fixes this problem. Instead of encoding a single
pre-selected address in the response, mDNS responder will now loop over
all addresses on a given interface, and try to encode them as separate
answer records in the reply.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
If we get DHCPv4 bound event, then resend mDNS announce message
for that interface. This way a new address from DHCP server will
get announced properly.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If we try to add an already existing IP address to the
address monitor list, then mark the address to be in use.
The address might have been marked as not-in-use before.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If we override a static address by a DHCPv4 address, then send
address DEL event so that listeners notice it. This happens
for example with mDNS responder that needs to keep track of
what IPv4 addresses it needs to advertise.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
The "init_called" flag needs to be per context and cannot be global
as it is meant to tell whether the context is initialized first time
or not.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Fixed multicast address checking.
- net_eth_is_addr_multicast() should be for multicast address checking
but not for only IP multicast address. Then net_eth_is_addr_group()
is no longer needed.
- LLDP and gPTP multicast address checking should not depend on Kconfig
option.
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
There is no reason for which CONFIG_NET_SOCKETS_SOCKOPT_TLS should select
some crypto features by default. The correct list really depends on the
server/client the device would like to connect to.
For this reason the selection of any crypto feature is removed from
CONFIG_NET_SOCKETS_SOCKOPT_TLS with the idea that the proper ciphersuite
is to be enabled in the final sample/test configuration file.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>