Ignore:
Timestamp:
May 12, 2012, 4:38:21 PM (13 years ago)
Author:
rick
Message:

[1:-1] is voor het IP address en niet voor het mac adress. Zorg ervoor dat er
complete goede mac addressen opgeslagen worden.

Related-To: nodefactory:ticket:161

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/releng-9.0/nanobsd/files/usr/local/www/wlportal/index.cgi

    r10794 r10795  
    9292  """ Find out the MAC for a certain IP address """
    9393  try:
    94     return subprocess.check_output(['/usr/sbin/arp', '-n' ,ipaddr], shell=False).split()[3][1:-1]
     94    # ? (172.17.32.1) at 00:12:34:45:67:90 on ue0 permanent [ethernet]
     95    return subprocess.check_output(['/usr/sbin/arp', '-n' ,ipaddr], shell=False).split()[3]
    9596  except subprocess.CalledProcessError:
    9697    raise MACnotFound
     
    9899def get_active_MACs():
    99100  """ Return dictionary with active IPs as keys """
     101  # ? (172.17.32.1) at 00:12:34:45:67:90 on ue0 permanent [ethernet]
     102  # ? (172.17.32.2) at 00:aa:bb:cc:dd:ee on ue0 expires in 964 seconds [ethernet]
     103  # ? (172.16.3.38) at (incomplete) on vr2 expired [ethernet]
    100104  output = subprocess.check_output(['/usr/sbin/arp', '-n' ,'-a'], shell=False)
    101105  db = {}
    102106  for line in output.strip().split('\n'):
    103107    i = line.split()
    104     mac = i[3][1:-1]
    105     ip = i[5]
     108    mac = i[3]
     109    ip = i[5][1:-1]
    106110    db[ip] = mac
    107111  return db
Note: See TracChangeset for help on using the changeset viewer.