diff options
Diffstat (limited to 'config')
-rw-r--r-- | config/default_linux.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/config/default_linux.go b/config/default_linux.go index f83b76fe..8cfcc501 100644 --- a/config/default_linux.go +++ b/config/default_linux.go @@ -53,3 +53,20 @@ func GetIPv6LinkLocalNeighborAddress(ifname string) (string, error) { return fmt.Sprintf("%s%%%s", addr, ifname), nil } + +func isLocalLinkLocalAddress(ifindex int, addr net.IP) (bool, error) { + ifi, err := net.InterfaceByIndex(ifindex) + if err != nil { + return false, err + } + addrs, err := ifi.Addrs() + if err != nil { + return false, err + } + for _, a := range addrs { + if ip, _, _ := net.ParseCIDR(a.String()); addr.Equal(ip) { + return true, nil + } + } + return false, nil +} |