diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-23 05:20:31 -0800 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-23 05:20:31 -0800 |
commit | f33719f78de63f9b51d10605e99d72222410e60d (patch) | |
tree | ef668c9187abe3f36042d01d3f12321e799054a3 /server/peer.go | |
parent | cb48c082ed63590c42ff27315e583649027241e1 (diff) |
packet: define FSMState
Then we can use stringer nicely. Now FSMstate shows nicely like:
DEBU[0081] Peer (10.0.0.1) state changed from BGP_FSM_ACTIVE to BGP_FSM_OPENSENT
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/peer.go')
-rw-r--r-- | server/peer.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/server/peer.go b/server/peer.go index a28e94b6..45fc1cf5 100644 --- a/server/peer.go +++ b/server/peer.go @@ -29,7 +29,6 @@ type Peer struct { t tomb.Tomb globalConfig config.GlobalType peerConfig config.NeighborType - state int acceptedConnCh chan *net.TCPConn incoming chan *bgp.BGPMessage outgoing chan *bgp.BGPMessage @@ -46,7 +45,6 @@ func NewPeer(g config.GlobalType, peer config.NeighborType, outEventCh chan *mes p := &Peer{ globalConfig: g, peerConfig: peer, - state: bgp.BGP_FSM_IDLE, acceptedConnCh: make(chan *net.TCPConn), incoming: make(chan *bgp.BGPMessage, 4096), outgoing: make(chan *bgp.BGPMessage, 4096), @@ -54,6 +52,7 @@ func NewPeer(g config.GlobalType, peer config.NeighborType, outEventCh chan *mes outEventCh: outEventCh, } p.fsm = NewFSM(&g, &peer, p.acceptedConnCh, p.incoming, p.outgoing) + peer.BgpNeighborCommonState.State = uint32(bgp.BGP_FSM_IDLE) p.adjRib = table.NewAdjRib() p.rib = table.NewTableManager() p.t.Go(p.loop) @@ -136,8 +135,8 @@ func (peer *Peer) loop() error { case nextState := <-peer.fsm.StateChanged(): // waits for all goroutines created for the current state h.Wait() - oldState := peer.state - peer.state = nextState + oldState := bgp.FSMState(peer.peerConfig.BgpNeighborCommonState.State) + peer.peerConfig.BgpNeighborCommonState.State = uint32(nextState) peer.fsm.StateChange(nextState) sameState = false // TODO: check peer's rf |