tcpconns plugin: fix build on FreeBSD current
[collectd.git] / src / tcpconns.c
index 150a7b7..7036d08 100644 (file)
@@ -251,7 +251,6 @@ static enum { SRC_DUNNO, SRC_NETLINK, SRC_PROC } linux_source = SRC_DUNNO;
 static void conn_prepare_vl(value_list_t *vl, value_t *values) {
   vl->values = values;
   vl->values_len = 1;
-  sstrncpy(vl->host, hostname_g, sizeof(vl->host));
   sstrncpy(vl->plugin, "tcpconns", sizeof(vl->plugin));
   sstrncpy(vl->type, "tcp_connections", sizeof(vl->type));
 }
@@ -746,9 +745,15 @@ static int conn_read(void) {
   for (in_ptr = (struct xinpgen *)(((char *)in_orig) + in_orig->xig_len);
        in_ptr->xig_len > sizeof(struct xinpgen);
        in_ptr = (struct xinpgen *)(((char *)in_ptr) + in_ptr->xig_len)) {
+#if __FreeBSD_version >= 1200026
+    struct xtcpcb *tp = (struct xtcpcb *)in_ptr;
+    struct xinpcb *inp = &tp->xt_inp;
+    struct xsocket *so = &inp->xi_socket;
+#else
     struct tcpcb *tp = &((struct xtcpcb *)in_ptr)->xt_tp;
     struct inpcb *inp = &((struct xtcpcb *)in_ptr)->xt_inp;
     struct xsocket *so = &((struct xtcpcb *)in_ptr)->xt_socket;
+#endif
 
     /* Ignore non-TCP sockets */
     if (so->xso_protocol != IPPROTO_TCP)