Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

does not return all ARP entries #9

Open
DouglasPearless opened this issue Sep 19, 2017 · 1 comment
Open

does not return all ARP entries #9

DouglasPearless opened this issue Sep 19, 2017 · 1 comment

Comments

@DouglasPearless
Copy link

Sample code:

var arp = require('arp-a')
, tbl = { ipaddrs: {}, ifnames : {} }
;

arp.table(function(err, entry) {
if (!!err) return console.log('arp: ' + err.message);
if (!entry) return;

tbl.ipaddrs[entry.ip] = entry.mac;
if (!tbl.ifnames[entry.ifname]) tbl.ifnames[entry.ifname] = {};
tbl.ifnames[entry.ifname][entry.mac] = entry.ip;

});

console.log(tbl)

Output from the code:

{ ipaddrs: 
   { '169.254.41.79': '70:73:cb:b1:d7:20',
     '172.22.1.1': 'f8:c0:01:85:95:01',
     '172.22.1.21': '70:73:cb:b1:d7:20',
     '172.22.1.24': 'e0:f8:47:2d:78:38',
     '172.22.1.32': 'c8:e0:eb:26:dc:55',
     '172.22.1.33': '5c:cf:7f:44:a5:9a',
     '172.22.1.35': '80:be:05:86:8e:d3',
     '172.22.1.40': '00:25:4b:b7:71:d8',
     '172.22.1.41': '70:3e:ac:68:14:9d',
     '172.22.1.43': 'b0:34:95:f1:8d:40',
     '172.22.1.255': 'ff:ff:ff:ff:ff:ff',
     '224.0.0.1': '01:00:5e:00:00:01',
     '224.0.0.251': '01:00:5e:00:00:fb',
     '239.255.255.250': '01:00:5e:7f:ff:fa' },
  ifnames: 
   { en1: 
      { '70:73:cb:b1:d7:20': '172.22.1.21',
        'f8:c0:01:85:95:01': '172.22.1.1',
        'c8:e0:eb:26:dc:55': '172.22.1.32',
        '5c:cf:7f:44:a5:9a': '172.22.1.33',
        '80:be:05:86:8e:d3': '172.22.1.35',
        '00:25:4b:b7:71:d8': '172.22.1.40',
        '70:3e:ac:68:14:9d': '172.22.1.41',
        'b0:34:95:f1:8d:40': '172.22.1.43',
        'ff:ff:ff:ff:ff:ff': '172.22.1.255',
        '01:00:5e:00:00:01': '224.0.0.1',
        '01:00:5e:00:00:fb': '224.0.0.251',
        '01:00:5e:7f:ff:fa': '239.255.255.250' },
     lo0: { 'e0:f8:47:2d:78:38': '172.22.1.24' } } }

Comparative output from AngryIP:

172.22.1.18 | 1 ms | NAS.local | [n/s] | ICP | 00:08:9B:D0:25:4E
-- | -- | -- | -- | -- | --
172.22.1.19 | 1 ms | [n/a] | [n/s] | Hewlett Packard | 00:1F:29:67:4C:F8
172.22.1.21 | 1 ms | A | [n/s] | Apple | 70:73:CB:B1:D7:20
172.22.1.22 | 1 ms | B | [n/s] | Apple | B8:C7:5D:C7:A7:0C
172.22.1.23 | 1 ms | C | [n/s] | PC Partner | 00:01:2E:48:AB:AA
172.22.1.24 | 0 ms | D | [n/s] | Apple | E0:F8:47:2D:78:38
172.22.1.26 | 1 ms | E | [n/s] | Apple | 5C:96:9D:6D:4F:AF
172.22.1.27 | 1 ms | F | [n/s] | CANON | 88:87:17:A0:50:06
172.22.1.29 | 24 ms | G | [n/s] | Apple | 6C:8D:C1:9F:B0:D1
172.22.1.30 | 1 ms | H | [n/s] | Raspberry Pi Foundation | B8:27:EB:47:F7:49
172.22.1.32 | 90 ms | I | [n/s] | Apple | C8:E0:EB:26:DC:55
172.22.1.33 | 5 ms | [n/a] | [n/s] | Espressif | 5C:CF:7F:44:A5:9A
172.22.1.34 | 107 ms | [n/a] | [n/s] | Espressif | 5C:CF:7F:89:23:F7
172.22.1.35 | 1015 ms | J | [n/s] | Apple | 80:BE:05:86:8E:D3
172.22.1.37 | 5 ms | [n/a] | [n/s] | Frontier Silicon | 00:22:61:B0:EB:9E
172.22.1.38 | 78 ms | K | .local[n/s] | Apple | 00:25:4B:94:18:14
172.22.1.40 | 1 ms | L | .local[n/s] | Apple | 00:25:4B:B7:71:D8
172.22.1.43 | 2 ms | M | [n/s] | Apple | B0:34:95:F1:8D:40

So it appears to ignore entries without a host name?

@mrose17
Copy link
Member

mrose17 commented Sep 19, 2017

try moving the console.log(tbl) to the second line of the callback, i.e.,

    if (!entry) return console.log(tbl);

does that help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants