-
-
Notifications
You must be signed in to change notification settings - Fork 2k
/
enumerator.py
34 lines (26 loc) · 1.15 KB
/
enumerator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# SPDX-License-Identifier: GPL-2.0-only
# This file is part of Scapy
# See https://scapy.net/ for more information
# Copyright (C) Nils Weiss <nils@we155.de>
# scapy.contrib.description = BMW specific enumerators
# scapy.contrib.status = loads
from scapy.packet import Packet
from scapy.contrib.automotive.scanner.enumerator import _AutomotiveTestCaseScanResult # noqa: E501
from scapy.contrib.automotive.uds import UDS
from scapy.contrib.automotive.bmw.definitions import DEV_JOB
from scapy.contrib.automotive.uds_scan import UDS_Enumerator
from typing import (
Any,
Iterable,
)
class BMW_DevJobEnumerator(UDS_Enumerator):
_description = "Available DevelopmentJobs by Identifier " \
"and negative response per state"
def _get_initial_requests(self, **kwargs):
# type: (Any) -> Iterable[Packet]
scan_range = kwargs.pop("scan_range", range(0x10000))
return (UDS() / DEV_JOB(identifier=x) for x in scan_range)
def _get_table_entry_y(self, tup):
# type: (_AutomotiveTestCaseScanResult) -> str
return "0x%04x: %s" % \
(tup[1].identifier, tup[1].sprintf("%DEV_JOB.identifier%"))