Browse code

- added mcast_ttl

Andrei Pelinescu-Onciul authored on 03/05/2004 12:18:10
Showing 7 changed files
... ...
@@ -23,6 +23,9 @@ core:
23 23
  - new parts:
24 24
        UNIX domain socket server implemented
25 25
  - changes: 
26
+    -  multicast support added (see mcast_loopback & mcast_ttl)
27
+    -  saving of procces group id enabled, if the -G option is specified
28
+       (a safe way to quickly kill all ser processes)
26 29
     -  core dump-ing is enabled by default, see also disable_core_dump
27 30
     -  protocol and port can be specified in the alias and listen lines, e.g.:
28 31
         alias= tcp:foo.bar:* udp:test.bar:5080 foo.com
... ...
@@ -31,6 +34,8 @@ core:
31 31
                               ==, !=, ~= for strings
32 32
                               ==, !=, >, <, >=, <= for integers
33 33
  - new config variables:
34
+   mcast_loopback = <yes/no> - loopback sent multicast datagram, default no.
35
+   mcast_ttl = number - set multicast ttl, default OS specific (usually 1).
34 36
    sock_mode = <permissions> (e.g. sock_mode=0600:  default value = 0660)
35 37
        ser unix sockets and fifo will be created with this permissions
36 38
        (old name fifo_mode is still supported, but deprecated)
... ...
@@ -48,6 +48,8 @@
48 48
  *  2004-03-30  added DISABLE_CORE and OPEN_FD_LIMIT (andrei)
49 49
  *  2004-04-28  added sock_mode (replaces fifo_mode), sock_user &
50 50
  *               sock_group  (andrei)
51
+ *  2004-05-03  applied multicast support patch from janakj
52
+ *              added MCAST_TTL (andrei)
51 53
  */
52 54
 
53 55
 
... ...
@@ -53,6 +53,8 @@
53 53
  * 2004-02-24  added LOAD_AVP_T and AVP_TO_URI_T (bogdan)
54 54
  * 2004-03-30  added DISABLE_CORE and OPEN_FD_LIMIT (andrei)
55 55
  * 2004-04-29  added SOCK_MODE, SOCK_USER & SOCK_GROUP (andrei)
56
+ * 2004-05-03  applied multicast support patch (MCAST_LOOPBACK) from janakj
57
+               added MCAST_TTL (andrei)
56 58
  */
57 59
 
58 60
 
... ...
@@ -243,6 +245,7 @@ static struct id_list* mk_listen_id(char*, int, int);
243 243
 %token DISABLE_CORE
244 244
 %token OPEN_FD_LIMIT
245 245
 %token MCAST_LOOPBACK
246
+%token MCAST_TTL
246 247
 
247 248
 
248 249
 
... ...
@@ -665,8 +668,15 @@ assign_stm:	DEBUG EQUAL NUMBER { debug=$3; }
665 665
 									warn("no multicast support compiled in");
666 666
 								#endif
667 667
 		  }
668
-                | MCAST_LOOPBACK EQUAL error { yyerror("boolean value expected"); }
669
-
668
+		| MCAST_LOOPBACK EQUAL error { yyerror("boolean value expected"); }
669
+		| MCAST_TTL EQUAL NUMBER {
670
+								#ifdef USE_MCAST
671
+										mcast_ttl=$3;
672
+								#else
673
+									warn("no multicast support compiled in");
674
+								#endif
675
+		  }
676
+		| MCAST_TTL EQUAL error { yyerror("number expected"); }
670 677
 		| error EQUAL { yyerror("unknown config variable"); }
671 678
 	;
672 679
 
... ...
@@ -31,7 +31,7 @@
31 31
  *  2004-02-20  removed from ser main.c into its own file (andrei)
32 32
  *  2004-03-04  moved setuid/setgid in do_suid() (andrei)
33 33
  *  2004-03-25  added increase_open_fds & set_core_dump (andrei)
34
- *  2004-04-04  applied pgid patch from janakj
34
+ *  2004-05-03  applied pgid patch from janakj
35 35
  */
36 36
 
37 37
 #define _XOPEN_SOURCE
... ...
@@ -104,6 +104,7 @@ extern char* working_dir;
104 104
 
105 105
 #ifdef USE_MCAST
106 106
 extern int mcast_loopback;
107
+extern int mcast_ttl;
107 108
 #endif /* USE_MCAST */
108 109
 
109 110
 /*
... ...
@@ -143,6 +143,9 @@ static char flags[]=
143 143
 #ifdef DISABLE_NAGLE
144 144
 ", DISABLE_NAGLE"
145 145
 #endif
146
+#ifdef USE_MCAST
147
+", USE_MCAST"
148
+#endif
146 149
 #ifdef NO_DEBUG
147 150
 ", NO_DEBUG"
148 151
 #endif
... ...
@@ -348,6 +351,7 @@ int reply_to_via=0;
348 348
 
349 349
 #ifdef USE_MCAST
350 350
 int mcast_loopback = 0;
351
+int mcast_ttl = -1; /* if -1, don't touch it, use the default (usually 1) */
351 352
 #endif /* USE_MCAST */
352 353
 
353 354
 #if 0
... ...
@@ -30,6 +30,8 @@
30 30
  *  2003-02-10  undoed the above changes (andrei)
31 31
  *  2003-03-19  replaced all the mallocs/frees w/ pkg_malloc/pkg_free (andrei)
32 32
  *  2003-04-14  set sockopts to TOS low delay (andrei)
33
+ *  2004-05-03  applied multicast support patch from janakj
34
+ *              added set multicast ttl support (andrei)
33 35
  */
34 36
 
35 37
 
... ...
@@ -237,6 +239,14 @@ static int setup_mcast_rcvr(int sock, union sockaddr_union* addr)
237 237
 			    strerror(errno));
238 238
 			return -1;
239 239
 		}
240
+		if (mcast_ttl>=0){
241
+			if (setsockopt(sock, IPPROTO_IP, IP_MULTICAST_TTL, &mcast_ttl,
242
+						sizeof(mcast_ttl))==-1){
243
+				LOG(L_ERR, "ERROR: setup_mcast_rcvr: setosckopt (ttl):"
244
+						" %s\n", strerror(errno));
245
+				return -1;
246
+			}
247
+		}
240 248
 #ifdef USE_IPV6
241 249
 	} else if (addr->s.sa_family==AF_INET6){
242 250
 		memcpy(&mreq6.ipv6mr_multiaddr, &addr->sin6.sin6_addr, 
... ...
@@ -256,6 +266,14 @@ static int setup_mcast_rcvr(int sock, union sockaddr_union* addr)
256 256
 			    strerror(errno));
257 257
 			return -1;
258 258
 		}
259
+		if (mcast_ttl>=0){
260
+			if (setsockopt(sock, IPPROTO_IP, IPV6_MULTICAST_HOPS, &mcast_ttl,
261
+						sizeof(mcast_ttl))==-1){
262
+				LOG(L_ERR, "ERROR: setup_mcast_rcvr: setosckopt (ttlv6):"
263
+						" %s\n", strerror(errno));
264
+				return -1;
265
+			}
266
+		}
259 267
 #endif /* USE_IPV6 */
260 268
 	} else {
261 269
 		LOG(L_ERR, "ERROR: udp_init: Unsupported protocol family\n");