SNTP client (Simple Network Time Protocol) More...
#include "core/net.h"
#include "sntp/sntp_client.h"
#include "sntp/sntp_client_misc.h"
#include "debug.h"
Go to the source code of this file.
Macros | |
#define | TRACE_LEVEL SNTP_TRACE_LEVEL |
Functions | |
error_t | sntpClientInit (SntpClientContext *context) |
Initialize SNTP client context. More... | |
error_t | sntpClientSetTimeout (SntpClientContext *context, systime_t timeout) |
Set communication timeout. More... | |
error_t | sntpClientBindToInterface (SntpClientContext *context, NetInterface *interface) |
Bind the SNTP client to a particular network interface. More... | |
error_t | sntpClientSetServerAddr (SntpClientContext *context, const IpAddr *serverIpAddr, uint16_t serverPort) |
Specify the IP address of the NTP server. More... | |
error_t | sntpClientGetTimestamp (SntpClientContext *context, NtpTimestamp *timestamp) |
Retrieve current time from NTP server. More... | |
uint32_t | sntpClientGetKissCode (SntpClientContext *context) |
Retrieve the kiss code from a Kiss-of-Death message. More... | |
void | sntpClientDeinit (SntpClientContext *context) |
Release SNTP client context. More... | |
Detailed Description
SNTP client (Simple Network Time Protocol)
License
SPDX-License-Identifier: GPL-2.0-or-later
Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
This file is part of CycloneTCP Open.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Description
The Simple Network Time Protocol is used to synchronize computer clocks in the Internet. Refer to RFC 4330 for more details
- Version
- 2.4.4
Definition in file sntp_client.c.
Macro Definition Documentation
◆ TRACE_LEVEL
#define TRACE_LEVEL SNTP_TRACE_LEVEL |
Definition at line 37 of file sntp_client.c.
Function Documentation
◆ sntpClientBindToInterface()
error_t sntpClientBindToInterface | ( | SntpClientContext * | context, |
NetInterface * | interface | ||
) |
Bind the SNTP client to a particular network interface.
- Parameters
-
[in] context Pointer to the SNTP client context [in] interface Network interface to be used
- Returns
- Error code
Definition at line 103 of file sntp_client.c.
◆ sntpClientDeinit()
void sntpClientDeinit | ( | SntpClientContext * | context | ) |
Release SNTP client context.
- Parameters
-
[in] context Pointer to the SNTP client context
Definition at line 257 of file sntp_client.c.
◆ sntpClientGetKissCode()
uint32_t sntpClientGetKissCode | ( | SntpClientContext * | context | ) |
Retrieve the kiss code from a Kiss-of-Death message.
- Parameters
-
[in] context Pointer to the SNTP client context
- Returns
- Kiss code
Definition at line 231 of file sntp_client.c.
◆ sntpClientGetTimestamp()
error_t sntpClientGetTimestamp | ( | SntpClientContext * | context, |
NtpTimestamp * | timestamp | ||
) |
Retrieve current time from NTP server.
- Parameters
-
[in] context Pointer to the SNTP client context [out] timestamp Pointer to the NTP timestamp
- Returns
- Error code
Definition at line 154 of file sntp_client.c.
◆ sntpClientInit()
error_t sntpClientInit | ( | SntpClientContext * | context | ) |
Initialize SNTP client context.
- Parameters
-
[in] context Pointer to the SNTP client context
- Returns
- Error code
Definition at line 55 of file sntp_client.c.
◆ sntpClientSetServerAddr()
error_t sntpClientSetServerAddr | ( | SntpClientContext * | context, |
const IpAddr * | serverIpAddr, | ||
uint16_t | serverPort | ||
) |
Specify the IP address of the NTP server.
- Parameters
-
[in] context Pointer to the SNTP client context [in] serverIpAddr IP address of the NTP server [in] serverPort Port number
- Returns
- Error code
Definition at line 126 of file sntp_client.c.
◆ sntpClientSetTimeout()
error_t sntpClientSetTimeout | ( | SntpClientContext * | context, |
systime_t | timeout | ||
) |
Set communication timeout.
- Parameters
-
[in] context Pointer to the SNTP client context [in] timeout Timeout value, in milliseconds
- Returns
- Error code
Definition at line 82 of file sntp_client.c.