diff options
author | Joe Hershberger <joe.hershberger@ni.com> | 2015-04-08 01:41:01 -0500 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2015-04-18 11:11:32 -0600 |
commit | 049a95a7759c0e384c1fc7b8575d968d56a33997 (patch) | |
tree | c3d30763163e2e67324ebc8f54d6d84d1d8f9c8a /net/link_local.c | |
parent | 2ea4cfdef64a690ced0af005fd7a581751a3e581 (diff) | |
download | u-boot-049a95a7759c0e384c1fc7b8575d968d56a33997.tar.gz u-boot-049a95a7759c0e384c1fc7b8575d968d56a33997.tar.bz2 u-boot-049a95a7759c0e384c1fc7b8575d968d56a33997.zip |
net: cosmetic: Change IPaddr_t to struct in_addr
This patch is simply clean-up to make the IPv4 type that is used match
what Linux uses. It also attempts to move all variables that are IP
addresses use good naming instead of CamelCase. No functional change.
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'net/link_local.c')
-rw-r--r-- | net/link_local.c | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/net/link_local.c b/net/link_local.c index 4152fae5ba..6d92c555fb 100644 --- a/net/link_local.c +++ b/net/link_local.c @@ -49,7 +49,7 @@ static enum ll_state_t { DISABLED } state = DISABLED; -static IPaddr_t ip; +static struct in_addr ip; static int timeout_ms = -1; static unsigned deadline_ms; static unsigned conflicts; @@ -64,14 +64,16 @@ static void link_local_timeout(void); * Pick a random link local IP address on 169.254/16, except that * the first and last 256 addresses are reserved. */ -static IPaddr_t pick(void) +static struct in_addr pick(void) { unsigned tmp; + struct in_addr ip; do { tmp = rand_r(&seed) & IN_CLASSB_HOST; } while (tmp > (IN_CLASSB_HOST - 0x0200)); - return (IPaddr_t) htonl((LINKLOCAL_ADDR + 0x0100) + tmp); + ip.s_addr = htonl((LINKLOCAL_ADDR + 0x0100) + tmp); + return ip; } /** @@ -102,16 +104,17 @@ static void configure_wait(void) void link_local_start(void) { - ip = getenv_IPaddr("llipaddr"); - if (ip != 0 && (ntohl(ip) & IN_CLASSB_NET) != LINKLOCAL_ADDR) { + ip = getenv_ip("llipaddr"); + if (ip.s_addr != 0 && + (ntohl(ip.s_addr) & IN_CLASSB_NET) != LINKLOCAL_ADDR) { puts("invalid link address"); net_set_state(NETLOOP_FAIL); return; } - NetOurSubnetMask = IN_CLASSB_NET; + net_netmask.s_addr = IN_CLASSB_NET; seed = seed_mac(); - if (ip == 0) + if (ip.s_addr == 0) ip = pick(); state = PROBE; @@ -131,10 +134,12 @@ static void link_local_timeout(void) /* timeouts in the PROBE state mean no conflicting ARP packets have been received, so we can progress through the states */ if (nprobes < PROBE_NUM) { + struct in_addr zero_ip = {.s_addr = 0}; + nprobes++; debug_cond(DEBUG_LL_STATE, "probe/%u %s@%pI4\n", nprobes, eth_get_name(), &ip); - arp_raw_request(0, NetEtherNullAddr, ip); + arp_raw_request(zero_ip, NetEtherNullAddr, ip); timeout_ms = PROBE_MIN * 1000; timeout_ms += random_delay_ms(PROBE_MAX - PROBE_MIN); } else { @@ -172,7 +177,7 @@ static void link_local_timeout(void) /* Switch to monitor state */ state = MONITOR; printf("Successfully assigned %pI4\n", &ip); - NetCopyIP(&NetOurIP, &ip); + net_copy_ip(&net_ip, &ip); ready = 1; conflicts = 0; timeout_ms = -1; @@ -206,7 +211,7 @@ void link_local_receive_arp(struct arp_hdr *arp, int len) { int source_ip_conflict; int target_ip_conflict; - IPaddr_t null_ip = 0; + struct in_addr null_ip = {.s_addr = 0}; if (state == DISABLED) return; @@ -322,7 +327,7 @@ void link_local_receive_arp(struct arp_hdr *arp, int len) state = PROBE; debug("defend conflict -- starting over\n"); ready = 0; - NetOurIP = 0; + net_ip.s_addr = 0; /* restart the whole protocol */ ip = pick(); |