[Git][NTPsec/ntpsec][master] In pylib/packet.py, add flatten() to support MAC computation.
Eric S. Raymond
gitlab at mg.gitlab.com
Mon Oct 31 11:40:30 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
3a5643d4 by Eric S. Raymond at 2016-10-31T07:10:43-04:00
In pylib/packet.py, add flatten() to support MAC computation.
- - - - -
1 changed file:
- pylib/packet.py
Changes:
=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -146,15 +146,15 @@ class Packet:
format = "!BBHHHHH"
HEADER_LEN = 12
- def send(self, payload1, payload2, payload3, payload4):
- "Send the packet and its payload in association with a session"
+ def flatten(self, payload1, payload2, payload3, payload4):
+ "Flatten the packet into an octet sequence."
self.count = len(self.extension)
body = struct.pack(Packet.format,
self.li_vn_mode,
self.r_e_m_op,
payload1, payload2, payload3, payload4,
self.count)
- self.session.sendpkt(body + self.extension)
+ return polybytes(body + self.extension)
def analyze(self, rawdata):
(self.li_vn_mode,
@@ -204,11 +204,17 @@ class Mode6Packet(Packet):
"Return statistics on a fragment."
return "%5d %5d\t%3d octets\n" % (self.offset, self.end(), self.count)
+ def flatten(self):
+ return Packet.flatten(self,
+ self.sequence,
+ self.status,
+ self.associd,
+ self.offset)
+
def send(self):
self.session.sequence += 1
self.sequence = self.session.sequence
- Packet.send(self,
- self.sequence, self.status, self.associd, self.offset)
+ self.session.sendpkt(self.flatten())
def analyze(self, data):
(self.sequence,
@@ -409,8 +415,6 @@ class Mode6Session:
if not auth and not self.always_auth:
return pkt.send()
- # Following code is a non-working prototype
-
# Pad out packet to a multiple of 8 octets to be sure
# receiver can handle it.
while ((Packet.HEADER_LEN + len(pkt.extension)) % 8):
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/3a5643d4588ed3f3cb5ebe7d7b27f8da0ce86349
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161031/5d95cfd8/attachment.html>
More information about the vc
mailing list