scapy.dadict

Direct Access dictionary.

class scapy.dadict.DADict(_name: str = 'DADict', **kargs: Any)[source]

Bases: Generic[scapy.dadict._K, scapy.dadict._V]

Direct Access Dictionary

This acts like a dict, but it provides a direct attribute access to its keys through its values. This is used to store protocols, manuf…

For instance, scapy fields will use a DADict as an enum:

ETHER_TYPES[2048] -> IPv4

Whereas humans can access:

ETHER_TYPES.IPv4 -> 2048
ident(v: scapy.dadict._V) str[source]

Return value that is used as key for the direct access

iterkeys() Iterator[scapy.dadict._K][source]
itervalues() Iterator[scapy.dadict._V][source]
keys() List[scapy.dadict._K][source]
update(*args: Dict[str, scapy.dadict._V], **kwargs: Dict[str, scapy.dadict._V]) None[source]
values() List[scapy.dadict._V][source]
exception scapy.dadict.DADict_Exception[source]

Bases: scapy.error.Scapy_Exception

scapy.dadict.fixname(x: Union[bytes, str]) str[source]

Modifies a string to make sure it can be used as an attribute name.