Fill-in the mode field of the fd_entry so that the
implementation can be made aware that the specific file
descriptors created are sockets.
Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
The Xilinx AXI Ethernet subsystem is capable of RX/Tx checksum
offloading. While it supports computing IP and UDP/TCP checksums, it
does not support computing ICMP checksums and only computes IP checksums
for ICMP messages. Thus, this patch adds an additional configuration for
ethernet drivers that indicates for which protocols checksum offloading
is (to be) supported. This flag is then considered by the IP subsystem
in determining when flags need to be computed in software.
Signed-off-by: Eric Ackermann <eric.ackermann@cispa.de>
Allow DTLS handshake to be retried before the engine
drops into bootstrap. Otherwise any termporary failure,
for example DNS failure might drop us into bootstrap
without retrying.
Now all the retry logic should be in sm_do_network_error().
sm_do_registration() should only fall back to bootstrap
if there is configuration error.
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
In case no Renewal/Rebinding times have been provided the server via
DHCP options, we should reset their values on ACK, so that the client
can recalculate the defaults. This is important, as the lease time may
change, so we should recalculate default T1/T2 timeout based on the new
lease time value.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
DHCP Request retransmission in RENEW and REBIND states was not
compliant with RFC2131.
The retransmission interval should not be calculated as in REQUESTING
state in such case, but rather calculated based on the remaining T2
or lease time (depending on current state).
RFC doesn't also mention any retransmission count limit for those
states. The client should retransmit the REQUEST until T2 or lease
expiry time are reached.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
While forwarding a multicast packet decrement hop limit in a common net
buffer. Also, packets with hop limit equal to 0 should not be forwarded.
Signed-off-by: Konrad Derda <konrad.derda@nordicsemi.no>
Adding network interface status monitor function. Depending
on the interface operation state and change of the state
events are generated and handled by the function.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This commit adds implementation of the PTP thread that will
poll sockets descriptors and PTP Port's timeres for timeouts,
generate events and handle them and trigger STATE_DECISION_EVENT
handling when needed.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
The STATE_DECISION_EVENT in PTP is a pivotal mechanism that
facilitates dynamic state management within the protocol,
allowing devices to adapt their operational states based on the BTCA's
recommendations and the health of the network.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Introduction of PTP stack's core functions responsible for
event generation and handling of these events. Events are generated
base on timeouts and/or PTP messages received via BSD sockets
assigned to a specific PTP Port. These function will be used
in PTP thread.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
The commit adds functions that enable and disable PTP Port.
This is going to be used by event handling routine.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Timers are used to trigger message transmission and detect
inactivity of other PTP Clocks what should result in an action
of the PTP Port.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This commit introduces routines for PTP message transmission.
It includes transmission of three types of messages (Announce,
Sync, Delay_Req) that should be send periodically depending
on the PTP Port's state.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Introduction of routines processing received PTP Management messages.
The processing is split into clock-oriented and port-oriented parts.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Add handler for STATE_DECISION_EVENT it consists of following routines:
- state decision algorithm
- best timeTransmitter clock algorithm
- data sets comparison algorithm
Based on IEEE 1588-2019 section 9.3.3
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This commit adds routines for handling incoming messages
needed for correct operation of the PTP stack in end to end
mode with multicast operation mode.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Initial implementation of the clock adjustment and delay calculation.
Timestamp values used for calculations will be obtained from
proper PTP messages (Sync, Follow_Up, Delay_Req, and Delay_Resp)
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Foreign timeTransmitters are other PTP Clocks in a domain. They announce
their parameters via announce messages. PTP Ports should record
these foreign timeTransmitters.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This commit introduces module responsible for sending and receiving
messages. It is based on BSD Sockets API.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Add allocation of container used for TLVs and dummy functions for
preparing correct byte order of data. TLV stands for Type, Length,
Value, and it is extension of PTP messages that's used to transmit
extra information. This data is attached at the end of PTP message.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Add functions preparing messages to network byte order before sending
and changing to host byte order after reception and before processing
by PTP stack.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Add dynamic memory allocation for PTP messages. Memory allocation
is done with Zephyr's memory slab. It's size can be configured
with `PTP_MSG_POLL_SIZE` Kconfig symbol.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Introduces definition of structures for all types of PTP messages
defined in the IEEE 1588-2019 standard.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Based on IEEE 1588-2019 some of PTP Port states might not be used
if the option of 17.7 is implemented. This patch prepares state
machine implementation for such scenario.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Implement possibility to configure PTP stack in TIME_RECEIVER_ONLY mode.
This restrics stack behaviour and doesn't allow for any PTP Port
of the PTP Clock become a TimeTransmitter Clock.
The change includes:
- Kconfig option
- Additional field in `struct ptp_port` structure
- New state machine function for a timeReceiver-only PTP Port.
- Extra steps in PTP Clock and PTP Port initialization.
New finite state machine is based on the figure 31
in section 9.2.5 of the IEEE 1588-2019.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This commit introduces PTP Clock and PTP Port structures
and API for initializing PTP Clock and PTP Ports. Configuration
options has been added as Kconfig symbols to configure parameters
of the Clock and Ports at compile time.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Datasets defined in the header file are going to be used
in PTP Clock's structure and PTP Port's structure. They
gather data into structures defined in IEEE 1588-2019.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
The patch brings implementationof a state machine for full
PTP implementation. It returns new PTP Port's state based
on event that occured and previous state.
Based on the figure 30 in section 9.2.5 of the IEEE 1588-2019.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
The header's file content is based on 5.3 section of
the IEEE 1588-2019 standard describing Precise Time Protocol (PTP)
used to synchronize devices in the network.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This is an initial commit that introduces PTP library in the Zephyr.
It adds basic Kconfig symbols for enabling library, CMakeLists.txt
for compiling it, public header file, and initial PTP thread definition
and library initialization. Implementation of the functional PTP stack
will be introduced in following commits.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Add returning timestamp of received packet in ancillary data buffer
in `msghdr` structure. This commit enables getting timestamp of
the received packet by calling `recvmsg()` function. The function
returns in the `msg_control` field timestamp if following criteria
are met:
- `CONFIG_NET_CONTEXT_TIMESTAMPING` is set
- `SO_TIMESTAMPING` socket option has `SOF_TIMESTAMPING_RX_HARDWARE`
option enabled for that socket
- driver used by sockets supports packet timestamping
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This is the last commit of the set of patches that introduces
`SO_TIMESTAMPING` socket level optino in Zephyr. The patch
adds `SOF_TIMESTAMPING_RX_HARDWARE` and `SOF_TIMESTAMPING_TX_HARDWARE`
bitmasks. It can be extedned in the future to cover more timestamping
features. Currently the feature can be used with ptp_clock driver.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This is next commit from the set of patches that brings to the
Zephyr, SO_TIMESTAMPING socket level option. It stores timestamping
option bitmask that can be transfered to the net_pkt.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
This is the first commit from the set of patches that brings to the
Zephyr, SO_TIMESTAMPING socket level option. This enables to pass to
the network driver information whether given network packet should
be timestamped or not.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Added incrementation of the packet reference count when puting
the packet on the queue used in tx timestamping thread. This fixes
an issue when user wants to access the packet data in the timestamp
callback context. Before the fix was introduced if sockets were used
packet has been unreferenced before execution reached timestamp callback
context.
Signed-off-by: Adam Wojasinski <awojasinski@baylibre.com>
Add proper PSA_WANT kconfigs for TLS sockets and RSA key exchanges
when CONFIG_PSA_CRYPTO_CLIENT is set.
Signed-off-by: Valerio Setti <vsetti@baylibre.com>
In case we want to immediately send empty Ack to server,
we should bypass all send queues.
This is required when we try to send Ack from callbacks
that happen from socket-loop context. On those cases
the Ack would have not been send because the callback
might be blocking the socket-loop while processing
a request (like write callbacks).
Signed-off-by: Seppo Takalo <seppo.takalo@nordicsemi.no>
If network socket tracing is enabled, then the system will track
various socket API calls for usage.
Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
Replaced tcp_out() with tcp_out_ext() when sending
SYN during tcp connect, so we can intercept error value,
beacuse in such case the packet would not be sent at all
and the stack would not trigger any mechanism to flush
this context so it ends up leaking. These scenarios can
arise when the underlaying interface is not properly
configured or is disconnected. The conn is marked to be
closed and is closed before exiting tcp_in().
Since we can now identify this case we can also exit
early in the net_tcp_connect() function and not wait
for any timeout.
Signed-off-by: Daniel Nejezchleb <dnejezchleb@hwg.cz>
Add descriptions for recently introduced IPv4 and IPv6
connectivity events to the net event monitor.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
conn_mgr now fires:
- NET_EVENT_L4_IPV4_CONNECTED
- NET_EVENT_L4_IPV4_DISCONNECTED
- NET_EVENT_L4_IPV6_CONNECTED
- NET_EVENT_L4_IPV6_DISCONNECTED
These events track whether there are any ready ifaces offering
specifically IPv4 or specifically IPv6 connectivity.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Don't track up/down blame separately.
Instead, track a single last-blame iface.
Don't track blame iface inside set_ready.
Instead, track directly inside handle_update.
These two changes will simplify the addition
of blame for IPv4- and IPv6-specific events.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
Instead of incrementing and decrementing global counter,
just recompute the ready-count from scratch every time
conn_mgr_mon_handle_update is called.
This will simplify the introduction of additional ready count types.
This should have no externally observable impact on the behavior of
conn_mgr.
Signed-off-by: Georges Oates_Larsen <georges.larsen@nordicsemi.no>
In case of ACD Probe/Announcement, all we need is to generate ARP
packet, we don't really want any cache entries to be created or searched
for. There was a bug, that a cache entry was created for the
Announcement sent, resulting in skipped ARP packet generation and
malformed packet being sent by the ACD module.
Therefore, simplify all this, by simply returning early in case of
conflict detection packets.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
The autoconf module can now reuse generic address conflict detection,
which was added for all address types.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
In case a conflict was detected on a DHCP-assigned address, send a
Decline message to the server and start over.
Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>