From ea287debe1980182adbe8c63b71bb82193dad5b7 Mon Sep 17 00:00:00 2001 From: wdenk Date: Fri, 1 Apr 2005 00:25:43 +0000 Subject: * Patch by Masami Komiya, 30 Mar 2005: add SNTP support and expand time server and time offset fields of DHCP support. See doc/README.SNTP * Patch by Steven Scholz, 13 Dec 2004: Fix bug in at91rm920 ethernet driver --- common/cmd_net.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'common') diff --git a/common/cmd_net.c b/common/cmd_net.c index 47f9622..b6d436e 100644 --- a/common/cmd_net.c +++ b/common/cmd_net.c @@ -136,6 +136,19 @@ static void netboot_update_env (void) #endif if (NetOurNISDomain[0]) setenv ("domain", NetOurNISDomain); + +#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_TIMEOFFSET) + if (NetTimeOffset) { + sprintf (tmp, "%d", NetTimeOffset); + setenv ("timeoffset", tmp); + } +#endif +#if (CONFIG_BOOTP_MASK & CONFIG_BOOTP_NTPSERVER) + if (NetNtpServerIP) { + ip_to_string (NetNtpServerIP, tmp); + setenv ("ntpserverip", tmp); + } +#endif } static int @@ -279,4 +292,42 @@ U_BOOT_CMD( ); #endif /* CFG_CMD_CDP */ +#if (CONFIG_COMMANDS & CFG_CMD_SNTP) +int do_sntp (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) +{ + char *toff; + + if (argc < 2) { + NetNtpServerIP = getenv_IPaddr ("ntpserverip"); + if (NetNtpServerIP == 0) { + printf ("ntpserverip not set\n"); + return (1); + } + } else { + NetNtpServerIP = string_to_ip(argv[1]); + if (NetNtpServerIP == 0) { + printf ("Bad NTP server IP address\n"); + return (1); + } + } + + toff = getenv ("timeoffset"); + if (toff == NULL) NetTimeOffset = 0; + else NetTimeOffset = simple_strtol (toff, NULL, 10); + + if (NetLoop(SNTP) < 0) { + printf("SNTP failed: host %s not responding\n", argv[1]); + return 1; + } + + return 0; +} + +U_BOOT_CMD( + sntp, 2, 1, do_sntp, + "sntp\t- synchronize RTC via network\n", + "[NTP server IP]\n" +); +#endif /* CFG_CMD_SNTP */ + #endif /* CFG_CMD_NET */ -- cgit v1.1