#elif HAVE_SYSCTLBYNAME
# include <sys/socketvar.h>
# include <sys/sysctl.h>
+
+/* Some includes needed for compiling on FreeBSD */
+#include <sys/time.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_SOCKET_H
+# include <sys/socket.h>
+#endif
+#if HAVE_NET_IF_H
+# include <net/if.h>
+#endif
+
# include <net/route.h>
# include <netinet/in.h>
# include <netinet/in_systm.h>
vl.values = values;
vl.values_len = 1;
vl.time = time (NULL);
- strcpy (vl.host, hostname_g);
- strcpy (vl.plugin, "tcpconns");
+ sstrncpy (vl.host, hostname_g, sizeof (vl.host));
+ sstrncpy (vl.plugin, "tcpconns", sizeof (vl.plugin));
if (((port_collect_listening != 0) && (pe->flags & PORT_IS_LISTENING))
|| (pe->flags & PORT_COLLECT_LOCAL))
{
snprintf (vl.plugin_instance, sizeof (vl.plugin_instance),
- "%hu-local", pe->port);
+ "%"PRIu16"-local", pe->port);
vl.plugin_instance[sizeof (vl.plugin_instance) - 1] = '\0';
for (i = 1; i <= TCP_STATE_MAX; i++)
if (pe->flags & PORT_COLLECT_REMOTE)
{
snprintf (vl.plugin_instance, sizeof (vl.plugin_instance),
- "%hu-remote", pe->port);
+ "%"PRIu16"-remote", pe->port);
vl.plugin_instance[sizeof (vl.plugin_instance) - 1] = '\0';
for (i = 1; i <= TCP_STATE_MAX; i++)
port_entry_t *next = pe->next;
DEBUG ("tcpconns plugin: Removing temporary entry "
- "for listening port %hu", pe->port);
+ "for listening port %"PRIu16, pe->port);
if (prev == NULL)
port_list_head = next;
#endif
)
{
- NOTICE ("tcpconns plugin: Ignoring connection with unknown state 0x%02x.",
- state);
+ NOTICE ("tcpconns plugin: Ignoring connection with "
+ "unknown state 0x%02"PRIx8".", state);
return (-1);
}
pe->flags |= PORT_IS_LISTENING;
}
- DEBUG ("tcpconns plugin: Connection %hu <-> %hu (%s)",
+ DEBUG ("tcpconns plugin: Connection %"PRIu16" <-> %"PRIu16" (%s)",
port_local, port_remote, tcp_state[state]);
pe = conn_get_port_entry (port_local, 0 /* no create */);