"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/dhcp.c" between
dhcpcd-7.1.0.tar.xz and dhcpcd-7.1.1.tar.xz

About: dhcpcd is a RFC2131 compliant DHCP (Dynamic Host Configuration Protocol) client.

dhcp.c  (dhcpcd-7.1.0.tar.xz):dhcp.c  (dhcpcd-7.1.1.tar.xz)
skipping to change at line 1767 skipping to change at line 1767
struct if_options *ifo = ifp->options; struct if_options *ifo = ifp->options;
struct bootp *bootp; struct bootp *bootp;
struct bootp_pkt *udp; struct bootp_pkt *udp;
size_t len, ulen; size_t len, ulen;
ssize_t r; ssize_t r;
struct in_addr from, to; struct in_addr from, to;
struct timespec tv; struct timespec tv;
if (!callback) { if (!callback) {
/* No carrier? Don't bother sending the packet. */ /* No carrier? Don't bother sending the packet. */
if (ifp->carrier == LINK_DOWN) if (ifp->carrier <= LINK_DOWN)
return; return;
logdebugx("%s: sending %s with xid 0x%x", logdebugx("%s: sending %s with xid 0x%x",
ifp->name, ifp->name,
ifo->options & DHCPCD_BOOTP ? "BOOTP" : get_dhcp_op(type), ifo->options & DHCPCD_BOOTP ? "BOOTP" : get_dhcp_op(type),
state->xid); state->xid);
} else { } else {
if (state->interval == 0) if (state->interval == 0)
state->interval = 4; state->interval = 4;
else { else {
state->interval *= 2; state->interval *= 2;
if (state->interval > 64) if (state->interval > 64)
state->interval = 64; state->interval = 64;
} }
tv.tv_sec = state->interval + DHCP_RAND_MIN; tv.tv_sec = state->interval + DHCP_RAND_MIN;
tv.tv_nsec = (suseconds_t)arc4random_uniform( tv.tv_nsec = (suseconds_t)arc4random_uniform(
(DHCP_RAND_MAX - DHCP_RAND_MIN) * NSEC_PER_SEC); (DHCP_RAND_MAX - DHCP_RAND_MIN) * NSEC_PER_SEC);
timespecnorm(&tv); timespecnorm(&tv);
/* No carrier? Don't bother sending the packet. /* No carrier? Don't bother sending the packet.
* However, we do need to advance the timeout. */ * However, we do need to advance the timeout. */
if (ifp->carrier == LINK_DOWN) if (ifp->carrier <= LINK_DOWN)
goto fail; goto fail;
logdebugx("%s: sending %s (xid 0x%x), next in %0.1f seconds", logdebugx("%s: sending %s (xid 0x%x), next in %0.1f seconds",
ifp->name, ifp->name,
ifo->options & DHCPCD_BOOTP ? "BOOTP" : get_dhcp_op(type), ifo->options & DHCPCD_BOOTP ? "BOOTP" : get_dhcp_op(type),
state->xid, state->xid,
timespec_to_double(&tv)); timespec_to_double(&tv));
} }
r = make_message(&bootp, ifp, type); r = make_message(&bootp, ifp, type);
if (r == -1) if (r == -1)
skipping to change at line 1968 skipping to change at line 1968
static void static void
dhcp_expire1(struct interface *ifp) dhcp_expire1(struct interface *ifp)
{ {
struct dhcp_state *state = D_STATE(ifp); struct dhcp_state *state = D_STATE(ifp);
eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp);
dhcp_drop(ifp, "EXPIRE"); dhcp_drop(ifp, "EXPIRE");
unlink(state->leasefile); unlink(state->leasefile);
state->interval = 0; state->interval = 0;
if (!(ifp->options->options & DHCPCD_LINK) || ifp->carrier != LINK_DOWN) if (!(ifp->options->options & DHCPCD_LINK) || ifp->carrier > LINK_DOWN)
dhcp_discover(ifp); dhcp_discover(ifp);
} }
static void static void
dhcp_expire(void *arg) dhcp_expire(void *arg)
{ {
struct interface *ifp = arg; struct interface *ifp = arg;
logerrx("%s: DHCP lease expired", ifp->name); logerrx("%s: DHCP lease expired", ifp->name);
if (ifp->options->options & DHCPCD_LASTLEASE_EXTEND) { if (ifp->options->options & DHCPCD_LASTLEASE_EXTEND) {
skipping to change at line 2604 skipping to change at line 2604
#ifdef ARP #ifdef ARP
struct ipv4_addr *ia; struct ipv4_addr *ia;
#endif #endif
if (state == NULL || state->state == DHS_NONE) if (state == NULL || state->state == DHS_NONE)
return; return;
ifo = ifp->options; ifo = ifp->options;
state->state = DHS_REBOOT; state->state = DHS_REBOOT;
state->interval = 0; state->interval = 0;
if (ifo->options & DHCPCD_LINK && ifp->carrier == LINK_DOWN) { if (ifo->options & DHCPCD_LINK && ifp->carrier <= LINK_DOWN) {
loginfox("%s: waiting for carrier", ifp->name); loginfox("%s: waiting for carrier", ifp->name);
return; return;
} }
if (ifo->options & DHCPCD_STATIC) { if (ifo->options & DHCPCD_STATIC) {
dhcp_static(ifp); dhcp_static(ifp);
return; return;
} }
if (ifo->options & DHCPCD_INFORM) { if (ifo->options & DHCPCD_INFORM) {
loginfox("%s: informing address of %s", loginfox("%s: informing address of %s",
ifp->name, inet_ntoa(state->lease.addr)); ifp->name, inet_ntoa(state->lease.addr));
skipping to change at line 2694 skipping to change at line 2694
if (ifp->options->options & DHCPCD_RELEASE && if (ifp->options->options & DHCPCD_RELEASE &&
!(ifp->options->options & DHCPCD_INFORM)) !(ifp->options->options & DHCPCD_INFORM))
{ {
/* Failure to send the release may cause this function to /* Failure to send the release may cause this function to
* re-enter so guard by setting the state. */ * re-enter so guard by setting the state. */
if (state->state == DHS_RELEASE) if (state->state == DHS_RELEASE)
return; return;
state->state = DHS_RELEASE; state->state = DHS_RELEASE;
unlink(state->leasefile); unlink(state->leasefile);
if (ifp->carrier != LINK_DOWN && if (ifp->carrier > LINK_DOWN &&
state->new != NULL && state->new != NULL &&
state->lease.server.s_addr != INADDR_ANY) state->lease.server.s_addr != INADDR_ANY)
{ {
loginfox("%s: releasing lease of %s", loginfox("%s: releasing lease of %s",
ifp->name, inet_ntoa(state->lease.addr)); ifp->name, inet_ntoa(state->lease.addr));
dhcp_new_xid(ifp); dhcp_new_xid(ifp);
send_message(ifp, DHCP_RELEASE, NULL); send_message(ifp, DHCP_RELEASE, NULL);
#ifdef RELEASE_SLOW #ifdef RELEASE_SLOW
/* Give the packet a chance to go */ /* Give the packet a chance to go */
ts.tv_sec = RELEASE_DELAY_S; ts.tv_sec = RELEASE_DELAY_S;
 End of changes. 5 change blocks. 
5 lines changed or deleted 5 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)