#ifndef lint
static char ocopyright[] =
-"$Id: auth.c,v 1.5 2000/03/17 03:59:00 mellon Exp $ Copyright 1998-2000 The Internet Software Consortium.";
+"$Id: auth.c,v 1.6 2000/03/18 02:15:36 mellon Exp $ Copyright 1998-2000 The Internet Software Consortium.";
#endif
#include "dhcpd.h"
struct auth_key *key;
{
if (!auth_key_hash)
- auth_key_hash = new_hash (0, 0);
+ auth_key_hash = new_hash (0, 0, 0);
if (!auth_key_hash)
log_fatal ("Can't allocate authentication key hash.");
add_hash (auth_key_hash, key_id -> data, key_id -> len,
* SUCH DAMAGE.
*
* This software has been written for the Internet Software Consortium
- * by Ted Lemon in cooperation with Vixie Enterprises and Nominum, Inc.
+ * by Ted Lemon in cooperation with Nominum, Inc.
* To learn more about the Internet Software Consortium, see
- * ``http://www.isc.org/''. To learn more about Vixie Enterprises,
- * see ``http://www.vix.com''. To learn more about Nominum, Inc., see
+ * ``http://www.isc.org/''. To learn more about Nominum, Inc., see
* ``http://www.nominum.com''.
*/
#ifndef lint
static char copyright[] =
-"$Id: dns.c,v 1.18 2000/03/17 03:59:01 mellon Exp $ Copyright (c) 2000 The Internet Software Consortium. All rights reserved.\n";
+"$Id: dns.c,v 1.19 2000/03/18 02:15:36 mellon Exp $ Copyright (c) 2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
struct hash_table *tsig_key_hash;
struct hash_table *dns_zone_hash;
+#if defined (NSUPDATE)
+isc_result_t find_tsig_key (ns_tsig_key **key, const char *zname)
+{
+ struct dns_zone *zone;
+ isc_result_t status;
+ ns_tsig_key *tkey;
+
+ zone = (struct dns_zone *)0;
+ status = dns_zone_lookup (&zone, zname);
+ if (status != ISC_R_SUCCESS)
+ return status;
+ if (!zone -> key) {
+ dns_zone_dereference (&zone, MDL);
+ return ISC_R_KEY_UNKNOWN;
+ }
+
+ if ((!zone -> key -> name ||
+ strlen (zone -> key -> name) > NS_MAXDNAME) ||
+ (!zone -> key -> algorithm ||
+ strlen (zone -> key -> algorithm) > NS_MAXDNAME) ||
+ (!zone -> key -> key.len)) {
+ dns_zone_dereference (&zone, MDL);
+ return ISC_R_INVALIDKEY;
+ }
+ tkey = dmalloc (sizeof *tkey, MDL);
+ if (!tkey) {
+ nomem:
+ dns_zone_dereference (&zone, MDL);
+ return ISC_R_NOMEMORY;
+ }
+ memset (tkey, 0, sizeof *tkey);
+ tkey -> data = dmalloc (zone -> key -> key.len, MDL);
+ if (!tkey -> data) {
+ dfree (tkey, MDL);
+ goto nomem;
+ }
+ strcpy (tkey -> name, zone -> key -> name);
+ strcpy (tkey -> alg, zone -> key -> algorithm);
+ memcpy (tkey -> data,
+ zone -> key -> key.data, zone -> key -> key.len);
+ tkey -> len = zone -> key -> key.len;
+ *key = tkey;
+ return ISC_R_SUCCESS;
+}
+
+void tkey_free (ns_tsig_key **key)
+{
+ if ((*key) -> data)
+ dfree ((*key) -> data, MDL);
+ dfree ((*key), MDL);
+ *key = (ns_tsig_key *)0;
+}
+#endif
+
isc_result_t enter_dns_zone (struct dns_zone *zone)
{
struct dns_zone *tz;
} else {
dns_zone_hash =
new_hash ((hash_reference)dns_zone_reference,
- (hash_dereference)dns_zone_dereference);
+ (hash_dereference)dns_zone_dereference, 1);
if (!dns_zone_hash)
return ISC_R_NOMEMORY;
}
} else {
tsig_key_hash =
new_hash ((hash_reference)tsig_key_reference,
- (hash_dereference)tsig_key_dereference);
+ (hash_dereference)tsig_key_dereference, 1);
if (!tsig_key_hash)
return ISC_R_NOMEMORY;
}
#ifndef lint
static char copyright[] =
-"$Id: hash.c,v 1.18 2000/03/17 03:59:01 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n";
+"$Id: hash.c,v 1.19 2000/03/18 02:15:36 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
+#include <ctype.h>
-static INLINE int do_hash PROTO ((const unsigned char *, unsigned, unsigned));
+static int do_hash PROTO ((const unsigned char *, unsigned, unsigned));
+static int do_case_hash PROTO ((const unsigned char *, unsigned, unsigned));
struct hash_table *new_hash (hash_reference referencer,
- hash_dereference dereferencer)
+ hash_dereference dereferencer,
+ int casep)
{
struct hash_table *rv = new_hash_table (DEFAULT_HASH_SIZE, MDL);
if (!rv)
DEFAULT_HASH_SIZE * sizeof (struct hash_bucket *));
rv -> referencer = referencer;
rv -> dereferencer = dereferencer;
+ if (casep) {
+ rv -> cmp = casecmp;
+ rv -> do_hash = do_case_hash;
+ } else {
+ rv -> cmp = memcmp;
+ rv -> do_hash = do_hash;
+ }
return rv;
}
-static INLINE int do_hash (name, len, size)
+static int do_case_hash (name, len, size)
const unsigned char *name;
unsigned len;
unsigned size;
register int accum = 0;
register const unsigned char *s = (const unsigned char *)name;
int i = len;
+ register unsigned c;
+
+ while (i--) {
+ /* Make the hash case-insensitive. */
+ c = *s++;
+ if (isascii (c) && isupper (c))
+ c = tolower (c);
+
+ /* Add the character in... */
+ accum += *s++;
+ /* Add carry back in... */
+ while (accum > 255) {
+ accum = (accum & 255) + (accum >> 8);
+ }
+ }
+ return accum % size;
+}
+
+static int do_hash (name, len, size)
+ const unsigned char *name;
+ unsigned len;
+ unsigned size;
+{
+ register int accum = 0;
+ register const unsigned char *s = (const unsigned char *)name;
+ int i = len;
+
while (i--) {
/* Add the character in... */
accum += *s++;
if (!len)
len = strlen ((const char *)name);
- hashno = do_hash (name, len, table -> hash_count);
+ hashno = (*table -> do_hash) (name, len, table -> hash_count);
bp = new_hash_bucket (MDL);
if (!bp) {
if (!len)
len = strlen ((const char *)name);
- hashno = do_hash (name, len, table -> hash_count);
+ hashno = (*table -> do_hash) (name, len, table -> hash_count);
/* Go through the list looking for an entry that matches;
if we find it, delete it. */
if ((!bp -> len &&
!strcmp ((const char *)bp -> name, (const char *)name)) ||
(bp -> len == len &&
- !memcmp (bp -> name, name, len))) {
+ !(*table -> cmp) (bp -> name, name, len))) {
if (pbp) {
pbp -> next = bp -> next;
} else {
if (!len)
len = strlen ((const char *)name);
- hashno = do_hash (name, len, table -> hash_count);
+ hashno = (*table -> do_hash) (name, len, table -> hash_count);
for (bp = table -> buckets [hashno]; bp; bp = bp -> next) {
if (len == bp -> len
- && !memcmp (bp -> name, name, len))
+ && !(*table -> cmp) (bp -> name, name, len))
return bp -> value;
}
return (unsigned char *)0;
}
+int casecmp (const void *v1, const void *v2, unsigned len)
+{
+ unsigned i;
+ const char *s = v1;
+ const char *t = v2;
+
+ for (i = 0; i < len; i++)
+ {
+ int c1, c2;
+ if (isascii (s [i]) && isupper (s [i]))
+ c1 = tolower (s [i]);
+ else
+ c1 = s [i];
+
+ if (isascii (t [i]) && isupper (t [i]))
+ c2 = tolower (t [i]);
+ else
+ c2 = t [i];
+
+ if (c1 < c2)
+ return -1;
+ if (c1 > c2)
+ return 1;
+ }
+ return 0;
+}
#ifndef lint
static char copyright[] =
-"$Id: parse.c,v 1.66 2000/03/17 03:59:01 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n";
+"$Id: parse.c,v 1.67 2000/03/18 02:15:37 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
universes = ua;
}
universes [nu -> index] = nu;
- nu -> hash = new_hash (0, 0);
+ nu -> hash = new_hash (0, 0, 1);
if (!nu -> hash)
log_fatal ("Can't allocate %s option hash table.", nu -> name);
add_hash (&universe_hash,
#ifndef lint
static char copyright[] =
-"$Id: tables.c,v 1.38 2000/03/17 03:59:02 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n";
+"$Id: tables.c,v 1.39 2000/03/18 02:15:37 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
dhcp_universe.store_length = putUChar;
dhcp_universe.index = universe_count++;
universes [dhcp_universe.index] = &dhcp_universe;
- dhcp_universe.hash = new_hash (0, 0);
+ dhcp_universe.hash = new_hash (0, 0, 1);
if (!dhcp_universe.hash)
log_fatal ("Can't allocate dhcp option hash table.");
for (i = 0; i < 256; i++) {
nwip_universe.store_length = putUChar;
nwip_universe.index = universe_count++;
universes [nwip_universe.index] = &nwip_universe;
- nwip_universe.hash = new_hash (0, 0);
+ nwip_universe.hash = new_hash (0, 0, 1);
if (!nwip_universe.hash)
log_fatal ("Can't allocate dhcp option hash table.");
for (i = 0; i < 256; i++) {
#ifndef lint
static char copyright[] =
-"$Id: tree.c,v 1.79 2000/03/17 03:59:02 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n";
+"$Id: tree.c,v 1.80 2000/03/18 02:15:37 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
expr -> op);
return 0;
+ case expr_function:
+ log_error ("Function opcode in evaluate_dns_expression: %d",
+ expr -> op);
+ return 0;
+
case expr_arg:
break;
}
/* Do the update and record the error code, if there was
an error; otherwise set it to NOERROR. */
- *result = minires_nupdate (&res, ISC_LIST_HEAD (uq), NULL);
+ *result = minires_nupdate (&res, ISC_LIST_HEAD (uq));
status = 1;
print_dns_status ((int)*result, &uq);
void remove_protocol PROTO ((struct protocol *));
/* hash.c */
-struct hash_table *new_hash PROTO ((hash_reference, hash_dereference));
+struct hash_table *new_hash PROTO ((hash_reference, hash_dereference, int));
void add_hash PROTO ((struct hash_table *,
const unsigned char *, unsigned, void *));
void delete_hash_entry PROTO ((struct hash_table *,
const unsigned char *, unsigned));
void *hash_lookup PROTO ((struct hash_table *,
const unsigned char *, unsigned));
+int casecmp (const void *s, const void *t, unsigned len);
/* tables.c */
extern struct universe dhcp_universe;
isc_result_t icmp_echoreply PROTO ((omapi_object_t *));
/* dns.c */
+#if defined (NSUPDATE)
+isc_result_t find_tsig_key (ns_tsig_key **, const char *);
+void tkey_free (ns_tsig_key **);
+#endif
isc_result_t enter_dns_zone (struct dns_zone *);
isc_result_t dns_zone_lookup (struct dns_zone **, const char *);
isc_result_t enter_tsig_key (struct tsig_key *);
struct hash_bucket *buckets [DEFAULT_HASH_SIZE];
hash_reference referencer;
hash_dereference dereferencer;
+ int (*cmp) (const void *, const void *, size_t);
+ int (*do_hash) (const unsigned char *, unsigned, unsigned);
};
struct named_hash {
#define ISC_R_KEYCONFLICT 44
#define ISC_R_BADPARSE 45
#define ISC_R_NOKEYS 46
+#define ISC_R_KEY_UNKNOWN 47
+#define ISC_R_INVALIDKEY 48
-#define ISC_R_NRESULTS 47 /* Number of results */
+#define ISC_R_NRESULTS 49 /* Number of results */
const char * isc_result_totext(isc_result_t);
isc_result_t isc_result_register(unsigned int base,
unsigned int, unsigned long);
void minires_freeupdrec (ns_updrec *);
int minires_nmkupdate (res_state, ns_updrec *, unsigned char *, unsigned);
-ns_rcode minires_nupdate (res_state, ns_updrec *, ns_tsig_key *);
+ns_rcode minires_nupdate (res_state, ns_updrec *);
int minires_ninit (res_state);
#if defined (MINIRES_LIB)
#if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "$Id: res_update.c,v 1.3 2000/02/03 04:33:03 mellon Exp $";
+static const char rcsid[] = "$Id: res_update.c,v 1.4 2000/03/18 02:15:49 mellon Exp $";
#endif /* not lint */
/*
static int nsprom(struct sockaddr_in *, const struct in_addr *, int);
static void dprintf(const char *, ...);
+void tkey_free (ns_tsig_key **);
+int find_tsig_key (ns_tsig_key **, const char *);
+
ns_rcode
-res_nupdate(res_state statp, ns_updrec *rrecp_in, ns_tsig_key *key) {
+res_nupdate(res_state statp, ns_updrec *rrecp_in) {
ns_updrec *rrecp;
u_char answer[PACKETSZ], packet[2*PACKETSZ];
struct zonegrp *zptr, tgrp;
unsigned n;
struct sockaddr_in nsaddrs[MAXNS];
ns_rcode rcode;
+ ns_tsig_key *key;
/* Make sure all the updates are in the same zone, and find out
what zone they are in. */
zptr->z_nsaddrs, zptr->z_nscount);
/* Send the update and remember the result. */
- if (key != NULL)
+ key = (ns_tsig_key *)0;
+ if (!find_tsig_key (&key, zptr->z_origin)) {
n = res_nsendsigned(statp, packet, n, key,
answer, sizeof answer);
- else
+ tkey_free (&key);
+ } else {
n = res_nsend(statp, packet, n, answer, sizeof answer);
+ }
if (n < 0) {
rcode = -1;
goto undone;
"key conflict", /* 44 */
"parse error(s) occurred", /* 45 */
"no key specified", /* 46 */
+ "zone TSIG key not known", /* 47 */
+ "invalid TSIG key", /* 48 */
};
const char *isc_result_totext (isc_result_t result)
#ifndef lint
static char copyright[] =
-"$Id: class.c,v 1.18 2000/03/17 04:00:30 mellon Exp $ Copyright (c) 1998-2000 The Internet Software Consortium. All rights reserved.\n";
+"$Id: class.c,v 1.19 2000/03/18 02:15:52 mellon Exp $ Copyright (c) 1998-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
MDL);
data_string_forget (&data, MDL);
if (!class -> hash)
- class -> hash = new_hash (0, 0);
+ class -> hash = new_hash (0, 0, 0);
add_hash (class -> hash,
nc -> hash_string.data,
nc -> hash_string.len,
#ifndef lint
static char copyright[] =
-"$Id: confpars.c,v 1.104 2000/03/17 04:00:31 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n";
+"$Id: confpars.c,v 1.105 2000/03/18 02:15:52 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
}
data_string_copy (&class -> hash_string, &data, MDL);
if (!pc -> hash)
- pc -> hash = new_hash (0, 0);
+ pc -> hash = new_hash (0, 0, 0);
add_hash (pc -> hash,
class -> hash_string.data,
class -> hash_string.len,
#ifndef lint
static char copyright[] =
-"$Id: mdb.c,v 1.28 2000/03/17 04:00:31 mellon Exp $ Copyright (c) 1996-2000 The Internet Software Consortium. All rights reserved.\n";
+"$Id: mdb.c,v 1.29 2000/03/18 02:15:52 mellon Exp $ Copyright (c) 1996-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
struct executable_statement *esp;
if (!host_name_hash) {
- host_name_hash = new_hash (0, 0);
+ host_name_hash = new_hash (0, 0, 0);
if (!host_name_hash)
log_fatal ("Can't allocate host name hash");
} else {
if (hd -> interface.hlen) {
if (!host_hw_addr_hash) {
- host_hw_addr_hash = new_hash (0, 0);
+ host_hw_addr_hash = new_hash (0, 0, 0);
if (!host_hw_addr_hash)
log_fatal ("Can't allocate host/hw hash");
} else
/* If there's no uid hash, make one; otherwise, see if
there's already an entry in the hash for this host. */
if (!host_uid_hash) {
- host_uid_hash = new_hash (0, 0);
+ host_uid_hash = new_hash (0, 0, 0);
if (!host_uid_hash)
log_fatal ("Can't allocate host/uid hash");
hp = (struct host_decl *)0;
}
}
} else {
- group_name_hash = new_hash (0, 0);
+ group_name_hash = new_hash (0, 0, 0);
t = (struct group_object *)0;
}
/* Initialize the hash table if it hasn't been done yet. */
if (!lease_uid_hash) {
- lease_uid_hash = new_hash (0, 0);
+ lease_uid_hash = new_hash (0, 0, 0);
if (!lease_uid_hash)
log_fatal ("Can't allocate lease/uid hash");
}
if (!lease_ip_addr_hash) {
- lease_ip_addr_hash = new_hash (0, 0);
+ lease_ip_addr_hash = new_hash (0, 0, 0);
if (!lease_uid_hash)
log_fatal ("Can't allocate lease/ip hash");
}
if (!lease_hw_addr_hash) {
- lease_hw_addr_hash = new_hash (0, 0);
+ lease_hw_addr_hash = new_hash (0, 0, 0);
if (!lease_uid_hash)
log_fatal ("Can't allocate lease/hw hash");
}
#ifndef lint
static char copyright[] =
-"$Id: stables.c,v 1.8 2000/03/17 04:00:32 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n";
+"$Id: stables.c,v 1.9 2000/03/18 02:15:52 mellon Exp $ Copyright (c) 1995-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
agent_universe.store_tag = putUChar;
agent_universe.store_length = putUChar;
universes [agent_universe.index] = &agent_universe;
- agent_universe.hash = new_hash (0, 0);
+ agent_universe.hash = new_hash (0, 0, 1);
if (!agent_universe.hash)
log_fatal ("Can't allocate agent option hash table.");
for (i = 0; i < 256; i++) {
server_universe.store_length = putUChar;
server_universe.index = universe_count++;
universes [server_universe.index] = &server_universe;
- server_universe.hash = new_hash (0, 0);
+ server_universe.hash = new_hash (0, 0, 1);
if (!server_universe.hash)
log_fatal ("Can't allocate server option hash table.");
for (i = 0; i < 256; i++) {