14027N/A-gnome_nettool_LDADD = @NETTOOL_LIBS@
14027N/A+gnome_nettool_LDADD = @NETTOOL_LIBS@ \
14027N/A+ * Copyright (c) 2006 WIDE Project. All rights reserved.
14027N/A+ * Redistribution and use in source and binary forms, with or without
14027N/A+ * modification, are permitted provided that the following conditions
14027N/A+ * 1. Redistributions of source code must retain the above copyright
14027N/A+ * notice, this list of conditions and the following disclaimer.
14027N/A+ * 2. Redistributions in binary form must reproduce the above copyright
14027N/A+ * notice, this list of conditions and the following disclaimer in the
14027N/A+ * documentation
and/or other materials provided with the distribution.
14027N/A+ * 3. Neither the name of the project nor the names of its contributors
14027N/A+ * may be used to endorse or promote products derived from this software
14027N/A+ * without specific prior written permission.
14027N/A+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
14027N/A+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14027N/A+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
14027N/A+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
14027N/A+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
14027N/A+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
14027N/A+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
14027N/A+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
14027N/A+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
14027N/A+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
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)
14027N/A+ * Copyright (c) 2006 WIDE Project. All rights reserved.
14027N/A+ * Redistribution and use in source and binary forms, with or without
14027N/A+ * modification, are permitted provided that the following conditions
14027N/A+ * 1. Redistributions of source code must retain the above copyright
14027N/A+ * notice, this list of conditions and the following disclaimer.
14027N/A+ * 2. Redistributions in binary form must reproduce the above copyright
14027N/A+ * notice, this list of conditions and the following disclaimer in the
14027N/A+ * documentation
and/or other materials provided with the distribution.
14027N/A+ * 3. Neither the name of the project nor the names of its contributors
14027N/A+ * may be used to endorse or promote products derived from this software
14027N/A+ * without specific prior written permission.
14027N/A+ * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
14027N/A+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14027N/A+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
14027N/A+ * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
14027N/A+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
14027N/A+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
14027N/A+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
14027N/A+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
14027N/A+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
14027N/A+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
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);
14027N/A+netstatus_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;
14027N/A+ netstatus_sysdeps_read_iface_statistics (text, &out_bytes, &out_pkts, &out_err,
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);
14027N/A # define NETSTAT_ROUTE6_FORMAT "%s %s %s %d %d %d %s"
14027N/A # define NETSTAT_MULTICAST_FORMAT "%s %d %s"
14027N/A-#elif defined(__FreeBSD__) || defined(__OpenBSD__)
14027N/A+#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(sun)
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"
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"
14027N/A # define PING_FORMAT "%d bytes from %s icmp_seq=%d. time=%f %s"
14027N/A+#define gethostbyname2 res_gethostbyname2