Skip to content
Snippets Groups Projects
Commit 84e5bf6a authored by jogarock's avatar jogarock
Browse files

Modified to meet PR standards. See PR conversation

--HG--
branch : issue_5141
parent 364a290e
Branches
No related tags found
No related merge requests found
...@@ -289,17 +289,17 @@ class CDPMsg(CDPMsgGeneric): ...@@ -289,17 +289,17 @@ class CDPMsg(CDPMsgGeneric):
class _CDPChecksum: class _CDPChecksum:
def _check_len(self, pkt): def _check_len(self, pkt):
"""Check for odd packet length and pad according to Cisco spec""" """Check for odd packet length and pad according to Cisco spec.
This padding is only used for checksum computation. The original
packet should not be altered."""
if len(pkt) % 2: if len(pkt) % 2:
last_chr = pkt[-1] last_chr = pkt[-1]
if ord(last_chr) <=0x80: if last_chr <= '\x80':
ck_p = pkt[:-1] + '\x00' + last_chr return pkt[:-1] + '\x00' + last_chr
else: else:
ck_p = pkt[:-1] + '\xff' + chr(ord(last_chr) - 1) return pkt[:-1] + '\xff' + chr(ord(last_chr) - 1)
else: else:
ck_p = pkt return pkt
return ck_p
def post_build(self, pkt, pay): def post_build(self, pkt, pay):
p = pkt + pay p = pkt + pay
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment