diff --git a/.gitignore b/.gitignore index 87aaa0353..fc0890495 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ coverage.xml .ipynb_checkpoints .mypy_cache .vscode +.DS_Store [.]venv/ __pycache__/ doc/scapy/_build diff --git a/scapy/contrib/geneve.py b/scapy/contrib/geneve.py index b44cb5433..6515f299a 100644 --- a/scapy/contrib/geneve.py +++ b/scapy/contrib/geneve.py @@ -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 diff --git a/test/contrib/geneve.uts b/test/contrib/geneve.uts index 697a359f7..5e730dcaf 100644 --- a/test/contrib/geneve.uts +++ b/test/contrib/geneve.uts @@ -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())