Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scapy/layers/inet.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ def in4_pseudoheader(proto, u, plen):
:param u: IP layer instance
:param plen: the length of the upper layer and payload
"""
u = u.copy()
if u.len is not None:
if u.ihl is None:
olen = sum(len(x) for x in u.options)
Expand Down
9 changes: 9 additions & 0 deletions test/scapy/layers/inet.uts
Original file line number Diff line number Diff line change
Expand Up @@ -763,3 +763,12 @@ assert no_sr[UDP].chksum == sr[UDP].chksum

sr = IP(raw(IP(options=[IPOption_LSRR(routers=["1.1.1.1"]), IPOption_SSRR(routers=["8.8.8.8"])])/UDP()/DNS()))
assert no_sr[UDP].chksum != sr[UDP].chksum

# GH4174
sr = Ether(src="de:ad:be:ef:aa:55", dst="ca:fe:00:00:00:00")/IP(src="20.0.0.1",dst="100.0.0.1")/ \
IP(src="20.0.0.1",dst="100.0.0.1", options=[IPOption_SSRR(copy_flag=1, pointer=4, routers=["1.1.1.1", "8.8.8.8"])])/ \
UDP(sport=1111, dport=2222) / VXLAN() / \
Ether(src="de:ad:be:ef:aa:55", dst="ca:fe:00:00:00:00")/IP(src="20.0.0.1",dst="100.0.0.1") / \
TCP()
bytes(sr[UDP])
assert sr[IP:2].dst == "100.0.0.1"