Newer
Older
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package config
import (
"fmt"
"github.com/bio-routing/bio-rd/protocols/isis/types"
)
type ISISConfig struct {
NETs []NET
Interfaces []ISISInterfaceConfig
TrafficEngineeringRouterID [4]byte
}
type ISISInterfaceConfig struct {
Name string
Passive bool
P2P bool
ISISLevel1Config *ISISLevelConfig
ISISLevel2Config *ISISLevelConfig
}
type ISISLevelConfig struct {
HelloInterval uint16
HoldTime uint16
Metric uint32
Priority uint8
}
// NET represents an ISO network entity title
type NET struct {
AFI byte
AreaID types.AreaID
SystemID types.SystemID
SEL byte
}
func parseNET(addr []byte) (*NET, error) {
l := len(addr)
if l < 8 {
return nil, fmt.Errorf("NET too short")
}
if l > 20 {
return nil, fmt.Errorf("NET too long")
}
areaID := []byte{}
for i := 0; i < l-8; i++ {
areaID = append(areaID, addr[i+1])
}
systemID := types.SystemID{
addr[l-7],
addr[l-6],
addr[l-5],
addr[l-4],
addr[l-3],
addr[l-2],
}
return &NET{
AFI: addr[0],
AreaID: areaID,
SystemID: systemID,
SEL: addr[l-1],
}, nil
}