def get_if_raw_hwaddr(ifname):
 NULL_MAC_ADDRESS = ('\x00' * 6)
 if (ifname == LOOPBACK_NAME):
  return (ARPHDR_LOOPBACK, NULL_MAC_ADDRESS)
 try:
  fd = os.popen(('%s %s' % (conf.prog.ifconfig, ifname)))
 except OSError as msg:
  raise Scapy_Exception(('Failed to execute ifconfig: (%s)' % msg))
 addresses = [l for l in fd.readlines() if ((l.find('ether') >= 0) or (l.find('lladdr') >= 0) or (l.find('address') >= 0))]
 if (not addresses):
  raise Scapy_Exception(('No MAC address found on %s !' % ifname))
 mac = addresses[0].split(' ')[1]
 mac = [chr(int(b, 16)) for b in mac.split(':')]
 return (ARPHDR_ETHER, ''.join(mac))

def get_if_raw_hwaddr ( ifname ) : NULL_MAC_ADDRESS = ( '\x00' * 6 ) if ( ifname == LOOPBACK_NAME ) : return ( ARPHDR_LOOPBACK , NULL_MAC_ADDRESS ) try : fd = os . popen ( ( '%s %s' % ( conf . prog . ifconfig , ifname ) ) ) except OSError as msg : raise Scapy_Exception ( ( 'Failed to execute ifconfig: (%s)' % msg ) ) addresses = [ l for l in fd . readlines ( ) if ( ( l . find ( 'ether' ) >= 0 ) or ( l . find ( 'lladdr' ) >= 0 ) or ( l . find ( 'address' ) >= 0 ) ) ] if ( not addresses ) : raise Scapy_Exception ( ( 'No MAC address found on %s !' % ifname ) ) mac = addresses [ 0 ] . split ( ' ' ) [ 1 ] mac = [ chr ( int ( b , 16 ) ) for b in mac . split ( ':' ) ] return ( ARPHDR_ETHER , '' . join ( mac ) )
returns the packed mac address configured on ifname .