Skip to content
Snippets Groups Projects
peer.go 548 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/config"
    
    Oliver Herms's avatar
    Oliver Herms committed
    	"github.com/bio-routing/bio-rd/rt"
    
    Oliver Herms's avatar
    Oliver Herms committed
    )
    
    type Peer struct {
    	addr     net.IP
    	asn      uint32
    	fsm      *FSM
    
    Oliver Herms's avatar
    Oliver Herms committed
    	vrf      *rt.RT
    
    Oliver Herms's avatar
    Oliver Herms committed
    	routerID uint32
    }
    
    
    Oliver Herms's avatar
    Oliver Herms committed
    func NewPeer(c config.Peer, vrf *rt.RT) (*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, vrf),
    		vrf:  vrf,
    
    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()
    }