A stack which works with or without an Mbed os library. Provides IPv4 or IPv6 with a full 1500 byte buffer.
Dependents: oldheating gps motorhome heating
Diff: udp/ntp/ntp.h
- Revision:
- 113:904b40231907
- Parent:
- 112:f8694d0b8858
- Child:
- 138:5ff0c7069300
--- a/udp/ntp/ntp.h Mon Jan 21 16:58:28 2019 +0000 +++ b/udp/ntp/ntp.h Tue Jan 22 15:41:12 2019 +0000 @@ -1,16 +1,31 @@ -extern bool NtpTrace; +#pragma once -extern bool NtpServerEnable; -extern uint64_t (*NtpFunctionGetClockRef) (); -extern int (*NtpFunctionGetClockStratum) (); -extern char* (*NtpFunctionGetClockIdent) (); -extern int (*NtpFunctionGetClockLi) (); -extern int (*NtpFunctionGetClockPrecision)(); +__packed struct NtpHeader +{ + unsigned Mode : 3; + unsigned VN : 3; + unsigned LI : 2; + uint8_t Stratum; + int8_t Poll; + int8_t Precision; + uint32_t RootDelay; + uint32_t Dispersion; + char RefIdentifier[4]; + + uint64_t RefTimeStamp; + uint64_t OriTimeStamp; + uint64_t RecTimeStamp; + uint64_t TraTimeStamp; +}; -extern void NtpHdrWriteRequest(void* pPacket, int* pSize); +extern bool NtpTrace; extern int NtpHandlePacketReceived(void (*traceback)(void), int sizeRx, void* pPacketRx, int* pSizeTx, void* pPacketTx); extern int NtpPollForPacketToSend(int type, void* pPacket, int* pSize); - +extern void NtpLogHeader(struct NtpHeader* pHeader); +extern void NtpInit(void); -#define NTP_PORT 123 \ No newline at end of file +#define NTP_PORT 123 + +#define NTP_CLIENT 3 +#define NTP_SERVER 4 \ No newline at end of file