summaryrefslogtreecommitdiffhomepage
path: root/server/peer.go
diff options
context:
space:
mode:
authorWataru Ishida <ishida.wataru@lab.ntt.co.jp>2016-11-10 05:08:24 +0000
committerWataru Ishida <ishida.wataru@lab.ntt.co.jp>2016-11-14 02:15:35 +0000
commit926ab34220431de2561c17269d473f8fc8f33217 (patch)
tree1b3caab92f0a59adc3c8acebe4b8a31626ec8152 /server/peer.go
parentd23cea2d7c95b0d6683fbd80abcdb65e303816a4 (diff)
config: use struct type instead of []byte for capability and open msg
Signed-off-by: Wataru Ishida <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server/peer.go')
-rw-r--r--server/peer.go23
1 files changed, 9 insertions, 14 deletions
diff --git a/server/peer.go b/server/peer.go
index eaf1e4ac..e7fa290b 100644
--- a/server/peer.go
+++ b/server/peer.go
@@ -511,22 +511,17 @@ func (peer *Peer) ToConfig() *config.Neighbor {
conf.AfiSafis[i] = peer.fsm.pConf.AfiSafis[i]
}
- remoteCap := make([][]byte, 0, len(peer.fsm.capMap))
+ remoteCap := make([]bgp.ParameterCapabilityInterface, 0, len(peer.fsm.capMap))
for _, c := range peer.fsm.capMap {
for _, m := range c {
+ // need to copy all values here
buf, _ := m.Serialize()
- remoteCap = append(remoteCap, buf)
+ cap, _ := bgp.DecodeCapability(buf)
+ remoteCap = append(remoteCap, cap)
}
}
- conf.State.Capabilities.RemoteList = remoteCap
-
- caps := capabilitiesFromConfig(peer.fsm.pConf)
- localCap := make([][]byte, 0, len(caps))
- for _, c := range caps {
- buf, _ := c.Serialize()
- localCap = append(localCap, buf)
- }
- conf.State.Capabilities.LocalList = localCap
+ conf.State.RemoteCapabilityList = remoteCap
+ conf.State.LocalCapabilityList = capabilitiesFromConfig(peer.fsm.pConf)
conf.State.RemoteRouterId = peer.fsm.peerInfo.ID.To4().String()
conf.State.SessionState = config.IntToSessionStateMap[int(peer.fsm.state)]
@@ -541,9 +536,9 @@ func (peer *Peer) ToConfig() *config.Neighbor {
conf.Transport.State.LocalAddress, conf.Transport.State.LocalPort = peer.fsm.LocalHostPort()
_, conf.Transport.State.RemotePort = peer.fsm.RemoteHostPort()
-
- conf.State.ReceivedOpenMessage, _ = peer.fsm.recvOpen.Serialize()
-
+ buf, _ := peer.fsm.recvOpen.Serialize()
+ // need to copy all values here
+ conf.State.ReceivedOpenMessage, _ = bgp.ParseBGPMessage(buf)
}
return &conf
}