net: Refactor to protect access to the NetState variable
Changes to NetState now go through an accessor function called
net_set_state()
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
diff --git a/net/dns.c b/net/dns.c
index cc7ed51..cc0aa0a 100644
--- a/net/dns.c
+++ b/net/dns.c
@@ -98,7 +98,7 @@
DnsTimeout(void)
{
puts("Timeout\n");
- NetState = NETLOOP_FAIL;
+ net_set_state(NETLOOP_FAIL);
}
static void
@@ -128,7 +128,7 @@
/* Received 0 answers */
if (header->nanswers == 0) {
puts("DNS: host not found\n");
- NetState = NETLOOP_SUCCESS;
+ net_set_state(NETLOOP_SUCCESS);
return;
}
@@ -141,7 +141,7 @@
/* We sent query class 1, query type 1 */
if (&p[5] > e || get_unaligned_be16(p+1) != DNS_A_RECORD) {
puts("DNS: response was not an A record\n");
- NetState = NETLOOP_SUCCESS;
+ net_set_state(NETLOOP_SUCCESS);
return;
}
@@ -191,7 +191,7 @@
puts("server responded with invalid IP number\n");
}
- NetState = NETLOOP_SUCCESS;
+ net_set_state(NETLOOP_SUCCESS);
}
void