summaryrefslogtreecommitdiff
path: root/sys/net80211/ieee80211_node.c
diff options
context:
space:
mode:
authorDamien Bergamini <damien@cvs.openbsd.org>2009-01-28 17:15:22 +0000
committerDamien Bergamini <damien@cvs.openbsd.org>2009-01-28 17:15:22 +0000
commitfb3f10120ee99ec591063a1f25fb79f32c78cd01 (patch)
tree89bcc42e091bf850fefc0d233bcda89e47530023 /sys/net80211/ieee80211_node.c
parent6b2c2b39f1604a9e6733df499ad0a07c98092f82 (diff)
In ieee80211_find_node(), roll our own RB_FIND() based on the key (macaddr)
instead of resorting to horrid hacks/casts. Restore the ieee80211_node structure back to its original state.
Diffstat (limited to 'sys/net80211/ieee80211_node.c')
-rw-r--r--sys/net80211/ieee80211_node.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/sys/net80211/ieee80211_node.c b/sys/net80211/ieee80211_node.c
index ff6ff062f7e..e034fd6e730 100644
--- a/sys/net80211/ieee80211_node.c
+++ b/sys/net80211/ieee80211_node.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ieee80211_node.c,v 1.52 2009/01/27 17:02:29 damien Exp $ */
+/* $OpenBSD: ieee80211_node.c,v 1.53 2009/01/28 17:15:21 damien Exp $ */
/* $NetBSD: ieee80211_node.c,v 1.14 2004/05/09 09:18:47 dyoung Exp $ */
/*-
@@ -812,9 +812,21 @@ ieee80211_dup_bss(struct ieee80211com *ic, const u_int8_t *macaddr)
struct ieee80211_node *
ieee80211_find_node(struct ieee80211com *ic, const u_int8_t *macaddr)
{
- /* XXX ugly, but avoids a full node structure in the stack */
- return (RB_FIND(ieee80211_tree, &ic->ic_tree,
- (struct ieee80211_node *)macaddr));
+ struct ieee80211_node *ni;
+ int cmp;
+
+ /* similar to RB_FIND except we compare keys, not nodes */
+ ni = RB_ROOT(&ic->ic_tree);
+ while (ni != NULL) {
+ cmp = memcmp(macaddr, ni->ni_macaddr, IEEE80211_ADDR_LEN);
+ if (cmp < 0)
+ ni = RB_LEFT(ni, ni_node);
+ else if (cmp > 0)
+ ni = RB_RIGHT(ni, ni_node);
+ else
+ break;
+ }
+ return ni;
}
/*