[Git][NTPsec/ntpsec][master] AgentX x-coders now return dicts instead of unreadable tuple-forrests

Ian Bruene gitlab at mg.gitlab.com
Tue Jul 18 20:50:29 UTC 2017


Ian Bruene pushed to branch master at NTPsec / ntpsec


Commits:
f4aace48 by Ian Bruene at 2017-07-18T15:35:45-05:00
AgentX x-coders now return dicts instead of unreadable tuple-forrests

- - - - -


2 changed files:

- pylib/agentx.py
- tests/pylib/test_agentx.py


Changes:

=====================================
pylib/agentx.py
=====================================
--- a/pylib/agentx.py
+++ b/pylib/agentx.py
@@ -57,7 +57,8 @@ def decode_openpdu(data, flags):
     timeout = struct.unpack("Bxxx", temp)[0]
     oid, data = decode_oid(data, flags)
     octets = decode_octetstr(data, flags)[0]
-    return (timeout, oid, octets)
+    result = {"timeout": timeout, "oid": oid, "description": octets}
+    return result
 
 
 def encode_closepdu(sID, tactID, pktID, reason):
@@ -70,7 +71,7 @@ def encode_closepdu(sID, tactID, pktID, reason):
 
 
 def decode_closepdu(data, flags):
-    reason = ord(data[0])  # Bxxx
+    reason = {"reason": ord(data[0])}  # Bxxx
     return reason
 
 
@@ -108,7 +109,9 @@ def decode_registerpdu_core(data, flags):
         upperBound = struct.unpack(endianToken + "I", temp)[0]
     else:
         upperBound = None
-    result = (oid, timeout, priority, context, rangeSubid, upperBound)
+    result = {"oid": oid, "timeout": timeout, "priority": priority,
+              "context": context, "range_subid": rangeSubid,
+              "upper_bound": upperBound}
     return result
 
 
@@ -131,7 +134,7 @@ decode_registerpdu = decode_registerpdu_core
 
 def decode_unregisterpdu(data, flags):
     result = decode_registerpdu_core(data, flags)
-    result = (result[0],) + result[2:]  # Remove the timeout
+    del result["timeout"]
     return result
 
 
@@ -150,7 +153,8 @@ def encode_getpdu_core(isnext, sID, tactID, pktID, oidranges, context=None):
 def decode_getpdu_core(data, flags):
     context, data = decode_context(data, flags)
     oidranges, data = decode_searchrange_list(data, flags)
-    return (context, oidranges)
+    result = {"context": context, "oidranges": oidranges}
+    return result
 
 
 def encode_getpdu(sID, tactID, pktID, oidranges, context=None):
@@ -180,7 +184,8 @@ def decode_getbulkpdu(data, flags):
     temp, data = slicedata(data, 4)
     nonReps, maxReps = struct.unpack(endianToken + "HH", temp)
     oidranges, data = decode_searchrange_list(data, flags)
-    result = (context, nonReps, maxReps, oidranges)
+    result = {"context": context, "non_reps": nonReps, "max_reps": maxReps,
+              "oidranges": oidranges}
     return result
 
 
@@ -195,7 +200,8 @@ def encode_testsetpdu(sID, tactID, pktID, varbinds, context=None):
 def decode_testsetpdu(data, flags):
     context, data = decode_context(data, flags)
     varbinds = decode_varbindlist(data, flags)
-    return context, varbinds
+    result = {"context": context, "varbinds": varbinds}
+    return result
 
 
 # CommitSet, UndoSet, and CleanupSet are bare headers. Don't need decoders
@@ -224,7 +230,7 @@ def encode_pingpdu(sID, tactID, pktID, context=None):
 
 def decode_pingpdu(data, flags):
     context, data = decode_context(data, flags)
-    return context
+    return {"context": context}
 
 
 def encode_notifypdu(sID, tactID, pktID, varbinds, context=None):
@@ -238,7 +244,8 @@ def encode_notifypdu(sID, tactID, pktID, varbinds, context=None):
 def decode_notifypdu(data, flags):
     context, data = decode_context(data, flags)
     varbinds = decode_varbindlist(data, flags)
-    return (context, varbinds)
+    result = {"context": context, "varbinds": varbinds}
+    return result
 
 
 def encode_indexallocpdu_core(isdealloc,
@@ -269,7 +276,8 @@ def encode_indexdeallocpdu(sID, tactID, pktID, newIndex, anyIndex,
 def decode_indexallocpdu(data, flags):
     context, data = decode_context(data, flags)
     varbinds = decode_varbindlist(data, flags)
-    return (context, varbinds)
+    result = {"context": context, "varbinds": varbinds}
+    return result
 
 
 decode_indexdeallocpdu = decode_indexallocpdu
@@ -288,9 +296,9 @@ def encode_addagentcapspdu(sID, tactID, pktID, oid, descr, context=None):
 def decode_addagentcapspdu(data, flags):
     context, data = decode_context(data, flags)
     oid, data = decode_oid(data, flags)
-    oid = oid[0]  # we don't need the include field here
     descr = decode_octetstr(data, flags)[0]
-    return (context, oid, descr)
+    result = {"context": context, "oid": oid, "description": descr}
+    return result
 
 
 def encode_rmagentcapspdu(sID, tactID, pktID, oid, context=None):
@@ -305,8 +313,8 @@ def encode_rmagentcapspdu(sID, tactID, pktID, oid, context=None):
 def decode_rmagentcapspdu(data, flags):
     context, data = decode_context(data, flags)
     oid, data = decode_oid(data, flags)
-    oid = oid[0]  # we don't need the include here
-    return (context, oid)
+    result = {"context": context, "oid": oid}
+    return result
 
 
 def encode_responsepdu(sID, tactID, pktID,
@@ -328,7 +336,9 @@ def decode_responsepdu(data, flags):
         varbinds = decode_varbindlist(data, flags)
     else:
         varbinds = None
-    return (sysUpTime, resError, resIndex, varbinds)
+    result = {"sys_uptime": sysUpTime, "res_err": resError,
+              "res_index": resIndex, "varbinds": varbinds}
+    return result
 
 
 # ========================================================================
@@ -380,7 +390,8 @@ def decode_oid(data, flags):
     endianToken = getendian(flags)
     formatString = endianToken + ("I" * n_subid)
     subids += struct.unpack(formatString, data)
-    return ((subids, include), rest)
+    result = {"subids": subids, "include": include}
+    return (result, rest)
 
 
 def encode_octetstr(octets):
@@ -428,12 +439,12 @@ def decode_varbind(data, flags):
     header, data = slicedata(data, 4)
     endianToken = getendian(flags)
     valType = struct.unpack(endianToken + "Hxx", header)[0]
-    (name, _), data = decode_oid(data, flags)
+    name, data = decode_oid(data, flags)
     if valType not in definedValueTypes.keys():
         raise ValueError("Value type %s not in defined types" % valType)
     handlers = definedValueTypes[valType]
     payload, data = handlers[1](data, flags)
-    result = (valType, name, payload)
+    result = {"type": valType, "name": name, "data": payload}
     return result, data
 
 
@@ -488,7 +499,8 @@ def encode_searchrange(startOID, endOID, inclusiveP):
 def decode_searchrange(data, flags):
     startOID, data = decode_oid(data, flags)
     endOID, data = decode_oid(data, flags)
-    return (startOID, endOID, data)
+    result = {"start": startOID, "end": endOID}
+    return result, data
 
 
 def encode_searchrange_list(oidranges):
@@ -507,7 +519,7 @@ def decode_searchrange_list(data, flags):
         if isnullOID(one):
             break
         two, data = decode_oid(data, flags)
-        oidranges.append((one[0], two[0], one[1]))  # oid, oid, inclusive
+        oidranges.append({"start": one, "end": two})  # oid, oid, inclusive
     return tuple(oidranges), data
 
 
@@ -524,7 +536,7 @@ def slicedata(data, slicepoint):
 
 
 def isnullOID(oid):
-    if (len(oid[0]) == 0) and (oid[1] is False):
+    if (len(oid["subids"]) == 0) and (oid["include"] is False):
         return True
     return False
 
@@ -541,7 +553,6 @@ def decode_varbindlist(data, flags):
         varbinds = []
         while len(data) > 0:
             vb, data = decode_varbind(data, flags)
-            vb = tuple(vb)
             varbinds.append(vb)
         varbinds = tuple(varbinds)
     else:
@@ -564,7 +575,7 @@ def encode_pduheader(pduType, instanceRegistration, newIndex,
     flags |= newIndex << 1
     flags |= anyIndex << 2
     flags |= nonDefaultContext << 3
-    flags |= True << 4  # network byte order, we always send big endian
+    flags |= True << 4  # byte order, we always send network / big endian
     data = struct.pack(">BBBxIIII", 1, pduType, flags,
                        sessionID,
                        transactionID,
@@ -590,7 +601,10 @@ def decode_pduheader(data):  # Endianess is controlled from the PDU header
     fmt = getendian(flagDict) + "IIII"
     linen, data = slicedata(data, 16)  # 4 x 4-byte variables
     sID, tactionID, pktID, dataLen = struct.unpack(fmt, linen)
-    return (version, pduType, flagDict, sID, tactionID, pktID, dataLen)
+    result = {"version": version, "type": pduType, "flags": flagDict,
+              "session_id": sID, "transaction_id": tactionID,
+              "packet_id": pktID, "length": dataLen}
+    return result
 
 
 def encode_context(context):
@@ -614,19 +628,19 @@ def decode_context(data, flags):
 def decode_packet(data):
     header, data = slicedata(data, 20)
     header = decode_pduheader(header)
-    version, pduType, flags, sID, tactID, pktID, dataLen = header
-    if version != 1:
-        raise ValueError("Unknown packet version", version)
-    if pduType not in definedPDUTypes.keys():
-        raise ValueError("PDU type %s not in defined types" % pduType)
-    headerData = (pduType, flags, sID, tactID, pktID)
-    decoder = definedPDUTypes[pduType]
+    if header["version"] != 1:
+        raise ValueError("Unknown packet version", header["version"])
+    pktType = header["type"]
+    if pktType not in definedPDUTypes.keys():
+        raise ValueError("PDU type %s not in defined types" % pktType)
+    decoder = definedPDUTypes[pktType]
     if decoder is None:
         parsedPkt = None
     else:
-        packetSlice, data = slicedata(data, dataLen)
-        parsedPkt = decoder(packetSlice, flags)
-    return headerData + (parsedPkt,)
+        packetSlice, data = slicedata(data, header["length"])
+        parsedPkt = decoder(packetSlice, header["flags"])
+    result = {"header": header, "body": parsedPkt}
+    return result, data
 
 
 # Value types
@@ -720,3 +734,8 @@ ERR_INCONSISTENT_VALUE = 12
 ERR_RESOURCE_UNAVAILABLE = 13
 ERR_NOT_WRITABLE = 17
 ERR_INCONSISTENT_NAME = 18
+definedErrors = (ERR_NOERROR, ERR_GENERR, ERR_NO_ACCESS, ERR_WRONG_TYPE,
+                 ERR_WRONG_LEN, ERR_WRONG_ENCODING, ERR_WRONG_VALUE,
+                 ERR_NO_CREATION, ERR_INCONSISTENT_VALUE,
+                 ERR_RESOURCE_UNAVAILABLE, ERR_NOT_WRITABLE,
+                 ERR_INCONSISTENT_NAME)


=====================================
tests/pylib/test_agentx.py
=====================================
--- a/tests/pylib/test_agentx.py
+++ b/tests/pylib/test_agentx.py
@@ -105,21 +105,27 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
         # Test null packet
         self.assertEqual(f("\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00",
                            standardFlags),
-                         (0, ((), False), ""))
+                         {"timeout": 0,
+                          "oid": {"subids": (), "include": False},
+                          "description": ""})
         # Test basic packet
         self.assertEqual(f("\x4E\x00\x00\x00"
                            "\x04\x00\x00\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02"
                            "\x00\x00\x00\x03\x00\x00\x00\x04"
                            "\x00\x00\x00\x03foo\x00", standardFlags),
-                          (78, ((1, 2, 3, 4), False), "foo"))
+                         {"timeout": 78,
+                          "oid": {"subids": (1, 2, 3, 4), "include": False},
+                          "description": "foo"})
         # Test basic packet, little endian
         self.assertEqual(f("\x4E\x00\x00\x00"
                            "\x04\x00\x00\x00"
                            "\x01\x00\x00\x00\x02\x00\x00\x00"
                            "\x03\x00\x00\x00\x04\x00\x00\x00"
                            "\x03\x00\x00\x00foo\x00", lilEndianFlags),
-                          (78, ((1, 2, 3, 4), False), "foo"))
+                         {"timeout": 78,
+                          "oid": {"subids": (1, 2, 3, 4), "include": False},
+                          "description": "foo"})
 
     def test_encode_closepdu(self):
         f = ntp.agentx.encode_closepdu
@@ -136,7 +142,8 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
         f = ntp.agentx.decode_closepdu
 
         # Test
-        self.assertEqual(f("\x01\x00\x00\x00", standardFlags), 1)
+        self.assertEqual(f("\x01\x00\x00\x00", standardFlags),
+                         {"reason": 1})
 
     def test_encode_registerpdu(self):
         f = ntp.agentx.encode_registerpdu
@@ -187,29 +194,39 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
         self.assertEqual(f("\x04\x05\x00\x00"
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x03", standardFlags),
-                         (((1, 2, 3), False), 4, 5, None, 0, None))
+                         {"oid": {"subids": (1, 2, 3), "include": False},
+                          "timeout": 4, "priority": 5, "context": None,
+                          "range_subid": 0, "upper_bound": None})
         # Test basic, little endian
         self.assertEqual(f("\x04\x05\x00\x00"
                            "\x03\x00\x00\x00\x01\x00\x00\x00"
                            "\x02\x00\x00\x00\x03\x00\x00\x00", lilEndianFlags),
-                         (((1, 2, 3), False), 4, 5, None, 0, None))
+                         {"oid": {"subids": (1, 2, 3), "include": False},
+                          "timeout": 4, "priority": 5, "context": None,
+                          "range_subid": 0, "upper_bound": None})
         # Test with context
         self.assertEqual(f("\x00\x00\x00\x04blah\x04\x05\x00\x00"
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x03", contextFlags),
-                         (((1, 2, 3), False), 4, 5, "blah", 0, None))
+                         {"oid": {"subids": (1, 2, 3), "include": False},
+                          "timeout": 4, "priority": 5, "context": "blah",
+                          "range_subid": 0, "upper_bound": None})
         # Test with range
         self.assertEqual(f("\x04\x05\x05\x00"
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x03"
                            "\x00\x00\x00\x17", standardFlags),
-                         (((1, 2, 3), False), 4, 5, None, 5, 23))
+                         {"oid": {"subids": (1, 2, 3), "include": False},
+                          "timeout": 4, "priority": 5, "context": None,
+                          "range_subid": 5, "upper_bound": 23})
         # Test with context and range
         self.assertEqual(f("\x00\x00\x00\x04blah\x04\x05\x05\x00"
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x03"
                            "\x00\x00\x00\x17", contextFlags),
-                         (((1, 2, 3), False), 4, 5, "blah", 5, 23))
+                         {"oid": {"subids": (1, 2, 3), "include": False},
+                          "timeout": 4, "priority": 5, "context": "blah",
+                          "range_subid": 5, "upper_bound": 23})
 
     def test_encode_unregisterpdu(self):
         f = ntp.agentx.encode_unregisterpdu
@@ -260,29 +277,39 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
         self.assertEqual(f("\x00\x05\x00\x00"
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x03", standardFlags),
-                         (((1, 2, 3), False), 5, None, 0, None))
+                         {"oid": {"subids": (1, 2, 3), "include": False},
+                          "priority": 5, "context": None,
+                          "range_subid": 0, "upper_bound": None})
         # Test basic, little endian
         self.assertEqual(f("\x00\x05\x00\x00"
                            "\x03\x00\x00\x00\x01\x00\x00\x00"
                            "\x02\x00\x00\x00\x03\x00\x00\x00", lilEndianFlags),
-                         (((1, 2, 3), False), 5, None, 0, None))
+                         {"oid": {"subids": (1, 2, 3), "include": False},
+                          "priority": 5, "context": None,
+                          "range_subid": 0, "upper_bound": None})
         # Test with context
         self.assertEqual(f("\x00\x00\x00\x04blah\x00\x05\x00\x00"
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x03", contextFlags),
-                         (((1, 2, 3), False), 5, "blah", 0, None))
+                         {"oid": {"subids": (1, 2, 3), "include": False},
+                          "priority": 5, "context": "blah",
+                          "range_subid": 0, "upper_bound": None})
         # Test with range
         self.assertEqual(f("\x04\x05\x05\x00"
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x03"
                            "\x00\x00\x00\x17", standardFlags),
-                         (((1, 2, 3), False), 5, None, 5, 23))
+                         {"oid": {"subids": (1, 2, 3), "include": False},
+                          "priority": 5, "context": None,
+                          "range_subid": 5, "upper_bound": 23})
         # Test with context and range
         self.assertEqual(f("\x00\x00\x00\x04blah\x04\x05\x05\x00"
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x03"
                            "\x00\x00\x00\x17", contextFlags),
-                         (((1, 2, 3), False), 5, "blah", 5, 23))
+                         {"oid": {"subids": (1, 2, 3), "include": False},
+                          "priority": 5, "context": "blah",
+                          "range_subid": 5, "upper_bound": 23})
 
     def test_encode_getpdu(self):
         f = ntp.agentx.encode_getpdu
@@ -328,7 +355,9 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
         f = ntp.agentx.decode_getpdu
 
         # Test null
-        self.assertEqual(f("\x00\x00\x00\x00", standardFlags), (None, ()))
+        self.assertEqual(f("\x00\x00\x00\x00", standardFlags),
+                         {"context": None,
+                          "oidranges": ()})
         # Test basic
         self.assertEqual(f(
             "\x03\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03"
@@ -336,9 +365,15 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
             "\x02\x00\x01\x00\x00\x00\x00\x0A\x00\x00\x00\x14"
             "\x02\x00\x00\x00\x00\x00\x00\x1E\x00\x00\x00\x28"
             "\x00\x00\x00\x00", standardFlags),
-                         (None,
-                          (((1, 2, 3), (1, 2, 5), False),
-                           ((10, 20), (30, 40), True))))
+                         {"context": None,
+                          "oidranges": ({"start": {"subids": (1, 2, 3),
+                                                   "include": False},
+                                         "end": {"subids": (1, 2, 5),
+                                                 "include": False}},
+                                        {"start": {"subids": (10, 20),
+                                                   "include": True},
+                                         "end": {"subids": (30, 40),
+                                                 "include": False}})})
         # Test basic, little endian
         self.assertEqual(f(
             "\x03\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00"
@@ -346,9 +381,15 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
             "\x02\x00\x01\x00\x0A\x00\x00\x00\x14\x00\x00\x00"
             "\x02\x00\x00\x00\x1E\x00\x00\x00\x28\x00\x00\x00"
             "\x00\x00\x00\x00", lilEndianFlags),
-                         (None,
-                          (((1, 2, 3), (1, 2, 5), False),
-                           ((10, 20), (30, 40), True))))
+                         {"context": None,
+                          "oidranges": ({"start": {"subids": (1, 2, 3),
+                                                   "include": False},
+                                         "end": {"subids": (1, 2, 5),
+                                                 "include": False}},
+                                        {"start": {"subids": (10, 20),
+                                                   "include": True},
+                                         "end": {"subids": (30, 40),
+                                                 "include": False}})})
         # Test with context
         self.assertEqual(f("\x00\x00\x00\x04blah"
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
@@ -358,9 +399,15 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x02\x00\x01\x00\x00\x00\x00\x0A\x00\x00\x00\x14"
                            "\x02\x00\x00\x00\x00\x00\x00\x1E\x00\x00\x00\x28"
                            "\x00\x00\x00\x00", contextFlags),
-                         ("blah",
-                          (((1, 2, 3), (1, 2, 5), False),
-                           ((10, 20), (30, 40), True))))
+                         {"context": "blah",
+                          "oidranges": ({"start": {"subids": (1, 2, 3),
+                                                   "include": False},
+                                         "end": {"subids": (1, 2, 5),
+                                                 "include": False}},
+                                        {"start": {"subids": (10, 20),
+                                                   "include": True},
+                                         "end": {"subids": (30, 40),
+                                                 "include": False}})})
 
     def test_encode_getnextpdu(self):
         f = ntp.agentx.encode_getnextpdu
@@ -406,7 +453,9 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
         f = ntp.agentx.decode_getnextpdu
 
         # Test null
-        self.assertEqual(f("\x00\x00\x00\x00", standardFlags), (None, ()))
+        self.assertEqual(f("\x00\x00\x00\x00", standardFlags),
+                         {"context": None,
+                          "oidranges": ()})
         # Test basic
         self.assertEqual(f(
             "\x03\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03"
@@ -414,9 +463,15 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
             "\x02\x00\x01\x00\x00\x00\x00\x0A\x00\x00\x00\x14"
             "\x02\x00\x00\x00\x00\x00\x00\x1E\x00\x00\x00\x28"
             "\x00\x00\x00\x00", standardFlags),
-                         (None,
-                          (((1, 2, 3), (1, 2, 5), False),
-                           ((10, 20), (30, 40), True))))
+                         {"context": None,
+                          "oidranges": ({"start": {"subids": (1, 2, 3),
+                                                   "include": False},
+                                         "end": {"subids": (1, 2, 5),
+                                                 "include": False}},
+                                        {"start": {"subids": (10, 20),
+                                                   "include": True},
+                                         "end": {"subids": (30, 40),
+                                                 "include": False}})})
         # Test basic, little endian
         self.assertEqual(f(
             "\x03\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00"
@@ -424,9 +479,15 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
             "\x02\x00\x01\x00\x0A\x00\x00\x00\x14\x00\x00\x00"
             "\x02\x00\x00\x00\x1E\x00\x00\x00\x28\x00\x00\x00"
             "\x00\x00\x00\x00", lilEndianFlags),
-                         (None,
-                          (((1, 2, 3), (1, 2, 5), False),
-                           ((10, 20), (30, 40), True))))
+                         {"context": None,
+                          "oidranges": ({"start": {"subids": (1, 2, 3),
+                                                   "include": False},
+                                         "end": {"subids": (1, 2, 5),
+                                                 "include": False}},
+                                        {"start": {"subids": (10, 20),
+                                                   "include": True},
+                                         "end": {"subids": (30, 40),
+                                                 "include": False}})})
         # Test with context
         self.assertEqual(f("\x00\x00\x00\x04blah"
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
@@ -436,9 +497,15 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x02\x00\x01\x00\x00\x00\x00\x0A\x00\x00\x00\x14"
                            "\x02\x00\x00\x00\x00\x00\x00\x1E\x00\x00\x00\x28"
                            "\x00\x00\x00\x00", contextFlags),
-                         ("blah",
-                          (((1, 2, 3), (1, 2, 5), False),
-                           ((10, 20), (30, 40), True))))
+                         {"context": "blah",
+                          "oidranges": ({"start": {"subids": (1, 2, 3),
+                                                   "include": False},
+                                         "end": {"subids": (1, 2, 5),
+                                                 "include": False}},
+                                        {"start": {"subids": (10, 20),
+                                                   "include": True},
+                                         "end": {"subids": (30, 40),
+                                                 "include": False}})})
 
     def test_encode_getbulkpdu(self):
         f = ntp.agentx.encode_getbulkpdu
@@ -480,9 +547,15 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x02\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x07"
                            "\x02\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x09"
                            "\x00\x00\x00\x00", standardFlags),
-                         (None, 1, 5,
-                          (((1, 2), (3, 4), False),
-                           ((6, 7), (8, 9), True))))
+                         {"context": None, "non_reps": 1, "max_reps": 5,
+                          "oidranges": ({"start": {"subids": (1, 2),
+                                                   "include": False},
+                                         "end": {"subids": (3, 4),
+                                                 "include": False}},
+                                        {"start": {"subids": (6, 7),
+                                                   "include": True},
+                                         "end": {"subids": (8, 9),
+                                                 "include": False}})})
         # Test basic, little endian
         self.assertEqual(f("\x01\x00\x05\x00"
                            "\x02\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00"
@@ -490,9 +563,15 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x02\x00\x01\x00\x06\x00\x00\x00\x07\x00\x00\x00"
                            "\x02\x00\x00\x00\x08\x00\x00\x00\x09\x00\x00\x00"
                            "\x00\x00\x00\x00", lilEndianFlags),
-                         (None, 1, 5,
-                          (((1, 2), (3, 4), False),
-                           ((6, 7), (8, 9), True))))
+                         {"context": None, "non_reps": 1, "max_reps": 5,
+                          "oidranges": ({"start": {"subids": (1, 2),
+                                                   "include": False},
+                                         "end": {"subids": (3, 4),
+                                                 "include": False}},
+                                        {"start": {"subids": (6, 7),
+                                                   "include": True},
+                                         "end": {"subids": (8, 9),
+                                                 "include": False}})})
         # Test with context
         self.assertEqual(f("\x00\x00\x00\x04blah"
                            "\x00\x01\x00\x05"
@@ -501,9 +580,15 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x02\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x07"
                            "\x02\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x09"
                            "\x00\x00\x00\x00", contextFlags),
-                         ("blah", 1, 5,
-                          (((1, 2), (3, 4), False),
-                           ((6, 7), (8, 9), True))))
+                         {"context": "blah", "non_reps": 1, "max_reps": 5,
+                          "oidranges": ({"start": {"subids": (1, 2),
+                                                   "include": False},
+                                         "end": {"subids": (3, 4),
+                                                 "include": False}},
+                                        {"start": {"subids": (6, 7),
+                                                   "include": True},
+                                         "end": {"subids": (8, 9),
+                                                 "include": False}})})
 
     def test_encode_testsetpdu(self):
         f = ntp.agentx.encode_testsetpdu
@@ -557,9 +642,16 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x04"
                            "\x00\x00\x00\x04blah", standardFlags),
-                         (None,
-                          ((x.OID, (1, 2, 3), ((4, 5, 6), False)),
-                           (x.OCTET_STR, (1, 2, 4), "blah"))))
+                         {"context": None,
+                          "varbinds": ({"type": x.OID,
+                                        "name": {"subids": (1, 2, 3),
+                                                 "include": False},
+                                        "data": {"subids": (4, 5, 6),
+                                                 "include": False}},
+                                       {"type": x.OCTET_STR,
+                                        "name": {"subids": (1, 2, 4),
+                                                 "include": False},
+                                        "data": "blah"})})
         # Test, little endian
         self.assertEqual(f("\x06\x00\x00\x00"
                            "\x03\x00\x00\x00\x01\x00\x00\x00"
@@ -570,9 +662,16 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x03\x00\x00\x00\x01\x00\x00\x00"
                            "\x02\x00\x00\x00\x04\x00\x00\x00"
                            "\x04\x00\x00\x00blah", lilEndianFlags),
-                         (None,
-                          ((x.OID, (1, 2, 3), ((4, 5, 6), False)),
-                           (x.OCTET_STR, (1, 2, 4), "blah"))))
+                         {"context": None,
+                          "varbinds": ({"type": x.OID,
+                                        "name": {"subids": (1, 2, 3),
+                                                 "include": False},
+                                        "data": {"subids": (4, 5, 6),
+                                                 "include": False}},
+                                       {"type": x.OCTET_STR,
+                                        "name": {"subids": (1, 2, 4),
+                                                 "include": False},
+                                        "data": "blah"})})
         # Test with context
         self.assertEqual(f("\x00\x00\x00\x04blah"
                            "\x00\x06\x00\x00"
@@ -584,9 +683,16 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x04"
                            "\x00\x00\x00\x04blah", contextFlags),
-                         ("blah",
-                          ((x.OID, (1, 2, 3), ((4, 5, 6), False)),
-                           (x.OCTET_STR, (1, 2, 4), "blah"))))
+                         {"context": "blah",
+                          "varbinds": ({"type": x.OID,
+                                        "name": {"subids": (1, 2, 3),
+                                                 "include": False},
+                                        "data": {"subids": (4, 5, 6),
+                                                 "include": False}},
+                                       {"type": x.OCTET_STR,
+                                        "name": {"subids": (1, 2, 4),
+                                                 "include": False},
+                                        "data": "blah"})})
 
     def test_encode_commitsetpdu(self):
         f = ntp.agentx.encode_commitsetpdu
@@ -629,9 +735,11 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
         f = ntp.agentx.decode_pingpdu
 
         # Test
-        self.assertEqual(f("", standardFlags), None)
+        self.assertEqual(f("", standardFlags),
+                         {"context": None})
         # Test with context
-        self.assertEqual(f("\x00\x00\x00\x04blah", contextFlags), "blah")
+        self.assertEqual(f("\x00\x00\x00\x04blah", contextFlags),
+                         {"context": "blah"})
 
     def test_encode_notifypdu(self):
         f = ntp.agentx.encode_notifypdu
@@ -685,9 +793,16 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x04"
                            "\x00\x00\x00\x04blah", standardFlags),
-                         (None,
-                          ((x.OID, (1, 2, 3), ((4, 5, 6), False)),
-                           (x.OCTET_STR, (1, 2, 4), "blah"))))
+                         {"context": None,
+                          "varbinds": ({"type": x.OID,
+                                        "name": {"subids": (1, 2, 3),
+                                                 "include": False},
+                                        "data": {"subids": (4, 5, 6),
+                                                 "include": False}},
+                                       {"type": x.OCTET_STR,
+                                        "name": {"subids": (1, 2, 4),
+                                                 "include": False},
+                                        "data": "blah"})})
         # Test, little endian
         self.assertEqual(f("\x06\x00\x00\x00"
                            "\x03\x00\x00\x00\x01\x00\x00\x00"
@@ -698,9 +813,16 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x03\x00\x00\x00\x01\x00\x00\x00"
                            "\x02\x00\x00\x00\x04\x00\x00\x00"
                            "\x04\x00\x00\x00blah", lilEndianFlags),
-                         (None,
-                          ((x.OID, (1, 2, 3), ((4, 5, 6), False)),
-                           (x.OCTET_STR, (1, 2, 4), "blah"))))
+                         {"context": None,
+                          "varbinds": ({"type": x.OID,
+                                        "name": {"subids": (1, 2, 3),
+                                                 "include": False},
+                                        "data": {"subids": (4, 5, 6),
+                                                 "include": False}},
+                                       {"type": x.OCTET_STR,
+                                        "name": {"subids": (1, 2, 4),
+                                                 "include": False},
+                                        "data": "blah"})})
         # Test with context
         self.assertEqual(f("\x00\x00\x00\x04blah"
                            "\x00\x06\x00\x00"
@@ -712,9 +834,16 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x04"
                            "\x00\x00\x00\x04blah", contextFlags),
-                         ("blah",
-                          ((x.OID, (1, 2, 3), ((4, 5, 6), False)),
-                           (x.OCTET_STR, (1, 2, 4), "blah"))))
+                         {"context": "blah",
+                          "varbinds": ({"type": x.OID,
+                                        "name": {"subids": (1, 2, 3),
+                                                 "include": False},
+                                        "data": {"subids": (4, 5, 6),
+                                                 "include": False}},
+                                       {"type": x.OCTET_STR,
+                                        "name": {"subids": (1, 2, 4),
+                                                 "include": False},
+                                        "data": "blah"})})
 
     def test_encode_indexallocpdu(self):
         f = ntp.agentx.encode_indexallocpdu
@@ -768,9 +897,16 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x04"
                            "\x00\x00\x00\x04blah", standardFlags),
-                         (None,
-                          ((x.OID, (1, 2, 3), ((4, 5, 6), False)),
-                           (x.OCTET_STR, (1, 2, 4), "blah"))))
+                         {"context": None,
+                          "varbinds": ({"type": x.OID,
+                                        "name": {"subids": (1, 2, 3),
+                                                 "include": False},
+                                        "data": {"subids": (4, 5, 6),
+                                                 "include": False}},
+                                       {"type": x.OCTET_STR,
+                                        "name": {"subids": (1, 2, 4),
+                                                 "include": False},
+                                        "data": "blah"})})
         # Test, little endian
         self.assertEqual(f("\x06\x00\x00\x00"
                            "\x03\x00\x00\x00\x01\x00\x00\x00"
@@ -781,9 +917,16 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x03\x00\x00\x00\x01\x00\x00\x00"
                            "\x02\x00\x00\x00\x04\x00\x00\x00"
                            "\x04\x00\x00\x00blah", lilEndianFlags),
-                         (None,
-                          ((x.OID, (1, 2, 3), ((4, 5, 6), False)),
-                           (x.OCTET_STR, (1, 2, 4), "blah"))))
+                         {"context": None,
+                          "varbinds": ({"type": x.OID,
+                                        "name": {"subids": (1, 2, 3),
+                                                 "include": False},
+                                        "data": {"subids": (4, 5, 6),
+                                                 "include": False}},
+                                       {"type": x.OCTET_STR,
+                                        "name": {"subids": (1, 2, 4),
+                                                 "include": False},
+                                        "data": "blah"})})
         # Test with context
         self.assertEqual(f("\x00\x00\x00\x04blah"
                            "\x00\x06\x00\x00"
@@ -795,9 +938,16 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x04"
                            "\x00\x00\x00\x04blah", contextFlags),
-                         ("blah",
-                          ((x.OID, (1, 2, 3), ((4, 5, 6), False)),
-                           (x.OCTET_STR, (1, 2, 4), "blah"))))
+                         {"context": "blah",
+                          "varbinds": ({"type": x.OID,
+                                        "name": {"subids": (1, 2, 3),
+                                                 "include": False},
+                                        "data": {"subids": (4, 5, 6),
+                                                 "include": False}},
+                                       {"type": x.OCTET_STR,
+                                        "name": {"subids": (1, 2, 4),
+                                                 "include": False},
+                                        "data": "blah"})})
 
     def test_encode_indexdeallocpdu(self):
         f = ntp.agentx.encode_indexdeallocpdu
@@ -851,9 +1001,16 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x04"
                            "\x00\x00\x00\x04blah", standardFlags),
-                         (None,
-                          ((x.OID, (1, 2, 3), ((4, 5, 6), False)),
-                           (x.OCTET_STR, (1, 2, 4), "blah"))))
+                         {"context": None,
+                          "varbinds": ({"type": x.OID,
+                                        "name": {"subids": (1, 2, 3),
+                                                 "include": False},
+                                        "data": {"subids": (4, 5, 6),
+                                                 "include": False}},
+                                       {"type": x.OCTET_STR,
+                                        "name": {"subids": (1, 2, 4),
+                                                 "include": False},
+                                        "data": "blah"})})
         # Test, little endian
         self.assertEqual(f("\x06\x00\x00\x00"
                            "\x03\x00\x00\x00\x01\x00\x00\x00"
@@ -864,9 +1021,16 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x03\x00\x00\x00\x01\x00\x00\x00"
                            "\x02\x00\x00\x00\x04\x00\x00\x00"
                            "\x04\x00\x00\x00blah", lilEndianFlags),
-                         (None,
-                          ((x.OID, (1, 2, 3), ((4, 5, 6), False)),
-                           (x.OCTET_STR, (1, 2, 4), "blah"))))
+                         {"context": None,
+                          "varbinds": ({"type": x.OID,
+                                        "name": {"subids": (1, 2, 3),
+                                                 "include": False},
+                                        "data": {"subids": (4, 5, 6),
+                                                 "include": False}},
+                                       {"type": x.OCTET_STR,
+                                        "name": {"subids": (1, 2, 4),
+                                                 "include": False},
+                                        "data": "blah"})})
         # Test with context
         self.assertEqual(f("\x00\x00\x00\x04blah"
                            "\x00\x06\x00\x00"
@@ -878,9 +1042,16 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x04"
                            "\x00\x00\x00\x04blah", contextFlags),
-                         ("blah",
-                          ((x.OID, (1, 2, 3), ((4, 5, 6), False)),
-                           (x.OCTET_STR, (1, 2, 4), "blah"))))
+                         {"context": "blah",
+                          "varbinds": ({"type": x.OID,
+                                        "name": {"subids": (1, 2, 3),
+                                                 "include": False},
+                                        "data": {"subids": (4, 5, 6),
+                                                 "include": False}},
+                                       {"type": x.OCTET_STR,
+                                        "name": {"subids": (1, 2, 4),
+                                                 "include": False},
+                                        "data": "blah"})})
 
     def test_encode_addagentcapspdu(self):
         f = ntp.agentx.encode_addagentcapspdu
@@ -910,18 +1081,24 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
         self.assertEqual(f("\x03\x00\x00\x00\x00\x00\x00\x04"
                            "\x00\x00\x00\x05\x00\x00\x00\x06"
                            "\x00\x00\x00\x04blah", standardFlags),
-                         (None, (4, 5, 6), "blah"))
+                         {"context": None,
+                          "oid": {"subids": (4, 5, 6), "include": False},
+                          "description": "blah"})
         # Test, little endian
         self.assertEqual(f("\x03\x00\x00\x00\x04\x00\x00\x00"
                            "\x05\x00\x00\x00\x06\x00\x00\x00"
                            "\x04\x00\x00\x00blah", lilEndianFlags),
-                         (None, (4, 5, 6), "blah"))
+                         {"context": None,
+                          "oid": {"subids": (4, 5, 6), "include": False},
+                          "description": "blah"})
         # Test with context
         self.assertEqual(f("\x00\x00\x00\x04bluh"
                            "\x03\x00\x00\x00\x00\x00\x00\x04"
                            "\x00\x00\x00\x05\x00\x00\x00\x06"
                            "\x00\x00\x00\x04blah", contextFlags),
-                         ("bluh", (4, 5, 6), "blah"))
+                         {"context": "bluh",
+                          "oid": {"subids": (4, 5, 6), "include": False},
+                          "description": "blah"})
 
     def test_encode_rmagentcapspdu(self):
         f = ntp.agentx.encode_rmagentcapspdu
@@ -948,16 +1125,19 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
         # Test
         self.assertEqual(f("\x03\x00\x00\x00\x00\x00\x00\x04"
                            "\x00\x00\x00\x05\x00\x00\x00\x06", standardFlags),
-                         (None, (4, 5, 6)))
+                         {"context": None,
+                          "oid": {"subids": (4, 5, 6), "include": False}})
         # Test, little endian
         self.assertEqual(f("\x03\x00\x00\x00\x04\x00\x00\x00"
                            "\x05\x00\x00\x00\x06\x00\x00\x00", lilEndianFlags),
-                         (None, (4, 5, 6)))
+                         {"context": None,
+                          "oid": {"subids": (4, 5, 6), "include": False}})
         # Test with context
         self.assertEqual(f("\x00\x00\x00\x04bluh"
                            "\x03\x00\x00\x00\x00\x00\x00\x04"
                            "\x00\x00\x00\x05\x00\x00\x00\x06", contextFlags),
-                         ("bluh", (4, 5, 6)))
+                         {"context": "bluh",
+                          "oid": {"subids": (4, 5, 6), "include": False}})
 
     def test_encode_responsepdu(self):
         f = ntp.agentx.encode_responsepdu
@@ -993,10 +1173,12 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
 
         # Test
         self.assertEqual(f("\x00\x00\x00\x04\x00\x05\x00\x06", standardFlags),
-                         (4, 5, 6, None))
+                         {"sys_uptime": 4, "res_err": 5,
+                          "res_index": 6, "varbinds": None})
         # Test, little endian
         self.assertEqual(f("\x04\x00\x00\x00\x05\x00\x06\x00", lilEndianFlags),
-                         (4, 5, 6, None))
+                         {"sys_uptime": 4, "res_err": 5,
+                          "res_index": 6, "varbinds": None})
         # Test with varbinds
         self.assertEqual(f("\x00\x00\x00\x04\x00\x05\x00\x06"
                            "\x00\x06\x00\x00"
@@ -1008,9 +1190,16 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x04"
                            "\x00\x00\x00\x04blah", standardFlags),
-                         (4, 5, 6,
-                          ((x.OID, (1, 2, 3), ((4, 5, 6), False)),
-                           (x.OCTET_STR, (1, 2, 4), "blah"))))
+                         {"sys_uptime": 4, "res_err": 5, "res_index": 6,
+                          "varbinds": ({"type": x.OID,
+                                        "name": {"subids": (1, 2, 3),
+                                                 "include": False},
+                                        "data": {"subids": (4, 5, 6),
+                                                 "include": False}},
+                                       {"type": x.OCTET_STR,
+                                        "name": {"subids": (1, 2, 4),
+                                                 "include": False},
+                                        "data": "blah"})})
 
     #
     # Data type tests
@@ -1128,34 +1317,40 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
 
         # Test empty OID, extra data
         self.assertEqual(f("\x00\x00\x00\x00" + extraData, standardFlags),
-                         (((), False), extraData))
+                         ({"subids": (), "include": False}, extraData))
         # Test basic OID, extra data
         self.assertEqual(f("\x05\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x03"
                            "\x00\x00\x00\x04\x00\x00\x00\x05" + extraData,
                            standardFlags),
-                         (((1, 2, 3, 4, 5), False), extraData))
+                         ({"subids": (1, 2, 3, 4, 5), "include": False},
+                          extraData))
         # Test basic OID, little endian
         self.assertEqual(f("\x05\x00\x00\x00\x01\x00\x00\x00"
                            "\x02\x00\x00\x00\x03\x00\x00\x00"
                            "\x04\x00\x00\x00\x05\x00\x00\x00", lilEndianFlags),
-                         (((1, 2, 3, 4, 5), False), ""))
+                         ({"subids": (1, 2, 3, 4, 5), "include": False},
+                          ""))
         # Test prefixed OID
         self.assertEqual(f("\x03\x17\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x03", standardFlags),
-                         (((1, 3, 6, 1, 23, 1, 2, 3), False), ""))
+                         ({"subids": (1, 3, 6, 1, 23, 1, 2, 3),
+                           "include": False},
+                          ""))
         # Test include
         self.assertEqual(f("\x02\x00\x05\x00\x00\x00\x00\x01\x00\x00\x00\x02",
                            standardFlags),
-                         (((1, 2), True), ""))
+                         ({"subids": (1, 2), "include": True}, ""))
         # Test together
         self.assertEqual(f("\x04\x01\x02\x00\x00\x00\x00\x03"
                            "\x00\x00\x00\x04\x00\x00\x00\x05\x00\x00\x00\x06",
                            standardFlags),
-                         (((1, 3, 6, 1, 1, 3, 4, 5, 6), True), ""))
+                         ({"subids": (1, 3, 6, 1, 1, 3, 4, 5, 6),
+                           "include": True},
+                          ""))
         # Test maximum size
         self.assertEqual(f(maximumOIDstr, standardFlags),
-                         ((maximumOIDsubs, False), ""))
+                         ({"subids": maximumOIDsubs, "include": False}, ""))
         # Test over maximum size
         # Need to replace the hardcoded n_subid=128 with 129
         fatOID = "\x81" + maximumOIDstr[1:] + "\xDE\xAD\xBE\xEF"
@@ -1194,7 +1389,9 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
         # Test minimum size, extra data
         self.assertEqual(f("\x00\x00\x00\x00\x00\x00\x00\x00" + extraData,
                            standardFlags),
-                         (((), False), ((), False), extraData))
+                         ({"start": {"subids": (), "include": False},
+                           "end": {"subids": (), "include": False}},
+                          extraData))
         # Test inclusive
         self.assertEqual(f("\x04\x00\x01\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02"
@@ -1202,7 +1399,9 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x04\x00\x00\x00"
                            "\x00\x00\x00\x05\x00\x00\x00\x06"
                            "\x00\x00\x00\x07\x00\x00\x00\x08", standardFlags),
-                         (((1, 2, 3, 4), True), ((5, 6, 7, 8), False), ""))
+                         ({"start": {"subids": (1, 2, 3, 4), "include": True},
+                           "end": {"subids": (5, 6, 7, 8), "include": False}},
+                          ""))
         # Test exclusive
         self.assertEqual(f("\x04\x00\x00\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02"
@@ -1210,7 +1409,9 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x04\x00\x00\x00"
                            "\x00\x00\x00\x05\x00\x00\x00\x06"
                            "\x00\x00\x00\x07\x00\x00\x00\x08", standardFlags),
-                         (((1, 2, 3, 4), False), ((5, 6, 7, 8), False), ""))
+                         ({"start": {"subids": (1, 2, 3, 4), "include": False},
+                           "end": {"subids": (5, 6, 7, 8), "include": False}},
+                          ""))
         # Test little endian
         self.assertEqual(f("\x04\x00\x01\x00"
                            "\x01\x00\x00\x00\x02\x00\x00\x00"
@@ -1218,7 +1419,9 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x04\x00\x00\x00"
                            "\x05\x00\x00\x00\x06\x00\x00\x00"
                            "\x07\x00\x00\x00\x08\x00\x00\x00", lilEndianFlags),
-                         (((1, 2, 3, 4), True), ((5, 6, 7, 8), False), ""))
+                         ({"start": {"subids": (1, 2, 3, 4), "include": True},
+                           "end": {"subids": (5, 6, 7, 8), "include": False}},
+                          ""))
 
     def test_encode_searchrange_list(self):
         f = ntp.agentx.encode_searchrange_list
@@ -1241,20 +1444,22 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x02\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x03"
                            "\x02\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x04"
                            "\x00\x00\x00\x00" + extraData, standardFlags),
-                         ((
-                             ((1, 2), (1, 2), True),
-                             ((2, 3), (3, 4), False)
-                         ), extraData))
+                         (({"start": {"subids": (1, 2), "include": True},
+                            "end": {"subids": (1, 2), "include": False}},
+                           {"start": {"subids": (2, 3), "include": False},
+                            "end": {"subids": (3, 4), "include": False}}),
+                          extraData))
         # Test, little endian
         self.assertEqual(f("\x02\x00\x01\x00\x01\x00\x00\x00\x02\x00\x00\x00"
                            "\x02\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00"
                            "\x02\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00"
                            "\x02\x00\x00\x00\x03\x00\x00\x00\x04\x00\x00\x00"
                            "\x00\x00\x00\x00" + extraData, lilEndianFlags),
-                         ((
-                             ((1, 2), (1, 2), True),
-                             ((2, 3), (3, 4), False)
-                         ), extraData))
+                         (({"start": {"subids": (1, 2), "include": True},
+                            "end": {"subids": (1, 2), "include": False}},
+                           {"start": {"subids": (2, 3), "include": False},
+                            "end": {"subids": (3, 4), "include": False}}),
+                          extraData))
 
     def test_encode_octetstr(self):
         f = ntp.agentx.encode_octetstr
@@ -1349,62 +1554,103 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
         self.assertEqual(f("\x00\x05\x00\x00\x03\x00\x00\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03",
                            standardFlags),
-                         ((a.NULL, (1, 2, 3), None), ""))
+                         ({"type": a.NULL,
+                           "name": {"subids": (1, 2, 3), "include": False},
+                           "data": None},
+                          ""))
         self.assertEqual(f("\x00\x80\x00\x00\x03\x00\x00\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03",
                            standardFlags),
-                         ((a.NO_SUCH_OBJECT, (1, 2, 3), None), ""))
+                         ({"type": a.NO_SUCH_OBJECT,
+                           "name": {"subids": (1, 2, 3), "include": False},
+                           "data": None},
+                          ""))
         self.assertEqual(f("\x00\x81\x00\x00\x03\x00\x00\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03",
                            standardFlags),
-                         ((a.NO_SUCH_INSTANCE, (1, 2, 3), None), ""))
+                         ({"type": a.NO_SUCH_INSTANCE,
+                           "name": {"subids": (1, 2, 3), "include": False},
+                           "data": None},
+                          ""))
         self.assertEqual(f("\x00\x82\x00\x00\x03\x00\x00\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03",
                            standardFlags),
-                         ((a.END_OF_MIB_VIEW, (1, 2, 3), None), ""))
+                         ({"type": a.END_OF_MIB_VIEW,
+                           "name": {"subids": (1, 2, 3), "include": False},
+                           "data": None},
+                          ""))
         # Test octet based types
         self.assertEqual(f("\x00\x04\x00\x00\x03\x00\x00\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03"
                            "\x00\x00\x00\x0512345\x00\x00\x00",
                            standardFlags),
-                         ((a.OCTET_STR, (1, 2, 3), "12345"), ""))
+                         ({"type": a.OCTET_STR,
+                           "name": {"subids": (1, 2, 3), "include": False},
+                           "data": "12345"},
+                          ""))
         self.assertEqual(f("\x00\x40\x00\x00\x03\x00\x00\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03"
                            "\x00\x00\x00\x04\x10\x20\x30\x40", standardFlags),
-                         ((a.IP_ADDR, (1, 2, 3), (16, 32, 48, 64)), ""))
+                         ({"type": a.IP_ADDR,
+                           "name": {"subids": (1, 2, 3), "include": False},
+                           "data": (16, 32, 48, 64)},
+                          ""))
         # Test integer32 types
         self.assertEqual(f("\x00\x02\x00\x00\x03\x00\x00\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03"
                            "\x00\x00\x00\x2A", standardFlags),
-                         ((a.INTEGER, (1, 2, 3), 42), ""))
+                         ({"type": a.INTEGER,
+                           "name": {"subids": (1, 2, 3), "include": False},
+                           "data": 42},
+                          ""))
         self.assertEqual(f("\x00\x41\x00\x00\x03\x00\x00\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03"
                            "\x00\x00\x00\x2A", standardFlags),
-                         ((a.COUNTER32, (1, 2, 3), 42), ""))
+                         ({"type": a.COUNTER32,
+                           "name": {"subids": (1, 2, 3), "include": False},
+                           "data": 42},
+                          ""))
         self.assertEqual(f("\x00\x42\x00\x00\x03\x00\x00\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03"
                            "\x00\x00\x00\x2A", standardFlags),
-                         ((a.GAUGE32, (1, 2, 3), 42), ""))
+                         ({"type": a.GAUGE32,
+                           "name": {"subids": (1, 2, 3), "include": False},
+                           "data": 42},
+                          ""))
         self.assertEqual(f("\x00\x43\x00\x00\x03\x00\x00\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03"
                            "\x00\x00\x00\x2A", standardFlags),
-                         ((a.TIME_TICKS, (1, 2, 3), 42), ""))
+                         ({"type": a.TIME_TICKS,
+                           "name": {"subids": (1, 2, 3), "include": False},
+                           "data": 42},
+                          ""))
         # Test integer64 type
         self.assertEqual(f("\x00\x46\x00\x00\x03\x00\x00\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03"
                            "\x00\x00\x00\x00\x00\x00\x00\x2A", standardFlags),
-                         ((a.COUNTER64, (1, 2, 3), 42), ""))
+                         ({"type": a.COUNTER64,
+                           "name": {"subids": (1, 2, 3), "include": False},
+                           "data": 42},
+                          ""))
         # Test oid type
         self.assertEqual(f("\x00\x06\x00\x00\x03\x00\x00\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\x03"
                            "\x03\x00\x00\x00\x00\x00\x00\x10"
                            "\x00\x00\x00\x2A\x00\x00\x01\x00", standardFlags),
-                         ((a.OID, (1, 2, 3), ((16, 42, 256), False)), ""))
+                         ({"type": a.OID,
+                           "name": {"subids": (1, 2, 3),
+                                    "include": False},
+                           "data": {"subids": (16, 42, 256),
+                                    "include": False}},
+                          ""))
         # Test integer32 with little endian
         self.assertEqual(f("\x43\x00\x00\x00\x03\x00\x00\x00"
                            "\x01\x00\x00\x00\x02\x00\x00\x00\x03\x00\x00\x00"
                            "\x2A\x00\x00\x00", lilEndianFlags),
-                         ((a.TIME_TICKS, (1, 2, 3), 42), ""))
+                         ({"type": a.TIME_TICKS,
+                           "name": {"subids": (1, 2, 3), "include": False},
+                           "data": 42},
+                          ""))
 
     #
     # Misc tests
@@ -1450,48 +1696,69 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
         self.assertEqual(f("\x01\x01\x10\x00"
                            "\xDE\xAD\xBE\xEF\xCA\xFE\xBA\xBE"
                            "\xFA\xCE\xF0\x0D\x00\x00\x00\x00"),
-                         (1, a.PDU_OPEN, {"instReg": False,
-                                          "newIndex": False,
-                                          "anyIndex": False,
-                                          "contextP": False,
-                                          "bigEndian": True},
-                          0xDEADBEEF, 0xCAFEBABE, 0xFACEF00D, 0), "")
+                         {"version": 1,
+                          "type": a.PDU_OPEN,
+                          "flags": {"instReg": False,
+                                    "newIndex": False,
+                                    "anyIndex": False,
+                                    "contextP": False,
+                                    "bigEndian": True},
+                          "session_id": 0xDEADBEEF,
+                          "transaction_id": 0xCAFEBABE,
+                          "packet_id": 0xFACEF00D,
+                          "length": 0})
         # Test "empty" header, little endian
         self.assertEqual(f("\x01\x01\x00\x00"
                            "\xEF\xBE\xAD\xDE\xBE\xBA\xFE\xCA"
                            "\x0D\xF0\xCE\xFA\x00\x00\x00\x00"),
-                         (1, a.PDU_OPEN, {"instReg": False,
-                                          "newIndex": False,
-                                          "anyIndex": False,
-                                          "contextP": False,
-                                          "bigEndian": False},
-                          0xDEADBEEF, 0xCAFEBABE, 0xFACEF00D, 0), "")
+                         {"version": 1,
+                          "type": a.PDU_OPEN,
+                          "flags": {"instReg ": False,
+                                    "newIndex": False,
+                                    "anyIndex": False,
+                                    "contextP": False,
+                                    "bigEndian": False},
+                          "session_id": 0xDEADBEEF,
+                          "transaction_id": 0xCAFEBABE,
+                          "packet_id": 0xFACEF00D,
+                          "length": 0})
         # Test "empty" header, extra data
         self.assertEqual(f("\x01\x01\x10\x00"
                            "\xDE\xAD\xBE\xEF\xCA\xFE\xBA\xBE"
                            "\xFA\xCE\xF0\x0D\x00\x00\x00\x00" + extraData),
-                         (1, a.PDU_OPEN, {"instReg": False,
-                                          "newIndex": False,
-                                          "anyIndex": False,
-                                          "contextP": False,
-                                          "bigEndian": True},
-                          0xDEADBEEF, 0xCAFEBABE, 0xFACEF00D, 0), extraData)
+                         {"version": 1,
+                          "type": a.PDU_OPEN,
+                          "flags": {"instReg": False,
+                                    "newIndex": False,
+                                    "anyIndex": False,
+                                    "contextP": False,
+                                    "bigEndian": True},
+                          "session_id": 0xDEADBEEF,
+                          "transaction_id": 0xCAFEBABE,
+                          "packet_id": 0xFACEF00D,
+                          "length": 0})
         # Test flags
         self.assertEqual(f("\x01\x01\x1F\x00"
                            "\xDE\xAD\xBE\xEF\xCA\xFE\xBA\xBE"
                            "\xFA\xCE\xF0\x0D\x00\x00\x00\x00"),
-                         (1, a.PDU_OPEN, {"instReg": True,
-                                          "newIndex": True,
-                                          "anyIndex": True,
-                                          "contextP": True,
-                                          "bigEndian": True},
-                          0xDEADBEEF, 0xCAFEBABE, 0xFACEF00D, 0), "")
+                         {"version": 1,
+                          "type": a.PDU_OPEN,
+                          "flags": {"instReg": True,
+                                    "newIndex": True,
+                                    "anyIndex": True,
+                                    "contextP": True,
+                                    "bigEndian": True},
+                          "session_id": 0xDEADBEEF,
+                          "transaction_id": 0xCAFEBABE,
+                          "packet_id": 0xFACEF00D,
+                          "length": 0})
 
     def test_decode_packet(self):
         f = ntp.agentx.decode_packet
         x = ntp.agentx
         # Not testing all the variants of each packet type, that is
         # the job of the other tests.
+        self.maxDiff = None
 
         # Test open
         self.assertEqual(f("\x01\x01\x10\x00"
@@ -1502,15 +1769,26 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x00\x00\x00\x01\x00\x00\x00\x02"
                            "\x00\x00\x00\x03\x00\x00\x00\x04"
                            "\x00\x00\x00\x03foo\x00"),
-                         (x.PDU_OPEN, standardFlags, 12, 34, 56,
-                          (78, ((1, 2, 3, 4), False), "foo")))
+                         ({"header": {"version": 1, "type": x.PDU_OPEN,
+                                      "flags": standardFlags, "session_id": 12,
+                                      "transaction_id": 34, "packet_id": 56,
+                                      "length": 32},
+                           "body": {"timeout": 78,
+                                    "oid": {"subids": (1, 2, 3, 4),
+                                            "include": False},
+                                    "description": "foo"}},
+                          ""))
         # Test close
         self.assertEqual(f("\x01\x02\x10\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02"
                            "\x00\x00\x00\x03\x00\x00\x00\x04"
                            "\x01\x00\x00\x00"),
-                         (x.PDU_CLOSE, standardFlags, 1, 2, 3,
-                          x.RSN_OTHER))
+                         ({"header": {"version": 1, "type": x.PDU_CLOSE,
+                                      "flags": standardFlags, "session_id": 1,
+                                      "transaction_id": 2, "packet_id": 3,
+                                      "length": 4},
+                           "body": {"reason": x.RSN_OTHER}},
+                          ""))
         # Test register
         self.assertEqual(f("\x01\x03\x11\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02"
@@ -1518,10 +1796,17 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x04\x05\x00\x00"
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x03"),
-                         (x.PDU_REGISTER,
-                          makeFlags(True, False, False, False, True),
-                          1, 2, 3,
-                          (((1, 2, 3), False), 4, 5, None, 0, None)))
+                         ({"header": {"version": 1, "type": x.PDU_REGISTER,
+                                      "flags": makeFlags(True, False, False,
+                                                         False, True),
+                                      "session_id": 1, "transaction_id": 2,
+                                      "packet_id": 3, "length": 20},
+                           "body": {"oid": {"subids": (1, 2, 3),
+                                            "include": False},
+                                    "timeout": 4, "priority": 5,
+                                    "context": None, "range_subid": 0,
+                                    "upper_bound": None}},
+                          ""))
         # Test unregister
         self.assertEqual(f("\x01\x04\x10\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02"
@@ -1529,22 +1814,37 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x00\x05\x00\x00"
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x03"),
-                         (x.PDU_UNREGISTER, standardFlags, 1, 2, 3,
-                          (((1, 2, 3), False), 5, None, 0, None)))
+                         ({"header": {"version": 1, "type": x.PDU_UNREGISTER,
+                                      "flags": standardFlags, "session_id": 1,
+                                      "transaction_id": 2, "packet_id": 3,
+                                      "length": 20},
+                           "body": {"oid": {"subids": (1, 2, 3),
+                                            "include": False},
+                                    "priority": 5, "context": None,
+                                    "range_subid": 0, "upper_bound": None}},
+                          ""))
         # Test get
         self.assertEqual(f("\x01\x05\x10\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02"
                            "\x00\x00\x00\x03\x00\x00\x00\x04"
                            "\x00\x00\x00\x00"),
-                         (x.PDU_GET, standardFlags, 1, 2, 3,
-                          (None, ())))
+                         ({"header": {"version": 1, "type": x.PDU_GET,
+                                      "flags": standardFlags, "session_id": 1,
+                                      "transaction_id": 2, "packet_id": 3,
+                                      "length": 4},
+                           "body": {"context": None, "oidranges": ()}},
+                          ""))
         # Test get next
         self.assertEqual(f("\x01\x06\x10\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02"
                            "\x00\x00\x00\x03\x00\x00\x00\x04"
                            "\x00\x00\x00\x00"),
-                         (x.PDU_GET_NEXT, standardFlags, 1, 2, 3,
-                          (None, ())))
+                         ({"header": {"version": 1, "type": x.PDU_GET_NEXT,
+                                      "flags": standardFlags, "session_id": 1,
+                                      "transaction_id": 2, "packet_id": 3,
+                                      "length": 4},
+                           "body": {"context": None, "oidranges": ()}},
+                          ""))
         # Test get bulk
         self.assertEqual(f("\x01\x07\x10\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02"
@@ -1555,10 +1855,21 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x02\x00\x01\x00\x00\x00\x00\x06\x00\x00\x00\x07"
                            "\x02\x00\x00\x00\x00\x00\x00\x08\x00\x00\x00\x09"
                            "\x00\x00\x00\x00"),
-                         (x.PDU_GET_BULK, standardFlags, 1, 2, 3,
-                          (None, 1, 5,
-                           (((1, 2), (3, 4), False),
-                            ((6, 7), (8, 9), True)))))
+                         ({"header": {"version": 1, "type": x.PDU_GET_BULK,
+                                      "flags": standardFlags, "session_id": 1,
+                                      "transaction_id": 2, "packet_id": 3,
+                                      "length": 56},
+                           "body": {"context": None, "non_reps": 1,
+                                    "max_reps": 5,
+                                    "oidranges": ({"start": {"subids": (1, 2),
+                                                             "include": False},
+                                                   "end": {"subids": (3, 4),
+                                                           "include": False}},
+                                                  {"start": {"subids": (6, 7),
+                                                             "include": True},
+                                                   "end": {"subids": (8, 9),
+                                                           "include": False}}
+                                    )}}, ""))
         # Test test set
         self.assertEqual(f("\x01\x08\x10\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02"
@@ -1572,28 +1883,51 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x04"
                            "\x00\x00\x00\x04blah"),
-                         (x.PDU_TEST_SET, standardFlags, 1, 2, 3,
-                          (None,
-                           ((x.OID, (1, 2, 3), ((4, 5, 6), False)),
-                            (x.OCTET_STR, (1, 2, 4), "blah")))))
+                         ({"header": {"version": 1, "type": x.PDU_TEST_SET,
+                                      "flags": standardFlags, "session_id": 1,
+                                      "transaction_id": 2, "packet_id": 3,
+                                      "length": 64},
+                           "body": {"context": None,
+                                    "varbinds": ({"type": x.OID,
+                                                  "name": {"subids": (1, 2, 3),
+                                                           "include": False},
+                                                  "data": {"subids": (4, 5, 6),
+                                                           "include": False}},
+                                                 {"type": x.OCTET_STR,
+                                                  "name": {"subids": (1, 2, 4),
+                                                           "include": False},
+                                                  "data": "blah"})}},
+                          ""))
         # Test commit set
         self.assertEqual(f("\x01\x09\x10\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02"
                            "\x00\x00\x00\x03\x00\x00\x00\x00"),
-                         (x.PDU_COMMIT_SET, standardFlags, 1, 2, 3,
-                          None))
+                         ({"header": {"version": 1, "type": x.PDU_COMMIT_SET,
+                                      "flags": standardFlags, "session_id": 1,
+                                      "transaction_id": 2, "packet_id": 3,
+                                      "length": 0},
+                           "body": None},
+                          ""))
         # Test undo set
         self.assertEqual(f("\x01\x0A\x10\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02"
                            "\x00\x00\x00\x03\x00\x00\x00\x00"),
-                         (x.PDU_UNDO_SET, standardFlags, 1, 2, 3,
-                          None))
+                         ({"header": {"version": 1, "type": x.PDU_UNDO_SET,
+                                      "flags": standardFlags, "session_id": 1,
+                                      "transaction_id": 2, "packet_id": 3,
+                                      "length": 0},
+                           "body": None},
+                          ""))
         # Test cleanup set
         self.assertEqual(f("\x01\x0B\x10\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02"
                            "\x00\x00\x00\x03\x00\x00\x00\x00"),
-                         (x.PDU_CLEANUP_SET, standardFlags, 1, 2, 3,
-                          None))
+                         ({"header": {"version": 1, "type": x.PDU_CLEANUP_SET,
+                                      "flags": standardFlags, "session_id": 1,
+                                      "transaction_id": 2, "packet_id": 3,
+                                      "length": 0},
+                           "body": None},
+                          ""))
         # Test notify
         self.assertEqual(f("\x01\x0C\x10\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02"
@@ -1607,15 +1941,31 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x04"
                            "\x00\x00\x00\x04blah"),
-                         (x.PDU_NOTIFY, standardFlags, 1, 2, 3,
-                          (None,
-                           ((x.OID, (1, 2, 3), ((4, 5, 6), False)),
-                            (x.OCTET_STR, (1, 2, 4), "blah")))))
+                         ({"header": {"version": 1, "type": x.PDU_NOTIFY,
+                                      "flags": standardFlags, "session_id": 1,
+                                      "transaction_id": 2, "packet_id": 3,
+                                      "length": 64},
+                           "body": {"context": None,
+                                    "varbinds": ({"type": x.OID,
+                                                  "name": {"subids": (1, 2, 3),
+                                                           "include": False},
+                                                  "data": {"subids": (4, 5, 6),
+                                                           "include": False}},
+                                                 {"type": x.OCTET_STR,
+                                                  "name": {"subids": (1, 2, 4),
+                                                           "include": False},
+                                                  "data": "blah"})}},
+                          ""))
         # Test ping
         self.assertEqual(f("\x01\x0D\x10\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02"
                            "\x00\x00\x00\x03\x00\x00\x00\x00"),
-                         (x.PDU_PING, standardFlags, 1, 2, 3, None))
+                         ({"header": {"version": 1, "type": x.PDU_PING,
+                                      "flags": standardFlags, "session_id": 1,
+                                      "transaction_id": 2, "packet_id": 3,
+                                      "length": 0},
+                           "body": {"context": None}},
+                          ""))
         # Test index alloc
         self.assertEqual(f("\x01\x0E\x16\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02"
@@ -1629,12 +1979,22 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x04"
                            "\x00\x00\x00\x04blah"),
-                         (x.PDU_INDEX_ALLOC,
-                          makeFlags(False, True, True, False, True),
-                          1, 2, 3,
-                          (None,
-                           ((x.OID, (1, 2, 3), ((4, 5, 6), False)),
-                            (x.OCTET_STR, (1, 2, 4), "blah")))))
+                         ({"header": {"version": 1, "type": x.PDU_INDEX_ALLOC,
+                                      "flags": makeFlags(False, True, True,
+                                                         False, True),
+                                      "session_id": 1, "transaction_id": 2,
+                                      "packet_id": 3, "length": 64},
+                           "body": {"context": None,
+                                    "varbinds": ({"type": x.OID,
+                                                  "name": {"subids": (1, 2, 3),
+                                                           "include": False},
+                                                  "data": {"subids": (4, 5, 6),
+                                                           "include": False}},
+                                                 {"type": x.OCTET_STR,
+                                                  "name": {"subids": (1, 2, 4),
+                                                           "include": False},
+                                                  "data": "blah"})}},
+                          ""))
         # Test index dealloc
         self.assertEqual(f("\x01\x0F\x16\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02"
@@ -1648,12 +2008,23 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x03\x00\x00\x00\x00\x00\x00\x01"
                            "\x00\x00\x00\x02\x00\x00\x00\x04"
                            "\x00\x00\x00\x04blah"),
-                         (x.PDU_INDEX_DEALLOC,
-                          makeFlags(False, True, True, False, True),
-                          1, 2, 3,
-                          (None,
-                           ((x.OID, (1, 2, 3), ((4, 5, 6), False)),
-                            (x.OCTET_STR, (1, 2, 4), "blah")))))
+                         ({"header": {"version": 1,
+                                      "type": x.PDU_INDEX_DEALLOC,
+                                      "flags": makeFlags(False, True, True,
+                                                         False, True),
+                                      "session_id": 1, "transaction_id": 2,
+                                      "packet_id": 3, "length": 64},
+                           "body": {"context": None,
+                                    "varbinds": ({"type": x.OID,
+                                                  "name": {"subids": (1, 2, 3),
+                                                           "include": False},
+                                                  "data": {"subids": (4, 5, 6),
+                                                           "include": False}},
+                                                 {"type": x.OCTET_STR,
+                                                  "name": {"subids": (1, 2, 4),
+                                                           "include": False},
+                                                  "data": "blah"})}},
+                          ""))
         # Test add agent caps
         self.assertEqual(f("\x01\x10\x10\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02"
@@ -1661,23 +2032,43 @@ class TestNtpclientsNtpsnmpd(unittest.TestCase):
                            "\x03\x00\x00\x00\x00\x00\x00\x04"
                            "\x00\x00\x00\x05\x00\x00\x00\x06"
                            "\x00\x00\x00\x04blah"),
-                         (x.PDU_ADD_AGENT_CAPS, standardFlags, 1, 2, 3,
-                          (None, (4, 5, 6), "blah")))
+                         ({"header": {"version": 1,
+                                      "type": x.PDU_ADD_AGENT_CAPS,
+                                      "flags": standardFlags, "session_id": 1,
+                                      "transaction_id": 2, "packet_id": 3,
+                                      "length": 24},
+                           "body": {"context": None,
+                                    "oid": {"subids": (4, 5, 6),
+                                            "include": False},
+                                    "description": "blah"}},
+                          ""))
         # Test rm agent caps
         self.assertEqual(f("\x01\x11\x10\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02"
                            "\x00\x00\x00\x03\x00\x00\x00\x10"
                            "\x03\x00\x00\x00\x00\x00\x00\x04"
                            "\x00\x00\x00\x05\x00\x00\x00\x06"),
-                         (x.PDU_RM_AGENT_CAPS, standardFlags, 1, 2, 3,
-                          (None, (4, 5, 6))))
+                         ({"header": {"version": 1,
+                                      "type": x.PDU_RM_AGENT_CAPS,
+                                      "flags": standardFlags, "session_id": 1,
+                                      "transaction_id": 2, "packet_id": 3,
+                                      "length": 16},
+                           "body": {"context": None,
+                                    "oid": {"subids": (4, 5, 6),
+                                            "include": False}}},
+                          ""))
         # Test response
         self.assertEqual(f("\x01\x12\x10\x00"
                            "\x00\x00\x00\x01\x00\x00\x00\x02"
                            "\x00\x00\x00\x03\x00\x00\x00\x08"
                            "\x00\x00\x00\x04\x00\x05\x00\x06"),
-                         (x.PDU_RESPONSE, standardFlags, 1, 2, 3,
-                          (4, 5, 6, None)))
+                         ({"header": {"version": 1, "type": x.PDU_RESPONSE,
+                                      "flags": standardFlags, "session_id": 1,
+                                      "transaction_id": 2, "packet_id": 3,
+                                      "length": 8},
+                           "body": {"sys_uptime": 4, "res_err": 5,
+                                    "res_index": 6, "varbinds": None}},
+                          ""))
 
 
 if __name__ == "__main__":



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

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/f4aace48de6fe143519483c4abfd04063249e623
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/20170718/a3c2750e/attachment.html>


More information about the vc mailing list