udp: Add support for SO_TIMESTAMP

Adds support for timestamping received UDP packets, either in
hardware or in kernel. Builds on the existing support of SO_TIMESTAMP
for SocketCAN.

Implementation uses CLOCK_REALTIME for timestamping to match the
behavior of Linux. This could be made configurable in future if needed.
This commit is contained in:
Petteri Aimonen
2023-11-17 09:44:49 +02:00
committed by Xiang Xiao
parent ce654a6148
commit cb161940c2
9 changed files with 143 additions and 4 deletions
+12
View File
@@ -442,6 +442,18 @@ struct net_driver_s
struct netdev_statistics_s d_statistics;
#endif
#if defined(CONFIG_NET_TIMESTAMP)
/* Reception timestamp of packet being currently processed.
* If CONFIG_ARCH_HAVE_NETDEV_TIMESTAMP is true, the timestamp is provided
* by hardware driver. Otherwise it is filled in by kernel when packet
* enters ipv4_input or ipv6_input.
*
* The timestamp is in CLOCK_REALTIME.
*/
struct timespec d_rxtime;
#endif
/* Application callbacks:
*
* Network device event handlers are retained in a 'list' and are called