[Git][NTPsec/ntpsec][master] Filled out ntpAssociationTable

Ian Bruene gitlab at mg.gitlab.com
Tue Nov 21 17:35:07 UTC 2017


Ian Bruene pushed to branch master at NTPsec / ntpsec


Commits:
bf354a02 by Ian Bruene at 2017-11-21T11:34:32-06:00
Filled out ntpAssociationTable

- - - - -


1 changed file:

- ntpclients/ntpsnmpd


Changes:

=====================================
ntpclients/ntpsnmpd
=====================================
--- a/ntpclients/ntpsnmpd
+++ b/ntpclients/ntpsnmpd
@@ -164,34 +164,32 @@ class DataSource:  # This may be broken up in future to be less NTP-specific
                                     2: node(None, None, False,
                                             self.sub_assocName),
                                     # ntpAssocRefId DisplayString
-                                    3: node(self.cbr_assocRefID,
-                                            None, True, None),
+                                    3: node(None, None, False,
+                                            self.sub_assocRefID),
                                     # ntpAssocAddressType
                                     #  InetAddressType
-                                    4: node(self.cbr_assocAddrType,
-                                            None, True, None),
+                                    4: node(None, None, False, None),
                                     # ntpAssocAddress
                                     #  InetAddress SIZE (4|8|16|20)
-                                    5: node(self.cbr_assocAddr,
-                                            None, True, None),
+                                    5: node(None, None, False, None),
                                     # ntpAssocOffset DisplayString
-                                    6: node(self.cbr_assocOffset,
-                                            None, True, None),
+                                    6: node(None, None, False,
+                                            self.sub_assocOffset),
                                     # ntpAssocStratum NtpStratum
-                                    7: node(self.cbr_assocStratum,
-                                            None, True, None),
+                                    7: node(None, None, False,
+                                            self.sub_assocStratum),
                                     # ntpAssocStatusJitter
                                     #  DisplayString
-                                    8: node(self.cbr_assocStatusJitter,
-                                            None, True, None),
+                                    8: node(None, None, False,
+                                            self.sub_assocJitter),
                                     # ntpAssocStatusDelay
                                     #  DisplayString
-                                    9: node(self.cbr_assocStatusDelay,
-                                            None, True, None),
+                                    9: node(None, None, False,
+                                            self.sub_assocDelay),
                                     # ntpAssocStatusDispersion
                                     #  DisplayString
-                                    10: node(self.cbr_assocStatusDisp,
-                                             None, True, None)})}),
+                                    10: node(None, None, False,
+                                             self.sub_assocDispersion)})}),
                         # ntpAssociationStatisticsTable
                         #  SEQUENCE of ntpAssociationStatisticsEntry
                         2:
@@ -444,24 +442,13 @@ class DataSource:  # This may be broken up in future to be less NTP-specific
 
     ##############################
 
-    # assocID: dynamic
-    # assocName: dynamic
-
-    def cbr_assocRefID(self, oid):  # DUMMY
-        # DisplayString
-        return ax.Varbind(ax.VALUE_OCTET_STR, oid, "says;")
-
-    def cbr_assocAddrType(self, oid):  # DUMMY
-        # InetAddressType (range of ints)
-        return ax.Varbind(ax.VALUE_INTEGER, oid, 3)
-
-    def cbr_assocAddr(self, oid):  # DUMMY
-        # InetAddress
-        return ax.Varbind(ax.VALUE_OCTET_STR, oid, "\x01\x02\x03\x04")
-
-    def cbr_assocOffset(self, oid):  # DUMMY
-        # DisplayString
-        return ax.Varbind(ax.VALUE_OCTET_STR, oid, "Would")
+    # == Dynamics ==
+    # assocID
+    # assocName
+    # assocRefID
+    # assocAddrType
+    # assocAddr
+    # assocOffset
 
     def cbr_assocStratum(self, oid):  # DUMMY
         # NTPStratum
@@ -564,11 +551,11 @@ class DataSource:  # This may be broken up in future to be less NTP-specific
         return subs
 
     def sub_assocName(self):
-        def readCallback(oid):  # DUMMY
+        def readCallback(oid):
             index = oid.subids[-1]  # if called properly this works (Ha!)
             pdata = self.misc_getPeerData()
             associd = self.misc_getPeerIDs()[index]
-            srcadr = pdata[associd]["srcadr"][1]
+            srcadr = pdata[associd]["srcadr"][1]  # TODO: DNS
             return ax.Varbind(ax.VALUE_OCTET_STR, oid, srcadr)
         subs = {}
         associds = self.misc_getPeerIDs()  # need the peer count
@@ -576,6 +563,92 @@ class DataSource:  # This may be broken up in future to be less NTP-specific
             subs[i] = ax.mibnode(readCallback, None, None, None)
         return subs
 
+    def sub_assocRefID(self):
+        def readCallback(oid):
+            index = oid.subids[-1]  # if called properly this works (Ha!)
+            pdata = self.misc_getPeerData()
+            associd = self.misc_getPeerIDs()[index]
+            # elaborate code in util.py indicates this may not be stable
+            try:
+                refid = pdata[associd]["refid"][1]
+            except IndexError:
+                refid = ""
+            return ax.Varbind(ax.VALUE_OCTET_STR, oid, refid)
+        subs = {}
+        associds = self.misc_getPeerIDs()  # need the peer count
+        for i in range(len(associds)):
+            subs[i] = ax.mibnode(readCallback, None, None, None)
+        return subs
+
+    ########################
+
+    def sub_assocOffset(self):
+        def readCallback(oid):
+            index = oid.subids[-1]  # if called properly this works (Ha!)
+            pdata = self.misc_getPeerData()
+            associd = self.misc_getPeerIDs()[index]
+            offset = pdata[associd]["offset"][1]
+            offset = ntp.util.unitifyvar(offset, "offset", width=None,
+                                         unitSpace=True)
+            return ax.Varbind(ax.VALUE_OCTET_STR, oid, offset)
+        subs = {}
+        associds = self.misc_getPeerIDs()  # need the peer count
+        for i in range(len(associds)):
+            subs[i] = ax.mibnode(readCallback, None, None, None)
+        return subs
+
+    def sub_assocStratum(self):
+        def readCallback(oid):
+            index = oid.subids[-1]  # if called properly this works (Ha!)
+            pdata = self.misc_getPeerData()
+            associd = self.misc_getPeerIDs()[index]
+            stratum = pdata[associd]["stratum"][0]
+            return ax.Varbind(ax.VALUE_GAUGE32, oid, stratum)
+        subs = {}
+        associds = self.misc_getPeerIDs()  # need the peer count
+        for i in range(len(associds)):
+            subs[i] = ax.mibnode(readCallback, None, None, None)
+        return subs
+
+    def sub_assocJitter(self):
+        def readCallback(oid):
+            index = oid.subids[-1]  # if called properly this works (Ha!)
+            pdata = self.misc_getPeerData()
+            associd = self.misc_getPeerIDs()[index]
+            jitter = pdata[associd]["jitter"][1]
+            return ax.Varbind(ax.VALUE_OCTET_STR, oid, jitter)
+        subs = {}
+        associds = self.misc_getPeerIDs()  # need the peer count
+        for i in range(len(associds)):
+            subs[i] = ax.mibnode(readCallback, None, None, None)
+        return subs
+
+    def sub_assocDelay(self):
+        def readCallback(oid):
+            index = oid.subids[-1]  # if called properly this works (Ha!)
+            pdata = self.misc_getPeerData()
+            associd = self.misc_getPeerIDs()[index]
+            delay = pdata[associd]["delay"][1]
+            return ax.Varbind(ax.VALUE_OCTET_STR, oid, delay)
+        subs = {}
+        associds = self.misc_getPeerIDs()  # need the peer count
+        for i in range(len(associds)):
+            subs[i] = ax.mibnode(readCallback, None, None, None)
+        return subs
+
+    def sub_assocDispersion(self):
+        def readCallback(oid):
+            index = oid.subids[-1]  # if called properly this works (Ha!)
+            pdata = self.misc_getPeerData()
+            associd = self.misc_getPeerIDs()[index]
+            dispersion = pdata[associd]["rootdisp"][1]
+            return ax.Varbind(ax.VALUE_OCTET_STR, oid, dispersion)
+        subs = {}
+        associds = self.misc_getPeerIDs()  # need the peer count
+        for i in range(len(associds)):
+            subs[i] = ax.mibnode(readCallback, None, None, None)
+        return subs
+
     # =====================================
     # Misc data helpers (not part of the MIB proper)
     # =====================================



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/bf354a028a8134b1fe9edaa701d273d56cac7b26

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/bf354a028a8134b1fe9edaa701d273d56cac7b26
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20171121/6dd274e6/attachment.html>


More information about the vc mailing list