summaryrefslogtreecommitdiff
path: root/net/ntp.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ntp.c')
-rw-r--r--net/ntp.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/net/ntp.c b/net/ntp.c
new file mode 100644
index 0000000..137d677
--- /dev/null
+++ b/net/ntp.c
@@ -0,0 +1,36 @@
+#include "udp.h"
+#include "ntp.h"
+
+uint32_t ntp_generic(struct netdev *dev, uint32_t ip, uint16_t src, uint16_t dst, uint8_t* pos,uint8_t *end)
+{
+ pos-=48; // we need 48 bytes
+ struct udp_v4_ntp *ntp=pos;
+
+ ntp->li_vn_mode=0x1b; // Eight bits. li, vn, and mode.
+ // li. Two bits. Leap indicator.
+ // vn. Three bits. Version number of the protocol.
+ // mode. Three bits. Client will pick mode 3 for client.
+
+ ntp->stratum=0; // Eight bits. Stratum level of the local clock.
+ ntp->poll=0; // Eight bits. Maximum interval between successive messages.
+ ntp->precision=0; // Eight bits. Precision of the local clock.
+
+ ntp->rootDelay=0; // 32 bits. Total round trip delay time.
+ ntp->rootDispersion=0; // 32 bits. Max error aloud from primary clock source.
+ ntp->refId=0; // 32 bits. Reference clock identifier.
+
+ ntp->refTm_s=0; // 32 bits. Reference time-stamp seconds.
+ ntp->refTm_f=0; // 32 bits. Reference time-stamp fraction of a second.
+
+ ntp->origTm_s=0; // 32 bits. Originate time-stamp seconds.
+ ntp->origTm_f=0; // 32 bits. Originate time-stamp fraction of a second.
+
+ ntp->rxTm_s=0; // 32 bits. Received time-stamp seconds.
+ ntp->rxTm_f=0; // 32 bits. Received time-stamp fraction of a second.
+
+ ntp->txTm_s=0; // 32 bits and the most important field the client cares about. Transmit time-stamp seconds.
+ ntp->txTm_f=0; // 32 bits. Transmit time-stamp fraction of a second.
+
+ return udp_generic(dev, ip, src, dst, pos,end);
+}
+