pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/43377?usp=email )

Change subject: Introduce library/NTP_Functions.ttcn
......................................................................

Introduce library/NTP_Functions.ttcn

This is useful to encdec timestamps in NTP format, which are used by
other protocols, eg. PFCP.

Change-Id: I1551c3424679da8cb71aadb6f34a545c698eb329
---
A library/NTP_Functions.ttcn
1 file changed, 36 insertions(+), 0 deletions(-)

Approvals:
  fixeria: Looks good to me, approved
  Jenkins Builder: Verified
  osmith: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved




diff --git a/library/NTP_Functions.ttcn b/library/NTP_Functions.ttcn
new file mode 100644
index 0000000..4072153
--- /dev/null
+++ b/library/NTP_Functions.ttcn
@@ -0,0 +1,36 @@
+/* NTP Functions in TTCN-3, (RFC 5905)
+ * (C) 2026 sysmocom - s.f.m.c. GmbH <[email protected]>
+ * All rights reserved.
+ *
+ * Released under the terms of GNU General Public License, Version 2 or
+ * (at your option) any later version.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+module NTP_Functions {
+
+import from TCCDateTime_Functions all;
+
+const integer TIME_NTP32_1970_1900_SEC_DIFF := 2208988800; /* 1970 - 1900 in 
seconds */
+
+function f_time_to_ntp32(integer time) return integer
+{
+       return (time + TIME_NTP32_1970_1900_SEC_DIFF) mod 4294967296;
+}
+
+function f_time_from_ntp32(integer ntp_timestamp) return integer
+{
+       if (ntp_timestamp < TIME_NTP32_1970_1900_SEC_DIFF) {
+               return 0;
+       }
+       return ntp_timestamp - TIME_NTP32_1970_1900_SEC_DIFF;
+}
+
+function f_time_ntp32_now() return integer
+{
+       var integer now := f_time();
+       return f_time_to_ntp32(now);
+}
+
+}

--
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/43377?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I1551c3424679da8cb71aadb6f34a545c698eb329
Gerrit-Change-Number: 43377
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: osmith <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>

Reply via email to