mirror of https://github.com/secdev/scapy.git
Fix Geneve dissection (#3917)
* fix Geneve dissection * Removed accidentally added local files and added unit test. * Little enhancement of Geneve multiple options test * Removed redundant line from gitignore
This commit is contained in:
parent
18d4c30fa4
commit
703cd5a7f5
|
@ -11,6 +11,7 @@ coverage.xml
|
|||
.ipynb_checkpoints
|
||||
.mypy_cache
|
||||
.vscode
|
||||
.DS_Store
|
||||
[.]venv/
|
||||
__pycache__/
|
||||
doc/scapy/_build
|
||||
|
|
|
@ -43,6 +43,9 @@ class GeneveOptions(Packet):
|
|||
BitField("length", None, 5),
|
||||
StrLenField('data', '', length_from=lambda x: x.length * 4)]
|
||||
|
||||
def extract_padding(self, s):
|
||||
return "", s
|
||||
|
||||
def post_build(self, p, pay):
|
||||
if self.length is None:
|
||||
tmp_len = len(self.data) // 4
|
||||
|
|
|
@ -30,6 +30,16 @@ assert (s == b'\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x81\x00\x00\x01\
|
|||
p = Ether(s)
|
||||
assert GENEVE in p and Ether in p[GENEVE].payload and p[GENEVE].proto == 0x6558 and p[GeneveOptions].length == 1 and p[GeneveOptions].classid == 0x102 and p[GeneveOptions].type == 0x80
|
||||
|
||||
= Build & dissect - GENEVE with multiple options
|
||||
|
||||
s = raw(GENEVE(proto=0x0800,options=[GeneveOptions(classid=0x0102,type=0x1,data=b'\x00\x01\x00\x02'), GeneveOptions(classid=0x0102,type=0x2,data=b'\x00\x01\x00\x02')]))
|
||||
p = GENEVE(s)
|
||||
assert p.optionlen == 4
|
||||
assert len(p.options) == 2
|
||||
assert p.options[0].classid == 0x102 and p.options[0].type == 0x1
|
||||
assert p.options[1].classid == 0x102 and p.options[1].type == 0x2
|
||||
|
||||
|
||||
= Build & dissect - GENEVE encapsulates IPv4
|
||||
|
||||
s = raw(IP()/UDP(sport=10000)/GENEVE()/IP())
|
||||
|
|
Loading…
Reference in New Issue