On Thu, 2014-01-09 at 09:56 -0500, Gedare Bloom wrote: > http://git.rtems.org/rtems/commit/?id=2b03a62441d63d056dbbd6de17429ae05e4dfd04
> if ( i >= sizeof packet && > - ((packet.li_vn_mode & (0x7 << 3)) == (3 << 3)) && > + (((packet.li_vn_mode & (0x7 << 3)) == (3 << 3)) || > + ((packet.li_vn_mode & (0x7 << 3)) == (4 << 3))) && > ((packet.transmit_timestamp.integer != 0) || (packet.transmit_timestamp.fraction != 0)) && > 0 == callback( &packet, 0 , usr_data) ) > return 0; That indentation's good 'n' weird! Apparently it was before, too, though. > On Fri, Nov 1, 2013 at 9:59 AM, <ged...@rtems.org> wrote: > > From: Jim Panetta <pane...@slac.stanford.edu> > > > > 1) The value of rtems_bsdnet_ntpserver_count is equal to 0 when no > > server is set, so the check for (rtems_bsdnet_ntpserver_count < 0) > > in rtems_bsdnet_get_ntp() is wrong. The check should be "<= 0". > > > > 2) Binding the listening socket port to 0 does not work. Packets > > appear on the interface, but the recvfrom in tryServer() never > > returns. Changing this to the well known NTP socket 123 allows > > the packets to be seen. > > > > 3) In tryServer(), an explicit check for NTP version 3 packets is made. > > If the NTP server is version 4, this check fails even though the > > packets seem to be the right shape. > > --- > > cpukit/libnetworking/lib/rtems_bsdnet_ntp.c | 7 ++++--- > > 1 file changed, 4 insertions(+), 3 deletions(-) > > > > diff --git a/cpukit/libnetworking/lib/rtems_bsdnet_ntp.c > > b/cpukit/libnetworking/lib/rtems_bsdnet_ntp.c > > index 4f991ff..35092ea 100644 > > --- a/cpukit/libnetworking/lib/rtems_bsdnet_ntp.c > > +++ b/cpukit/libnetworking/lib/rtems_bsdnet_ntp.c > > @@ -140,7 +140,8 @@ tryServer (int i, int s, rtems_bsdnet_ntp_callback_t > > callback, void *usr_data) > > } > > > > if ( i >= sizeof packet && > > - ((packet.li_vn_mode & (0x7 << 3)) == (3 << 3)) && > > + (((packet.li_vn_mode & (0x7 << 3)) == (3 << 3)) || > > + ((packet.li_vn_mode & (0x7 << 3)) == (4 << 3))) && > > ((packet.transmit_timestamp.integer != 0) || > > (packet.transmit_timestamp.fraction != 0)) && > > 0 == callback( &packet, 0 , usr_data) ) > > return 0; > > @@ -174,7 +175,7 @@ int ret; > > } > > memset (&myAddr, 0, sizeof myAddr); > > myAddr.sin_family = AF_INET; > > - myAddr.sin_port = htons (0); > > + myAddr.sin_port = htons (123); > > myAddr.sin_addr.s_addr = htonl (INADDR_ANY); > > if (bind (s, (struct sockaddr *)&myAddr, sizeof myAddr) < 0) { > > fprintf (stderr, "rtems_bsdnet_get_ntp() Can't bind socket: > > %s\n", strerror (errno)); > > @@ -190,7 +191,7 @@ int ret; > > * and hope that there's an NTP broadcast > > * server out there somewhere. > > */ > > - if (rtems_bsdnet_ntpserver_count < 0) { > > + if (rtems_bsdnet_ntpserver_count <= 0) { > > ret = tryServer (-1, sock, callback, usr_data); > > } > > else { > > -- > > 1.7.9.5 > > > _______________________________________________ > rtems-devel mailing list > rtems-devel@rtems.org > http://www.rtems.org/mailman/listinfo/rtems-devel > -- Nick Withers Embedded Systems Programmer Room 2.26, Building 57 Department of Nuclear Physics Research School of Physics and Engineering The Australian National University (CRICOS: 00120C) eMail: nick.with...@anu.edu.au Phone: +61 2 6125 2091 Mobile: +61 414 397 446 _______________________________________________ rtems-devel mailing list rtems-devel@rtems.org http://www.rtems.org/mailman/listinfo/rtems-devel