diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-09-04 14:30:13 +0900 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-09-08 13:13:37 +0900 |
commit | d8dc45772cd1a384cb15917bea43cac5d2a04f10 (patch) | |
tree | 26a4f2eec14a791546d2bf254626286b6dbe1cd2 /server | |
parent | 9298e5eeca78e8bb02ff34b500add622b73b4f5f (diff) |
api: kill api.Capability
keep protobuf structures simple
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r-- | server/fsm.go | 3 | ||||
-rw-r--r-- | server/fsm_test.go | 2 | ||||
-rw-r--r-- | server/peer.go | 12 |
3 files changed, 9 insertions, 8 deletions
diff --git a/server/fsm.go b/server/fsm.go index c255c021..c9950a5d 100644 --- a/server/fsm.go +++ b/server/fsm.go @@ -391,8 +391,7 @@ func capabilitiesFromConfig(gConf *config.Global, pConf *config.Neighbor) []bgp. caps = append(caps, bgp.NewCapRouteRefresh()) for _, rf := range pConf.AfiSafis.AfiSafiList { k, _ := bgp.GetRouteFamily(rf.AfiSafiName) - afi, safi := bgp.RouteFamilyToAfiSafi(k) - caps = append(caps, bgp.NewCapMultiProtocol(afi, safi)) + caps = append(caps, bgp.NewCapMultiProtocol(k)) } caps = append(caps, bgp.NewCapFourOctetASNumber(gConf.GlobalConfig.As)) return caps diff --git a/server/fsm_test.go b/server/fsm_test.go index db9be4b3..72dfe05f 100644 --- a/server/fsm_test.go +++ b/server/fsm_test.go @@ -313,7 +313,7 @@ func open() *bgp.BGPMessage { p1 := bgp.NewOptionParameterCapability( []bgp.ParameterCapabilityInterface{bgp.NewCapRouteRefresh()}) p2 := bgp.NewOptionParameterCapability( - []bgp.ParameterCapabilityInterface{bgp.NewCapMultiProtocol(3, 4)}) + []bgp.ParameterCapabilityInterface{bgp.NewCapMultiProtocol(bgp.RF_IPv4_UC)}) g := bgp.CapGracefulRestartTuples{4, 2, 3} p3 := bgp.NewOptionParameterCapability( []bgp.ParameterCapabilityInterface{bgp.NewCapGracefulRestart(2, 100, diff --git a/server/peer.go b/server/peer.go index 67e2c437..45cb1c79 100644 --- a/server/peer.go +++ b/server/peer.go @@ -135,7 +135,7 @@ func (peer *Peer) handleBGPmessage(m *bgp.BGPMessage) ([]*table.Path, bool, []*b if c.Code() == bgp.BGP_CAP_MULTIPROTOCOL { m := c.(*bgp.CapMultiProtocol) - r[bgp.AfiSafiToRouteFamily(m.CapValue.AFI, m.CapValue.SAFI)] = true + r[m.CapValue] = true } } } @@ -246,17 +246,19 @@ func (peer *Peer) ToApiStruct() *api.Peer { f := peer.fsm c := f.pConf - remoteCap := make([]*api.Capability, 0, len(peer.capMap)) + remoteCap := make([][]byte, 0, len(peer.capMap)) for _, c := range peer.capMap { for _, m := range c { - remoteCap = append(remoteCap, m.ToApiStruct()) + buf, _ := m.Serialize() + remoteCap = append(remoteCap, buf) } } caps := capabilitiesFromConfig(&peer.gConf, &peer.conf) - localCap := make([]*api.Capability, 0, len(caps)) + localCap := make([][]byte, 0, len(caps)) for _, c := range caps { - localCap = append(localCap, c.ToApiStruct()) + buf, _ := c.Serialize() + localCap = append(localCap, buf) } conf := &api.PeerConf{ |