Marco Zecchini
/
Example_RTOS
Rtos API example
Embed:
(wiki syntax)
Show/hide line numbers
sntp_opts.h
Go to the documentation of this file.
00001 /** 00002 * @file 00003 * SNTP client options list 00004 */ 00005 00006 /* 00007 * Copyright (c) 2007-2009 Frédéric Bernon, Simon Goldschmidt 00008 * All rights reserved. 00009 * 00010 * Redistribution and use in source and binary forms, with or without modification, 00011 * are permitted provided that the following conditions are met: 00012 * 00013 * 1. Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 3. The name of the author may not be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00022 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 00024 * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00025 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 00026 * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00027 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 00028 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 00029 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 00030 * OF SUCH DAMAGE. 00031 * 00032 * This file is part of the lwIP TCP/IP stack. 00033 * 00034 * Author: Frédéric Bernon, Simon Goldschmidt 00035 * 00036 */ 00037 #ifndef LWIP_HDR_APPS_SNTP_OPTS_H 00038 #define LWIP_HDR_APPS_SNTP_OPTS_H 00039 00040 #include "lwip/opt.h" 00041 00042 /** 00043 * @defgroup sntp_opts Options 00044 * @ingroup sntp 00045 * @{ 00046 */ 00047 00048 /** SNTP macro to change system time in seconds 00049 * Define SNTP_SET_SYSTEM_TIME_US(sec, us) to set the time in microseconds instead of this one 00050 * if you need the additional precision. 00051 */ 00052 #if !defined SNTP_SET_SYSTEM_TIME || defined __DOXYGEN__ 00053 #define SNTP_SET_SYSTEM_TIME(sec) LWIP_UNUSED_ARG(sec) 00054 #endif 00055 00056 /** The maximum number of SNTP servers that can be set */ 00057 #if !defined SNTP_MAX_SERVERS || defined __DOXYGEN__ 00058 #define SNTP_MAX_SERVERS LWIP_DHCP_MAX_NTP_SERVERS 00059 #endif 00060 00061 /** Set this to 1 to implement the callback function called by dhcp when 00062 * NTP servers are received. */ 00063 #if !defined SNTP_GET_SERVERS_FROM_DHCP || defined __DOXYGEN__ 00064 #define SNTP_GET_SERVERS_FROM_DHCP LWIP_DHCP_GET_NTP_SRV 00065 #endif 00066 00067 /** Set this to 1 to support DNS names (or IP address strings) to set sntp servers 00068 * One server address/name can be defined as default if SNTP_SERVER_DNS == 1: 00069 * \#define SNTP_SERVER_ADDRESS "pool.ntp.org" 00070 */ 00071 #if !defined SNTP_SERVER_DNS || defined __DOXYGEN__ 00072 #define SNTP_SERVER_DNS 0 00073 #endif 00074 00075 /** 00076 * SNTP_DEBUG: Enable debugging for SNTP. 00077 */ 00078 #if !defined SNTP_DEBUG || defined __DOXYGEN__ 00079 #define SNTP_DEBUG LWIP_DBG_OFF 00080 #endif 00081 00082 /** SNTP server port */ 00083 #if !defined SNTP_PORT || defined __DOXYGEN__ 00084 #define SNTP_PORT 123 00085 #endif 00086 00087 /** Set this to 1 to allow config of SNTP server(s) by DNS name */ 00088 #if !defined SNTP_SERVER_DNS || defined __DOXYGEN__ 00089 #define SNTP_SERVER_DNS 0 00090 #endif 00091 00092 /** Sanity check: 00093 * Define this to 00094 * - 0 to turn off sanity checks (default; smaller code) 00095 * - >= 1 to check address and port of the response packet to ensure the 00096 * response comes from the server we sent the request to. 00097 * - >= 2 to check returned Originate Timestamp against Transmit Timestamp 00098 * sent to the server (to ensure response to older request). 00099 * - >= 3 @todo: discard reply if any of the LI, Stratum, or Transmit Timestamp 00100 * fields is 0 or the Mode field is not 4 (unicast) or 5 (broadcast). 00101 * - >= 4 @todo: to check that the Root Delay and Root Dispersion fields are each 00102 * greater than or equal to 0 and less than infinity, where infinity is 00103 * currently a cozy number like one second. This check avoids using a 00104 * server whose synchronization source has expired for a very long time. 00105 */ 00106 #if !defined SNTP_CHECK_RESPONSE || defined __DOXYGEN__ 00107 #define SNTP_CHECK_RESPONSE 0 00108 #endif 00109 00110 /** According to the RFC, this shall be a random delay 00111 * between 1 and 5 minutes (in milliseconds) to prevent load peaks. 00112 * This can be defined to a random generation function, 00113 * which must return the delay in milliseconds as u32_t. 00114 * Turned off by default. 00115 */ 00116 #if !defined SNTP_STARTUP_DELAY || defined __DOXYGEN__ 00117 #define SNTP_STARTUP_DELAY 0 00118 #endif 00119 00120 /** If you want the startup delay to be a function, define this 00121 * to a function (including the brackets) and define SNTP_STARTUP_DELAY to 1. 00122 */ 00123 #if !defined SNTP_STARTUP_DELAY_FUNC || defined __DOXYGEN__ 00124 #define SNTP_STARTUP_DELAY_FUNC SNTP_STARTUP_DELAY 00125 #endif 00126 00127 /** SNTP receive timeout - in milliseconds 00128 * Also used as retry timeout - this shouldn't be too low. 00129 * Default is 3 seconds. 00130 */ 00131 #if !defined SNTP_RECV_TIMEOUT || defined __DOXYGEN__ 00132 #define SNTP_RECV_TIMEOUT 3000 00133 #endif 00134 00135 /** SNTP update delay - in milliseconds 00136 * Default is 1 hour. Must not be beolw 15 seconds by specification (i.e. 15000) 00137 */ 00138 #if !defined SNTP_UPDATE_DELAY || defined __DOXYGEN__ 00139 #define SNTP_UPDATE_DELAY 3600000 00140 #endif 00141 00142 /** SNTP macro to get system time, used with SNTP_CHECK_RESPONSE >= 2 00143 * to send in request and compare in response. 00144 */ 00145 #if !defined SNTP_GET_SYSTEM_TIME || defined __DOXYGEN__ 00146 #define SNTP_GET_SYSTEM_TIME(sec, us) do { (sec) = 0; (us) = 0; } while(0) 00147 #endif 00148 00149 /** Default retry timeout (in milliseconds) if the response 00150 * received is invalid. 00151 * This is doubled with each retry until SNTP_RETRY_TIMEOUT_MAX is reached. 00152 */ 00153 #if !defined SNTP_RETRY_TIMEOUT || defined __DOXYGEN__ 00154 #define SNTP_RETRY_TIMEOUT SNTP_RECV_TIMEOUT 00155 #endif 00156 00157 /** Maximum retry timeout (in milliseconds). */ 00158 #if !defined SNTP_RETRY_TIMEOUT_MAX || defined __DOXYGEN__ 00159 #define SNTP_RETRY_TIMEOUT_MAX (SNTP_RETRY_TIMEOUT * 10) 00160 #endif 00161 00162 /** Increase retry timeout with every retry sent 00163 * Default is on to conform to RFC. 00164 */ 00165 #if !defined SNTP_RETRY_TIMEOUT_EXP || defined __DOXYGEN__ 00166 #define SNTP_RETRY_TIMEOUT_EXP 1 00167 #endif 00168 00169 /** 00170 * @} 00171 */ 00172 00173 #endif /* LWIP_HDR_APPS_SNTP_OPTS_H */
Generated on Sun Jul 17 2022 08:25:30 by 1.7.2