Browse Source

MT#55283 support SO_TIMESTAMP_OLD

Supports obscure situations where the old 32-bit timestamp is returned

Change-Id: I8423cd04baa9fd49e254d88d17e3e609ee5a20bb
(cherry picked from commit c0b245b979)
(cherry picked from commit ae9bf2317d)
mr13.4.1
Richard Fuchs 4 months ago
parent
commit
35935ee6ee
1 changed files with 16 additions and 3 deletions
  1. +16
    -3
      lib/socket.h

+ 16
- 3
lib/socket.h View File

@ -218,13 +218,26 @@ INLINE ssize_t socket_sendto_from(socket_t *s, const void *b, size_t l, const en
return socket_sendiov(s, &(struct iovec) { .iov_base = (void *) b, .iov_len = l }, l, dst, src);
}
struct timeval32 {
int32_t tv_sec;
int32_t tv_usec;
};
#define socket_recvfrom_parse_cmsg(tv, to, parse_to, msgh, firsthdr, nexthdr) do { \
if ((*tv) || (*to)) { \
struct cmsghdr *cm; \
for (cm = firsthdr; cm; cm = nexthdr) { \
if (cm->cmsg_level == SOL_SOCKET && cm->cmsg_type == SO_TIMESTAMP && (*tv)) { \
*(*tv) = timeval_us(*((struct timeval *) CMSG_DATA(cm))); \
(*tv) = NULL; \
if ((*tv) && cm->cmsg_level == SOL_SOCKET) { \
if (cm->cmsg_type == SO_TIMESTAMP) { \
*(*tv) = timeval_us(*((struct timeval *) CMSG_DATA(cm))); \
(*tv) = NULL; \
} \
else if (cm->cmsg_type == SO_TIMESTAMP_OLD) { \
struct timeval32 *tc = (struct timeval32 *) CMSG_DATA(cm); \
struct timeval tvv = { .tv_sec = tc->tv_sec, .tv_usec = tc->tv_usec }; \
*(*tv) = timeval_us(tvv); \
(*tv) = NULL; \
} \
} \
if (parse && (*to) && parse_to(cm, (*to))) \
(*to) = NULL; \


Loading…
Cancel
Save