Skip to content
Snippets Groups Projects
Commit 78d3f280 authored by Alessandro Rubini's avatar Alessandro Rubini
Browse files

lib/ipv4: bootp requests once a second, no count-based


Signed-off-by: default avatarAlessandro Rubini <rubini@gnudd.com>
parent 7bab5d84
Branches
Tags
No related merge requests found
......@@ -53,7 +53,7 @@ void ipv4_init(void)
}
static int bootp_retry = 0;
static int bootp_timer = 0;
static uint32_t bootp_tics;
void ipv4_poll(void)
{
......@@ -61,6 +61,10 @@ void ipv4_poll(void)
wr_sockaddr_t addr;
int len;
if (!bootp_tics)
bootp_tics = timer_get_tics() - 1;
if ((len = ptpd_netif_recvfrom(ipv4_socket, &addr,
buf, sizeof(buf), 0)) > 0) {
if (needIP)
......@@ -70,16 +74,15 @@ void ipv4_poll(void)
ptpd_netif_sendto(ipv4_socket, &addr, buf, len, 0);
}
if (needIP && bootp_timer == 0) {
if (needIP && time_after(timer_get_tics(), bootp_tics)) {
len = send_bootp(buf, ++bootp_retry);
memset(addr.mac, 0xFF, 6);
addr.ethertype = htons(0x0800); /* IPv4 */
ptpd_netif_sendto(ipv4_socket, &addr, buf, len, 0);
bootp_tics = timer_get_tics() + TICS_PER_SECOND;
}
if (needIP && ++bootp_timer == 100000)
bootp_timer = 0;
}
void getIP(unsigned char *IP)
......@@ -100,8 +103,6 @@ void setIP(unsigned char *IP)
*eb_ip = ip;
needIP = (ip == 0);
if (!needIP) {
if (!needIP)
bootp_retry = 0;
bootp_timer = 0;
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment