static NOINLINE void send_offer(struct dhcp_packet *oldpacket,
uint32_t static_lease_nip,
struct dyn_lease *lease,
- uint8_t *requested_ip_opt,
+ uint32_t requested_nip,
unsigned arpping_ms)
{
struct dhcp_packet packet;
/* Else: */
if (!static_lease_nip) {
/* We have no static lease for client's chaddr */
- uint32_t req_nip;
const char *p_host_name;
if (lease) {
packet.yiaddr = lease->lease_nip;
}
/* Or: if client has requested an IP */
- else if (requested_ip_opt != NULL
- /* (read IP) */
- && (move_from_unaligned32(req_nip, requested_ip_opt), 1)
+ else if (requested_nip != 0
/* and the IP is in the lease range */
- && ntohl(req_nip) >= server_config.start_ip
- && ntohl(req_nip) <= server_config.end_ip
+ && ntohl(requested_nip) >= server_config.start_ip
+ && ntohl(requested_nip) <= server_config.end_ip
/* and */
- && ( !(lease = find_lease_by_nip(req_nip)) /* is not already taken */
+ && ( !(lease = find_lease_by_nip(requested_nip)) /* is not already taken */
|| is_expired_lease(lease) /* or is taken, but expired */
)
) {
- packet.yiaddr = req_nip;
+ packet.yiaddr = requested_nip;
}
else {
/* Otherwise, find a free IP */
int tv;
uint8_t *server_id_opt;
uint8_t *requested_ip_opt;
- uint32_t requested_nip = requested_nip; /* for compiler */
+ uint32_t requested_nip;
uint32_t static_lease_nip;
struct dyn_lease *lease, fake_lease;
}
/* Get REQUESTED_IP if present */
+ requested_nip = 0;
requested_ip_opt = udhcp_get_option32(&packet, DHCP_REQUESTED_IP);
if (requested_ip_opt) {
move_from_unaligned32(requested_nip, requested_ip_opt);
case DHCPDISCOVER:
log1("received %s", "DISCOVER");
- send_offer(&packet, static_lease_nip, lease, requested_ip_opt, arpping_ms);
+ send_offer(&packet, static_lease_nip, lease, requested_nip, arpping_ms);
break;
case DHCPREQUEST: