Wrap scapy to satisfy pylint """ import ptf from ptf import config import sys import logging try: import scapy.config import scapy.route import scapy.layers.l2 import scapy.layers.inet import scapy.layers.dhcp import scapy.packet import scapy.main if not config.get("disable_ipv6", False): import scapy.route6 import scapy.layers.inet6 except ImportError: sys.exit("Need to install scapy for packet parsing") Ether = scapy.layers.l2.Ether LLC = scapy.layers.l2.LLC SNAP = scapy.layers.l2.SNAP Dot1Q = scapy.layers.l2.Dot1Q GRE = scapy.layers.l2.GRE IP = scapy.layers.inet.IP IPOption = scapy.layers.inet.IPOption try: ARP = scapy.layers.inet.ARP except AttributeError:
""" A pluggable packet module This module dynamically imports definitions from packet manipulation module, specified in config or provided as an agrument. The default one is Scapy, but one can develop its own packet manipulation framework and then, create an implementation of packet module for it (for Scapy it is packet_scapy.py) """ from __future__ import print_function from ptf import config __module = __import__(config.get("packet_manipulation_module", "ptf.packet_scapy"), fromlist=["*"]) __keys = [] # import logic - everything from __all__ if provided, otherwise everything not starting # with underscore print("Using packet manipulation module: %s" % __module.__name__) if "__all__" in __module.__dict__: __keys = __module.__dict__["__all__"] else: __keys = [k for k in __module.__dict__ if not k.startswith("_")] locals().update({k: getattr(__module, k) for k in __keys})