summaryrefslogtreecommitdiff
path: root/common/cmd_net.c
diff options
context:
space:
mode:
authorWolfgang Denk <wd@denx.de>2009-07-23 19:20:26 +0200
committerWolfgang Denk <wd@denx.de>2009-07-23 19:20:26 +0200
commit4fb799aeafa71c4e6caacd3acdc4a4547cfbd5d4 (patch)
tree6c49be563c2bcf3d24af9279493a054b613999ff /common/cmd_net.c
parentb201171f2b4d509f3ad510b214bee70ff902e3d6 (diff)
parent97cfe86163505ea18e7ff7b71e78df5bb03dad57 (diff)
downloadu-boot-imx-4fb799aeafa71c4e6caacd3acdc4a4547cfbd5d4.zip
u-boot-imx-4fb799aeafa71c4e6caacd3acdc4a4547cfbd5d4.tar.gz
u-boot-imx-4fb799aeafa71c4e6caacd3acdc4a4547cfbd5d4.tar.bz2
Merge branch 'master' of git://git.denx.de/u-boot-net
Diffstat (limited to 'common/cmd_net.c')
-rw-r--r--common/cmd_net.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/common/cmd_net.c b/common/cmd_net.c
index 68183c4..ac706ae 100644
--- a/common/cmd_net.c
+++ b/common/cmd_net.c
@@ -353,3 +353,52 @@ U_BOOT_CMD(
"[NTP server IP]\n"
);
#endif
+
+#if defined(CONFIG_CMD_DNS)
+int do_dns(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+ if (argc == 1) {
+ cmd_usage(cmdtp);
+ return -1;
+ }
+
+ /*
+ * We should check for a valid hostname:
+ * - Each label must be between 1 and 63 characters long
+ * - the entire hostname has a maximum of 255 characters
+ * - only the ASCII letters 'a' through 'z' (case-insensitive),
+ * the digits '0' through '9', and the hyphen
+ * - cannot begin or end with a hyphen
+ * - no other symbols, punctuation characters, or blank spaces are
+ * permitted
+ * but hey - this is a minimalist implmentation, so only check length
+ * and let the name server deal with things.
+ */
+ if (strlen(argv[1]) >= 255) {
+ printf("dns error: hostname too long\n");
+ return 1;
+ }
+
+ NetDNSResolve = argv[1];
+
+ if (argc == 3)
+ NetDNSenvvar = argv[2];
+ else
+ NetDNSenvvar = NULL;
+
+ if (NetLoop(DNS) < 0) {
+ printf("dns lookup of %s failed, check setup\n", argv[1]);
+ return 1;
+ }
+
+ return 0;
+}
+
+U_BOOT_CMD(
+ dns, 3, 1, do_dns,
+ "lookup the IP of a hostname",
+ "hostname [envvar]"
+);
+
+#endif /* CONFIG_CMD_DNS */
+