From 1c982d8336c9d89732e8a481a8c90b3e7e283f6f Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Sun, 8 Mar 2015 15:13:07 +0900 Subject: server: support multiple route familes per peer You can configure like the following: [Global] As = 65032 RouterId = "192.168.255.1" [[NeighborList]] NeighborAddress = "10.0.255.1" PeerAs = 65001 [NeighborList.RouteServer] RouteServerClient = true [[NeighborList.AfiSafiList]] AfiSafiName = "ipv4-unicast" [[NeighborList.AfiSafiList]] AfiSafiName = "ipv6-unicast" Signed-off-by: FUJITA Tomonori --- server/fsm.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'server/fsm.go') diff --git a/server/fsm.go b/server/fsm.go index 94bfc85d..f519e984 100644 --- a/server/fsm.go +++ b/server/fsm.go @@ -288,16 +288,15 @@ func (h *FSMHandler) active() bgp.FSMState { } func buildopen(global *config.Global, peerConf *config.Neighbor) *bgp.BGPMessage { - var afi int - if peerConf.NeighborAddress.To4() != nil { - afi = bgp.AFI_IP - } else { - afi = bgp.AFI_IP6 - } p1 := bgp.NewOptionParameterCapability( []bgp.ParameterCapabilityInterface{bgp.NewCapRouteRefresh()}) - p2 := bgp.NewOptionParameterCapability( - []bgp.ParameterCapabilityInterface{bgp.NewCapMultiProtocol(uint16(afi), bgp.SAFI_UNICAST)}) + c := []bgp.ParameterCapabilityInterface{} + for _, rf := range peerConf.AfiSafiList { + k, _ := bgp.GetRouteFamily(rf.AfiSafiName) + afi, safi := bgp.RouteFamilyToAfiSafi(k) + c = append(c, bgp.NewCapMultiProtocol(afi, safi)) + } + p2 := bgp.NewOptionParameterCapability(c) p3 := bgp.NewOptionParameterCapability( []bgp.ParameterCapabilityInterface{bgp.NewCapFourOctetASNumber(global.As)}) holdTime := uint16(peerConf.Timers.HoldTime) -- cgit v1.2.3