netutils/ntpclient: add more features
Allow multiple NTP servers, also with runtime configurable list Add validation of received NTP packets NTPv4 support with 'Kiss o' Death' message handling IPv6 support Collect multiple NTP samples and filter outsiders Check if system clock has been altered during NTP (if CONFIG_CLOCK_MONOTONIC) Signed-off-by: Juha Niskanen <juha.niskanen@haltian.com>
This commit is contained in:
parent
faaec6513c
commit
3b21cd9ceb
@ -92,6 +92,30 @@ extern "C"
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ntpc_dualstack_family()
|
||||
*
|
||||
* Description:
|
||||
* Set the protocol family used (AF_INET, AF_INET6 or AF_UNSPEC)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void ntpc_dualstack_family(int family);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ntpc_start_with_list
|
||||
*
|
||||
* Description:
|
||||
* Start the NTP daemon
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, the non-negative task ID of the NTPC daemon is returned;
|
||||
* On failure, a negated errno value is returned.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ntpc_start_with_list(FAR const char *ntp_server_list);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ntpc_start
|
||||
*
|
||||
|
@ -13,14 +13,25 @@ config NETUTILS_NTPCLIENT
|
||||
if NETUTILS_NTPCLIENT
|
||||
|
||||
config NETUTILS_NTPCLIENT_SERVER
|
||||
string "NTP server URL (or IP address)"
|
||||
default "pool.ntp.org"
|
||||
string "NTP server hostnames"
|
||||
default "0.pool.ntp.org;1.pool.ntp.org;2.pool.ntp.org"
|
||||
depends on LIBC_NETDB
|
||||
---help---
|
||||
List of NTP server hostnames to use. Server names need to
|
||||
be separated by ';'.
|
||||
|
||||
config NETUTILS_NTPCLIENT_SERVERIP
|
||||
hex "NTP server IP address"
|
||||
default 0x0a000001
|
||||
depends on !LIBC_NETDB
|
||||
---help---
|
||||
Warning: this is deprecated option. Suitable only for testing.
|
||||
Never use this in real NuttX products!
|
||||
|
||||
Use of hardcoded IP address for NTP server is known bad
|
||||
practice:
|
||||
|
||||
https://en.wikipedia.org/wiki/NTP_server_misuse_and_abuse
|
||||
|
||||
config NETUTILS_NTPCLIENT_PORTNO
|
||||
int "NTP server port number"
|
||||
@ -38,6 +49,14 @@ config NETUTILS_NTPCLIENT_POLLDELAYSEC
|
||||
int "NTP client poll interval (seconds)"
|
||||
default 60
|
||||
|
||||
config NETUTILS_NTPCLIENT_RETRIES
|
||||
int "NTP client retry seconds to wait for network up"
|
||||
default 60
|
||||
|
||||
config NETUTILS_NTPCLIENT_NUM_SAMPLES
|
||||
int "NTP client number of samples collected for filter"
|
||||
default 5
|
||||
|
||||
config NETUTILS_NTPCLIENT_SIGWAKEUP
|
||||
int "NTP client wakeup signal number"
|
||||
default 18
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -197,13 +197,18 @@ struct ntp_datagram_s
|
||||
uint8_t origtimestamp[8]; /* Originate Timestamp */
|
||||
uint8_t recvtimestamp[8]; /* Receive Timestamp */
|
||||
uint8_t xmittimestamp[8]; /* Transmit Timestamp */
|
||||
};
|
||||
|
||||
#ifdef CONFIG_NETUTILS_NTPCLIENT_WITH_AUTH
|
||||
struct ntp_datagram_with_key_s
|
||||
{
|
||||
struct ntp_datagram_s header;
|
||||
uint8_t keyid[4]; /* Authenticator data */
|
||||
uint8_t digest1[4];
|
||||
uint8_t digest2[4];
|
||||
uint8_t digest3[4];
|
||||
uint8_t digest4[4];
|
||||
#endif
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif /* __APPS_NETUTILS_NTPCLIENT_NTPV3_H */
|
||||
|
Loading…
x
Reference in New Issue
Block a user