summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9f83cfe)
raw | patch | inline | side by side (parent: 9f83cfe)
author | octo <octo> | |
Mon, 30 Jan 2006 17:15:39 +0000 (17:15 +0000) | ||
committer | octo <octo> | |
Mon, 30 Jan 2006 17:15:39 +0000 (17:15 +0000) |
src/configfile.c | patch | blob | history | |
src/network.c | patch | blob | history | |
src/network.h | patch | blob | history |
diff --git a/src/configfile.c b/src/configfile.c
index c217724ad94c46b3ed39b946d66908b3293f3ad9..52978b39c2a43b57dd642f6b6713ae37aa9a4969 100644 (file)
--- a/src/configfile.c
+++ b/src/configfile.c
*/
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;
diff --git a/src/network.c b/src/network.c
index 3fe25fd46274c5d508a4e38b7877dca7640f1a8a..cecf0bad743186158393292c7676621b3556fd3c 100644 (file)
--- a/src/network.c
+++ b/src/network.c
#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)
{
@@ -128,6 +147,13 @@ static int network_bind_socket (const sockent_t *se, const struct addrinfo *ai)
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)
{
diff --git a/src/network.h b/src/network.h
index 374448cc7a3c53b2eb50a640f753fa048ff3f100..aa3d3fcd03d3a85e040137efbf0b652eddeeefa5 100644 (file)
--- a/src/network.h
+++ b/src/network.h
#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);