+ "Perform CDP network configuration",
+ "\n"
+);
+#endif
+
+#if defined(CONFIG_CMD_SNTP)
+int do_sntp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+ char *toff;
+
+ if (argc < 2) {
+ net_ntp_server = getenv_ip("ntpserverip");
+ if (net_ntp_server.s_addr == 0) {
+ printf("ntpserverip not set\n");
+ return CMD_RET_FAILURE;
+ }
+ } else {
+ net_ntp_server = string_to_ip(argv[1]);
+ if (net_ntp_server.s_addr == 0) {
+ printf("Bad NTP server IP address\n");
+ return CMD_RET_FAILURE;
+ }
+ }
+
+ toff = getenv("timeoffset");
+ if (toff == NULL)
+ NetTimeOffset = 0;
+ else
+ NetTimeOffset = simple_strtol(toff, NULL, 10);
+
+ if (NetLoop(SNTP) < 0) {
+ printf("SNTP failed: host %pI4 not responding\n",
+ &net_ntp_server);
+ return CMD_RET_FAILURE;
+ }
+
+ return CMD_RET_SUCCESS;
+}
+
+U_BOOT_CMD(
+ sntp, 2, 1, do_sntp,
+ "synchronize RTC via network",
+ "[NTP server IP]\n"
+);
+#endif
+
+#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",
+ ""