summaryrefslogtreecommitdiffhomepage
path: root/config/default.go
diff options
context:
space:
mode:
authorSatoshi Fujimoto <satoshi.fujimoto7@gmail.com>2017-12-12 15:02:16 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-12-16 22:10:33 +0900
commit1227aceb31af1bdc817ee4d89a72a7a7db874347 (patch)
treecb3e45dc0a594eb607c222a968ef45f4433d042a /config/default.go
parent61cdca78d7ee84ac2f0384f2096a42fa54acb6b7 (diff)
config: Move some functions to util.go
default.go and serve.go has some functions which are not directly related to its main role. This commit moves those functions to util.go, a more suitable place. Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Diffstat (limited to 'config/default.go')
-rw-r--r--config/default.go58
1 files changed, 0 insertions, 58 deletions
diff --git a/config/default.go b/config/default.go
index b586407c..c3fa4eb3 100644
--- a/config/default.go
+++ b/config/default.go
@@ -43,64 +43,6 @@ func defaultAfiSafi(typ AfiSafiType, enable bool) AfiSafi {
}
}
-// yaml is decoded as []interface{}
-// but toml is decoded as []map[string]interface{}.
-// currently, viper can't hide this difference.
-// handle the difference here.
-func extractArray(intf interface{}) ([]interface{}, error) {
- if intf != nil {
- list, ok := intf.([]interface{})
- if ok {
- return list, nil
- }
- l, ok := intf.([]map[string]interface{})
- if !ok {
- return nil, fmt.Errorf("invalid configuration: neither []interface{} nor []map[string]interface{}")
- }
- list = make([]interface{}, 0, len(l))
- for _, m := range l {
- list = append(list, m)
- }
- return list, nil
- }
- return nil, nil
-}
-
-func getIPv6LinkLocalAddress(ifname string) (string, error) {
- ifi, err := net.InterfaceByName(ifname)
- if err != nil {
- return "", err
- }
- addrs, err := ifi.Addrs()
- if err != nil {
- return "", err
- }
- for _, addr := range addrs {
- ip := addr.(*net.IPNet).IP
- if ip.To4() == nil && ip.IsLinkLocalUnicast() {
- return fmt.Sprintf("%s%%%s", ip.String(), ifname), nil
- }
- }
- return "", fmt.Errorf("no ipv6 link local address for %s", ifname)
-}
-
-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
-}
-
func SetDefaultNeighborConfigValues(n *Neighbor, pg *PeerGroup, g *Global) error {
// Determines this function is called against the same Neighbor struct,
// and if already called, returns immediately.