]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Moved hash.c from libdhcp to libomapi, in anticipation of moving the
authorDamien Neil <source@isc.org>
Tue, 1 Aug 2000 22:55:07 +0000 (22:55 +0000)
committerDamien Neil <source@isc.org>
Tue, 1 Aug 2000 22:55:07 +0000 (22:55 +0000)
tsig_key structure into libomapi.  (tsig_keys are stored in a hashtable,
and libomapi should not depend on libdhcp.)

common/Makefile.dist
common/alloc.c
common/tables.c
includes/dhcpd.h
includes/omapip/hash.h [moved from includes/hash.h with 83% similarity]
includes/omapip/omapip_p.h
omapip/Makefile.dist
omapip/hash.c [moved from common/hash.c with 82% similarity]

index 0f49a801d7b00421f3c5d6996de03e00cc0b95d1..c3f287ebb98f53e1993d895cd75eeccc30f8ed97 100644 (file)
@@ -21,11 +21,11 @@ CATMANPAGES = dhcp-options.cat5 dhcp-contrib.cat5 dhcp-eval.cat5
 SEDMANPAGES = dhcp-options.man5 dhcp-contrib.man5 dhcp-eval.man5
 SRC    = raw.c parse.c nit.c icmp.c dispatch.c conflex.c upf.c bpf.c socket.c \
         lpf.c dlpi.c packet.c tr.c ethernet.c memory.c print.c options.c \
-        inet.c tree.c tables.c hash.c alloc.c fddi.c \
+        inet.c tree.c tables.c alloc.c fddi.c \
         inet_addr.c dns.c resolv.c execute.c discover.c comapi.c
 OBJ    = raw.o parse.o nit.o icmp.o dispatch.o conflex.o upf.o bpf.o socket.o \
         lpf.o dlpi.o packet.o tr.o ethernet.o memory.o print.o options.o \
-        inet.o tree.o tables.o hash.o alloc.o fddi.o \
+        inet.o tree.o tables.o alloc.o fddi.o \
         inet_addr.o dns.o resolv.o execute.o discover.o comapi.o
 MAN    = dhcp-options.5 dhcp-contrib.5 dhcp-eval.5
 
index 0b897de54384fc68b8e136e1680a60fe66a65d1f..7cb83e1984f38659ccbe700cde31a2753a2fef8d 100644 (file)
@@ -43,7 +43,7 @@
 
 #ifndef lint
 static char copyright[] =
-"$Id: alloc.c,v 1.50 2000/08/01 21:54:01 neild Exp $ Copyright (c) 1996-2000 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: alloc.c,v 1.51 2000/08/01 22:54:47 neild Exp $ Copyright (c) 1996-2000 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
@@ -177,54 +177,6 @@ struct dhcp_packet *new_dhcp_packet (file, line)
        return rval;
 }
 
-struct hash_table *new_hash_table (count, file, line)
-       int count;
-       const char *file;
-       int line;
-{
-       struct hash_table *rval = dmalloc (sizeof (struct hash_table)
-                                          - (DEFAULT_HASH_SIZE
-                                             * sizeof (struct hash_bucket *))
-                                          + (count
-                                             * sizeof (struct hash_bucket *)),
-                                          file, line);
-       rval -> hash_count = count;
-       return rval;
-}
-
-struct hash_bucket *free_hash_buckets;
-
-struct hash_bucket *new_hash_bucket (file, line)
-       const char *file;
-       int line;
-{
-       struct hash_bucket *rval;
-       int i;
-       if (!free_hash_buckets) {
-               rval = dmalloc (127 * sizeof (struct hash_bucket),
-                               file, line);
-               if (!rval)
-                       return rval;
-               for (i = 0; i < 127; i++) {
-                       rval -> next = free_hash_buckets;
-                       free_hash_buckets = rval;
-                       rval++;
-               }
-       }
-       rval = free_hash_buckets;
-       free_hash_buckets = rval -> next;
-       return rval;
-}
-
-void free_hash_bucket (ptr, file, line)
-       struct hash_bucket *ptr;
-       const char *file;
-       int line;
-{
-       ptr -> next = free_hash_buckets;
-       free_hash_buckets = ptr;
-}
-
 struct protocol *new_protocol (file, line)
        const char *file;
        int line;
@@ -316,14 +268,6 @@ void free_protocol (ptr, file, line)
        dfree ((VOIDPTR)ptr, file, line);
 }
 
-void free_hash_table (ptr, file, line)
-       struct hash_table *ptr;
-       const char *file;
-       int line;
-{
-       dfree ((VOIDPTR)ptr, file, line);
-}
-
 void free_dhcp_packet (ptr, file, line)
        struct dhcp_packet *ptr;
        const char *file;
index de851ac5cf0f407399ce51ae3925249c97613ec5..e7832703633825c5058b63c06186ad238c459196 100644 (file)
 
 #ifndef lint
 static char copyright[] =
-"$Id: tables.c,v 1.42 2000/05/16 23:02:30 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: tables.c,v 1.43 2000/08/01 22:54:50 neild Exp $ Copyright (c) 1995-2000 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
 #include "dhcpd.h"
 
+/* XXXDPN: Moved here from hash.c, when it moved to libomapi.  Not sure
+   where these really belong. */
+HASH_FUNCTIONS (group, const char *, struct group_object)
+HASH_FUNCTIONS (universe, const char *, struct universe)
+HASH_FUNCTIONS (option, const char *, struct option)
+
 /* DHCP Option names, formats and codes, from RFC1533.
 
    Format codes:
index 444390830b4a99b0ff2e6a7226c31921a6a1e438..f42307ec77311ff675bbd6f2f7246a9bbe00a0e9 100644 (file)
@@ -73,7 +73,6 @@
 #include "dhcp.h"
 #include "statement.h"
 #include "tree.h"
-#include "hash.h"
 #include "inet.h"
 #include "auth.h"
 #include "dhctoken.h"
@@ -1211,8 +1210,6 @@ int group_allocate (struct group **, const char *, int);
 int group_reference (struct group **, struct group *, const char *, int);
 int group_dereference (struct group **, const char *, int);
 struct dhcp_packet *new_dhcp_packet PROTO ((const char *, int));
-struct hash_table *new_hash_table PROTO ((int, const char *, int));
-struct hash_bucket *new_hash_bucket PROTO ((const char *, int));
 struct protocol *new_protocol PROTO ((const char *, int));
 struct lease_state *new_lease_state PROTO ((const char *, int));
 struct domain_search_list *new_domain_search_list PROTO ((const char *, int));
@@ -1229,8 +1226,6 @@ void free_domain_search_list PROTO ((struct domain_search_list *,
                                     const char *, int));
 void free_lease_state PROTO ((struct lease_state *, const char *, int));
 void free_protocol PROTO ((struct protocol *, const char *, int));
-void free_hash_bucket PROTO ((struct hash_bucket *, const char *, int));
-void free_hash_table PROTO ((struct hash_table *, const char *, int));
 void free_dhcp_packet PROTO ((struct dhcp_packet *, const char *, int));
 struct client_lease *new_client_lease PROTO ((const char *, int));
 void free_client_lease PROTO ((struct client_lease *, const char *, int));
@@ -1534,21 +1529,6 @@ void remove_protocol PROTO ((struct protocol *));
 OMAPI_OBJECT_ALLOC_DECL (interface,
                         struct interface_info, dhcp_type_interface)
 
-/* hash.c */
-struct hash_table *new_hash PROTO ((hash_reference, hash_dereference, int));
-void add_hash PROTO ((struct hash_table *,
-                     const unsigned char *, unsigned, hashed_object_t *,
-                     const char *, int));
-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)
-HASH_FUNCTIONS_DECL (option, const char *, struct option)
-
 /* tables.c */
 extern struct universe dhcp_universe;
 extern struct universe nwip_universe;
@@ -1561,6 +1541,9 @@ struct universe **universes;
 extern struct hash_table *universe_hash;
 void initialize_common_option_spaces PROTO ((void));
 struct universe *config_universe;
+HASH_FUNCTIONS_DECL (group, const char *, struct group_object)
+HASH_FUNCTIONS_DECL (universe, const char *, struct universe)
+HASH_FUNCTIONS_DECL (option, const char *, struct option)
 
 /* stables.c */
 #if defined (FAILOVER_PROTOCOL)
similarity index 83%
rename from includes/hash.h
rename to includes/omapip/hash.h
index 428d5c5831ee758901a04d128e8e82ce3e4edce2..94e48bb2bc2586a611ad11282e88a27428a30339 100644 (file)
@@ -3,7 +3,7 @@
    Definitions for hashing... */
 
 /*
- * Copyright (c) 1996-1999 Internet Software Consortium.
+ * Copyright (c) 1995-2000 Internet Software Consortium.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -41,6 +41,9 @@
  * ``http://www.nominum.com''.
  */
 
+#ifndef OMAPI_HASH_H
+#define OMAPI_HASH_H
+
 #define DEFAULT_HASH_SIZE      9973
 
 /* The purpose of the hashed_object_t struct is to not match anything else. */
@@ -119,4 +122,20 @@ int name##_hash_foreach (struct hash_table *table,                       \
        return hash_foreach (table, (hash_foreach_func)func);                 \
 }
 
-                           
+
+struct hash_table *new_hash_table (int, const char *, int);
+void free_hash_table (struct hash_table *, const char *, int);
+struct hash_bucket *new_hash_bucket (const char *, int);
+void free_hash_bucket (struct hash_bucket *, const char *, int);
+struct hash_table *new_hash (hash_reference, hash_dereference, int);
+void add_hash (struct hash_table *,
+                     const unsigned char *, unsigned, hashed_object_t *,
+                     const char *, int);
+void delete_hash_entry (struct hash_table *, const unsigned char *,
+                              unsigned, const char *, int);
+int hash_lookup (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);
+
+#endif /* OMAPI_HASH_H */
index 2be4a130564f9fe6743a00e45c052ed9030aa6e2..74ef2e23a449321dfe50d0241961c4442a13cc49 100644 (file)
@@ -71,6 +71,7 @@
 #include <isc/result.h>
 
 #include <omapip/convert.h>
+#include <omapip/hash.h>
 #include <omapip/omapip.h>
 
 /* OMAPI protocol header, version 1.00 */
index b6c30714b7e83f9d54d2a9b1183780f29a1c5ded..9dd2dfb1f1bd2b6ac53bab6047b28b56accc4375 100644 (file)
@@ -21,10 +21,10 @@ CATMANPAGES = omapi.cat3
 SEDMANPAGES = omapi.man3
 SRC    = protocol.c buffer.c alloc.c result.c connection.c errwarn.c \
         listener.c dispatch.c generic.c support.c handle.c message.c \
-        convert.c
+        convert.c hash.c
 OBJ    = protocol.o buffer.o alloc.o result.o connection.o errwarn.o \
         listener.o dispatch.o generic.o support.o handle.o message.o \
-        convert.o
+        convert.o hash.o
 MAN    = omapi.3
 
 DEBUG  = -g
similarity index 82%
rename from common/hash.c
rename to omapip/hash.c
index 371b0e03fc987fa3f18f07b50d7cacaf200d9069..3cd85f7fc62312df69f3d7d88fe76443b095ef33 100644 (file)
 
 #ifndef lint
 static char copyright[] =
-"$Id: hash.c,v 1.25 2000/06/24 06:19:13 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium.  All rights reserved.\n";
+"$Id: hash.c,v 1.1 2000/08/01 22:55:07 neild Exp $ Copyright (c) 1995-2000 The Internet Software Consortium.  All rights reserved.\n";
 #endif /* not lint */
 
-#include "dhcpd.h"
+#include <omapip/omapip_p.h>
 #include <ctype.h>
 
-static int do_hash PROTO ((const unsigned char *, unsigned, unsigned));
-static int do_case_hash PROTO ((const unsigned char *, unsigned, unsigned));
+static int do_hash (const unsigned char *, unsigned, unsigned);
+static int do_case_hash (const unsigned char *, unsigned, unsigned);
+
+struct hash_table *new_hash_table (count, file, line)
+       int count;
+       const char *file;
+       int line;
+{
+       struct hash_table *rval = dmalloc (sizeof (struct hash_table)
+                                          - (DEFAULT_HASH_SIZE
+                                             * sizeof (struct hash_bucket *))
+                                          + (count
+                                             * sizeof (struct hash_bucket *)),
+                                          file, line);
+       rval -> hash_count = count;
+       return rval;
+}
+
+void free_hash_table (ptr, file, line)
+       struct hash_table *ptr;
+       const char *file;
+       int line;
+{
+       dfree ((VOIDPTR)ptr, file, line);
+}
+
+struct hash_bucket *free_hash_buckets;
+
+struct hash_bucket *new_hash_bucket (file, line)
+       const char *file;
+       int line;
+{
+       struct hash_bucket *rval;
+       int i;
+       if (!free_hash_buckets) {
+               rval = dmalloc (127 * sizeof (struct hash_bucket),
+                               file, line);
+               if (!rval)
+                       return rval;
+               for (i = 0; i < 127; i++) {
+                       rval -> next = free_hash_buckets;
+                       free_hash_buckets = rval;
+                       rval++;
+               }
+       }
+       rval = free_hash_buckets;
+       free_hash_buckets = rval -> next;
+       return rval;
+}
+
+void free_hash_bucket (ptr, file, line)
+       struct hash_bucket *ptr;
+       const char *file;
+       int line;
+{
+       ptr -> next = free_hash_buckets;
+       free_hash_buckets = ptr;
+}
 
 struct hash_table *new_hash (hash_reference referencer,
                             hash_dereference dereferencer,
@@ -278,7 +334,3 @@ int casecmp (const void *v1, const void *v2, unsigned long len)
        }
        return 0;
 }
-
-HASH_FUNCTIONS (group, const char *, struct group_object)
-HASH_FUNCTIONS (universe, const char *, struct universe)
-HASH_FUNCTIONS (option, const char *, struct option)