ntp_debug.c File Reference

Data logging functions for debugging purpose (NTP) More...

#include "core/net.h"
#include "ntp/ntp_debug.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define TRACE_LEVEL   NTP_TRACE_LEVEL
 

Functions

void ntpDumpPacket (const NtpHeader *packet, size_t length)
 Dump NTP packet for debugging purpose. More...
 
void ntpDumpExtensions (const uint8_t *extensions, size_t length)
 Dump NTP extension fields. More...
 
void ntpDumpExtension (const NtpExtension *extension, size_t length)
 Dump NTP extension field. More...
 
void ntpDumpNtsAeadExtension (const NtpNtsAeadExtension *extension, size_t length)
 Dump NTS Authenticator and Encrypted Extension Fields extension. More...
 
void ntpDumpTimestamp (const NtpTimestamp *timestamp)
 Dump NTP timestamp. More...
 
const char_tntpGetParamName (uint_t value, const NtpParamName *paramList, size_t paramListLen)
 Convert a parameter to string representation. More...
 

Variables

const NtpParamName ntpLeapIndicatorList []
 
const NtpParamName ntpVersionList []
 
const NtpParamName ntpModeList []
 
const NtpParamName ntpStartumList []
 
const NtpParamName ntpExtensionTypeList []
 

Detailed Description

Data logging functions for debugging purpose (NTP)

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.

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

Definition in file ntp_debug.c.

Macro Definition Documentation

◆ TRACE_LEVEL

#define TRACE_LEVEL   NTP_TRACE_LEVEL

Definition at line 32 of file ntp_debug.c.

Function Documentation

◆ ntpDumpExtension()

void ntpDumpExtension ( const NtpExtension extension,
size_t  length 
)

Dump NTP extension field.

Parameters
[in]extensionPointer to the extension field
[in]lengthLength of the extension field, in bytes

Definition at line 246 of file ntp_debug.c.

◆ ntpDumpExtensions()

void ntpDumpExtensions ( const uint8_t *  extensions,
size_t  length 
)

Dump NTP extension fields.

Parameters
[in]extensionsPointer to the extension fields
[in]lengthTotal length of the extension fields, in bytes

Definition at line 212 of file ntp_debug.c.

◆ ntpDumpNtsAeadExtension()

void ntpDumpNtsAeadExtension ( const NtpNtsAeadExtension extension,
size_t  length 
)

Dump NTS Authenticator and Encrypted Extension Fields extension.

Parameters
[in]extensionPointer to the extension field
[in]lengthLength of the extension field, in bytes

Definition at line 295 of file ntp_debug.c.

◆ ntpDumpPacket()

void ntpDumpPacket ( const NtpHeader packet,
size_t  length 
)

Dump NTP packet for debugging purpose.

Parameters
[in]packetPointer to the NTP packet to dump
[in]lengthLength of the packet, in bytes

Definition at line 108 of file ntp_debug.c.

◆ ntpDumpTimestamp()

void ntpDumpTimestamp ( const NtpTimestamp timestamp)

Dump NTP timestamp.

Parameters
[in]timestampPointer to the NTP timestamp

Definition at line 331 of file ntp_debug.c.

◆ ntpGetParamName()

const char_t* ntpGetParamName ( uint_t  value,
const NtpParamName paramList,
size_t  paramListLen 
)

Convert a parameter to string representation.

Parameters
[in]valueParameter value
[in]paramListList of acceptable parameters
[in]paramListLenNumber of entries in the list
Returns
NULL-terminated string describing the parameter

Definition at line 348 of file ntp_debug.c.

Variable Documentation

◆ ntpExtensionTypeList

const NtpParamName ntpExtensionTypeList[]
Initial value:
=
{
{NTP_EXTENSION_TYPE_NO_OPERATION_REQ, "No-Operation Request"},
{NTP_EXTENSION_TYPE_UNIQUE_ID, "Unique Identifier"},
{NTP_EXTENSION_TYPE_NTS_COOKIE_PLACEHOLDER, "NTS Cookie Placeholder"},
{NTP_EXTENSION_TYPE_NTS_AEAD, "NTS Authenticator and Encrypted Extension Fields"},
{NTP_EXTENSION_TYPE_NO_OPERATION_RESP, "No-Operation Response"},
{NTP_EXTENSION_TYPE_NO_OPERATION_ERROR_RESP, "No-Operation Error Response"}
}

Definition at line 90 of file ntp_debug.c.

◆ ntpLeapIndicatorList

const NtpParamName ntpLeapIndicatorList[]
Initial value:
=
{
{NTP_LI_NO_WARNING, "no warning"},
{NTP_LI_LAST_MIN_HAS_61_SECS, "last minute has 61 seconds"},
{NTP_LI_LAST_MIN_HAS_59_SECS, "last minute has 59 seconds"},
{NTP_LI_ALARM_CONDITION, "alarm condition"}
}

Definition at line 43 of file ntp_debug.c.

◆ ntpModeList

const NtpParamName ntpModeList[]
Initial value:
=
{
{NTP_MODE_SYMMETRIC_ACTIVE, "symmetric active"},
{NTP_MODE_SYMMETRIC_PASSIVE, "symmetric passive"},
{NTP_MODE_CLIENT, "client"},
{NTP_MODE_SERVER, "server"},
{NTP_MODE_BROADCAST, "broadcast"}
}

Definition at line 59 of file ntp_debug.c.

◆ ntpStartumList

const NtpParamName ntpStartumList[]
Initial value:
=
{
{NTP_STRATUM_KISS_OF_DEATH, "kiss-of-death message"},
{NTP_STRATUM_PRIMARY, "primary"},
{NTP_STRATUM_SECONDARY_2, "secondary"},
{NTP_STRATUM_SECONDARY_3, "secondary"},
{NTP_STRATUM_SECONDARY_4, "secondary"},
{NTP_STRATUM_SECONDARY_5, "secondary"},
{NTP_STRATUM_SECONDARY_6, "secondary"},
{NTP_STRATUM_SECONDARY_7, "secondary"},
{NTP_STRATUM_SECONDARY_8, "secondary"},
{NTP_STRATUM_SECONDARY_9, "secondary"},
{NTP_STRATUM_SECONDARY_10, "secondary"},
{NTP_STRATUM_SECONDARY_11, "secondary"},
{NTP_STRATUM_SECONDARY_12, "secondary"},
{NTP_STRATUM_SECONDARY_13, "secondary"},
{NTP_STRATUM_SECONDARY_14, "secondary"},
{NTP_STRATUM_SECONDARY_15, "secondary"}
}

Definition at line 69 of file ntp_debug.c.

◆ ntpVersionList

const NtpParamName ntpVersionList[]
Initial value:
=
{
{NTP_VERSION_3, "NTPv3"},
{NTP_VERSION_4, "NTPv4"}
}

Definition at line 52 of file ntp_debug.c.

@ NTP_STRATUM_SECONDARY_2
Definition: ntp_common.h:101
@ NTP_EXTENSION_TYPE_NTS_COOKIE
NTS Cookie.
Definition: ntp_common.h:155
@ NTP_LI_NO_WARNING
Definition: ntp_common.h:59
@ NTP_STRATUM_SECONDARY_13
Definition: ntp_common.h:112
@ NTP_MODE_SERVER
Definition: ntp_common.h:88
@ NTP_STRATUM_SECONDARY_6
Definition: ntp_common.h:105
@ NTP_STRATUM_SECONDARY_7
Definition: ntp_common.h:106
@ NTP_STRATUM_SECONDARY_8
Definition: ntp_common.h:107
@ NTP_EXTENSION_TYPE_NO_OPERATION_ERROR_RESP
No-Operation Error Response.
Definition: ntp_common.h:159
@ NTP_MODE_BROADCAST
Definition: ntp_common.h:89
@ NTP_STRATUM_SECONDARY_4
Definition: ntp_common.h:103
@ NTP_STRATUM_SECONDARY_9
Definition: ntp_common.h:108
@ NTP_EXTENSION_TYPE_NO_OPERATION_REQ
No-Operation Request.
Definition: ntp_common.h:153
@ NTP_MODE_SYMMETRIC_PASSIVE
Definition: ntp_common.h:86
@ NTP_STRATUM_SECONDARY_12
Definition: ntp_common.h:111
@ NTP_STRATUM_SECONDARY_10
Definition: ntp_common.h:109
@ NTP_EXTENSION_TYPE_UNIQUE_ID
Unique Identifier.
Definition: ntp_common.h:154
@ NTP_STRATUM_SECONDARY_15
Definition: ntp_common.h:114
@ NTP_VERSION_3
Definition: ntp_common.h:74
@ NTP_LI_LAST_MIN_HAS_61_SECS
Definition: ntp_common.h:60
@ NTP_LI_ALARM_CONDITION
Definition: ntp_common.h:62
@ NTP_LI_LAST_MIN_HAS_59_SECS
Definition: ntp_common.h:61
@ NTP_STRATUM_KISS_OF_DEATH
Definition: ntp_common.h:99
@ NTP_MODE_CLIENT
Definition: ntp_common.h:87
@ NTP_STRATUM_SECONDARY_14
Definition: ntp_common.h:113
@ NTP_EXTENSION_TYPE_NO_OPERATION_RESP
No-Operation Response.
Definition: ntp_common.h:158
@ NTP_STRATUM_PRIMARY
Definition: ntp_common.h:100
@ NTP_STRATUM_SECONDARY_11
Definition: ntp_common.h:110
@ NTP_STRATUM_SECONDARY_5
Definition: ntp_common.h:104
@ NTP_EXTENSION_TYPE_NTS_COOKIE_PLACEHOLDER
NTS Cookie Placeholder.
Definition: ntp_common.h:156
@ NTP_STRATUM_SECONDARY_3
Definition: ntp_common.h:102
@ NTP_MODE_SYMMETRIC_ACTIVE
Definition: ntp_common.h:85
@ NTP_VERSION_4
Definition: ntp_common.h:75
@ NTP_EXTENSION_TYPE_NTS_AEAD
NTS Authenticator and Encrypted Extension Fields.
Definition: ntp_common.h:157