# HG changeset patch # User asl # Date 1046196738 0 # Node ID 018143c925ee86d646562b33151df25ad516b807 # Parent 36f3d2a15e37e7050ee0b1ada5ae85febb241549 * tests/sntp1.c (net_test): Strip the trailing "\n" making it more readable. * doc/sntp.sgml: Added license banner and added missing * include/sntp.h (cyg_sntp_start): C++ safe * cdl/sntp.cdl: Stricture requirements and same description as in ecos.db. Only build the test if CYGPKH_NET_BUILD_HW_TESTS * tests/sntp1.c (net_test): Check we have the required packages. Require the time to be within 90 days of the build date of the tes diff --git a/packages/net/sntp/current/ChangeLog b/packages/net/sntp/current/ChangeLog --- a/packages/net/sntp/current/ChangeLog +++ b/packages/net/sntp/current/ChangeLog @@ -1,3 +1,19 @@ +2003-02-25 Gary Thomas + + * tests/sntp1.c (net_test): Strip the trailing "\n" making it more + readable. + +2003-02-25 Andrew Lunn + + * doc/sntp.sgml: Added license banner and added missing + * include/sntp.h (cyg_sntp_start): C++ safe + * cdl/sntp.cdl: Stricture requirements and same description as in + ecos.db. Only build the test if CYGPKH_NET_BUILD_HW_TESTS + * tests/sntp1.c (net_test): Check we have the required + packages. Require the time to be within 90 days of the build + date of the test + + 2003-02-16 Andrew Lunn * src/sntp.c: First import of SNTP client code. diff --git a/packages/net/sntp/current/cdl/sntp.cdl b/packages/net/sntp/current/cdl/sntp.cdl --- a/packages/net/sntp/current/cdl/sntp.cdl +++ b/packages/net/sntp/current/cdl/sntp.cdl @@ -51,15 +51,15 @@ cdl_package CYGPKG_NET_SNTP { display "Simple Network Time Protocol Client (SNTP)" description " - This package provides an SNTP client which will recieve - SNTP broadcasts and set the system clock to the correct - time." + This package provides a SNTP client which can recieve broadcast time + information and set the system clock." doc ref/net-sntp.html include_dir cyg/sntp requires CYGPKG_NET - requires CYGPKG_ISO_TIME - + requires CYGPKG_LIBC_TIME + requires CYGSEM_LIBC_TIME_TIME_WORKING + requires CYGSEM_LIBC_TIME_SETTIME_WORKING compile sntp.c cdl_component CYGPKG_NET_SNTP_OPTIONS { @@ -95,7 +95,7 @@ cdl_package CYGPKG_NET_SNTP { display "sntp tests" flavor data no_define - calculated { "tests/sntp1.c" } + calculated { CYGPKG_NET_BUILD_HW_TESTS ? "tests/sntp1.c" : "" } } } diff --git a/packages/net/sntp/current/doc/sntp.sgml b/packages/net/sntp/current/doc/sntp.sgml --- a/packages/net/sntp/current/doc/sntp.sgml +++ b/packages/net/sntp/current/doc/sntp.sgml @@ -1,4 +1,35 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Simple Network Time Protocol Client @@ -8,7 +39,7 @@ from an NTP server and uses the informat clock. - + The SNTP Client Starting the SNTP client @@ -23,8 +54,8 @@ called. The thread is then started by c void cyg_sntp_start(void); - Once started, the thread will run forever. + diff --git a/packages/net/sntp/current/include/sntp.h b/packages/net/sntp/current/include/sntp.h --- a/packages/net/sntp/current/include/sntp.h +++ b/packages/net/sntp/current/include/sntp.h @@ -51,6 +51,7 @@ //============================================================================= /* Call this function to start the SNTP Client */ -void cyg_sntp_start(void); +__externC void +cyg_sntp_start(void); #endif diff --git a/packages/net/sntp/current/src/sntp.c b/packages/net/sntp/current/src/sntp.c --- a/packages/net/sntp/current/src/sntp.c +++ b/packages/net/sntp/current/src/sntp.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -152,8 +153,10 @@ static void sntp_fn(cyg_addrword_t data) mode = (htonl(buf[0]) & MODE_MASK) >> MODE_SHIFT; /* Only support protocol versions 3 or 4 */ - if (new_srv.version < 3 || new_srv.version > 4) + if (new_srv.version < 3 || new_srv.version > 4) { + CYG_TRACE1(1, "Unsupported version of NTP. Version %d",version); continue; + } /* Only process broadcast packet */ if (mode != MODE_BROADCAST) diff --git a/packages/net/sntp/current/tests/sntp1.c b/packages/net/sntp/current/tests/sntp1.c --- a/packages/net/sntp/current/tests/sntp1.c +++ b/packages/net/sntp/current/tests/sntp1.c @@ -46,8 +46,11 @@ // Description: Tests the sntp client //####DESCRIPTIONEND#### +#include +#include + +#if defined(CYGINT_ISO_STDIO_FORMATTED_IO) && defined(CYGINT_ISO_STRING_STRFUNCS) #include -#include #include #include #include @@ -69,6 +72,7 @@ net_test(cyg_addrword_t param) "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; + char time_info[32]; CYG_TEST_INIT(); @@ -80,7 +84,9 @@ net_test(cyg_addrword_t param) for (seconds = 120; seconds > 0; seconds--) { now = time(NULL); - CYG_TEST_INFO(ctime(&now)); + ctime_r(&now, time_info); + time_info[strlen(time_info)-1] = '\0'; // Strip \n + CYG_TEST_INFO(time_info); cyg_thread_delay(100); } @@ -105,12 +111,12 @@ net_test(cyg_addrword_t param) if (build_time > time(NULL)) { CYG_TEST_FAIL_FINISH("Build time is ahead of SNTP time"); } else { - if ((build_time + 60 * 60 * 24 * 10) > time(NULL)) { - CYG_TEST_FAIL_FINISH("Build time is more than 10 days old"); + if ((build_time + 60 * 60 * 24 * 90) > time(NULL)) { + CYG_TEST_FAIL_FINISH("Build time is more than 90 days old"); } } } - CYG_TEST_FINISH("sntp1 test is complete"); + CYG_TEST_PASS_FINISH("sntp1 test is complete"); } #define STACK_SIZE (CYGNUM_HAL_STACK_SIZE_TYPICAL*2) @@ -133,3 +139,12 @@ cyg_user_start(void) ); cyg_thread_resume(thread_handle); // Start it } + +#else //defined(CYGINT_ISO_STDIO_FORMATTED_IO) && defined(CYGINT_ISO_STRING_STRFUNCS) + +void cyg_user_start(void) +{ + CYG_TEST_NA("Not all the required packages are available"); +} + +#endif