Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions arp.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package arp

import (
"time"
"errors"
)

type ArpTable map[string]string
Expand Down Expand Up @@ -47,3 +48,15 @@ func CacheUpdateCount() int {
func Search(ip string) string {
return arpCache.Search(ip)
}

// Search looks up the IP address by MAC address
// in the arp table
func SearchByMac(target string) (string, error) {
for ip, _ := range Table() {
m := Search(ip)
if(m == target) {
return ip, nil
}
}
return "", errors.New("Mac not found")
}