nts_client_misc.h
Go to the documentation of this file.
1 /**
2  * @file nts_client_misc.h
3  * @brief Helper functions for NTS client
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2024 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneTCP Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.4.4
29  **/
30 
31 #ifndef _NTS_CLIENT_MISC_H
32 #define _NTS_CLIENT_MISC_H
33 
34 //Dependencies
35 #include "core/net.h"
36 #include "nts/nts_client.h"
37 
38 //C++ guard
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 //NTS client related functions
45  NtsClientState newState);
46 
52 
54  const uint8_t *body, size_t length);
55 
57  const uint8_t *body, size_t length);
58 
60  const uint8_t *body, size_t length);
61 
63  const uint8_t *body, size_t length);
64 
66  const uint8_t *body, size_t length);
67 
69  const uint8_t *body, size_t length);
70 
72  const uint8_t *body, size_t length);
73 
75  const uint8_t *body, size_t length);
76 
80 
84 
86  const IpAddr *ipAddr, uint16_t port, const uint8_t *message,
87  size_t length);
88 
90  NtpTimestamp *timestamp);
91 
94 
95 //C++ guard
96 #ifdef __cplusplus
97 }
98 #endif
99 
100 #endif
error_t ntsClientShutdownNtsKeConnection(NtsClientContext *context)
Shutdown NTS-KE connection.
IP network address.
Definition: ip.h:90
NtpTimestamp
Definition: ntp_common.h:179
uint8_t message[]
Definition: chap.h:154
error_t ntsClientParseNewCookieForNtpv4Record(NtsClientContext *context, const uint8_t *body, size_t length)
Parse New Cookie for NTPv4 record.
error_t ntsClientCheckNtpTimeout(NtsClientContext *context)
Determine whether a timeout error has occurred (NTP phase)
error_t ntsClientOpenNtsKeConnection(NtsClientContext *context)
Open NTS-KE connection.
NTS client (Network Time Security)
error_t ntsClientReceiveNtpResponse(NtsClientContext *context)
Wait for NTP response.
error_t ntsClientParseNtpResponse(NtsClientContext *context, NtpTimestamp *timestamp)
Parse NTP response.
void ntsClientCloseNtpConnection(NtsClientContext *context)
Close NTP connection.
error_t
Error codes.
Definition: error.h:43
error_t ntsClientCheckNtsKeTimeout(NtsClientContext *context)
Determine whether a timeout error has occurred (NTS-KE phase)
void ntsClientChangeState(NtsClientContext *context, NtsClientState newState)
Update NTS client state.
error_t ntsClientParseEndOfMessageRecord(NtsClientContext *context, const uint8_t *body, size_t length)
Parse End of Message record.
error_t ntsClientParseWarningRecord(NtsClientContext *context, const uint8_t *body, size_t length)
Parse Warning record.
error_t ntsClientEstablishNtsKeConnection(NtsClientContext *context)
Establish NTS-KE connection.
NtsClientState
NTS client states.
Definition: nts_client.h:143
error_t ntsClientSendNtpRequest(NtsClientContext *context)
Send NTP request to the server.
error_t ntsClientParseNtpv4ServerRecord(NtsClientContext *context, const uint8_t *body, size_t length)
Parse NTPv4 Server Negotiation record.
error_t ntsClientOpenNtpConnection(NtsClientContext *context)
Open NTP connection.
error_t ntsClientSendNtsKeRequest(NtsClientContext *context)
Send NTS-KE request.
uint8_t length
Definition: tcp.h:368
#define NtsClientContext
Definition: nts_client.h:130
uint16_t port
Definition: dns_common.h:267
error_t ntsClientDecryptNtpResponse(NtsClientContext *context, const IpAddr *ipAddr, uint16_t port, const uint8_t *message, size_t length)
Decrypt NTP response.
error_t ntsClientParseAeadAlgoNegoRecord(NtsClientContext *context, const uint8_t *body, size_t length)
Parse AEAD Algorithm Negotiation record.
error_t ntsClientParseNtsNextProtoNegoRecord(NtsClientContext *context, const uint8_t *body, size_t length)
Parse NTS Next Protocol Negotiation record.
void ntsClientCloseNtsKeConnection(NtsClientContext *context)
Close NTS-KE connection.
error_t ntsClientFormatNtsKeRequest(NtsClientContext *context)
Format NTS-KE request.
error_t ntsClientParseNtpv4PortRecord(NtsClientContext *context, const uint8_t *body, size_t length)
Parse NTPv4 Port Negotiation record.
Ipv4Addr ipAddr
Definition: ipcp.h:105
error_t ntsClientParseErrorRecord(NtsClientContext *context, const uint8_t *body, size_t length)
Parse Error record.
TCP/IP stack core.
uint8_t body[]
Definition: nts_common.h:106
error_t ntsClientReceiveNtsKeResponse(NtsClientContext *context)
Receive NTS-KE response.