Skip to content
Open
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
3 changes: 3 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ installed:
Please note the following guidelines when adding tests:
- Do not create a new `.uts` if there is already a file that contains tests for that layer. Only create a `.uts` file when no previous tests exist for that layer.
- When adding tests to an existing `.uts` file, try to place the tests contextually close to tests that are related to the same or similar features.
- When writing test reconnect or reset handlers that rebind socket variables in an enclosing scope, ensure `nonlocal` is declared to prevent `UnboundLocalError` inside exception-handling blocks from silently bypassing socket closure and unpairing.
- When managing paired test sockets or simulated buses (`TestSocket`, `UnstableSocket`, `ObjectPipe`), explicitly close and unpair discarded sockets, and drain or clear reusable shared pipes (`pipe.clear()`) across reconnections to avoid socket leaks and duplicate frame deliveries.
- Tests relying on external network services (e.g., `whois`) must allow for upstream rate limits and query quota errors (such as RIPE `%ERROR:` responses) to avoid intermittent failures on CI runners.

## Check source changes

Expand Down
206 changes: 206 additions & 0 deletions scapy/contrib/automotive/j1939/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
# SPDX-License-Identifier: GPL-2.0-only
# This file is part of Scapy
# See https://scapy.net/ for more information
# Copyright (C) National Motor Freight Traffic Association Inc.
# <ben.l.gardiner@gmail.com>

# scapy.contrib.description = SAE J1939 Transport Layer Socket & Diagnostics
# scapy.contrib.status = loads

from scapy.contrib.automotive.j1939.j1939_dm import (
J1939Dm1,
J1939Dm13,
J1939Dm14,
J1939Dm15,
J1939Dtc,
J1939_PGN_DM1,
J1939_PGN_DM13,
J1939_PGN_DM14,
J1939_PGN_DM15,
)
from scapy.contrib.automotive.j1939.j1939_dm_scanner import (
J1939PgnScanResult,
J1939_DM_PGNS,
J1939_PF_ACK,
J1939_PGN_ACK,
J1939_PGN_VIN,
j1939_scan_dm,
j1939_scan_pgns,
)
from scapy.contrib.automotive.j1939.j1939_name import (
J1939Name,
J1939_INDUSTRY_GROUPS,
J1939_INDUSTRY_SPECIFIC_FUNCTIONS,
J1939_INDUSTRY_SPECIFIC_VEHICLE_SYSTEMS,
J1939_MANUFACTURERS,
J1939_PRE_ASSIGNED_FUNCTIONS,
j1939_format_name_function,
j1939_format_name_industry_group,
j1939_format_name_manufacturer,
j1939_format_name_vehicle_system,
)
from scapy.contrib.automotive.j1939.j1939_scanner import (
J1939ScanResult,
J1939_ACK_CTRL_ACCESS_DENIED,
J1939_ACK_CTRL_ACK,
J1939_ACK_CTRL_CANNOT_RESPOND,
J1939_ACK_CTRL_NACK,
J1939_DEFAULT_BITRATE,
J1939_DEFAULT_BUSLOAD,
J1939_DIAGADAPTERS_ADDRESSES,
J1939_PF_ADDRESS_CLAIMED,
J1939_PF_REQUEST,
J1939_PF_XCP,
J1939_PGN_ECU_ID,
J1939_SCAN_METHODS,
J1939_TP_CM_PF,
J1939_UDS_TESTER_PRESENT_REQS,
J1939_UDS_TESTER_PRESENT_RESPS,
J1939_XCP_CONNECT_REQ,
J1939_XCP_POSITIVE_RESPONSE,
J1939_XCP_SRC_ADDRS,
j1939_check_rx_filter_warning,
j1939_check_socket_can_filters,
j1939_emit_sa_filter_warning,
j1939_get_sock,
j1939_inter_probe_delay,
j1939_request_name,
j1939_request_names,
j1939_sa_filter,
j1939_scan,
j1939_scan_addr_claim,
j1939_scan_ecu_id,
j1939_scan_passive,
j1939_scan_rts_probe,
j1939_scan_uds,
j1939_scan_unicast,
j1939_scan_xcp,
)
from scapy.contrib.j1939 import (
J1939,
J1939Ack,
J1939DiagA,
J1939DiagB,
J1939Request,
J1939Socket,
J1939SoftSocket,
J1939TPImplementation,
J1939_CAN,
J1939_GLOBAL_ADDRESS,
J1939_NULL_ADDRESS,
J1939_PF_DIAG_A,
J1939_PF_DIAG_B,
J1939_PGN_ADDRESS_CLAIMED,
J1939_PGN_ADDRESS_COMMANDED,
J1939_PGN_DIAG_A,
J1939_PGN_DIAG_B,
J1939_PGN_REQUEST,
J1939_PGN_TP_CM,
J1939_PGN_TP_DT,
J1939_TP_CTRL_ABORT,
J1939_TP_CTRL_ACK,
J1939_TP_CTRL_BAM,
J1939_TP_CTRL_CTS,
J1939_TP_CTRL_RTS,
J1939_USE_CAN_KERNEL_MODULE,
NativeJ1939Socket,
can_id_to_j1939,
j1939_log,
j1939_pgn_from_fields,
j1939_to_can_id,
)

__all__ = [
Comment thread
BenGardiner marked this conversation as resolved.
"J1939",
"J1939Ack",
"J1939DiagA",
"J1939DiagB",
"J1939Dm1",
"J1939Dm13",
"J1939Dm14",
"J1939Dm15",
"J1939Dtc",
"J1939Name",
"J1939PgnScanResult",
"J1939Request",
"J1939ScanResult",
"J1939Socket",
"J1939SoftSocket",
"J1939TPImplementation",
"J1939_ACK_CTRL_ACCESS_DENIED",
"J1939_ACK_CTRL_ACK",
"J1939_ACK_CTRL_CANNOT_RESPOND",
"J1939_ACK_CTRL_NACK",
"J1939_CAN",
"J1939_DEFAULT_BITRATE",
"J1939_DEFAULT_BUSLOAD",
"J1939_DIAGADAPTERS_ADDRESSES",
"J1939_DM_PGNS",
"J1939_GLOBAL_ADDRESS",
"J1939_INDUSTRY_GROUPS",
"J1939_INDUSTRY_SPECIFIC_FUNCTIONS",
"J1939_INDUSTRY_SPECIFIC_VEHICLE_SYSTEMS",
"J1939_MANUFACTURERS",
"J1939_NULL_ADDRESS",
"J1939_PF_ACK",
"J1939_PF_ADDRESS_CLAIMED",
"J1939_PF_DIAG_A",
"J1939_PF_DIAG_B",
"J1939_PF_REQUEST",
"J1939_PF_XCP",
"J1939_PGN_ACK",
"J1939_PGN_ADDRESS_CLAIMED",
"J1939_PGN_ADDRESS_COMMANDED",
"J1939_PGN_DIAG_A",
"J1939_PGN_DIAG_B",
"J1939_PGN_DM1",
"J1939_PGN_DM13",
"J1939_PGN_DM14",
"J1939_PGN_DM15",
"J1939_PGN_ECU_ID",
"J1939_PGN_REQUEST",
"J1939_PGN_TP_CM",
"J1939_PGN_TP_DT",
"J1939_PGN_VIN",
"J1939_PRE_ASSIGNED_FUNCTIONS",
"J1939_SCAN_METHODS",
"J1939_TP_CM_PF",
"J1939_TP_CTRL_ABORT",
"J1939_TP_CTRL_ACK",
"J1939_TP_CTRL_BAM",
"J1939_TP_CTRL_CTS",
"J1939_TP_CTRL_RTS",
"J1939_UDS_TESTER_PRESENT_REQS",
"J1939_UDS_TESTER_PRESENT_RESPS",
"J1939_USE_CAN_KERNEL_MODULE",
"J1939_XCP_CONNECT_REQ",
"J1939_XCP_POSITIVE_RESPONSE",
"J1939_XCP_SRC_ADDRS",
"NativeJ1939Socket",
"can_id_to_j1939",
"j1939_check_rx_filter_warning",
"j1939_check_socket_can_filters",
"j1939_emit_sa_filter_warning",
"j1939_format_name_function",
"j1939_format_name_industry_group",
"j1939_format_name_manufacturer",
"j1939_format_name_vehicle_system",
"j1939_get_sock",
"j1939_inter_probe_delay",
"j1939_log",
"j1939_pgn_from_fields",
"j1939_request_name",
"j1939_request_names",
"j1939_sa_filter",
"j1939_scan",
"j1939_scan_addr_claim",
"j1939_scan_dm",
"j1939_scan_ecu_id",
"j1939_scan_passive",
"j1939_scan_pgns",
"j1939_scan_rts_probe",
"j1939_scan_uds",
"j1939_scan_unicast",
"j1939_scan_xcp",
"j1939_to_can_id",
]
Loading
Loading