aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/comapi.c59
-rw-r--r--common/conflex.c4
-rw-r--r--common/dhcp-eval.52
-rw-r--r--common/dns.c71
-rw-r--r--common/execute.c79
-rw-r--r--common/options.c10
-rw-r--r--common/packet.c51
-rw-r--r--common/parse.c69
-rw-r--r--common/print.c5
-rw-r--r--common/socket.c85
-rw-r--r--common/tables.c3
11 files changed, 267 insertions, 171 deletions
diff --git a/common/comapi.c b/common/comapi.c
index c24b4a6..90d2262 100644
--- a/common/comapi.c
+++ b/common/comapi.c
@@ -3,6 +3,7 @@
OMAPI object interfaces for the DHCP server. */
/*
+ * Copyright (c) 2012 Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2007,2009 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1999-2003 by Internet Software Consortium
*
@@ -435,7 +436,7 @@ isc_result_t dhcp_group_remove (omapi_object_t *lp,
status = dhcp_group_destroy ((omapi_object_t *)group, MDL);
- return ISC_R_SUCCESS;
+ return status;
}
isc_result_t dhcp_control_set_value (omapi_object_t *h,
@@ -511,12 +512,12 @@ isc_result_t dhcp_control_destroy (omapi_object_t *h,
isc_result_t dhcp_control_signal_handler (omapi_object_t *h,
const char *name, va_list ap)
{
- dhcp_control_object_t *control;
+ /* In this function h should be a (dhcp_control_object_t *) */
+
isc_result_t status;
if (h -> type != dhcp_type_control)
return DHCP_R_INVALIDARG;
- control = (dhcp_control_object_t *)h;
/* Try to find some inner object that can take the value. */
if (h -> inner && h -> inner -> type -> get_value) {
@@ -572,11 +573,11 @@ isc_result_t dhcp_control_lookup (omapi_object_t **lp,
status = omapi_get_value_str (ref, id, "handle", &tv);
if (status == ISC_R_SUCCESS) {
status = omapi_handle_td_lookup (lp, tv -> value);
-
+
omapi_value_dereference (&tv, MDL);
if (status != ISC_R_SUCCESS)
return status;
-
+
/* Don't return the object if the type is wrong. */
if ((*lp) -> type != dhcp_type_control) {
omapi_object_dereference (lp, MDL);
@@ -612,12 +613,12 @@ isc_result_t dhcp_subnet_set_value (omapi_object_t *h,
omapi_data_string_t *name,
omapi_typed_data_t *value)
{
- struct subnet *subnet;
+ /* In this function h should be a (struct subnet *) */
+
isc_result_t status;
if (h -> type != dhcp_type_subnet)
return DHCP_R_INVALIDARG;
- subnet = (struct subnet *)h;
/* No values to set yet. */
@@ -628,7 +629,7 @@ isc_result_t dhcp_subnet_set_value (omapi_object_t *h,
if (status == ISC_R_SUCCESS || status == DHCP_R_UNCHANGED)
return status;
}
-
+
return ISC_R_NOTFOUND;
}
@@ -637,12 +638,12 @@ isc_result_t dhcp_subnet_get_value (omapi_object_t *h, omapi_object_t *id,
omapi_data_string_t *name,
omapi_value_t **value)
{
- struct subnet *subnet;
+ /* In this function h should be a (struct subnet *) */
+
isc_result_t status;
if (h -> type != dhcp_type_subnet)
return DHCP_R_INVALIDARG;
- subnet = (struct subnet *)h;
/* No values to get yet. */
@@ -658,14 +659,17 @@ isc_result_t dhcp_subnet_get_value (omapi_object_t *h, omapi_object_t *id,
isc_result_t dhcp_subnet_destroy (omapi_object_t *h, const char *file, int line)
{
+#if defined (DEBUG_MEMORY_LEAKAGE) || \
+ defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
struct subnet *subnet;
+#endif
if (h -> type != dhcp_type_subnet)
return DHCP_R_INVALIDARG;
- subnet = (struct subnet *)h;
#if defined (DEBUG_MEMORY_LEAKAGE) || \
defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
+ subnet = (struct subnet *)h;
if (subnet -> next_subnet)
subnet_dereference (&subnet -> next_subnet, file, line);
if (subnet -> next_sibling)
@@ -685,13 +689,13 @@ isc_result_t dhcp_subnet_destroy (omapi_object_t *h, const char *file, int line)
isc_result_t dhcp_subnet_signal_handler (omapi_object_t *h,
const char *name, va_list ap)
{
- struct subnet *subnet;
+ /* In this function h should be a (struct subnet *) */
+
isc_result_t status;
int updatep = 0;
if (h -> type != dhcp_type_subnet)
return DHCP_R_INVALIDARG;
- subnet = (struct subnet *)h;
/* Can't write subnets yet. */
@@ -711,12 +715,12 @@ isc_result_t dhcp_subnet_stuff_values (omapi_object_t *c,
omapi_object_t *id,
omapi_object_t *h)
{
- struct subnet *subnet;
+ /* In this function h should be a (struct subnet *) */
+
isc_result_t status;
if (h -> type != dhcp_type_subnet)
return DHCP_R_INVALIDARG;
- subnet = (struct subnet *)h;
/* Can't stuff subnet values yet. */
@@ -761,12 +765,12 @@ isc_result_t dhcp_shared_network_set_value (omapi_object_t *h,
omapi_data_string_t *name,
omapi_typed_data_t *value)
{
- struct shared_network *shared_network;
+ /* In this function h should be a (struct shared_network *) */
+
isc_result_t status;
if (h -> type != dhcp_type_shared_network)
return DHCP_R_INVALIDARG;
- shared_network = (struct shared_network *)h;
/* No values to set yet. */
@@ -777,7 +781,7 @@ isc_result_t dhcp_shared_network_set_value (omapi_object_t *h,
if (status == ISC_R_SUCCESS || status == DHCP_R_UNCHANGED)
return status;
}
-
+
return ISC_R_NOTFOUND;
}
@@ -787,12 +791,12 @@ isc_result_t dhcp_shared_network_get_value (omapi_object_t *h,
omapi_data_string_t *name,
omapi_value_t **value)
{
- struct shared_network *shared_network;
+ /* In this function h should be a (struct shared_network *) */
+
isc_result_t status;
if (h -> type != dhcp_type_shared_network)
return DHCP_R_INVALIDARG;
- shared_network = (struct shared_network *)h;
/* No values to get yet. */
@@ -809,14 +813,19 @@ isc_result_t dhcp_shared_network_get_value (omapi_object_t *h,
isc_result_t dhcp_shared_network_destroy (omapi_object_t *h,
const char *file, int line)
{
+ /* In this function h should be a (struct shared_network *) */
+
+#if defined (DEBUG_MEMORY_LEAKAGE) || \
+ defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
struct shared_network *shared_network;
+#endif
if (h -> type != dhcp_type_shared_network)
return DHCP_R_INVALIDARG;
- shared_network = (struct shared_network *)h;
#if defined (DEBUG_MEMORY_LEAKAGE) || \
defined (DEBUG_MEMORY_LEAKAGE_ON_EXIT)
+ shared_network = (struct shared_network *)h;
if (shared_network -> next)
shared_network_dereference (&shared_network -> next,
file, line);
@@ -849,13 +858,13 @@ isc_result_t dhcp_shared_network_signal_handler (omapi_object_t *h,
const char *name,
va_list ap)
{
- struct shared_network *shared_network;
+ /* In this function h should be a (struct shared_network *) */
+
isc_result_t status;
int updatep = 0;
if (h -> type != dhcp_type_shared_network)
return DHCP_R_INVALIDARG;
- shared_network = (struct shared_network *)h;
/* Can't write shared_networks yet. */
@@ -875,12 +884,12 @@ isc_result_t dhcp_shared_network_stuff_values (omapi_object_t *c,
omapi_object_t *id,
omapi_object_t *h)
{
- struct shared_network *shared_network;
+ /* In this function h should be a (struct shared_network *) */
+
isc_result_t status;
if (h -> type != dhcp_type_shared_network)
return DHCP_R_INVALIDARG;
- shared_network = (struct shared_network *)h;
/* Can't stuff shared_network values yet. */
diff --git a/common/conflex.c b/common/conflex.c
index 9c9ed66..0ae5e69 100644
--- a/common/conflex.c
+++ b/common/conflex.c
@@ -3,7 +3,7 @@
Lexical scanner for dhcpd config file... */
/*
- * Copyright (c) 2004-2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
@@ -1043,6 +1043,8 @@ intern(char *atom, enum dhcp_token dfv) {
return INCLUDE;
if (!strcasecmp (atom + 1, "nteger"))
return INTEGER;
+ if (!strcasecmp (atom + 1, "nfiniband"))
+ return TOKEN_INFINIBAND;
if (!strcasecmp (atom + 1, "nfinite"))
return INFINITE;
if (!strcasecmp (atom + 1, "nfo"))
diff --git a/common/dhcp-eval.5 b/common/dhcp-eval.5
index 788c969..db67009 100644
--- a/common/dhcp-eval.5
+++ b/common/dhcp-eval.5
@@ -1,4 +1,4 @@
-.\" $Id: dhcp-eval.5,v 1.29.24.2.4.1 2011-11-28 18:18:51 sar Exp $
+.\" $Id: dhcp-eval.5,v 1.29.24.3 2011-11-28 18:09:30 sar Exp $
.\"
.\" Copyright (c) 2009-2011 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 2004,2007 by Internet Systems Consortium, Inc. ("ISC")
diff --git a/common/dns.c b/common/dns.c
index 3992b6c..53e85a4 100644
--- a/common/dns.c
+++ b/common/dns.c
@@ -3,7 +3,7 @@
Domain Name Service subroutines. */
/*
- * Copyright (c) 2009-2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2009-2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2007 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2001-2003 by Internet Software Consortium
*
@@ -813,6 +813,12 @@ void repudiate_zone (struct dns_zone **zone)
XXX zones. This isn't a big problem since we're not yet
XXX caching zones... :'} */
+ /* verify that we have a pointer at least */
+ if ((zone == NULL) || (*zone == NULL)) {
+ log_info("Null argument to repudiate zone");
+ return;
+ }
+
(*zone) -> timeout = cur_time - 1;
dns_zone_dereference (zone, MDL);
}
@@ -1319,6 +1325,24 @@ void ddns_interlude(isc_task_t *taskp,
* need to clean up. */
if ((eresult == ISC_R_CANCELED) ||
((ddns_cb->flags & DDNS_ABORT) != 0)) {
+#if defined (DEBUG_DNS_UPDATES)
+ log_info("DDNS: completeing transaction cancellation cb=%p, "
+ "flags=%x, %s",
+ ddns_cb, ddns_cb->flags, isc_result_totext(eresult));
+#endif
+ if ((ddns_cb->flags & DDNS_ABORT) == 0) {
+ log_info("DDNS: cleaning up lease pointer for a cancel "
+ "cb=%p", ddns_cb);
+ /*
+ * We shouldn't actually be able to get here but
+ * we are. This means we haven't cleaned up
+ * the lease pointer so we need to do that before
+ * freeing the cb.
+ */
+ ddns_cb->cur_func(ddns_cb, eresult);
+ return;
+ }
+
if (ddns_cb->next_op != NULL) {
/* if necessary cleanup up next op block */
ddns_cb_free(ddns_cb->next_op, MDL);
@@ -1333,6 +1357,8 @@ void ddns_interlude(isc_task_t *taskp,
int i;
/* Our zone information was questionable,
* repudiate it and try again */
+ log_error("DDNS: bad zone information, repudiating zone %s",
+ ddns_cb->zone_name);
repudiate_zone(&ddns_cb->zone);
ddns_cb->zone_name[0] = 0;
ISC_LIST_INIT(ddns_cb->zone_server_list);
@@ -1340,20 +1366,18 @@ void ddns_interlude(isc_task_t *taskp,
ISC_LINK_INIT(&ddns_cb->zone_addrs[i], link);
}
- if ((ddns_cb->state &
- (DDNS_STATE_ADD_PTR | DDNS_STATE_REM_PTR)) != 0) {
- result = ddns_modify_ptr(ddns_cb);
+ if ((ddns_cb->state == DDNS_STATE_ADD_PTR) ||
+ (ddns_cb->state == DDNS_STATE_REM_PTR)) {
+ result = ddns_modify_ptr(ddns_cb, MDL);
} else {
- result = ddns_modify_fwd(ddns_cb);
+ result = ddns_modify_fwd(ddns_cb, MDL);
}
if (result != ISC_R_SUCCESS) {
- /* if we couldn't redo the query toss it */
- if (ddns_cb->next_op != NULL) {
- /* cleanup up next op block */
- ddns_cb_free(ddns_cb->next_op, MDL);
- }
- ddns_cb_free(ddns_cb, MDL);
+ /* if we couldn't redo the query log it and
+ * let the next function clean it up */
+ log_info("DDNS: Failed to retry after zone failure");
+ ddns_cb->cur_func(ddns_cb, result);
}
return;
} else {
@@ -1371,7 +1395,7 @@ void ddns_interlude(isc_task_t *taskp,
*/
isc_result_t
-ddns_modify_fwd(dhcp_ddns_cb_t *ddns_cb)
+ddns_modify_fwd(dhcp_ddns_cb_t *ddns_cb, const char *file, int line)
{
isc_result_t result;
dns_tsec_t *tsec_key = NULL;
@@ -1541,6 +1565,13 @@ ddns_modify_fwd(dhcp_ddns_cb_t *ddns_cb)
#endif
cleanup:
+#if defined (DEBUG_DNS_UPDATES)
+ if (result != ISC_R_SUCCESS) {
+ log_info("DDNS: %s(%d): error in ddns_modify_fwd %s for %p",
+ file, line, isc_result_totext(result), ddns_cb);
+ }
+#endif
+
if (dataspace != NULL) {
isc_mem_put(dhcp_gbl_ctx.mctx, dataspace,
sizeof(*dataspace) * 4);
@@ -1550,7 +1581,7 @@ ddns_modify_fwd(dhcp_ddns_cb_t *ddns_cb)
isc_result_t
-ddns_modify_ptr(dhcp_ddns_cb_t *ddns_cb)
+ddns_modify_ptr(dhcp_ddns_cb_t *ddns_cb, const char *file, int line)
{
isc_result_t result;
dns_tsec_t *tsec_key = NULL;
@@ -1730,6 +1761,13 @@ ddns_modify_ptr(dhcp_ddns_cb_t *ddns_cb)
#endif
cleanup:
+#if defined (DEBUG_DNS_UPDATES)
+ if (result != ISC_R_SUCCESS) {
+ log_info("DDNS: %s(%d): error in ddns_modify_ptr %s for %p",
+ file, line, isc_result_totext(result), ddns_cb);
+ }
+#endif
+
if (dataspace != NULL) {
isc_mem_put(dhcp_gbl_ctx.mctx, dataspace,
sizeof(*dataspace) * 2);
@@ -1738,13 +1776,18 @@ ddns_modify_ptr(dhcp_ddns_cb_t *ddns_cb)
}
void
-ddns_cancel(dhcp_ddns_cb_t *ddns_cb) {
+ddns_cancel(dhcp_ddns_cb_t *ddns_cb, const char *file, int line) {
ddns_cb->flags |= DDNS_ABORT;
if (ddns_cb->transaction != NULL) {
dns_client_cancelupdate((dns_clientupdatetrans_t *)
ddns_cb->transaction);
}
ddns_cb->lease = NULL;
+
+#if defined (DEBUG_DNS_UPDATES)
+ log_info("DDNS: %s(%d): cancelling transaction for %p",
+ file, line, ddns_cb);
+#endif
}
#endif /* NSUPDATE */
diff --git a/common/execute.c b/common/execute.c
index 9d08207..363ffa6 100644
--- a/common/execute.c
+++ b/common/execute.c
@@ -3,7 +3,8 @@
Support for executable statements. */
/*
- * Copyright (c) 2004-2007,2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2009,2012 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2007 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1998-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
@@ -327,66 +328,66 @@ int execute_statements (result, packet, lease, client_state,
case set_statement:
case define_statement:
if (!scope) {
- log_error ("set %s: no scope",
- r -> data.set.name);
+ log_error("set %s: no scope",
+ r->data.set.name);
status = 0;
break;
}
if (!*scope) {
- if (!binding_scope_allocate (scope, MDL)) {
- log_error ("set %s: can't allocate scope",
- r -> data.set.name);
+ if (!binding_scope_allocate(scope, MDL)) {
+ log_error("set %s: can't allocate scope",
+ r->data.set.name);
status = 0;
break;
}
}
- binding = find_binding (*scope, r -> data.set.name);
+ binding = find_binding(*scope, r->data.set.name);
#if defined (DEBUG_EXPRESSIONS)
- log_debug ("exec: set %s", r -> data.set.name);
+ log_debug("exec: set %s", r->data.set.name);
#endif
- if (!binding) {
- binding = dmalloc (sizeof *binding, MDL);
- if (binding) {
- memset (binding, 0, sizeof *binding);
- binding -> name =
- dmalloc (strlen
- (r -> data.set.name) + 1,
- MDL);
- if (binding -> name) {
- strcpy (binding -> name,
- r -> data.set.name);
- binding -> next = (*scope) -> bindings;
- (*scope) -> bindings = binding;
+ if (binding == NULL) {
+ binding = dmalloc(sizeof(*binding), MDL);
+ if (binding != NULL) {
+ memset(binding, 0, sizeof(*binding));
+ binding->name =
+ dmalloc(strlen
+ (r->data.set.name) + 1,
+ MDL);
+ if (binding->name != NULL) {
+ strcpy(binding->name, r->data.set.name);
+ binding->next = (*scope)->bindings;
+ (*scope)->bindings = binding;
} else {
- dfree (binding, MDL);
- binding = (struct binding *)0;
+ dfree(binding, MDL);
+ binding = NULL;
}
}
}
- if (binding) {
- if (binding -> value)
+ if (binding != NULL) {
+ if (binding->value != NULL)
binding_value_dereference
- (&binding -> value, MDL);
- if (r -> op == set_statement) {
+ (&binding->value, MDL);
+ if (r->op == set_statement) {
status = (evaluate_expression
- (&binding -> value, packet,
+ (&binding->value, packet,
lease, client_state,
in_options, out_options,
- scope, r -> data.set.expr,
+ scope, r->data.set.expr,
MDL));
} else {
if (!(binding_value_allocate
- (&binding -> value, MDL))) {
- dfree (binding, MDL);
- binding = (struct binding *)0;
+ (&binding->value, MDL))) {
+ dfree(binding, MDL);
+ binding = NULL;
}
- if (binding -> value) {
- binding -> value -> type =
- binding_function;
- (fundef_reference
- (&binding -> value -> value.fundef,
- r -> data.set.expr -> data.func,
- MDL));
+ if ((binding != NULL) &&
+ (binding->value != NULL)) {
+ binding->value->type =
+ binding_function;
+ (fundef_reference
+ (&binding->value->value.fundef,
+ r->data.set.expr->data.func,
+ MDL));
}
}
}
diff --git a/common/options.c b/common/options.c
index 80fd8db..e485222 100644
--- a/common/options.c
+++ b/common/options.c
@@ -3,7 +3,7 @@
DHCP options parsing and reassembly. */
/*
- * Copyright (c) 2004-2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
@@ -2361,7 +2361,7 @@ prepare_option_buffer(struct universe *universe, struct buffer *bp,
cleanup:
option_dereference(&option, MDL);
- return 1;
+ return status;
}
static void
@@ -3845,6 +3845,7 @@ do_packet6(struct interface_info *interface, const char *packet,
msg_type = packet[0];
if ((msg_type == DHCPV6_RELAY_FORW) ||
(msg_type == DHCPV6_RELAY_REPL)) {
+ int relaylen = (int)(offsetof(struct dhcpv6_relay_packet, options));
relay = (const struct dhcpv6_relay_packet *)packet;
decoded_packet->dhcpv6_msg_type = relay->msg_type;
@@ -3856,7 +3857,7 @@ do_packet6(struct interface_info *interface, const char *packet,
relay->peer_address, sizeof(relay->peer_address));
if (!parse_option_buffer(decoded_packet->options,
- relay->options, len-sizeof(*relay),
+ relay->options, len - relaylen,
&dhcpv6_universe)) {
/* no logging here, as parse_option_buffer() logs all
cases where it fails */
@@ -3864,6 +3865,7 @@ do_packet6(struct interface_info *interface, const char *packet,
return;
}
} else {
+ int msglen = (int)(offsetof(struct dhcpv6_packet, options));
msg = (const struct dhcpv6_packet *)packet;
decoded_packet->dhcpv6_msg_type = msg->msg_type;
@@ -3873,7 +3875,7 @@ do_packet6(struct interface_info *interface, const char *packet,
sizeof(decoded_packet->dhcpv6_transaction_id));
if (!parse_option_buffer(decoded_packet->options,
- msg->options, len-sizeof(*msg),
+ msg->options, len - msglen,
&dhcpv6_universe)) {
/* no logging here, as parse_option_buffer() logs all
cases where it fails */
diff --git a/common/packet.c b/common/packet.c
index 42bca69..45e96e8 100644
--- a/common/packet.c
+++ b/common/packet.c
@@ -3,7 +3,8 @@
Packet assembly code, originally contributed by Archie Cobbs. */
/*
- * Copyright (c) 2004,2005,2007,2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2009,2012 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004,2005,2007 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
@@ -105,18 +106,25 @@ void assemble_hw_header (interface, buf, bufix, to)
unsigned *bufix;
struct hardware *to;
{
-#if defined (HAVE_TR_SUPPORT)
- if (interface -> hw_address.hbuf [0] == HTYPE_IEEE802)
- assemble_tr_header (interface, buf, bufix, to);
- else
+ switch (interface->hw_address.hbuf[0]) {
+#if defined(HAVE_TR_SUPPORT)
+ case HTYPE_IEEE802:
+ assemble_tr_header(interface, buf, bufix, to);
+ break;
#endif
#if defined (DEC_FDDI)
- if (interface -> hw_address.hbuf [0] == HTYPE_FDDI)
- assemble_fddi_header (interface, buf, bufix, to);
- else
+ case HTYPE_FDDI:
+ assemble_fddi_header(interface, buf, bufix, to);
+ break;
#endif
- assemble_ethernet_header (interface, buf, bufix, to);
-
+ case HTYPE_INFINIBAND:
+ log_error("Attempt to assemble hw header for infiniband");
+ break;
+ case HTYPE_ETHER:
+ default:
+ assemble_ethernet_header(interface, buf, bufix, to);
+ break;
+ }
}
/* UDP header and IP header assembled together for convenience. */
@@ -184,7 +192,9 @@ void assemble_udp_ip_header (interface, buf, bufix,
#ifdef PACKET_DECODING
/* Decode a hardware header... */
-/* XXX currently only supports ethernet; doesn't check for other types. */
+/* Support for ethernet, TR and FDDI
+ * Doesn't support infiniband yet as the supported oses shouldn't get here
+ */
ssize_t decode_hw_header (interface, buf, bufix, from)
struct interface_info *interface;
@@ -192,17 +202,22 @@ ssize_t decode_hw_header (interface, buf, bufix, from)
unsigned bufix;
struct hardware *from;
{
+ switch(interface->hw_address.hbuf[0]) {
#if defined (HAVE_TR_SUPPORT)
- if (interface -> hw_address.hbuf [0] == HTYPE_IEEE802)
- return decode_tr_header (interface, buf, bufix, from);
- else
+ case HTYPE_IEEE802:
+ return (decode_tr_header(interface, buf, bufix, from));
#endif
#if defined (DEC_FDDI)
- if (interface -> hw_address.hbuf [0] == HTYPE_FDDI)
- return decode_fddi_header (interface, buf, bufix, from);
- else
+ case HTYPE_FDDI:
+ return (decode_fddi_header(interface, buf, bufix, from));
#endif
- return decode_ethernet_header (interface, buf, bufix, from);
+ case HTYPE_INFINIBAND:
+ log_error("Attempt to decode hw header for infiniband");
+ return (0);
+ case HTYPE_ETHER:
+ default:
+ return (decode_ethernet_header(interface, buf, bufix, from));
+ }
}
/* UDP header and IP header decoded together for convenience. */
diff --git a/common/parse.c b/common/parse.c
index 61488c1..434085a 100644
--- a/common/parse.c
+++ b/common/parse.c
@@ -3,7 +3,7 @@
Common parser code for dhcpd and dhclient. */
/*
- * Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
@@ -569,7 +569,9 @@ parse_ip_addr_with_subnet(cfile, match)
/*
* hardware-parameter :== HARDWARE hardware-type colon-separated-hex-list SEMI
- * hardware-type :== ETHERNET | TOKEN_RING | TOKEN_FDDI
+ * hardware-type :== ETHERNET | TOKEN_RING | TOKEN_FDDI | INFINIBAND
+ * Note that INFINIBAND may not be useful for some items, such as classification
+ * as the hardware address won't always be available.
*/
void parse_hardware_param (cfile, hardware)
@@ -581,24 +583,27 @@ void parse_hardware_param (cfile, hardware)
unsigned hlen;
unsigned char *t;
- token = next_token (&val, (unsigned *)0, cfile);
+ token = next_token(&val, NULL, cfile);
switch (token) {
case ETHERNET:
- hardware -> hbuf [0] = HTYPE_ETHER;
+ hardware->hbuf[0] = HTYPE_ETHER;
break;
case TOKEN_RING:
- hardware -> hbuf [0] = HTYPE_IEEE802;
+ hardware->hbuf[0] = HTYPE_IEEE802;
break;
case TOKEN_FDDI:
- hardware -> hbuf [0] = HTYPE_FDDI;
+ hardware->hbuf[0] = HTYPE_FDDI;
+ break;
+ case TOKEN_INFINIBAND:
+ hardware->hbuf[0] = HTYPE_INFINIBAND;
break;
default:
- if (!strncmp (val, "unknown-", 8)) {
- hardware -> hbuf [0] = atoi (&val [8]);
+ if (!strncmp(val, "unknown-", 8)) {
+ hardware->hbuf[0] = atoi(&val[8]);
} else {
- parse_warn (cfile,
- "expecting a network hardware type");
- skip_to_semi (cfile);
+ parse_warn(cfile,
+ "expecting a network hardware type");
+ skip_to_semi(cfile);
return;
}
@@ -612,34 +617,33 @@ void parse_hardware_param (cfile, hardware)
that data in the lease file rather than simply failing on such
clients. Yuck. */
hlen = 0;
- token = peek_token (&val, (unsigned *)0, cfile);
+ token = peek_token(&val, NULL, cfile);
if (token == SEMI) {
- hardware -> hlen = 1;
+ hardware->hlen = 1;
goto out;
}
- t = parse_numeric_aggregate (cfile, (unsigned char *)0, &hlen,
- COLON, 16, 8);
- if (!t) {
- hardware -> hlen = 1;
+ t = parse_numeric_aggregate(cfile, NULL, &hlen, COLON, 16, 8);
+ if (t == NULL) {
+ hardware->hlen = 1;
return;
}
- if (hlen + 1 > sizeof hardware -> hbuf) {
- dfree (t, MDL);
- parse_warn (cfile, "hardware address too long");
+ if (hlen + 1 > sizeof(hardware->hbuf)) {
+ dfree(t, MDL);
+ parse_warn(cfile, "hardware address too long");
} else {
- hardware -> hlen = hlen + 1;
- memcpy ((unsigned char *)&hardware -> hbuf [1], t, hlen);
- if (hlen + 1 < sizeof hardware -> hbuf)
- memset (&hardware -> hbuf [hlen + 1], 0,
- (sizeof hardware -> hbuf) - hlen - 1);
- dfree (t, MDL);
+ hardware->hlen = hlen + 1;
+ memcpy((unsigned char *)&hardware->hbuf[1], t, hlen);
+ if (hlen + 1 < sizeof(hardware->hbuf))
+ memset(&hardware->hbuf[hlen + 1], 0,
+ (sizeof(hardware->hbuf)) - hlen - 1);
+ dfree(t, MDL);
}
out:
- token = next_token (&val, (unsigned *)0, cfile);
+ token = next_token(&val, NULL, cfile);
if (token != SEMI) {
- parse_warn (cfile, "expecting semicolon.");
- skip_to_semi (cfile);
+ parse_warn(cfile, "expecting semicolon.");
+ skip_to_semi(cfile);
}
}
@@ -903,7 +907,7 @@ parse_date_core(cfile)
struct parse *cfile;
{
int guess;
- int tzoff, wday, year, mon, mday, hour, min, sec;
+ int tzoff, year, mon, mday, hour, min, sec;
const char *val;
enum dhcp_token token;
static int months[11] = { 31, 59, 90, 120, 151, 181,
@@ -941,7 +945,7 @@ parse_date_core(cfile)
return((TIME)0);
}
token = next_token(&val, NULL, cfile); /* consume day of week */
- wday = atoi(val);
+ /* we are not using this for anything */
/* Year... */
token = peek_token(&val, NULL, cfile);
@@ -3386,11 +3390,10 @@ int parse_boolean_expression (expr, cfile, lose)
int parse_boolean (cfile)
struct parse *cfile;
{
- enum dhcp_token token;
const char *val;
int rv;
- token = next_token (&val, (unsigned *)0, cfile);
+ (void)next_token(&val, NULL, cfile);
if (!strcasecmp (val, "true")
|| !strcasecmp (val, "on"))
rv = 1;
diff --git a/common/print.c b/common/print.c
index e8eac79..d5d0ae0 100644
--- a/common/print.c
+++ b/common/print.c
@@ -3,7 +3,7 @@
Turn data structures into printable text. */
/*
- * Copyright (c) 2009-2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2009-2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2007 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
@@ -479,10 +479,9 @@ char *print_dotted_quads (len, data)
{
static char dq_buf [DQLEN + 1];
int i;
- char *s, *last;
+ char *s;
s = &dq_buf [0];
- last = s;
i = 0;
diff --git a/common/socket.c b/common/socket.c
index a48404b..f95665c 100644
--- a/common/socket.c
+++ b/common/socket.c
@@ -3,7 +3,7 @@
BSD socket interface code... */
/*
- * Copyright (c) 2004-2011 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
* Permission to use, copy, modify, and distribute this software for any
@@ -51,6 +51,7 @@
#include <net/if.h>
#include <sys/sockio.h>
#include <net/if_dl.h>
+#include <sys/dlpi.h>
#endif
#ifdef USE_SOCKET_FALLBACK
@@ -765,7 +766,7 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
struct sockaddr_in *from;
struct hardware *hfrom;
{
-#if !defined(USE_V4_PKTINFO)
+#if !(defined(IP_PKTINFO) && defined(IP_RECVPKTINFO) && defined(USE_V4_PKTINFO))
SOCKLEN_T flen = sizeof *from;
#endif
int result;
@@ -788,7 +789,6 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
struct cmsghdr *cmsg;
struct in_pktinfo *pktinfo;
unsigned int ifindex;
- int found_pktinfo;
/*
* If necessary allocate space for the control message header.
@@ -831,7 +831,7 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
* We set up some space for a "control message". We have
* previously asked the kernel to give us packet
* information (when we initialized the interface), so we
- * should get the destination address from that.
+ * should get the interface index from that.
*/
m.msg_control = control_buf;
m.msg_controllen = control_buf_len;
@@ -842,12 +842,8 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
/*
* If we did read successfully, then we need to loop
* through the control messages we received and
- * find the one with our destination address.
- *
- * We also keep a flag to see if we found it. If we
- * didn't, then we consider this to be an error.
+ * find the one with our inteface index.
*/
- found_pktinfo = 0;
cmsg = CMSG_FIRSTHDR(&m);
while (cmsg != NULL) {
if ((cmsg->cmsg_level == IPPROTO_IP) &&
@@ -861,18 +857,21 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
* the discover code.
*/
memcpy(hfrom->hbuf, &ifindex, sizeof(ifindex));
- found_pktinfo = 1;
+ return (result);
}
cmsg = CMSG_NXTHDR(&m, cmsg);
}
- if (!found_pktinfo) {
- result = -1;
- errno = EIO;
- }
+
+ /*
+ * We didn't find the necessary control message
+ * flag it as an error
+ */
+ result = -1;
+ errno = EIO;
}
#else
- result = recvfrom (interface -> rfdesc, (char *)buf, len, 0,
- (struct sockaddr *)from, &flen);
+ result = recvfrom(interface -> rfdesc, (char *)buf, len, 0,
+ (struct sockaddr *)from, &flen);
#endif /* IP_PKTINFO ... */
#ifdef IGNORE_HOSTUNREACH
} while (result < 0 &&
@@ -880,7 +879,7 @@ ssize_t receive_packet (interface, buf, len, from, hfrom)
errno == ECONNREFUSED) &&
retry++ < 10);
#endif
- return result;
+ return (result);
}
#endif /* USE_SOCKET_RECEIVE */
@@ -897,7 +896,6 @@ receive_packet6(struct interface_info *interface,
int result;
struct cmsghdr *cmsg;
struct in6_pktinfo *pktinfo;
- int found_pktinfo;
/*
* If necessary allocate space for the control message header.
@@ -952,11 +950,7 @@ receive_packet6(struct interface_info *interface,
* If we did read successfully, then we need to loop
* through the control messages we received and
* find the one with our destination address.
- *
- * We also keep a flag to see if we found it. If we
- * didn't, then we consider this to be an error.
*/
- found_pktinfo = 0;
cmsg = CMSG_FIRSTHDR(&m);
while (cmsg != NULL) {
if ((cmsg->cmsg_level == IPPROTO_IPV6) &&
@@ -964,17 +958,21 @@ receive_packet6(struct interface_info *interface,
pktinfo = (struct in6_pktinfo *)CMSG_DATA(cmsg);
*to_addr = pktinfo->ipi6_addr;
*if_idx = pktinfo->ipi6_ifindex;
- found_pktinfo = 1;
+
+ return (result);
}
cmsg = CMSG_NXTHDR(&m, cmsg);
}
- if (!found_pktinfo) {
- result = -1;
- errno = EIO;
- }
+
+ /*
+ * We didn't find the necessary control message
+ * flag is as an error
+ */
+ result = -1;
+ errno = EIO;
}
- return result;
+ return (result);
}
#endif /* DHCPv6 */
@@ -1002,6 +1000,9 @@ isc_result_t fallback_discard (object)
log_error ("fallback_discard: %m");
return ISC_R_UNEXPECTED;
}
+#else
+ /* ignore the fact that status value is never used */
+ IGNORE_UNUSED(status);
#endif
return ISC_R_SUCCESS;
}
@@ -1070,7 +1071,7 @@ void maybe_setup_fallback ()
void
get_hw_addr(const char *name, struct hardware *hw) {
struct sockaddr_dl *dladdrp;
- int rv, sock, i;
+ int sock, i;
struct lifreq lifr;
memset(&lifr, 0, sizeof (lifr));
@@ -1104,7 +1105,8 @@ get_hw_addr(const char *name, struct hardware *hw) {
hw->hlen = sizeof (hw->hbuf);
srandom((long)gethrtime());
- for (i = 0; i < hw->hlen; ++i) {
+ hw->hbuf[0] = HTYPE_IPMP;
+ for (i = 1; i < hw->hlen; ++i) {
hw->hbuf[i] = random() % 256;
}
@@ -1117,8 +1119,27 @@ get_hw_addr(const char *name, struct hardware *hw) {
log_fatal("Couldn't get interface hardware address for %s: %m",
name);
dladdrp = (struct sockaddr_dl *)&lifr.lifr_addr;
- hw->hlen = dladdrp->sdl_alen;
- memcpy(hw->hbuf, LLADDR(dladdrp), hw->hlen);
+ hw->hlen = dladdrp->sdl_alen+1;
+ switch (dladdrp->sdl_type) {
+ case DL_CSMACD: /* IEEE 802.3 */
+ case DL_ETHER:
+ hw->hbuf[0] = HTYPE_ETHER;
+ break;
+ case DL_TPR:
+ hw->hbuf[0] = HTYPE_IEEE802;
+ break;
+ case DL_FDDI:
+ hw->hbuf[0] = HTYPE_FDDI;
+ break;
+ case DL_IB:
+ hw->hbuf[0] = HTYPE_INFINIBAND;
+ break;
+ default:
+ log_fatal("%s: unsupported DLPI MAC type %lu", name,
+ (unsigned long)dladdrp->sdl_type);
+ }
+
+ memcpy(hw->hbuf+1, LLADDR(dladdrp), hw->hlen-1);
if (sock != -1)
(void) close(sock);
diff --git a/common/tables.c b/common/tables.c
index 10e2ce0..c820d83 100644
--- a/common/tables.c
+++ b/common/tables.c
@@ -3,6 +3,7 @@
Tables of information... */
/*
+ * Copyright (c) 2011-2012 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 2004-2009 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-2003 by Internet Software Consortium
*
@@ -601,7 +602,7 @@ const char *hardware_types [] = {
"unknown-29",
"unknown-30",
"unknown-31",
- "unknown-32",
+ "infiniband",
"unknown-33",
"unknown-34",
"unknown-35",