--- iftop-0.17.orig/iftop.c +++ iftop-0.17/iftop.c @@ -45,6 +45,7 @@ #include "cfgfile.h" #include "ppp.h" +#include /* ethernet address of interface. */ int have_hw_addr = 0; @@ -52,7 +53,9 @@ /* IP address of interface */ int have_ip_addr = 0; +int have_ip6_addr = 0; struct in_addr if_ip_addr; +struct in6_addr if_ip6_addr; extern options_t options; @@ -77,7 +80,8 @@ /* Only need ethernet (plus optional 4 byte VLAN) and IP headers (48) + first 2 bytes of tcp/udp header */ -#define CAPTURE_LENGTH 72 +/* Increase with a further 20 to account for IPv6 header length. */ +#define CAPTURE_LENGTH 92 void init_history() { history = addr_hash_create(); @@ -147,10 +151,14 @@ return ret; } -int ip_addr_match(struct in_addr addr) { +int __inline__ ip_addr_match(struct in_addr addr) { return addr.s_addr == if_ip_addr.s_addr; } +int __inline__ ip6_addr_match(struct in6_addr *addr) { + return IN6_ARE_ADDR_EQUAL(addr, &if_ip6_addr); +} + /** * Creates an addr_pair from an ip (and tcp/udp) header, swapping src and dst * if required @@ -159,6 +167,11 @@ unsigned short int src_port = 0; unsigned short int dst_port = 0; + /* Arrange for predictable values. */ + memset(ap, '\0', sizeof(*ap)); + + if(IP_V(iptr) == 4) { + ap->af = AF_INET; /* Does this protocol use ports? */ if(iptr->ip_p == IPPROTO_TCP || iptr->ip_p == IPPROTO_UDP) { /* We take a slight liberty here by treating UDP the same as TCP */ @@ -181,7 +194,33 @@ ap->dst = iptr->ip_src; ap->dst_port = src_port; } + } /* IPv4 */ + else if (IP_V(iptr) == 6) { + /* IPv6 packet seen. */ + struct ip6_hdr *ip6tr = (struct ip6_hdr *) iptr; + + ap->af = AF_INET6; + + if( (ip6tr->ip6_nxt == IPPROTO_TCP) || (ip6tr->ip6_nxt == IPPROTO_UDP) ) { + struct tcphdr *thdr = ((void *) ip6tr) + 40; + + src_port = ntohs(thdr->th_sport); + dst_port = ntohs(thdr->th_dport); + } + if(flip == 0) { + memcpy(&ap->src6, &ip6tr->ip6_src, sizeof(ap->src6)); + ap->src_port = src_port; + memcpy(&ap->dst6, &ip6tr->ip6_dst, sizeof(ap->dst6)); + ap->dst_port = dst_port; + } + else { + memcpy(&ap->src6, &ip6tr->ip6_dst, sizeof(ap->src6)); + ap->src_port = dst_port; + memcpy(&ap->dst6, &ip6tr->ip6_src, sizeof(ap->dst6)); + ap->dst_port = src_port; + } + } } static void handle_ip_packet(struct ip* iptr, int hw_dir) @@ -193,9 +232,16 @@ void **void_pp; } u_ht = { &ht }; addr_pair ap; - int len; + unsigned int len = 0; + struct in6_addr scribdst; /* Scratch pad. */ + struct in6_addr scribsrc; /* Scratch pad. */ + /* Reinterpret packet type. */ + struct ip6_hdr* ip6tr = (struct ip6_hdr *) iptr; + + memset(&ap, '\0', sizeof(ap)); - if(options.netfilter == 0) { + if( (IP_V(iptr) ==4 && options.netfilter == 0) + || (IP_V(iptr) == 6 && options.netfilter6 == 0) ) { /* * Net filter is off, so assign direction based on MAC address */ @@ -212,12 +258,22 @@ /* Packet direction is not given away by h/ware layer. Try IP * layer */ - else if(have_ip_addr && ip_addr_match(iptr->ip_src)) { + else if((IP_V(iptr) == 4) && have_ip_addr && ip_addr_match(iptr->ip_src)) { /* outgoing */ assign_addr_pair(&ap, iptr, 0); direction = 1; } - else if(have_ip_addr && ip_addr_match(iptr->ip_dst)) { + else if((IP_V(iptr) == 4) && have_ip_addr && ip_addr_match(iptr->ip_dst)) { + /* incoming */ + assign_addr_pair(&ap, iptr, 1); + direction = 0; + } + else if((IP_V(iptr) == 6) && have_ip6_addr && ip6_addr_match(&ip6tr->ip6_src)) { + /* outgoing */ + assign_addr_pair(&ap, iptr, 0); + direction = 1; + } + else if((IP_V(iptr) == 6) && have_ip6_addr && ip6_addr_match(&ip6tr->ip6_dst)) { /* incoming */ assign_addr_pair(&ap, iptr, 1); direction = 0; @@ -231,16 +287,18 @@ else if (options.promiscuous_but_choosy) { return; /* junk it */ } - else if(iptr->ip_src.s_addr < iptr->ip_dst.s_addr) { + else if((IP_V(iptr) == 4) && (iptr->ip_src.s_addr < iptr->ip_dst.s_addr)) { assign_addr_pair(&ap, iptr, 1); direction = 0; } - else { + else if(IP_V(iptr) == 4) { assign_addr_pair(&ap, iptr, 0); direction = 0; } + /* Drop other uncertain packages. */ } - else { + + if(IP_V(iptr) == 4 && options.netfilter != 0) { /* * Net filter on, assign direction according to netmask */ @@ -260,22 +318,96 @@ } } - ap.protocol = iptr->ip_p; + if(IP_V(iptr) == 6 && options.netfilter6 != 0) { + /* + * Net filter IPv6 active. + */ + int j; + //else if((IP_V(iptr) == 6) && have_ip6_addr && ip6_addr_match(&ip6tr->ip6_dst)) { + /* First reduce the participating addresses using the netfilter prefix. + * We need scratch pads to do this. + */ + for (j=0; j < 4; ++j) { + scribdst.s6_addr32[j] = ip6tr->ip6_dst.s6_addr32[j] + & options.netfilter6mask.s6_addr32[j]; + scribsrc.s6_addr32[j] = ip6tr->ip6_src.s6_addr32[j] + & options.netfilter6mask.s6_addr32[j]; + } + + /* Now look for any hits. */ + //if(in_filter_net(iptr->ip_src) && !in_filter_net(iptr->ip_dst)) { + if (IN6_ARE_ADDR_EQUAL(&scribsrc, &options.netfilter6net) + && ! IN6_ARE_ADDR_EQUAL(&scribdst, &options.netfilter6net)) { + /* out of network */ + assign_addr_pair(&ap, iptr, 0); + direction = 1; + } + //else if(in_filter_net(iptr->ip_dst) && !in_filter_net(iptr->ip_src)) { + else if (! IN6_ARE_ADDR_EQUAL(&scribsrc, &options.netfilter6net) + && IN6_ARE_ADDR_EQUAL(&scribdst, &options.netfilter6net)) { + /* into network */ + assign_addr_pair(&ap, iptr, 1); + direction = 0; + } + else { + /* drop packet */ + return ; + } + } + +#if 1 + /* Test if link-local IPv6 packets should be dropped. */ + if( IP_V(iptr) == 6 && !options.link_local + && (IN6_IS_ADDR_LINKLOCAL(&ip6tr->ip6_dst) + || IN6_IS_ADDR_LINKLOCAL(&ip6tr->ip6_src)) ) + return; +#endif + + /* Do address resolving. */ + switch (IP_V(iptr)) { + case 4: + ap.protocol = iptr->ip_p; + /* Add the addresses to be resolved */ + /* The IPv4 address is embedded in a in6_addr structure, + * so it need be copied, and delivered to resolve(). */ + memset(&scribdst, '\0', sizeof(scribdst)); + memcpy(&scribdst, &iptr->ip_dst, sizeof(struct in_addr)); + resolve(ap.af, &scribdst, NULL, 0); + memset(&scribsrc, '\0', sizeof(scribsrc)); + memcpy(&scribsrc, &iptr->ip_src, sizeof(struct in_addr)); + resolve(ap.af, &scribsrc, NULL, 0); + break; + case 6: + ap.protocol = ip6tr->ip6_nxt; + /* Add the addresses to be resolved */ + resolve(ap.af, &ip6tr->ip6_dst, NULL, 0); + resolve(ap.af, &ip6tr->ip6_src, NULL, 0); + default: + break; + } - /* Add the addresses to be resolved */ - resolve(&iptr->ip_dst, NULL, 0); - resolve(&iptr->ip_src, NULL, 0); if(hash_find(history, &ap, u_ht.void_pp) == HASH_STATUS_KEY_NOT_FOUND) { ht = history_create(); hash_insert(history, &ap, ht); } - len = ntohs(iptr->ip_len); + /* Do accounting. */ + switch (IP_V(iptr)) { + case 4: + len = ntohs(iptr->ip_len); + break; + case 6: + len = ntohs(ip6tr->ip6_plen) + 40; + default: + break; + } /* Update record */ ht->last_write = history_pos; - if(iptr->ip_src.s_addr == ap.src.s_addr) { + if( ((IP_V(iptr) == 4) && (iptr->ip_src.s_addr == ap.src.s_addr)) + || ((IP_V(iptr) == 6) && !memcmp(&ip6tr->ip6_src, &ap.src6, sizeof(ap.src6))) ) + { ht->sent[history_pos] += len; ht->total_sent += len; } @@ -374,7 +506,7 @@ packet += 2; length -= 2; - if(proto == PPP_IP || proto == ETHERTYPE_IP) { + if(proto == PPP_IP || proto == ETHERTYPE_IP || proto == ETHERTYPE_IPV6) { handle_ip_packet((struct ip*)packet, -1); } } @@ -420,7 +552,7 @@ payload += sizeof(struct vlan_8021q_header); } - if(ether_type == ETHERTYPE_IP) { + if(ether_type == ETHERTYPE_IP || ether_type == ETHERTYPE_IPV6) { struct ip* iptr; int dir = -1; @@ -440,6 +572,7 @@ dir = 0; } + /* Distinguishing ip_hdr and ip6_hdr will be done later. */ iptr = (struct ip*)(payload); /* alignment? */ handle_ip_packet(iptr, dir); } @@ -452,10 +585,10 @@ char *set_filter_code(const char *filter) { char *x; if (filter) { - x = xmalloc(strlen(filter) + sizeof "() and ip"); - sprintf(x, "(%s) and ip", filter); + x = xmalloc(strlen(filter) + sizeof "() and (ip or ip6)"); + sprintf(x, "(%s) and (ip or ip6)", filter); } else - x = xstrdup("ip"); + x = xstrdup("ip or ip6"); if (pcap_compile(pd, &pcap_filter, x, 1, 0) == -1) { xfree(x); return pcap_geterr(pd); @@ -485,19 +618,28 @@ #ifdef HAVE_DLPI result = get_addrs_dlpi(options.interface, if_hw_addr, &if_ip_addr); #else - result = get_addrs_ioctl(options.interface, if_hw_addr, &if_ip_addr); + result = get_addrs_ioctl(options.interface, if_hw_addr, + &if_ip_addr, &if_ip6_addr); #endif if (result < 0) { exit(1); } - have_hw_addr = result & 1; - have_ip_addr = result & 2; + have_hw_addr = result & 0x01; + have_ip_addr = result & 0x02; + have_ip6_addr = result & 0x04; if(have_ip_addr) { fprintf(stderr, "IP address is: %s\n", inet_ntoa(if_ip_addr)); } + if(have_ip6_addr) { + char ip6str[INET6_ADDRSTRLEN]; + + ip6str[0] = '\0'; + inet_ntop(AF_INET6, &if_ip6_addr, ip6str, sizeof(ip6str)); + fprintf(stderr, "IPv6 address is: %s\n", ip6str); + } if(have_hw_addr) { fprintf(stderr, "MAC address is:"); --- iftop-0.17.orig/addrs_ioctl.c +++ iftop-0.17/addrs_ioctl.c @@ -18,12 +18,17 @@ #include #include -#if defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ +#if defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ \ + || ( defined __GNUC__ && ! defined __linux__ ) #include #include #include #endif +#ifdef USE_GETIFADDRS +#include +#endif + #include "iftop.h" /* @@ -40,16 +45,20 @@ */ int -get_addrs_ioctl(char *interface, char if_hw_addr[], struct in_addr *if_ip_addr) +get_addrs_ioctl(char *interface, char if_hw_addr[], struct in_addr *if_ip_addr, struct in6_addr *if_ip6_addr) { int s; struct ifreq ifr = {}; int got_hw_addr = 0; int got_ip_addr = 0; + int got_ip6_addr = 0; +#ifdef USE_GETIFADDRS + struct ifaddrs *ifa, *ifas; +#endif /* -- */ - s = socket(PF_INET, SOCK_DGRAM, 0); /* any sort of IP socket will do */ + s = socket(AF_INET, SOCK_DGRAM, 0); /* any sort of IP socket will do */ if (s == -1) { perror("socket"); @@ -71,7 +80,8 @@ got_hw_addr = 1; } #else -#if defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ +#if defined __FreeBSD__ || defined __OpenBSD__ || defined __APPLE__ \ + || ( defined __GNUC__ && ! defined __linux__ ) { int sysctlparam[6] = {CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST, 0}; size_t needed = 0; @@ -109,7 +119,45 @@ #endif /* Get the IP address of the interface */ -#ifdef SIOCGIFADDR +#ifdef USE_GETIFADDRS + if (getifaddrs(&ifas) == -1) { + fprintf(stderr, "Unable to get IP address for interface: %s\n", interface); + perror("getifaddrs()"); + } + else { + for (ifa = ifas; ifa != NULL; ifa = ifa->ifa_next) { + if (got_ip_addr && got_ip6_addr) + break; /* Search is already complete. */ + + if (strcmp(ifa->ifa_name, interface)) + continue; /* Not our interface. */ + + if ( (ifa->ifa_addr->sa_family != AF_INET) + && (ifa->ifa_addr->sa_family != AF_INET6) ) + continue; /* AF_PACKET is beyond our scope. */ + + if ( (ifa->ifa_addr->sa_family == AF_INET) + && !got_ip_addr ) { + got_ip_addr = 2; + memcpy(if_ip_addr, + &(((struct sockaddr_in *) ifa->ifa_addr)->sin_addr), + sizeof(*if_ip_addr)); + continue; + } + /* Must be a IPv6 address at this point. */ + struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *) ifa->ifa_addr; + + if ( IN6_IS_ADDR_LINKLOCAL(&(sa6->sin6_addr)) + || IN6_IS_ADDR_SITELOCAL(&(sa6->sin6_addr)) ) + continue; + + /* A useful IPv6 address. */ + memcpy(if_ip6_addr, &(sa6->sin6_addr), sizeof(*if_ip6_addr)); + got_ip6_addr = 4; + } + freeifaddrs(ifas); + } /* getifaddrs() */ +#elif defined(SIOCGIFADDR) (*(struct sockaddr_in *) &ifr.ifr_addr).sin_family = AF_INET; if (ioctl(s, SIOCGIFADDR, &ifr) < 0) { fprintf(stderr, "Unable to get IP address for interface: %s\n", interface); @@ -125,5 +173,5 @@ close(s); - return got_hw_addr + got_ip_addr; + return got_hw_addr + got_ip_addr + got_ip6_addr; } --- iftop-0.17.orig/options.c +++ iftop-0.17/options.c @@ -30,7 +30,7 @@ options_t options; -char optstr[] = "+i:f:nNF:hpbBPm:c:"; +char optstr[] = "+i:f:nNF:G:lhpbBPm:c:"; /* Global options. */ @@ -118,6 +118,10 @@ options.netfilter = 0; inet_aton("10.0.1.0", &options.netfilternet); inet_aton("255.255.255.0", &options.netfiltermask); + options.netfilter6 = 0; + inet_pton(AF_INET6, "fe80::", &options.netfilter6net); /* Link-local */ + inet_pton(AF_INET6, "ffff::", &options.netfilter6mask); + options.link_local = 0; options.dnsresolution = 1; options.portresolution = 1; #ifdef NEED_PROMISCUOUS_FOR_OUTGOING @@ -237,7 +241,8 @@ fprintf(fp, "iftop: display bandwidth usage on an interface by host\n" "\n" -"Synopsis: iftop -h | [-npbBP] [-i interface] [-f filter code] [-N net/mask]\n" +"Synopsis: iftop -h | [-npblBP] [-i interface] [-f filter code]\n" +" [-F net/mask] [-G net6/mask6]\n" "\n" " -h display this message\n" " -n don't do hostname lookups\n" @@ -249,7 +254,9 @@ " -i interface listen on named interface\n" " -f filter code use filter code to select packets to count\n" " (default: none, but only IP packets are counted)\n" -" -F net/mask show traffic flows in/out of network\n" +" -F net/mask show traffic flows in/out of IPv4 network\n" +" -G net6/mask6 show traffic flows in/out of IPv6 network\n" +" -l display and count link-local IPv6 traffic (default: off)\n" " -P show ports as well as hosts\n" " -m limit sets the upper limit for the bandwidth scale\n" " -c config file specifies an alternative configuration file\n" @@ -285,6 +292,10 @@ config_set_string("filter-code", optarg); break; + case 'l': + config_set_string("link-local", "true"); + break; + case 'p': config_set_string("promiscuous", "true"); break; @@ -297,6 +308,10 @@ config_set_string("net-filter", optarg); break; + case 'G': + config_set_string("net-filter6", optarg); + break; + case 'm': config_set_string("max-bandwidth", optarg); break; @@ -437,6 +452,8 @@ if(s) { char* mask; + options.netfilter = 0; + mask = strchr(s, '/'); if (mask == NULL) { fprintf(stderr, "Could not parse net/mask: %s\n", s); @@ -454,7 +471,7 @@ int n; n = atoi(mask); if (n > 32) { - fprintf(stderr, "Invalid netmask: %s\n", s); + fprintf(stderr, "Invalid netmask length: %s\n", mask); } else { if(n == 32) { @@ -469,17 +486,86 @@ options.netfiltermask.s_addr = htonl(~mm); } } + options.netfilter = 1; } - else if (inet_aton(mask, &options.netfiltermask) == 0) { - fprintf(stderr, "Invalid netmask: %s\n", s); + else { + if (inet_aton(mask, &options.netfiltermask) != 0) + options.netfilter = 1; + else { + fprintf(stderr, "Invalid netmask: %s\n", s); + return 0; + } } options.netfilternet.s_addr = options.netfilternet.s_addr & options.netfiltermask.s_addr; - options.netfilter = 1; return 1; } return 0; } +/* + * Read the net filter IPv6 option. + */ +int options_config_get_net_filter6() { + char* s; + int j; + + s = config_get_string("net-filter6"); + if(s) { + char* mask; + + options.netfilter6 = 0; + + mask = strchr(s, '/'); + if (mask == NULL) { + fprintf(stderr, "Could not parse IPv6 net/prefix: %s\n", s); + return 0; + } + *mask = '\0'; + mask++; + if (inet_pton(AF_INET6, s, &options.netfilter6net) == 0) { + fprintf(stderr, "Invalid IPv6 network address: %s\n", s); + return 0; + } + /* Accept prefix lengths and address expressions. */ + if (mask[strspn(mask, "0123456789")] == '\0') { + /* Whole string is numeric */ + unsigned int n; + + n = atoi(mask); + if (n > 128 || n < 1) { + fprintf(stderr, "Invalid IPv6 prefix length: %s\n", mask); + } + else { + int bl, rem; + const uint32_t mm = 0xffffffff; + uint32_t part = mm; + + bl = n / 32; + rem = n % 32; + part <<= 32 - rem; + for (j=0; j < bl; ++j) + options.netfilter6mask.s6_addr32[j] = htonl(mm); + if (rem > 0) + options.netfilter6mask.s6_addr32[bl] = htonl(part); + options.netfilter6 = 1; + } + } + else { + if (inet_pton(AF_INET6, mask, &options.netfilter6mask) != 0) + options.netfilter6 = 1; + else { + fprintf(stderr, "Invalid IPv6 netmask: %s\n", s); + return 0; + } + } + /* Prepare any comparison by masking the provided filtered net. */ + for (j=0; j < 4; ++j) + options.netfilter6net.s6_addr32[j] &= options.netfilter6mask.s6_addr32[j]; + + return 1; + } + return 0; +} void options_make() { options_config_get_string("interface", &options.interface); @@ -498,5 +584,7 @@ options_config_get_bw_rate("max-bandwidth", &options.max_bandwidth); options_config_get_enum("port-display", showports_enumeration, (int*)&options.showports); options_config_get_string("screen-filter", &options.screenfilter); + options_config_get_bool("link-local", &options.link_local); options_config_get_net_filter(); + options_config_get_net_filter6(); }; --- iftop-0.17.orig/addr_hash.c +++ iftop-0.17/addr_hash.c @@ -11,6 +11,19 @@ int compare(void* a, void* b) { addr_pair* aa = (addr_pair*)a; addr_pair* bb = (addr_pair*)b; + + if (aa->af != bb->af) + return 0; + + if (aa->af == AF_INET6) { + return (IN6_ARE_ADDR_EQUAL(&aa->src6, &bb->src6) + && aa->src_port == bb->src_port + && IN6_ARE_ADDR_EQUAL(&aa->dst6, &bb->dst6) + && aa->dst_port == bb->dst_port + && aa->protocol == bb->protocol); + } + + /* AF_INET or unknown. */ return (aa->src.s_addr == bb->src.s_addr && aa->src_port == bb->src_port && aa->dst.s_addr == bb->dst.s_addr @@ -18,25 +31,42 @@ && aa->protocol == bb->protocol); } +static int __inline__ hash_uint32(uint32_t n) { + return ((n & 0x000000FF) + + ((n & 0x0000FF00) >> 8) + + ((n & 0x00FF0000) >> 16) + + ((n & 0xFF000000) >> 24)); +} + int hash(void* key) { int hash; - long addr; addr_pair* ap = (addr_pair*)key; - - addr = (long)ap->src.s_addr; - hash = ((addr & 0x000000FF) - + (addr & 0x0000FF00 >> 8) - + (addr & 0x00FF0000 >> 16) - + (addr & 0xFF000000 >> 24) - + ap->src_port) % 0xFF; - - addr = (long)ap->dst.s_addr; - hash = ( hash + (addr & 0x000000FF) - + (addr & 0x0000FF00 >> 8) - + (addr & 0x00FF0000 >> 16) - + (addr & 0xFF000000 >> 24) - + ap->dst_port) % 0xFF; + if (ap->af == AF_INET6) { + uint32_t* addr6 = ap->src6.s6_addr32; + + hash = ( hash_uint32(addr6[0]) + + hash_uint32(addr6[1]) + + hash_uint32(addr6[2]) + + hash_uint32(addr6[3]) + + ap->src_port) % 0xFF; + + addr6 = ap->dst6.s6_addr32; + hash = ( hash + hash_uint32(addr6[0]) + + hash_uint32(addr6[1]) + + hash_uint32(addr6[2]) + + hash_uint32(addr6[3]) + + ap->dst_port) % 0xFF; + } else { + in_addr_t addr = ap->src.s_addr; + + hash = ( hash_uint32(addr) + + ap->src_port) % 0xFF; + + addr = ap->dst.s_addr; + hash = ( hash + hash_uint32(addr) + + ap->dst_port) % 0xFF; + } return hash; } --- iftop-0.17.orig/options.h +++ iftop-0.17/options.h @@ -78,6 +78,13 @@ struct in_addr netfilternet; struct in_addr netfiltermask; + int netfilter6; + struct in6_addr netfilter6net; + struct in6_addr netfilter6mask; + + /* Account for link-local traffic. */ + int link_local; + char *config_file; int config_file_specified; --- iftop-0.17.orig/addr_hash.h +++ iftop-0.17/addr_hash.h @@ -12,11 +12,18 @@ #include "hash.h" typedef struct { + int af; unsigned short int protocol; unsigned short int src_port; - struct in_addr src; + union { + struct in_addr src; + struct in6_addr src6; + }; unsigned short int dst_port; - struct in_addr dst; + union { + struct in_addr dst; + struct in6_addr dst6; + }; } addr_pair; typedef addr_pair key_type; /* index into hash table */ --- iftop-0.17.orig/ns_hash.c +++ iftop-0.17/ns_hash.c @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -14,29 +15,36 @@ #define hash_table_size 256 int ns_hash_compare(void* a, void* b) { - struct in_addr* aa = (struct in_addr*)a; - struct in_addr* bb = (struct in_addr*)b; - return (aa->s_addr == bb->s_addr); + struct in6_addr* aa = (struct in6_addr*)a; + struct in6_addr* bb = (struct in6_addr*)b; + return IN6_ARE_ADDR_EQUAL(aa, bb); +} + +static int __inline__ hash_uint32(uint32_t n) { + return ((n & 0x000000FF) + + ((n & 0x0000FF00) >> 8) + + ((n & 0x00FF0000) >> 16) + + ((n & 0xFF000000) >> 24)); } int ns_hash_hash(void* key) { int hash; - long addr; - - addr = (long)((struct in_addr*)key)->s_addr; - - hash = ((addr & 0x000000FF) - + (addr & 0x0000FF00 >> 8) - + (addr & 0x00FF0000 >> 16) - + (addr & 0xFF000000 >> 24)) % 0xFF; + uint32_t* addr6 = ((struct in6_addr *) key)->s6_addr32; + + hash = ( hash_uint32(addr6[0]) + + hash_uint32(addr6[1]) + + hash_uint32(addr6[2]) + + hash_uint32(addr6[3])) % 0xFF; return hash; } void* ns_hash_copy_key(void* orig) { - struct in_addr* copy; + struct in6_addr* copy; + copy = xmalloc(sizeof *copy); - *copy = *(struct in_addr*)orig; + memcpy(copy, orig, sizeof *copy); + return copy; } --- iftop-0.17.orig/cfgfile.c +++ iftop-0.17/cfgfile.c @@ -36,6 +36,8 @@ "log-scale", "max-bandwidth", "net-filter", + "net-filter6", + "link-local", "port-display", NULL }; @@ -230,8 +232,15 @@ stringmap S; S = stringmap_find(config, directive); - if (S) stringmap_delete_free(S); - stringmap_insert(config, directive, item_ptr(xstrdup(s))); + if (S) { + /* Replace any already stored string value. + * The node can simply not be deleted straight off, + * due to possible presence of leafs on either side. */ + if (S->d.v) + xfree(S->d.v); + S->d.v = xstrdup(s); + } else + stringmap_insert(config, directive, item_ptr(xstrdup(s))); } int read_config(char *file, int whinge_on_error) { --- iftop-0.17.orig/resolver.h +++ iftop-0.17/resolver.h @@ -14,6 +14,6 @@ void resolver_initialise(void); -void resolve(struct in_addr* addr, char* result, int buflen); +void resolve(int af, struct in6_addr* addr, char* result, int buflen); #endif /* __RESOLVER_H_ */ --- iftop-0.17.orig/stringmap.c +++ iftop-0.17/stringmap.c @@ -53,11 +53,11 @@ } /* stringmap_insert: - * Insert into S an item having key k and value d. Returns an existing key - * or NULL if it was inserted. + * Insert into S an item having key k and value d. Returns a pointer to + * the existing item value, or NULL if a new item was created. */ item *stringmap_insert(stringmap S, const char *k, const item d) { - if (!S) return 0; + if (!S) return NULL; if (S->key == NULL) { S->key = xstrdup(k); S->d = d; --- iftop-0.17.orig/ui.c +++ iftop-0.17/ui.c @@ -109,19 +109,19 @@ * Compare two screen lines based on hostname / IP. Fall over to compare by * bandwidth. */ -int screen_line_host_compare(struct in_addr* a, struct in_addr* b, host_pair_line* aa, host_pair_line* bb) { +int screen_line_host_compare(void* a, void* b, host_pair_line* aa, host_pair_line* bb) { char hosta[HOSTNAME_LENGTH], hostb[HOSTNAME_LENGTH]; int r; /* This isn't overly efficient because we resolve again before display. */ if (options.dnsresolution) { - resolve(a, hosta, HOSTNAME_LENGTH); - resolve(b, hostb, HOSTNAME_LENGTH); + resolve(aa->ap.af, a, hosta, HOSTNAME_LENGTH); + resolve(bb->ap.af, b, hostb, HOSTNAME_LENGTH); } else { - strcpy(hosta, inet_ntoa(*a)); - strcpy(hostb, inet_ntoa(*b)); + inet_ntop(aa->ap.af, a, hosta, sizeof(hosta)); + inet_ntop(bb->ap.af, b, hostb, sizeof(hostb)); } r = strcmp(hosta, hostb); @@ -149,10 +149,10 @@ return screen_line_bandwidth_compare(aa, bb, 2); } else if(options.sort == OPTION_SORT_SRC) { - return screen_line_host_compare(&(aa->ap.src), &(bb->ap.src), aa, bb); + return screen_line_host_compare(&(aa->ap.src6), &(bb->ap.src6), aa, bb); } else if(options.sort == OPTION_SORT_DEST) { - return screen_line_host_compare(&(aa->ap.dst), &(bb->ap.dst), aa, bb); + return screen_line_host_compare(&(aa->ap.dst6), &(bb->ap.dst6), aa, bb); } return 1; @@ -486,10 +486,10 @@ /* Aggregate hosts, if required */ if(options.aggregate_src) { - ap.src.s_addr = 0; + memset(&ap.src6, '\0', sizeof(ap.src6)); } if(options.aggregate_dest) { - ap.dst.s_addr = 0; + memset(&ap.dst6, '\0', sizeof(ap.dst6)); } /* Aggregate ports, if required */ @@ -534,7 +534,7 @@ } -void sprint_host(char * line, struct in_addr* addr, unsigned int port, unsigned int protocol, int L) { +void sprint_host(char * line, int af, struct in6_addr* addr, unsigned int port, unsigned int protocol, int L) { char hostname[HOSTNAME_LENGTH]; char service[HOSTNAME_LENGTH]; char* s_name; @@ -545,14 +545,15 @@ ip_service skey; int left; - if(addr->s_addr == 0) { + + if(IN6_IS_ADDR_UNSPECIFIED(addr)) { sprintf(hostname, " * "); } else { if (options.dnsresolution) - resolve(addr, hostname, L); + resolve(af, addr, hostname, L); else - strcpy(hostname, inet_ntoa(*addr)); + inet_ntop(af, addr, hostname, sizeof(hostname)); } left = strlen(hostname); @@ -636,8 +637,15 @@ L = HOSTNAME_LENGTH; } - sprint_host(host1, &(screen_line->ap.src), screen_line->ap.src_port, screen_line->ap.protocol, L); - sprint_host(host2, &(screen_line->ap.dst), screen_line->ap.dst_port, screen_line->ap.protocol, L); + sprint_host(host1, screen_line->ap.af, + &(screen_line->ap.src6), + screen_line->ap.src_port, + screen_line->ap.protocol, L); + sprint_host(host2, screen_line->ap.af, + &(screen_line->ap.dst6), + screen_line->ap.dst_port, + screen_line->ap.protocol, L); + if(!screen_filter_match(host1) && !screen_filter_match(host2)) { continue; } --- iftop-0.17.orig/resolver.c +++ iftop-0.17/resolver.c @@ -25,7 +25,7 @@ #define RESOLVE_QUEUE_LENGTH 20 -struct in_addr resolve_queue[RESOLVE_QUEUE_LENGTH]; +struct in6_addr resolve_queue[RESOLVE_QUEUE_LENGTH]; pthread_cond_t resolver_queue_cond; pthread_mutex_t resolver_queue_mutex; @@ -55,18 +55,48 @@ * as NetBSD break the RFC and implement it in a non-thread-safe fashion, so * for the moment, the configure script won't try to use it. */ -char *do_resolve(struct in_addr *addr) { - struct sockaddr_in sin = {0}; +char *do_resolve(struct in6_addr *addr) { + struct sockaddr_in sin; + struct sockaddr_in6 sin6; char buf[NI_MAXHOST]; /* 1025 */ - int res; - sin.sin_family = AF_INET; - sin.sin_addr = *addr; - sin.sin_port = 0; + int res, af; + uint32_t* probe; - if (getnameinfo((struct sockaddr*)&sin, sizeof sin, buf, sizeof buf, NULL, 0, NI_NAMEREQD) == 0) - return xstrdup(buf); - else - return NULL; + memset(&sin, '\0', sizeof(sin)); + memset(&sin6, '\0', sizeof(sin6)); + + /* If the upper three (network byte order) uint32-parts + * are null, then there ought to be an IPv4 address here. + * Any such IPv6 would have to be 'xxxx::'. Neglectable? */ + probe = (uint32_t *) addr; + af = (probe[1] || probe[2] || probe[3]) ? AF_INET6 : AF_INET; + + switch (af) { + case AF_INET: + sin.sin_family = af; + sin.sin_port = 0; + memcpy(&sin.sin_addr, addr, sizeof(sin.sin_addr)); + + if (getnameinfo((struct sockaddr*)&sin, sizeof sin, + buf, sizeof buf, NULL, 0, NI_NAMEREQD) == 0) + return xstrdup(buf); + else + return NULL; + break; + case AF_INET6: + sin6.sin6_family = af; + sin6.sin6_port = 0; + memcpy(&sin6.sin6_addr, addr, sizeof(sin6.sin6_addr)); + + if (getnameinfo((struct sockaddr*)&sin6, sizeof sin6, + buf, sizeof buf, NULL, 0, NI_NAMEREQD) == 0) + return xstrdup(buf); + else + return NULL; + break; + default: + return NULL; + } } #elif defined(USE_GETHOSTBYADDR_R) @@ -376,7 +406,7 @@ /* Keep resolving until the queue is empty */ while(head != tail) { char * hostname; - struct in_addr addr = resolve_queue[tail]; + struct in6_addr addr = resolve_queue[tail]; /* mutex always locked at this point */ @@ -427,7 +457,7 @@ } -void resolve(struct in_addr* addr, char* result, int buflen) { +void resolve(int af, struct in6_addr* addr, char* result, int buflen) { char* hostname; union { char **ch_pp; @@ -443,12 +473,18 @@ /* Found => already resolved, or on the queue */ } else { - hostname = strdup(inet_ntoa(*addr)); + hostname = xmalloc(INET6_ADDRSTRLEN); + inet_ntop(af, addr, hostname, INET6_ADDRSTRLEN); hash_insert(ns_hash, addr, hostname); if(((head + 1) % RESOLVE_QUEUE_LENGTH) == tail) { /* queue full */ } + else if((af == AF_INET6) + && (IN6_IS_ADDR_LINKLOCAL(addr) + || IN6_IS_ADDR_SITELOCAL(addr))) { + /* Link-local and site-local stay numerical. */ + } else { resolve_queue[head] = *addr; head = (head + 1) % RESOLVE_QUEUE_LENGTH; --- iftop-0.17.orig/iftop.8 +++ iftop-0.17/iftop.8 @@ -11,8 +11,8 @@ .SH SYNOPSIS \fBiftop\fP \fB-h\fP | -[\fB-nNpbBP\fP] [\fB-i\fP \fIinterface\fP] [\fB-f\fP \fIfilter code\fP] [\fB-F\fP \fInet\fP/\fImask\fP] - +[\fB-nNpblBP\fP] [\fB-i\fP \fIinterface\fP] [\fB-f\fP \fIfilter code\fP] [\fB-F\fP \fInet\fP/\fImask\fP] +[\fB-G\fP \fInet6\fP/\fImask6\fP] .SH DESCRIPTION \fBiftop\fP listens to network traffic on a named \fIinterface\fP, or on the first interface it can find which looks like an external interface if none is @@ -65,6 +65,10 @@ \fB-P\fP Turn on port display. .TP +\fB-l\fP +Display and count datagrams addressed to or from link-local IPv6 addresses. +The default is not to display that address category. +.TP \fB-b\fP Don't display bar graphs of traffic. .TP @@ -79,12 +83,17 @@ counted, so the specified code is evaluated as \fB(\fP\fIfilter code\fP\fB) and ip\fP. .TP \fB-F\fP \fInet\fP/\fImask\fP -Specifies a network for traffic analysis. If specified, iftop will only +Specifies an IPv4 network for traffic analysis. If specified, iftop will only include packets flowing in to or out of the given network, and packet direction is determined relative to the network boundary, rather than to the interface. You may specify \fImask\fP as a dotted quad, such as /255.255.255.0, or as a single number specifying the number of bits set in the netmask, such as /24. .TP +\fB-G\fP \fInet6\fP/\fImask6\fP +Specifies an IPv6 network for traffic analysis. The value of \fImask6\fP can be +given as a prefix length or as a numerical address string for more compound +bitmasking. +.TP \fB-c\fP \fIconfig file\fP Specifies an alternate config file. If not specified, iftop will use \fB~/.iftoprc\fP if it exists. See below for a description of config files @@ -213,6 +222,9 @@ \fBport-display:\fP \fI(off|source-only|destination-only|on)\fP Controls display of port numbers. .TP +\fBlink-local:\fP \fI(yes|no)\fP +Determines displaying of link-local IPv6 addresses. +.TP \fBhide-source:\fP \fI(yes|no)\fP Hides source host names. .TP @@ -240,6 +252,9 @@ \fBnet-filter:\fP \fInet/mask\fP Defines an IP network boundary for determining packet direction. .TP +\fBnet-filter6:\fP \fInet6/mask6\fP +Defines an IPv6 network boundary for determining packet direction. +.TP \fBscreen-filter:\fP \fIregexp\fP Sets a regular expression to filter screen output. --- iftop-0.17.orig/debian/compat +++ iftop-0.17/debian/compat @@ -0,0 +1 @@ +7 --- iftop-0.17.orig/debian/rules +++ iftop-0.17/debian/rules @@ -0,0 +1,22 @@ +#!/usr/bin/make -f + +%: + dh ${@} --with quilt + +override_dh_auto_clean: + dh_auto_clean + + rm -f config.guess config.sub + +override_dh_auto_configure: + [ -r /usr/share/misc/config.guess ] && cp -f /usr/share/misc/config.guess config.guess + [ -r /usr/share/misc/config.sub ] && cp -f /usr/share/misc/config.sub config.sub + + dh_auto_configure -- LDFLAGS="${LDFLAGS} -Wl,-z,defs" \ + CFLAGS="${CFLAGS} -Wall -DUSE_GETNAMEINFO=1 -DUSE_GETIFADDRS=1" + +override_dh_auto_install: + dh_auto_install -- DESTDIR=$(CURDIR)/debian/iftop + +override_dh_strip: + dh_strip --dbg-package=iftop-dbg --- iftop-0.17.orig/debian/NEWS +++ iftop-0.17/debian/NEWS @@ -0,0 +1,11 @@ +iftop (0.17-17) unstable; urgency=low + + The iftop package is now shipped with the "-DNO_SYSTEM" flag enabled. + This disables the possibility to run commands in a subshell. This is a + kind of unexpected feauture and could allow users, running iftop via sudo + to get a complete root shell (if sudo is not configure properly). + + I appologise for any inconvenience caused to users of this feature and + recommend the usage of screen or several terminal windows. + + -- Alexander Reichle-Schmehl Tue, 19 Jan 2010 14:31:29 +0100 --- iftop-0.17.orig/debian/copyright +++ iftop-0.17/debian/copyright @@ -0,0 +1,46 @@ +Authors: + Paul Warren + Chris Lightfoot +Download: http://www.ex-parrot.com/~pdw/iftop/download/ + +Files: * +Copyright: + (C) 2002-2004 Paul Warren + (C) 2002-2004 Chris Lightfoot +License: GPL-2+ + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + . + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + . + On Debian systems, the complete text of the GNU General Public License + can be found in /usr/share/common-licenses/GPL-2 file. + +Files: debian/* +Copyright: 2005-2009 Daniel Baumann , 2009-2010 Alexander Reichle-Schmehl +License: GPL-2+ + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + . + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + . + On Debian systems, the complete text of the GNU General Public License + can be found in /usr/share/common-licenses/GPL-2 file. --- iftop-0.17.orig/debian/changelog +++ iftop-0.17/debian/changelog @@ -0,0 +1,263 @@ +iftop (0.17-17) experimental; urgency=low + + * Use versioned build depends on quilt to allow easy backporting + * Add IPv6 support (Closes: #427852) + * Fix segfault when using the same command line argument multiple time + (Closes: #425488) + * Fix typo in display (Closes: #477928) + * Use better hash Algorithm in address pairs (Closes: #595169) + * Fix link-level address detection on kfreebsd-* (Closes: #598367) + * Many thanks for Mats Erik Andersson for working on these issues! + + -- Alexander Reichle-Schmehl Fri, 15 Oct 2010 11:30:59 +0200 + +iftop (0.17-16) unstable; urgency=low + + * Adopt package (Closes: #543874) + * Add README.source + * Bump build-depends on debhelper, since we use override targets + * Fix another typo in iftop.8 + + -- Alexander Reichle-Schmehl Mon, 18 Jan 2010 23:35:24 +0100 + +iftop (0.17-15) unstable; urgency=low + + * Updating package to standards version 3.8.3. + * Removing vcs fields. + * Orphaning package. + + -- Daniel Baumann Thu, 27 Aug 2009 09:47:18 +0200 + +iftop (0.17-14) unstable; urgency=low + + * Removing accidentally imported (useless) removal of po files in + clean. + * Avoid empty packages because dh tries to be extra clever wrt/ + destdir. + + -- Daniel Baumann Wed, 29 Jul 2009 23:47:10 +0200 + +iftop (0.17-13) unstable; urgency=low + + * Minimizing rules file. + * Wrapping patch descriptions to 80 characters a line. + + -- Daniel Baumann Wed, 29 Jul 2009 23:19:11 +0200 + +iftop (0.17-12) unstable; urgency=low + + * Updating package to standards version 3.8.2. + * Updating manpage patch to also remove unknown sequences. + * Adding misc depends to the debug package. + + -- Daniel Baumann Mon, 27 Jul 2009 13:20:53 +0200 + +iftop (0.17-11) unstable; urgency=low + + * Updating rules to current state of the art. + * Upgrading package to standards 3.8.1. + * Updating section for debug packages. + * Using correct rfc-2822 date formats in changelog. + + -- Daniel Baumann Mon, 04 May 2009 11:42:02 +0200 + +iftop (0.17-10) unstable; urgency=low + + * Applying patch from Marcin Kryczek to make displaying of top bar and + screen consistent regarding bits and bytes mode (Closes: #513243). + * Adding note in manpage about always using bits when specifying max- + bandwith, regardless if the option to display in bytes was choosen, + thanks to Nathan Stratton Treadway . + + -- Daniel Baumann Tue, 27 Jan 2009 17:51:00 +0100 + +iftop (0.17-9) unstable; urgency=low + + * Reordering compiler flags in configure call. + * Correcting indenting in copyright file. + * Updatingto debhelper 7. + * Updating to standards 3.8.0. + * Updating vcs fields in control file. + * Using patch-stamp rather than patch in rules file. + * Replacing obsolete dh_clean -k with dh_prep. + * Prefixing debhelper files with package name. + * Using quilt rather than dpatch. + * Updating year in copyright file. + * Updating rules to current state of the art. + * Updating manpage patch in order to fix yet another typo in the manpage, + thanks to Serafeim Zanikolas (Closes: #512886). + * Sorting build-depends. + + -- Daniel Baumann Sun, 25 Jan 2009 00:05:00 +0100 + +iftop (0.17-8) unstable; urgency=low + + * Adding debug package. + + -- Daniel Baumann Wed, 16 Apr 2008 13:52:00 +0200 + +iftop (0.17-7) unstable; urgency=low + + * Reordering rules file. + * Removing config.guess and config.sub from debian branch. + * Removing watch file. + * Removing useless REAMDE from docs file. + * Rewriting copyright file in machine-interpretable format. + * Adding vcs fields in control file. + * Updating package to debhelper 6. + * Removing useless whitespaces in changelog file. + + -- Daniel Baumann Wed, 16 Apr 2008 13:39:00 +0200 + +iftop (0.17-6) unstable; urgency=low + + * Bumped policy version. + * Using new homepage field in control. + * Don't hide make errors in clean target of rules. + + -- Daniel Baumann Sun, 23 Dec 2007 15:55:00 +0100 + +iftop (0.17-5) unstable; urgency=low + + * Applied patch from Eric Cooper to fix -b option + (Closes: #445991). + + -- Daniel Baumann Tue, 09 Oct 2007 21:19:00 +0200 + +iftop (0.17-4) unstable; urgency=low + + * Minor cleanups. + * Bumped package to debhelper 5. + + -- Daniel Baumann Tue, 01 May 2007 13:45:00 +0200 + +iftop (0.17-3) unstable; urgency=low + + * Updated build-depends, moving libpcap-dev to libpcap0.8-dev + (Closes: #386904). + + -- Daniel Baumann Mon, 11 Sep 2006 09:09:00 +0200 + +iftop (0.17-2) unstable; urgency=low + + * New email address. + * Bumped policy version. + + -- Daniel Baumann Thu, 06 Jul 2006 08:48:00 +0200 + +iftop (0.17-1) unstable; urgency=low + + * New upstream release. + * Fixed manpage typos (Closes: #360205). + + -- Daniel Baumann Sat, 22 Apr 2006 17:04:00 +0100 + +iftop (0.16-5) unstable; urgency=low + + * Added patch to fix crash on arm (Closes: #351293). + + -- Daniel Baumann Sat, 04 Feb 2006 12:13:00 +0100 + +iftop (0.16-4) unstable; urgency=low + + * Added patch to fix drives line going crazy if order is frozen + (Closes: #315734). + + -- Daniel Baumann Mon, 05 Dec 2005 23:07:00 +0100 + +iftop (0.16-3) unstable; urgency=low + + * Added patch to fix armeb specific bug of structure size (Closes: #336212). + + -- Daniel Baumann Thu, 03 Nov 2005 22:45:00 +0200 + +iftop (0.16-2) unstable; urgency=low + + * New maintainer (Closes: #335917). + * Redone debian/ based on new debhelper templates: + - added watch file. + - bumped to new policy. + - config.{guess,sub} are now updated via diff.gz (Closes: #333825). + - added patch to fix manpage and usage string for -N and -F options + (Closes: #335203). + + -- Daniel Baumann Wed, 26 Oct 2005 23:08:00 +0200 + +iftop (0.16-1) unstable; urgency=low + + * New upstream release. + + -- christophe barbe Tue, 06 Apr 2004 20:37:45 -0400 + +iftop (0.15-2) unstable; urgency=low + + * Fix -N and -n options (Closes: #228643) + Thanks to Klaus Sperner . + + -- christophe barbe Mon, 19 Jan 2004 21:03:05 -0500 + +iftop (0.15-1) unstable; urgency=low + + * New upstream release. + + -- christophe barbe Sat, 15 Nov 2003 14:43:29 -0500 + +iftop (0.13-1) unstable; urgency=low + + * New upstream. + * iftop moved in /usr/sbin (Closes: #185285). + + -- christophe barbe Fri, 25 Jul 2003 17:32:38 -0400 + +iftop (0.11-2) unstable; urgency=low + + * Move DH_COMPAT in debian/compat. + * Bump Standards-Version up to 3.5.9. + + -- christophe barbe Thu, 03 Apr 2003 20:41:17 -0500 + +iftop (0.11-1) unstable; urgency=low + + * New upstream. + * Authors took into account some Flawfinder reports (Closes: #168542). + + -- christophe barbe Sun, 12 Jan 2003 18:31:04 -0500 + +iftop (0.10-1) unstable; urgency=low + + * New Upstream. + + -- christophe barbe Tue, 29 Oct 2002 18:35:13 -0500 + +iftop (0.9-1) unstable; urgency=low + + * New Upstream (closes: #166036). + + -- christophe barbe Wed, 23 Oct 2002 09:25:10 -0400 + +iftop (0.7-1) unstable; urgency=low + + * New buildable upstream release (unlike 0.6). + + -- christophe barbe Thu, 29 Aug 2002 13:35:15 -0400 + +iftop (0.5-1) unstable; urgency=low + + * New Upstream release. + * Exit nicely when running as non-root (Closes: #157168). + * Better interface selection (Closes: #157176). + + -- christophe barbe Mon, 26 Aug 2002 15:54:14 -0400 + +iftop (0.4-2) unstable; urgency=low + + * Rebuilt with new libpcap to remove dependency on libpcap0, which I + got removed from unstable by accident. (closes: #156217). + + -- christophe barbe Sun, 11 Aug 2002 16:27:00 -0400 + +iftop (0.4-1) unstable; urgency=low + + * Initial Release (closes: #151413). + + -- christophe barbe Sat, 29 Jun 2002 17:43:41 -0400 --- iftop-0.17.orig/debian/iftop.docs +++ iftop-0.17/debian/iftop.docs @@ -0,0 +1 @@ +TODO --- iftop-0.17.orig/debian/watch +++ iftop-0.17/debian/watch @@ -0,0 +1,4 @@ +version=3 +http://www.ex-parrot.com/~pdw/iftop/download/?M0D \ + iftop-([\d\.]*).tar.gz + --- iftop-0.17.orig/debian/README.source +++ iftop-0.17/debian/README.source @@ -0,0 +1,2 @@ +This package uses quilt for patch management, for more information see +the file /usr/share/doc/quilt/README.source in the quilt package. --- iftop-0.17.orig/debian/control +++ iftop-0.17/debian/control @@ -0,0 +1,31 @@ +Source: iftop +Section: net +Priority: optional +Maintainer: Alexander Reichle-Schmehl +Build-Depends: debhelper (>= 7.0.50~), quilt (>= 0.46-7~), autotools-dev, libncurses5-dev, libpcap0.8-dev +Standards-Version: 3.8.3 +Homepage: http://www.ex-parrot.com/~pdw/iftop/ +Vcs-Svn: svn://svn.debian.org/collab-maint/deb-maint/iftop/trunk/ +Vcs-Browser: http://svn.debian.org/viewsvn/collab-maint/deb-maint/iftop/ + +Package: iftop +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: displays bandwidth usage information on an network interface + iftop does for network usage what top(1) does for CPU usage. It listens to + network traffic on a named interface and displays a table of current bandwidth + usage by pairs of hosts. Handy for answering the question "Why is my Internet + link so slow?". + +Package: iftop-dbg +Section: debug +Priority: extra +Architecture: any +Depends: ${misc:Depends}, iftop (= ${binary:Version}) +Description: displays bandwidth usage information on an network interface (debug) + iftop does for network usage what top(1) does for CPU usage. It listens to + network traffic on a named interface and displays a table of current bandwidth + usage by pairs of hosts. Handy for answering the question "Why is my Internet + link so slow?". + . + This package contains the debugging symbols. --- iftop-0.17.orig/debian/patches/01-manpage.patch +++ iftop-0.17/debian/patches/01-manpage.patch @@ -0,0 +1,47 @@ +Author: A. Costa +Description: Fixes a few typos. + +--- a/iftop.8 ++++ b/iftop.8 +@@ -25,7 +25,7 @@ By default, \fBiftop\fP will look up the + finds in packets. This can cause substantial traffic of itself, and may result + in a confusing display. You may wish to suppress display of DNS traffic by + using filter code such as \fBnot port domain\fP, or switch it off entirely, +-by using the \fB-n\fP option or by pressing \fBR\fP when the program is running. ++by using the \fB-n\fP option or by pressing \fBn\fP when the program is running. + + By default, \fBiftop\fP counts all IP packets that pass through the filter, and + the direction of the packet is determined according to the direction the packet +@@ -43,7 +43,7 @@ Ignore ethernet broadcast packets. + Count web traffic only, unless it is being directed through a local web cache. + .TP + \fBicmp\fP +-How much bandwith are users wasting trying to figure out why the network is ++How much bandwidth are users wasting trying to figure out why the network is + slow? + + .SH OPTIONS +@@ -104,7 +104,6 @@ instance, + foo.example.com => bar.example.com 1Kb 500b 100b + <= 2Mb 2Mb 2Mb + +-.Sp + .fi + shows, on the first line, traffic from \fBfoo.example.com\fP to + \fBbar.example.com\fP; in the preceding 2 seconds, this averaged 1Kbit/s, +@@ -229,13 +228,13 @@ Sets which column is used to sort the di + Controls the appearance of each item in the display. + .TP + \fBshow-totals:\fP \fI(yes|no)\fP +-Shows cummulative total for each item. ++Shows cumulative total for each item. + .TP + \fBlog-scale:\fP \fI(yes|no)\fP + Use a logarithmic scale for bar graphs. + .TP + \fBmax-bandwidth:\fP \fIbw\fP +-Fixes the maximum for the bar graph scale to \fIbw\fP, e.g. "10M" ++Fixes the maximum for the bar graph scale to \fIbw\fP, e.g. "10M". Note that the value has to always be in bits, regardless if the option to display in bytes has been chosen. + .TP + \fBnet-filter:\fP \fInet/mask\fP + Defines an IP network boundary for determining packet direction. --- iftop-0.17.orig/debian/patches/05-bar-display.patch +++ iftop-0.17/debian/patches/05-bar-display.patch @@ -0,0 +1,17 @@ +Author: Eric Cooper +Description: + The -b option doesn't turn off the bar display as the man page says it should + (Closes: #445991). + +diff -Naurp iftop.orig/options.c iftop/options.c +--- iftop.orig/options.c 2008-09-07 23:53:08.000000000 +0000 ++++ iftop/options.c 2009-01-24 22:58:21.000000000 +0000 +@@ -302,7 +302,7 @@ void options_read_args(int argc, char ** + break; + + case 'b': +- config_set_string("show-bars", "true"); ++ config_set_string("show-bars", "false"); + break; + + case 'B': --- iftop-0.17.orig/debian/patches/02-armeb.patch +++ iftop-0.17/debian/patches/02-armeb.patch @@ -0,0 +1,15 @@ +Author: Lennert Buytenhek +Description: Fixes armeb specific bug. + +diff -Naurp iftop.orig/ether.h iftop/ether.h +--- iftop.orig/ether.h 2008-09-07 23:53:08.000000000 +0000 ++++ iftop/ether.h 2009-01-24 22:57:23.000000000 +0000 +@@ -12,7 +12,7 @@ struct ether_header { + u_int8_t ether_dhost[ETHER_ADDR_LEN]; + u_int8_t ether_shost[ETHER_ADDR_LEN]; + u_int16_t ether_type; +-}; ++} __attribute__((packed)); + + struct vlan_8021q_header { + u_int16_t priority_cfi_vid; --- iftop-0.17.orig/debian/patches/series +++ iftop-0.17/debian/patches/series @@ -0,0 +1,6 @@ +01-manpage.patch +02-armeb.patch +03-frozen-order.patch +04-arm.patch +05-bar-display.patch +06-bar-bytes.patch --- iftop-0.17.orig/debian/patches/04-arm.patch +++ iftop-0.17/debian/patches/04-arm.patch @@ -0,0 +1,19 @@ +Author: Joey Hess +Description: Fixes crash on arm. + +diff -Naurp iftop.orig/cfgfile.c iftop/cfgfile.c +--- iftop.orig/cfgfile.c 2008-09-07 23:53:08.000000000 +0000 ++++ iftop/cfgfile.c 2009-01-24 22:58:11.000000000 +0000 +@@ -45,9 +45,9 @@ stringmap config; + extern options_t options ; + + int is_cfgdirective_valid(const char *s) { +- char **t; +- for (t = config_directives; *t != NULL; ++t) +- if (strcmp(s, *t) == 0) return 1; ++ int t; ++ for (t = 0; config_directives[t] != NULL; t++) ++ if (strcmp(s, config_directives[t]) == 0) return 1; + return 0; + } + --- iftop-0.17.orig/debian/patches/03-frozen-order.patch +++ iftop-0.17/debian/patches/03-frozen-order.patch @@ -0,0 +1,14 @@ +Author: Max Alekseyev +Description: Fix frozen order drives line totals crazy. + +diff -Naurp iftop.orig/ui.c iftop/ui.c +--- iftop.orig/ui.c 2008-09-07 23:53:08.000000000 +0000 ++++ iftop/ui.c 2009-01-24 22:57:57.000000000 +0000 +@@ -446,6 +446,7 @@ void screen_hash_clear() { + hash_node_type* n = NULL; + while(hash_next_item(screen_hash, &n) == HASH_STATUS_OK) { + host_pair_line* hpl = (host_pair_line*)n->rec; ++ hpl->total_recv = hpl->total_sent = 0; + memset(hpl->recv, 0, sizeof(hpl->recv)); + memset(hpl->sent, 0, sizeof(hpl->sent)); + } --- iftop-0.17.orig/debian/patches/06-bar-bytes.patch +++ iftop-0.17/debian/patches/06-bar-bytes.patch @@ -0,0 +1,16 @@ +Author: Marcin Kryczek +Description: + Connection rates are displayed in bytes, but the top bar is graduated in bits. + +diff -Naurp iftop.orig/ui.c iftop/ui.c +--- iftop.orig/ui.c 2008-09-08 01:53:08.000000000 +0200 ++++ iftop/ui.c 2009-01-27 17:44:50.000000000 +0100 +@@ -263,7 +263,7 @@ static void draw_bar_scale(int* y) { + char s[40], *p; + int x; + /* This 1024 vs 1000 stuff is just plain evil */ +- readable_size(i, s, sizeof s, options.log_scale ? 1000 : 1024, 0); ++ readable_size(i, s, sizeof s, options.log_scale ? 1000 : 1024, options.bandwidth_in_bytes); + p = s + strspn(s, " "); + x = get_bar_length(i * 8); + mvaddch(*y + 1, x, ACS_BTEE);