[quagga-dev 12197] [PATCH 5/7] sockopt: add support for querying tcp round-trip-time

Timo Teräs timo.teras at iki.fi
Wed Apr 29 07:43:03 BST 2015


Signed-off-by: Timo Teräs <timo.teras at iki.fi>
---
 lib/sockopt.c | 16 ++++++++++++++++
 lib/sockopt.h |  1 +
 2 files changed, 17 insertions(+)

diff --git a/lib/sockopt.c b/lib/sockopt.c
index be22827..257271b 100644
--- a/lib/sockopt.c
+++ b/lib/sockopt.c
@@ -519,6 +519,22 @@ sockopt_iphdrincl_swab_systoh (struct ip *iph)
 }
 
 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
 sockopt_tcp_signature (int sock, union sockunion *su, const char *password)
 {
 #if defined(HAVE_TCP_MD5_LINUX24) && defined(GNU_LINUX)
diff --git a/lib/sockopt.h b/lib/sockopt.h
index aced6d4..cb14efc 100644
--- a/lib/sockopt.h
+++ b/lib/sockopt.h
@@ -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_systoh (struct ip *iph);
 
+extern int sockopt_tcp_rtt (int);
 extern int sockopt_tcp_signature(int sock, union sockunion *su,
                                  const char *password);
 #endif /*_ZEBRA_SOCKOPT_H */
-- 
2.3.6





More information about the Quagga-dev mailing list