Skip to content
Snippets Groups Projects
Commit e0dc9af8 authored by zer0@platinum's avatar zer0@platinum
Browse files

Fix PadField class: add getfield() method

parent 9890b567
No related branches found
No related tags found
No related merge requests found
...@@ -154,6 +154,11 @@ class PadField: ...@@ -154,6 +154,11 @@ class PadField:
self._align = align self._align = align
self._padwith = padwith or "" self._padwith = padwith or ""
def getfield(self, pkt, s):
x = self._fld.getfield(pkt,s)
padlen = ((self._align - (len(x[1]) % self._align)) % self._align)
return x[0][padlen:], x[1]
def addfield(self, pkt, s, val): def addfield(self, pkt, s, val):
sval = self._fld.addfield(pkt, "", val) sval = self._fld.addfield(pkt, "", val)
return s+sval+struct.pack("%is" % (-len(sval)%self._align), self._padwith) return s+sval+struct.pack("%is" % (-len(sval)%self._align), self._padwith)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment