2
0
mirror of https://gitlab.isc.org/isc-projects/dhcp synced 2025-08-31 06:15:55 +00:00

Fixed OMAPI lookups based on hardware-address. The hardware type

is now specified via the hardware-type field.
This commit is contained in:
Damien Neil
2000-10-20 01:01:41 +00:00
parent 88398a425e
commit 2e3e0f9214

View File

@@ -50,7 +50,7 @@
#ifndef lint
static char copyright[] =
"$Id: omapi.c,v 1.39 2000/10/10 19:14:37 mellon Exp $ Copyright (c) 1999-2000 The Internet Software Consortium. All rights reserved.\n";
"$Id: omapi.c,v 1.40 2000/10/20 01:01:41 neild Exp $ Copyright (c) 1999-2000 The Internet Software Consortium. All rights reserved.\n";
#endif /* not lint */
#include "dhcpd.h"
@@ -1204,11 +1204,53 @@ isc_result_t dhcp_host_lookup (omapi_object_t **lp,
/* Now look for a hardware address. */
status = omapi_get_value_str (ref, id, "hardware-address", &tv);
if (status == ISC_R_SUCCESS) {
host = (struct host_decl *)0;
host_hash_lookup (&host, host_hw_addr_hash,
tv -> value -> u.buffer.value,
tv -> value -> u.buffer.len, MDL);
unsigned char *haddr;
unsigned int len;
len = tv -> value -> u.buffer.len + 1;
haddr = dmalloc (len, MDL);
if (!haddr) {
omapi_value_dereference (&tv, MDL);
return ISC_R_NOMEMORY;
}
memcpy (haddr + 1, tv -> value -> u.buffer.value, len - 1);
omapi_value_dereference (&tv, MDL);
status = omapi_get_value_str (ref, id, "hardware-type", &tv);
if (status == ISC_R_SUCCESS) {
if (tv -> value -> type == omapi_datatype_data) {
if ((tv -> value -> u.buffer.len != 4) ||
(tv -> value -> u.buffer.value[0] != 0) ||
(tv -> value -> u.buffer.value[1] != 0) ||
(tv -> value -> u.buffer.value[2] != 0)) {
omapi_value_dereference (&tv, MDL);
dfree (haddr, MDL);
return ISC_R_INVALIDARG;
}
haddr[0] = tv -> value -> u.buffer.value[3];
} else if (tv -> value -> type == omapi_datatype_int) {
haddr[0] = (unsigned char)
tv -> value -> u.integer;
} else {
omapi_value_dereference (&tv, MDL);
dfree (haddr, MDL);
return ISC_R_INVALIDARG;
}
omapi_value_dereference (&tv, MDL);
} else {
/* If no hardware-type is specified, default to
ethernet. This may or may not be a good idea,
but Telus is currently relying on this behavior.
- DPN */
haddr[0] = HTYPE_ETHER;
}
host = (struct host_decl *)0;
host_hash_lookup (&host, host_hw_addr_hash, haddr, len, MDL);
dfree (haddr, MDL);
if (*lp && *lp != (omapi_object_t *)host) {
omapi_object_dereference (lp, MDL);