function parseArpTable (arpStr) {
  var arpArr = []
  var arpt = arpStr.join()
  arpt = arpt.split('\n')
  var x
  for (x in arpt) {
    var entry = arpt[x]
    var arpObj = {}

    // Get the IP from the "(1.2.3.4)" fromat
    var ipStart = entry.indexOf('(')
    if (ipStart === -1) {
      continue
    }
    var ipEnd = entry.indexOf(')')
    var ip = entry.slice(ipStart + 1, ipEnd)
    arpObj['ip'] = ip

    // Get the Corresponding MAC Addres by splitting
    var mac = entry.split(' ')[3]

    // make sure MAC addresses are in lowercase
    mac = mac.toLowerCase()

    // make sure octets have a leading zero
    var macSplited = mac.split(':')
    for (var i in macSplited) {
      if (macSplited.hasOwnProperty(i)) {
        if (macSplited[i].length === 1) {
          macSplited[i] = '0' + macSplited[i]
        }
      }
    }

    // join octets again
    mac = macSplited.join(':')

    arpObj['mac'] = mac

    arpArr.push(arpObj)
  }

  return arpArr
}
function parseArpTable (arpStr) {
  var arpArr = []
  var arpt = arpStr.join()
  arpt = arpt.split('\n')
  var x
  for (x in arpt) {
    var entry = arpt[x]
    var arpObj = {}

    
    var ipStart = entry.indexOf('(')
    if (ipStart === -1) {
      continue
    }
    var ipEnd = entry.indexOf(')')
    var ip = entry.slice(ipStart + 1, ipEnd)
    arpObj['ip'] = ip

    
    var mac = entry.split(' ')[3]

    
    mac = mac.toLowerCase()

    
    var macSplited = mac.split(':')
    for (var i in macSplited) {
      if (macSplited.hasOwnProperty(i)) {
        if (macSplited[i].length === 1) {
          macSplited[i] = '0' + macSplited[i]
        }
      }
    }

    
    mac = macSplited.join(':')

    arpObj['mac'] = mac

    arpArr.push(arpObj)
  }

  return arpArr
}
function parseArpTable ( arpStr ) { var arpArr = [ ] var arpt = arpStr . join ( ) arpt = arpt . split ( '\n' ) var x for ( x in arpt ) { var entry = arpt [ x ] var arpObj = { } // Get the IP from the "(1.2.3.4)" fromat var ipStart = entry . indexOf ( '(' ) if ( ipStart === - 1 ) { continue } var ipEnd = entry . indexOf ( ')' ) var ip = entry . slice ( ipStart + 1 , ipEnd ) arpObj [ 'ip' ] = ip // Get the Corresponding MAC Addres by splitting var mac = entry . split ( ' ' ) [ 3 ] // make sure MAC addresses are in lowercase mac = mac . toLowerCase ( ) // make sure octets have a leading zero var macSplited = mac . split ( ':' ) for ( var i in macSplited ) { if ( macSplited . hasOwnProperty ( i ) ) { if ( macSplited [ i ] . length === 1 ) { macSplited [ i ] = '0' + macSplited [ i ] } } } // join octets again mac = macSplited . join ( ':' ) arpObj [ 'mac' ] = mac arpArr . push ( arpObj ) } return arpArr }
Parse ARP details from table TODO: Validate and format IP and MAC Addresses
Parse ARP details from table TODO : Validate and format IP and MAC Addresses