ArpListener

class mtf.network_port.arp_listener.ArpListener
type: List[Type[Operation] | Type[EtherType] | Type[HARDWARE_TYPE] | Type[PROTOCOL_TYPE]] = [<class 'PrimaITestCaseLibrary.Operation'>, <class 'PrimaITestCaseLibrary.EtherType'>, <class 'PrimaITestCaseLibrary.MessageManagment.HARDWARE_TYPE'>, <class 'PrimaITestCaseLibrary.PROTOCOL_TYPE'>]
convertor: Dict[str, Callable[[str], str] | Type[Operation] | Type[EtherType] | Type[HARDWARE_TYPE] | Type[PROTOCOL_TYPE]] = {'hardware_type': <class 'PrimaITestCaseLibrary.MessageManagment.HARDWARE_TYPE'>, 'operation': <class 'PrimaITestCaseLibrary.Operation'>, 'proto_type': <class 'PrimaITestCaseLibrary.EtherType'>, 'protocol_type': <class 'PrimaITestCaseLibrary.PROTOCOL_TYPE'>, 'sender_mac_address': <function ArpListener.<lambda>>, 'target_mac_address': <function ArpListener.<lambda>>}
__init__(channel_name='', protocol=<mtf_eth_protocol_type.ARP: 262144>)
start_listening(channel=None, arp_filter: dict | None = None, keep_cache=False, callback_fnc=None, silent_mode: bool = False) bool
Parameters:

arp_filter (<keys:values>, optional) – list of attribute to filter on

Create filter for requests from sender 192.168.0.1
filter =  {'operation': 0x01, 'sender_ip_address':'192.168.0.1' }

Note

The filter is applied by AND logic operator is applied between given dictionary keys .

adapt_queue_elements() Queue[BaseEvent]

ensure the object.timestamp, object.payload

static __new__(cls, *args, **kwargs)

Initialize a new instance of the ControllerBase.

The instance will be automatically added to the list of controllers.

callback_(data_frame: BusEvent)
clean_up()
classmethod controllers_cleanup()

Clean up all controller instances.

Calls the clean_up() method for each instance.

get_message_queue() list[dict[str, Any]]

Get messages queue :return: :rtype:

get_queue() list[dict[str, Any]]

Get the queue

get_timestamp_queue() list[int]
register_callback(callback_fnc: Callable[[IEthernetProtocol], None])
Parameters:

callback_fnc – callback function with parameter of type MessageEthernet

Setting a callback
# ...
from andisdk import MessageEthernet
# ...

def eth_listener_callback(msg: MessageEthernet):
    # do things

# ... creating listener 
# register our callback
listener.register_callback(eth_listener_callback)

Warning

The callback function should be lightweight without logs. Otherwise, it will reduce the performance dramatically. The object that is passed to callback functions is mutable. So the user must be careful. In case of silent mode, the callback functions will be invoked only when getting the queue.

reset() None

cleanup the queue

start(channel=None, keep_cache=False, silent_mode: bool = False)
stop()
stop_listening() bool
unregister_callback(callback_fnc: Callable[[IEthernetProtocol], None])
Parameters:

callback_fnc – callback function with parameter of type MessageEthernet

Remove a callback
# ...
from andisdk import MessageEthernet
# ...

def eth_listener_callback(msg: MessageEthernet):
    # do things

# ... creating listener 
# ... do work
# unregister our callback
listener.unregister_callback(eth_listener_callback)