Add gnomenetstatus, a GNOME 2 applet that displays network usage similar to
the Windows task bar icon (i.e. with two computer monitors blinking based in input and output traffic).
This commit is contained in:
parent
7ef90db4b1
commit
21079947e1
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=97194
@ -185,6 +185,7 @@
|
||||
SUBDIR += gnome-vnc
|
||||
SUBDIR += gnomeicu2
|
||||
SUBDIR += gnomemeeting
|
||||
SUBDIR += gnomenetstatus
|
||||
SUBDIR += gnometelnet
|
||||
SUBDIR += gnosamba
|
||||
SUBDIR += gnu-finger
|
||||
|
28
net/gnome-netstatus/Makefile
Normal file
28
net/gnome-netstatus/Makefile
Normal file
@ -0,0 +1,28 @@
|
||||
# New ports collection makefile for: gnomenetstatus
|
||||
# Date Created: 05 December 2003
|
||||
# Whom: Joe Marcus Clarke <marcus@FreeBSD.org>
|
||||
#
|
||||
# $FreeBSD$
|
||||
#
|
||||
|
||||
PORTNAME= gnomenetstatus
|
||||
PORTVERSION= 0.12
|
||||
PORTREVISION= 1
|
||||
CATEGORIES= net gnome
|
||||
MASTER_SITES= ${MASTER_SITE_GNOME}
|
||||
MASTER_SITE_SUBDIR= sources/gnome-netstatus/0.12
|
||||
DISTNAME= gnome-netstatus-${PORTVERSION}
|
||||
DIST_SUBDIR= gnome2
|
||||
|
||||
MAINTAINER= gnome@FreeBSD.org
|
||||
COMMENT= A GNOME applet that shows network status
|
||||
|
||||
USE_X_PREFIX= yes
|
||||
USE_BZIP2= yes
|
||||
USE_GNOME= gnomehack gnomeprefix libgnome
|
||||
USE_GMAKE= yes
|
||||
USE_LIBTOOL= yes
|
||||
CONFIGURE_ARGS= CPPFLAGS="-I${LOCALBASE}/include" \
|
||||
LDFLAGS="-L${LOCALBASE}/lib"
|
||||
|
||||
.include <bsd.port.mk>
|
1
net/gnome-netstatus/distinfo
Normal file
1
net/gnome-netstatus/distinfo
Normal file
@ -0,0 +1 @@
|
||||
MD5 (gnome2/gnome-netstatus-0.12.tar.bz2) = 9977c8fddaaa335c86772da56a591112
|
10
net/gnome-netstatus/files/patch-configure
Normal file
10
net/gnome-netstatus/files/patch-configure
Normal file
@ -0,0 +1,10 @@
|
||||
--- configure.orig Wed Dec 11 18:31:51 2002
|
||||
+++ configure Thu Dec 12 12:07:17 2002
|
||||
@@ -7414,6 +7414,7 @@
|
||||
|
||||
# This can be used to rebuild libtool when needed
|
||||
LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
|
||||
+$ac_aux_dir/ltconfig $LIBTOOL_DEPS
|
||||
|
||||
# Always use our own libtool.
|
||||
LIBTOOL='$(SHELL) $(top_builddir)/libtool'
|
114
net/gnome-netstatus/files/patch-src_netstatus-iface.c
Normal file
114
net/gnome-netstatus/files/patch-src_netstatus-iface.c
Normal file
@ -0,0 +1,114 @@
|
||||
--- src/netstatus-iface.c.orig Fri Oct 31 08:49:51 2003
|
||||
+++ src/netstatus-iface.c Fri Jan 2 23:29:27 2004
|
||||
@@ -32,9 +32,12 @@
|
||||
|
||||
#include <libgnome/gnome-i18n.h>
|
||||
|
||||
+#include <sys/types.h>
|
||||
+#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_arp.h>
|
||||
+#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
@@ -577,6 +580,7 @@
|
||||
iface);
|
||||
|
||||
netstatus_iface_monitor_timeout (iface);
|
||||
+
|
||||
}
|
||||
}
|
||||
|
||||
@@ -646,7 +650,11 @@
|
||||
strncpy (if_req.ifr_name, iface->priv->name, IF_NAMESIZE - 1);
|
||||
if_req.ifr_name [IF_NAMESIZE - 1] = '\0';
|
||||
if (mask && ioctl (fd, SIOCGIFNETMASK, &if_req) == 0)
|
||||
+#if !defined(__FreeBSD__)
|
||||
*mask = g_strdup (inet_ntoa (((struct sockaddr_in *) &if_req.ifr_netmask)->sin_addr));
|
||||
+#else
|
||||
+ *mask = g_strdup (inet_ntoa (((struct sockaddr_in *) &if_req.ifr_addr)->sin_addr));
|
||||
+#endif
|
||||
|
||||
close (fd);
|
||||
|
||||
@@ -925,6 +933,7 @@
|
||||
char **hw_addr)
|
||||
|
||||
{
|
||||
+#ifdef SIOCGIFHWADDR
|
||||
static struct HwType *hw_type = NULL;
|
||||
struct ifreq if_req;
|
||||
int fd;
|
||||
@@ -973,6 +982,9 @@
|
||||
*hw_addr = hw_type->print_hw_addr (if_req.ifr_hwaddr.sa_data);
|
||||
|
||||
return hw_type;
|
||||
+#else
|
||||
+ return NULL;
|
||||
+#endif
|
||||
}
|
||||
|
||||
gboolean
|
||||
@@ -1083,8 +1095,11 @@
|
||||
struct ifconf *if_conf;
|
||||
GList *interfaces;
|
||||
GList *loopbacks;
|
||||
+ gchar *ptr;
|
||||
int fd;
|
||||
- int i;
|
||||
+ struct ifreq *if_req;
|
||||
+ int len;
|
||||
+ gboolean loopback;
|
||||
|
||||
if ((fd = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
|
||||
{
|
||||
@@ -1105,12 +1120,25 @@
|
||||
interfaces = NULL;
|
||||
loopbacks = NULL;
|
||||
|
||||
- for (i = 0; i < if_conf->ifc_len / sizeof (struct ifreq); i++)
|
||||
+ for (ptr = if_conf->ifc_buf; ptr < if_conf->ifc_buf + if_conf->ifc_len;)
|
||||
{
|
||||
- struct ifreq if_req = if_conf->ifc_req [i];
|
||||
- gboolean loopback = FALSE;
|
||||
+ if_req = (struct ifreq *) ptr;
|
||||
+ loopback = FALSE;
|
||||
+ len = sizeof(struct sockaddr);
|
||||
+#if defined(HAVE_SOCKADDR_SA_LEN) || defined(__FreeBSD__)
|
||||
+ if (if_req->ifr_addr.sa_len > len)
|
||||
+ len = if_req->ifr_addr.sa_len;
|
||||
+#endif
|
||||
+
|
||||
+ ptr += sizeof(if_req->ifr_name) + len;
|
||||
+
|
||||
+ if (g_list_find_custom (interfaces, if_req->ifr_name,
|
||||
+ (GCompareFunc) g_ascii_strcasecmp) != NULL
|
||||
+ || g_list_find_custom (loopbacks, if_req->ifr_name,
|
||||
+ (GCompareFunc) g_ascii_strcasecmp) != NULL)
|
||||
+ continue;
|
||||
|
||||
- if (ioctl (fd, SIOCGIFFLAGS, &if_req) < 0)
|
||||
+ if (ioctl (fd, SIOCGIFFLAGS, if_req) < 0)
|
||||
{
|
||||
if (error)
|
||||
*error = g_error_new (NETSTATUS_ERROR,
|
||||
@@ -1120,13 +1148,14 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
- loopback = (if_req.ifr_flags & IFF_LOOPBACK);
|
||||
+ loopback = (if_req->ifr_flags & IFF_LOOPBACK);
|
||||
}
|
||||
|
||||
if (!loopback)
|
||||
- interfaces = g_list_prepend (interfaces, g_strdup (if_req.ifr_name));
|
||||
+ interfaces = g_list_prepend (interfaces, g_strdup (if_req->ifr_name));
|
||||
else
|
||||
- loopbacks = g_list_prepend (loopbacks, g_strdup (if_req.ifr_name));
|
||||
+ loopbacks = g_list_prepend (loopbacks, g_strdup (if_req->ifr_name));
|
||||
+
|
||||
}
|
||||
|
||||
interfaces = g_list_concat (interfaces, loopbacks);
|
160
net/gnome-netstatus/files/patch-src_netstatus-sysdeps.c
Normal file
160
net/gnome-netstatus/files/patch-src_netstatus-sysdeps.c
Normal file
@ -0,0 +1,160 @@
|
||||
--- src/netstatus-sysdeps.c.orig Mon Jun 9 13:18:04 2003
|
||||
+++ src/netstatus-sysdeps.c Fri Jan 2 23:29:16 2004
|
||||
@@ -27,10 +27,13 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
+#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <glib.h>
|
||||
#include <libgnome/gnome-i18n.h>
|
||||
|
||||
+#if !defined(__FreeBSD__)
|
||||
+
|
||||
static inline char *
|
||||
parse_iface_name (const char *buf)
|
||||
{
|
||||
@@ -90,6 +93,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
+#endif
|
||||
|
||||
static inline int
|
||||
parse_stats (char *buf,
|
||||
@@ -124,6 +128,8 @@
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
+#if !defined(__FreeBSD__)
|
||||
+
|
||||
static inline FILE *
|
||||
get_proc_net_dev_fh (void)
|
||||
{
|
||||
@@ -206,3 +212,126 @@
|
||||
|
||||
return error_message;
|
||||
}
|
||||
+
|
||||
+#else
|
||||
+
|
||||
+static inline void
|
||||
+parse_header (char *buf,
|
||||
+ int *prx_idx,
|
||||
+ int *ptx_idx,
|
||||
+ int *brx_idx,
|
||||
+ int *btx_idx)
|
||||
+{
|
||||
+ char *p;
|
||||
+ int i;
|
||||
+
|
||||
+ *prx_idx = *ptx_idx = -1;
|
||||
+ *brx_idx = *btx_idx = -1;
|
||||
+
|
||||
+ p = strtok (buf, " \n\t");
|
||||
+ for (i = 0; p; i++, p = strtok (NULL, " \t\n"))
|
||||
+ {
|
||||
+ if (!strcmp (p, "Ipkts"))
|
||||
+ {
|
||||
+ *prx_idx = i;
|
||||
+ }
|
||||
+ else if (!strcmp (p, "Ibytes"))
|
||||
+ {
|
||||
+ *brx_idx = i;
|
||||
+ }
|
||||
+ else if (!strcmp (p, "Opkts"))
|
||||
+ {
|
||||
+ *ptx_idx = i;
|
||||
+ }
|
||||
+ else if (!strcmp (p, "Obytes"))
|
||||
+ {
|
||||
+ *btx_idx = i;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+char *
|
||||
+netstatus_sysdeps_read_iface_statistics (const char *iface,
|
||||
+ long *in_packets,
|
||||
+ long *out_packets,
|
||||
+ long *in_bytes,
|
||||
+ long *out_bytes)
|
||||
+{
|
||||
+ gchar *buf;
|
||||
+ gchar *cmd = NULL;
|
||||
+ gchar **command_line;
|
||||
+ int prx_idx, ptx_idx;
|
||||
+ int brx_idx, btx_idx;
|
||||
+ char *error_message = NULL;
|
||||
+ gchar *dir = g_get_current_dir ();
|
||||
+ gint pout;
|
||||
+ GIOChannel *channel;
|
||||
+ GError *err = NULL;
|
||||
+
|
||||
+ *in_packets = -1;
|
||||
+ *out_packets = -1;
|
||||
+ *in_bytes = -1;
|
||||
+ *out_bytes = -1;
|
||||
+
|
||||
+ cmd = g_strdup_printf ("/usr/bin/netstat netstat -n -I %s -b -f inet", iface);
|
||||
+ command_line = g_strsplit (cmd, " ", -1);
|
||||
+ g_free (cmd);
|
||||
+
|
||||
+ if (g_spawn_async_with_pipes (dir, command_line, NULL,
|
||||
+ G_SPAWN_FILE_AND_ARGV_ZERO, NULL,
|
||||
+ NULL, NULL, NULL, &pout,
|
||||
+ NULL, &err)) {
|
||||
+ g_strfreev (command_line);
|
||||
+ channel = g_io_channel_unix_new (pout);
|
||||
+ g_io_channel_read_line (channel, &buf, NULL, NULL, NULL);
|
||||
+
|
||||
+ parse_header (buf, &prx_idx, &ptx_idx, &brx_idx, &btx_idx);
|
||||
+ if (prx_idx == -1 || ptx_idx == -1 ||
|
||||
+ brx_idx == -1 || btx_idx == -1)
|
||||
+ {
|
||||
+ if (buf)
|
||||
+ g_free (buf);
|
||||
+ g_io_channel_unref (channel);
|
||||
+ g_io_channel_shutdown (channel, TRUE, NULL);
|
||||
+ close (pout);
|
||||
+ return g_strdup ("Could not parse netstat output. Unknown format");
|
||||
+ }
|
||||
+
|
||||
+ if (buf)
|
||||
+ g_free (buf);
|
||||
+ g_io_channel_read_line (channel, &buf, NULL, NULL, NULL);
|
||||
+
|
||||
+ if (!parse_stats (buf, prx_idx, ptx_idx, in_packets, out_packets,
|
||||
+ brx_idx, btx_idx, in_bytes, out_bytes))
|
||||
+ {
|
||||
+ if (error_message)
|
||||
+ g_free (error_message);
|
||||
+ error_message = g_strdup_printf (_("Could not parse interface statistics from '%s'. "
|
||||
+ "prx_idx = %d; ptx_idx = %d; brx_idx = %d; btx_idx = %d;"),
|
||||
+ buf, prx_idx, ptx_idx, brx_idx, btx_idx);
|
||||
+ }
|
||||
+
|
||||
+ if (buf)
|
||||
+ g_free (buf);
|
||||
+
|
||||
+ if ((*in_packets == -1 || *out_packets == -1 || *in_bytes == -1 || *out_bytes == -1) && !error_message)
|
||||
+ error_message = g_strdup_printf ("Could not obtain information on interface '%s' from netstat", iface);
|
||||
+
|
||||
+ g_io_channel_unref (channel);
|
||||
+ g_io_channel_shutdown (channel, TRUE, NULL);
|
||||
+ close (pout);
|
||||
+ }
|
||||
+ else {
|
||||
+ g_strfreev (command_line);
|
||||
+ if (error_message)
|
||||
+ g_free (error_message);
|
||||
+ error_message = g_strdup_printf ("Error running /usr/bin/netstat for '%s': %s",
|
||||
+ iface, err->message);
|
||||
+ g_error_free (err);
|
||||
+ }
|
||||
+
|
||||
+ g_free (dir);
|
||||
+
|
||||
+ return error_message;
|
||||
+}
|
||||
+#endif
|
2
net/gnome-netstatus/pkg-descr
Normal file
2
net/gnome-netstatus/pkg-descr
Normal file
@ -0,0 +1,2 @@
|
||||
Gnome-netstatus is an applet which provides information about a network
|
||||
interface on your panel.
|
40
net/gnome-netstatus/pkg-plist
Normal file
40
net/gnome-netstatus/pkg-plist
Normal file
@ -0,0 +1,40 @@
|
||||
etc/gconf/gconf.xml.defaults/apps/netstatus_applet/%gconf.xml
|
||||
etc/gconf/gconf.xml.defaults/schemas/apps/netstatus_applet/%gconf.xml
|
||||
etc/gconf/gconf.xml.defaults/schemas/apps/netstatus_applet/prefs/%gconf.xml
|
||||
etc/gconf/schemas/netstatus.schemas
|
||||
libdata/bonobo/servers/GNOME_NetstatusApplet_Factory.server
|
||||
libexec/gnome-netstatus-applet
|
||||
share/gnome/gnome-2.0/ui/GNOME_NetstatusApplet.xml
|
||||
share/gnome/gnome-netstatus/gnome-netstatus.glade
|
||||
share/gnome/icons/gnome-netstatus/gnome-netstatus-disconn.png
|
||||
share/gnome/icons/gnome-netstatus/gnome-netstatus-error.png
|
||||
share/gnome/icons/gnome-netstatus/gnome-netstatus-idle.png
|
||||
share/gnome/icons/gnome-netstatus/gnome-netstatus-rx.png
|
||||
share/gnome/icons/gnome-netstatus/gnome-netstatus-tx.png
|
||||
share/gnome/icons/gnome-netstatus/gnome-netstatus-txrx.png
|
||||
share/gnome/pixmaps/gnome-netstatus-tx.png
|
||||
share/locale/az/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/cs/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/de/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/el/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/es/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/fr/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/it/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/ja/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/ms/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/nl/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/pl/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/pt/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/ru/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/sr/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/sr@Latn/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/sv/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/tr/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/vi/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/wa/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/zh_CN/LC_MESSAGES/gnome-netstatus.mo
|
||||
@dirrm share/gnome/icons/gnome-netstatus
|
||||
@dirrm share/gnome/gnome-netstatus
|
||||
@dirrm etc/gconf/gconf.xml.defaults/schemas/apps/netstatus_applet/prefs
|
||||
@dirrm etc/gconf/gconf.xml.defaults/schemas/apps/netstatus_applet
|
||||
@dirrm etc/gconf/gconf.xml.defaults/apps/netstatus_applet
|
28
net/gnomenetstatus/Makefile
Normal file
28
net/gnomenetstatus/Makefile
Normal file
@ -0,0 +1,28 @@
|
||||
# New ports collection makefile for: gnomenetstatus
|
||||
# Date Created: 05 December 2003
|
||||
# Whom: Joe Marcus Clarke <marcus@FreeBSD.org>
|
||||
#
|
||||
# $FreeBSD$
|
||||
#
|
||||
|
||||
PORTNAME= gnomenetstatus
|
||||
PORTVERSION= 0.12
|
||||
PORTREVISION= 1
|
||||
CATEGORIES= net gnome
|
||||
MASTER_SITES= ${MASTER_SITE_GNOME}
|
||||
MASTER_SITE_SUBDIR= sources/gnome-netstatus/0.12
|
||||
DISTNAME= gnome-netstatus-${PORTVERSION}
|
||||
DIST_SUBDIR= gnome2
|
||||
|
||||
MAINTAINER= gnome@FreeBSD.org
|
||||
COMMENT= A GNOME applet that shows network status
|
||||
|
||||
USE_X_PREFIX= yes
|
||||
USE_BZIP2= yes
|
||||
USE_GNOME= gnomehack gnomeprefix libgnome
|
||||
USE_GMAKE= yes
|
||||
USE_LIBTOOL= yes
|
||||
CONFIGURE_ARGS= CPPFLAGS="-I${LOCALBASE}/include" \
|
||||
LDFLAGS="-L${LOCALBASE}/lib"
|
||||
|
||||
.include <bsd.port.mk>
|
1
net/gnomenetstatus/distinfo
Normal file
1
net/gnomenetstatus/distinfo
Normal file
@ -0,0 +1 @@
|
||||
MD5 (gnome2/gnome-netstatus-0.12.tar.bz2) = 9977c8fddaaa335c86772da56a591112
|
10
net/gnomenetstatus/files/patch-configure
Normal file
10
net/gnomenetstatus/files/patch-configure
Normal file
@ -0,0 +1,10 @@
|
||||
--- configure.orig Wed Dec 11 18:31:51 2002
|
||||
+++ configure Thu Dec 12 12:07:17 2002
|
||||
@@ -7414,6 +7414,7 @@
|
||||
|
||||
# This can be used to rebuild libtool when needed
|
||||
LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
|
||||
+$ac_aux_dir/ltconfig $LIBTOOL_DEPS
|
||||
|
||||
# Always use our own libtool.
|
||||
LIBTOOL='$(SHELL) $(top_builddir)/libtool'
|
114
net/gnomenetstatus/files/patch-src_netstatus-iface.c
Normal file
114
net/gnomenetstatus/files/patch-src_netstatus-iface.c
Normal file
@ -0,0 +1,114 @@
|
||||
--- src/netstatus-iface.c.orig Fri Oct 31 08:49:51 2003
|
||||
+++ src/netstatus-iface.c Fri Jan 2 23:29:27 2004
|
||||
@@ -32,9 +32,12 @@
|
||||
|
||||
#include <libgnome/gnome-i18n.h>
|
||||
|
||||
+#include <sys/types.h>
|
||||
+#include <sys/socket.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_arp.h>
|
||||
+#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
@@ -577,6 +580,7 @@
|
||||
iface);
|
||||
|
||||
netstatus_iface_monitor_timeout (iface);
|
||||
+
|
||||
}
|
||||
}
|
||||
|
||||
@@ -646,7 +650,11 @@
|
||||
strncpy (if_req.ifr_name, iface->priv->name, IF_NAMESIZE - 1);
|
||||
if_req.ifr_name [IF_NAMESIZE - 1] = '\0';
|
||||
if (mask && ioctl (fd, SIOCGIFNETMASK, &if_req) == 0)
|
||||
+#if !defined(__FreeBSD__)
|
||||
*mask = g_strdup (inet_ntoa (((struct sockaddr_in *) &if_req.ifr_netmask)->sin_addr));
|
||||
+#else
|
||||
+ *mask = g_strdup (inet_ntoa (((struct sockaddr_in *) &if_req.ifr_addr)->sin_addr));
|
||||
+#endif
|
||||
|
||||
close (fd);
|
||||
|
||||
@@ -925,6 +933,7 @@
|
||||
char **hw_addr)
|
||||
|
||||
{
|
||||
+#ifdef SIOCGIFHWADDR
|
||||
static struct HwType *hw_type = NULL;
|
||||
struct ifreq if_req;
|
||||
int fd;
|
||||
@@ -973,6 +982,9 @@
|
||||
*hw_addr = hw_type->print_hw_addr (if_req.ifr_hwaddr.sa_data);
|
||||
|
||||
return hw_type;
|
||||
+#else
|
||||
+ return NULL;
|
||||
+#endif
|
||||
}
|
||||
|
||||
gboolean
|
||||
@@ -1083,8 +1095,11 @@
|
||||
struct ifconf *if_conf;
|
||||
GList *interfaces;
|
||||
GList *loopbacks;
|
||||
+ gchar *ptr;
|
||||
int fd;
|
||||
- int i;
|
||||
+ struct ifreq *if_req;
|
||||
+ int len;
|
||||
+ gboolean loopback;
|
||||
|
||||
if ((fd = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
|
||||
{
|
||||
@@ -1105,12 +1120,25 @@
|
||||
interfaces = NULL;
|
||||
loopbacks = NULL;
|
||||
|
||||
- for (i = 0; i < if_conf->ifc_len / sizeof (struct ifreq); i++)
|
||||
+ for (ptr = if_conf->ifc_buf; ptr < if_conf->ifc_buf + if_conf->ifc_len;)
|
||||
{
|
||||
- struct ifreq if_req = if_conf->ifc_req [i];
|
||||
- gboolean loopback = FALSE;
|
||||
+ if_req = (struct ifreq *) ptr;
|
||||
+ loopback = FALSE;
|
||||
+ len = sizeof(struct sockaddr);
|
||||
+#if defined(HAVE_SOCKADDR_SA_LEN) || defined(__FreeBSD__)
|
||||
+ if (if_req->ifr_addr.sa_len > len)
|
||||
+ len = if_req->ifr_addr.sa_len;
|
||||
+#endif
|
||||
+
|
||||
+ ptr += sizeof(if_req->ifr_name) + len;
|
||||
+
|
||||
+ if (g_list_find_custom (interfaces, if_req->ifr_name,
|
||||
+ (GCompareFunc) g_ascii_strcasecmp) != NULL
|
||||
+ || g_list_find_custom (loopbacks, if_req->ifr_name,
|
||||
+ (GCompareFunc) g_ascii_strcasecmp) != NULL)
|
||||
+ continue;
|
||||
|
||||
- if (ioctl (fd, SIOCGIFFLAGS, &if_req) < 0)
|
||||
+ if (ioctl (fd, SIOCGIFFLAGS, if_req) < 0)
|
||||
{
|
||||
if (error)
|
||||
*error = g_error_new (NETSTATUS_ERROR,
|
||||
@@ -1120,13 +1148,14 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
- loopback = (if_req.ifr_flags & IFF_LOOPBACK);
|
||||
+ loopback = (if_req->ifr_flags & IFF_LOOPBACK);
|
||||
}
|
||||
|
||||
if (!loopback)
|
||||
- interfaces = g_list_prepend (interfaces, g_strdup (if_req.ifr_name));
|
||||
+ interfaces = g_list_prepend (interfaces, g_strdup (if_req->ifr_name));
|
||||
else
|
||||
- loopbacks = g_list_prepend (loopbacks, g_strdup (if_req.ifr_name));
|
||||
+ loopbacks = g_list_prepend (loopbacks, g_strdup (if_req->ifr_name));
|
||||
+
|
||||
}
|
||||
|
||||
interfaces = g_list_concat (interfaces, loopbacks);
|
160
net/gnomenetstatus/files/patch-src_netstatus-sysdeps.c
Normal file
160
net/gnomenetstatus/files/patch-src_netstatus-sysdeps.c
Normal file
@ -0,0 +1,160 @@
|
||||
--- src/netstatus-sysdeps.c.orig Mon Jun 9 13:18:04 2003
|
||||
+++ src/netstatus-sysdeps.c Fri Jan 2 23:29:16 2004
|
||||
@@ -27,10 +27,13 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
+#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <glib.h>
|
||||
#include <libgnome/gnome-i18n.h>
|
||||
|
||||
+#if !defined(__FreeBSD__)
|
||||
+
|
||||
static inline char *
|
||||
parse_iface_name (const char *buf)
|
||||
{
|
||||
@@ -90,6 +93,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
+#endif
|
||||
|
||||
static inline int
|
||||
parse_stats (char *buf,
|
||||
@@ -124,6 +128,8 @@
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
+#if !defined(__FreeBSD__)
|
||||
+
|
||||
static inline FILE *
|
||||
get_proc_net_dev_fh (void)
|
||||
{
|
||||
@@ -206,3 +212,126 @@
|
||||
|
||||
return error_message;
|
||||
}
|
||||
+
|
||||
+#else
|
||||
+
|
||||
+static inline void
|
||||
+parse_header (char *buf,
|
||||
+ int *prx_idx,
|
||||
+ int *ptx_idx,
|
||||
+ int *brx_idx,
|
||||
+ int *btx_idx)
|
||||
+{
|
||||
+ char *p;
|
||||
+ int i;
|
||||
+
|
||||
+ *prx_idx = *ptx_idx = -1;
|
||||
+ *brx_idx = *btx_idx = -1;
|
||||
+
|
||||
+ p = strtok (buf, " \n\t");
|
||||
+ for (i = 0; p; i++, p = strtok (NULL, " \t\n"))
|
||||
+ {
|
||||
+ if (!strcmp (p, "Ipkts"))
|
||||
+ {
|
||||
+ *prx_idx = i;
|
||||
+ }
|
||||
+ else if (!strcmp (p, "Ibytes"))
|
||||
+ {
|
||||
+ *brx_idx = i;
|
||||
+ }
|
||||
+ else if (!strcmp (p, "Opkts"))
|
||||
+ {
|
||||
+ *ptx_idx = i;
|
||||
+ }
|
||||
+ else if (!strcmp (p, "Obytes"))
|
||||
+ {
|
||||
+ *btx_idx = i;
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+char *
|
||||
+netstatus_sysdeps_read_iface_statistics (const char *iface,
|
||||
+ long *in_packets,
|
||||
+ long *out_packets,
|
||||
+ long *in_bytes,
|
||||
+ long *out_bytes)
|
||||
+{
|
||||
+ gchar *buf;
|
||||
+ gchar *cmd = NULL;
|
||||
+ gchar **command_line;
|
||||
+ int prx_idx, ptx_idx;
|
||||
+ int brx_idx, btx_idx;
|
||||
+ char *error_message = NULL;
|
||||
+ gchar *dir = g_get_current_dir ();
|
||||
+ gint pout;
|
||||
+ GIOChannel *channel;
|
||||
+ GError *err = NULL;
|
||||
+
|
||||
+ *in_packets = -1;
|
||||
+ *out_packets = -1;
|
||||
+ *in_bytes = -1;
|
||||
+ *out_bytes = -1;
|
||||
+
|
||||
+ cmd = g_strdup_printf ("/usr/bin/netstat netstat -n -I %s -b -f inet", iface);
|
||||
+ command_line = g_strsplit (cmd, " ", -1);
|
||||
+ g_free (cmd);
|
||||
+
|
||||
+ if (g_spawn_async_with_pipes (dir, command_line, NULL,
|
||||
+ G_SPAWN_FILE_AND_ARGV_ZERO, NULL,
|
||||
+ NULL, NULL, NULL, &pout,
|
||||
+ NULL, &err)) {
|
||||
+ g_strfreev (command_line);
|
||||
+ channel = g_io_channel_unix_new (pout);
|
||||
+ g_io_channel_read_line (channel, &buf, NULL, NULL, NULL);
|
||||
+
|
||||
+ parse_header (buf, &prx_idx, &ptx_idx, &brx_idx, &btx_idx);
|
||||
+ if (prx_idx == -1 || ptx_idx == -1 ||
|
||||
+ brx_idx == -1 || btx_idx == -1)
|
||||
+ {
|
||||
+ if (buf)
|
||||
+ g_free (buf);
|
||||
+ g_io_channel_unref (channel);
|
||||
+ g_io_channel_shutdown (channel, TRUE, NULL);
|
||||
+ close (pout);
|
||||
+ return g_strdup ("Could not parse netstat output. Unknown format");
|
||||
+ }
|
||||
+
|
||||
+ if (buf)
|
||||
+ g_free (buf);
|
||||
+ g_io_channel_read_line (channel, &buf, NULL, NULL, NULL);
|
||||
+
|
||||
+ if (!parse_stats (buf, prx_idx, ptx_idx, in_packets, out_packets,
|
||||
+ brx_idx, btx_idx, in_bytes, out_bytes))
|
||||
+ {
|
||||
+ if (error_message)
|
||||
+ g_free (error_message);
|
||||
+ error_message = g_strdup_printf (_("Could not parse interface statistics from '%s'. "
|
||||
+ "prx_idx = %d; ptx_idx = %d; brx_idx = %d; btx_idx = %d;"),
|
||||
+ buf, prx_idx, ptx_idx, brx_idx, btx_idx);
|
||||
+ }
|
||||
+
|
||||
+ if (buf)
|
||||
+ g_free (buf);
|
||||
+
|
||||
+ if ((*in_packets == -1 || *out_packets == -1 || *in_bytes == -1 || *out_bytes == -1) && !error_message)
|
||||
+ error_message = g_strdup_printf ("Could not obtain information on interface '%s' from netstat", iface);
|
||||
+
|
||||
+ g_io_channel_unref (channel);
|
||||
+ g_io_channel_shutdown (channel, TRUE, NULL);
|
||||
+ close (pout);
|
||||
+ }
|
||||
+ else {
|
||||
+ g_strfreev (command_line);
|
||||
+ if (error_message)
|
||||
+ g_free (error_message);
|
||||
+ error_message = g_strdup_printf ("Error running /usr/bin/netstat for '%s': %s",
|
||||
+ iface, err->message);
|
||||
+ g_error_free (err);
|
||||
+ }
|
||||
+
|
||||
+ g_free (dir);
|
||||
+
|
||||
+ return error_message;
|
||||
+}
|
||||
+#endif
|
2
net/gnomenetstatus/pkg-descr
Normal file
2
net/gnomenetstatus/pkg-descr
Normal file
@ -0,0 +1,2 @@
|
||||
Gnome-netstatus is an applet which provides information about a network
|
||||
interface on your panel.
|
40
net/gnomenetstatus/pkg-plist
Normal file
40
net/gnomenetstatus/pkg-plist
Normal file
@ -0,0 +1,40 @@
|
||||
etc/gconf/gconf.xml.defaults/apps/netstatus_applet/%gconf.xml
|
||||
etc/gconf/gconf.xml.defaults/schemas/apps/netstatus_applet/%gconf.xml
|
||||
etc/gconf/gconf.xml.defaults/schemas/apps/netstatus_applet/prefs/%gconf.xml
|
||||
etc/gconf/schemas/netstatus.schemas
|
||||
libdata/bonobo/servers/GNOME_NetstatusApplet_Factory.server
|
||||
libexec/gnome-netstatus-applet
|
||||
share/gnome/gnome-2.0/ui/GNOME_NetstatusApplet.xml
|
||||
share/gnome/gnome-netstatus/gnome-netstatus.glade
|
||||
share/gnome/icons/gnome-netstatus/gnome-netstatus-disconn.png
|
||||
share/gnome/icons/gnome-netstatus/gnome-netstatus-error.png
|
||||
share/gnome/icons/gnome-netstatus/gnome-netstatus-idle.png
|
||||
share/gnome/icons/gnome-netstatus/gnome-netstatus-rx.png
|
||||
share/gnome/icons/gnome-netstatus/gnome-netstatus-tx.png
|
||||
share/gnome/icons/gnome-netstatus/gnome-netstatus-txrx.png
|
||||
share/gnome/pixmaps/gnome-netstatus-tx.png
|
||||
share/locale/az/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/cs/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/de/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/el/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/es/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/fr/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/it/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/ja/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/ms/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/nl/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/pl/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/pt/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/ru/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/sr/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/sr@Latn/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/sv/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/tr/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/vi/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/wa/LC_MESSAGES/gnome-netstatus.mo
|
||||
share/locale/zh_CN/LC_MESSAGES/gnome-netstatus.mo
|
||||
@dirrm share/gnome/icons/gnome-netstatus
|
||||
@dirrm share/gnome/gnome-netstatus
|
||||
@dirrm etc/gconf/gconf.xml.defaults/schemas/apps/netstatus_applet/prefs
|
||||
@dirrm etc/gconf/gconf.xml.defaults/schemas/apps/netstatus_applet
|
||||
@dirrm etc/gconf/gconf.xml.defaults/apps/netstatus_applet
|
Loading…
Reference in New Issue
Block a user