Dependents:   Nucleo

Embed: (wiki syntax)

« Back to documentation index

sntp_client.h File Reference

sntp_client.h File Reference

SNTP client (Simple Network Time Protocol) More...

Go to the source code of this file.

Data Structures

struct  SntpClientContext
 SNTP client context. More...

Enumerations

enum  NtpLeapIndicator
 

Leap indicator.

More...
enum  NtpVersion
 

NTP version number.

More...
enum  NtpMode
 

Protocol mode.

More...

Functions

error_t sntpClientGetTimestamp (NetInterface *interface, const IpAddr *serverIpAddr, NtpTimestamp *timestamp)
 Retrieve current time from NTP server using SNTP protocol.
error_t sntpSendRequest (SntpClientContext *context)
 Send NTP request using SNTP protocol.
error_t sntpWaitForResponse (SntpClientContext *context, systime_t timeout)
 Wait for a valid response from the NTP server.
error_t sntpParseResponse (SntpClientContext *context, const NtpHeader *message, size_t length)
 Parse NTP server response.
void sntpDumpMessage (const NtpHeader *message, size_t length)
 Dump NTP message for debugging purpose.
void sntpDumpTimestamp (const NtpTimestamp *timestamp)
 Dump NTP timestamp.

Detailed Description

SNTP client (Simple Network Time Protocol)

License

Copyright (C) 2010-2017 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:
1.7.6

Definition in file sntp_client.h.


Enumeration Type Documentation

Leap indicator.

Definition at line 70 of file sntp_client.h.

enum NtpMode

Protocol mode.

Definition at line 96 of file sntp_client.h.

enum NtpVersion

NTP version number.

Definition at line 83 of file sntp_client.h.


Function Documentation

error_t sntpClientGetTimestamp ( NetInterface *  interface,
const IpAddr serverIpAddr,
NtpTimestamp *  timestamp 
)

Retrieve current time from NTP server using SNTP protocol.

Parameters:
[in]interfaceUnderlying network interface (optional parameter)
[in]serverIpAddrIP address of the NTP server
[out]timestampCurrent time
Returns:
Error code

Definition at line 55 of file sntp_client.c.

void sntpDumpMessage ( const NtpHeader *  message,
size_t  length 
)

Dump NTP message for debugging purpose.

Parameters:
[in]messagePointer to the NTP message
[in]lengthLength of the NTP message

Definition at line 280 of file sntp_client.c.

void sntpDumpTimestamp ( const NtpTimestamp *  timestamp )

Dump NTP timestamp.

Parameters:
[in]timestampPointer to the NTP timestamp

Definition at line 345 of file sntp_client.c.

error_t sntpParseResponse ( SntpClientContext context,
const NtpHeader *  message,
size_t  length 
)

Parse NTP server response.

Parameters:
[in]contextPointer to the SNTP client context
[in]messageNTP response message to parse
[in]lengthLength of the incoming NTP message
Returns:
Error code

Definition at line 238 of file sntp_client.c.

error_t sntpSendRequest ( SntpClientContext context )

Send NTP request using SNTP protocol.

Parameters:
[in]contextSNTP client context
Returns:
Error code

Definition at line 142 of file sntp_client.c.

error_t sntpWaitForResponse ( SntpClientContext context,
systime_t  timeout 
)

Wait for a valid response from the NTP server.

Parameters:
[in]contextPointer to the SNTP client context
[in]timeoutMaximum time period to wait
Returns:
Error code

Definition at line 186 of file sntp_client.c.