]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - net/net.c
* Patch by Masami Komiya, 30 Mar 2005:
[people/ms/u-boot.git] / net / net.c
index d7523fd1006208117366ed618c76e1a9690ced47..11a286b5783fd0dab7f7446fb00d835bfd4b0c97 100644 (file)
--- a/net/net.c
+++ b/net/net.c
  *                       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 <status_led.h>
 #include <miiphy.h>
 #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;
@@ -416,6 +439,11 @@ restart:
                case NETCONS:
                        NcStart();
                        break;
+#endif
+#if (CONFIG_COMMANDS & CFG_CMD_SNTP)
+               case SNTP:
+                       SntpStart();
+                       break;
 #endif
                default:
                        break;
@@ -1426,6 +1454,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
@@ -1435,7 +1471,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