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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package server
import (
"fmt"
"sync"
"testing"
"time"
"github.com/bio-routing/bio-rd/routingtable/filter"
"net"
"github.com/bio-routing/bio-rd/routingtable/locRIB"
)
func TestFSM(t *testing.T) {
fsmA := newFSM2(&peer{
addr: net.ParseIP("169.254.100.100"),
rib: locRIB.New(),
importFilter: filter.NewAcceptAllFilter(),
exportFilter: filter.NewAcceptAllFilter(),
})
fsmA.holdTimer = time.NewTimer(time.Second * 90)
fsmA.keepaliveTimer = time.NewTimer(time.Second * 30)
fsmA.connectRetryTimer = time.NewTimer(time.Second * 120)
fsmA.state = newEstablishedState(fsmA)
var wg sync.WaitGroup
wg.Add(1)
go func() {
fsmA.con = fakeConn{}
for {
nextState, reason := fsmA.state.run()
fsmA.state = nextState
stateName := stateName(nextState)
fmt.Printf("New state: %s\n", stateName)
switch stateName {
case "idle":
wg.Done()
return
case "cease":
t.Errorf("Unexpected cease state: %s", reason)
wg.Done()
return
case "established":
continue
default:
t.Errorf("Unexpected new state: %s", reason)
wg.Done()
return
}
}
}()
for i := uint8(0); i < 255; i++ {
fsmA.msgRecvCh <- []byte{
255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
0, 53,
2,
0, 0,
0, 26,
64, // Attribute flags
1, // Attribute Type code (ORIGIN)
1, // Length
2, // INCOMPLETE
64, // Attribute flags
2, // Attribute Type code (AS Path)
12, // Length
2, // Type = AS_SEQUENCE
2, // Path Segement Length
59, 65, // AS15169
12, 248, // AS3320
1, // Type = AS_SET
2, // Path Segement Length
59, 65, // AS15169
12, 248, // AS3320
0, // Attribute flags
3, // Attribute Type code (Next Hop)
4, // Length
10, 11, 12, 13, // Next Hop
24, 169, 254, i,
}
}
fmt.Printf("Route count in RIB: %d\n", fsmA.rib.RouteCount())
fmt.Printf("Stopping FSM\n")
fsmA.eventCh <- ManualStop
fmt.Printf("WAINTING\n")
wg.Wait()
}