tools/testing/selftests/tc-testing/plugin-lib/scapyPlugin.py
Source file repositories/reference/linux-study-clean/tools/testing/selftests/tc-testing/plugin-lib/scapyPlugin.py
File Facts
- System
- Linux kernel
- Corpus path
tools/testing/selftests/tc-testing/plugin-lib/scapyPlugin.py- Extension
.py- Size
- 1703 bytes
- Lines
- 55
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: tools
- Status
- atlas-only
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
Dependency Surface
- No C-style include directives detected by the generator.
Detected Declarations
- No top-level syscall, struct, function, initcall, or export declaration detected by the generator.
Annotated Snippet
#!/usr/bin/env python3
import os
import signal
from string import Template
import subprocess
import time
from TdcPlugin import TdcPlugin
from tdc_config import *
try:
from scapy.all import *
except ImportError:
print("Unable to import the scapy python module.")
print("\nIf not already installed, you may do so with:")
print("\t\tpip3 install scapy==2.4.2")
exit(1)
class SubPlugin(TdcPlugin):
def __init__(self):
self.sub_class = 'scapy/SubPlugin'
super().__init__()
def post_execute(self):
if 'scapy' not in self.args.caseinfo:
if self.args.verbose:
print('{}.post_execute: no scapy info in test case'.format(self.sub_class))
return
# Check for required fields
lscapyinfo = self.args.caseinfo['scapy']
if type(lscapyinfo) != list:
lscapyinfo = [ lscapyinfo, ]
for scapyinfo in lscapyinfo:
scapy_keys = ['iface', 'count', 'packet']
missing_keys = []
keyfail = False
for k in scapy_keys:
if k not in scapyinfo:
keyfail = True
missing_keys.append(k)
if keyfail:
print('{}: Scapy block present in the test, but is missing info:'
.format(self.sub_class))
print('{}'.format(missing_keys))
pkt = eval(scapyinfo['packet'])
if '$' in scapyinfo['iface']:
tpl = Template(scapyinfo['iface'])
scapyinfo['iface'] = tpl.safe_substitute(NAMES)
for count in range(scapyinfo['count']):
sendp(pkt, iface=scapyinfo['iface'])
Annotation
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: atlas-only.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.