Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Feb 2010 16:39:28 +0000 (UTC)
From:      Luigi Rizzo <luigi@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r204323 - user/luigi/ipfw3-head/sys/netinet/ipfw
Message-ID:  <201002251639.o1PGdSkp076129@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: luigi
Date: Thu Feb 25 16:39:28 2010
New Revision: 204323
URL: http://svn.freebsd.org/changeset/base/204323

Log:
  add function dn_ht_scan_bucket()

Modified:
  user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c

Modified: user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c
==============================================================================
--- user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c	Thu Feb 25 16:14:07 2010	(r204322)
+++ user/luigi/ipfw3-head/sys/netinet/ipfw/dn_heap.c	Thu Feb 25 16:39:28 2010	(r204323)
@@ -471,3 +471,39 @@ dn_ht_scan(struct dn_ht *ht, int (*fn)(v
 	}
 	return found;
 }
+
+/*
+ * Similar to dn_ht_scan(), except thah the scan is performed only
+ * in the bucket 'bucket'. The function returns a correct bucket number if
+ * the original is invalid
+ */
+int
+dn_ht_scan_bucket(struct dn_ht *ht, int *bucket, int (*fn)(void *, void *),
+		 void *arg)
+{
+	int i, ret, found = 0;
+	void **curp, *cur, *next;
+
+	if (ht == NULL || fn == NULL)
+		return 0;
+	if (*bucket >= ht->buckets)
+		*bucket = 0;
+	i = *bucket;
+
+	curp = &ht->ht[i];
+	while ( (cur = *curp) != NULL) {
+		next = *(void **)((char *)cur + ht->ofs);
+		ret = fn(cur, arg);
+		if (ret & DNHT_SCAN_DEL) {
+			found++;
+			ht->entries--;
+			*curp = next;
+		} else {
+			curp = (void **)((char *)cur + ht->ofs);
+		}
+		if (ret & DNHT_SCAN_END)
+			return found;
+	}
+	return found;
+}
+



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201002251639.o1PGdSkp076129>