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
execute(socket: Union[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
property negative_response_blacklist
property results
property results_with_negative_response

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

property results_with_positive_response

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

property results_with_response
property results_without_response

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

runtime_estimation() Optional[Tuple[int, int, float]][source]
property scanned_states

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

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

Bases: ServiceEnumerator, StateGenerator

get_new_edge(socket: Union[SuperSocket, SingleConversationSocket], config: AutomotiveTestCaseExecutorConfiguration) Optional[Tuple[EcuState, EcuState]][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: Union[SuperSocket, SingleConversationSocket], edge: Tuple[EcuState, EcuState]) Optional[Tuple[Callable[[Union[SuperSocket, SingleConversationSocket], AutomotiveTestCaseExecutorConfiguration, Dict[str, Any]], bool], Dict[str, Any], Optional[Callable[[Union[SuperSocket, SingleConversationSocket], AutomotiveTestCaseExecutorConfiguration], bool]]]][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: Union[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