From a776f4addec4b7d5a759fc78fa824738caea8a9d Mon Sep 17 00:00:00 2001 From: Reyk Floeter Date: Fri, 9 Sep 2005 13:21:14 +0000 Subject: replace hasch tables with red-black trees used by the node tables. ok mcbride@ --- usr.sbin/hostapd/hostapd.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'usr.sbin/hostapd/hostapd.h') diff --git a/usr.sbin/hostapd/hostapd.h b/usr.sbin/hostapd/hostapd.h index a5ff7fdf8cc..95b88d9c4ae 100644 --- a/usr.sbin/hostapd/hostapd.h +++ b/usr.sbin/hostapd/hostapd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: hostapd.h,v 1.5 2005/07/30 17:18:24 reyk Exp $ */ +/* $OpenBSD: hostapd.h,v 1.6 2005/09/09 13:21:13 reyk Exp $ */ /* * Copyright (c) 2004, 2005 Reyk Floeter @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -136,6 +137,7 @@ struct hostapd_entry { struct in_addr a_ipv4; } e_addr; + RB_ENTRY(hostapd_entry) e_nodes; TAILQ_ENTRY(hostapd_entry) e_entries; }; @@ -143,10 +145,8 @@ struct hostapd_entry { #define e_ipv4 e_addr.a_ipv4 #define HOSTAPD_TABLE_NAMELEN 32 -#define HOSTAPD_TABLE_HASHSIZE 256 -#define HOSTAPD_TABLE_HASH(_a) ((((( \ - (0 ^ (_a)[0]) ^ (_a)[1]) ^ (_a)[2]) ^ (_a)[3]) ^ (_a)[4]) ^ (_a)[5] \ -) + +RB_HEAD(hostapd_tree, hostapd_entry); struct hostapd_table { char t_name[HOSTAPD_TABLE_NAMELEN]; @@ -154,7 +154,7 @@ struct hostapd_table { #define HOSTAPD_TABLE_F_CONST 0x01 - TAILQ_HEAD(, hostapd_entry) t_head[HOSTAPD_TABLE_HASHSIZE]; + struct hostapd_tree t_tree; TAILQ_HEAD(, hostapd_entry) t_mask_head; TAILQ_ENTRY(hostapd_table) t_entries; }; @@ -341,6 +341,9 @@ struct hostapd_entry *hostapd_entry_lookup(struct hostapd_table *, u_int8_t *); void hostapd_entry_update(struct hostapd_table *, struct hostapd_entry *); +int hostapd_entry_cmp(struct hostapd_entry *, struct hostapd_entry *); + +RB_PROTOTYPE(hostapd_tree, hostapd_entry, e_nodes, hostapd_entry_cmp); int hostapd_parse_file(struct hostapd_config *); int hostapd_parse_symset(char *); -- cgit v1.2.3