#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"
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;
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)
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)
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 *);
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);
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, \
{ \
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); \
}