Changeset 2b03a62 in rtems


Ignore:
Timestamp:
Nov 1, 2013, 1:59:41 PM (6 years ago)
Author:
Jim Panetta <panetta@…>
Branches:
4.11, master
Children:
66bf2cc9
Parents:
78c84df
git-author:
Jim Panetta <panetta@…> (11/01/13 13:59:41)
git-committer:
Gedare Bloom <gedare@…> (01/09/14 14:56:03)
Message:

NTP: Sync time correctly when receiving broadcast updates

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libnetworking/lib/rtems_bsdnet_ntp.c

    r78c84df r2b03a62  
    141141
    142142        if ( i >= sizeof packet &&
    143                 ((packet.li_vn_mode & (0x7 << 3)) == (3 << 3)) &&
     143    (((packet.li_vn_mode & (0x7 << 3)) == (3 << 3)) ||
     144     ((packet.li_vn_mode & (0x7 << 3)) == (4 << 3))) &&
    144145            ((packet.transmit_timestamp.integer != 0) || (packet.transmit_timestamp.fraction != 0)) &&
    145146                0 == callback( &packet, 0 , usr_data) )
     
    175176        memset (&myAddr, 0, sizeof myAddr);
    176177        myAddr.sin_family = AF_INET;
    177         myAddr.sin_port = htons (0);
     178        myAddr.sin_port = htons (123);
    178179        myAddr.sin_addr.s_addr = htonl (INADDR_ANY);
    179180        if (bind (s, (struct sockaddr *)&myAddr, sizeof myAddr) < 0) {
     
    191192                 * server out there somewhere.
    192193                 */
    193                 if (rtems_bsdnet_ntpserver_count < 0) {
     194                if (rtems_bsdnet_ntpserver_count <= 0) {
    194195                        ret = tryServer (-1, sock, callback, usr_data);
    195196                }
Note: See TracChangeset for help on using the changeset viewer.