Skip to content
Permalink
Browse files

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>
  • Loading branch information...
jukkar committed May 30, 2019
1 parent e809b95 commit eef7625660d6030b81338f00b81994878ff27780
Showing with 21 additions and 0 deletions.
  1. +3 −0 include/net/socket.h
  2. +18 −0 subsys/net/lib/sockets/sockets.c
@@ -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;

0 comments on commit eef7625

Please sign in to comment.
You can’t perform that action at this time.