Dependencies:
mbed
« Back to documentation index
sntp.c File Reference
SNTP client module.
More...
Go to the source code of this file.
Functions
static PACK_STRUCT_END void sntp_request (void *arg)
Send an SNTP request via sockets.
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_thread (void *arg)
SNTP thread.
void sntp_init (void)
Initialize this module when using sockets.
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, struct ip_addr *addr, u16_t port)
UDP recv callback for the sntp pcb.
static void sntp_send_request (struct ip_addr *server_addr)
Actually send an sntp request to a server.
static void sntp_dns_found (const char *hostname, struct ip_addr *ipaddr, void *arg)
DNS found callback when using DNS names as server address.
Variables
static struct udp_pcb * sntp_pcb
The UDP pcb used by the SNTP client.
static char * sntp_server_addresses [] = {SNTP_SERVER_ADDRESS}
Addresses of servers.
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 struct ip_addr 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 sntp.c .
Function Documentation
static void sntp_dns_found
(
const char *
hostname ,
struct ip_addr *
ipaddr ,
void *
arg
)
[static]
DNS found callback when using DNS names as server address.
Definition at line 621 of file sntp.c .
Initialize this module when using sockets.
Initialize this module when using raw API.
Send out request instantly or after SNTP_STARTUP_DELAY.
Definition at line 433 of file sntp.c .
static void sntp_initialize_request
(
struct sntp_msg *
req )
[static]
Initialize request struct to be sent to server.
Definition at line 324 of file sntp.c .
static void sntp_process
(
u32_t *
receive_timestamp )
[static]
SNTP processing of received timestamp.
Definition at line 298 of file sntp.c .
static void sntp_recv
(
void *
arg ,
struct udp_pcb *
pcb ,
struct pbuf *
p ,
struct ip_addr *
addr ,
u16_t
port
)
[static]
UDP recv callback for the sntp pcb.
Definition at line 505 of file sntp.c .
static void sntp_request
(
void *
arg )
[static]
Send an SNTP request via sockets.
Send out an sntp request via raw API.
This is a very minimal implementation that does not fully conform to the SNTPv4 RFC, especially regarding server load and error procesing.
Parameters:
arg is unused (only necessary to conform to sys_timeout)
Definition at line 351 of file 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 446 of file sntp.c .
static void sntp_send_request
(
struct ip_addr *
server_addr )
[static]
Actually send an sntp request to a server.
Parameters:
server_addr resolved IP address of the SNTP server
Definition at line 591 of file sntp.c .
static void sntp_thread
(
void *
arg )
[static]
SNTP thread.
Definition at line 420 of file 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.
Parameters:
arg is unused (only necessary to conform to sys_timeout)
Definition at line 479 of file sntp.c .
Variable Documentation
The currently used server (initialized to 0)
Definition at line 268 of file sntp.c .
Saves the last server address to compare with response.
Definition at line 285 of file sntp.c .
Saves the last timestamp sent (which is sent back by the server) to compare against in response.
Definition at line 291 of file sntp.c .
The UDP pcb used by the SNTP client.
Definition at line 263 of file sntp.c .
Retry time, initialized with SNTP_RETRY_TIMEOUT and doubled with each retry.
Definition at line 277 of file sntp.c .
Addresses of servers.
Definition at line 265 of file sntp.c .