Andrei Pelinescu-Onciul пре 21 година
родитељ
комит
956d111a9e
7 измењених фајлова са 43 додато и 3 уклоњено
  1. 5 0
      NEWS
  2. 2 0
      cfg.lex
  3. 12 2
      cfg.y
  4. 1 1
      daemonize.c
  5. 1 0
      globals.h
  6. 4 0
      main.c
  7. 18 0
      udp_server.c

+ 5 - 0
NEWS

@@ -23,6 +23,9 @@ core:
  - new parts:
        UNIX domain socket server implemented
  - changes: 
+    -  multicast support added (see mcast_loopback & mcast_ttl)
+    -  saving of procces group id enabled, if the -G option is specified
+       (a safe way to quickly kill all ser processes)
     -  core dump-ing is enabled by default, see also disable_core_dump
     -  protocol and port can be specified in the alias and listen lines, e.g.:
         alias= tcp:foo.bar:* udp:test.bar:5080 foo.com
@@ -31,6 +34,8 @@ core:
                               ==, !=, ~= for strings
                               ==, !=, >, <, >=, <= for integers
  - new config variables:
+   mcast_loopback = <yes/no> - loopback sent multicast datagram, default no.
+   mcast_ttl = number - set multicast ttl, default OS specific (usually 1).
    sock_mode = <permissions> (e.g. sock_mode=0600:  default value = 0660)
        ser unix sockets and fifo will be created with this permissions
        (old name fifo_mode is still supported, but deprecated)

+ 2 - 0
cfg.lex

@@ -48,6 +48,8 @@
  *  2004-03-30  added DISABLE_CORE and OPEN_FD_LIMIT (andrei)
  *  2004-04-28  added sock_mode (replaces fifo_mode), sock_user &
  *               sock_group  (andrei)
+ *  2004-05-03  applied multicast support patch from janakj
+ *              added MCAST_TTL (andrei)
  */
 
 

+ 12 - 2
cfg.y

@@ -53,6 +53,8 @@
  * 2004-02-24  added LOAD_AVP_T and AVP_TO_URI_T (bogdan)
  * 2004-03-30  added DISABLE_CORE and OPEN_FD_LIMIT (andrei)
  * 2004-04-29  added SOCK_MODE, SOCK_USER & SOCK_GROUP (andrei)
+ * 2004-05-03  applied multicast support patch (MCAST_LOOPBACK) from janakj
+               added MCAST_TTL (andrei)
  */
 
 
@@ -243,6 +245,7 @@ static struct id_list* mk_listen_id(char*, int, int);
 %token DISABLE_CORE
 %token OPEN_FD_LIMIT
 %token MCAST_LOOPBACK
+%token MCAST_TTL
 
 
 
@@ -665,8 +668,15 @@ assign_stm:	DEBUG EQUAL NUMBER { debug=$3; }
 									warn("no multicast support compiled in");
 								#endif
 		  }
-                | MCAST_LOOPBACK EQUAL error { yyerror("boolean value expected"); }
-
+		| MCAST_LOOPBACK EQUAL error { yyerror("boolean value expected"); }
+		| MCAST_TTL EQUAL NUMBER {
+								#ifdef USE_MCAST
+										mcast_ttl=$3;
+								#else
+									warn("no multicast support compiled in");
+								#endif
+		  }
+		| MCAST_TTL EQUAL error { yyerror("number expected"); }
 		| error EQUAL { yyerror("unknown config variable"); }
 	;
 

+ 1 - 1
daemonize.c

@@ -31,7 +31,7 @@
  *  2004-02-20  removed from ser main.c into its own file (andrei)
  *  2004-03-04  moved setuid/setgid in do_suid() (andrei)
  *  2004-03-25  added increase_open_fds & set_core_dump (andrei)
- *  2004-04-04  applied pgid patch from janakj
+ *  2004-05-03  applied pgid patch from janakj
  */
 
 #define _XOPEN_SOURCE

+ 1 - 0
globals.h

@@ -104,6 +104,7 @@ extern char* working_dir;
 
 #ifdef USE_MCAST
 extern int mcast_loopback;
+extern int mcast_ttl;
 #endif /* USE_MCAST */
 
 /*

+ 4 - 0
main.c

@@ -143,6 +143,9 @@ static char flags[]=
 #ifdef DISABLE_NAGLE
 ", DISABLE_NAGLE"
 #endif
+#ifdef USE_MCAST
+", USE_MCAST"
+#endif
 #ifdef NO_DEBUG
 ", NO_DEBUG"
 #endif
@@ -348,6 +351,7 @@ int reply_to_via=0;
 
 #ifdef USE_MCAST
 int mcast_loopback = 0;
+int mcast_ttl = -1; /* if -1, don't touch it, use the default (usually 1) */
 #endif /* USE_MCAST */
 
 #if 0

+ 18 - 0
udp_server.c

@@ -30,6 +30,8 @@
  *  2003-02-10  undoed the above changes (andrei)
  *  2003-03-19  replaced all the mallocs/frees w/ pkg_malloc/pkg_free (andrei)
  *  2003-04-14  set sockopts to TOS low delay (andrei)
+ *  2004-05-03  applied multicast support patch from janakj
+ *              added set multicast ttl support (andrei)
  */
 
 
@@ -237,6 +239,14 @@ static int setup_mcast_rcvr(int sock, union sockaddr_union* addr)
 			    strerror(errno));
 			return -1;
 		}
+		if (mcast_ttl>=0){
+			if (setsockopt(sock, IPPROTO_IP, IP_MULTICAST_TTL, &mcast_ttl,
+						sizeof(mcast_ttl))==-1){
+				LOG(L_ERR, "ERROR: setup_mcast_rcvr: setosckopt (ttl):"
+						" %s\n", strerror(errno));
+				return -1;
+			}
+		}
 #ifdef USE_IPV6
 	} else if (addr->s.sa_family==AF_INET6){
 		memcpy(&mreq6.ipv6mr_multiaddr, &addr->sin6.sin6_addr, 
@@ -256,6 +266,14 @@ static int setup_mcast_rcvr(int sock, union sockaddr_union* addr)
 			    strerror(errno));
 			return -1;
 		}
+		if (mcast_ttl>=0){
+			if (setsockopt(sock, IPPROTO_IP, IPV6_MULTICAST_HOPS, &mcast_ttl,
+						sizeof(mcast_ttl))==-1){
+				LOG(L_ERR, "ERROR: setup_mcast_rcvr: setosckopt (ttlv6):"
+						" %s\n", strerror(errno));
+				return -1;
+			}
+		}
 #endif /* USE_IPV6 */
 	} else {
 		LOG(L_ERR, "ERROR: udp_init: Unsupported protocol family\n");