Skip to content
Snippets Groups Projects
Commit f68bcee1 authored by Oliver Herms's avatar Oliver Herms
Browse files

Renaming FSM2 to FSM

parent 3536eaee
No related branches found
No related tags found
No related merge requests found
......@@ -26,8 +26,8 @@ type state interface {
run() (state, string)
}
// FSM2 implements the BGP finite state machine (RFC4271)
type FSM2 struct {
// FSM implements the BGP finite state machine (RFC4271)
type FSM struct {
peer *Peer
eventCh chan int
con net.Conn
......@@ -72,7 +72,7 @@ type FSM2 struct {
}
// NewPassiveFSM2 initiates a new passive FSM
func NewPassiveFSM2(peer *Peer, con *net.TCPConn) *FSM2 {
func NewPassiveFSM2(peer *Peer, con *net.TCPConn) *FSM {
fsm := newFSM2(peer)
fsm.con = con
fsm.state = newIdleState(fsm)
......@@ -80,15 +80,15 @@ func NewPassiveFSM2(peer *Peer, con *net.TCPConn) *FSM2 {
}
// NewActiveFSM2 initiates a new passive FSM
func NewActiveFSM2(peer *Peer) *FSM2 {
func NewActiveFSM2(peer *Peer) *FSM {
fsm := newFSM2(peer)
fsm.active = true
fsm.state = newIdleState(fsm)
return fsm
}
func newFSM2(peer *Peer) *FSM2 {
return &FSM2{
func newFSM2(peer *Peer) *FSM {
return &FSM{
connectRetryTime: time.Minute,
peer: peer,
eventCh: make(chan int),
......@@ -102,17 +102,17 @@ func newFSM2(peer *Peer) *FSM2 {
}
}
func (fsm *FSM2) start() {
func (fsm *FSM) start() {
go fsm.run()
go fsm.tcpConnector()
return
}
func (fsm *FSM2) activate() {
func (fsm *FSM) activate() {
fsm.eventCh <- AutomaticStart
}
func (fsm *FSM2) run() {
func (fsm *FSM) run() {
next, reason := fsm.state.run()
for {
newState := stateName(next)
......@@ -160,11 +160,11 @@ func stateName(s state) string {
}
}
func (fsm *FSM2) cease() {
func (fsm *FSM) cease() {
fsm.eventCh <- Cease
}
func (fsm *FSM2) tcpConnector() error {
func (fsm *FSM) tcpConnector() error {
for {
select {
case <-fsm.initiateCon:
......@@ -189,11 +189,11 @@ func (fsm *FSM2) tcpConnector() error {
}
}
func (fsm *FSM2) tcpConnect() {
func (fsm *FSM) tcpConnect() {
fsm.initiateCon <- struct{}{}
}
func (fsm *FSM2) msgReceiver() error {
func (fsm *FSM) msgReceiver() error {
for {
msg, err := recvMsg(fsm.con)
if err != nil {
......@@ -204,21 +204,21 @@ func (fsm *FSM2) msgReceiver() error {
}
}
func (fsm *FSM2) startConnectRetryTimer() {
func (fsm *FSM) startConnectRetryTimer() {
fsm.connectRetryTimer = time.NewTimer(fsm.connectRetryTime)
}
func (fsm *FSM2) resetConnectRetryTimer() {
func (fsm *FSM) resetConnectRetryTimer() {
if !fsm.connectRetryTimer.Reset(fsm.connectRetryTime) {
<-fsm.connectRetryTimer.C
}
}
func (fsm *FSM2) resetConnectRetryCounter() {
func (fsm *FSM) resetConnectRetryCounter() {
fsm.connectRetryCounter = 0
}
func (fsm *FSM2) sendOpen() error {
func (fsm *FSM) sendOpen() error {
msg := packet.SerializeOpenMsg(&packet.BGPOpen{
Version: BGPVersion,
AS: uint16(fsm.peer.localASN),
......@@ -235,7 +235,7 @@ func (fsm *FSM2) sendOpen() error {
return nil
}
func (fsm *FSM2) sendNotification(errorCode uint8, errorSubCode uint8) error {
func (fsm *FSM) sendNotification(errorCode uint8, errorSubCode uint8) error {
msg := packet.SerializeNotificationMsg(&packet.BGPNotification{})
_, err := fsm.con.Write(msg)
......@@ -246,7 +246,7 @@ func (fsm *FSM2) sendNotification(errorCode uint8, errorSubCode uint8) error {
return nil
}
func (fsm *FSM2) sendKeepalive() error {
func (fsm *FSM) sendKeepalive() error {
msg := packet.SerializeKeepaliveMsg()
_, err := fsm.con.Write(msg)
......
......@@ -7,10 +7,10 @@ import (
)
type activeState struct {
fsm *FSM2
fsm *FSM
}
func newActiveState(fsm *FSM2) *activeState {
func newActiveState(fsm *FSM) *activeState {
return &activeState{
fsm: fsm,
}
......
......@@ -7,10 +7,10 @@ import (
)
type connectState struct {
fsm *FSM2
fsm *FSM
}
func newConnectState(fsm *FSM2) *connectState {
func newConnectState(fsm *FSM) *connectState {
return &connectState{
fsm: fsm,
}
......
......@@ -14,10 +14,10 @@ import (
)
type establishedState struct {
fsm *FSM2
fsm *FSM
}
func newEstablishedState(fsm *FSM2) *establishedState {
func newEstablishedState(fsm *FSM) *establishedState {
return &establishedState{
fsm: fsm,
}
......
......@@ -5,11 +5,11 @@ import (
)
type idleState struct {
fsm *FSM2
fsm *FSM
newStateReason string
}
func newIdleState(fsm *FSM2) *idleState {
func newIdleState(fsm *FSM) *idleState {
return &idleState{
fsm: fsm,
}
......
......@@ -3,12 +3,12 @@ package server
import "net"
type fsmManager struct {
fsms map[string][]*FSM2
fsms map[string][]*FSM
}
func newFSMManager() *fsmManager {
return &fsmManager{
fsms: make(map[string][]*FSM2, 0),
fsms: make(map[string][]*FSM, 0),
}
}
......@@ -16,10 +16,10 @@ func (m *fsmManager) resolveCollision(addr net.IP) {
}
func (m *fsmManager) newFSMPassive() *FSM2 {
return &FSM2{}
func (m *fsmManager) newFSMPassive() *FSM {
return &FSM{}
}
func (m *fsmManager) newFSMActive() *FSM2 {
return &FSM2{}
func (m *fsmManager) newFSMActive() *FSM {
return &FSM{}
}
......@@ -8,10 +8,10 @@ import (
)
type openConfirmState struct {
fsm *FSM2
fsm *FSM
}
func newOpenConfirmState(fsm *FSM2) *openConfirmState {
func newOpenConfirmState(fsm *FSM) *openConfirmState {
return &openConfirmState{
fsm: fsm,
}
......
......@@ -10,10 +10,10 @@ import (
)
type openSentState struct {
fsm *FSM2
fsm *FSM
}
func newOpenSentState(fsm *FSM2) *openSentState {
func newOpenSentState(fsm *FSM) *openSentState {
return &openSentState{
fsm: fsm,
}
......
......@@ -16,7 +16,7 @@ type Peer struct {
addr net.IP
peerASN uint32
localASN uint32
fsms []*FSM2
fsms []*FSM
fsmsMu sync.Mutex
rib routingtable.RouteTableClient
routerID uint32
......@@ -30,7 +30,7 @@ type Peer struct {
exportFilter *filter.Filter
}
func (p *Peer) collisionHandling(callingFSM *FSM2) bool {
func (p *Peer) collisionHandling(callingFSM *FSM) bool {
p.fsmsMu.Lock()
defer p.fsmsMu.Unlock()
......@@ -88,7 +88,7 @@ func NewPeer(c config.Peer, rib routingtable.RouteTableClient, server *BGPServer
addr: c.PeerAddress,
peerASN: c.PeerAS,
localASN: c.LocalAS,
fsms: make([]*FSM2, 0),
fsms: make([]*FSM, 0),
rib: rib,
addPathSend: c.AddPathSend,
addPathRecv: c.AddPathRecv,
......
......@@ -10,7 +10,7 @@ import (
log "github.com/sirupsen/logrus"
)
func pathAttribues(p *route.Path, fsm *FSM2) (*packet.PathAttribute, error) {
func pathAttribues(p *route.Path, fsm *FSM) (*packet.PathAttribute, error) {
asPathPA, err := packet.ParseASPathStr(strings.TrimRight(fmt.Sprintf("%d %s", fsm.peer.localASN, p.BGPPath.ASPath), " "))
if err != nil {
return nil, fmt.Errorf("Unable to parse AS path: %v", err)
......
......@@ -15,11 +15,11 @@ import (
// UpdateSender converts table changes into BGP update messages
type UpdateSender struct {
routingtable.ClientManager
fsm *FSM2
fsm *FSM
iBGP bool
}
func newUpdateSender(fsm *FSM2) *UpdateSender {
func newUpdateSender(fsm *FSM) *UpdateSender {
return &UpdateSender{
fsm: fsm,
iBGP: fsm.peer.localASN == fsm.peer.peerASN,
......
......@@ -12,11 +12,11 @@ import (
// UpdateSenderAddPath converts table changes into BGP update messages with add path
type UpdateSenderAddPath struct {
routingtable.ClientManager
fsm *FSM2
fsm *FSM
iBGP bool
}
func newUpdateSenderAddPath(fsm *FSM2) *UpdateSenderAddPath {
func newUpdateSenderAddPath(fsm *FSM) *UpdateSenderAddPath {
return &UpdateSenderAddPath{
fsm: fsm,
iBGP: fsm.peer.localASN == fsm.peer.peerASN,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment