Example #1
0
func NewPeer(g config.Global, conf config.Neighbor) *Peer {
	peer := &Peer{
		gConf:    g,
		conf:     conf,
		rfMap:    make(map[bgp.RouteFamily]bool),
		capMap:   make(map[bgp.BGPCapabilityCode][]bgp.ParameterCapabilityInterface),
		outgoing: make(chan *bgp.BGPMessage, 128),
	}

	conf.NeighborState.SessionState = uint32(bgp.BGP_FSM_IDLE)
	conf.Timers.TimersState.Downtime = time.Now().Unix()
	for _, rf := range conf.AfiSafis.AfiSafiList {
		k, _ := bgp.GetRouteFamily(rf.AfiSafiName)
		peer.rfMap[k] = true
	}
	id := net.ParseIP(string(conf.RouteReflector.RouteReflectorConfig.RouteReflectorClusterId)).To4()
	peer.peerInfo = &table.PeerInfo{
		AS:                      conf.NeighborConfig.PeerAs,
		LocalAS:                 g.GlobalConfig.As,
		LocalID:                 g.GlobalConfig.RouterId,
		Address:                 conf.NeighborConfig.NeighborAddress,
		RouteReflectorClient:    peer.isRouteReflectorClient(),
		RouteReflectorClusterID: id,
	}
	peer.adjRib = table.NewAdjRib(peer.configuredRFlist())
	peer.fsm = NewFSM(&g, &conf)
	if peer.isRouteServerClient() {
		peer.localRib = table.NewTableManager(conf.NeighborConfig.NeighborAddress.String(), peer.configuredRFlist(), g.MplsLabelRange.MinLabel, g.MplsLabelRange.MaxLabel)
	}

	if conf.NeighborConfig.PeerAs != g.GlobalConfig.As {
		for _, member := range g.Confederation.ConfederationConfig.MemberAs {
			if member == conf.NeighborConfig.PeerAs {
				peer.isConfederationMember = true
				break
			}
		}
	}

	return peer
}
Example #2
0
File: main.go Project: hzhou8/gobgp
func newPeer(g config.Global, p config.Neighbor, incoming chan *server.FsmMsg) *server.Peer {
	tbl := table.NewTableManager(g.GlobalConfig.RouterId.String(), []bgp.RouteFamily{bgp.RF_IPv4_UC, bgp.RF_IPv6_UC}, 0, 0)
	peer := server.NewPeer(g, p, tbl)
	server.NewFSMHandler(peer.Fsm(), incoming, peer.Outgoing())
	return peer
}
Example #3
0
func NewLocalRib(owner string, rfList []bgp.RouteFamily, policyMap map[string]*policy.Policy) *LocalRib {
	return &LocalRib{
		rib: table.NewTableManager(owner, rfList),
	}
}
Example #4
0
func NewLocalRib(owner string, rfList []bgp.RouteFamily, minLabel, maxLabel uint32) *LocalRib {
	return &LocalRib{
		rib: table.NewTableManager(owner, rfList, minLabel, maxLabel),
	}
}