Skip to content

Conversation

@mbUSC
Copy link

@mbUSC mbUSC commented Aug 21, 2023

Resolves #4049

@codecov
Copy link

codecov bot commented Aug 21, 2023

Codecov Report

❌ Patch coverage is 34.28571% with 23 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.95%. Comparing base (f37c402) to head (8af2e41).
⚠️ Report is 493 commits behind head on master.

Files with missing lines Patch % Lines
scapy/layers/tuntap.py 34.28% 23 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4100      +/-   ##
==========================================
+ Coverage   81.68%   81.95%   +0.26%     
==========================================
  Files         328      328              
  Lines       75497    75875     +378     
==========================================
+ Hits        61668    62181     +513     
+ Misses      13829    13694     -135     
Files with missing lines Coverage Δ
scapy/layers/tuntap.py 73.77% <34.28%> (-9.06%) ⬇️

... and 40 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@guedou
Copy link
Member

guedou commented Aug 21, 2023

Thanks for this PR. I will give it a try. In the meantine, could you fix the PEP-08 issues https://github.com/secdev/scapy/actions/runs/5920584081/job/16053137679?pr=4100#step:5:1 ?

self.kernel_packet_class = MacOSUtunPacketInfo
self.mtu_overhead = 4

match = re.match(r"([a-z]+)([0-9]+)", self.iface.decode("utf-8"), re.I)
Copy link
Contributor

@micolous micolous Aug 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to import re or decode bytestrings - just strip the prefix (b'utun') from the string:

# self.iface = b'utun0'
interface_num = int(self.iface[4:])

elif BSD:
if not (self.iface.startswith(b"tap") or
self.iface.startswith(b"tun") or
self.iface.startswith(b"utun")):
Copy link
Contributor

@micolous micolous Aug 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utun is Darwin-specific, so shouldn't be attempted on BSD.

However, tap and tun on Darwin are provided by a third-party kext (which works the same way as BSD's tap and tun), so Darwin will still need to hit this BSD branch.

IntField("addr_family", socket.AF_INET)
]

def guess_payload_class(self, payload):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use bind_layers() rather than implementing guess_payload_class.

@gpotter2
Copy link
Member

Superseded by #4816

@gpotter2 gpotter2 closed this Sep 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Interface names must start with tun or tap on BSD and Darwin

4 participants