project

package
v0.0.0-...-5841409 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IGPUndef = iota
	IGPOSPF  = iota
	IGPISIS  = iota
)
View Source
const (
	NoRel    = iota
	Provider = iota
	Customer = iota
	Peer     = iota
)

Variables

This section is empty.

Functions

func Delete

func Delete(name string)

func List

func List()

func Save

func Save(name string, v interface{})

func Test

func Test()

Types

type AddressFamily

type AddressFamily struct {
	IPv4  bool
	IPv6  bool
	VPNv4 bool
	VPNv6 bool
}

type AutonomousSystem

type AutonomousSystem struct {
	ASN       int
	IGP       string
	MPLS      bool
	Network   Net
	LoStart   net.IPNet
	Routers   []*Router
	Hosts     []*Host
	Links     []Link
	HostLinks []HostLink
	VPN       []VPN
	BGP       struct {
		Disabled        bool
		RedistributeIGP bool
	}
	OSPF struct {
		Stubs []int
	}
	RPKI struct {
		Servers []string
	}
}

AutonomousSystem represents an AS in a Project

func (a *AutonomousSystem) GetMatchingLink(first, second *NetInterface) *NetInterface

func (*AutonomousSystem) IGPType

func (a *AutonomousSystem) IGPType() int

func (*AutonomousSystem) IsOSPFStub

func (a *AutonomousSystem) IsOSPFStub(area int) bool

func (*AutonomousSystem) ReserveSubnets

func (a *AutonomousSystem) ReserveSubnets()

ReserveSubnets generates IPv4 addressing for internal links in an AS

func (*AutonomousSystem) SetupFullMesh

func (a *AutonomousSystem) SetupFullMesh(lm config.InternalLinks, noCost bool) []Link

SetupFullMesh generates an internal links configuration using a full-mesh topology

func (a *AutonomousSystem) SetupLinks(cfg config.InternalLinks)

SetupLinks generates the L2 configuration based on provided config

func (*AutonomousSystem) SetupManual

func (a *AutonomousSystem) SetupManual(lm config.InternalLinks, noCost bool) []Link

SetupManual generates an internal links configuration based on the provided informations

func (*AutonomousSystem) SetupRing

func (a *AutonomousSystem) SetupRing(lm config.InternalLinks, noCost bool) []Link

SetupRing generates an internal links configuration using a ring topology

func (*AutonomousSystem) TotalContainers

func (a *AutonomousSystem) TotalContainers() int

TotalContainres returns the total number of router containers needed for the AS (= P + PE + CE)

type BGPNbr

type BGPNbr struct {
	RemoteAS     int
	UpdateSource string
	ConnCheck    bool
	NextHopSelf  bool
	IfName       string
	RouteMapsIn  []string
	RouteMapsOut []string
	AF           AddressFamily
	RRClient     bool
	RSClient     bool
	Mask         int
}

BGPNbr represents a neighbor configuration for a given router

type ExternalLink struct {
	From *ExternalLinkItem
	To   *ExternalLinkItem
}

ExternalLink represents a link between 2 routers from different AS

type ExternalLinkItem

type ExternalLinkItem struct {
	ASN       int
	Router    *Router
	Interface *NetInterface
	Relation  int
}

ExternalLinkItem represents a side of an ExternalLink

func NewExtLinkItem

func NewExtLinkItem(asn int, router *Router) *ExternalLinkItem

NewExtLinkItem returns a poiter to an ExternalLinkItem based on the provided informations

type Host

type Host struct {
	Hostname      string
	ContainerName string
	DockerImage   string
	Command       []string
	Files         []HostFile
	Links         []*NetInterface
	NextInterface int
}

func (*Host) CopyFiles

func (host *Host) CopyFiles()

func (*Host) StartContainer

func (host *Host) StartContainer(wg *sync.WaitGroup)

StartContainer starts the container

func (*Host) StopContainer

func (host *Host) StopContainer(wg *sync.WaitGroup)

type HostFile

type HostFile struct {
	HostPath      string
	ContainerPath string
}
type HostLink struct {
	Router *LinkItem
	Host   *HostLinkItem
}

type HostLinkItem

type HostLinkItem struct {
	Host      *Host
	Interface *NetInterface
}

func NewHostLinkItem

func NewHostLinkItem(host *Host) *HostLinkItem

type IGPSettings

type IGPSettings struct {
	ISIS struct {
		Circuit int
		Passive bool
	}
	OSPFArea int
}

type IXP

type IXP struct {
	ASN         int
	Network     Net
	RouteServer *Router
	Links       []*ExternalLinkItem
}
type Link struct {
	First  *LinkItem
	Second *LinkItem
}

type LinkItem

type LinkItem struct {
	Router    *Router
	Interface *NetInterface
}

func NewLinkItem

func NewLinkItem(router *Router) *LinkItem

type Net

type Net struct {
	IPNet            *net.IPNet
	NextAvailable    *net.IPNet
	AvailableSubnets int
	AutoAddress      bool
}

func NewNetwork

func NewNetwork(prefix string, prefixLen int) Net

func (Net) AllIPs

func (n Net) AllIPs() []net.IP

AllIPs returns a slice containing all IPs in a network (identifier and broadcast included)

func (Net) CheckPrefix

func (n Net) CheckPrefix(prefixLen int) (int, bool)

CheckPrefix returns the subnet length of the network. The second value return is true if the prefixLen provided is valable.

func (Net) Hosts

func (n Net) Hosts() []net.IP

Hosts returns a slice of hosts in a network

func (Net) Is4

func (n Net) Is4() bool

Is4 returns true if Net is an IPV4 network

func (Net) MarshalJSON

func (n Net) MarshalJSON() ([]byte, error)

func (*Net) NextIP

func (n *Net) NextIP() net.IPNet

NextIP returns the current NextAvailable IPNet, then increments its IP by one

func (*Net) NextLinkIPs

func (n *Net) NextLinkIPs() (a net.IPNet, b net.IPNet)

NextLinkIPs returns the 2 first host IPs of the NextAvailable IPNet, then sets the value to the next one

func (*Net) NextSubnet

func (n *Net) NextSubnet(prefixLen int) net.IPNet

NextSubnet returns the current NextAvailable IPNet, then sets the value to the next subnet

func (Net) Size

func (n Net) Size() int

Size returns the size of a network (number of addresses)

func (*Net) UnmarshalJSON

func (n *Net) UnmarshalJSON(b []byte) error

type NetInterface

type NetInterface struct {
	IfName      string
	Description string
	IP          net.IPNet
	Speed       int
	External    bool
	Cost        int
	VRF         string
	IGP         IGPSettings
}

func (*NetInterface) IsDownstreamVRF

func (l *NetInterface) IsDownstreamVRF() bool

func (*NetInterface) SetSpeedAndCost

func (l *NetInterface) SetSpeedAndCost(v int)

type OSPFNet

type OSPFNet struct {
	Prefix string
	Area   int
}

type Project

type Project struct {
	Name     string
	AS       map[int]*AutonomousSystem
	Ext      []*ExternalLink
	IXPs     []IXP
	RPKI     map[string]RPKIServer
	AllLinks ovsdocker.OVSBulk
}

Project is the main struct of topomate

func Get

func Get(name string) *Project

func ReadConfig

func ReadConfig(path string) *Project

ReadConfig reads a yaml file, parses it and returns a Project

func (p *Project) ApplyExternalLinks()

ApplyExternalLinks creates all external links between the different AS

func (p *Project) ApplyHostLinks()
func (p *Project) ApplyIXPLinks()
func (p *Project) ApplyInternalLinks()

ApplyInternalLinks creates all internal links for each AS of the project

func (p *Project) FindMatchingExtLink(iface *NetInterface) *NetInterface
func (p *Project) GetMatchingExtLink(first, second *NetInterface) *NetInterface

func (*Project) Print

func (p *Project) Print()

Print displays some informations concerning the project

func (p *Project) RemoveExternalLinks()

RemoveExternalLinks removes all external links

func (p *Project) RemoveHostLinks()
func (p *Project) RemoveIXPLinks()
func (p *Project) RemoveInternalLinks()

RemoveInternalLinks removes all internal links of the project

func (*Project) StartAll

func (p *Project) StartAll(linksFlag string)

StartAll starts all containers (creates them before if needed) with the configurations present the configuration directory, and apply links

func (*Project) StopAll

func (p *Project) StopAll()

StopAll stops all containers and removes all links

type RPKIServer

type RPKIServer struct {
	IP   string
	Port int
}

type Router

type Router struct {
	ID            int
	Hostname      string
	ContainerName string
	CustomImage   string
	Loopback      []net.IPNet
	Links         []*NetInterface
	Neighbors     map[string]*BGPNbr
	NextInterface int
	IGP           struct {
		ISIS struct {
			Level int
			Area  int
		}
		// OSPF []string
		OSPF []OSPFNet
	}
}

Router contains informations needed to configure a router. It contains elements relative to the container and to the FRR configuration.

func (*Router) CopyConfig

func (r *Router) CopyConfig(configPath string)

CopyConfig copies the configuration file configPath to the configuration directory in the container file system.

func (*Router) LoID

func (r *Router) LoID() string

func (*Router) LoInfo

func (r *Router) LoInfo() (string, int)

func (*Router) NeighborsAF

func (r *Router) NeighborsAF() (af AddressFamily)

func (*Router) ReloadConfig

func (r *Router) ReloadConfig()

func (*Router) SaveConfig

func (r *Router) SaveConfig(configPath string)

func (*Router) StartContainer

func (r *Router) StartContainer(wg *sync.WaitGroup, configPath string)

StartContainer starts the container for the router. If configPath is set, it also copies the configuration file from the configured directory to the container

func (*Router) StartFRR

func (r *Router) StartFRR()

StartFRR launches the init script inside the container

func (*Router) StopContainer

func (r *Router) StopContainer(wg *sync.WaitGroup, configPath string)

StopContainer stops the router container

type VPN

type VPN struct {
	VRF          string
	Customers    []VPNCustomer
	Neighbors    map[string]bool
	SpokeSubnets []net.IPNet
}

func (*VPN) IsHubAndSpoke

func (vpn *VPN) IsHubAndSpoke() bool

type VPNCustomer

type VPNCustomer struct {
	Router *Router
	Parent *Router
	Hub    bool
}

Jump to

Keyboard shortcuts

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