#ifndef lint
static char copyright[] =
-"$Id: memory.c,v 1.58 1999/09/16 01:19:52 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+"$Id: memory.c,v 1.59 1999/09/16 05:12:33 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
omapi_object_type_t *dhcp_type_host;
-void enter_host (hd, dynamicp, commit)
+isc_result_t enter_host (hd, dynamicp, commit)
struct host_decl *hd;
int dynamicp;
int commit;
struct host_decl *np = (struct host_decl *)0;
struct executable_statement *esp;
+ if (!host_name_hash) {
+ host_name_hash = new_hash ();
+ if (!host_name_hash)
+ log_fatal ("Can't allocate host name hash");
+ } else {
+ hp = (struct host_decl *)
+ hash_lookup (host_name_hash,
+ (unsigned char *)hd -> name,
+ strlen (hd -> name));
+
+ /* If there isn't already a host decl matching this
+ address, add it to the hash table. */
+ if (!hp) {
+ add_hash (host_name_hash,
+ (unsigned char *)hd -> name,
+ strlen (hd -> name),
+ (unsigned char *)hd);
+ hd -> refcnt++; /* XXX */
+ } else
+ /* XXX actually, we have to delete the old one
+ XXX carefully and replace it. Not done yet. */
+ return ISC_R_EXISTS;
+ }
+
if (dynamicp) {
hd -> flags |= HOST_DECL_DYNAMIC;
hd -> n_dynamic = dynamic_hosts;
}
}
- if (!host_name_hash) {
- host_name_hash = new_hash ();
- if (!host_name_hash)
- log_fatal ("Can't allocate host/hw hash");
- } else {
- hp = (struct host_decl *)
- hash_lookup (host_name_hash,
- (unsigned char *)hd -> name,
- strlen (hd -> name));
-
- /* If there isn't already a host decl matching this
- address, add it to the hash table. */
- if (!hp) {
- add_hash (host_name_hash,
- (unsigned char *)hd -> name, strlen (hd -> name),
- (unsigned char *)hd);
- hd -> refcnt++; /* XXX */
- } else
- /* XXX actually, we have to delete the old one
- XXX carefully and replace it. Not done yet. */
- log_fatal ("duplicate hostname: %s!", hd -> name);
- }
if (dynamicp && commit) {
write_host (hd);
commit_leases ();
}
+
+ return ISC_R_SUCCESS;
}
void delete_host (hd, commit)
#ifndef lint
static char copyright[] =
-"$Id: confpars.c,v 1.81 1999/09/16 00:52:50 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
+"$Id: confpars.c,v 1.82 1999/09/16 05:12:38 mellon Exp $ Copyright (c) 1995, 1996 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
int declaration = 0;
int dynamicp = 0;
int deleted = 0;
+ isc_result_t status;
token = peek_token (&val, cfile);
if (token != LBRACE) {
free_group (host -> group, "parse_host_declaration");
dfree (host, "parse_host_declaration");
} else {
- enter_host (host, dynamicp, 0);
+ status = enter_host (host, dynamicp, 0);
+ if (status != ISC_R_SUCCESS)
+ parse_warn ("host %s: %s", isc_result_totext (status));
}
}
#ifndef lint
static char copyright[] =
-"$Id: omapi.c,v 1.6 1999/09/16 04:53:38 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
+"$Id: omapi.c,v 1.7 1999/09/16 05:12:38 mellon Exp $ Copyright (c) 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
lease = (struct lease *)h;
if (!strcmp (name, "updated")) {
+ if (lease -> hardware_addr.hlen == 0 ||
+ lease -> hardware_addr.htype == 0 ||
+ lease -> hardware_addr.hlen > 16)
+ return ISC_R_INVALIDARG;
if (!write_lease (lease))
return ISC_R_IOERROR;
}
host = (struct host_decl *)h;
if (!strcmp (name, "updated")) {
+ if (host -> interface.hlen == 0 ||
+ host -> interface.htype == 0 ||
+ host -> interface.hlen > 16)
+ return ISC_R_INVALIDARG;
+
if (!host -> name) {
char hnbuf [64];
sprintf (hnbuf, "nh%08lx%08lx",
return ISC_R_NOMEMORY;
strcpy (host -> name, hnbuf);
}
- enter_host (host, 1, 1);
+
+ status = enter_host (host, 1, 1);
+ if (status != ISC_R_SUCCESS)
+ return status;
}
/* Try to find some inner object that can take the value. */