]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Add hash_foreach, et al.
authorTed Lemon <source@isc.org>
Tue, 6 Jun 2000 23:46:37 +0000 (23:46 +0000)
committerTed Lemon <source@isc.org>
Tue, 6 Jun 2000 23:46:37 +0000 (23:46 +0000)
common/hash.c
includes/dhcpd.h
includes/hash.h

index 9f3bf7063d4be51eca800f51695836ed3a10d568..0588a150e1131415d84f93d30ba6052f51a07fed 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: hash.c,v 1.23 2000/05/17 16:15:38 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: hash.c,v 1.24 2000/06/06 23:46:31 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -229,6 +229,27 @@ int hash_lookup (vp, table, name, len, file, line)
        return 0;
 }
 
+int hash_foreach (struct hash_table *table, hash_foreach_func func)
+{
+       int i;
+       struct hash_bucket *bp, *next;
+       int count = 0;
+
+       if (!table)
+               return 0;
+
+       for (i = 0; i < table -> hash_count; i++) {
+               bp = table -> buckets [i];
+               while (bp) {
+                       next = bp -> next;
+                       (*func) (bp -> name, bp -> len, bp -> value);
+                       bp = next;
+                       count++;
+               }
+       }
+       return count;
+}
+
 int casecmp (const void *v1, const void *v2, unsigned long len)
 {
        unsigned i;
index e0f821f00ef116142aa84dbadcb93fa6294ef8e9..5eab482595c5ab89984026c380141233e68e7e6a 100644 (file)
@@ -1521,6 +1521,7 @@ void delete_hash_entry PROTO ((struct hash_table *, const unsigned char *,
                               unsigned, const char *, int));
 int hash_lookup PROTO ((hashed_object_t **, struct hash_table *,
                        const unsigned char *, unsigned, const char *, int));
+int hash_foreach (struct hash_table *, hash_foreach_func);
 int casecmp (const void *s, const void *t, unsigned long len);
 HASH_FUNCTIONS_DECL (group, const char *, struct group_object)
 HASH_FUNCTIONS_DECL (universe, const char *, struct universe)
@@ -2133,6 +2134,8 @@ void uid_hash_delete PROTO ((struct lease *));
 void hw_hash_add PROTO ((struct lease *));
 void hw_hash_delete PROTO ((struct lease *));
 void write_leases PROTO ((void));
+int lease_enqueue (struct lease *);
+void lease_instantiate (const unsigned char *, unsigned, struct lease *);
 void expire_all_pools PROTO ((void));
 void dump_subnets PROTO ((void));
 HASH_FUNCTIONS_DECL (lease, const unsigned char *, struct lease)
@@ -2205,6 +2208,8 @@ isc_result_t dhcp_failover_set_state (dhcp_failover_state_t *,
 int dhcp_failover_pool_rebalance (dhcp_failover_state_t *);
 int dhcp_failover_pool_check (struct pool *);
 int dhcp_failover_state_pool_check (dhcp_failover_state_t *);
+void dhcp_failover_timeout (void *);
+void dhcp_failover_send_contact (void *);
 isc_result_t dhcp_failover_send_updates (dhcp_failover_state_t *);
 int dhcp_failover_queue_update (struct lease *, int);
 void dhcp_failover_ack_queue_remove (dhcp_failover_state_t *, struct lease *);
index 0e5b593a27f91fd103ba8dd2951b02cf66b42bfc..bd6a2b3258f17d7be50d111680d0761824ca77ca 100644 (file)
@@ -48,6 +48,8 @@ typedef struct {
        int foo;
 } hashed_object_t;
 
+typedef void (*hash_foreach_func) (const unsigned char *,
+                                  unsigned, hashed_object_t *);
 typedef int (*hash_reference) (hashed_object_t **, hashed_object_t *,
                               const char *, int);
 typedef int (*hash_dereference) (hashed_object_t **, const char *, int);
@@ -82,7 +84,10 @@ void name##_hash_add (struct hash_table *, bufarg, unsigned, type *,       \
 void name##_hash_delete (struct hash_table *, bufarg, unsigned,                      \
                         const char *, int);                                  \
 int name##_hash_lookup (type **, struct hash_table *, bufarg, unsigned,              \
-                       const char *, int);
+                       const char *, int);                                   \
+int name##_hash_foreach (struct hash_table *,                                \
+                        void (*) (bufarg, unsigned, type *));
+
 
 #define HASH_FUNCTIONS(name, bufarg, type)                                   \
 void name##_hash_add (struct hash_table *table,                                      \
@@ -106,6 +111,12 @@ int name##_hash_lookup (type **ptr, struct hash_table *table,                    \
 {                                                                            \
        return hash_lookup ((hashed_object_t **)ptr, table,                   \
                            (const unsigned char *)buf, len, file, line);     \
+}                                                                            \
+                                                                             \
+int name##_hash_foreach (struct hash_table *table,                           \
+                        void (*func) (bufarg, unsigned, type *))             \
+{                                                                            \
+       return hash_foreach (table, (hash_foreach_func)func);                 \
 }