Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
SNTP client module. More...
Go to the source code of this file.
Functions | |
static PACK_STRUCT_END void | sntp_request (void *arg) |
Send out an sntp request. | |
static void | sntp_process (u32_t *receive_timestamp) |
SNTP processing of received timestamp. | |
static void | sntp_initialize_request (struct sntp_msg *req) |
Initialize request struct to be sent to server. | |
static void | sntp_retry (void *arg) |
Retry: send a new request (and increase retry timeout). | |
static void | sntp_try_next_server (void *arg) |
If Kiss-of-Death is received (or another packet parsing error), try the next server or retry the current server and increase the retry timeout if only one server is available. | |
static void | sntp_recv (void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr, u16_t port) |
UDP recv callback for the sntp pcb. | |
static void | sntp_send_request (const ip_addr_t *server_addr) |
Actually send an sntp request to a server. | |
static void | sntp_dns_found (const char *hostname, const ip_addr_t *ipaddr, void *arg) |
DNS found callback when using DNS names as server address. | |
void | sntp_init (void) |
Initialize this module. | |
void | sntp_stop (void) |
Stop this module. | |
u8_t | sntp_enabled (void) |
Get enabled state. | |
void | sntp_setoperatingmode (u8_t operating_mode) |
Sets the operating mode. | |
u8_t | sntp_getoperatingmode (void) |
Gets the operating mode. | |
void | sntp_servermode_dhcp (int set_servers_from_dhcp) |
Config SNTP server handling by IP address, name, or DHCP; clear table. | |
void | sntp_setserver (u8_t idx, const ip_addr_t *server) |
Initialize one of the NTP servers by IP address. | |
void | dhcp_set_ntp_servers (u8_t num, const ip4_addr_t *server) |
Initialize one of the NTP servers by IP address, required by DHCP. | |
const ip_addr_t * | sntp_getserver (u8_t idx) |
Obtain one of the currently configured by IP address (or DHCP) NTP servers. | |
void | sntp_setservername (u8_t idx, char *server) |
Initialize one of the NTP servers by name. | |
char * | sntp_getservername (u8_t idx) |
Obtain one of the currently configured by name NTP servers. | |
Variables | |
static u8_t | sntp_opmode |
The operating mode. | |
static struct udp_pcb * | sntp_pcb |
The UDP pcb used by the SNTP client. | |
static u8_t | sntp_current_server |
The currently used server (initialized to 0) | |
static u32_t | sntp_retry_timeout |
Retry time, initialized with SNTP_RETRY_TIMEOUT and doubled with each retry. | |
static ip_addr_t | sntp_last_server_address |
Saves the last server address to compare with response. | |
static u32_t | sntp_last_timestamp_sent [2] |
Saves the last timestamp sent (which is sent back by the server) to compare against in response. |
Detailed Description
SNTP client module.
Definition in file lwip_sntp.c.
Function Documentation
void dhcp_set_ntp_servers | ( | u8_t | num, |
const ip4_addr_t * | server | ||
) |
Initialize one of the NTP servers by IP address, required by DHCP.
This function must exist, in other to add offered NTP servers to the NTP (or SNTP) engine.
- Parameters:
-
numdns the index of the NTP server to set must be < SNTP_MAX_SERVERS dnsserver IP address of the NTP server to set
Definition at line 659 of file lwip_sntp.c.
static void sntp_dns_found | ( | const char * | hostname, |
const ip_addr_t * | ipaddr, | ||
void * | arg | ||
) | [static] |
DNS found callback when using DNS names as server address.
Definition at line 468 of file lwip_sntp.c.
char* sntp_getservername | ( | u8_t | idx ) |
Obtain one of the currently configured by name NTP servers.
- Parameters:
-
numdns the index of the NTP server
- Returns:
- IP address of the indexed NTP server or NULL if the NTP server has not been configured by name (or at all)
Definition at line 718 of file lwip_sntp.c.
static void sntp_initialize_request | ( | struct sntp_msg * | req ) | [static] |
Initialize request struct to be sent to server.
Definition at line 240 of file lwip_sntp.c.
static void sntp_process | ( | u32_t * | receive_timestamp ) | [static] |
SNTP processing of received timestamp.
Definition at line 210 of file lwip_sntp.c.
static void sntp_recv | ( | void * | arg, |
struct udp_pcb * | pcb, | ||
struct pbuf * | p, | ||
const ip_addr_t * | addr, | ||
u16_t | port | ||
) | [static] |
UDP recv callback for the sntp pcb.
Definition at line 335 of file lwip_sntp.c.
static void sntp_request | ( | void * | arg ) | [static] |
Send out an sntp request.
- Parameters:
-
arg is unused (only necessary to conform to sys_timeout)
Definition at line 491 of file lwip_sntp.c.
static void sntp_retry | ( | void * | arg ) | [static] |
Retry: send a new request (and increase retry timeout).
- Parameters:
-
arg is unused (only necessary to conform to sys_timeout)
Definition at line 265 of file lwip_sntp.c.
static void sntp_send_request | ( | const ip_addr_t * | server_addr ) | [static] |
Actually send an sntp request to a server.
- Parameters:
-
server_addr resolved IP address of the SNTP server
Definition at line 436 of file lwip_sntp.c.
void sntp_servermode_dhcp | ( | int | set_servers_from_dhcp ) |
Config SNTP server handling by IP address, name, or DHCP; clear table.
- Parameters:
-
set_servers_from_dhcp enable or disable getting server addresses from dhcp
Definition at line 620 of file lwip_sntp.c.
void sntp_setservername | ( | u8_t | idx, |
char * | server | ||
) |
Initialize one of the NTP servers by name.
- Parameters:
-
numdns the index of the NTP server to set must be < SNTP_MAX_SERVERS dnsserver DNS name of the NTP server to set, to be resolved at contact time
Definition at line 703 of file lwip_sntp.c.
static void sntp_try_next_server | ( | void * | arg ) | [static] |
If Kiss-of-Death is received (or another packet parsing error), try the next server or retry the current server and increase the retry timeout if only one server is available.
(implicitly, SNTP_MAX_SERVERS > 1)
- Parameters:
-
arg is unused (only necessary to conform to sys_timeout)
Definition at line 299 of file lwip_sntp.c.
Variable Documentation
u8_t sntp_current_server [static] |
The currently used server (initialized to 0)
Definition at line 181 of file lwip_sntp.c.
ip_addr_t sntp_last_server_address [static] |
Saves the last server address to compare with response.
Definition at line 197 of file lwip_sntp.c.
u32_t sntp_last_timestamp_sent[2] [static] |
Saves the last timestamp sent (which is sent back by the server) to compare against in response.
Definition at line 203 of file lwip_sntp.c.
u8_t sntp_opmode [static] |
The operating mode.
Definition at line 163 of file lwip_sntp.c.
The UDP pcb used by the SNTP client.
Definition at line 166 of file lwip_sntp.c.
u32_t sntp_retry_timeout [static] |
Retry time, initialized with SNTP_RETRY_TIMEOUT and doubled with each retry.
Definition at line 189 of file lwip_sntp.c.
Generated on Tue Jul 12 2022 14:25:36 by
