net: socket: Add SO_TIMESTAMPING socket option
This can be used to activate the network packet statistics collection. Note that we do not have resources to calculate each network packet transit times but we collect average times instead. Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
e809b95c51
commit
eef7625660
|
@ -732,6 +732,9 @@ static inline char *inet_ntop(sa_family_t family, const void *src, char *dst,
|
|||
/** sockopt: Async error (ignored, for compatibility) */
|
||||
#define SO_ERROR 4
|
||||
|
||||
/** sockopt: Timestamp TX packets */
|
||||
#define SO_TIMESTAMPING 37
|
||||
|
||||
/* Socket options for IPPROTO_TCP level */
|
||||
/** sockopt: Disable TCP buffering (ignored, for compatibility) */
|
||||
#define TCP_NODELAY 1
|
||||
|
|
|
@ -1168,6 +1168,24 @@ int zsock_setsockopt_ctx(struct net_context *ctx, int level, int optname,
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case SO_TIMESTAMPING:
|
||||
/* Calculate TX network packet timings */
|
||||
if (IS_ENABLED(CONFIG_NET_CONTEXT_TIMESTAMP)) {
|
||||
ret = net_context_set_option(ctx,
|
||||
NET_OPT_TIMESTAMP,
|
||||
optval, optlen);
|
||||
if (ret < 0) {
|
||||
errno = -ret;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue