fsm

package
v0.0.0-...-ac9ef1f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2017 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

conn.go

fsm.go

peer.go

Index

Constants

View Source
const (
	BGPCmdReasonNone int = iota
	BGPCmdReasonMaxPrefixExceeded
)
View Source
const BGPIdleHoldTimeDefault uint16 = 5 // 240 seconds
View Source
const BGPRestartTimeDefault uint32 = 1 // 240 seconds

Variables

View Source
var BGPEventTypeToStr = map[BGPFSMEvent]string{
	BGPEventManualStart:                     "ManualStart",
	BGPEventManualStop:                      "ManualStop",
	BGPEventAutoStart:                       "AutoStart",
	BGPEventManualStartPassTcpEst:           "ManualStartPassTcpEst",
	BGPEventAutoStartPassTcpEst:             "AutoStartPassTcpEst",
	BGPEventAutoStartDampPeerOscl:           "AutoStartDampPeerOscl",
	BGPEventAutoStartDampPeerOsclPassTcpEst: "AutoStartDampPeerOsclPassTcpEst",
	BGPEventAutoStop:                        "AutoStop",
	BGPEventConnRetryTimerExp:               "ConnRetryTimerExp",
	BGPEventHoldTimerExp:                    "HoldTimerExp",
	BGPEventKeepAliveTimerExp:               "KeepAliveTimerExp",
	BGPEventDelayOpenTimerExp:               "DelayOpenTimerExp",
	BGPEventIdleHoldTimerExp:                "IdleHoldTimerExp",
	BGPEventTcpConnValid:                    "TcpConnValid",
	BGPEventTcpCrInvalid:                    "TcpCrInvalid",
	BGPEventTcpCrAcked:                      "TcpCrAcked",
	BGPEventTcpConnConfirmed:                "TcpConnConfirmed",
	BGPEventTcpConnFails:                    "TcpConnFails",
	BGPEventBGPOpen:                         "BGPOpen",
	BGPEventBGPOpenDelayOpenTimer:           "BGPOpenDelayOpenTimer",
	BGPEventHeaderErr:                       "HeaderErr",
	BGPEventOpenMsgErr:                      "OpenMsgErr",
	BGPEventOpenCollisionDump:               "OpenCollisionDump",
	BGPEventNotifMsgVerErr:                  "NotifMsgVerErr",
	BGPEventNotifMsg:                        "NotifMsg",
	BGPEventKeepAliveMsg:                    "KeepAliveMsg",
	BGPEventUpdateMsg:                       "UpdateMsg",
	BGPEventUpdateMsgErr:                    "UpdateMsgErr",
}
View Source
var IdleHoldTimeInterval = map[uint16]uint16{
	0:   0,
	5:   10,
	10:  30,
	60:  120,
	120: 180,
	180: 300,
	300: 500,
	500: 0,
}

Functions

This section is empty.

Types

type ActiveState

type ActiveState struct {
	BaseState
}

func NewActiveState

func NewActiveState(fsm *FSM) *ActiveState

func (*ActiveState) String

func (st *ActiveState) String() string

type BGPFSMEvent

type BGPFSMEvent int
const (
	BGPEventManualStart BGPFSMEvent
	BGPEventManualStop
	BGPEventAutoStart
	BGPEventManualStartPassTcpEst
	BGPEventAutoStartPassTcpEst
	BGPEventAutoStartDampPeerOscl
	BGPEventAutoStartDampPeerOsclPassTcpEst
	BGPEventAutoStop
	BGPEventConnRetryTimerExp
	BGPEventHoldTimerExp
	BGPEventKeepAliveTimerExp
	BGPEventDelayOpenTimerExp
	BGPEventIdleHoldTimerExp
	BGPEventTcpConnValid
	BGPEventTcpCrInvalid
	BGPEventTcpCrAcked
	BGPEventTcpConnConfirmed
	BGPEventTcpConnFails
	BGPEventBGPOpen
	BGPEventBGPOpenDelayOpenTimer
	BGPEventHeaderErr
	BGPEventOpenMsgErr
	BGPEventOpenCollisionDump
	BGPEventNotifMsgVerErr
	BGPEventNotifMsg
	BGPEventKeepAliveMsg
	BGPEventUpdateMsg
	BGPEventUpdateMsgErr
)

type BaseState

type BaseState struct {
	// contains filtered or unexported fields
}

func NewBaseState

func NewBaseState(fsm *FSM) BaseState

type BaseStateIface

type BaseStateIface interface {
	String() string
	// contains filtered or unexported methods
}

type ConnectState

type ConnectState struct {
	BaseState
}

func NewConnectState

func NewConnectState(fsm *FSM) *ConnectState

func (*ConnectState) String

func (st *ConnectState) String() string

type EstablishedState

type EstablishedState struct {
	BaseState
}

func NewEstablishedState

func NewEstablishedState(fsm *FSM) *EstablishedState

func (*EstablishedState) String

func (st *EstablishedState) String() string

type FSM

type FSM struct {
	Manager *FSMManager
	State   BaseStateIface
	// contains filtered or unexported fields
}

func NewFSM

func NewFSM(fsmManager *FSMManager, id uint8, neighborConf *base.NeighborConf) *FSM

func (*FSM) AcceptPeerConn

func (fsm *FSM) AcceptPeerConn()

func (*FSM) ApplyAutomaticStart

func (fsm *FSM) ApplyAutomaticStart()

func (*FSM) ChangeState

func (fsm *FSM) ChangeState(newState BaseStateIface)

func (*FSM) ClearPeerConn

func (fsm *FSM) ClearPeerConn()

func (*FSM) ConnBroken

func (fsm *FSM) ConnBroken()

func (*FSM) ConnEstablished

func (fsm *FSM) ConnEstablished()

func (*FSM) GetIdleHoldTime

func (fsm *FSM) GetIdleHoldTime() uint16

func (*FSM) HandleAnotherConnection

func (fsm *FSM) HandleAnotherConnection(data interface{})

func (*FSM) IncrConnectRetryCounter

func (fsm *FSM) IncrConnectRetryCounter()

func (*FSM) Init

func (fsm *FSM) Init(state BaseStateIface)

func (*FSM) InitiateConnToPeer

func (fsm *FSM) InitiateConnToPeer()

func (*FSM) ProcessEvent

func (fsm *FSM) ProcessEvent(event BGPFSMEvent, data interface{})

func (*FSM) ProcessOpenMessage

func (fsm *FSM) ProcessOpenMessage(pkt *packet.BGPMessage) bool

func (*FSM) ProcessPacket

func (fsm *FSM) ProcessPacket(msg *packet.BGPMessage, msgErr *packet.BGPMessageError)

func (*FSM) ProcessUpdateMessage

func (fsm *FSM) ProcessUpdateMessage(pkt *packet.BGPMessage)

func (*FSM) RejectPeerConn

func (fsm *FSM) RejectPeerConn()

func (*FSM) SendNotificationMessage

func (fsm *FSM) SendNotificationMessage(code uint8, subCode uint8, data []byte)

func (*FSM) SetConnectRetryCounter

func (fsm *FSM) SetConnectRetryCounter(value int)

func (*FSM) SetHoldTime

func (fsm *FSM) SetHoldTime(holdTime uint32, keepaliveTime uint32)

func (*FSM) SetIdleHoldTime

func (fsm *FSM) SetIdleHoldTime(seconds uint16)

func (*FSM) SetPassiveTcpEstablishment

func (fsm *FSM) SetPassiveTcpEstablishment(flag bool)

func (*FSM) SetPeerConn

func (fsm *FSM) SetPeerConn(data interface{})

func (*FSM) StartConnectRetryTimer

func (fsm *FSM) StartConnectRetryTimer()

func (*FSM) StartFSM

func (fsm *FSM) StartFSM()

func (*FSM) StartHoldTimer

func (fsm *FSM) StartHoldTimer()

func (*FSM) StartIdleHoldTimer

func (fsm *FSM) StartIdleHoldTimer()

func (*FSM) StartKeepAliveTimer

func (fsm *FSM) StartKeepAliveTimer()

func (*FSM) StartRestartTimer

func (fsm *FSM) StartRestartTimer()

func (*FSM) StopConnToPeer

func (fsm *FSM) StopConnToPeer()

func (*FSM) StopConnectRetryTimer

func (fsm *FSM) StopConnectRetryTimer()

func (*FSM) StopHoldTimer

func (fsm *FSM) StopHoldTimer()

func (*FSM) StopIdleHoldTimer

func (fsm *FSM) StopIdleHoldTimer()

func (*FSM) StopKeepAliveTimer

func (fsm *FSM) StopKeepAliveTimer()

func (*FSM) StopRestartTimer

func (fsm *FSM) StopRestartTimer()

type FSMIface

type FSMIface interface {
	StartFSM(state BaseStateIface)
	ProcessEvent(event BGPFSMEvent)
	ChangeState(state BaseStateIface)
}

type FSMManager

type FSMManager struct {
	AcceptCh chan net.Conn

	CloseCh   chan bool
	StopFSMCh chan string

	CommandCh   chan PeerFSMCommand
	BfdStatusCh chan bool
	// contains filtered or unexported fields
}

func NewFSMManager

func NewFSMManager(logger *logging.Writer, neighborConf *base.NeighborConf, bgpPktSrcCh chan *packet.BGPPktSrc,
	fsmConnCh chan PeerFSMConn, reachabilityCh chan config.ReachabilityInfo) *FSMManager

func (*FSMManager) AcceptPeerConn

func (mgr *FSMManager) AcceptPeerConn()

func (*FSMManager) Cleanup

func (mgr *FSMManager) Cleanup()

func (*FSMManager) Init

func (mgr *FSMManager) Init()

func (*FSMManager) RejectPeerConn

func (mgr *FSMManager) RejectPeerConn()

func (*FSMManager) SendUpdateMsg

func (mgr *FSMManager) SendUpdateMsg(bgpMsg *packet.BGPMessage)

func (*FSMManager) StopFSM

func (mgr *FSMManager) StopFSM(stopMsg string)

type IdleState

type IdleState struct {
	BaseState
	// contains filtered or unexported fields
}

func NewIdleState

func NewIdleState(fsm *FSM) *IdleState

func (*IdleState) String

func (st *IdleState) String() string

type OpenConfirmState

type OpenConfirmState struct {
	BaseState
}

func NewOpenConfirmState

func NewOpenConfirmState(fsm *FSM) *OpenConfirmState

func (*OpenConfirmState) String

func (st *OpenConfirmState) String() string

type OpenSentState

type OpenSentState struct {
	BaseState
}

func NewOpenSentState

func NewOpenSentState(fsm *FSM) *OpenSentState

func (*OpenSentState) String

func (st *OpenSentState) String() string

type OutTCPConn

type OutTCPConn struct {
	StopConnCh chan bool
	// contains filtered or unexported fields
}

func NewOutTCPConn

func NewOutTCPConn(fsm *FSM, fsmConnCh chan net.Conn, fsmConnErrCh chan PeerConnErr) *OutTCPConn

func (*OutTCPConn) Connect

func (o *OutTCPConn) Connect(seconds uint32, remote, local string, connCh chan net.Conn, errCh chan error)

func (*OutTCPConn) ConnectToPeer

func (o *OutTCPConn) ConnectToPeer(seconds uint32, remote, local string)

type PeerAttrs

type PeerAttrs struct {
	PeerIP        string
	BGPId         net.IP
	ASSize        uint8
	HoldTime      uint32
	KeepaliveTime uint32
	AddPathFamily map[packet.AFI]map[packet.SAFI]uint8
}

type PeerConn

type PeerConn struct {
	// contains filtered or unexported fields
}

func NewPeerConn

func NewPeerConn(fsm *FSM, dir config.ConnDir, conn *net.Conn, id uint32) *PeerConn

func (*PeerConn) DecodeMessage

func (p *PeerConn) DecodeMessage(header *packet.BGPHeader, buf []byte) (*packet.BGPMessage, *packet.BGPMessageError,
	bool)

func (*PeerConn) ReadPkt

func (p *PeerConn) ReadPkt(doneCh chan bool, stopCh chan bool, exitCh chan bool)

func (*PeerConn) StartReading

func (p *PeerConn) StartReading()

func (*PeerConn) StopReading

func (p *PeerConn) StopReading(exitCh chan bool)

type PeerConnDir

type PeerConnDir struct {
	// contains filtered or unexported fields
}

type PeerConnErr

type PeerConnErr struct {
	// contains filtered or unexported fields
}

type PeerFSMCommand

type PeerFSMCommand struct {
	Command int
	Reason  int
}

type PeerFSMConn

type PeerFSMConn struct {
	PeerIP      string
	Established bool
	Conn        *net.Conn
}

type PeerFSMConnState

type PeerFSMConnState struct {
	// contains filtered or unexported fields
}

type PeerFSMEvent

type PeerFSMEvent struct {
	// contains filtered or unexported fields
}

type PeerFSMState

type PeerFSMState struct {
	PeerIP string
	State  config.BGPFSMState
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL