diff -Nrup libgtop-2.14.1/sysdeps/solaris/netload.c libgtop-2.14.1.netload.mod/sysdeps/solaris/netload.c
--- libgtop-2.14.1/sysdeps/solaris/netload.c	2005-12-12 18:09:40.000000000 +0800
+++ libgtop-2.14.1.netload.mod/sysdeps/solaris/netload.c	2006-06-27 20:05:33.571016000 +0800
@@ -26,14 +26,259 @@
 #include <glibtop/error.h>
 #include <glibtop/netload.h>
 
-static const unsigned long _glibtop_sysdeps_netload = 0;
+#include "glibtop_private.h"
+
+#include <errno.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <sys/sockio.h>
+
+//#if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1
+/* GNU LibC */
+#include <net/if.h>
+/*#include <netinet/ip_icmp.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <netinet/udp.h>
+#include <netinet/ip.h>
+/*#else
+#include <linux/if.h>
+#include <linux/in.h>
+#include <linux/ip.h>
+#include <linux/icmp.h>
+#include <linux/tcp.h>
+#include <linux/udp.h>
+#endif*/
+
+#ifdef HAVE_IFADDRS_H
+/* needed for IPV6 support */
+
+#include <ifaddrs.h>
+
+#ifndef IN6_IS_ADDR_GLOBAL
+#define IN6_IS_ADDR_GLOBAL(a) \
+   (((((__const uint8_t *) (a))[0] & 0xff) == 0x3f   \
+     || (((__const uint8_t *) (a))[0] & 0xff) == 0x20))
+#endif
+#endif /* HAVE_IFADDRS_H */
+
+#define _GLIBTOP_IP_FW_ACCTIN	0x1000	/* Account incoming packets only. */
+#define _GLIBTOP_IP_FW_ACCTOUT	0x2000	/* Account outgoing packets only. */
+
+static const unsigned long _glibtop_sysdeps_netload =
+(1L << GLIBTOP_NETLOAD_ERRORS_IN) +
+(1L << GLIBTOP_NETLOAD_ERRORS_OUT) +
+(1L << GLIBTOP_NETLOAD_COLLISIONS);
+
+static const unsigned long _glibtop_sysdeps_netload_data =
+(1L << GLIBTOP_NETLOAD_ADDRESS) +
+(1L << GLIBTOP_NETLOAD_SUBNET) +
+(1L << GLIBTOP_NETLOAD_MTU);
+
+static const unsigned long _glibtop_sysdeps_netload_bytes =
+(1L << GLIBTOP_NETLOAD_BYTES_IN) +
+(1L << GLIBTOP_NETLOAD_BYTES_OUT) +
+(1L << GLIBTOP_NETLOAD_BYTES_TOTAL);
+
+static const unsigned long _glibtop_sysdeps_netload_packets =
+(1L << GLIBTOP_NETLOAD_PACKETS_IN) +
+(1L << GLIBTOP_NETLOAD_PACKETS_OUT) +
+(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL);
+
+static const unsigned long _glibtop_sysdeps_netload_total =
+(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) +
+(1L << GLIBTOP_NETLOAD_BYTES_TOTAL);
+
+static const unsigned long _glibtop_sysdeps_netload_in =
+(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) +
+(1L << GLIBTOP_NETLOAD_BYTES_TOTAL) +
+(1L << GLIBTOP_NETLOAD_PACKETS_IN) +
+(1L << GLIBTOP_NETLOAD_BYTES_IN);
+
+static const unsigned long _glibtop_sysdeps_netload_out =
+(1L << GLIBTOP_NETLOAD_PACKETS_TOTAL) +
+(1L << GLIBTOP_NETLOAD_BYTES_TOTAL) +
+(1L << GLIBTOP_NETLOAD_PACKETS_OUT) +
+(1L << GLIBTOP_NETLOAD_BYTES_OUT);
+
+static const unsigned long _glibtop_sysdeps_netload_6 =
+(1L << GLIBTOP_NETLOAD_ADDRESS6) +
+(1L << GLIBTOP_NETLOAD_PREFIX6) +
+(1L << GLIBTOP_NETLOAD_SCOPE6);
+
 
 /* Init function. */
 
 void
 glibtop_init_netload_s (glibtop *server)
 {
-	server->sysdeps.netload = _glibtop_sysdeps_netload;
+    server->sysdeps.netload = _glibtop_sysdeps_netload |
+	_glibtop_sysdeps_netload_bytes |
+	_glibtop_sysdeps_netload_packets;
+}
+
+
+#ifdef HAVE_IFADDRS_H
+
+static void get_ipv6(glibtop *server, glibtop_netload *buf,
+		     const char *interface)
+{
+	struct ifaddrs *ifa0, *ifr6;
+
+	if(getifaddrs (&ifa0) != 0)
+	{
+		glibtop_warn_r(server, "getifaddrs failed : %s", g_strerror(errno));
+		return;
+	}
+
+	for (ifr6 = ifa0; ifr6; ifr6 = ifr6->ifa_next) {
+		if (strcmp (ifr6->ifa_name, interface) == 0
+		    && ifr6->ifa_addr != NULL
+		    && ifr6->ifa_addr->sa_family == AF_INET6)
+			break;
+	}
+
+	if(!ifr6) goto free_ipv6;
+
+	memcpy(buf->address6,
+	       &((struct sockaddr_in6 *) ifr6->ifa_addr)->sin6_addr,
+	       16);
+
+	memcpy(buf->prefix6,
+	       &((struct sockaddr_in6 *) ifr6->ifa_netmask)->sin6_addr,
+	       16);
+
+
+	if (IN6_IS_ADDR_LINKLOCAL (buf->address6))
+		buf->scope6 = GLIBTOP_IF_IN6_SCOPE_LINK;
+
+	else if (IN6_IS_ADDR_SITELOCAL (buf->address6))
+		buf->scope6 = GLIBTOP_IF_IN6_SCOPE_SITE;
+
+	else if (IN6_IS_ADDR_GLOBAL (buf->address6)
+		 || IN6_IS_ADDR_MC_ORGLOCAL (buf->address6)
+		 || IN6_IS_ADDR_V4COMPAT (buf->address6)
+		 || IN6_IS_ADDR_MULTICAST (buf->address6)
+		 || IN6_IS_ADDR_UNSPECIFIED (buf->address6)
+		)
+		buf->scope6 = GLIBTOP_IF_IN6_SCOPE_GLOBAL;
+
+	else if (IN6_IS_ADDR_LOOPBACK (buf->address6))
+		buf->scope6 = GLIBTOP_IF_IN6_SCOPE_HOST;
+
+	else
+		buf->scope6 = GLIBTOP_IF_IN6_SCOPE_UNKNOWN;
+
+	buf->flags |= _glibtop_sysdeps_netload_6;
+
+ free_ipv6:
+	freeifaddrs(ifa0);
+}
+
+#endif /* HAVE_IFADDRS_H */
+
+
+
+static int
+solaris_stats(glibtop *server,
+		glibtop_netload *buf,
+		const char *interface)
+{
+	char	*name = interface;
+	char	*module;
+	char	*ptr;
+	kstat_ctl_t		*kctl;
+	kstat_t			*ksp;
+	kstat_named_t		*kdata;
+	int have_bytes = 1;
+
+	/*
+	 *  chop off the trailing interface and 
+	 */
+	module = strdup( name );
+	ptr = module + strlen( module ) - 1;
+	while( (ptr > module) && isdigit( (int) *ptr ) ) {
+		*ptr = '\0';
+		ptr--;
+	}
+
+	/*
+	 *  get a kstat handle and update the user's kstat chain
+	 */
+	if( (kctl = kstat_open()) == NULL ){
+		glibtop_warn_io_r (server, "kstat_open ()");
+		free( module );
+		return( 0 );
+	}
+	while( kstat_chain_update( kctl ) != 0 )
+		;
+
+	/*
+	 *  traverse the kstat chain
+	 *  to find the appropriate statistics
+	 */
+	if( (ksp = kstat_lookup( kctl,
+			module, 0, name )) == NULL ) {
+		free( module );
+		kstat_close(kctl);
+		return( 0 );
+	}
+	if( kstat_read( kctl, ksp, NULL ) == -1 ) {
+		free( module );
+		kstat_close(kctl);
+		return( 0 );
+	}
+	free( module );
+
+	/*
+	 *  lookup & store the data
+	 */
+	kdata = (kstat_named_t *) kstat_data_lookup( ksp, "ipackets" );
+	if( kdata != NULL ) {
+		buf->packets_in= kdata->value.ul;
+	}
+	kdata = (kstat_named_t *) kstat_data_lookup( ksp, "opackets" );
+	if( kdata != NULL ) {
+		buf->packets_out = kdata->value.ul;
+	}
+	kdata = (kstat_named_t *) kstat_data_lookup( ksp, "rbytes" );
+	if( kdata != NULL ) {
+		buf->bytes_in =kdata->value.ul;
+	}
+	kdata = (kstat_named_t *) kstat_data_lookup( ksp, "obytes" );
+	if( kdata != NULL ) {
+		buf->bytes_out =kdata->value.ul;
+	}
+	kdata = (kstat_named_t *) kstat_data_lookup( ksp, "ierrors" );
+	if( kdata != NULL ) {
+		buf->errors_in = kdata->value.ul;
+	}
+	kdata = (kstat_named_t *) kstat_data_lookup( ksp, "oerrors" );
+	if( kdata != NULL ) {
+		buf->errors_out = kdata->value.ul;
+	}
+	kdata = (kstat_named_t *) kstat_data_lookup( ksp, "collisions" );
+	if( kdata != NULL ) {
+		buf->collisions = kdata->value.ul;
+	}
+	
+	/* Compute total valules. */
+
+	buf->bytes_total = buf->bytes_in + buf->bytes_out;
+	buf->packets_total = buf->packets_in + buf->packets_out;
+	buf->errors_total = buf->errors_in + buf->errors_out;
+	/* And now the flags. */
+	buf->flags |= _glibtop_sysdeps_netload;
+	buf->flags |= _glibtop_sysdeps_netload_bytes;
+	buf->flags |= _glibtop_sysdeps_netload_packets;
+	    
+	kstat_close(kctl);
+
+	/* finished */
+	
 }
 
 /* Provides network statistics. */
@@ -42,5 +287,73 @@ void
 glibtop_get_netload_s (glibtop *server, glibtop_netload *buf,
 		       const char *interface)
 {
-	memset (buf, 0, sizeof (glibtop_netload));
+    int skfd;
+    memset (buf, 0, sizeof (glibtop_netload));
+
+    /* set flag */
+    skfd = socket (PF_INET, SOCK_DGRAM, 0);
+    if (skfd) {
+	struct ifreq ifr;
+
+	g_strlcpy (ifr.ifr_name, interface, sizeof ifr.ifr_name);
+	if (ioctl (skfd, SIOCGIFFLAGS, &ifr) >= 0) {
+	    const unsigned long long flags = ifr.ifr_flags;
+
+	    buf->flags |= (1L << GLIBTOP_NETLOAD_IF_FLAGS);
+
+	    if (flags & IFF_UP)
+		buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_UP);
+
+	    if (flags & IFF_BROADCAST)
+		buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_BROADCAST);
+
+	    if (flags & IFF_DEBUG)
+		buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_DEBUG);
+
+	    if (flags & IFF_LOOPBACK)
+		buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_LOOPBACK);
+
+	    if (flags & IFF_POINTOPOINT)
+		buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_POINTOPOINT);
+
+	    if (flags & IFF_RUNNING)
+		buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_RUNNING);
+
+	    if (flags & IFF_NOARP)
+		buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_NOARP);
+
+	    if (flags & IFF_PROMISC)
+		buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_PROMISC);
+
+	    if (flags & IFF_ALLMULTI)
+		buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_ALLMULTI);
+
+	    if (flags & IFF_MULTICAST)
+		buf->if_flags |= (1L << GLIBTOP_IF_FLAGS_MULTICAST);
+	    }
+
+	g_strlcpy (ifr.ifr_name, interface, sizeof ifr.ifr_name);
+	if (!ioctl (skfd, SIOCGIFADDR, &ifr)) {
+	    buf->address = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr;
+	    buf->flags |= (1L << GLIBTOP_NETLOAD_ADDRESS);
+	}
+
+	g_strlcpy (ifr.ifr_name, interface, sizeof ifr.ifr_name);
+	if (!ioctl (skfd, SIOCGIFNETMASK, &ifr)) {
+	    buf->subnet = ((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr.s_addr;
+	    buf->flags |= (1L << GLIBTOP_NETLOAD_SUBNET);
+	}
+	close (skfd);
+    }
+
+    /*
+     * Statistics
+     */
+     
+    solaris_stats(server, buf, interface);
+
+#ifdef HAVE_IFADDRS_H
+    get_ipv6(server, buf, interface);
+#endif /* HAVE_IFADDRS_H */
 }
+
