*/
static cf_mode_item_t cf_mode_list[] =
{
- /*
- {"Server", NULL, MODE_CLIENT },
- {"Port", NULL, MODE_CLIENT | MODE_SERVER },
- */
+ {"MulticastTTL",NULL, MODE_CLIENT },
{"PIDFile", NULL, MODE_CLIENT | MODE_SERVER | MODE_LOCAL},
{"DataDir", NULL, MODE_CLIENT | MODE_SERVER | MODE_LOCAL},
{"LogFile", NULL, MODE_CLIENT | MODE_SERVER | MODE_LOCAL}
};
-static int cf_mode_num = 3;
+static int cf_mode_num = 4;
static int nesting_depth = 0;
static char *current_module = NULL;
#include "network.h"
#include "common.h"
+#include "configfile.h"
#include "utils_debug.h"
/* 1500 - 40 - 8 = Ethernet packet - IPv6 header - UDP header */
{
int loop = 1;
+ char *ttl_str;
+ int ttl_int;
+
+ ttl_str = cf_get_option ("MulticastTTL", NULL);
+ ttl_int = 0;
+ if (ttl_str != NULL)
+ ttl_int = atoi (ttl_str);
+ if ((ttl_int < 1) || (ttl_int > 255))
+ ttl_int = NET_DEFAULT_MC_TTL;
+
DBG ("fd = %i; calling `bind'", se->fd);
if (bind (se->fd, ai->ai_addr, ai->ai_addrlen) == -1)
return (-1);
}
+ /* IP_MULTICAST_TTL */
+ if (setsockopt (se->fd, IPPROTO_IP, IP_MULTICAST_TTL,
+ &ttl_int, sizeof (ttl_int)) == -1)
+ {
+ syslog (LOG_ERR, "setsockopt: %s", strerror (errno));
+ return (-1);
+ }
+
if (setsockopt (se->fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
&mreq, sizeof (mreq)) == -1)
{
return (-1);
}
+ if (setsockopt (se->fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
+ &ttl_int, sizeof (ttl_int)) == -1)
+ {
+ syslog (LOG_ERR, "setsockopt: %s", strerror (errno));
+ return (-1);
+ }
+
if (setsockopt (se->fd, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP,
&mreq, sizeof (mreq)) == -1)
{
#define NET_DEFAULT_V4_ADDR "239.192.74.66"
#define NET_DEFAULT_V6_ADDR "ff18::efc0:4a42"
#define NET_DEFAULT_PORT "25826"
+#define NET_DEFAULT_MC_TTL 1
int network_create_socket (const char *node, const char *service);
int network_receive (char **host, char **type, char **instance, char **value);