diff --git a/commands/net.c b/commands/net.c index 08eecb4..4bdccd3 100644 --- a/commands/net.c +++ b/commands/net.c @@ -75,19 +75,6 @@ #endif if (NetOurNISDomain[0]) setenv ("domain", NetOurNISDomain); - -#if defined CONFIG_NET_SNTP && defined CONFIG_BOOTP_TIMEOFFSET - if (NetTimeOffset) { - sprintf (tmp, "%d", NetTimeOffset); - setenv ("timeoffset", tmp); - } -#endif -#if defined CONFIG_NET_SNTP && defined CONFIG_BOOTP_NTPSERVER - if (NetNtpServerIP) { - ip_to_string (NetNtpServerIP, tmp); - setenv ("ntpserverip", tmp); - } -#endif } static int do_tftpb (cmd_tbl_t *cmdtp, int argc, char *argv[]) diff --git a/include/net.h b/include/net.h index c09868c..486e3ad 100644 --- a/include/net.h +++ b/include/net.h @@ -309,9 +309,6 @@ extern ushort CDPNativeVLAN; extern ushort CDPApplianceVLAN; -extern IPaddr_t NetNtpServerIP; /* the ip address to NTP */ -extern int NetTimeOffset; /* offset time from UTC */ - /* Initialize the network adapter */ int NetLoopInit(proto_t); diff --git a/net/Kconfig b/net/Kconfig index 841fe51..cca2b00 100644 --- a/net/Kconfig +++ b/net/Kconfig @@ -11,10 +11,6 @@ bool prompt "rarp protocol support" -config NET_SNTP - bool - prompt "sntp support" - config NET_NFS bool prompt "nfs support" diff --git a/net/Makefile b/net/Makefile index df775be..0ffc895 100644 --- a/net/Makefile +++ b/net/Makefile @@ -3,6 +3,5 @@ obj-$(CONFIG_NET) += net.o obj-$(CONFIG_NET_NFS) += nfs.o obj-$(CONFIG_NET_RARP) += rarp.o -obj-$(CONFIG_NET_SNTP) += sntp.o obj-$(CONFIG_NET_TFTP) += tftp.o obj-$(CONFIG_NET_PING) += ping.o diff --git a/net/dhcp.c b/net/dhcp.c index 311e3a9..cc2b78f 100644 --- a/net/dhcp.c +++ b/net/dhcp.c @@ -375,12 +375,6 @@ case 1: NetCopyIP (&NetOurSubnetMask, (popt + 2)); break; -#if defined CONFIG_NET_SNTP && defined CONFIG_BOOTP_TIMEOFFSET - case 2: /* Time offset */ - NetCopyLong (&NetTimeOffset, (ulong *) (popt + 2)); - NetTimeOffset = ntohl (NetTimeOffset); - break; -#endif case 3: NetCopyIP (&NetOurGatewayIP, (popt + 2)); break; @@ -404,11 +398,6 @@ memcpy (&NetOurRootPath, popt + 2, size); NetOurRootPath[size] = 0; break; -#if defined CONFIG_NET_SNTP && defined CONFIG_BOOTP_NTPSERVER - case 42: /* NTP server IP */ - NetCopyIP (&NetNtpServerIP, (popt + 2)); - break; -#endif case 51: NetCopyLong (&dhcp_leasetime, (ulong *) (popt + 2)); break; diff --git a/net/net.c b/net/net.c index db6d575..94b4a40 100644 --- a/net/net.c +++ b/net/net.c @@ -65,12 +65,6 @@ * We want: - load the boot file * Next step: none * - * SNTP: - * - * Prerequisites: - own ethernet address - * - own IP address - * We want: - network time - * Next step: none */ @@ -87,9 +81,6 @@ #include "tftp.h" #include "rarp.h" #include "nfs.h" -#ifdef CONFIG_NET_SNTP -#include "sntp.h" -#endif #define ARP_TIMEOUT (5 * SECOND) /* Seconds before trying ARP again */ #ifndef CONFIG_NET_RETRY_COUNT @@ -135,11 +126,6 @@ char BootFile[128]; /* Boot File name */ -#ifdef CONFIG_NET_SNTP -IPaddr_t NetNtpServerIP; /* NTP server IP address */ -int NetTimeOffset=0; /* offset time from UTC */ -#endif - uchar PktBuf[(PKTBUFSRX+1) * PKTSIZE_ALIGN + PKTALIGN]; uchar *NetRxPackets[PKTBUFSRX]; /* Receive packets */ @@ -779,14 +765,6 @@ switch (protocol) { /* Fall through */ -#ifdef CONFIG_NET_SNTP - case SNTP: - if (NetNtpServerIP == 0) { - puts ("*** ERROR: NTP server address not given\n"); - return -1; - } - goto common; -#endif #ifdef CONFIG_NET_NFS case NFS: #endif @@ -796,7 +774,7 @@ printf("*** ERROR: `%s.serverip' not set\n", dev_id(&edev->dev)); return -1; } -common: + if (NetOurIP == 0) { printf("*** ERROR: `%s.ipaddr' not set\n", dev_id(&edev->dev)); return -1; diff --git a/net/sntp.c b/net/sntp.c deleted file mode 100644 index 8d913dd..0000000 --- a/net/sntp.c +++ /dev/null @@ -1,131 +0,0 @@ -/* - * SNTP support driver - * - * Masami Komiya 2005 - * - */ - -#include -#include -#include -#include -#include - -#include "sntp.h" - -#define SNTP_TIMEOUT 10 - -static int SntpOurPort; - -static void -SntpSend (void) -{ - struct sntp_pkt_t pkt; - int pktlen = SNTP_PACKET_LEN; - int sport; - - debug ("%s\n", __FUNCTION__); - - memset (&pkt, 0, sizeof(pkt)); - - pkt.li = NTP_LI_NOLEAP; - pkt.vn = NTP_VERSION; - pkt.mode = NTP_MODE_CLIENT; - - memcpy ((char *)NetTxPacket + NetEthHdrSize() + IP_HDR_SIZE, (char *)&pkt, pktlen); - - SntpOurPort = 10000 + ((uint32_t)get_time_ns() % 4096); - sport = NTP_SERVICE_PORT; - - NetSendUDPPacket (NetServerEther, NetNtpServerIP, sport, SntpOurPort, pktlen); -} - -static void -SntpTimeout (void) -{ - puts ("Timeout\n"); - NetState = NETLOOP_FAIL; - return; -} - -static void -SntpHandler (uchar *pkt, unsigned dest, unsigned src, unsigned len) -{ - struct sntp_pkt_t *rpktp = (struct sntp_pkt_t *)pkt; - struct rtc_time tm; - ulong seconds; - - debug ("%s\n", __FUNCTION__); - - if (dest != SntpOurPort) return; - - /* - * As the RTC's used in U-Boot sepport second resolution only - * we simply ignore the sub-second field. - */ - memcpy (&seconds, &rpktp->transmit_timestamp, sizeof(ulong)); - - to_tm(ntohl(seconds) - 2208988800UL + NetTimeOffset, &tm); -#if (CONFIG_COMMANDS & CFG_CMD_DATE) - rtc_set (&tm); -#endif - printf ("Date: %4d-%02d-%02d Time: %2d:%02d:%02d\n", - tm.tm_year, tm.tm_mon, tm.tm_mday, - tm.tm_hour, tm.tm_min, tm.tm_sec); - - NetState = NETLOOP_SUCCESS; -} - -void -SntpStart (void) -{ - debug ("%s\n", __FUNCTION__); - - NetSetTimeout (SNTP_TIMEOUT * SECOND, SntpTimeout); - NetSetHandler(SntpHandler); - memset (NetServerEther, 0, 6); - - SntpSend (); -} - -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 (NetLoopInit(SNTP) < 0) - return 1; - - SntpStart(); - - if (NetLoop() < 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" -); -