The previous version failed on FreeBSD with:
modbus.c: In function 'mb_read_data':
modbus.c:476:21: error: storage size of 'sockaddr' isn't known
struct sockaddr sockaddr;
^
**/
#include "collectd.h"
+
#include "common.h"
-#include "plugin.h"
#include "configfile.h"
-
-#include <netdb.h>
+#include "plugin.h"
#include <modbus.h>
+#include <netdb.h>
+#include <sys/socket.h>
#ifndef LIBMODBUS_VERSION_CHECK
/* Assume version 2.0.3 */
}
else if (host->conntype == MBCONN_TCP)
{
- struct sockaddr sockaddr;
- socklen_t saddrlen = sizeof (sockaddr);
-
- status = getpeername (modbus_get_socket (host->connection),
- &sockaddr, &saddrlen);
- if (status != 0)
+ if (getpeername (modbus_get_socket (host->connection),
+ (void *) &(struct sockaddr_storage) {0},
+ &(socklen_t) {sizeof(struct sockaddr_storage)}) != 0)
status = errno;
}