nts_client.c File Reference

NTS client (Network Time Security) More...

#include "core/net.h"
#include "nts/nts_client.h"
#include "nts/nts_client_misc.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   NTS_TRACE_LEVEL
 

Functions

error_t ntsClientInit (NtsClientContext *context)
 Initialize NTS client context. More...
 
error_t ntsClientSetTimeout (NtsClientContext *context, systime_t timeout)
 Set communication timeout. More...
 
error_t ntsClientRegisterTlsInitCallback (NtsClientContext *context, NtsClientTlsInitCallback callback)
 Register TLS initialization callback function. More...
 
error_t ntsClientRegisterRandCallback (NtsClientContext *context, NtsClientRandCallback callback)
 Register random data generation callback function. More...
 
error_t ntsClientBindToInterface (NtsClientContext *context, NetInterface *interface)
 Bind the NTS client to a particular network interface. More...
 
error_t ntsClientSetServerAddr (NtsClientContext *context, const IpAddr *serverIpAddr, uint16_t serverPort)
 Specify the IP address of the NTS server. More...
 
error_t ntsClientGetTimestamp (NtsClientContext *context, NtpTimestamp *timestamp)
 Retrieve current time from NTS server. More...
 
uint32_t ntsClientGetKissCode (NtsClientContext *context)
 Retrieve the kiss code from a Kiss-of-Death message. More...
 
void ntsClientDeinit (NtsClientContext *context)
 Release NTS client context. More...
 

Detailed Description

NTS client (Network Time Security)

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

Network Time Security (NTS) is a mechanism for using TLS and AEAD to provide cryptographic security for the client-server mode of the NTP. Refer to RFC 8915 for more details

Author
Oryx Embedded SARL (www.oryx-embedded.com)
Version
2.4.4

Definition in file nts_client.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   NTS_TRACE_LEVEL

Definition at line 38 of file nts_client.c.

Function Documentation

◆ ntsClientBindToInterface()

error_t ntsClientBindToInterface ( NtsClientContext context,
NetInterface interface 
)

Bind the NTS client to a particular network interface.

Parameters
[in]contextPointer to the NTS client context
[in]interfaceNetwork interface to be used
Returns
Error code

Definition at line 155 of file nts_client.c.

◆ ntsClientDeinit()

void ntsClientDeinit ( NtsClientContext context)

Release NTS client context.

Parameters
[in]contextPointer to the NTS client context

Definition at line 452 of file nts_client.c.

◆ ntsClientGetKissCode()

uint32_t ntsClientGetKissCode ( NtsClientContext context)

Retrieve the kiss code from a Kiss-of-Death message.

Parameters
[in]contextPointer to the NTS client context
Returns
Kiss code

Definition at line 426 of file nts_client.c.

◆ ntsClientGetTimestamp()

error_t ntsClientGetTimestamp ( NtsClientContext context,
NtpTimestamp timestamp 
)

Retrieve current time from NTS server.

Parameters
[in]contextPointer to the NTS client context
[out]timestampPointer to the NTP timestamp
Returns
Error code

Definition at line 209 of file nts_client.c.

◆ ntsClientInit()

error_t ntsClientInit ( NtsClientContext context)

Initialize NTS client context.

Parameters
[in]contextPointer to the NTS client context
Returns
Error code

Definition at line 56 of file nts_client.c.

◆ ntsClientRegisterRandCallback()

error_t ntsClientRegisterRandCallback ( NtsClientContext context,
NtsClientRandCallback  callback 
)

Register random data generation callback function.

Parameters
[in]contextPointer to the NTS client context
[in]callbackRandom data generation callback function
Returns
Error code

Definition at line 133 of file nts_client.c.

◆ ntsClientRegisterTlsInitCallback()

error_t ntsClientRegisterTlsInitCallback ( NtsClientContext context,
NtsClientTlsInitCallback  callback 
)

Register TLS initialization callback function.

Parameters
[in]contextPointer to the NTS client context
[in]callbackTLS initialization callback function
Returns
Error code

Definition at line 111 of file nts_client.c.

◆ ntsClientSetServerAddr()

error_t ntsClientSetServerAddr ( NtsClientContext context,
const IpAddr serverIpAddr,
uint16_t  serverPort 
)

Specify the IP address of the NTS server.

Parameters
[in]contextPointer to the NTS client context
[in]serverIpAddrIP address of the NTS server
[in]serverPortPort number
Returns
Error code

Definition at line 178 of file nts_client.c.

◆ ntsClientSetTimeout()

error_t ntsClientSetTimeout ( NtsClientContext context,
systime_t  timeout 
)

Set communication timeout.

Parameters
[in]contextPointer to the NTS client context
[in]timeoutTimeout value, in milliseconds
Returns
Error code

Definition at line 90 of file nts_client.c.