1 /* macOS and iOS have the .h files but the tcp_info struct is private API */
2 #if defined(HAVE_NETINET_TCP_H) && defined(HAVE_NETINET_IN_H) && defined(HAVE_SYS_SOCKET_H)
3 #include <netinet/tcp.h>
4 #include <netinet/in.h>
5 #include <sys/socket.h>
6 #if defined(TCP_INFO)
7 #define HAVE_SOCKET_METRIC_HEADERS
8 #endif
9 #endif
10
11 #include "gsttcpsrcstats.h"
12
13 void
gst_tcp_stats_from_socket(GstStructure * structure,GSocket * socket)14 gst_tcp_stats_from_socket (GstStructure * structure, GSocket * socket)
15 {
16 #ifdef HAVE_SOCKET_METRIC_HEADERS
17 if (getsockopt (fd, IPPROTO_TCP, TCP_INFO, &info, &info_len) == 0) {
18 /* this is system-specific */
19 #ifdef HAVE_BSD_TCP_INFO
20 gst_structure_set (s,
21 "reordering", G_TYPE_UINT, info.__tcpi_reordering,
22 "unacked", G_TYPE_UINT, info.__tcpi_unacked,
23 "sacked", G_TYPE_UINT, info.__tcpi_sacked,
24 "lost", G_TYPE_UINT, info.__tcpi_lost,
25 "retrans", G_TYPE_UINT, info.__tcpi_retrans,
26 "fackets", G_TYPE_UINT, info.__tcpi_fackets, NULL);
27 #elif defined(HAVE_LINUX_TCP_INFO)
28 gst_structure_set (s,
29 "reordering", G_TYPE_UINT, info.tcpi_reordering,
30 "unacked", G_TYPE_UINT, info.tcpi_unacked,
31 "sacked", G_TYPE_UINT, info.tcpi_sacked,
32 "lost", G_TYPE_UINT, info.tcpi_lost,
33 "retrans", G_TYPE_UINT, info.tcpi_retrans,
34 "fackets", G_TYPE_UINT, info.tcpi_fackets, NULL);
35 #endif
36 }
37 #endif
38 }
39