diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-11-08 16:27:54 +0900 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-11-11 00:31:32 +0900 |
commit | 403ae3580bbaeb49da535efa66b96ee7b87b31d9 (patch) | |
tree | 84df2dc6ecd48d01e8b6db6faeb7ae37b3d28958 /server | |
parent | 15812686282c61120e07c7880be6d347c1a53059 (diff) |
server: expose fsmMsgType, fsmMsg
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server')
-rw-r--r-- | server/fsm.go | 30 | ||||
-rw-r--r-- | server/fsm_test.go | 2 | ||||
-rw-r--r-- | server/peer.go | 4 | ||||
-rw-r--r-- | server/server.go | 6 |
4 files changed, 21 insertions, 21 deletions
diff --git a/server/fsm.go b/server/fsm.go index c41aacd5..4ac2a4b1 100644 --- a/server/fsm.go +++ b/server/fsm.go @@ -28,16 +28,16 @@ import ( "time" ) -type fsmMsgType int +type FsmMsgType int const ( - _ fsmMsgType = iota + _ FsmMsgType = iota FSM_MSG_STATE_CHANGE FSM_MSG_BGP_MESSAGE ) -type fsmMsg struct { - MsgType fsmMsgType +type FsmMsg struct { + MsgType FsmMsgType MsgSrc string MsgData interface{} PathList []*table.Path @@ -292,15 +292,15 @@ type FSMHandler struct { t tomb.Tomb fsm *FSM conn net.Conn - msgCh chan *fsmMsg + msgCh chan *FsmMsg errorCh chan bool - incoming chan *fsmMsg + incoming chan *FsmMsg outgoing chan *bgp.BGPMessage holdTimerResetCh chan bool reason string } -func NewFSMHandler(fsm *FSM, incoming chan *fsmMsg, outgoing chan *bgp.BGPMessage) *FSMHandler { +func NewFSMHandler(fsm *FSM, incoming chan *FsmMsg, outgoing chan *bgp.BGPMessage) *FSMHandler { h := &FSMHandler{ fsm: fsm, errorCh: make(chan bool, 2), @@ -454,7 +454,7 @@ func (h *FSMHandler) recvMessageWithError() error { "State": h.fsm.state, "error": err, }).Warn("malformed BGP Header") - h.msgCh <- &fsmMsg{ + h.msgCh <- &FsmMsg{ MsgType: FSM_MSG_BGP_MESSAGE, MsgSrc: h.fsm.pConf.NeighborConfig.NeighborAddress.String(), MsgData: err, @@ -468,7 +468,7 @@ func (h *FSMHandler) recvMessageWithError() error { return err } - var fmsg *fsmMsg + var fmsg *FsmMsg m, err := bgp.ParseBGPBody(hd, bodyBuf) if err == nil { h.fsm.bgpMessageStateUpdate(m.Header.Type, true) @@ -483,13 +483,13 @@ func (h *FSMHandler) recvMessageWithError() error { "State": h.fsm.state, "error": err, }).Warn("malformed BGP message") - fmsg = &fsmMsg{ + fmsg = &FsmMsg{ MsgType: FSM_MSG_BGP_MESSAGE, MsgSrc: h.fsm.pConf.NeighborConfig.NeighborAddress.String(), MsgData: err, } } else { - fmsg = &fsmMsg{ + fmsg = &FsmMsg{ MsgType: FSM_MSG_BGP_MESSAGE, MsgSrc: h.fsm.pConf.NeighborConfig.NeighborAddress.String(), MsgData: m, @@ -543,7 +543,7 @@ func (h *FSMHandler) opensent() bgp.FSMState { fsm.conn.Write(b) fsm.bgpMessageStateUpdate(m.Header.Type, false) - h.msgCh = make(chan *fsmMsg) + h.msgCh = make(chan *FsmMsg) h.conn = fsm.conn h.t.Go(h.recvMessage) @@ -583,7 +583,7 @@ func (h *FSMHandler) opensent() bgp.FSMState { fsm.peerInfo.ID = body.ID _, fsm.rfMap = open2Cap(body, fsm.pConf) - e := &fsmMsg{ + e := &FsmMsg{ MsgType: FSM_MSG_BGP_MESSAGE, MsgSrc: fsm.pConf.NeighborConfig.NeighborAddress.String(), MsgData: m, @@ -654,7 +654,7 @@ func keepaliveTicker(fsm *FSM) *time.Ticker { func (h *FSMHandler) openconfirm() bgp.FSMState { fsm := h.fsm ticker := keepaliveTicker(fsm) - h.msgCh = make(chan *fsmMsg) + h.msgCh = make(chan *FsmMsg) h.conn = fsm.conn h.t.Go(h.recvMessage) @@ -961,7 +961,7 @@ func (h *FSMHandler) loop() error { // zero means that tomb.Dying() if nextState >= bgp.BGP_FSM_IDLE { - e := &fsmMsg{ + e := &FsmMsg{ MsgType: FSM_MSG_STATE_CHANGE, MsgSrc: fsm.pConf.NeighborConfig.NeighborAddress.String(), MsgData: nextState, diff --git a/server/fsm_test.go b/server/fsm_test.go index 0ce1a53f..aad9ff07 100644 --- a/server/fsm_test.go +++ b/server/fsm_test.go @@ -295,7 +295,7 @@ func makePeerAndHandler() (*Peer, *FSMHandler) { p.fsm = NewFSM(&gConf, &pConf, &Peer{}) - incoming := make(chan *fsmMsg, 4096) + incoming := make(chan *FsmMsg, 4096) p.outgoing = make(chan *bgp.BGPMessage, 4096) h := &FSMHandler{ diff --git a/server/peer.go b/server/peer.go index 425d61ee..81e7f1f8 100644 --- a/server/peer.go +++ b/server/peer.go @@ -133,7 +133,7 @@ func open2Cap(open *bgp.BGPOpen, n *config.Neighbor) (map[bgp.BGPCapabilityCode] return capMap, rfMap } -func (peer *Peer) handleBGPmessage(e *fsmMsg) ([]*table.Path, bool, []*bgp.BGPMessage) { +func (peer *Peer) handleBGPmessage(e *FsmMsg) ([]*table.Path, bool, []*bgp.BGPMessage) { m := e.MsgData.(*bgp.BGPMessage) bgpMsgList := []*bgp.BGPMessage{} pathList := []*table.Path{} @@ -212,7 +212,7 @@ func (peer *Peer) handleBGPmessage(e *fsmMsg) ([]*table.Path, bool, []*bgp.BGPMe return pathList, update, bgpMsgList } -func (peer *Peer) startFSMHandler(incoming chan *fsmMsg) { +func (peer *Peer) startFSMHandler(incoming chan *FsmMsg) { peer.fsm.h = NewFSMHandler(peer.fsm, incoming, peer.outgoing) } diff --git a/server/server.go b/server/server.go index d6aad66c..1e54da39 100644 --- a/server/server.go +++ b/server/server.go @@ -84,7 +84,7 @@ type BgpServer struct { addedPeerCh chan config.Neighbor deletedPeerCh chan config.Neighbor updatedPeerCh chan config.Neighbor - fsmincomingCh chan *fsmMsg + fsmincomingCh chan *FsmMsg rpkiConfigCh chan config.RpkiServers bmpConfigCh chan config.BmpServers dumper *dumper @@ -248,7 +248,7 @@ func (server *BgpServer) Serve() { return l } - server.fsmincomingCh = make(chan *fsmMsg, 4096) + server.fsmincomingCh = make(chan *FsmMsg, 4096) var senderMsgs []*SenderMsg var zapiMsgCh chan *zebra.Message @@ -707,7 +707,7 @@ func (server *BgpServer) propagateUpdate(peer *Peer, pathList []*table.Path) []* return msgs } -func (server *BgpServer) handleFSMMessage(peer *Peer, e *fsmMsg, incoming chan *fsmMsg) []*SenderMsg { +func (server *BgpServer) handleFSMMessage(peer *Peer, e *FsmMsg, incoming chan *FsmMsg) []*SenderMsg { msgs := make([]*SenderMsg, 0) switch e.MsgType { |