mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-02 09:46:37 +03:00
net: lwip: dns: Call env_set() from dns loop instead of found callback
The lwIP dns command handle env_set() calls from the found callback and printf() to console in the dns loop. Making it more complex than it needs to be. Simplify and ensure any environment variable that is being set is the same value that would have been printed on console. There should not be any intended change in behavior, besides the change from using ip4addr helper to using version less ipaddr helper. Signed-off-by: Jonas Karlman <jonas@kwiboo.se> Reviewed-by: Jerome Forissier <jerome.forissier@arm.com>
This commit is contained in:
committed by
Jerome Forissier
parent
f3b600efb3
commit
3299bffc7c
@@ -14,7 +14,6 @@
|
||||
|
||||
struct dns_cb_arg {
|
||||
ip_addr_t host_ipaddr;
|
||||
const char *var;
|
||||
bool done;
|
||||
};
|
||||
|
||||
@@ -26,7 +25,6 @@ static void do_dns_tmr(void *arg)
|
||||
static void dns_cb(const char *name, const ip_addr_t *ipaddr, void *arg)
|
||||
{
|
||||
struct dns_cb_arg *dns_cb_arg = arg;
|
||||
char *ipstr = ip4addr_ntoa(ipaddr);
|
||||
|
||||
dns_cb_arg->done = true;
|
||||
|
||||
@@ -37,21 +35,17 @@ static void dns_cb(const char *name, const ip_addr_t *ipaddr, void *arg)
|
||||
}
|
||||
|
||||
dns_cb_arg->host_ipaddr.addr = ipaddr->addr;
|
||||
|
||||
if (dns_cb_arg->var)
|
||||
env_set(dns_cb_arg->var, ipstr);
|
||||
}
|
||||
|
||||
static int dns_loop(struct udevice *udev, const char *name, const char *var)
|
||||
{
|
||||
struct dns_cb_arg dns_cb_arg = { };
|
||||
struct netif *netif;
|
||||
const char *ipstr;
|
||||
ip_addr_t ipaddr;
|
||||
ulong start;
|
||||
int ret;
|
||||
|
||||
dns_cb_arg.var = var;
|
||||
|
||||
netif = net_lwip_new_netif(udev);
|
||||
if (!netif)
|
||||
return CMD_RET_FAILURE;
|
||||
@@ -85,8 +79,11 @@ static int dns_loop(struct udevice *udev, const char *name, const char *var)
|
||||
net_lwip_remove_netif(netif);
|
||||
|
||||
if (dns_cb_arg.done && dns_cb_arg.host_ipaddr.addr != 0) {
|
||||
if (!var)
|
||||
printf("%s\n", ipaddr_ntoa(&dns_cb_arg.host_ipaddr));
|
||||
ipstr = ipaddr_ntoa(&dns_cb_arg.host_ipaddr);
|
||||
if (var)
|
||||
env_set(var, ipstr);
|
||||
else
|
||||
printf("%s\n", ipstr);
|
||||
return CMD_RET_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user