Skip to content

File syn_ntp_server.h

FileList > net > syn_ntp_server.h

Go to the source code of this file

Zero-Heap NTP v4 Server Protocol Engine over UDP port 123. More...

  • #include "syntropic/common/syn_defs.h"
  • #include "syntropic/port/syn_port_socket.h"
  • #include <stdbool.h>
  • #include <stddef.h>
  • #include <stdint.h>

Classes

Type Name
struct SYN_NTPServer

Public Functions

Type Name
SYN_Status syn_ntp_server_init (SYN_NTPServer * server, uint8_t stratum, uint32_t(*)(void) get_epoch_sec_cb)
Initialize NTP Server Instance.
SYN_Status syn_ntp_server_process_packet (SYN_NTPServer * server, const uint8_t request_pkt, uint8_t response_pkt)
Process an incoming 48-byte NTP client request packet and format response.

Macros

Type Name
define SYN_NTP_EPOCH_OFFSET 2208988800UL
define SYN_NTP_PACKET_LEN 48U
define SYN_NTP_SERVER_PORT 123U

Detailed Description

Implements a lightweight NTP v4 (RFC 5905) time server allowing SyntropicOS microcontrollers acting as network gateways to serve time synchronization to local network nodes using system RTC or GPS time.

Public Functions Documentation

function syn_ntp_server_init

Initialize NTP Server Instance.

SYN_Status syn_ntp_server_init (
    SYN_NTPServer * server,
    uint8_t stratum,
    uint32_t(*)(void) get_epoch_sec_cb
) 

Parameters:

  • server Pointer to NTP server instance.
  • stratum Server stratum level (e.g. 1 for GPS, 2 for SNTP relay).
  • get_epoch_sec_cb Callback returning current UTC epoch seconds.

Returns:

SYN_OK on success, SYN_INVALID_PARAM if NULL.


function syn_ntp_server_process_packet

Process an incoming 48-byte NTP client request packet and format response.

SYN_Status syn_ntp_server_process_packet (
    SYN_NTPServer * server,
    const uint8_t request_pkt,
    uint8_t response_pkt
) 

Parameters:

  • server Pointer to NTP server context.
  • request_pkt Raw 48-byte input request packet.
  • response_pkt Output 48-byte response packet buffer.

Returns:

SYN_OK on success, SYN_INVALID_PARAM if NULL or invalid.


Macro Definition Documentation

define SYN_NTP_EPOCH_OFFSET

#define SYN_NTP_EPOCH_OFFSET `2208988800UL`

Seconds offset between 1900 and 1970 UTC epochs


define SYN_NTP_PACKET_LEN

#define SYN_NTP_PACKET_LEN `48U`

Standard 48-byte NTP Packet Length


define SYN_NTP_SERVER_PORT

#define SYN_NTP_SERVER_PORT `123U`

Standard NTP UDP Server Port (123)



The documentation for this class was generated from the following file src/syntropic/net/syn_ntp_server.h