Blame SOURCES/net-tools-cycle.patch

648959
diff -up net-tools-2.0/lib/interface.c.cycle net-tools-2.0/lib/interface.c
648959
--- net-tools-2.0/lib/interface.c.cycle	2016-02-15 16:54:18.000000000 +0100
648959
+++ net-tools-2.0/lib/interface.c	2016-03-30 09:58:18.247891588 +0200
648959
@@ -93,6 +93,7 @@ int if_list_all = 0;	/* do we have reque
648959
 static struct interface *int_list, *int_last;
648959
 
648959
 static int if_readlist_proc(const char *);
648959
+static int if_readlist_rep(const char *, struct interface *);
648959
 
648959
 static struct interface *if_cache_add(const char *name)
648959
 {
648959
@@ -138,11 +139,14 @@ struct interface *lookup_interface(const
648959
 int for_all_interfaces(int (*doit) (struct interface *, void *), void *cookie)
648959
 {
648959
     struct interface *ife;
648959
+    int err;
648959
 
648959
     if (!if_list_all && (if_readlist() < 0))
648959
 	return -1;
648959
     for (ife = int_list; ife; ife = ife->next) {
648959
-	int err = doit(ife, cookie);
648959
+	if_readlist_rep(ife->name, ife);
648959
+	err = doit(ife, cookie);
648959
+
648959
 	if (err)
648959
 	    return err;
648959
     }
648959
@@ -210,16 +214,24 @@ out:
648959
     return err;
648959
 }
648959
 
648959
-static const char *get_name(char *name, const char *p)
648959
+static const char *get_name(char **namep, const char *p)
648959
 {
648959
+    int count = 0;
648959
     while (isspace(*p))
648959
 	p++;
648959
+    char *name = *namep = p;
648959
     while (*p) {
648959
 	if (isspace(*p))
648959
 	    break;
648959
 	if (*p == ':') {	/* could be an alias */
648959
 		const char *dot = p++;
648959
- 		while (*p && isdigit(*p)) p++;
648959
+		count++;
648959
+		while (*p && isdigit(*p)) {
648959
+		    p++;
648959
+		    count++;
648959
+		    if (count == (IFNAMSIZ-1))
648959
+			break;
648959
+		}
648959
 		if (*p == ':') {
648959
 			/* Yes it is, backup and copy it. */
648959
 			p = dot;
648959
@@ -235,6 +247,9 @@ static const char *get_name(char *name,
648959
 	    break;
648959
 	}
648959
 	*name++ = *p++;
648959
+	count++;
648959
+	if (count == (IFNAMSIZ-1))
648959
+    	      break;
648959
     }
648959
     *name++ = '\0';
648959
     return p;
648959
@@ -316,9 +331,10 @@ static int get_dev_fields(const char *bp
648959
 static int if_readlist_proc(const char *target)
648959
 {
648959
     FILE *fh;
648959
-    char buf[512];
648959
     struct interface *ife;
648959
     int err;
648959
+    char *line = NULL;
648959
+    size_t linelen = 0;  
648959
 
648959
     fh = fopen(_PATH_PROCNET_DEV, "r");
648959
     if (!fh) {
648959
@@ -326,10 +342,11 @@ static int if_readlist_proc(const char *
648959
 			_PATH_PROCNET_DEV, strerror(errno));
648959
 		return -2;
648959
 	}
648959
-    if (fgets(buf, sizeof buf, fh))
648959
-		/* eat line */;
648959
-    if (fgets(buf, sizeof buf, fh))
648959
-		/* eat line */;
648959
+    if (getline(&line, &linelen, fh) == -1 /* eat line */
648959
+	|| getline(&line, &linelen, fh) == -1) { /* eat line */
648959
+		err = -1;
648959
+		goto out;
648959
+	}
648959
 
648959
 #if 0				/* pretty, but can't cope with missing fields */
648959
     fmt = proc_gen_fmt(_PATH_PROCNET_DEV, 1, fh,
648959
@@ -354,14 +371,14 @@ static int if_readlist_proc(const char *
648959
     if (!fmt)
648959
 	return -1;
648959
 #else
648959
-    procnetdev_vsn = procnetdev_version(buf);
648959
+    procnetdev_vsn = procnetdev_version(line);
648959
 #endif
648959
 
648959
     err = 0;
648959
-    while (fgets(buf, sizeof buf, fh)) {
648959
+    while (getline(&line, &linelen, fh) != -1) {
648959
 	const char *s;
648959
-	char name[IFNAMSIZ];
648959
-	s = get_name(name, buf);
648959
+	char *name;
648959
+	s = get_name(&name, line);    
648959
 	ife = if_cache_add(name);
648959
 	get_dev_fields(s, ife);
648959
 	ife->statistics_valid = 1;
648959
@@ -376,6 +393,51 @@ static int if_readlist_proc(const char *
648959
 #if 0
648959
     free(fmt);
648959
 #endif
648959
+  out:
648959
+    free(line);
648959
+    fclose(fh);
648959
+    return err;
648959
+}
648959
+
648959
+static int if_readlist_rep(const char *target, struct interface *ife)
648959
+{
648959
+    FILE *fh;
648959
+    int err;
648959
+    char *line = NULL;
648959
+    size_t linelen = 0;
648959
+
648959
+    fh = fopen(_PATH_PROCNET_DEV, "r");
648959
+    if (!fh) {
648959
+		fprintf(stderr, _("Warning: cannot open %s (%s). Limited output.\n"),
648959
+			_PATH_PROCNET_DEV, strerror(errno)); 
648959
+		return if_readconf();
648959
+	}
648959
+    if (getline(&line, &linelen, fh) == -1 /* eat line */
648959
+	|| getline(&line, &linelen, fh) == -1) { /* eat line */
648959
+		err = -1;
648959
+		goto out;
648959
+	}
648959
+
648959
+    procnetdev_vsn = procnetdev_version(line);
648959
+
648959
+    err = 0;
648959
+    while (getline(&line, &linelen, fh) != -1) {
648959
+	char *s, *name;
648959
+	s = get_name(&name, line);    
648959
+	get_dev_fields(s, ife);
648959
+	if (target && !strcmp(target,name))
648959
+	{
648959
+		ife->statistics_valid = 1;
648959
+		break;
648959
+	}
648959
+    }
648959
+    if (ferror(fh)) {
648959
+	perror(_PATH_PROCNET_DEV);
648959
+	err = -1;
648959
+    }
648959
+
648959
+  out:
648959
+    free(line);
648959
     fclose(fh);
648959
     return err;
648959
 }
648959
diff -up net-tools-2.0/man/en_US/netstat.8.cycle net-tools-2.0/man/en_US/netstat.8
648959
--- net-tools-2.0/man/en_US/netstat.8.cycle	2016-02-15 16:54:18.000000000 +0100
648959
+++ net-tools-2.0/man/en_US/netstat.8	2016-03-30 09:58:18.241891637 +0200
648959
@@ -36,6 +36,7 @@ netstat \- Print network connections, ro
648959
 .RB [ \-\-verbose | \-v ]
648959
 .RB [ \-\-continuous | \-c]
648959
 .RB [ \-\-wide | \-W ]
648959
+.RB [delay]
648959
 .P
648959
 .B netstat 
648959
 .RB { \-\-route | \-r }
648959
@@ -45,22 +46,25 @@ netstat \- Print network connections, ro
648959
 .RB [ \-\-numeric | \-n ]
648959
 .RB [ \-\-numeric\-hosts "] [" \-\-numeric\-ports "] [" \-\-numeric\-users ]
648959
 .RB [ \-\-continuous | \-c ]
648959
+.RB [delay]
648959
 .P
648959
 .B netstat
648959
-.RB { \-\-interfaces | \-i }
648959
+.RB { \-\-interfaces | \-I | \-i }
648959
 .RB [ \-\-all | \-a ]
648959
-.RB [ \-\-extend | \-e  [ \-\-extend | \-e] ]
648959
+.RB [ \-\-extend | \-e  ]
648959
 .RB [ \-\-verbose | \-v ]
648959
 .RB [ \-\-program | \-p ]
648959
 .RB [ \-\-numeric | \-n ]
648959
 .RB [ \-\-numeric-hosts "] [" \-\-numeric-ports "] [" \-\-numeric-users ]
648959
 .RB [ \-\-continuous | \-c ]
648959
+.RB [delay]
648959
 .P
648959
 .B netstat
648959
 .RB { \-\-groups | \-g }
648959
 .RB [ \-\-numeric | \-n ]
648959
 .RB [ \-\-numeric\-hosts "] [" \-\-numeric\-ports "] [" \-\-numeric\-users ]
648959
 .RB [ \-\-continuous | \-c ]
648959
+.RB [delay]
648959
 .P
648959
 .B netstat
648959
 .RB { \-\-masquerade | \-M }
648959
@@ -68,6 +72,7 @@ netstat \- Print network connections, ro
648959
 .RB [ \-\-numeric | \-n ]
648959
 .RB [ \-\-numeric\-hosts "] [" \-\-numeric\-ports "] [" \-\-numeric\-users ]
648959
 .RB [ \-\-continuous | \-c ]
648959
+.RB [delay]
648959
 .P
648959
 .B netstat
648959
 .RB { \-\-statistics | -s }
648959
@@ -76,6 +81,7 @@ netstat \- Print network connections, ro
648959
 .RB [ \-\-udplite | \-U ]
648959
 .RB [ \-\-sctp | \-S ]
648959
 .RB [ \-\-raw | \-w ]
648959
+.RB [delay]
648959
 .P
648959
 .B netstat 
648959
 .RB { \-\-version | \-V }
648959
@@ -128,8 +134,8 @@ and
648959
 produce the same output.
648959
 .SS "\-\-groups, \-g"
648959
 Display multicast group membership information for IPv4 and IPv6.
648959
-.SS "\-\-interfaces, \-i"
648959
-Display a table of all network interfaces.
648959
+.SS "\-\-interfaces=\fIiface \fR, \fB\-I=\fIiface \fR, \fB\-i"
648959
+Display a table of all network interfaces, or the specified \fIiface\fR.
648959
 .SS "\-\-masquerade, \-M"
648959
 Display a list of masqueraded connections.
648959
 .SS "\-\-statistics, \-s"
648959
@@ -201,13 +207,18 @@ Show the PID and name of the program to
648959
 .SS "\-l, \-\-listening"
648959
 Show only listening sockets.  (These are omitted by default.)
648959
 .SS "\-a, \-\-all"
648959
-Show both listening and non-listening sockets.  With the
648959
+Show both listening and non-listening (for TCP this means established
648959
+connections) sockets.  With the
648959
 .B \-\-interfaces
648959
 option, show interfaces that are not up
648959
 .SS "\-F"
648959
 Print routing information from the FIB.  (This is the default.)
648959
 .SS "\-C"
648959
 Print routing information from the route cache.
648959
+.SS delay
648959
+Netstat will cycle printing through statistics every 
648959
+.B delay 
648959
+seconds.
648959
 .P
648959
 .SH OUTPUT
648959
 .P
648959
diff -up net-tools-2.0/netstat.c.cycle net-tools-2.0/netstat.c
648959
--- net-tools-2.0/netstat.c.cycle	2016-02-15 16:54:18.000000000 +0100
648959
+++ net-tools-2.0/netstat.c	2016-03-30 10:04:07.617171984 +0200
648959
@@ -115,8 +115,8 @@
648959
 #endif
648959
 
648959
 /* prototypes for statistics.c */
648959
-void parsesnmp(int, int, int, int);
648959
-void parsesnmp6(int, int, int);
648959
+int parsesnmp(int, int, int, int);
648959
+int parsesnmp6(int, int, int);
648959
 
648959
 typedef enum {
648959
     SS_FREE = 0,		/* not allocated                */
648959
@@ -142,6 +142,7 @@ static char *Release = RELEASE, *Signatu
648959
 #define E_IOCTL -3
648959
 
648959
 int flag_int = 0;
648959
+char *flag_int_name = NULL;
648959
 int flag_rou = 0;
648959
 int flag_mas = 0;
648959
 int flag_sta = 0;
648959
@@ -340,10 +341,10 @@ static void prg_cache_clear(void)
648959
     prg_cache_loaded = 0;
648959
 }
648959
 
648959
-static void wait_continous(void)
648959
+static void wait_continous(int reptimer)
648959
 {
648959
     fflush(stdout);
648959
-    sleep(1);
648959
+    sleep(reptimer);
648959
 }
648959
 
648959
 static int extract_type_1_socket_inode(const char lname[], unsigned long * inode_p) {
648959
@@ -501,6 +502,121 @@ static void prg_cache_load(void)
648959
 			 " will not be shown, you would have to be root to see it all.)\n"));
648959
 }
648959
 
648959
+#define TCP_HASH_SIZE 1009
648959
+
648959
+static struct tcp_node {
648959
+  struct tcp_node *next;
648959
+  char            *socket_pair;
648959
+} *tcp_node_hash[TCP_HASH_SIZE];
648959
+
648959
+static unsigned int tcp_node_compute_string_hash(const char *p)
648959
+{
648959
+  unsigned int h = *p;
648959
+
648959
+  if (h)
648959
+    for (p += 1; *p != '\0'; p++)
648959
+      h = (h << 5) - h + *p;
648959
+
648959
+  return h;
648959
+}
648959
+
648959
+#define TCP_NODE_HASH_STRING(x) \
648959
+  (tcp_node_compute_string_hash(x) % TCP_HASH_SIZE)
648959
+
648959
+static void tcp_node_hash_clear(void)
648959
+{
648959
+  int i;
648959
+  struct tcp_node *next_node;
648959
+  struct tcp_node *tmp_node;
648959
+  for (i=0; i < TCP_HASH_SIZE; i++) {
648959
+    if (tcp_node_hash[i]) {
648959
+      /* free the children of this hash bucket */
648959
+      next_node = tcp_node_hash[i]->next;
648959
+      while (next_node) {
648959
+	tmp_node = next_node;
648959
+	next_node = next_node->next;
648959
+	free(tmp_node->socket_pair);
648959
+	free(tmp_node);
648959
+      }
648959
+
648959
+      /* free the bucket itself */
648959
+      free(tcp_node_hash[i]->socket_pair);
648959
+      free(tcp_node_hash[i]);
648959
+      tcp_node_hash[i] = NULL;
648959
+    }
648959
+  }
648959
+}
648959
+
648959
+/* This function takes a socket pair string.  If it already exists in
648959
+   the hash it returns -1, otherwise it returns 0. */
648959
+
648959
+static int tcp_node_hash_check_and_append(const char *local_addr,
648959
+					  int local_port,
648959
+					  const char *rem_addr,
648959
+					  int rem_port)
648959
+{
648959
+  unsigned int hash_val;
648959
+  struct tcp_node *tmp_node;
648959
+  int   tmp_string_len;
648959
+  char *tmp_string;;
648959
+
648959
+  /* Size of the string is the size of the two lengths of the address
648959
+     strings plus enough sizes for the colons and the ports. */
648959
+  tmp_string_len = strlen(local_addr) + strlen(rem_addr) + 32;
648959
+  tmp_string = malloc(tmp_string_len);
648959
+  if (!tmp_string)
648959
+    return 0;
648959
+
648959
+  if (snprintf(tmp_string, tmp_string_len - 1, "%s:%d:%s:%d",
648959
+	       local_addr, local_port, rem_addr, rem_port) < 0) {
648959
+    free(tmp_string);
648959
+    return 0;
648959
+  }
648959
+
648959
+  hash_val = TCP_NODE_HASH_STRING(tmp_string);
648959
+
648959
+  /* See if we have to allocate this node */
648959
+  if (!tcp_node_hash[hash_val]) {
648959
+    tcp_node_hash[hash_val] = malloc(sizeof(struct tcp_node));
648959
+    if (!tcp_node_hash[hash_val]) {
648959
+      free(tmp_string);
648959
+      return 0;
648959
+    }
648959
+
648959
+    memset(tcp_node_hash[hash_val], 0, sizeof(struct tcp_node));
648959
+
648959
+    /* Stuff this new value into the hash bucket and return early */
648959
+    tcp_node_hash[hash_val]->socket_pair = tmp_string;
648959
+    return 0;
648959
+  }
648959
+
648959
+  /* Try to find the value in the hash bucket. */
648959
+  tmp_node = tcp_node_hash[hash_val];
648959
+  while (tmp_node) {
648959
+    if (!strcmp(tmp_node->socket_pair, tmp_string)) {
648959
+      free(tmp_string);
648959
+      return -1;
648959
+    }
648959
+    tmp_node = tmp_node->next;
648959
+  }
648959
+
648959
+  /* If we got this far it means that it isn't in the hash bucket.
648959
+     Add it to the front since it's faster that way. */
648959
+  tmp_node = tcp_node_hash[hash_val];
648959
+
648959
+  tcp_node_hash[hash_val] = malloc(sizeof(struct tcp_node));
648959
+  if (!tcp_node_hash[hash_val]) {
648959
+    free(tmp_string);
648959
+    tcp_node_hash[hash_val] = tmp_node;
648959
+    return 0;
648959
+  }
648959
+
648959
+  tcp_node_hash[hash_val]->socket_pair = tmp_string;
648959
+  tcp_node_hash[hash_val]->next = tmp_node;
648959
+
648959
+  return 0;
648959
+}
648959
+
648959
 #if HAVE_AFNETROM
648959
 static const char *netrom_state[] =
648959
 {
648959
@@ -1109,6 +1225,12 @@ static void tcp_do_one(int lnr, const ch
648959
 	return;
648959
     }
648959
 
648959
+    /* make sure that we haven't seen this socket pair before */
648959
+    if (tcp_node_hash_check_and_append(local_addr, local_port, rem_addr, rem_port) < 0) {
648959
+    	/*  fprintf(stderr, _("warning, got duplicate tcp line.\n")); */
648959
+    	return;
648959
+    }
648959
+
648959
 	addr_do_one(local_addr, sizeof(local_addr), 22, ap, &localsas, local_port, "tcp");
648959
 	addr_do_one(rem_addr, sizeof(rem_addr), 22, ap, &remsas, rem_port, "tcp");
648959
 
648959
@@ -1877,6 +1999,9 @@ static int rfcomm_info(void)
648959
 
648959
 static int iface_info(void)
648959
 {
648959
+    static int count=0;
648959
+    struct interface *ife = NULL;
648959
+
648959
     if (skfd < 0) {
648959
 	if ((skfd = sockets_open(0)) < 0) {
648959
 	    perror("socket");
648959
@@ -1886,20 +2011,25 @@ static int iface_info(void)
648959
     }
648959
     if (flag_exp < 2) {
648959
 	ife_short = 1;
648959
-	printf(_("Iface      MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg\n"));
648959
+	if(!(count % 8))
648959
+	    printf(_("Iface      MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg\n"));
648959
     }
648959
 
648959
-    if (for_all_interfaces(do_if_print, &flag_all) < 0) {
648959
+    if (flag_int_name) {
648959
+        ife = lookup_interface(flag_int_name);
648959
+        do_if_print(ife, &flag_all);
648959
+    }
648959
+    else if (for_all_interfaces(do_if_print, &flag_all) < 0) {
648959
 	perror(_("missing interface information"));
648959
 	exit(1);
648959
     }
648959
-    if (flag_cnt)
648959
+    if (!flag_cnt) {
648959
 	if_cache_free();
648959
-    else {
648959
 	close(skfd);
648959
 	skfd = -1;
648959
     }
648959
 
648959
+    count++;
648959
     return 0;
648959
 }
648959
 
648959
@@ -1915,9 +2045,10 @@ static void usage(int rc)
648959
 {
648959
     fprintf(stderr, _("usage: netstat [-vWeenNcCF] [<Af>] -r         netstat {-V|--version|-h|--help}\n"));
648959
     fprintf(stderr, _("       netstat [-vWnNcaeol] [<Socket> ...]\n"));
648959
-    fprintf(stderr, _("       netstat { [-vWeenNac] -i | [-cnNe] -M | -s [-6tuw] }\n\n"));
648959
+    fprintf(stderr, _("       netstat { [-vWeenNac] -I[<Iface>] | [-veenNac] -i | [-cnNe] -M | -s [-6tuw] } [delay]\n\n"));
648959
 
648959
     fprintf(stderr, _("        -r, --route              display routing table\n"));
648959
+    fprintf(stderr, _("        -I, --interfaces=<Iface> display interface table for <Iface>\n"));
648959
     fprintf(stderr, _("        -i, --interfaces         display interface table\n"));
648959
     fprintf(stderr, _("        -g, --groups             display multicast group memberships\n"));
648959
     fprintf(stderr, _("        -s, --statistics         display networking statistics (like SNMP)\n"));
648959
@@ -1957,11 +2088,12 @@ int main
648959
  (int argc, char *argv[]) {
648959
     int i;
648959
     int lop;
648959
+    int reptimer = 1;
648959
     static struct option longopts[] =
648959
     {
648959
 	AFTRANS_OPTS,
648959
 	{"version", 0, 0, 'V'},
648959
-	{"interfaces", 0, 0, 'i'},
648959
+	{"interfaces", 2, 0, 'I'},
648959
 	{"help", 0, 0, 'h'},
648959
 	{"route", 0, 0, 'r'},
648959
 #if HAVE_FW_MASQUERADE
648959
@@ -2005,7 +2137,7 @@ int main
648959
     getroute_init();		/* Set up AF routing support */
648959
 
648959
     afname[0] = '\0';
648959
-    while ((i = getopt_long(argc, argv, "A:CFMacdeghilnNoprsStuUvVWw2fx64?Z", longopts, &lop)) != EOF)
648959
+    while ((i = getopt_long(argc, argv, "A:CFMacdeghiI::lnNoprsStuUvVWw2fx64?Z", longopts, &lop)) != EOF)
648959
 	switch (i) {
648959
 	case -1:
648959
 	    break;
648959
@@ -2046,6 +2178,13 @@ int main
648959
 	case 'p':
648959
 	    flag_prg++;
648959
 	    break;
648959
+	case 'I':
648959
+	    if (optarg && strcmp(optarg, "(null)"))
648959
+		if (optarg[0] == '=') optarg++;
648959
+	    if (optarg && strcmp(optarg, "(null)"))
648959
+		flag_int_name = strdup(optarg);
648959
+	    flag_int++;
648959
+	    break;
648959
 	case 'i':
648959
 	    flag_int++;
648959
 	    break;
648959
@@ -2140,6 +2279,12 @@ int main
648959
 	    flag_sta++;
648959
 	}
648959
 
648959
+    if(argc == optind + 1) {
648959
+    	if((reptimer = atoi(argv[optind])) <= 0)
648959
+    		usage(E_USAGE);
648959
+        flag_cnt++;
648959
+    }
648959
+
648959
     if (flag_int + flag_rou + flag_mas + flag_sta > 1)
648959
 	usage(E_OPTERR);
648959
 
648959
@@ -2169,7 +2314,7 @@ int main
648959
 			     flag_not & FLAG_NUM_PORT, flag_exp);
648959
 	    if (i || !flag_cnt)
648959
 		break;
648959
-	    wait_continous();
648959
+	    wait_continous(reptimer);
648959
 	}
648959
 #else
648959
 	ENOSUPP("netstat", "FW_MASQUERADE");
648959
@@ -2182,15 +2327,16 @@ int main
648959
         if (!afname[0])
648959
             safe_strncpy(afname, DFLT_AF, sizeof(afname));
648959
 
648959
+        for (;;) {
648959
         if (!strcmp(afname, "inet")) {
648959
 #if HAVE_AFINET
648959
-            parsesnmp(flag_raw, flag_tcp, flag_udp, flag_sctp);
648959
+            i = parsesnmp(flag_raw, flag_tcp, flag_udp, flag_sctp);
648959
 #else
648959
             ENOSUPP("netstat", "AF INET");
648959
 #endif
648959
         } else if(!strcmp(afname, "inet6")) {
648959
 #if HAVE_AFINET6
648959
-            parsesnmp6(flag_raw, flag_tcp, flag_udp);
648959
+            i = parsesnmp6(flag_raw, flag_tcp, flag_udp);
648959
 #else
648959
             ENOSUPP("netstat", "AF INET6");
648959
 #endif
648959
@@ -2198,7 +2344,11 @@ int main
648959
           printf(_("netstat: No statistics support for specified address family: %s\n"), afname);
648959
           exit(1);
648959
         }
648959
-        exit(0);
648959
+	if(i || !flag_cnt)
648959
+	  break;
648959
+	sleep(reptimer);
648959
+        }
648959
+        return (i);
648959
     }
648959
 
648959
     if (flag_rou) {
648959
@@ -2220,7 +2370,7 @@ int main
648959
 	    i = route_info(afname, options);
648959
 	    if (i || !flag_cnt)
648959
 		break;
648959
-            wait_continous();
648959
+            wait_continous(reptimer);
648959
 	}
648959
 	return (i);
648959
     }
648959
@@ -2229,7 +2379,7 @@ int main
648959
 	    i = iface_info();
648959
 	    if (!flag_cnt || i)
648959
 		break;
648959
-            wait_continous();
648959
+            wait_continous(reptimer);
648959
 	}
648959
 	return (i);
648959
     }
648959
@@ -2416,8 +2566,9 @@ int main
648959
 
648959
 	if (!flag_cnt || i)
648959
 	    break;
648959
-        wait_continous();
648959
+        wait_continous(reptimer);
648959
 	prg_cache_clear();
648959
+	tcp_node_hash_clear();
648959
     }
648959
     return (i);
648959
 }
648959
diff -up net-tools-2.0/statistics.c.cycle net-tools-2.0/statistics.c
648959
--- net-tools-2.0/statistics.c.cycle	2016-02-15 16:54:18.000000000 +0100
648959
+++ net-tools-2.0/statistics.c	2016-03-30 09:58:18.238891661 +0200
648959
@@ -527,7 +527,7 @@ static void process_fd2(FILE *f, const c
648959
     }
648959
 }
648959
 
648959
-void parsesnmp(int flag_raw, int flag_tcp, int flag_udp, int flag_sctp)
648959
+int parsesnmp(int flag_raw, int flag_tcp, int flag_udp, int flag_sctp)
648959
 {
648959
     FILE *f;
648959
 
648959
@@ -536,14 +536,17 @@ void parsesnmp(int flag_raw, int flag_tc
648959
     f = proc_fopen("/proc/net/snmp");
648959
     if (!f) {
648959
 	perror(_("cannot open /proc/net/snmp"));
648959
-	return;
648959
+	return(1);
648959
     }
648959
 
648959
     if (process_fd(f, 1, NULL) < 0)
648959
       fprintf(stderr, _("Problem while parsing /proc/net/snmp\n"));
648959
 
648959
-    if (ferror(f))
648959
+    if (ferror(f)) {
648959
 	perror("/proc/net/snmp");
648959
+	fclose(f);
648959
+	return(1);
648959
+    }
648959
 
648959
     fclose(f);
648959
 
648959
@@ -553,8 +556,11 @@ void parsesnmp(int flag_raw, int flag_tc
648959
     	if (process_fd(f, 1, NULL) <0)
648959
           fprintf(stderr, _("Problem while parsing /proc/net/netstat\n"));
648959
 
648959
-        if (ferror(f))
648959
-	    perror("/proc/net/netstat");
648959
+        if (ferror(f)) {
648959
+	  perror("/proc/net/netstat");
648959
+	  fclose(f);
648959
+	  return(1);
648959
+        }
648959
 
648959
         fclose(f);
648959
     }
648959
@@ -567,9 +573,10 @@ void parsesnmp(int flag_raw, int flag_tc
648959
 	    fclose(f);
648959
 	}
648959
     }
648959
+    return(0);
648959
 }
648959
 
648959
-void parsesnmp6(int flag_raw, int flag_tcp, int flag_udp)
648959
+int parsesnmp6(int flag_raw, int flag_tcp, int flag_udp)
648959
 {
648959
     FILE *f;
648959
 
648959
@@ -578,7 +585,7 @@ void parsesnmp6(int flag_raw, int flag_t
648959
     f = fopen("/proc/net/snmp6", "r");
648959
     if (!f) {
648959
         perror(_("cannot open /proc/net/snmp6"));
648959
-        return;
648959
+        return(1);
648959
     }
648959
     process6_fd(f);
648959
     if (ferror(f))
648959
@@ -588,11 +595,14 @@ void parsesnmp6(int flag_raw, int flag_t
648959
     f = fopen("/proc/net/snmp", "r");
648959
     if (!f) {
648959
         perror(_("cannot open /proc/net/snmp"));
648959
-        return;
648959
+        return(1);
648959
     }
648959
     process_fd(f, 0, "Tcp");
648959
-    if (ferror(f))
648959
+    if (ferror(f)) {
648959
         perror("/proc/net/snmp");
648959
+        return(1);
648959
+    }
648959
 
648959
     fclose(f);
648959
+    return(0);
648959
 }