sockopt: add support for querying tcp round-trip-time

Signed-off-by: Timo Teräs <timo.teras@iki.fi>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
(cherry picked from commit 6b2672f3c9493aef3495192e113f95a7db4b65bc)
This commit is contained in:
Timo Teräs 2015-04-29 09:43:03 +03:00 committed by Daniel Walton
parent f842f16640
commit cf279b3abc
2 changed files with 17 additions and 0 deletions

View File

@ -518,6 +518,22 @@ sockopt_iphdrincl_swab_systoh (struct ip *iph)
iph->ip_id = ntohs(iph->ip_id); iph->ip_id = ntohs(iph->ip_id);
} }
int
sockopt_tcp_rtt (int sock)
{
#ifdef TCP_INFO
struct tcp_info ti;
socklen_t len = sizeof(ti);
if (getsockopt (sock, IPPROTO_TCP, TCP_INFO, &ti, &len) != 0)
return 0;
return ti.tcpi_rtt / 1000;
#else
return 0;
#endif
}
int int
sockopt_tcp_signature (int sock, union sockunion *su, const char *password) sockopt_tcp_signature (int sock, union sockunion *su, const char *password)
{ {

View File

@ -100,6 +100,7 @@ extern int getsockopt_ifindex (int, struct msghdr *);
extern void sockopt_iphdrincl_swab_htosys (struct ip *iph); extern void sockopt_iphdrincl_swab_htosys (struct ip *iph);
extern void sockopt_iphdrincl_swab_systoh (struct ip *iph); extern void sockopt_iphdrincl_swab_systoh (struct ip *iph);
extern int sockopt_tcp_rtt (int);
extern int sockopt_tcp_signature(int sock, union sockunion *su, extern int sockopt_tcp_signature(int sock, union sockunion *su,
const char *password); const char *password);
#endif /*_ZEBRA_SOCKOPT_H */ #endif /*_ZEBRA_SOCKOPT_H */