X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=net%2Fnet.c;h=00aa66150295784dc6970f8a6fb5e6a92a9c95b6;hb=59acc296d97b7262b64be8bc23b12c47b4fdd7e6;hp=261f7c187dd95b3ea97a1c9afa21eb2b0965336c;hpb=68ceb29e7133a0f972f53d3d61fd61207374baec;p=u-boot diff --git a/net/net.c b/net/net.c index 261f7c187d..00aa661502 100644 --- a/net/net.c +++ b/net/net.c @@ -64,6 +64,13 @@ * derived from our own IP address) * We want: - load the boot file * Next step: none + * + * SNTP: + * + * Prerequisites: - own ethernet address + * - own IP address + * We want: - network time + * Next step: none */ @@ -79,6 +86,9 @@ #include #include #endif +#if (CONFIG_COMMANDS & CFG_CMD_SNTP) +#include "sntp.h" +#endif #if (CONFIG_COMMANDS & CFG_CMD_NET) @@ -148,6 +158,11 @@ static void PingStart(void); static void CDPStart(void); #endif +#if (CONFIG_COMMANDS & CFG_CMD_SNTP) +IPaddr_t NetNtpServerIP; /* NTP server IP address */ +int NetTimeOffset=0; /* offset time from UTC */ +#endif + #ifdef CONFIG_NETCONSOLE void NcStart(void); int nc_input_packet(uchar *pkt, unsigned dest, unsigned src, unsigned len); @@ -312,6 +327,9 @@ restart: #endif #if (CONFIG_COMMANDS & CFG_CMD_PING) case PING: +#endif +#if (CONFIG_COMMANDS & CFG_CMD_SNTP) + case SNTP: #endif case NETCONS: case TFTP: @@ -333,6 +351,11 @@ restart: case PING: /* nothing */ break; +#endif +#if (CONFIG_COMMANDS & CFG_CMD_SNTP) + case SNTP: + /* nothing */ + break; #endif default: break; @@ -381,6 +404,7 @@ restart: #if (CONFIG_COMMANDS & CFG_CMD_DHCP) case DHCP: /* Start with a clean slate... */ + BootpTry = 0; NetOurIP = 0; NetServerIP = getenv_IPaddr ("serverip"); DhcpRequest(); /* Basically same as BOOTP */ @@ -415,6 +439,11 @@ restart: case NETCONS: NcStart(); break; +#endif +#if (CONFIG_COMMANDS & CFG_CMD_SNTP) + case SNTP: + SntpStart(); + break; #endif default: break; @@ -439,7 +468,7 @@ restart: /* * Main packet reception loop. Loop receiving packets until - * someone sets `NetQuit'. + * someone sets `NetState' to a state that terminates. */ for (;;) { WATCHDOG_RESET(); @@ -474,7 +503,9 @@ restart: thand_f *x; #if defined(CONFIG_MII) || (CONFIG_COMMANDS & CFG_CMD_MII) -#if defined(CFG_FAULT_ECHO_LINK_DOWN) && defined(CONFIG_STATUS_LED) && defined(STATUS_LED_RED) +# if defined(CFG_FAULT_ECHO_LINK_DOWN) && + defined(CONFIG_STATUS_LED) && + defined(STATUS_LED_RED) /* * Echo the inverted link state to the fault LED. */ @@ -483,7 +514,7 @@ restart: } else { status_led_set (STATUS_LED_RED, STATUS_LED_ON); } -#endif /* CFG_FAULT_ECHO_LINK_DOWN, ... */ +# endif /* CFG_FAULT_ECHO_LINK_DOWN, ... */ #endif /* CONFIG_MII, ... */ x = timeHandler; timeHandler = (thand_f *)0; @@ -585,7 +616,7 @@ NetSetHandler(rxhand_f * f) void -NetSetTimeout(int iv, thand_f * f) +NetSetTimeout(ulong iv, thand_f * f) { if (iv == 0) { timeHandler = (thand_f *)0; @@ -1291,6 +1322,7 @@ NetReceive(volatile uchar * inpkt, int len) #endif return; } + break; case PROT_RARP: #ifdef ET_DEBUG @@ -1424,6 +1456,14 @@ static int net_check_prereq (proto_t protocol) } goto common; #endif +#if (CONFIG_COMMANDS & CFG_CMD_SNTP) + case SNTP: + if (NetNtpServerIP == 0) { + puts ("*** ERROR: NTP server address not given\n"); + return (1); + } + goto common; +#endif #if (CONFIG_COMMANDS & CFG_CMD_NFS) case NFS: #endif @@ -1433,7 +1473,7 @@ static int net_check_prereq (proto_t protocol) puts ("*** ERROR: `serverip' not set\n"); return (1); } -#if (CONFIG_COMMANDS & CFG_CMD_PING) +#if (CONFIG_COMMANDS & (CFG_CMD_PING | CFG_CMD_SNTP)) common: #endif