summaryrefslogtreecommitdiffhomepage
path: root/table/table_manager.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-22 23:03:59 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-22 23:03:59 +0900
commit6cffab405aaee92ba3f0b065be1f0ea9cc11cf9f (patch)
tree20fa2b6ea1acdbcf870fe939afa9f7773b7286eb /table/table_manager.go
parent3901b2e7be031ccc0ba8217113a0cf3ffeeac63a (diff)
table: add timestamp to Path
Set timestamp at Path when update message for the path arrived. Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table/table_manager.go')
-rw-r--r--table/table_manager.go25
1 files changed, 13 insertions, 12 deletions
diff --git a/table/table_manager.go b/table/table_manager.go
index 109cd004..375e7b2b 100644
--- a/table/table_manager.go
+++ b/table/table_manager.go
@@ -33,7 +33,7 @@ func NewProcessMessage(m *bgp.BGPMessage, peerInfo *PeerInfo) *ProcessMessage {
}
}
-func (p *ProcessMessage) nlri2Path() []Path {
+func (p *ProcessMessage) nlri2Path(now time.Time) []Path {
updateMsg := p.innerMessage.Body.(*bgp.BGPUpdate)
pathAttributes := updateMsg.PathAttributes
pathList := make([]Path, 0)
@@ -41,13 +41,13 @@ func (p *ProcessMessage) nlri2Path() []Path {
// define local variable to pass nlri's address to CreatePath
var nlri bgp.NLRInfo = nlri_info
// create Path object
- path := CreatePath(p.fromPeer, &nlri, pathAttributes, false)
+ path := CreatePath(p.fromPeer, &nlri, pathAttributes, false, now)
pathList = append(pathList, path)
}
return pathList
}
-func (p *ProcessMessage) withdraw2Path() []Path {
+func (p *ProcessMessage) withdraw2Path(now time.Time) []Path {
updateMsg := p.innerMessage.Body.(*bgp.BGPUpdate)
pathAttributes := updateMsg.PathAttributes
pathList := make([]Path, 0)
@@ -55,13 +55,13 @@ func (p *ProcessMessage) withdraw2Path() []Path {
// define local variable to pass nlri's address to CreatePath
var w bgp.WithdrawnRoute = nlriWithdraw
// create withdrawn Path object
- path := CreatePath(p.fromPeer, &w, pathAttributes, true)
+ path := CreatePath(p.fromPeer, &w, pathAttributes, true, now)
pathList = append(pathList, path)
}
return pathList
}
-func (p *ProcessMessage) mpreachNlri2Path() []Path {
+func (p *ProcessMessage) mpreachNlri2Path(now time.Time) []Path {
updateMsg := p.innerMessage.Body.(*bgp.BGPUpdate)
pathAttributes := updateMsg.PathAttributes
attrList := []*bgp.PathAttributeMpReachNLRI{}
@@ -78,14 +78,14 @@ func (p *ProcessMessage) mpreachNlri2Path() []Path {
for _, mp := range attrList {
nlri_info := mp.Value
for _, nlri := range nlri_info {
- path := CreatePath(p.fromPeer, nlri, pathAttributes, false)
+ path := CreatePath(p.fromPeer, nlri, pathAttributes, false, now)
pathList = append(pathList, path)
}
}
return pathList
}
-func (p *ProcessMessage) mpunreachNlri2Path() []Path {
+func (p *ProcessMessage) mpunreachNlri2Path(now time.Time) []Path {
updateMsg := p.innerMessage.Body.(*bgp.BGPUpdate)
pathAttributes := updateMsg.PathAttributes
attrList := []*bgp.PathAttributeMpUnreachNLRI{}
@@ -103,7 +103,7 @@ func (p *ProcessMessage) mpunreachNlri2Path() []Path {
nlri_info := mp.Value
for _, nlri := range nlri_info {
- path := CreatePath(p.fromPeer, nlri, pathAttributes, true)
+ path := CreatePath(p.fromPeer, nlri, pathAttributes, true, now)
pathList = append(pathList, path)
}
}
@@ -112,10 +112,11 @@ func (p *ProcessMessage) mpunreachNlri2Path() []Path {
func (p *ProcessMessage) ToPathList() []Path {
pathList := make([]Path, 0)
- pathList = append(pathList, p.nlri2Path()...)
- pathList = append(pathList, p.withdraw2Path()...)
- pathList = append(pathList, p.mpreachNlri2Path()...)
- pathList = append(pathList, p.mpunreachNlri2Path()...)
+ now := time.Now()
+ pathList = append(pathList, p.nlri2Path(now)...)
+ pathList = append(pathList, p.withdraw2Path(now)...)
+ pathList = append(pathList, p.mpreachNlri2Path(now)...)
+ pathList = append(pathList, p.mpunreachNlri2Path(now)...)
return pathList
}