Add support for IP_LOCAL_PORT_RANGE socket option. The option
supports both IPv4 and IPv6 sockets although the type is IPPROTO_IP.
The option can be used to enforce the ephemeral port number selection
to be in certain range.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This addresses the following warning building with `CONFIG_64BIT=y`:
error: field precision specifier '.*' expects argument of type 'int',
but argument X has type 'size_t' {aka 'long unsigned int'}
Signed-off-by: Chen Xingyu <hi@xingrz.me>
Non-confirmable CoAP requests need lifetime tracking as well
so we can free the structure after a timeout.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
When waiting for response after receiving the empty Ack, client
actually used way too timeout.
CoAP timeout only holds the timeout value in ms. t0 is the starting time.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
802.11 doesn't have specific constraints, it just says that listen
interval should be >=0 and it a 2 byte field.
3 as a typical DTIM value from nRF chipsets, so, remove the hardware
specific line and just set a failure.
Signed-off-by: Chaitanya Tata <Chaitanya.Tata@nordicsemi.no>
The pull context LwM2M client's set_socketoptions callback is currently
unused and can't be set by a user. Add a public API to set the
pull context's client's set_socketoptions callback.
Signed-off-by: Andi Gerl <andi.gerl@exacttechnology.com>
Make sure that we cannot connect to IPv4 multicast or broadcast
destination address for a TCP socket.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This is helper is only needed in socket multicast interface selection
where we need to get one address from the interface so that it will
tell (when getsockopt() is used), the interface IPv4 address where
multicast packets will be sent. This is private function which is not
needed in public headers so place the prototype to net_private.h file.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Do the selection same way as in IPv6 so that if user supplies
unspecified destination address, the default interface is selected
the same way.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Some of the network tests require that source and destination
addresses are not swapped so allow test to control the address
swapping from the test.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
After we take the true MTU into account, we need to send proper
number of bytes (multiple of 8) in one IPv6 fragment.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If PMTU is enabled, then use the MTU value from it instead of always
using network interface MTU.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If PMTU is enabled, then use the MTU value from it instead of always
using network interface MTU.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add IPV6_MTU IPv6 socket option and implement getsockopt() and
setsockopt() calls for the option.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add IP_MTU IPv4 socket option and implement getsockopt()
call for the option. The IP_MTU option does not support
setsockopt() call.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Send a network management event for a changed path MTU value.
Both IPv4 and IPv6 have their own events as we cannot mix these
because how the network event numbering space is implemented.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Catch "Destination Unreachable" ICMPv4 messages and update PMTU for
a given destination IPv4 address.
Use that PMTU when sending data to the destination.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Show information whether PMTU is enabled or not.
Show pmtu destination cache content with "net pmtu"
command. The "net pmtu flush" can be used to clear the
cache.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Catch "Packet Too Big" ICMPv6 messages and update PMTU for
a given destination IPv6 address.
Use that PMTU when sending data to the destination.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Print more cases when the packet is dropped, and also print
the upper layer verdict for the packet.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This adds generic code that can be used by both IPv4 and IPv6
Path MTU Discovery mechanism. The actual PMTU support for each
protocol family is in subsequent commits.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Print information in "net ipv6" command how the SLAAC addresses
are generated. There is the default legacy EUI-64 method (RFC 4862) or
the stable method described in RFC 7217.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This implements support for RFC 7217 which describes a method
to have stable IPv6 Interface Identifiers to be used with IPv6
Stateless Address Autoconfiguration (SLAAC). The stable IIDs are used
to provide enhanced privacy so that an IPv6 address configured using
this method is stable within each subnet, but the corresponding
Interface Identifier changes when the host moves from one network
to another. This method is meant to be an alternative to generating
Interface Identifiers based on hardware (MAC) addresses,
such that the benefits of stable addresses can be achieved without
sacrificing the security and privacy of users.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
* Add CONFIG_OPENTHREAD_PLATFORM_MESSAGE_MANAGEMENT to allow enabling
message management by the platform.
* Add implementation of `otPlatMessagePoolInit`, `otPlatMessagePoolNew`
and `otPlatMessagePoolFree`.
Signed-off-by: Adrian Gielniewski <adrian.gielniewski@nordicsemi.no>
Web browsers don't support HTTP Upgrade mechanism to upgrade to HTTP2.
Instead, HTTP2 is supported only over TLS, and ALPN is used to negotiate
the protocol to be used.
This commit adds the supported HTTP protocols to the ALPN list, so that
web browsers can use HTTP2 with the server.
Signed-off-by: Matt Rodgers <mrodgers@witekio.com>
Fixes: #78010
This commit implements the "Gateway Advertisement and Discovery" process
defined in section 6.1 of the MQTT-SN specification.
This includes breaking changes to the transport interface and the default
included UDP interface implementation as support for UDP multicast
messages is added as implemented by the Paho MQTT-SN Gateway.
Signed-off-by: Kenneth Witham <kennywitham4@gmail.com>
If a gateway is not set for a interface,
also log the destination address.
Also print the interface index instead of the
interface pointer.
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
If network interface is specified in the DNS server, then send
the queries to the server via the network interface. Print this
information in the server list.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Allow user to specify a network interface in the DNS server
list. User can append "%" and network interface name to the
DNS server to use this. If the network interface is mentioned
in the server list, then the DNS queries are sent via this network
interface.
For example setting the interfaces like this:
192.0.2.2%eth1
[2001:db8::2]:5353%ppp0
would cause the DNS queries to sent to 192.0.2.1 via eth1 in the first
example, and to 2001:db8::2 via ppp0 in the second example.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If trying to parse a string like 192.0.2.2:80/foobar and
setting the length to 12 which means to parse the IP address
and port, the parsing failed because it used one extra character
from the string. This issue was not present if the input string
was terminated after the port number.
Add a test case to catch this problem.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Add a new API to cancel just one, or mathing requests,
instead of cancelling all ongoing requests.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
poll() only for sockets that have traffic ongoing or have some lifetime
left.
On socket failures during a poll(), stop listening for the socket.
Application can recover by reconnecting the socket.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
When the client fails when parsing the response and we stop proceeding,
we should report that to the application.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Even if we receive duplicate confirmable message, we should still
respond with the Ack. Just don't deliver the second callback.
This is achieved by moving the MID deduplication to after Ack handling.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
Return the -errno when zsock_sendto() or zsock_recvfrom() fails, so
rest of the code can deal with return values, instead of separately
comparing errno and return value.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
When response is received and handled, don't just clear the structure
but instead mark it as ongoing=false.
So if we later on receive a duplicate response for it, we can still
respond with Ack or Rst.
This is achieved by using release_internal_request() when we don't
expect any response for it and reset_internal_request() when we really
fill up a new request.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
The sock_obj_core_dealloc() was not called if close() is called
instead of zsock_close(). This happens if POSIX API is enabled.
Fix this by calling zvfs_close() from zsock_close() and then
pass the socket number to zsock_close_ctx() so that the cleanup
can be done properly.
Reported-by: Andreas Ålgård <aal@ixys.no>
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
If we could not fragment the IPv6 packet, then drop it and do
not try to send it. Let the upper layer re-send the packet if
needed. It is causing more trouble if we try to send the packet
and not honor the MTU setting.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>