patches/gnome-nettool-01-sun-patch.diff
author gheet
Tue, 26 Aug 2008 14:36:02 +0000
changeset 13287 18e1d615e957
parent 13285 ce15225eaad7
child 13492 fa06dfd3a477
permissions -rw-r--r--
2008-08-26 Ghee Teo <[email protected]> Updated spec files to make sure directory attributes are correct and also full libraries linkage. * SUNWgnome-nettool.spec: * patches/gnome-nettool-01-sun-patch.diff:
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13285
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
     1
diff -urN gnome-nettool-2.22.0.orig/configure.in gnome-nettool-2.22.0.hacked/configure.in
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
     2
--- gnome-nettool-2.22.0.orig/configure.in	2008-03-10 18:07:42.000000000 +0000
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
     3
+++ gnome-nettool-2.22.0.hacked/configure.in	2008-07-17 15:42:01.347558000 +0100
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
     4
@@ -16,7 +16,7 @@
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
     5
 AC_PROG_CC
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
     6
 AC_HEADER_STDC([])
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
     7
 AC_CHECK_HEADERS(sys/sockio.h)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
     8
-AC_CHECK_HEADERS(sys/socket.h ifaddrs.h,,AC_MSG_ERROR(Required header not found: $ac_header))
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
     9
+AC_CHECK_HEADERS(sys/socket.h,,AC_MSG_ERROR(Required header not found: $ac_header))
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    10
 dnl AC_ARG_PROGRAM
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    11
 AM_PROG_LIBTOOL
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    12
 
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    13
diff -urN gnome-nettool-2.22.0.orig/src/Makefile.am gnome-nettool-2.22.0.hacked/src/Makefile.am
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    14
--- gnome-nettool-2.22.0.orig/src/Makefile.am	2008-02-12 18:25:08.000000000 +0000
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    15
+++ gnome-nettool-2.22.0.hacked/src/Makefile.am	2008-08-04 11:32:51.208692000 +0100
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    16
@@ -8,11 +8,12 @@
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    17
 	@NETTOOL_CFLAGS@
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    18
 
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    19
 LDADD =				\
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    20
-	$(NETTOOL_LIBS)	
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    21
+	$(NETTOOL_LIBS)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    22
 
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    23
 bin_PROGRAMS = gnome-nettool
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    24
 
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    25
 gnome_nettool_SOURCES = \
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    26
+	getifaddrs.c ifaddrs.h \
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    27
 	callbacks.c callbacks.h \
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    28
 	nettool.c nettool.h \
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    29
 	gn-combo-history.c gn-combo-history.h \
13287
18e1d615e957 2008-08-26 Ghee Teo <[email protected]>
gheet
parents: 13285
diff changeset
    30
@@ -29,7 +30,11 @@
13285
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    31
 	util-mii-wireless.h \
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    32
 	main.c
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    33
 
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    34
-gnome_nettool_LDADD = @NETTOOL_LIBS@
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    35
+gnome_nettool_LDADD = @NETTOOL_LIBS@	\
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    36
+		      -lresolv	\
13287
18e1d615e957 2008-08-26 Ghee Teo <[email protected]>
gheet
parents: 13285
diff changeset
    37
+		      -lsocket	\
18e1d615e957 2008-08-26 Ghee Teo <[email protected]>
gheet
parents: 13285
diff changeset
    38
+		      -lnsl	\
13285
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    39
+		      -lkstat
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    40
 
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    41
 EXTRA_DIST  = \
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    42
 	gnome-nettool.desktop.in \
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    43
diff -urN gnome-nettool-2.22.0.orig/src/getifaddrs.c gnome-nettool-2.22.0.hacked/src/getifaddrs.c
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    44
--- gnome-nettool-2.22.0.orig/src/getifaddrs.c	1970-01-01 01:00:00.000000000 +0100
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    45
+++ gnome-nettool-2.22.0.hacked/src/getifaddrs.c	2008-08-01 11:00:40.965611000 +0100
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    46
@@ -0,0 +1,217 @@
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    47
+/*
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    48
+ * Copyright (c) 2006 WIDE Project. All rights reserved.
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    49
+ *
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    50
+ * Redistribution and use in source and binary forms, with or without
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    51
+ * modification, are permitted provided that the following conditions
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    52
+ * are met:
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    53
+ * 1. Redistributions of source code must retain the above copyright
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    54
+ *    notice, this list of conditions and the following disclaimer.
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    55
+ * 2. Redistributions in binary form must reproduce the above copyright
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    56
+ *    notice, this list of conditions and the following disclaimer in the
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    57
+ *    documentation and/or other materials provided with the distribution.
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    58
+ * 3. Neither the name of the project nor the names of its contributors
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    59
+ *    may be used to endorse or promote products derived from this software
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    60
+ *    without specific prior written permission.
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    61
+ * 
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    62
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    63
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    64
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    65
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    66
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    67
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    68
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    69
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    70
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    71
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    72
+ * SUCH DAMAGE.
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    73
+ */
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    74
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    75
+#include <unistd.h>
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    76
+#include <stdlib.h>
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    77
+#include <errno.h>
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    78
+#include <string.h>
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    79
+#include <sys/sockio.h>
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    80
+#include <sys/socket.h>
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    81
+#include <net/if.h>
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    82
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    83
+#include "ifaddrs.h"
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    84
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    85
+static int
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    86
+get_lifreq(int fd, struct lifreq **ifr_ret)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    87
+{
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    88
+	struct lifnum lifn;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    89
+	struct lifconf lifc;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    90
+	struct lifreq *lifrp;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    91
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    92
+	lifn.lifn_family = AF_UNSPEC;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    93
+	lifn.lifn_flags = 0;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    94
+	if (ioctl(fd, SIOCGLIFNUM, &lifn) == -1)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    95
+		lifn.lifn_count = 16;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    96
+	else
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    97
+		lifn.lifn_count += 16;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    98
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
    99
+	for (;;) {
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   100
+		lifc.lifc_len = lifn.lifn_count * sizeof (*lifrp);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   101
+		lifrp = malloc(lifc.lifc_len);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   102
+		if (lifrp == NULL)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   103
+			return (-1);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   104
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   105
+		lifc.lifc_family = AF_UNSPEC;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   106
+		lifc.lifc_flags = 0;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   107
+		lifc.lifc_buf = (char *)lifrp;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   108
+		if (ioctl(fd, SIOCGLIFCONF, &lifc) == -1) {
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   109
+			free(lifrp);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   110
+			if (errno == EINVAL) {
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   111
+				lifn.lifn_count <<= 1;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   112
+				continue;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   113
+			}
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   114
+			(void) close(fd);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   115
+			return (-1);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   116
+		}
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   117
+		if (lifc.lifc_len < (lifn.lifn_count - 1) * sizeof (*lifrp))
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   118
+			break;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   119
+		free(lifrp);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   120
+		lifn.lifn_count <<= 1;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   121
+	}
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   122
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   123
+	*ifr_ret = lifrp;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   124
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   125
+	return (lifc.lifc_len / sizeof (*lifrp));
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   126
+}
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   127
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   128
+static size_t
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   129
+nbytes(const struct lifreq *lifrp, int nlif, size_t socklen)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   130
+{
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   131
+	size_t len = 0;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   132
+	size_t slen;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   133
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   134
+	while (nlif > 0) {
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   135
+		slen = strlen(lifrp->lifr_name) + 1;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   136
+		len += sizeof (struct ifaddrs) + ((slen + 3) & ~3);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   137
+		len += 3 * socklen;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   138
+		lifrp++;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   139
+		nlif--;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   140
+	}
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   141
+	return (len);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   142
+}
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   143
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   144
+static struct sockaddr *
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   145
+addrcpy(struct sockaddr_storage *addr, char **bufp)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   146
+{
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   147
+	char *buf = *bufp;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   148
+	size_t len;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   149
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   150
+	len = addr->ss_family == AF_INET ? sizeof (struct sockaddr_in) :
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   151
+	    sizeof (struct sockaddr_in6);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   152
+	(void) memcpy(buf, addr, len);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   153
+	*bufp = buf + len;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   154
+	return ((struct sockaddr *)buf);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   155
+}
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   156
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   157
+static int
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   158
+populate(struct ifaddrs *ifa, int fd, struct lifreq *lifrp, int nlif, int af,
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   159
+    char **bufp)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   160
+{
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   161
+	char *buf = *bufp;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   162
+	size_t slen;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   163
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   164
+	while (nlif > 0) {
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   165
+		ifa->ifa_next = (nlif > 1) ? ifa + 1 : NULL;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   166
+		(void) strcpy(ifa->ifa_name = buf, lifrp->lifr_name);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   167
+		slen = strlen(lifrp->lifr_name) + 1;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   168
+		buf += (slen + 3) & ~3;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   169
+		if (ioctl(fd, SIOCGLIFFLAGS, lifrp) == -1)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   170
+			ifa->ifa_flags = 0;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   171
+		else
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   172
+			ifa->ifa_flags = lifrp->lifr_flags;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   173
+		if (ioctl(fd, SIOCGLIFADDR, lifrp) == -1)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   174
+			ifa->ifa_addr = NULL;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   175
+		else
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   176
+			ifa->ifa_addr = addrcpy(&lifrp->lifr_addr, &buf);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   177
+		if (ioctl(fd, SIOCGLIFNETMASK, lifrp) == -1)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   178
+			ifa->ifa_netmask = NULL;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   179
+		else
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   180
+			ifa->ifa_netmask = addrcpy(&lifrp->lifr_addr, &buf);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   181
+		if (ifa->ifa_flags & IFF_POINTOPOINT) {
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   182
+			if (ioctl(fd, SIOCGLIFDSTADDR, lifrp) == -1)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   183
+				ifa->ifa_dstaddr = NULL;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   184
+			else
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   185
+				ifa->ifa_dstaddr =
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   186
+				    addrcpy(&lifrp->lifr_dstaddr, &buf);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   187
+		} else if (ifa->ifa_flags & IFF_BROADCAST) {
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   188
+			if (ioctl(fd, SIOCGLIFBRDADDR, lifrp) == -1)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   189
+				ifa->ifa_broadaddr = NULL;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   190
+			else
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   191
+				ifa->ifa_broadaddr =
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   192
+				    addrcpy(&lifrp->lifr_broadaddr, &buf);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   193
+		} else {
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   194
+			ifa->ifa_dstaddr = NULL;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   195
+		}
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   196
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   197
+		ifa++;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   198
+		nlif--;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   199
+		lifrp++;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   200
+	}
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   201
+	*bufp = buf;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   202
+	return (0);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   203
+}
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   204
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   205
+int
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   206
+getifaddrs(struct ifaddrs **ifap)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   207
+{
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   208
+	int fd4, fd6;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   209
+	int nif4, nif6 = 0;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   210
+	struct lifreq *ifr4 = NULL;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   211
+	struct lifreq *ifr6 = NULL;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   212
+	struct ifaddrs *ifa = NULL;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   213
+	char *buf;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   214
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   215
+	if ((fd4 = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   216
+		return (-1);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   217
+	if ((fd6 = socket(AF_INET6, SOCK_DGRAM, 0)) == -1 &&
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   218
+	    errno != EAFNOSUPPORT) {
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   219
+		(void) close(fd4);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   220
+		return (-1);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   221
+	}
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   222
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   223
+	if ((nif4 = get_lifreq(fd4, &ifr4)) == -1 ||
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   224
+	    (fd6 != -1 && (nif6 = get_lifreq(fd6, &ifr6)) == -1))
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   225
+		goto failure;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   226
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   227
+	if (nif4 == 0 && nif6 == 0) {
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   228
+		*ifap = NULL;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   229
+		return (0);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   230
+	}
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   231
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   232
+	ifa = malloc(nbytes(ifr4, nif4, sizeof (struct sockaddr_in)) +
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   233
+	    nbytes(ifr6, nif6, sizeof (struct sockaddr_in6)));
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   234
+	if (ifa == NULL)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   235
+		goto failure;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   236
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   237
+	buf = (char *)(ifa + nif4 + nif6);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   238
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   239
+	if (populate(ifa, fd4, ifr4, nif4, AF_INET, &buf) == -1)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   240
+		goto failure;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   241
+	if (nif4 > 0 && nif6 > 0)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   242
+		ifa[nif4 - 1].ifa_next = ifa + nif4;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   243
+	if (populate(ifa + nif4, fd6, ifr6, nif6, AF_INET6, &buf) == -1)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   244
+		goto failure;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   245
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   246
+	*ifap = ifa;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   247
+	return (0);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   248
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   249
+failure:
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   250
+	free(ifa);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   251
+	(void) close(fd4);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   252
+	if (fd6 != -1)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   253
+		(void) close(fd6);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   254
+	free(ifr4);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   255
+	free(ifr6);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   256
+	return (-1);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   257
+}
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   258
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   259
+void
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   260
+freeifaddrs(struct ifaddrs *ifa)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   261
+{
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   262
+	free(ifa);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   263
+}
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   264
diff -urN gnome-nettool-2.22.0.orig/src/ifaddrs.h gnome-nettool-2.22.0.hacked/src/ifaddrs.h
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   265
--- gnome-nettool-2.22.0.orig/src/ifaddrs.h	1970-01-01 01:00:00.000000000 +0100
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   266
+++ gnome-nettool-2.22.0.hacked/src/ifaddrs.h	2008-07-28 16:03:13.251431000 +0100
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   267
@@ -0,0 +1,48 @@
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   268
+/*
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   269
+ * Copyright (c) 2006 WIDE Project. All rights reserved.
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   270
+ *
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   271
+ * Redistribution and use in source and binary forms, with or without
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   272
+ * modification, are permitted provided that the following conditions
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   273
+ * are met:
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   274
+ * 1. Redistributions of source code must retain the above copyright
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   275
+ *    notice, this list of conditions and the following disclaimer.
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   276
+ * 2. Redistributions in binary form must reproduce the above copyright
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   277
+ *    notice, this list of conditions and the following disclaimer in the
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   278
+ *    documentation and/or other materials provided with the distribution.
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   279
+ * 3. Neither the name of the project nor the names of its contributors
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   280
+ *    may be used to endorse or promote products derived from this software
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   281
+ *    without specific prior written permission.
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   282
+ * 
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   283
+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   284
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   285
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   286
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   287
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   288
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   289
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   290
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   291
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   292
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   293
+ * SUCH DAMAGE.
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   294
+ */
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   295
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   296
+#ifndef __IFADDRS_H
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   297
+#define __IFADDRS_H
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   298
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   299
+#include <sys/types.h>
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   300
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   301
+#undef ifa_broadaddr
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   302
+#undef ifa_dstaddr
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   303
+struct ifaddrs {
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   304
+	struct ifaddrs	*ifa_next;	/* Pointer to next struct */
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   305
+	char		*ifa_name;	/* Interface name */
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   306
+	uint64_t	ifa_flags;	/* Interface flags */
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   307
+	struct sockaddr	*ifa_addr;	/* Interface address */
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   308
+	struct sockaddr	*ifa_netmask;	/* Interface netmask */
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   309
+	struct sockaddr	*ifa_dstaddr;	/* P2P interface destination */
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   310
+};
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   311
+#define	ifa_broadaddr	ifa_dstaddr
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   312
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   313
+extern int getifaddrs(struct ifaddrs **);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   314
+extern void freeifaddrs(struct ifaddrs *);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   315
+#endif
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   316
diff -urN gnome-nettool-2.22.0.orig/src/info.c gnome-nettool-2.22.0.hacked/src/info.c
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   317
--- gnome-nettool-2.22.0.orig/src/info.c	2008-02-12 18:25:08.000000000 +0000
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   318
+++ gnome-nettool-2.22.0.hacked/src/info.c	2008-08-04 11:32:11.119602000 +0100
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   319
@@ -20,6 +20,8 @@
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   320
 #include <gtk/gtk.h>
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   321
 #include <glib/gi18n.h>
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   322
 #include <glib/gprintf.h>
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   323
+#include <errno.h>
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   324
+#include <kstat.h>
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   325
 
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   326
 #ifdef HAVE_CONFIG_H
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   327
 #  include <config.h>
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   328
@@ -208,6 +210,106 @@
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   329
 	gtk_combo_box_set_active (GTK_COMBO_BOX (info->combo), 0);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   330
 }
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   331
 
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   332
+char *
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   333
+netstatus_sysdeps_read_iface_statistics (const char  *iface,
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   334
+					 gulong      *out_bytes,
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   335
+					 gulong      *out_packets,
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   336
+					 gulong	     *out_errors,
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   337
+					 gulong      *in_bytes,
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   338
+					 gulong      *in_packets,
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   339
+					 gulong      *in_errors,
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   340
+					 gulong      *collisions,
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   341
+					 gulong      *if_speed)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   342
+{
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   343
+  char *error_message = NULL;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   344
+  static kstat_ctl_t *kc = NULL;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   345
+  kstat_t *ksp;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   346
+  kstat_named_t *kn;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   347
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   348
+  /*
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   349
+   * The linux-specific code uses -1 as the default value.  But if we return -1
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   350
+   * (see comment below), then it gets interpreted as (unsigned long)-1, which
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   351
+   * looks stupid and is definitely more wrong than just showing 0.
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   352
+   */
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   353
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   354
+  *out_bytes = 0;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   355
+  *out_packets = 0;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   356
+  *out_errors = 0;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   357
+  *in_bytes = 0;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   358
+  *in_packets = 0;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   359
+  *in_errors = 0;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   360
+  *collisions = 0;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   361
+  *if_speed = 0;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   362
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   363
+  if (kc == NULL)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   364
+    {
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   365
+      if ((kc = kstat_open ()) == NULL)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   366
+	return g_strdup_printf ("Cannot open /dev/kstat: %s",
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   367
+		g_strerror (errno));
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   368
+    }
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   369
+  else
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   370
+    {
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   371
+      if (kstat_chain_update (kc) < 0)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   372
+	{
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   373
+	  int e = errno;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   374
+	  kstat_close (kc);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   375
+	  kc = NULL;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   376
+	  return g_strdup_printf ("Cannot update kstats: %s",
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   377
+		  g_strerror (e));
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   378
+	}
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   379
+    }
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   380
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   381
+  if ((ksp = kstat_lookup (kc, NULL, -1, iface)) == NULL)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   382
+    {
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   383
+      kstat_close (kc);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   384
+      kc = NULL;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   385
+      return g_strdup_printf ("Cannot find information on interface '%s'",
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   386
+	iface);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   387
+    }
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   388
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   389
+  if (kstat_read (kc, ksp, NULL) < 0)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   390
+    {
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   391
+      kstat_close (kc);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   392
+      kc = NULL;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   393
+      return g_strdup_printf ("Cannot read kstat");
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   394
+    }
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   395
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   396
+  if ((kn = kstat_data_lookup (ksp, "rbytes")) != NULL)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   397
+    *in_bytes = kn->value.ui32;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   398
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   399
+  if ((kn = kstat_data_lookup (ksp, "opackets")) != NULL)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   400
+    *out_packets = kn->value.ui32;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   401
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   402
+  if ((kn = kstat_data_lookup (ksp, "oerrors")) != NULL)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   403
+    *out_errors = kn->value.ui32;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   404
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   405
+  if ((kn = kstat_data_lookup (ksp, "obytes")) != NULL)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   406
+    *out_bytes = kn->value.ui32;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   407
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   408
+  if ((kn = kstat_data_lookup (ksp, "ipackets")) != NULL)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   409
+    *in_packets = kn->value.ui32;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   410
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   411
+  if ((kn = kstat_data_lookup (ksp, "ierrors")) != NULL)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   412
+    *in_errors = kn->value.ui32;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   413
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   414
+  if ((kn = kstat_data_lookup (ksp, "collisions")) != NULL)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   415
+    *collisions = kn->value.ui32;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   416
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   417
+  if ((kn = kstat_data_lookup (ksp, "ifspeed")) != NULL)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   418
+    *if_speed = kn->value.ui32;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   419
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   420
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   421
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   422
+  /*
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   423
+   * On Solaris, loopback doesn't report bytes, just packets.  The behavior of
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   424
+   * the linux-specific code reports an error if all the data is not present,
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   425
+   * and that shuts the applet down.  So perhaps it's best to simply return
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   426
+   * success if we can access the data at all.
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   427
+   */
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   428
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   429
+  return NULL;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   430
+}
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   431
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   432
 static gboolean
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   433
 info_nic_update_stats (gpointer data)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   434
 {
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   435
@@ -279,6 +381,28 @@
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   436
 	g_io_channel_unref (io);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   437
 #endif /* defined(__linux__) */
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   438
 
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   439
+	gulong out_bytes, out_pkts, out_err, in_bytes, in_pkts, in_err, collisions, ifspeed;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   440
+	char buf[128];
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   441
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   442
+	netstatus_sysdeps_read_iface_statistics (text, &out_bytes, &out_pkts, &out_err,
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   443
+						 &in_bytes, &in_pkts, &in_err, 
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   444
+						 &collisions, &ifspeed);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   445
+	snprintf (buf, 128, "%ld", out_bytes);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   446
+	gtk_label_set_text (GTK_LABEL (info->tx_bytes), buf);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   447
+	snprintf (buf, 128, "%ld", out_pkts);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   448
+	gtk_label_set_text (GTK_LABEL (info->tx), buf);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   449
+	snprintf (buf, 128, "%ld", out_err);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   450
+	gtk_label_set_text (GTK_LABEL (info->tx_errors), buf);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   451
+	snprintf (buf, 128, "%ld", in_bytes);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   452
+	gtk_label_set_text (GTK_LABEL (info->rx_bytes), buf);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   453
+	snprintf (buf, 128, "%ld", in_pkts);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   454
+	gtk_label_set_text (GTK_LABEL (info->rx), buf);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   455
+	snprintf (buf, 128, "%ld", in_err);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   456
+	gtk_label_set_text (GTK_LABEL (info->rx_errors), buf);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   457
+	snprintf (buf, 128, "%ld", collisions);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   458
+	gtk_label_set_text (GTK_LABEL (info->collisions), buf);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   459
+	snprintf (buf, 128, "%ld", ifspeed);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   460
+	gtk_label_set_text (GTK_LABEL (info->link_speed), buf);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   461
 	return TRUE;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   462
 }
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   463
 
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   464
@@ -369,7 +493,7 @@
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   465
 		scope = g_strdup ("Link");
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   466
 	else if (IN6_IS_ADDR_SITELOCAL (&sinptr6->sin6_addr))
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   467
 		scope = g_strdup ("Site");
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   468
-	else if (IN6_IS_ADDR_GLOBAL (&sinptr6->sin6_addr))
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   469
+	else if (IN6_IS_ADDR_MC_GLOBAL (&sinptr6->sin6_addr))
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   470
 		scope = g_strdup ("Global");
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   471
 	else if (IN6_IS_ADDR_MC_ORGLOCAL (&sinptr6->sin6_addr))
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   472
 		scope = g_strdup ("Global");
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   473
diff -urN gnome-nettool-2.22.0.orig/src/main.c gnome-nettool-2.22.0.hacked/src/main.c
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   474
--- gnome-nettool-2.22.0.orig/src/main.c	2008-02-12 18:25:08.000000000 +0000
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   475
+++ gnome-nettool-2.22.0.hacked/src/main.c	2008-07-28 15:45:28.844550000 +0100
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   476
@@ -151,6 +151,7 @@
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   477
 		current_page = INFO;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   478
 		info_set_nic (info, info_input);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   479
 	}
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   480
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   481
 	if (ping_input) {
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   482
 		current_page = PING;
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   483
 		netinfo_set_host (pinger, ping_input);
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   484
diff -urN gnome-nettool-2.22.0.orig/src/netstat.h gnome-nettool-2.22.0.hacked/src/netstat.h
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   485
--- gnome-nettool-2.22.0.orig/src/netstat.h	2008-02-12 18:25:08.000000000 +0000
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   486
+++ gnome-nettool-2.22.0.hacked/src/netstat.h	2008-07-17 15:47:02.608512000 +0100
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   487
@@ -30,10 +30,11 @@
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   488
 #   define NETSTAT_ROUTE6_FORMAT "%s %s %s %d %d %d %s"
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   489
 #   define NETSTAT_MULTICAST_FORMAT "%s %d %s"
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   490
 
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   491
-#elif defined(__FreeBSD__) || defined(__OpenBSD__)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   492
+#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(sun)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   493
 #   define NETSTAT_PROTOCOL_FORMAT "%s %d %d %d.%d.%d.%d.%s %s %s"
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   494
 #   define ALT_NETSTAT_PROTOCOL_FORMAT "%s %d %d *.%s %s %s"
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   495
 #   define NETSTAT_ROUTE_FORMAT "%s %s %s %d %d %s"
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   496
+#   define NETSTAT_ROUTE6_FORMAT "%s %s %s %d %d %d %s"
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   497
 #   define NETSTAT_MULTICAST_FORMAT "%s %d %s"
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   498
 
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   499
 #endif
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   500
diff -urN gnome-nettool-2.22.0.orig/src/ping.c gnome-nettool-2.22.0.hacked/src/ping.c
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   501
--- gnome-nettool-2.22.0.orig/src/ping.c	2008-02-12 18:25:08.000000000 +0000
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   502
+++ gnome-nettool-2.22.0.hacked/src/ping.c	2008-07-17 15:40:39.680340000 +0100
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   503
@@ -310,7 +310,7 @@
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   504
 	}
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   505
 	
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   506
 	if (program != NULL) {
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   507
-#if defined(__sun__) || defined(__hpux__)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   508
+#if defined(sun) || defined(__hpux__)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   509
 		if (ip_version == IPV4)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   510
 			command =
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   511
 				g_strdup_printf (PING_PROGRAM_FORMAT, program, host,
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   512
diff -urN gnome-nettool-2.22.0.orig/src/ping.h gnome-nettool-2.22.0.hacked/src/ping.h
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   513
--- gnome-nettool-2.22.0.orig/src/ping.h	2008-02-12 18:25:08.000000000 +0000
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   514
+++ gnome-nettool-2.22.0.hacked/src/ping.h	2008-07-17 15:40:16.548135000 +0100
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   515
@@ -35,7 +35,7 @@
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   516
 #   define PING_PROGRAM_FORMAT_6 "%s ping6 -c %d -n %s"
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   517
 #   define PING_FORMAT "%d bytes from %s icmp_seq=%d ttl=%d time=%s %s"
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   518
 #   define PING_PARAMS_6
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   519
-#elif defined(__sun__) 
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   520
+#elif defined(sun) 
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   521
 #   define PING_PROGRAM_FORMAT "%s ping -s -n %s 56 %d"
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   522
 #   define PING_PROGRAM_FORMAT_6 "%s ping -s -A inet6 -a -n %s 56 %d"
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   523
 #   define PING_FORMAT "%d bytes from %s icmp_seq=%d. time=%f %s"
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   524
diff -urN gnome-nettool-2.22.0.orig/src/utils.h gnome-nettool-2.22.0.hacked/src/utils.h
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   525
--- gnome-nettool-2.22.0.orig/src/utils.h	2008-02-12 18:25:08.000000000 +0000
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   526
+++ gnome-nettool-2.22.0.hacked/src/utils.h	2008-07-21 11:42:26.388716000 +0100
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   527
@@ -29,6 +29,8 @@
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   528
 #  include <config.h>
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   529
 #endif
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   530
 
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   531
+#define gethostbyname2 res_gethostbyname2
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   532
+
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   533
 #if (GLIB_MINOR_VERSION < 2)
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   534
 
ce15225eaad7 2008-08-26 Ghee Teo <[email protected]>
gheet
parents:
diff changeset
   535
 #  define _g_vsprintf  vsprintf