This is the mail archive of the ecos-patches@sources.redhat.com mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: FWD: SNTP client package


Andrew Lunn wrote:
Hi Folks

I guess you are all busy with beta 2.0.

You betcha! Just a bit of a status update - we're mostly at the testing stage now with a few problems with binary compatibility between different linux distributions and versions. You try and build a C++ binary for Red Hat 7.x, 8.x, Suse and Debian which works with 2.95, "2.96", and 3.x :-). Emphasis on C++. The installer is virtually complete and needs to be documented, and we've already started (internal) release candidates, but those still have problems so don't bother asking yet :-).


If you have some spare time please could you take a look at this.

Just a few comments...


+ /* Only support protocol versions 3 or 4 */
+ if (new_srv.version < 3 || new_srv.version > 4) + continue;

Should this maybe output some sort of diagnostic? Perhaps CYG_TRACE since diag_printf might be too noisy?


[sntp.h]
+/* Call this function to start the SNTP Client */
+void cyg_sntp_start(void);

That should be __externC to make it C++ safe.


+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 description is (subtly!) different from that of ecos.db.


+    include_dir   cyg/sntp
+
+    requires      CYGPKG_NET
+    requires      CYGPKG_ISO_TIME

CYGPKG_LIBC_TIME, since cyg_libc_time_settime, since it's specific to that implementation. And probably CYGSEM_LIBC_TIME_TIME_WORKING and CYGSEM_LIBC_TIME_SETTIME_WORKING instead in fact.


+void
+net_test(cyg_addrword_t param)
+{
+ int seconds;
+ time_t now, build_time;
+ struct tm tm={ 0,0,0,0,0,0,0,0,0 };
+ int i;
+ char month[4];
+ char months[12][4] = { "Jan", "Feb", "Mar", + "Apr", "May", "Jun", + "Jul", "Aug", "Sep",
+ "Oct", "Nov", "Dec" };
+ + CYG_TEST_INIT();
+
+ CYG_TEST_INFO("sntp1 test build " __DATE__);
+
+ init_all_network_interfaces();
+
+ cyg_sntp_start();
+
+ for (seconds = 120; seconds > 0; seconds--) {
+ now = time(NULL);
+ CYG_TEST_INFO(ctime(&now));
+ cyg_thread_delay(100);
+ }
+ + now = time(NULL);
+
+ if ( now < (5 * 60)) {
+ CYG_TEST_FAIL_FINISH("Nothing recieved from the SNTP server");
+ } else {
+ + i=sscanf(__DATE__, "%s %d %d",month,&tm.tm_mday,&tm.tm_year);

Should require the appropriate requirement (CYGINT_ISO_STDIO_FORMATTED_IO), either via CDL for the whole package, or via a compile time test in this test which changes to CYG_TEST_NA if it isn't defined.


+ CYG_ASSERT(3==i,"sscanf did not return enough results");
+ for (i=0; i < 12; i++) {
+ if (!strcmp(month,months[i]))

requires CYGINT_ISO_STRING_STRFUNCS


+	break;
+    }
+    tm.tm_mon = i;
+    tm.tm_mday++;
+
+    build_time = mktime(&tm);
+    CYG_ASSERT(-1 != build_time,"mktime returned -1");
+
+    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");
+      }

Hmm... I'm not entirely happy with this. This implies tests can get out of date over time. Obviously it's useful to have some baseline to test, but I'm not sure this is advisable. Comments from anyone else on this?


+    }
+  }
+  CYG_TEST_FINISH("sntp1 test is complete");

CYG_TEST_PASS_FINISH.


--- /dev/null	Fri Oct 11 13:37:09 2002
+++ packages/net/sntp/current/doc/sntp.sgml	Mon Feb 17 12:00:47 2003
@@ -0,0 +1,100 @@
+<PART ID="net-sntp">

Should have a licence banner preamble. See hal/common or kernel docs for example. (Yes I know I haven't always caught this in the past either, e.g. cpuload, crc, gprof).


+<TITLE>Simple Network Time Protocol Client</TITLE>
+<PARTINTRO>
+<PARA>
+The SNTP package provides implementation of a client for RFC 2030, the
+Simple Network Time Protocol (SNTP). The client listens for broadcasts
+from an NTP server and uses the information received to set the system
+clock.
+</PARA>
+</PARTINTRO>
+<CHAPTER id="sntp-the">

Trivial: use a consistent id tag prefix :-)... this will become important in future though. net-sntp is right.


+<sect1 id="net-sntp-warning">
+<title>Warning: timestamp wrap around</title>
+<para>
+The timestamp in the NTP packet is a 32bit integer which represents
+the number of seconds after 00:00 01/01/1900. This 32bit number will
+wrap around at 06:28:16 Feb 7 2036. At this point in time, the eCos
+time will jump back to around 00:00:00 Jan 1 1900 when the next
+broadcast is received. +</para>
+<para>
+YOU HAVE BEEN WARNED!
+</para>

:-)


+</PART>
\ No newline at end of file

That's it I think.


Jifl
--
eCosCentric    http://www.eCosCentric.com/    The eCos and RedBoot experts
--[ "You can complain because roses have thorns, or you ]--
--[  can rejoice because thorns have roses." -Lincoln   ]-- Opinions==mine


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]