vrrp

package module
v0.0.0-...-4d3e3d0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IPv4 byte = 4
	IPv6 byte = 6
)
View Source
const (
	INIT   uint32 = 0
	MASTER uint32 = 1
	BACKUP uint32 = 2
)
View Source
const (
	VRRPMultiTTL         = 255
	VRRPIPProtocolNumber = 112 // IANA VRRP 112
)
View Source
const (
	Master2Backup transition = iota
	Backup2Master
	Init2Master
	Init2Backup
	Master2Init
	Backup2Init
)
View Source
const EVENT_CHANNEL_SIZE = 1
View Source
const PACKET_QUEUE_SIZE = 512

Variables

View Source
var BroadcastHADAR, _ = net.ParseMAC("ff:ff:ff:ff:ff:ff")
View Source
var VRRPMultiAddrIPv4 = net.IPv4(224, 0, 0, 18)

VRRPMultiAddr(RFC5798 5.1.1.2) IANA VRRP Multicast IPv4: 224.0.0.18

View Source
var VRRPMultiAddrIPv6 = net.ParseIP("FF02:0:0:0:0:0:0:12")

IANA VRRP Multicast IPv6: FF02:0:0:0:0:0:0:12

Functions

func Debug

func Debug() bool

Types

type AddrAnnouncer

type AddrAnnouncer interface {
	io.Closer
	AnnounceAll(vr *VirtualRouter) error
}

type EVENT

type EVENT byte
const (
	SHUTDOWN EVENT = 0
	START    EVENT = 1
)

func (EVENT) String

func (e EVENT) String() string

type IPv4AddrAnnouncer

type IPv4AddrAnnouncer struct {
	ARPClient *arp.Client
}

IPv4AddrAnnouncer IPv4 ARP

func NewIPv4AddrAnnouncer

func NewIPv4AddrAnnouncer(nif *net.Interface) (*IPv4AddrAnnouncer, error)

NewIPv4AddrAnnouncer

func (*IPv4AddrAnnouncer) AnnounceAll

func (ar *IPv4AddrAnnouncer) AnnounceAll(vr *VirtualRouter) error

AnnounceAll IPv4

func (*IPv4AddrAnnouncer) Close

func (ar *IPv4AddrAnnouncer) Close() error

type IPv4VRRPMsgCon

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

IPv4VRRPMsgCon

func (*IPv4VRRPMsgCon) Close

func (conn *IPv4VRRPMsgCon) Close() error

func (*IPv4VRRPMsgCon) ReadMessage

func (conn *IPv4VRRPMsgCon) ReadMessage() (*VRRPPacket, error)

ReadMessage

func (*IPv4VRRPMsgCon) WriteMessage

func (conn *IPv4VRRPMsgCon) WriteMessage(packet *VRRPPacket) error

WriteMessage

type IPv6AddrAnnouncer

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

IPv6AddrAnnouncer IPv6 NDP

func NewIPIPv6AddrAnnouncer

func NewIPIPv6AddrAnnouncer(nif *net.Interface) (*IPv6AddrAnnouncer, error)

NewIPIPv6AddrAnnouncer

func (*IPv6AddrAnnouncer) AnnounceAll

func (nd *IPv6AddrAnnouncer) AnnounceAll(vr *VirtualRouter) error

AnnounceAll IPv6

func (*IPv6AddrAnnouncer) Close

func (nd *IPv6AddrAnnouncer) Close() error

type IPv6VRRPMsgCon

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

IPv6VRRPMsgCon

func (*IPv6VRRPMsgCon) Close

func (con *IPv6VRRPMsgCon) Close() error

func (*IPv6VRRPMsgCon) ReadMessage

func (con *IPv6VRRPMsgCon) ReadMessage() (*VRRPPacket, error)

ReadMessage

func (*IPv6VRRPMsgCon) WriteMessage

func (con *IPv6VRRPMsgCon) WriteMessage(packet *VRRPPacket) error

WriteMessage

type NetErr

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

NetErr

type PseudoHeader

type PseudoHeader struct {
	Saddr    net.IP
	Daddr    net.IP
	Zero     uint8
	Protocol uint8 // VRRP 112
	Len      uint16
}

func (*PseudoHeader) ToBytes

func (psh *PseudoHeader) ToBytes() []byte

ToBytes

type VRRPMsgConnection

type VRRPMsgConnection interface {
	io.Closer
	WriteMessage(*VRRPPacket) error
	ReadMessage() (*VRRPPacket, error)
}

VRRPMsgConnection

func NewIPv4VRRPMsgConn

func NewIPv4VRRPMsgConn(itf *net.Interface, src, dst net.IP) (VRRPMsgConnection, error)

NewIPv4VRRPMsgConn

func NewIPv6VRRPMsgConn

func NewIPv6VRRPMsgConn(itf *net.Interface, src, dst net.IP) (VRRPMsgConnection, error)

NewIPv6VRRPMsgConn

type VRRPPacket

type VRRPPacket struct {
	Header    [8]byte
	IPAddress [][4]byte
	Pshdr     *PseudoHeader
}

VRRPPacket

func FromBytes

func FromBytes(IPvXVersion byte, octets []byte) (*VRRPPacket, error)

FromBytes

func (*VRRPPacket) AddIPAddr

func (packet *VRRPPacket) AddIPAddr(ip netip.Addr)

AddIPAddr

func (*VRRPPacket) AddIPvXAddr

func (packet *VRRPPacket) AddIPvXAddr(version byte, ip net.IP) error

AddIPvXAddr

func (*VRRPPacket) GetAdvertisementInterval

func (packet *VRRPPacket) GetAdvertisementInterval() uint16

GetAdvertisementInterval

func (*VRRPPacket) GetCheckSum

func (packet *VRRPPacket) GetCheckSum() uint16

GetCheckSum

func (*VRRPPacket) GetIPvXAddr

func (packet *VRRPPacket) GetIPvXAddr(version byte) (addrs []net.IP)

GetIPvXAddr

func (*VRRPPacket) GetIPvXAddrCount

func (packet *VRRPPacket) GetIPvXAddrCount() byte

GetIPvXAddrCount

func (*VRRPPacket) GetPriority

func (packet *VRRPPacket) GetPriority() byte

GetPriority

func (*VRRPPacket) GetType

func (packet *VRRPPacket) GetType() byte

GetType

func (*VRRPPacket) GetVersion

func (packet *VRRPPacket) GetVersion() byte

GetVersion

func (*VRRPPacket) GetVirtualRouterID

func (packet *VRRPPacket) GetVirtualRouterID() byte

GetVirtualRouterID

func (*VRRPPacket) PacketSize

func (packet *VRRPPacket) PacketSize() int

PacketSize

func (*VRRPPacket) SetAdvertisementInterval

func (packet *VRRPPacket) SetAdvertisementInterval(interval uint16)

SetAdvertisementInterval

func (*VRRPPacket) SetCheckSum

func (packet *VRRPPacket) SetCheckSum(pshdr *PseudoHeader)

SetCheckSum

func (*VRRPPacket) SetPriority

func (packet *VRRPPacket) SetPriority(Priority byte)

SetPriority

func (*VRRPPacket) SetType

func (packet *VRRPPacket) SetType()

SetType

func (*VRRPPacket) SetVersion

func (packet *VRRPPacket) SetVersion(Version VRRPVersion)

SetVersion

func (*VRRPPacket) SetVirtualRouterID

func (packet *VRRPPacket) SetVirtualRouterID(VirtualRouterID byte)

SetVirtualRouterID

func (*VRRPPacket) String

func (packet *VRRPPacket) String() string

func (*VRRPPacket) ToBytes

func (packet *VRRPPacket) ToBytes() []byte

ToBytes

func (*VRRPPacket) ValidateCheckSum

func (packet *VRRPPacket) ValidateCheckSum(pshdr *PseudoHeader) bool

ValidateCheckSum

type VRRPVersion

type VRRPVersion byte
const (
	VRRPv1 VRRPVersion = 1
	VRRPv2 VRRPVersion = 2
	VRRPv3 VRRPVersion = 3
)

func (VRRPVersion) String

func (v VRRPVersion) String() string

type VirtualRouter

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

VirtualRouter

func NewVirtualRouter

func NewVirtualRouter(VRID byte, nif string, Owner bool, IPvX byte) (*VirtualRouter, error)

NewVirtualRouter

func NewVirtualRouterSpec

func NewVirtualRouterSpec(VRID byte, ift *net.Interface, preferIP net.IP, priority byte) (*VirtualRouter, error)

NewVirtualRouterSpec

func (*VirtualRouter) AddEventListener

func (r *VirtualRouter) AddEventListener(typ transition, handler func(*VirtualRouter)) bool

AddEventListener

func (*VirtualRouter) AddIPvXAddr

func (r *VirtualRouter) AddIPvXAddr(ip net.IP) error

AddIPvXAddr

func (*VirtualRouter) AdvInterval

func (r *VirtualRouter) AdvInterval() time.Duration

func (*VirtualRouter) Interface

func (r *VirtualRouter) Interface() *net.Interface

func (*VirtualRouter) Preempt

func (r *VirtualRouter) Preempt() bool

func (*VirtualRouter) PreferredSourceIP

func (r *VirtualRouter) PreferredSourceIP() net.IP

func (*VirtualRouter) Priority

func (r *VirtualRouter) Priority() byte

func (*VirtualRouter) RemoveIPvXAddr

func (r *VirtualRouter) RemoveIPvXAddr(ip net.IP)

RemoveIPvXAddr

func (*VirtualRouter) SetAdvInterval

func (r *VirtualRouter) SetAdvInterval(Interval time.Duration) *VirtualRouter

SetAdvInterval needs to be bigger than 10 ms.

func (*VirtualRouter) SetPreemptMode

func (r *VirtualRouter) SetPreemptMode(flag bool) *VirtualRouter

SetPreemptMode

func (*VirtualRouter) SetPriorityAndMasterAdvInterval

func (r *VirtualRouter) SetPriorityAndMasterAdvInterval(priority byte, interval time.Duration) *VirtualRouter

SetPriorityAndMasterAdvInterval

func (*VirtualRouter) Start

func (r *VirtualRouter) Start()

Start

func (*VirtualRouter) State

func (r *VirtualRouter) State() uint32

State returns INIT | MASTER | BACKUP

func (*VirtualRouter) Stop

func (r *VirtualRouter) Stop()

Stop

func (*VirtualRouter) VIPs

func (r *VirtualRouter) VIPs() []net.IP

func (*VirtualRouter) VRID

func (r *VirtualRouter) VRID() byte

VRID

func (*VirtualRouter) VirtualRouterMAC

func (r *VirtualRouter) VirtualRouterMAC() net.HardwareAddr

GetVirtualRouterMAC / RFC 5798 7.3. Virtual Router MAC Address - IPv4 case: 00-00-5E-00-01-{VRID} - IPv6 case: 00-00-5E-00-02-{VRID}

Jump to

Keyboard shortcuts

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