((struct dhcp_state *)(ifp)->if_data[IF_DATA_DHCP])
#define D_CSTATE(ifp) \
((const struct dhcp_state *)(ifp)->if_data[IF_DATA_DHCP])
+#define D_STATE_RUNNING(ifp) \
+ (D_CSTATE((ifp)) && D_CSTATE((ifp))->new && D_CSTATE((ifp))->reason)
#include "dhcpcd.h"
#include "if-options.h"
((struct dhcp6_state *)(ifp)->if_data[IF_DATA_DHCP6])
#define D6_CSTATE(ifp) \
((const struct dhcp6_state *)(ifp)->if_data[IF_DATA_DHCP6])
-#define D6_STATE_RUNNING(ifp) (D6_STATE((ifp)) && D6_STATE((ifp))->new)
+#define D6_STATE_RUNNING(ifp) \
+ (D6_CSTATE((ifp)) && D6_CSTATE((ifp))->new && D6_CSTATE((ifp))->reason)
+
#define D6_FIRST_OPTION(m) \
((struct dhcp6_option *) \
((uint8_t *)(m) + sizeof(struct dhcp6_message)))
if (argc == 1) {
TAILQ_FOREACH(ifp, ctx->ifaces, next) {
len++;
- if (D_STATE(ifp))
+ if (D_STATE_RUNNING(ifp))
len++;
if (D6_STATE_RUNNING(ifp))
len++;
TAILQ_FOREACH(ifp, ctx->ifaces, next) {
if (strcmp(argv[opt], ifp->name) == 0) {
len++;
- if (D_STATE(ifp))
+ if (D_STATE_RUNNING(ifp))
len++;
if (D6_STATE_RUNNING(ifp))
len++;
const char *reason;
int retval = 0;
#ifdef INET
- const struct dhcp_state *d = D_CSTATE(ifp);
+ const struct dhcp_state *d;
#endif
#ifdef INET6
- const struct dhcp6_state *d6 = D6_CSTATE(ifp);
+ const struct dhcp6_state *d6;
#endif
switch (ifp->carrier) {
if (send_interface1(fd, ifp, reason) == -1)
retval = -1;
#ifdef INET
- if (d && d->reason)
+ if (D_STATE_RUNNING(ifp)) {
+ d = D_CSTATE(ifp);
if (send_interface1(fd, ifp, d->reason) == -1)
retval = -1;
+ }
#endif
#ifdef INET6
if (send_interface1(fd, ifp, "ROUTERADVERT") == -1)
retval = -1;
}
- if (D6_STATE_RUNNING(ifp) && d6->reason) {
+ if (D6_STATE_RUNNING(ifp)) {
+ d6 = D6_CSTATE(ifp);
if (send_interface1(fd, ifp, d6->reason) == -1)
retval = -1;
}