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