summaryrefslogtreecommitdiffhomepage
path: root/server/peer.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-12-21 18:44:06 -0800
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-12-21 18:44:06 -0800
commit73d7ec4471158abd320c056dc28ed76708f6ba65 (patch)
tree4b6c916b26e97fa72e200f592a375b98b6b58c82 /server/peer.go
parent704135410381e69e2f39fea84cd029b65148da01 (diff)
server: conver PEER_MSG_PATH to bgp update
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'server/peer.go')
-rw-r--r--server/peer.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/server/peer.go b/server/peer.go
index 8439e7f5..ab80e9bf 100644
--- a/server/peer.go
+++ b/server/peer.go
@@ -82,7 +82,27 @@ func (peer *Peer) handlePeermessage(m *message) {
switch m.event {
case PEER_MSG_PATH:
pList, wList, _ := peer.rib.ProcessPaths(m.data.([]table.Path))
- fmt.Println(pList, wList)
+ // TODO: merge multiple messages
+ // TODO: 4bytes and 2bytes conversion.
+
+ msgs := make([]*bgp.BGPMessage, 0)
+ for _, p := range pList {
+ pathAttrs := p.GetPathAttrs()
+ nlri := p.GetNlri().(*bgp.NLRInfo)
+ m := bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{}, pathAttrs, []bgp.NLRInfo{*nlri})
+ msgs = append(msgs, m)
+ }
+
+ for _, dest := range wList {
+ p := dest.GetOldBestPath()
+ draw := p.GetNlri().(*bgp.WithdrawnRoute)
+ m := bgp.NewBGPUpdateMessage([]bgp.WithdrawnRoute{*draw}, []bgp.PathAttributeInterface{}, []bgp.NLRInfo{})
+ msgs = append(msgs, m)
+ }
+
+ for _, m := range msgs {
+ peer.outgoing <- m
+ }
}
}