+
+#if defined(CONFIG_CMD_DNS)
+int do_dns(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ if (argc == 1)
+ return CMD_RET_USAGE;
+
+ /*
+ * 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 CMD_RET_FAILURE;
+ }
+
+ 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 CMD_RET_FAILURE;
+ }
+
+ return CMD_RET_SUCCESS;
+}
+
+U_BOOT_CMD(
+ dns, 3, 1, do_dns,
+ "lookup the IP of a hostname",
+ "hostname [envvar]"
+);
+
+#endif /* CONFIG_CMD_DNS */
+
+#if defined(CONFIG_CMD_LINK_LOCAL)
+static int do_link_local(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
+{
+ char tmp[22];
+
+ if (NetLoop(LINKLOCAL) < 0)
+ return CMD_RET_FAILURE;
+
+ net_gateway.s_addr = 0;
+ ip_to_string(net_gateway, tmp);
+ setenv("gatewayip", tmp);
+
+ ip_to_string(net_netmask, tmp);
+ setenv("netmask", tmp);
+
+ ip_to_string(net_ip, tmp);
+ setenv("ipaddr", tmp);
+ setenv("llipaddr", tmp); /* store this for next time */
+
+ return CMD_RET_SUCCESS;
+}
+
+U_BOOT_CMD(
+ linklocal, 1, 1, do_link_local,
+ "acquire a network IP address using the link-local protocol",
+ ""
+);
+
+#endif /* CONFIG_CMD_LINK_LOCAL */