summaryrefslogtreecommitdiffstats
path: root/net/dns.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/dns.c')
-rw-r--r--net/dns.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/net/dns.c b/net/dns.c
index 4516235..ffe98ef 100644
--- a/net/dns.c
+++ b/net/dns.c
@@ -258,15 +258,26 @@ static int do_host(int argc, char *argv[])
{
IPaddr_t ip;
int ret;
+ char *hostname, *varname = NULL;
- if (argc != 2)
+ if (argc < 2)
return COMMAND_ERROR_USAGE;
+ hostname = argv[1];
+
+ if (argc > 2)
+ varname = argv[2];
+
ret = resolv(argv[1], &ip);
- if (ret)
- printf("unknown host %s\n", argv[1]);
+ if (ret) {
+ printf("unknown host %s\n", hostname);
+ return 1;
+ }
+
+ if (varname)
+ setenv_ip(varname, ip);
else
- printf("%s is at %pI4\n", argv[1], &ip);
+ printf("%s is at %pI4\n", hostname, &ip);
return 0;
}
@@ -274,7 +285,7 @@ static int do_host(int argc, char *argv[])
BAREBOX_CMD_START(host)
.cmd = do_host,
BAREBOX_CMD_DESC("resolve a hostname")
- BAREBOX_CMD_OPTS("HOSTNAME")
+ BAREBOX_CMD_OPTS("<HOSTNAME> [VARIABLE]")
BAREBOX_CMD_GROUP(CMD_GRP_NET)
BAREBOX_CMD_END
#endif