blob: dcb1b7eda19b6497a396e0a90f4b401efc2ffcfe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
package config
import (
"github.com/BurntSushi/toml"
"strings"
)
const (
DEFAULT_HOLDTIME = 90
DEFAULT_IDLE_HOLDTIME_AFTER_RESET = 30
)
type neighbor struct {
attributes map[string]bool
}
func SetDefaultConfigValues(md toml.MetaData, bt *BgpType) {
neighbors := []neighbor{}
nidx := 0
for _, key := range md.Keys() {
if !strings.HasPrefix(key.String(), "NeighborList") {
continue
}
if key.String() == "NeighborList" {
neighbors = append(neighbors, neighbor{attributes: make(map[string]bool)})
nidx++
} else {
neighbors[nidx-1].attributes[key.String()] = true
}
}
for i, n := range neighbors {
if _, ok := n.attributes["NeighborList.Timers.HoldTime"]; !ok {
bt.NeighborList[i].Timers.HoldTime = float64(DEFAULT_HOLDTIME)
}
if _, ok := n.attributes["NeighborList.Timers.KeepaliveInterval"]; !ok {
bt.NeighborList[i].Timers.KeepaliveInterval = bt.NeighborList[i].Timers.HoldTime / 3
}
if _, ok := n.attributes["NeighborList.Timers.IdleHoldTImeAfterReset"]; !ok {
bt.NeighborList[i].Timers.IdleHoldTImeAfterReset = float64(DEFAULT_IDLE_HOLDTIME_AFTER_RESET)
}
}
}
|