struct interface *iface = state->interface;
struct dhcp_lease *lease = &state->lease;
struct in_addr addr;
- struct in_addr net;
size_t duid_len = 0;
#ifdef ENABLE_DUID
unsigned char *duid = NULL;
lease->net.s_addr = options->request_netmask.s_addr;
}
+ /* If INFORMing, ensure the interface has the address */
+ if (state->options & DHCPCD_INFORM &&
+ has_address(iface->name, &lease->addr, &lease->net) < 1)
+ {
+ addr.s_addr = lease->addr.s_addr | ~lease->net.s_addr;
+ logger(LOG_DEBUG, "adding IP address %s/%d",
+ inet_ntoa(lease->addr), inet_ntocidr(lease->net));
+ if (add_address(iface->name, &lease->addr,
+ &lease->net, &addr) == -1)
+ {
+ logger(LOG_ERR, "add_address: %s", strerror(errno));
+ return -1;
+ }
+ iface->addr.s_addr = lease->addr.s_addr;
+ iface->net.s_addr = lease->net.s_addr;
+ }
+
if (*options->clientid) {
/* Attempt to see if the ClientID is a hardware address */
iface->clientid_len = hwaddr_aton(NULL, options->clientid);
}
}
- /* Remove all existing addresses.
- * After all, we ARE a DHCP client whose job it is to configure the
- * interface. We only do this on start, so persistent addresses
- * can be added afterwards by the user if needed. */
- if (!(options->options & DHCPCD_TEST) &&
- !(options->options & DHCPCD_DAEMONISED))
- {
- if (!(options->options & DHCPCD_INFORM)) {
- while (get_address(iface->name, &addr, &net) == 1) {
- logger(LOG_DEBUG, "deleting IP address %s/%d",
- inet_ntoa(addr),
- inet_ntocidr(net));
- if (del_address(iface->name, &addr, &net) == -1)
- {
- logger(LOG_ERR, "delete_address: %s",
- strerror(errno));
- break;
- }
- }
- } else if (has_address(iface->name,
- &lease->addr, &lease->net) < 1)
- {
- /* The inform address HAS to be configured for it to
- * work with most DHCP servers */
- /* add_address */
- addr.s_addr = lease->addr.s_addr | ~lease->net.s_addr;
- logger(LOG_DEBUG, "adding IP address %s/%d",
- inet_ntoa(lease->addr),
- inet_ntocidr(lease->net));
- if (add_address(iface->name, &lease->addr,
- &lease->net, &addr) == -1)
- {
- logger(LOG_ERR, "add_address: %s",
- strerror(errno));
- return -1;
- }
- iface->addr.s_addr = lease->addr.s_addr;
- iface->net.s_addr = lease->net.s_addr;
- }
- }
-
return 0;
}
switch (sig) {
case SIGINT:
logger(LOG_INFO, "received SIGINT, stopping");
- drop_config(state, "STOP", options);
+ if (!(state->options & DHCPCD_PERSISTENT))
+ drop_config(state, "STOP", options);
return -1;
case SIGTERM:
logger(LOG_INFO, "received SIGTERM, stopping");
- drop_config(state, "STOP", options);
+ if (!(state->options & DHCPCD_PERSISTENT))
+ drop_config(state, "STOP", options);
return -1;
case SIGALRM:
lease->addr.s_addr = options->request_address.s_addr;
else
lease->addr.s_addr = iface->addr.s_addr;
-
logger(LOG_INFO, "received approval for %s",
inet_ntoa(lease->addr));
- state->timeout = options->leasetime;
- if (state->timeout == 0)
- state->timeout = DEFAULT_LEASETIME;
- state->state = STATE_INIT;
+ state->state = STATE_BOUND;
+ state->lease.leasetime = ~0U;
reason = "INFORM";
} else if (IN_LINKLOCAL(htonl(lease->addr.s_addr))) {
if (lease->addr.s_addr != iface->addr.s_addr)
case STATE_REQUESTING:
case STATE_RENEWING:
case STATE_REBINDING:
- saddr.s_addr = dhcp->yiaddr;
- logger(LOG_INFO, "lease of %s acknowledged",
- inet_ntoa(saddr));
+ if (!(state->options & DHCPCD_INFORM)) {
+ saddr.s_addr = dhcp->yiaddr;
+ logger(LOG_INFO, "lease of %s acknowledged",
+ inet_ntoa(saddr));
+ }
break;
default:
logger(LOG_ERR, "wrong state %d", state->state);
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd Jun 07, 2008
+.Dd Jun 11, 2008
.Dt DHCPCD 8 SMM
.Sh NAME
.Nm dhcpcd
Once obtained it will probe every 10 seconds for a DHCP server to get a
proper address.
.Pp
-Even when
-.Nm
-obtains a proper lease, it will still add a Local Link route
-.Po
-165.254.0.0/16
-.Pc
-so that the host can communicate with clients using these addresses.
-.Pp
When using IPv4LL,
.Nm
will always succeed and return a 0 exit code. To disable this behaviour, you
.It Fl i , -classid Ar classid
Override the DHCP vendor
.Ar classid
-field we send. The default is
+field sent. The default is
dhcpcd <version>.
If not set then none is sent.
.It Fl k , -release
In this situation, we go back to the init state and broadcast again.
If no
.Ar address
-is given then we use the first address currently assigned to the
-.Ar interface .
+is given then the first address currently assigned to the
+.Ar interface
+is used.
.It Fl s , -inform Op Ar address Ns Op Ar /cidr
Behaves exactly like
.Fl r , -request
as above, but sends a DHCP INFORM instead of a REQUEST.
This does not get a lease as such, just notifies the DHCP server of the
.Ar address
-we are using.
-If we fail to contact a DHCP server then we return a failure instead of falling
+in use.
+.Nm
+remains running and pretends it has an infinite lease.
+.Nm
+will not de-configure the interface when it exits.
+If
+.Nm
+fails to contact a DHCP server then it returns a failure instead of falling
back on IPv4LL.
.It Fl t , -timeout Ar seconds
Timeout after
.It Fl E , -lastlease
If
.Nm
-cannot obtain a lease, then try to use the last lease we got for the interface.
+cannot obtain a lease, then try to use the last lease acquired for the
+interface.
If the
.Fl p, -persistent
-option is not given then we only use the lease if it hasn't expired.
+option is not given then the lease is used if it hasn't expired.
.It Fl F , -fqdn Ar fqdn
Requests that the DHCP server updates DNS using FQDN instead of just a
hostname.
If no option given, then don't request any options other than those to
configure the interface and routing.
.It Fl T, -test
-On receipt of discover messages we just call
+On receipt of OFFER messages just call
.Pa @SCRIPT@
with the reason of TEST which echo's the DHCP variables found in the message
to the console.
.It Pa @SYSCONFDIR@/dhcpcd.duid
Text file that holds the DUID used to identify the host.
.It Pa @SCRIPT@
-Bourne shell script that is run when we configure or deconfigure an interface.
+Bourne shell script that is run to configure or deconfigure an interface.
.It Pa @HOOKDIR@
A directory containing bourne shell scripts that are run by the above script.
Each script can be disabled by using the