diff --git a/arp.go b/arp.go index a4958ec..0dadd8d 100644 --- a/arp.go +++ b/arp.go @@ -2,6 +2,7 @@ package arp import ( "time" + "errors" ) type ArpTable map[string]string @@ -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") +}