From eff70c21375742b44ae5ebfd845dba38d0f3fcfc Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Sat, 27 Dec 2014 06:26:18 -0800 Subject: support IPv6_UC route family Signed-off-by: FUJITA Tomonori --- server/fsm.go | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'server/fsm.go') diff --git a/server/fsm.go b/server/fsm.go index 849d8169..76ed85a6 100644 --- a/server/fsm.go +++ b/server/fsm.go @@ -110,11 +110,19 @@ func (fsm *FSM) PeerInfoGet() *table.PeerInfo { } func (fsm *FSM) createPeerInfo() { + var rf table.RouteFamily + if fsm.peerConfig.NeighborAddress.To4() != nil { + rf = table.RF_IPv4_UC + } else { + rf = table.RF_IPv6_UC + } + fsm.peerInfo = &table.PeerInfo{ AS: fsm.peerConfig.PeerAs, ID: fsm.routerId, VersionNum: fsm.sourceVerNum, LocalID: fsm.globalConfig.RouterId, + RF: rf, } } @@ -168,14 +176,20 @@ func (h *FSMHandler) active() bgp.FSMState { return bgp.BGP_FSM_OPENSENT } -func buildopen(global *config.GlobalType, neighborT *config.NeighborType) *bgp.BGPMessage { +func buildopen(global *config.GlobalType, peerConf *config.NeighborType) *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(bgp.AFI_IP, bgp.SAFI_UNICAST)}) + []bgp.ParameterCapabilityInterface{bgp.NewCapMultiProtocol(uint16(afi), bgp.SAFI_UNICAST)}) p3 := bgp.NewOptionParameterCapability( []bgp.ParameterCapabilityInterface{bgp.NewCapFourOctetASNumber(global.As)}) - holdTime := uint16(neighborT.Timers.HoldTime) + holdTime := uint16(peerConf.Timers.HoldTime) as := global.As if as > (1<<16)-1 { as = bgp.AS_TRANS -- cgit v1.2.3