Esempio n. 1
0
func NewFSM(gConf *config.Global, pConf *config.Neighbor, policy *table.RoutingPolicy) *FSM {
	adminState := ADMIN_STATE_UP
	if pConf.Config.AdminDown {
		adminState = ADMIN_STATE_DOWN
	}
	pConf.State.SessionState = config.IntToSessionStateMap[int(bgp.BGP_FSM_IDLE)]
	pConf.Timers.State.Downtime = time.Now().Unix()
	fsmVersion++
	fsm := &FSM{
		gConf:                gConf,
		pConf:                pConf,
		state:                bgp.BGP_FSM_IDLE,
		connCh:               make(chan net.Conn, 1),
		opensentHoldTime:     float64(HOLDTIME_OPENSENT),
		adminState:           adminState,
		adminStateCh:         make(chan AdminState, 1),
		getActiveCh:          make(chan struct{}),
		rfMap:                make(map[bgp.RouteFamily]bool),
		capMap:               make(map[bgp.BGPCapabilityCode][]bgp.ParameterCapabilityInterface),
		peerInfo:             table.NewPeerInfo(gConf, pConf),
		policy:               policy,
		gracefulRestartTimer: time.NewTimer(time.Hour),
		version:              fsmVersion,
	}
	fsm.gracefulRestartTimer.Stop()
	fsm.t.Go(fsm.connectLoop)
	return fsm
}
Esempio n. 2
0
func NewFSM(gConf *config.Global, pConf *config.Neighbor, peer *Peer) *FSM {
	adminState := ADMIN_STATE_UP
	if pConf.NeighborState.AdminDown == true {
		adminState = ADMIN_STATE_DOWN
	}
	fsm := &FSM{
		gConf:            gConf,
		pConf:            pConf,
		state:            bgp.BGP_FSM_IDLE,
		connCh:           make(chan net.Conn, 1),
		opensentHoldTime: float64(HOLDTIME_OPENSENT),
		adminState:       adminState,
		adminStateCh:     make(chan AdminState, 1),
		getActiveCh:      make(chan struct{}),
		rfMap:            make(map[bgp.RouteFamily]bool),
		confedCheck:      !config.IsConfederationMember(gConf, pConf) && config.IsEBGPPeer(gConf, pConf),
		peerInfo:         table.NewPeerInfo(gConf, pConf),
		peer:             peer,
	}
	fsm.t.Go(fsm.connectLoop)
	return fsm
}
Esempio n. 3
0
File: fsm.go Progetto: taijiji/gobgp
func NewFSM(gConf *config.Global, pConf *config.Neighbor, policy *table.RoutingPolicy) *FSM {
	adminState := ADMIN_STATE_UP
	if pConf.State.AdminDown {
		adminState = ADMIN_STATE_DOWN
	}
	fsm := &FSM{
		gConf:            gConf,
		pConf:            pConf,
		state:            bgp.BGP_FSM_IDLE,
		connCh:           make(chan net.Conn, 1),
		opensentHoldTime: float64(HOLDTIME_OPENSENT),
		adminState:       adminState,
		adminStateCh:     make(chan AdminState, 1),
		getActiveCh:      make(chan struct{}),
		rfMap:            make(map[bgp.RouteFamily]bool),
		capMap:           make(map[bgp.BGPCapabilityCode][]bgp.ParameterCapabilityInterface),
		peerInfo:         table.NewPeerInfo(gConf, pConf),
		policy:           policy,
	}
	fsm.t.Go(fsm.connectLoop)
	return fsm
}