Module Name:    src
Committed By:   christos
Date:           Sun Oct 26 18:33:43 UTC 2014

Modified Files:
        src/tests/net/mcast: t_mcast.c

Log Message:
- deal with MacOS/X not having clock_*()
- change multicast address
- set the interface
XXX: Now the ipv6 code works on MacOS/X but does not work for us still.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/net/mcast/t_mcast.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/net/mcast/t_mcast.c
diff -u src/tests/net/mcast/t_mcast.c:1.8 src/tests/net/mcast/t_mcast.c:1.9
--- src/tests/net/mcast/t_mcast.c:1.8	Mon Oct 13 02:57:08 2014
+++ src/tests/net/mcast/t_mcast.c	Sun Oct 26 14:33:43 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_mcast.c,v 1.8 2014/10/13 06:57:08 martin Exp $	*/
+/*	$NetBSD: t_mcast.c,v 1.9 2014/10/26 18:33:43 christos Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 #include <sys/cdefs.h>
 #ifdef __RCSID
-__RCSID("$NetBSD: t_mcast.c,v 1.8 2014/10/13 06:57:08 martin Exp $");
+__RCSID("$NetBSD: t_mcast.c,v 1.9 2014/10/26 18:33:43 christos Exp $");
 #else
 extern const char *__progname;
 #define getprogname() __progname
@@ -39,6 +39,7 @@ extern const char *__progname;
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/wait.h>
+#include <sys/time.h>
 #include <netinet/in.h>
 
 #include <assert.h>
@@ -77,7 +78,7 @@ static int debug;
 #define PORT_V4 "6666"
 #define HOST_V4 "239.1.1.1"
 #define PORT_V6 "6666"
-#define HOST_V6 "FF05:0:0:0:0:0:0:1"
+#define HOST_V6 "FF02:0:0:0:0:0:0:1"
 
 struct message {
 	size_t seq;
@@ -91,6 +92,7 @@ addmc(int s, struct addrinfo *ai, bool b
 	struct ipv6_mreq m6;
 	struct sockaddr_in *s4;
 	struct sockaddr_in6 *s6;
+	unsigned int ifc;
 	
 	switch (ai->ai_family) {
 	case AF_INET:
@@ -121,7 +123,23 @@ addmc(int s, struct addrinfo *ai, bool b
 		}
 		assert(sizeof(*s6) == ai->ai_addrlen);
 		memset(&m6, 0, sizeof(m6));
-		m6.ipv6mr_interface = 0;
+#if 0
+		ifc = 1;
+		if (setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_LOOP,
+		    &ifc, sizeof(ifc))) == -1)
+		    	return -1;
+		ifc = 224;
+		if (setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
+		    &ifc, sizeof(ifc)) == -1)
+		    	return -1;
+#endif
+#if 1
+		ifc = 1;
+		if (setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_IF, &ifc,
+		    sizeof(ifc)) == -1)
+			return -1;
+#endif
+		m6.ipv6mr_interface = ifc;
 	        m6.ipv6mr_multiaddr = s6->sin6_addr;
 		return setsockopt(s, IPPROTO_IPV6, IPV6_JOIN_GROUP,
 		    &m6, sizeof(m6));
@@ -223,8 +241,16 @@ sender(const char *host, const char *por
 
 	s = getsocket(host, port, conn ? connect : connector, &slen, bug);
 	for (msg.seq = 0; msg.seq < n; msg.seq++) {
+#ifdef CLOCK_MONOTONIC
 		if (clock_gettime(CLOCK_MONOTONIC, &msg.ts) == -1)
 			ERRX(EXIT_FAILURE, "clock (%s)", strerror(errno));
+#else
+		struct timeval tv;
+		if (gettimeofday(&tv, NULL) == -1)
+			ERRX(EXIT_FAILURE, "clock (%s)", strerror(errno));
+		msg.ts.tv_sec = tv.tv_sec;
+		msg.ts.tv_nsec = tv.tv_usec * 1000;
+#endif
 		if (debug)
 			show("sending", &msg);
 		l = conn ? send(s, &msg, sizeof(msg), 0) :

Reply via email to