Tizen RT Libs&Environment  v1.0 D5
ntpclient.h
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright 2016 Samsung Electronics All Rights Reserved.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing,
12  * software distributed under the License is distributed on an
13  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
14  * either express or implied. See the License for the specific
15  * language governing permissions and limitations under the License.
16  *
17  ****************************************************************************/
18 /****************************************************************************
19  * apps/include/netutils/ntpclient.h
20  *
21  * Copyright (C) 2014 Gregory Nutt. All rights reserved.
22  * Author: Gregory Nutt <gnutt@nuttx.org>
23  *
24  * Redistribution and use in source and binary forms, with or without
25  * modification, are permitted provided that the following conditions
26  * are met:
27  *
28  * 1. Redistributions of source code must retain the above copyright
29  * notice, this list of conditions and the following disclaimer.
30  * 2. Redistributions in binary form must reproduce the above copyright
31  * notice, this list of conditions and the following disclaimer in
32  * the documentation and/or other materials provided with the
33  * distribution.
34  * 3. Neither the name NuttX nor the names of its contributors may be
35  * used to endorse or promote products derived from this software
36  * without specific prior written permission.
37  *
38  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
39  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
40  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
41  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
42  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
43  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
44  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
45  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
46  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
47  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
48  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49  * POSSIBILITY OF SUCH DAMAGE.
50  *
51  ****************************************************************************/
59 
62 #ifndef __APPS_INCLUDE_NETUTILS_NTPCLIENT_H
63 #define __APPS_INCLUDE_NETUTILS_NTPCLIENT_H 1
64 
65 /****************************************************************************
66  * Included Files
67  ****************************************************************************/
68 
69 #include <tinyara/config.h>
70 #include <netinet/in.h>
71 
72 /****************************************************************************
73  * Pre-processor Definitions
74  ****************************************************************************/
75 /* Configuration ************************************************************/
76 
77 #define MAX_NTP_SERVER_NUM 5
78 #define MIN_NTP_POLL_INTERVAL_SECS 10 /* 10 seconds */
79 #define MAX_NTP_POLL_INTERVAL_SECS (24 * 60 * 60) /* 24 hours */
80 
81 /****************************************************************************
82  * Public Types
83  ****************************************************************************/
84 
94 };
95 
103 };
104 
109  char *hostname; /* host name */
110  int port; /* port */
111 };
112 
117  struct ntpc_server_conn_s conn;
118  in_addr_t ipaddr; /* ip address */
119  int link; /* link status */
120 };
121 
122 /****************************************************************************
123  * Public Data
124  ****************************************************************************/
125 
126 #ifdef __cplusplus
127 // *INDENT-OFF*
128 #define EXTERN extern "C"
129 extern "C" {
130 #else
131 #define EXTERN extern
132 // *INDENT-ON*
133 #endif
134 
135 /****************************************************************************
136  * Public Function Prototypes
137  ****************************************************************************/
138 
152 int ntpc_start(struct ntpc_server_conn_s *server_list, uint32_t num_of_servers, uint32_t interval_secs, void *link_error_cb);
153 
161 #ifndef CONFIG_DISABLE_SIGNALS
162 int ntpc_stop(void);
163 #endif
164 
172 int ntpc_get_status(void);
173 
183 int ntpc_get_link_status(void);
184 
185 // @endcond
186 
187 #undef EXTERN
188 #ifdef __cplusplus
189 // *INDENT-OFF*
190 }
191 // *INDENT-ON*
192 #endif
193 
194 #endif /* __APPS_INCLUDE_NETUTILS_NTPCLIENT_H */
195 // end of NTPC group
ntpc_link_status_e
This enumeration describes the state of the NTP Client&#39;s Link.
Definition: ntpclient.h:99
in_addr_t ipaddr
Definition: ntpclient.h:118
int ntpc_start(struct ntpc_server_conn_s *server_list, uint32_t num_of_servers, uint32_t interval_secs, void *link_error_cb)
ntpc_start() starts the NTP client daemon.
int ntpc_stop(void)
ntpc_stop() stops the NTP client daemon.
Structure of NTP server information.
Definition: ntpclient.h:116
int ntpc_get_status(void)
ntpc_get_status() gets NTP client daemon&#39;s status value.
ntpc_daemon_e
This enumeration describes the state of the NTP daemon.
Definition: ntpclient.h:88
Structure of NTP server&#39;s connection information.
Definition: ntpclient.h:108