CONTRIBUTING.md is Scapy's contribution guide; this file is its operational companion for agents working in this checkout, not a replacement.
A layer is a Packet subclass with a fields_desc list. For packet, field,
binding, and layer-test patterns, use
scapy-packet-fields.
- New protocols may go in either location:
scapy/layers/normally contains protocols found on common networks, whilescapy/contrib/normally contains uncommon or specific protocols. - Code in
scapy/layers/should not importscapy/contrib/. Contrib code may import from either location. Contrib modules are loaded withload_contrib()rather than by the default layer loader. - Implement protocol-related features in the module containing that protocol.
Other features may live in
scapy/modules/orscapy/contrib/. - Be especially careful about CPU and memory costs in Scapy core code such as
scapy/packet.py; packet initialization is a hot path.
Follow CONTRIBUTING.md's test requirements. Scapy's
test suite uses UTScapy .uts campaigns under test/.
A campaign has this form:
% Packet regression
+ Build and dissect
= Round trip
~ protocol_keyword
packet = Protocol(field=value)
decoded = Protocol(bytes(packet))
decoded.field == value
%, +, and = start a campaign, test set, and unit test. ~ assigns
keywords. Unprefixed lines inside a unit test are Python; the truth value of the
last expression decides the result.
Run the affected campaign directly while developing, for example:
./test/run_tests -t test/contrib/automotive/autosar/pdu.uts -K tshark -NRun the portable suite from the repository root with Python and tox
installed:
./test/run_testsFollow CONTRIBUTING.md's coding style and conventions.
Flake8 checks scapy/ with an 88-column limit and the per-file exceptions in
tox.ini. CI invokes the lint and type-check environments under Python 3.12.
Because tox.ini does not select that interpreter for these environments,
install tox for Python 3.12 and invoke it explicitly to match CI:
python3.12 -m tox -e flake8
python3.12 -m tox -e mypyThe mypy environment runs both Linux and Windows configurations.
- Do not modify files in
scapy/layers/msrpce/raw/whose header says they are generated bymidl-to-scapy. - Update the encoded data in
scapy/libs/bluetoothids.py,scapy/libs/manuf.py, andscapy/libs/ethertypes.pythrough their matchingscapy/tools/generate_*.pyscripts.
Follow CONTRIBUTING.md's guidance on AI-assisted reports and PRs
and submitting pull requests.
If a change uncovers something that may be a security bug, follow
SECURITY.md for classification and reporting.