Documentation ¶
Index ¶
- Constants
- Variables
- func Debug() bool
- type AddrAnnouncer
- type EVENT
- type IPv4AddrAnnouncer
- type IPv4VRRPMsgCon
- type IPv6AddrAnnouncer
- type IPv6VRRPMsgCon
- type NetErr
- type PseudoHeader
- type VRRPMsgConnection
- type VRRPPacket
- func (packet *VRRPPacket) AddIPAddr(ip netip.Addr)
- func (packet *VRRPPacket) AddIPvXAddr(version byte, ip net.IP) error
- func (packet *VRRPPacket) GetAdvertisementInterval() uint16
- func (packet *VRRPPacket) GetCheckSum() uint16
- func (packet *VRRPPacket) GetIPvXAddr(version byte) (addrs []net.IP)
- func (packet *VRRPPacket) GetIPvXAddrCount() byte
- func (packet *VRRPPacket) GetPriority() byte
- func (packet *VRRPPacket) GetType() byte
- func (packet *VRRPPacket) GetVersion() byte
- func (packet *VRRPPacket) GetVirtualRouterID() byte
- func (packet *VRRPPacket) PacketSize() int
- func (packet *VRRPPacket) SetAdvertisementInterval(interval uint16)
- func (packet *VRRPPacket) SetCheckSum(pshdr *PseudoHeader)
- func (packet *VRRPPacket) SetPriority(Priority byte)
- func (packet *VRRPPacket) SetType()
- func (packet *VRRPPacket) SetVersion(Version VRRPVersion)
- func (packet *VRRPPacket) SetVirtualRouterID(VirtualRouterID byte)
- func (packet *VRRPPacket) String() string
- func (packet *VRRPPacket) ToBytes() []byte
- func (packet *VRRPPacket) ValidateCheckSum(pshdr *PseudoHeader) bool
- type VRRPVersion
- type VirtualRouter
- func (r *VirtualRouter) AddEventListener(typ transition, handler func(*VirtualRouter)) bool
- func (r *VirtualRouter) AddIPvXAddr(ip net.IP) error
- func (r *VirtualRouter) AdvInterval() time.Duration
- func (r *VirtualRouter) Interface() *net.Interface
- func (r *VirtualRouter) Preempt() bool
- func (r *VirtualRouter) PreferredSourceIP() net.IP
- func (r *VirtualRouter) Priority() byte
- func (r *VirtualRouter) RemoveIPvXAddr(ip net.IP)
- func (r *VirtualRouter) SetAdvInterval(Interval time.Duration) *VirtualRouter
- func (r *VirtualRouter) SetPreemptMode(flag bool) *VirtualRouter
- func (r *VirtualRouter) SetPriorityAndMasterAdvInterval(priority byte, interval time.Duration) *VirtualRouter
- func (r *VirtualRouter) Start()
- func (r *VirtualRouter) State() uint32
- func (r *VirtualRouter) Stop()
- func (r *VirtualRouter) VIPs() []net.IP
- func (r *VirtualRouter) VRID() byte
- func (r *VirtualRouter) VirtualRouterMAC() net.HardwareAddr
Constants ¶
const ( IPv4 byte = 4 IPv6 byte = 6 )
const ( INIT uint32 = 0 MASTER uint32 = 1 BACKUP uint32 = 2 )
const ( VRRPMultiTTL = 255 VRRPIPProtocolNumber = 112 // IANA VRRP 112 )
const ( Master2Backup transition = iota Backup2Master Init2Master Init2Backup Master2Init Backup2Init )
const EVENT_CHANNEL_SIZE = 1
const PACKET_QUEUE_SIZE = 512
Variables ¶
var BroadcastHADAR, _ = net.ParseMAC("ff:ff:ff:ff:ff:ff")
var VRRPMultiAddrIPv4 = net.IPv4(224, 0, 0, 18)
VRRPMultiAddr(RFC5798 5.1.1.2) IANA VRRP Multicast IPv4: 224.0.0.18
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 ¶
Types ¶
type AddrAnnouncer ¶
type AddrAnnouncer interface { io.Closer AnnounceAll(vr *VirtualRouter) error }
type IPv4AddrAnnouncer ¶
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 PseudoHeader ¶
type VRRPMsgConnection ¶
type VRRPMsgConnection interface { io.Closer WriteMessage(*VRRPPacket) error ReadMessage() (*VRRPPacket, error) }
VRRPMsgConnection
func NewIPv4VRRPMsgConn ¶
NewIPv4VRRPMsgConn
func NewIPv6VRRPMsgConn ¶
NewIPv6VRRPMsgConn
type VRRPPacket ¶
type VRRPPacket struct { Header [8]byte IPAddress [][4]byte Pshdr *PseudoHeader }
VRRPPacket
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) GetIPvXAddr ¶
func (packet *VRRPPacket) GetIPvXAddr(version byte) (addrs []net.IP)
GetIPvXAddr
func (*VRRPPacket) GetIPvXAddrCount ¶
func (packet *VRRPPacket) GetIPvXAddrCount() byte
GetIPvXAddrCount
func (*VRRPPacket) GetVirtualRouterID ¶
func (packet *VRRPPacket) GetVirtualRouterID() byte
GetVirtualRouterID
func (*VRRPPacket) SetAdvertisementInterval ¶
func (packet *VRRPPacket) SetAdvertisementInterval(interval uint16)
SetAdvertisementInterval
func (*VRRPPacket) SetCheckSum ¶
func (packet *VRRPPacket) SetCheckSum(pshdr *PseudoHeader)
SetCheckSum
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) 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 ¶
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) State ¶
func (r *VirtualRouter) State() uint32
State returns INIT | MASTER | BACKUP
func (*VirtualRouter) VIPs ¶
func (r *VirtualRouter) VIPs() []net.IP
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}