quagga

package
v0.0.0-...-1cdf2d7 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 7 Imported by: 88

Documentation

Overview

Package quagga provides a library for interfacing with Quagga daemons.

Index

Constants

View Source
const BGPSocketPath = "/var/run/quagga/bgpd.vty"

Variables

This section is empty.

Functions

func ParseUptime

func ParseUptime(uptime string) time.Duration

ParseUptime parses an uptime string and returns the corresponding duration. Time can come in five formats:

07:05:56
2d23h12m
03w5d13h
never
<error>

See the peer_uptime function in quagga/linc/bgpd/bgpd.c.

Types

type BGP

type BGP struct {
	// contains filtered or unexported fields
}

BGP contains the data needed to interface with the Quagga BGP daemon.

func NewBGP

func NewBGP(socket string, asn uint32) *BGP

NewBGP returns an initialised BGP structure.

func (*BGP) Advertise

func (b *BGP) Advertise(n *net.IPNet) error

Advertise requests the BGP daemon to advertise the specified network.

func (*BGP) Close

func (b *BGP) Close() error

Close closes a connection to the VTY of the BGP daemon.

func (*BGP) Configuration

func (b *BGP) Configuration() ([]string, error)

Configuration returns the current running configuration from the BGP daemon, as a slice of strings.

func (*BGP) Dial

func (b *BGP) Dial() error

Dial establishes a connection to the VTY of the BGP daemon.

func (*BGP) Enable

func (b *BGP) Enable() error

Enable issues an "enable" command to the BGP daemon.

func (*BGP) Neighbors

func (b *BGP) Neighbors() ([]*Neighbor, error)

Neighbors returns a list of BGP neighbors that we are currently peering with.

func (*BGP) Withdraw

func (b *BGP) Withdraw(n *net.IPNet) error

Withdraw requests the BGP daemon to withdraw advertisements for the specified network.

type BGPState

type BGPState uint

BGPState represents a BGP peering state.

const (
	BGPStateUnknown     BGPState = 0
	BGPStateIdle        BGPState = 1
	BGPStateConnect     BGPState = 2
	BGPStateActive      BGPState = 3
	BGPStateOpenSent    BGPState = 4
	BGPStateOpenConfirm BGPState = 5
	BGPStateEstablished BGPState = 6
)

func BGPStateByName

func BGPStateByName(name string) BGPState

BGPStateByName returns the BGP state that corresponds to the given name.

func (BGPState) String

func (s BGPState) String() string

String returns a string representation of the given BGP state.

type MessageStat

type MessageStat struct {
	Sent uint64
	Rcvd uint64
}

MessageStat encapsulates the statistics for a given message type.

type MessageStats

type MessageStats struct {
	Opens         MessageStat
	Notifications MessageStat
	Updates       MessageStat
	Keepalives    MessageStat
	RouteRefresh  MessageStat
	Capability    MessageStat
	Total         MessageStat
}

MessageStats encapsulates messages statistics for a BGP neighbor.

type Neighbor

type Neighbor struct {
	IP          net.IP
	RouterID    net.IP
	ASN         uint32
	Description string
	BGPState    BGPState
	Uptime      time.Duration
	MessageStats
}

Neighbor represents a BGP neighbor.

type Neighbors

type Neighbors struct {
	Neighbors []*Neighbor
}

Neighbors represents a list of BGP neighbors.

type VTY

type VTY struct {
	// contains filtered or unexported fields
}

VTY represents a connection to a Quagga VTY.

func NewVTY

func NewVTY(socket string) *VTY

NewVTY returns an initialised VTY struct.

func (*VTY) Close

func (v *VTY) Close() error

Close closes a connection to a Quagga VTY socket.

func (*VTY) Command

func (v *VTY) Command(cmd string) (string, error)

Command issues the given command over the Quagga VTY and reads the response.

func (*VTY) Commands

func (v *VTY) Commands(cmds []string) error

Commands issues a sequence of commands over the Quagga VTY, discarding responses.

func (*VTY) Dial

func (v *VTY) Dial() error

Dial establishes a connection to a Quagga VTY socket.

type VTYError

type VTYError struct {
	Response string
	Status   byte
}

VTYError encapsulates an error that was returned from a command issued to a Quagga VTY daemon.

func (VTYError) Error

func (e VTYError) Error() string

Jump to

Keyboard shortcuts

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