9
0
Fork 0

remove sntp support. Has been broken for long enough

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2009-10-13 11:19:28 +02:00
parent 1d73a42006
commit 146f9b6e5b
7 changed files with 1 additions and 186 deletions

View File

@ -75,19 +75,6 @@ void netboot_update_env(void)
#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[])

View File

@ -309,9 +309,6 @@ extern char BootFile[128]; /* Boot File name */
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);

View File

@ -11,10 +11,6 @@ config NET_RARP
bool
prompt "rarp protocol support"
config NET_SNTP
bool
prompt "sntp support"
config NET_NFS
bool
prompt "nfs support"

View File

@ -3,6 +3,5 @@ obj-$(CONFIG_NET) += eth.o
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

View File

@ -375,12 +375,6 @@ static void DhcpOptionsProcess (uchar * popt, Bootp_t *bp)
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 @@ static void DhcpOptionsProcess (uchar * popt, Bootp_t *bp)
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;

View File

@ -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 @@ ushort NetOurNativeVLAN = 0xFFFF; /* ditto */
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 @@ static int net_check_prereq (proto_t protocol)
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 @@ static int net_check_prereq (proto_t protocol)
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;

View File

@ -1,131 +0,0 @@
/*
* SNTP support driver
*
* Masami Komiya <mkomiya@sonare.it> 2005
*
*/
#include <common.h>
#include <command.h>
#include <clock.h>
#include <net.h>
#include <rtc.h>
#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"
);