15713N/A@@ -15,8 +15,14 @@ IT_PROG_INTLTOOL([0.35.0])
15713N/A+dnl *** checks for socket, nsl, and kstat libraries ***
15713N/A+AC_CHECK_FUNC(socket,,[AC_CHECK_LIB(socket,socket)])
15713N/A+AC_CHECK_FUNC(gethostbyname,,[AC_CHECK_LIB(nsl,gethostbyname)])
15713N/A+AC_CHECK_FUNC(kstat_open,,[AC_CHECK_LIB(kstat,kstat_open)])
14259N/A+ * Copyright (c) 2008 Sun Microsystems, Inc.. All rights reserved.
14259N/A+ * Use is subject to license terms
14259N/A+ * Author: James Carlson, James.D.Carlson@Sun.COM
14259N/A+ * This program is free software; you can redistribute it
and/or modify
14259N/A+ * it under the terms of the GNU General Public License as published by
14259N/A+ * the Free Software Foundation; either version 2 of the License, or
14259N/A+ * (at your option) any later version.
14259N/A+ * This program is distributed in the hope that it will be useful,
14259N/A+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14259N/A+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14259N/A+ * GNU General Public License for more details.
14259N/A+ * You should have received a copy of the GNU General Public License
14259N/A+ * along with this program; if not, write to the Free Software
14259N/A+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
14027N/A+get_lifreq(int fd, struct lifreq **ifr_ret)
14027N/A+ if (ioctl(fd, SIOCGLIFNUM, &lifn) == -1)
14027N/A+ if (ioctl(fd, SIOCGLIFCONF, &lifc) == -1) {
14027N/A+nbytes(const struct lifreq *lifrp, int nlif, size_t socklen)
14027N/A+ slen = strlen(lifrp->lifr_name) + 1;
14027N/A+ len += sizeof (struct ifaddrs) + ((slen + 3) & ~3);
14027N/A+addrcpy(struct sockaddr_storage *addr, char **bufp)
14027N/A+ len = addr->ss_family == AF_INET ? sizeof (struct sockaddr_in) :
14027N/A+ (void) memcpy(buf, addr, len);
14027N/A+ return ((struct sockaddr *)buf);
14027N/A+populate(struct ifaddrs *ifa, int fd, struct lifreq *lifrp, int nlif, int af,
14027N/A+ ifa->ifa_next = (nlif > 1) ? ifa + 1 : NULL;
14027N/A+ (void) strcpy(ifa->ifa_name = buf, lifrp->lifr_name);
14027N/A+ slen = strlen(lifrp->lifr_name) + 1;
14027N/A+ if (ioctl(fd, SIOCGLIFFLAGS, lifrp) == -1)
14027N/A+ ifa->ifa_flags = lifrp->lifr_flags;
14027N/A+ if (ioctl(fd, SIOCGLIFADDR, lifrp) == -1)
14027N/A+ ifa->ifa_addr = addrcpy(&lifrp->lifr_addr, &buf);
14027N/A+ if (ioctl(fd, SIOCGLIFNETMASK, lifrp) == -1)
14027N/A+ ifa->ifa_netmask = addrcpy(&lifrp->lifr_addr, &buf);
14027N/A+ if (ifa->ifa_flags & IFF_POINTOPOINT) {
14027N/A+ if (ioctl(fd, SIOCGLIFDSTADDR, lifrp) == -1)
14027N/A+ addrcpy(&lifrp->lifr_dstaddr, &buf);
14027N/A+ } else if (ifa->ifa_flags & IFF_BROADCAST) {
14027N/A+ if (ioctl(fd, SIOCGLIFBRDADDR, lifrp) == -1)
14027N/A+ addrcpy(&lifrp->lifr_broadaddr, &buf);
14027N/A+getifaddrs(struct ifaddrs **ifap)
14027N/A+ if ((fd4 = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
14027N/A+ if ((fd6 = socket(AF_INET6, SOCK_DGRAM, 0)) == -1 &&
14027N/A+ if ((nif4 = get_lifreq(fd4, &ifr4)) == -1 ||
14027N/A+ (fd6 != -1 && (nif6 = get_lifreq(fd6, &ifr6)) == -1))
14027N/A+ ifa = malloc(nbytes(ifr4, nif4, sizeof (struct sockaddr_in)) +
14027N/A+ nbytes(ifr6, nif6, sizeof (struct sockaddr_in6)));
14027N/A+ buf = (char *)(ifa + nif4 + nif6);
14027N/A+ if (populate(ifa, fd4, ifr4, nif4, AF_INET, &buf) == -1)
14027N/A+ ifa[nif4 - 1].ifa_next = ifa + nif4;
14027N/A+ if (populate(ifa + nif4, fd6, ifr6, nif6, AF_INET6, &buf) == -1)
14027N/A+freeifaddrs(struct ifaddrs *ifa)
14259N/A+ * Copyright (c) 2008 Sun Microsystems, Inc.. All rights reserved.
14259N/A+ * Use is subject to license terms
14259N/A+ * Author: James Carlson, James.D.Carlson@Sun.COM
14259N/A+ * This program is free software; you can redistribute it
and/or modify
14259N/A+ * it under the terms of the GNU General Public License as published by
14259N/A+ * the Free Software Foundation; either version 2 of the License, or
14259N/A+ * (at your option) any later version.
14259N/A+ * This program is distributed in the hope that it will be useful,
14259N/A+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14259N/A+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14259N/A+ * GNU General Public License for more details.
14259N/A+ * You should have received a copy of the GNU General Public License
14259N/A+ * along with this program; if not, write to the Free Software
14259N/A+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
14027N/A+ struct ifaddrs *ifa_next; /* Pointer to next struct */
14027N/A+ char *ifa_name; /* Interface name */
14027N/A+ uint64_t ifa_flags; /* Interface flags */
14027N/A+ struct sockaddr *ifa_addr; /* Interface address */
14027N/A+ struct sockaddr *ifa_netmask; /* Interface netmask */
14027N/A+ struct sockaddr *ifa_dstaddr; /* P2P interface destination */
14027N/A+#define ifa_broadaddr ifa_dstaddr
14027N/A+extern int getifaddrs(struct ifaddrs **);
14027N/A+extern void freeifaddrs(struct ifaddrs *);
14027N/A gtk_combo_box_set_active (GTK_COMBO_BOX (info->combo), 0);
14254N/A+gnome_nettool_sysdeps_read_iface_statistics (const char *iface,
14027N/A+ static kstat_ctl_t *kc = NULL;
14027N/A+ * The linux-specific code uses -1 as the default value. But if we return -1
14027N/A+ * (see comment below), then it gets interpreted as (unsigned long)-1, which
14027N/A+ * looks stupid and is definitely more wrong than just showing 0.
14027N/A+ if ((kc = kstat_open ()) == NULL)
14027N/A+ if (kstat_chain_update (kc) < 0)
14027N/A+ return g_strdup_printf ("Cannot update kstats: %s",
14027N/A+ if ((ksp = kstat_lookup (kc, NULL, -1, iface)) == NULL)
14027N/A+ return g_strdup_printf ("Cannot find information on interface '%s'",
14027N/A+ if (kstat_read (kc, ksp, NULL) < 0)
14027N/A+ return g_strdup_printf ("Cannot read kstat");
14027N/A+ if ((kn = kstat_data_lookup (ksp, "rbytes")) != NULL)
14027N/A+ if ((kn = kstat_data_lookup (ksp, "opackets")) != NULL)
14027N/A+ if ((kn = kstat_data_lookup (ksp, "oerrors")) != NULL)
14027N/A+ if ((kn = kstat_data_lookup (ksp, "obytes")) != NULL)
14027N/A+ if ((kn = kstat_data_lookup (ksp, "ipackets")) != NULL)
14027N/A+ if ((kn = kstat_data_lookup (ksp, "ierrors")) != NULL)
14027N/A+ if ((kn = kstat_data_lookup (ksp, "collisions")) != NULL)
14027N/A+ if ((kn = kstat_data_lookup (ksp, "ifspeed")) != NULL)
14027N/A+ * On Solaris, loopback doesn't report bytes, just packets. The behavior of
14027N/A+ * the linux-specific code reports an error if all the data is not present,
14027N/A+ * and that shuts the applet down. So perhaps it's best to simply return
14027N/A+ * success if we can access the data at all.
14027N/A info_nic_update_stats (gpointer data)
14027N/A #endif /* defined(__linux__) */
14027N/A+ gulong out_bytes, out_pkts, out_err, in_bytes, in_pkts, in_err, collisions, ifspeed;
14254N/A+ gnome_nettool_sysdeps_read_iface_statistics (text, &out_bytes,
14027N/A+ snprintf (buf, 128, "%ld", out_bytes);
14027N/A+ gtk_label_set_text (GTK_LABEL (info->tx_bytes), buf);
14027N/A+ snprintf (buf, 128, "%ld", out_pkts);
14027N/A+ gtk_label_set_text (GTK_LABEL (info->tx), buf);
14027N/A+ snprintf (buf, 128, "%ld", out_err);
14027N/A+ gtk_label_set_text (GTK_LABEL (info->tx_errors), buf);
14027N/A+ snprintf (buf, 128, "%ld", in_bytes);
14027N/A+ gtk_label_set_text (GTK_LABEL (info->rx_bytes), buf);
14027N/A+ snprintf (buf, 128, "%ld", in_pkts);
14027N/A+ gtk_label_set_text (GTK_LABEL (info->rx), buf);
14027N/A+ snprintf (buf, 128, "%ld", in_err);
14027N/A+ gtk_label_set_text (GTK_LABEL (info->rx_errors), buf);
14027N/A+ snprintf (buf, 128, "%ld", collisions);
14027N/A+ gtk_label_set_text (GTK_LABEL (info->collisions), buf);
14027N/A+ snprintf (buf, 128, "%ld", ifspeed);
14027N/A+ gtk_label_set_text (GTK_LABEL (info->link_speed), buf);
14027N/A else if (IN6_IS_ADDR_SITELOCAL (&sinptr6->sin6_addr))
14027N/A- else if (IN6_IS_ADDR_GLOBAL (&sinptr6->sin6_addr))
14027N/A+ else if (IN6_IS_ADDR_MC_GLOBAL (&sinptr6->sin6_addr))
14027N/A else if (IN6_IS_ADDR_MC_ORGLOCAL (&sinptr6->sin6_addr))
14027N/A info_set_nic (info, info_input);
14027N/A netinfo_set_host (pinger, ping_input);
14254N/A netstat->button = glade_xml_get_widget (xml, "netstat_button");
14254N/A netstat->routing = glade_xml_get_widget (xml, "netstat_routing");
14254N/A netstat->protocol = glade_xml_get_widget (xml, "netstat_protocol");
14254N/A+ gtk_widget_hide (netstat->protocol);
14254N/A netstat->multicast = glade_xml_get_widget (xml, "netstat_multicast");
14254N/A netstat->label_run = _("Netstat");
14254N/A g_return_val_if_fail (netinfo != NULL, NULL);
14254N/A if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (netinfo->routing))) {
14254N/A- /* Works for Solaris and Linux */
14254N/A+ if (netinfo_is_ipv6_enable ()) {
14254N/A+ option = g_strdup ("-rn -f inet -f inet6");
14254N/A+ option = g_strdup ("-rn -f inet");
14254N/A if (netinfo_is_ipv6_enable ()) {
14254N/A option = g_strdup ("-rn -A inet -A inet6");
14254N/A option = g_strdup ("-rn -A inet");
14254N/A netinfo->stbar_text = g_strdup (_("Getting routing table"));
14254N/A g_return_if_fail (line != NULL);
14254N/A count = strip_route_line (line, &data);
14254N/A-#if defined(__FreeBSD__) || defined(__OpenBSD__)
14254N/A+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(sun)
14254N/A if ((count == 8) || (count == 7)) {
14254N/A gtk_list_store_set (GTK_LIST_STORE (model), &iter,
14254N/A gtk_tree_view_set_model (widget, model);
14254N/A-#if defined(__FreeBSD__) || defined(__OpenBSD__)
14254N/A+#if defined(__FreeBSD__) || defined(__OpenBSD__) || defined(sun)
14254N/A+ count = sscanf (line, NETSTAT_ROUTE_FORMAT,
14254N/A count = sscanf (line, NETSTAT_ROUTE_FORMAT,
14254N/A+ count = sscanf (line, NETSTAT_MULTICAST_FORMAT,
14254N/A count = sscanf (line, NETSTAT_MULTICAST_FORMAT,
14254N/A snprintf ((data)->members, 30, "%d", members);
14027N/A # define NETSTAT_PROTOCOL_FORMAT "%s %d %d %d.%d.%d.%d.%s %s %s"
14027N/A # define ALT_NETSTAT_PROTOCOL_FORMAT "%s %d %d *.%s %s %s"
14027N/A # define NETSTAT_ROUTE_FORMAT "%s %s %s %d %d %s"
14027N/A+# define NETSTAT_ROUTE6_FORMAT "%s %s %s %d %d %d %s"
14027N/A # define NETSTAT_MULTICAST_FORMAT "%s %d %s"
14254N/A+# define NETSTAT_PROTOCOL_FORMAT "%s %d %d %s %s %s"
14254N/A+# define NETSTAT_ROUTE_FORMAT "%s %s %s %d %d %s"
14254N/A+# define NETSTAT_ROUTE6_FORMAT "%s %s %s %d %d %d %s"
14254N/A+# define NETSTAT_MULTICAST_FORMAT "%s %s %d"
14234N/A program = util_find_program_dialog ("ping", parent);
14234N/A+ program = util_find_program_dialog ("ping", parent);
14234N/A program = util_find_program_dialog ("ping6", parent);
14027N/A-#if defined(__sun__) || defined(__hpux__)
14027N/A+#if defined(sun) || defined(__hpux__)
14027N/A g_strdup_printf (PING_PROGRAM_FORMAT, program, host,
14027N/A # define PING_PROGRAM_FORMAT_6 "%s ping6 -c %d -n %s"
14027N/A # define PING_FORMAT "%d bytes from %s icmp_seq=%d ttl=%d time=%s %s"
14027N/A # define PING_PROGRAM_FORMAT "%s ping -s -n %s 56 %d"
14027N/A # define PING_PROGRAM_FORMAT_6 "%s ping -s -A inet6 -a -n %s 56 %d"
14234N/A-# define PING_FORMAT "%d bytes from %s icmp_seq=%d. time=%f %s"
14234N/A+# define PING_FORMAT "%d bytes from %s icmp_seq=%d. time=%s %s"
14234N/A # define PING_PROGRAM_FORMAT "%s ping %s -n %d"
14234N/A+#define gethostbyname2(name, domain) getipnodebyname((name), (domain), 0, &g_n_err_macro)