scapy.contrib.automotive.scanner.enumerator

class scapy.contrib.automotive.scanner.enumerator.ServiceEnumerator[source]

Bases: AutomotiveTestCase

Base class for ServiceEnumerators of automotive diagnostic protocols

property completed: bool
execute(socket: SuperSocket | SingleConversationSocket, state: EcuState, **kwargs: Any) None[source]
Parameters:
  • timeout (integer or float) – Timeout until a response will arrive after a request

  • count (integer) – Number of request to be sent in one execution

  • execution_time (int) – Time in seconds until the execution of this enumerator is stopped.

  • state_allow_list (EcuState or list) – List of EcuState objects or EcuState object in which the the execution of this enumerator is allowed. If provided, other states will not be executed.

  • state_block_list (EcuState or list) – List of EcuState objects or EcuState object in which the the execution of this enumerator is blocked.

  • retry_if_none_received (bool) – Specifies if a request will be send again, if None was received (usually because of a timeout).

  • exit_if_no_answer_received (bool) – Specifies to finish the execution of this enumerator once None is received.

  • exit_if_service_not_supported (bool) – Specifies to finish the execution of this enumerator, once the negative return code ‘serviceNotSupported’ is received.

  • exit_scan_on_first_negative_response (bool) – Specifies to finish the execution once a negative response is received.

  • retry_if_busy_returncode (bool) – Specifies to retry a request, if the ‘busyRepeatRequest’ negative response code is received.

  • debug (bool) – Enables debug functions during execute.

  • stop_event (Event) – Signals immediate stop of the execution.

  • scan_range (list or tuple or range or iterable) – Specifies the identifiers to be scanned.

property filtered_results: List[_AutomotiveTestCaseFilteredScanResult]
property negative_response_blacklist: List[int]
property results: List[_AutomotiveTestCaseScanResult]
property results_with_negative_response: List[_AutomotiveTestCaseFilteredScanResult]

Helper function to get all results with negative response :return: all results with negative response

property results_with_positive_response: List[_AutomotiveTestCaseFilteredScanResult]

Helper function to get all results with positive response :return: all results with positive response

property results_with_response: List[_AutomotiveTestCaseFilteredScanResult]
property results_without_response: List[_AutomotiveTestCaseScanResult]

Helper function to get all results without response :return: all results without response

runtime_estimation() Tuple[int, int, float] | None[source]
property scanned_states: Set[EcuState]

Helper function to get all sacnned states in results :return: all scanned states

show(dump: bool = False, filtered: bool = True, verbose: bool = False) str | None[source]
sr1_with_retry_on_error(req: Packet, socket: SuperSocket | SingleConversationSocket, state: EcuState, timeout: int) Packet | None[source]
property supported_responses: List[EcuResponse]
class scapy.contrib.automotive.scanner.enumerator.StateGeneratingServiceEnumerator[source]

Bases: ServiceEnumerator, StateGenerator

get_new_edge(socket: SuperSocket | SingleConversationSocket, config: AutomotiveTestCaseExecutorConfiguration) Tuple[EcuState, EcuState] | None[source]

Basic identification of a new edge. The last response is evaluated. If this response packet can modify the state of an Ecu, this new state is returned, otherwise None.

Parameters:
  • socket – Socket to the DUT (unused)

  • config – Global configuration of the executor (unused)

Returns:

tuple of old EcuState and new EcuState, or None

get_transition_function(socket: SuperSocket | SingleConversationSocket, edge: Tuple[EcuState, EcuState]) Tuple[Callable[[SuperSocket | SingleConversationSocket, AutomotiveTestCaseExecutorConfiguration, Dict[str, Any]], bool], Dict[str, Any], Callable[[SuperSocket | SingleConversationSocket, AutomotiveTestCaseExecutorConfiguration], bool] | None] | None[source]
get_transition_function_description(edge: Tuple[EcuState, EcuState]) str[source]
get_transition_function_kwargs(edge: Tuple[EcuState, EcuState]) Dict[str, Any][source]
static transition_function(sock: SuperSocket | SingleConversationSocket, config: AutomotiveTestCaseExecutorConfiguration, kwargs: Dict[str, Any]) bool[source]

Very basic transition function. This function sends a given request in kwargs and evaluates the response.

Parameters:
  • sock – Connection to the DUT

  • config – Global configuration of the executor (unused)

  • kwargs – Dictionary with arguments. This function only uses the argument “req” which must contain a Packet, causing an EcuState transition of the DUT.

Returns:

True in case of a successful transition, else False