示例#1
0
文件: peer.go 项目: rivasiv/gobgp
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
}
示例#2
0
文件: main.go 项目: 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
}
示例#3
0
文件: peer.go 项目: ttaanngg/gobgp
func NewLocalRib(owner string, rfList []bgp.RouteFamily, policyMap map[string]*policy.Policy) *LocalRib {
	return &LocalRib{
		rib: table.NewTableManager(owner, rfList),
	}
}
示例#4
0
文件: peer.go 项目: postfix/gobgp
func NewLocalRib(owner string, rfList []bgp.RouteFamily, minLabel, maxLabel uint32) *LocalRib {
	return &LocalRib{
		rib: table.NewTableManager(owner, rfList, minLabel, maxLabel),
	}
}