/*
- * Copyright (C) 2006-2007,2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2006-2017 by Internet Systems Consortium, Inc. ("ISC")
*
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
u_int32_t time_rebinding;
u_int32_t time_expiry;
u_int32_t client_last_transaction_time;
+#if defined(RELAY_PORT)
+ u_int16_t relay_port = 0;
+#endif
struct sockaddr_in to;
struct in_addr siaddr;
struct data_string prl;
/*
* We can't reply if there is no giaddr field.
*/
+ /*
+ * Note: this makes DHCPv4-over-DHCPv6 always fail but it should not
+ * really be a problem because it is not a specified use case
+ * (or even one that makes sense).
+ */
if (!packet->raw->giaddr.s_addr) {
log_info("%s: missing giaddr, ciaddr is %s, no reply sent",
msgbuf, inet_ntoa(packet->raw->ciaddr));
return;
}
- execute_statements_in_scope(NULL,
- packet,
- NULL,
- NULL,
- packet->options,
- options,
- &global_scope,
- relay_group,
- NULL);
+ execute_statements_in_scope(NULL, packet, NULL, NULL, packet->options,
+ options, &global_scope, relay_group,
+ NULL, NULL);
for (i=packet->class_count-1; i>=0; i--) {
- execute_statements_in_scope(NULL,
- packet,
- NULL,
- NULL,
- packet->options,
- options,
+ execute_statements_in_scope(NULL, packet, NULL, NULL,
+ packet->options, options,
&global_scope,
packet->classes[i]->group,
- relay_group);
+ relay_group, NULL);
}
/*
(lease_duration / 8);
if (time_renewal > cur_time) {
- if (time_renewal < cur_time)
- time_renewal = 0;
- else
- time_renewal = htonl(time_renewal - cur_time);
+ time_renewal = htonl(time_renewal - cur_time);
if (!add_option(options,
DHO_DHCP_RENEWAL_TIME,
}
if (lease->ends > cur_time) {
- if (time_expiry < cur_time) {
- log_error("Impossible condition at %s:%d.",
- MDL);
-
- option_state_dereference(&options, MDL);
- lease_dereference(&lease, MDL);
- return;
- }
time_expiry = htonl(lease->ends - cur_time);
+
if (!add_option(options,
DHO_DHCP_LEASE_TIME,
&time_expiry,
/*
* Figure out which address to use to send from.
*/
- get_server_source_address(&siaddr, options, packet);
+ get_server_source_address(&siaddr, options, options, packet);
/*
* Set up the option buffer.
#endif
memset(to.sin_zero, 0, sizeof(to.sin_zero));
+#if defined(RELAY_PORT)
+ relay_port = dhcp_check_relayport(packet);
+#endif
+
/*
* Leasequery packets are be sent to the gateway address.
*/
to.sin_addr = packet->raw->giaddr;
if (packet->raw->giaddr.s_addr != htonl(INADDR_LOOPBACK)) {
+#if defined(RELAY_PORT)
+ to.sin_port = relay_port ? relay_port : local_port;
+#else
to.sin_port = local_port;
+#endif
} else {
to.sin_port = remote_port; /* XXXSK: For debugging. */
}
exit:
if (!ret_val) {
- if (lq->client_id.len > 0) {
- data_string_forget(&lq->client_id, MDL);
- }
- if (lq->server_id.len > 0) {
- data_string_forget(&lq->server_id, MDL);
- }
- if (lq->lq_query.len > 0) {
- data_string_forget(&lq->lq_query, MDL);
- }
+ data_string_forget(&lq->client_id, MDL);
+ data_string_forget(&lq->server_id, MDL);
+ data_string_forget(&lq->lq_query, MDL);
}
return ret_val;
}
}
execute_statements_in_scope(NULL, lq.packet, NULL, NULL,
lq.packet->options, lq.reply_opts,
- &global_scope, root_group, NULL);
+ &global_scope, root_group, NULL, NULL);
lq.buf.reply.msg_type = DHCPV6_LEASEQUERY_REPLY;