2014-04-11 02:15:06 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* apps/include/netutils/ntpclient.h
|
|
|
|
*
|
2021-06-11 08:28:21 +02:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2014-04-11 02:15:06 +02:00
|
|
|
*
|
2021-06-11 08:28:21 +02:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2014-04-11 02:15:06 +02:00
|
|
|
*
|
2021-06-11 08:28:21 +02:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2014-04-11 02:15:06 +02:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __APPS_INCLUDE_NETUTILS_NTPCLIENT_H
|
2020-01-31 16:18:05 +01:00
|
|
|
#define __APPS_INCLUDE_NETUTILS_NTPCLIENT_H
|
2014-04-11 02:15:06 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
2021-02-19 05:25:05 +01:00
|
|
|
#include <sys/socket.h>
|
|
|
|
|
2014-04-11 02:15:06 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
2021-01-14 15:42:06 +01:00
|
|
|
|
2014-04-11 02:15:06 +02:00
|
|
|
/* Configuration ************************************************************/
|
|
|
|
|
|
|
|
#ifndef CONFIG_NETUTILS_NTPCLIENT_SERVERIP
|
|
|
|
# define CONFIG_NETUTILS_NTPCLIENT_SERVERIP 0x0a000001
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CONFIG_NETUTILS_NTPCLIENT_PORTNO
|
|
|
|
# define CONFIG_NETUTILS_NTPCLIENT_PORTNO 123
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CONFIG_NETUTILS_NTPCLIENT_STACKSIZE
|
|
|
|
# define CONFIG_NETUTILS_NTPCLIENT_STACKSIZE 2048
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CONFIG_NETUTILS_NTPCLIENT_SERVERPRIO
|
|
|
|
# define CONFIG_NETUTILS_NTPCLIENT_SERVERPRIO 100
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef CONFIG_NETUTILS_NTPCLIENT_POLLDELAYSEC
|
|
|
|
# define CONFIG_NETUTILS_NTPCLIENT_POLLDELAYSEC 60
|
|
|
|
#endif
|
|
|
|
|
2014-04-11 16:27:15 +02:00
|
|
|
#ifndef CONFIG_NETUTILS_NTPCLIENT_SIGWAKEUP
|
|
|
|
# define CONFIG_NETUTILS_NTPCLIENT_SIGWAKEUP 18
|
|
|
|
#endif
|
|
|
|
|
2014-04-11 02:15:06 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Types
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#define EXTERN extern "C"
|
2014-04-11 16:27:15 +02:00
|
|
|
extern "C"
|
|
|
|
{
|
2014-04-11 02:15:06 +02:00
|
|
|
#else
|
|
|
|
#define EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Function Prototypes
|
|
|
|
****************************************************************************/
|
2021-01-14 15:42:06 +01:00
|
|
|
|
2021-01-21 17:04:41 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* 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);
|
|
|
|
|
2014-04-11 02:15:06 +02:00
|
|
|
/****************************************************************************
|
2014-04-11 16:27:15 +02:00
|
|
|
* Name: ntpc_start
|
2014-04-11 02:15:06 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Start the NTP daemon
|
|
|
|
*
|
2014-04-11 16:27:15 +02:00
|
|
|
* Returned Value:
|
|
|
|
* On success, the non-negative task ID of the NTPC daemon is returned;
|
|
|
|
* On failure, a negated errno value is returned.
|
|
|
|
*
|
2014-04-11 02:15:06 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
2014-04-11 16:27:15 +02:00
|
|
|
int ntpc_start(void);
|
2014-04-11 02:15:06 +02:00
|
|
|
|
|
|
|
/****************************************************************************
|
2014-04-11 16:27:15 +02:00
|
|
|
* Name: ntpc_stop
|
2014-04-11 02:15:06 +02:00
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Stop the NTP daemon
|
|
|
|
*
|
2014-04-11 16:27:15 +02:00
|
|
|
* Returned Value:
|
|
|
|
* Zero on success; a negated errno value on failure. The current
|
|
|
|
* implementation only returns success.
|
|
|
|
*
|
2014-04-11 02:15:06 +02:00
|
|
|
****************************************************************************/
|
|
|
|
|
2014-04-11 16:27:15 +02:00
|
|
|
int ntpc_stop(void);
|
2014-04-11 02:15:06 +02:00
|
|
|
|
2021-02-19 05:25:05 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Name: ntpc_status
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* Get a status of the NTP daemon
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero on success; a negated errno value on failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
struct ntpc_status_s
|
|
|
|
{
|
|
|
|
/* the latest samples */
|
|
|
|
|
|
|
|
unsigned int nsamples;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
int64_t offset;
|
|
|
|
int64_t delay;
|
|
|
|
FAR const struct sockaddr *srv_addr;
|
|
|
|
struct sockaddr_storage _srv_addr_store;
|
|
|
|
}
|
|
|
|
samples[CONFIG_NETUTILS_NTPCLIENT_NUM_SAMPLES];
|
|
|
|
};
|
|
|
|
|
|
|
|
int ntpc_status(struct ntpc_status_s *statusp);
|
|
|
|
|
2014-04-11 02:15:06 +02:00
|
|
|
#undef EXTERN
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* __APPS_INCLUDE_NETUTILS_NTPCLIENT_H */
|