void (*modify_request)(struct dhcp_msg *, void *aux),
bool (*validate_offer)(const struct dhcp_msg *, void *aux),
void *aux, struct dhclient **);
+void dhclient_set_max_timeout(struct dhclient *, unsigned int max_timeout);
void dhclient_destroy(struct dhclient *);
struct netdev *dhclient_get_netdev(struct dhclient *);
bool changed;
unsigned int retransmit, delay; /* Used by send_reliably(). */
+ unsigned int max_timeout;
unsigned int init_delay; /* Used by S_INIT. */
cli->ipaddr = 0;
cli->server_ip = 0;
cli->retransmit = cli->delay = 0;
+ cli->max_timeout = 64;
cli->min_timeout = 1;
ds_init(&cli->s);
cli->changed = true;
return 0;
}
+/* Sets the maximum amount of timeout that 'cli' will wait for a reply from
+ * the DHCP server before retransmitting, in seconds, to 'max_timeout'. The
+ * default is 64 seconds. */
+void
+dhclient_set_max_timeout(struct dhclient *cli, unsigned int max_timeout)
+{
+ cli->max_timeout = MAX(2, max_timeout);
+}
+
/* Destroys 'cli' and frees all related resources. */
void
dhclient_destroy(struct dhclient *cli)
cli->modify_request(&msg, cli->aux);
}
do_send_msg(cli, &msg);
- cli->delay = MIN(64, MAX(4, cli->delay * 2));
+ cli->delay = MIN(cli->max_timeout, MAX(4, cli->delay * 2));
cli->retransmit += fuzz(cli->delay, 1);
timeout(cli, cli->retransmit);
dhcp_msg_uninit(&msg);
"discovery disabled: %s", strerror(retval));
return;
}
+ dhclient_set_max_timeout(d->dhcp, 3);
dhclient_init(d->dhcp, 0);
} else {
dhclient_destroy(d->dhcp);