Skip to content
Snippets Groups Projects
peer.go 582 B
Newer Older
  • Learn to ignore specific revisions
  • Oliver Herms's avatar
    Oliver Herms committed
    package server
    
    import (
    	"net"
    
    
    Oliver Herms's avatar
    Oliver Herms committed
    	"github.com/bio-routing/bio-rd/routingtable/locRIB"
    
    
    Oliver Herms's avatar
    Oliver Herms committed
    	"github.com/bio-routing/bio-rd/config"
    
    Oliver Herms's avatar
    Oliver Herms committed
    )
    
    type Peer struct {
    	addr     net.IP
    	asn      uint32
    	fsm      *FSM
    
    Oliver Herms's avatar
    Oliver Herms committed
    	rib      *locRIB.LocRIB
    
    Oliver Herms's avatar
    Oliver Herms committed
    	routerID uint32
    }
    
    
    Oliver Herms's avatar
    Oliver Herms committed
    func NewPeer(c config.Peer, rib *locRIB.LocRIB) (*Peer, error) {
    
    Oliver Herms's avatar
    Oliver Herms committed
    	p := &Peer{
    		addr: c.PeerAddress,
    		asn:  c.PeerAS,
    
    Oliver Herms's avatar
    Oliver Herms committed
    		fsm:  NewFSM(c, rib),
    		rib:  rib,
    
    Oliver Herms's avatar
    Oliver Herms committed
    	}
    	return p, nil
    }
    
    func (p *Peer) GetAddr() net.IP {
    	return p.addr
    }
    
    func (p *Peer) GetASN() uint32 {
    	return p.asn
    }
    
    func (p *Peer) Start() {
    	p.fsm.start()
    	p.fsm.activate()
    }