summaryrefslogtreecommitdiffhomepage
path: root/server/fsm.go
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-04-29 17:49:51 +0000
committerISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2015-05-10 04:26:48 +0000
commit23d1d4322199bbaae52c52aa0db8db9b000944fe (patch)
tree64ad12096d8bfcdd2bce990f02e1f42f542f11bc /server/fsm.go
parent7cbb6bbd32ad37ceae89c23bc79ff9cf5fe6a01d (diff)
api/gobgp: show multiprotocol capabilities in detail
/home/vagrant% gobgp -u 192.168.10.4 neighbor 192.168.10.2 BGP neighbor is 192.168.10.2, remote AS 65001 BGP version 4, remote router ID 192.168.10.2 BGP state = BGP_FSM_ESTABLISHED, up for 00:12:57 BGP OutQ = 0, Flops = 0 Neighbor capabilities: MULTIPROTOCOL(IP,UNICAST): advertised MULTIPROTOCOL(L2VPN,EVPN): advertised MULTIPROTOCOL(IP,ENCAP): advertised MULTIPROTOCOL(IP,ROUTE_TARGET_CONSTRTAINS): received ROUTE_REFRESH: advertised FOUR_OCTET_AS_NUMBER: advertised and received Message statistics: Sent Rcvd Opens: 1 1 Notifications: 0 0 Updates: 0 0 Keepalives: 26 26 Route Refesh: 0 0 Discarded: 0 0 Total: 27 27 Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server/fsm.go')
-rw-r--r--server/fsm.go21
1 files changed, 12 insertions, 9 deletions
diff --git a/server/fsm.go b/server/fsm.go
index 53cfc55c..fc7cded9 100644
--- a/server/fsm.go
+++ b/server/fsm.go
@@ -300,25 +300,28 @@ func (h *FSMHandler) active() bgp.FSMState {
}
}
-func buildopen(global *config.Global, peerConf *config.Neighbor) *bgp.BGPMessage {
- p1 := bgp.NewOptionParameterCapability(
- []bgp.ParameterCapabilityInterface{bgp.NewCapRouteRefresh()})
- c := []bgp.ParameterCapabilityInterface{}
+func capabilitiesFromConfig(global *config.Global, peerConf *config.Neighbor) []bgp.ParameterCapabilityInterface {
+ caps := make([]bgp.ParameterCapabilityInterface, 0, 4)
+ caps = append(caps, bgp.NewCapRouteRefresh())
for _, rf := range peerConf.AfiSafiList {
k, _ := bgp.GetRouteFamily(rf.AfiSafiName)
afi, safi := bgp.RouteFamilyToAfiSafi(k)
- c = append(c, bgp.NewCapMultiProtocol(afi, safi))
+ caps = append(caps, bgp.NewCapMultiProtocol(afi, safi))
}
- p2 := bgp.NewOptionParameterCapability(c)
- p3 := bgp.NewOptionParameterCapability(
- []bgp.ParameterCapabilityInterface{bgp.NewCapFourOctetASNumber(global.As)})
+ caps = append(caps, bgp.NewCapFourOctetASNumber(global.As))
+ return caps
+}
+
+func buildopen(global *config.Global, peerConf *config.Neighbor) *bgp.BGPMessage {
+ caps := capabilitiesFromConfig(global, peerConf)
+ opt := bgp.NewOptionParameterCapability(caps)
holdTime := uint16(peerConf.Timers.HoldTime)
as := global.As
if as > (1<<16)-1 {
as = bgp.AS_TRANS
}
return bgp.NewBGPOpenMessage(uint16(as), holdTime, global.RouterId.String(),
- []bgp.OptionParameterInterface{p1, p2, p3})
+ []bgp.OptionParameterInterface{opt})
}
func readAll(conn net.Conn, length int) ([]byte, error) {