Skip to content

Commit 703cd5a

Browse files
authored
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
1 parent 18d4c30 commit 703cd5a

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ coverage.xml
1111
.ipynb_checkpoints
1212
.mypy_cache
1313
.vscode
14+
.DS_Store
1415
[.]venv/
1516
__pycache__/
1617
doc/scapy/_build

scapy/contrib/geneve.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class GeneveOptions(Packet):
4343
BitField("length", None, 5),
4444
StrLenField('data', '', length_from=lambda x: x.length * 4)]
4545

46+
def extract_padding(self, s):
47+
return "", s
48+
4649
def post_build(self, p, pay):
4750
if self.length is None:
4851
tmp_len = len(self.data) // 4

test/contrib/geneve.uts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ assert (s == b'\xff\xff\xff\xff\xff\xff\x00\x00\x00\x00\x00\x00\x81\x00\x00\x01\
3030
p = Ether(s)
3131
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
3232

33+
= Build & dissect - GENEVE with multiple options
34+
35+
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')]))
36+
p = GENEVE(s)
37+
assert p.optionlen == 4
38+
assert len(p.options) == 2
39+
assert p.options[0].classid == 0x102 and p.options[0].type == 0x1
40+
assert p.options[1].classid == 0x102 and p.options[1].type == 0x2
41+
42+
3343
= Build & dissect - GENEVE encapsulates IPv4
3444

3545
s = raw(IP()/UDP(sport=10000)/GENEVE()/IP())

0 commit comments

Comments
 (0)