Update the nk_random calls to use the new re-entrant-safe API.
This commit is contained in:
parent
54a7f54a4a
commit
9bf79b6034
@ -31,6 +31,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <net/if.h>
|
#include <net/if.h>
|
||||||
|
#include "random.h"
|
||||||
|
|
||||||
struct client_state_t {
|
struct client_state_t {
|
||||||
unsigned long long leaseStartTime;
|
unsigned long long leaseStartTime;
|
||||||
@ -42,6 +43,7 @@ struct client_state_t {
|
|||||||
int nlPortId;
|
int nlPortId;
|
||||||
uint32_t clientAddr, serverAddr, routerAddr;
|
uint32_t clientAddr, serverAddr, routerAddr;
|
||||||
uint32_t lease, renewTime, rebindTime, xid;
|
uint32_t lease, renewTime, rebindTime, xid;
|
||||||
|
struct nk_random_state_u32 rnd32_state;
|
||||||
uint8_t routerArp[6], serverArp[6];
|
uint8_t routerArp[6], serverArp[6];
|
||||||
uint8_t using_dhcp_bpf, init, got_router_arp, got_server_arp;
|
uint8_t using_dhcp_bpf, init, got_router_arp, got_server_arp;
|
||||||
};
|
};
|
||||||
|
@ -636,7 +636,8 @@ int send_decline(struct client_state_t *cs, uint32_t server)
|
|||||||
|
|
||||||
int send_release(struct client_state_t *cs)
|
int send_release(struct client_state_t *cs)
|
||||||
{
|
{
|
||||||
struct dhcpmsg packet = init_packet(DHCPRELEASE, nk_random_u32());
|
struct dhcpmsg packet = init_packet(DHCPRELEASE,
|
||||||
|
nk_random_u32(&cs->rnd32_state));
|
||||||
packet.ciaddr = cs->clientAddr;
|
packet.ciaddr = cs->clientAddr;
|
||||||
add_option_reqip(&packet, cs->clientAddr);
|
add_option_reqip(&packet, cs->clientAddr);
|
||||||
add_option_serverid(&packet, cs->serverAddr);
|
add_option_serverid(&packet, cs->serverAddr);
|
||||||
|
@ -533,6 +533,7 @@ int main(int argc, char **argv)
|
|||||||
} else if (ifch_pid > 0) {
|
} else if (ifch_pid > 0) {
|
||||||
close(pToIfchR);
|
close(pToIfchR);
|
||||||
close(pToNdhcW);
|
close(pToNdhcW);
|
||||||
|
nk_random_u32_init(&cs.rnd32_state);
|
||||||
ndhc_main();
|
ndhc_main();
|
||||||
} else {
|
} else {
|
||||||
log_line("FATAL - failed to fork ndhc-ifch: %s", strerror(errno));
|
log_line("FATAL - failed to fork ndhc-ifch: %s", strerror(errno));
|
||||||
|
@ -306,7 +306,7 @@ static void selecting_timeout(struct client_state_t *cs, long long nowts)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (num_dhcp_requests == 0)
|
if (num_dhcp_requests == 0)
|
||||||
cs->xid = nk_random_u32();
|
cs->xid = nk_random_u32(&cs->rnd32_state);
|
||||||
send_discover(cs);
|
send_discover(cs);
|
||||||
dhcp_wake_ts = nowts + delay_timeout(num_dhcp_requests);
|
dhcp_wake_ts = nowts + delay_timeout(num_dhcp_requests);
|
||||||
num_dhcp_requests++;
|
num_dhcp_requests++;
|
||||||
|
Loading…
Reference in New Issue
Block a user