mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-08-22 18:07:25 +00:00
Moved hash.c from libdhcp to libomapi, in anticipation of moving the
tsig_key structure into libomapi. (tsig_keys are stored in a hashtable, and libomapi should not depend on libdhcp.)
This commit is contained in:
parent
c8d531a6f9
commit
c62871ba64
@ -21,11 +21,11 @@ CATMANPAGES = dhcp-options.cat5 dhcp-contrib.cat5 dhcp-eval.cat5
|
|||||||
SEDMANPAGES = dhcp-options.man5 dhcp-contrib.man5 dhcp-eval.man5
|
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 \
|
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 \
|
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
|
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 \
|
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 \
|
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
|
inet_addr.o dns.o resolv.o execute.o discover.o comapi.o
|
||||||
MAN = dhcp-options.5 dhcp-contrib.5 dhcp-eval.5
|
MAN = dhcp-options.5 dhcp-contrib.5 dhcp-eval.5
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
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 */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "dhcpd.h"
|
#include "dhcpd.h"
|
||||||
@ -177,54 +177,6 @@ struct dhcp_packet *new_dhcp_packet (file, line)
|
|||||||
return rval;
|
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)
|
struct protocol *new_protocol (file, line)
|
||||||
const char *file;
|
const char *file;
|
||||||
int line;
|
int line;
|
||||||
@ -316,14 +268,6 @@ void free_protocol (ptr, file, line)
|
|||||||
dfree ((VOIDPTR)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)
|
void free_dhcp_packet (ptr, file, line)
|
||||||
struct dhcp_packet *ptr;
|
struct dhcp_packet *ptr;
|
||||||
const char *file;
|
const char *file;
|
||||||
|
@ -43,11 +43,17 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
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 */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "dhcpd.h"
|
#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.
|
/* DHCP Option names, formats and codes, from RFC1533.
|
||||||
|
|
||||||
Format codes:
|
Format codes:
|
||||||
|
@ -73,7 +73,6 @@
|
|||||||
#include "dhcp.h"
|
#include "dhcp.h"
|
||||||
#include "statement.h"
|
#include "statement.h"
|
||||||
#include "tree.h"
|
#include "tree.h"
|
||||||
#include "hash.h"
|
|
||||||
#include "inet.h"
|
#include "inet.h"
|
||||||
#include "auth.h"
|
#include "auth.h"
|
||||||
#include "dhctoken.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_reference (struct group **, struct group *, const char *, int);
|
||||||
int group_dereference (struct group **, const char *, int);
|
int group_dereference (struct group **, const char *, int);
|
||||||
struct dhcp_packet *new_dhcp_packet PROTO ((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 protocol *new_protocol PROTO ((const char *, int));
|
||||||
struct lease_state *new_lease_state 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));
|
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));
|
const char *, int));
|
||||||
void free_lease_state PROTO ((struct lease_state *, 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_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));
|
void free_dhcp_packet PROTO ((struct dhcp_packet *, const char *, int));
|
||||||
struct client_lease *new_client_lease PROTO ((const char *, int));
|
struct client_lease *new_client_lease PROTO ((const char *, int));
|
||||||
void free_client_lease PROTO ((struct client_lease *, 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,
|
OMAPI_OBJECT_ALLOC_DECL (interface,
|
||||||
struct interface_info, dhcp_type_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 */
|
/* tables.c */
|
||||||
extern struct universe dhcp_universe;
|
extern struct universe dhcp_universe;
|
||||||
extern struct universe nwip_universe;
|
extern struct universe nwip_universe;
|
||||||
@ -1561,6 +1541,9 @@ struct universe **universes;
|
|||||||
extern struct hash_table *universe_hash;
|
extern struct hash_table *universe_hash;
|
||||||
void initialize_common_option_spaces PROTO ((void));
|
void initialize_common_option_spaces PROTO ((void));
|
||||||
struct universe *config_universe;
|
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 */
|
/* stables.c */
|
||||||
#if defined (FAILOVER_PROTOCOL)
|
#if defined (FAILOVER_PROTOCOL)
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
Definitions for hashing... */
|
Definitions for hashing... */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1996-1999 Internet Software Consortium.
|
* Copyright (c) 1995-2000 Internet Software Consortium.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -41,6 +41,9 @@
|
|||||||
* ``http://www.nominum.com''.
|
* ``http://www.nominum.com''.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef OMAPI_HASH_H
|
||||||
|
#define OMAPI_HASH_H
|
||||||
|
|
||||||
#define DEFAULT_HASH_SIZE 9973
|
#define DEFAULT_HASH_SIZE 9973
|
||||||
|
|
||||||
/* The purpose of the hashed_object_t struct is to not match anything else. */
|
/* 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); \
|
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 */
|
@ -71,6 +71,7 @@
|
|||||||
#include <isc/result.h>
|
#include <isc/result.h>
|
||||||
|
|
||||||
#include <omapip/convert.h>
|
#include <omapip/convert.h>
|
||||||
|
#include <omapip/hash.h>
|
||||||
#include <omapip/omapip.h>
|
#include <omapip/omapip.h>
|
||||||
|
|
||||||
/* OMAPI protocol header, version 1.00 */
|
/* OMAPI protocol header, version 1.00 */
|
||||||
|
@ -21,10 +21,10 @@ CATMANPAGES = omapi.cat3
|
|||||||
SEDMANPAGES = omapi.man3
|
SEDMANPAGES = omapi.man3
|
||||||
SRC = protocol.c buffer.c alloc.c result.c connection.c errwarn.c \
|
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 \
|
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 \
|
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 \
|
listener.o dispatch.o generic.o support.o handle.o message.o \
|
||||||
convert.o
|
convert.o hash.o
|
||||||
MAN = omapi.3
|
MAN = omapi.3
|
||||||
|
|
||||||
DEBUG = -g
|
DEBUG = -g
|
||||||
|
@ -43,14 +43,70 @@
|
|||||||
|
|
||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char copyright[] =
|
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 */
|
#endif /* not lint */
|
||||||
|
|
||||||
#include "dhcpd.h"
|
#include <omapip/omapip_p.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
static int do_hash PROTO ((const unsigned char *, unsigned, unsigned));
|
static int do_hash (const unsigned char *, unsigned, unsigned);
|
||||||
static int do_case_hash PROTO ((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,
|
struct hash_table *new_hash (hash_reference referencer,
|
||||||
hash_dereference dereferencer,
|
hash_dereference dereferencer,
|
||||||
@ -278,7 +334,3 @@ int casecmp (const void *v1, const void *v2, unsigned long len)
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
HASH_FUNCTIONS (group, const char *, struct group_object)
|
|
||||||
HASH_FUNCTIONS (universe, const char *, struct universe)
|
|
||||||
HASH_FUNCTIONS (option, const char *, struct option)
|
|
Loading…
x
Reference in New Issue
Block a user