Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub getMacForIP {
- my $ip = shift;
- my $if = shift;
- my $struc = "SCCCCCCCCCCCCCCSCCCCCCCCCCCCCCiSCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC";
- my @x = split("", 0 x 62);
- $x[0] = $main::AF_INET;
- my $i = 0;
- foreach my $c (split(//, $if)) {
- $x[46+$i++] = ord($c)
- }
- $i = 0;
- foreach my $c (split(/\./, $ip)) {
- $x[3+$i++] = $c
- }
- my $arpreq = pack($struc, @x);
- return 0 unless (ioctl(SOCKET,$main::SIOCGARP,$arpreq));
- return join("", map { length($_) > 1 ? $_ : "0".$_ } map { sprintf("%X", $_) } ((unpack($struc, $arpreq))[16..21]));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement