Don't special case DS_ARP_CHECK in nfrelease().
This commit is contained in:
parent
76ecfffce2
commit
6ea5ac0d5d
@ -85,7 +85,7 @@ out:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void arp_close_fd(struct client_state_t *cs)
|
void arp_close_fd(struct client_state_t *cs)
|
||||||
{
|
{
|
||||||
if (cs->arpFd == -1)
|
if (cs->arpFd == -1)
|
||||||
return;
|
return;
|
||||||
|
@ -49,6 +49,7 @@ struct arpMsg {
|
|||||||
uint8_t pad[18]; /* 2a pad for min. ethernet payload (60 bytes) */
|
uint8_t pad[18]; /* 2a pad for min. ethernet payload (60 bytes) */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void arp_close_fd(struct client_state_t *cs);
|
||||||
int arp_check(struct client_state_t *cs, struct dhcpmsg *packet);
|
int arp_check(struct client_state_t *cs, struct dhcpmsg *packet);
|
||||||
int arp_gw_check(struct client_state_t *cs);
|
int arp_gw_check(struct client_state_t *cs);
|
||||||
int arp_get_gw_hwaddr(struct client_state_t *cs);
|
int arp_get_gw_hwaddr(struct client_state_t *cs);
|
||||||
|
19
ndhc/state.c
19
ndhc/state.c
@ -23,6 +23,7 @@ static void renewing_timeout(struct client_state_t *cs);
|
|||||||
static void rebinding_timeout(struct client_state_t *cs);
|
static void rebinding_timeout(struct client_state_t *cs);
|
||||||
static void renew_requested_timeout(struct client_state_t *cs);
|
static void renew_requested_timeout(struct client_state_t *cs);
|
||||||
static void released_timeout(struct client_state_t *cs);
|
static void released_timeout(struct client_state_t *cs);
|
||||||
|
static void anfrelease(struct client_state_t *cs);
|
||||||
static void nfrelease(struct client_state_t *cs);
|
static void nfrelease(struct client_state_t *cs);
|
||||||
static void frelease(struct client_state_t *cs);
|
static void frelease(struct client_state_t *cs);
|
||||||
static void frenew(struct client_state_t *cs);
|
static void frenew(struct client_state_t *cs);
|
||||||
@ -43,7 +44,7 @@ dhcp_state_t dhcp_states[] = {
|
|||||||
{ an_packet, renewing_timeout, frenew, nfrelease}, // RENEWING
|
{ an_packet, renewing_timeout, frenew, nfrelease}, // RENEWING
|
||||||
{ an_packet, rebinding_timeout, frenew, nfrelease}, // REBINDING
|
{ an_packet, rebinding_timeout, frenew, nfrelease}, // REBINDING
|
||||||
{ 0, arp_gw_failed, frenew, frelease}, // ARP_GW_CHECK XXX
|
{ 0, arp_gw_failed, frenew, frelease}, // ARP_GW_CHECK XXX
|
||||||
{ 0, arp_success, frenew, nfrelease}, // ARP_CHECK
|
{ 0, arp_success, frenew, anfrelease}, // ARP_CHECK
|
||||||
{ an_packet, renew_requested_timeout, frenew, frelease}, // RENEW_REQUESTED
|
{ an_packet, renew_requested_timeout, frenew, frelease}, // RENEW_REQUESTED
|
||||||
{ 0, released_timeout, frenew, frelease}, // RELEASED
|
{ 0, released_timeout, frenew, frelease}, // RELEASED
|
||||||
{ 0, 0, 0, 0}, // NUM_STATES
|
{ 0, 0, 0, 0}, // NUM_STATES
|
||||||
@ -228,12 +229,17 @@ static void selecting_timeout(struct client_state_t *cs)
|
|||||||
}
|
}
|
||||||
#undef DELAY_SEC
|
#undef DELAY_SEC
|
||||||
|
|
||||||
|
static void anfrelease(struct client_state_t *cs)
|
||||||
|
{
|
||||||
|
arp_close_fd(cs);
|
||||||
|
nfrelease(cs);
|
||||||
|
}
|
||||||
|
|
||||||
static void nfrelease(struct client_state_t *cs)
|
static void nfrelease(struct client_state_t *cs)
|
||||||
{
|
{
|
||||||
struct in_addr temp_saddr = { .s_addr = cs->serverAddr };
|
|
||||||
struct in_addr temp_raddr = { .s_addr = cs->requestedIP };
|
|
||||||
log_line("Unicasting a release of %s to %s.",
|
log_line("Unicasting a release of %s to %s.",
|
||||||
inet_ntoa(temp_raddr), inet_ntoa(temp_saddr));
|
inet_ntoa((struct in_addr){.s_addr=cs->requestedIP}),
|
||||||
|
inet_ntoa((struct in_addr){.s_addr=cs->serverAddr}));
|
||||||
send_release(cs->serverAddr, cs->requestedIP);
|
send_release(cs->serverAddr, cs->requestedIP);
|
||||||
ifchange(NULL, IFCHANGE_DECONFIG);
|
ifchange(NULL, IFCHANGE_DECONFIG);
|
||||||
frelease(cs);
|
frelease(cs);
|
||||||
@ -242,11 +248,6 @@ static void nfrelease(struct client_state_t *cs)
|
|||||||
static void frelease(struct client_state_t *cs)
|
static void frelease(struct client_state_t *cs)
|
||||||
{
|
{
|
||||||
log_line("Entering released state.");
|
log_line("Entering released state.");
|
||||||
if (cs->dhcpState == DS_ARP_CHECK) {
|
|
||||||
epoll_del(cs, cs->arpFd);
|
|
||||||
close(cs->arpFd);
|
|
||||||
cs->arpFd = -1;
|
|
||||||
}
|
|
||||||
change_listen_mode(cs, LM_NONE);
|
change_listen_mode(cs, LM_NONE);
|
||||||
cs->dhcpState = DS_RELEASED;
|
cs->dhcpState = DS_RELEASED;
|
||||||
cs->timeout = -1;
|
cs->timeout = -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user