<s> """<STR_LIT>""" <EOL> import sys , os , socket <EOL> from scapy . error import * <EOL> import scapy . config <EOL> try : <EOL> import matplotlib . pyplot as plt <EOL> MATPLOTLIB = True <EOL> if scapy . config . conf . interactive : <EOL> plt . ion ( ) <EOL> except ImportError : <EOL> log_loading . debug ( "<STR_LIT>" ) <EOL> MATPLOTLIB = False <EOL> try : <EOL> import networkx as nx <EOL> NETWORKX = True <EOL> except ImportError : <EOL> log_loading . debug ( "<STR_LIT>" ) <EOL> NETWORKX = False <EOL> try : <EOL> import pyx <EOL> PYX = <NUM_LIT:1> <EOL> except ImportError : <EOL> log_loading . debug ( "<STR_LIT>" ) <EOL> PYX = <NUM_LIT:0> <EOL> if scapy . config . conf . use_netifaces : <EOL> try : <EOL> import netifaces <EOL> except ImportError as e : <EOL> log_loading . warning ( "<STR_LIT>" % e ) <EOL> scapy . config . conf . use_netifaces = False <EOL> def str2mac ( s ) : <EOL> return ( "<STR_LIT>" * <NUM_LIT:6> ) [ : - <NUM_LIT:1> ] % tuple ( s ) <EOL> def get_if_addr ( iff ) : <EOL> return socket . inet_ntoa ( get_if_raw_addr ( iff ) ) <EOL> def get_if_hwaddr ( iff ) : <EOL> mac = get_if_raw_hwaddr ( iff ) <EOL> return str2mac ( mac ) <EOL> LINUX = sys . platform . startswith ( "<STR_LIT>" ) <EOL> OPENBSD = sys . platform . startswith ( "<STR_LIT>" ) <EOL> FREEBSD = sys . platform . startswith ( "<STR_LIT>" ) <EOL> NETBSD = sys . platform . startswith ( "<STR_LIT>" ) <EOL> DARWIN = sys . platform . startswith ( "<STR_LIT>" ) <EOL> SOLARIS = sys . platform . startswith ( "<STR_LIT>" ) <EOL> WINDOWS = sys . platform . startswith ( "<STR_LIT:win32>" ) <EOL> X86_64 = not WINDOWS and ( os . uname ( ) [ <NUM_LIT:4> ] == '<STR_LIT>' ) <EOL> if WINDOWS : <EOL> pass <EOL> if LINUX : <EOL> from . linux import * <EOL> if scapy . config . conf . use_winpcapy or scapy . config . conf . use_netifaces : <EOL> from . pcapdnet import * <EOL> elif OPENBSD or FREEBSD or NETBSD or DARWIN : <EOL> from . bsd import * <EOL> elif SOLARIS : <EOL> from . solaris import * <EOL> elif WINDOWS : <EOL> from . windows import * <EOL> if scapy . config . conf . iface is None : <EOL> scapy . config . conf . iface = LOOPBACK_NAME <EOL> def get_if_raw_addr6 ( iff ) : <EOL> """<STR_LIT>""" <EOL> r = [ x for x in in6_getifaddr ( ) if x [ <NUM_LIT:2> ] == iff and x [ <NUM_LIT:1> ] == IPV6_ADDR_GLOBAL ] <EOL> if len ( r ) == <NUM_LIT:0> : <EOL> return None <EOL> else : <EOL> r = r [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] <EOL> return inet_pton ( socket . AF_INET6 , r ) </s>
