---- net-tools-1.60/netstat.c.foo Mon Apr 22 14:25:20 2002
-+++ net-tools-1.60/netstat.c Mon Apr 22 14:25:22 2002
-@@ -435,6 +435,162 @@
+diff -up net-tools-2.0/netstat.c.dup-tcp net-tools-2.0/netstat.c
+--- net-tools-2.0/netstat.c.dup-tcp 2012-10-04 11:32:01.437729086 +0200
++++ net-tools-2.0/netstat.c 2012-10-04 11:32:01.441729032 +0200
+@@ -502,6 +502,121 @@ static void prg_cache_load(void)
" will not be shown, you would have to be root to see it all.)\n"));
}
+ }
+
+ /* free the bucket itself */
++ free(tcp_node_hash[i]->socket_pair);
+ free(tcp_node_hash[i]);
+ tcp_node_hash[i] = NULL;
+ }
+
+ return 0;
+}
-+
-+#if 0
-+static void tcp_node_hash_report_bucket_size(void)
-+{
-+ int max = 0;
-+ int min = 0;
-+ int num = 0;
-+ int total = 0;
-+ struct tcp_node *tmp_node;
-+ int tmp, i;
-+ float avg;
-+
-+ for (i=0; i < TCP_HASH_SIZE; i++) {
-+ tmp_node = tcp_node_hash[i];
-+ if (!tmp_node)
-+ continue;
-+
-+ tmp = 0;
-+
-+ num++;
-+ tmp = 1;
-+
-+ while (tmp_node) {
-+ tmp++;
-+ tmp_node = tmp_node->next;
-+ }
-+
-+ total += tmp;
-+ if (tmp > max)
-+ max = tmp;
-+
-+ if (min == 0 || tmp < min)
-+ min = tmp;
-+ }
-+
-+ avg = (float)total/(float)num;
-+
-+ printf("%d nodes in %d buckets min/max/avg %d/%d/%.2f\n",
-+ total, num, min, max, avg);
-+
-+}
-+#endif
+
#if HAVE_AFNETROM
static const char *netrom_state[] =
{
-@@ -752,11 +908,20 @@
- fprintf(stderr, _("warning, got bogus tcp line.\n"));
- return;
- }
-+
- if ((ap = get_afntype(((struct sockaddr *) &localaddr)->sa_family)) == NULL) {
- fprintf(stderr, _("netstat: unsupported address family %d !\n"),
- ((struct sockaddr *) &localaddr)->sa_family);
+@@ -1018,6 +1133,12 @@ static void tcp_do_one(int lnr, const ch
return;
}
-+
+
+ /* make sure that we haven't seen this socket pair before */
-+ if (tcp_node_hash_check_and_append(local_addr, local_port,
-+ rem_addr, rem_port) < 0) {
-+ /* fprintf(stderr, _("warning, got duplicate tcp line.\n")); */
-+ return;
++ if (tcp_node_hash_check_and_append(local_addr, local_port, rem_addr, rem_port) < 0) {
++ /* fprintf(stderr, _("warning, got duplicate tcp line.\n")); */
++ return;
+ }
+
- if (state == TCP_LISTEN) {
- time_len = 0;
- retr = 0L;
-@@ -1880,6 +2045,7 @@
+ addr_do_one(local_addr, sizeof(local_addr), 22, ap, &localaddr, local_port, "tcp");
+ addr_do_one(rem_addr, sizeof(rem_addr), 22, ap, &remaddr, rem_port, "tcp");
+
+@@ -2355,6 +2476,7 @@ int main
break;
- sleep(reptimer);
+ wait_continous(reptimer);
prg_cache_clear();
+ tcp_node_hash_clear();
}