Minor patch for porting to Solaris 10
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mtr |
New
|
Undecided
|
Unassigned | ||
Nexenta Operating System |
New
|
Undecided
|
Unassigned |
Bug Description
I had some trouble getting mtr to compile on Solaris 10. Solaris needs an extra header, and it's picky about the bind and connect calls. This patch seems to have solved my problems. It seems to work on both sparc and i86pc. It does not seem to break linux.
diff --git a/configure.ac b/configure.ac
index d50c253..57a096d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -17,7 +17,7 @@ AC_CHECK_
AC_CHECK_
AC_CHECK_
-AC_CHECK_
+AC_CHECK_
AC_CHECK_
# We don't refer to any symbols in termcap, but -lcurses on SunOS does.
diff --git a/net.c b/net.c
index d648804..caf57fe 100644
--- a/net.c
+++ b/net.c
@@ -33,6 +33,9 @@
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
+#ifdef HAVE_SYS_FILIO_H
+#include <sys/filio.h>
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
@@ -337,10 +340,23 @@ void net_send_tcp(int index)
#endif
}
- if (bind(s, (struct sockaddr *) &local, sizeof (local))) {
- display_clear();
- perror("bind()");
- exit(EXIT_FAILURE);
+ switch (af) {
+ case AF_INET:
+ if (bind(s, (struct sockaddr *) local4, sizeof (struct sockaddr_in))) {
+ display_clear();
+ perror("bind()");
+ exit(EXIT_FAILURE);
+ }
+ break;
+#ifdef ENABLE_IPV6
+ case AF_INET6:
+ if (bind(s, (struct sockaddr *) local6, sizeof (struct sockaddr_in6))) {
+ display_clear();
+ perror("bind()");
+ exit(EXIT_FAILURE);
+ }
+ break;
+#endif
}
len = sizeof (local);
@@ -400,7 +416,17 @@ void net_send_tcp(int index)
gettimeofday
sequence[
- connect(s, (struct sockaddr *) &remote, sizeof (remote));
+ switch (af) {
+ case AF_INET:
+ connect(s, (struct sockaddr *) remote4, sizeof (struct sockaddr_in));
+ break;
+#ifdef ENABLE_IPV6
+ case AF_INET6:
+ connect(s, (struct sockaddr *) remote6, sizeof (struct sockaddr_in6));
+ break;
+#endif
+ }
+
}
/* Attempt to find the host at a particular number of hops away */
Nexenta OS builds on top of OpenSolaris kernel and is affected by the same problem.