diff options
author | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-18 20:19:01 -0800 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-12-18 20:19:01 -0800 |
commit | d7b9a40ba1fa2fb8d1aa9e0210bf117b6c88e996 (patch) | |
tree | e2e0ea342a605da3be60329a49c7970877284ab9 /server/peer.go | |
parent | d5a7a4569a5e6b55eda9c26ce70b846b643ebf50 (diff) |
peer: update local rib
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/peer.go')
-rw-r--r-- | server/peer.go | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/server/peer.go b/server/peer.go index f4e2d1f8..b24a1349 100644 --- a/server/peer.go +++ b/server/peer.go @@ -36,6 +36,9 @@ type Peer struct { outEventCh chan *message fsm *FSM adjRib *table.AdjRib + // peer and rib are always not one-to-one so should not be + // here but it's the simplest and works our first target. + rib *table.TableManager } func NewPeer(g config.GlobalType, peer config.NeighborType, outEventCh chan *message) *Peer { @@ -50,6 +53,7 @@ func NewPeer(g config.GlobalType, peer config.NeighborType, outEventCh chan *mes } p.fsm = NewFSM(&g, &peer, p.acceptedConnCh, p.incoming, p.outgoing) p.adjRib = table.NewAdjRib() + p.rib = table.NewTableManager() p.t.Go(p.loop) return p } @@ -71,8 +75,13 @@ func (peer *Peer) handleBGPmessage(m *bgp.BGPMessage) { peer.adjRib.UpdateIn(pathList) - for path := range pathList { - peer.sendToHub("", PEER_MSG_PATH, path) + peer.sendToHub("", PEER_MSG_PATH, pathList) +} + +func (peer *Peer) handlePeermessage(m *message) { + switch m.event { + case PEER_MSG_PATH: + pList, wList, _ := peer.rib.ProcessPaths(m.data.([]table.Path)) } } @@ -100,7 +109,7 @@ func (peer *Peer) loop() error { } peer.handleBGPmessage(m) case m := <-peer.inEventCh: - fmt.Println(m) + peer.handlePeermessage(m) } } } |