ospf3

package module
v0.0.0-...-684ef0b Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: MIT Imports: 8 Imported by: 0

README

ospf3 Test Status Go Reference Go Report Card

Package ospf3 implements OSPFv3 (OSPF for IPv6) as described in RFC5340. MIT Licensed.

Documentation

Overview

Package ospf3 implements OSPFv3 (OSPF for IPv6) as described in RFC5340.

Index

Constants

This section is empty.

Variables

View Source
var (
	// AllSPFRouters is the IPv6 multicast group address that all routers
	// running OSPFv3 should participate in.
	AllSPFRouters = &net.IPAddr{IP: net.ParseIP("ff02::5")}

	// AllDRouters is the IPv6 multicast group address that the Designated
	// Router and Backup Designated Router running OSPFv3 must participate in.
	AllDRouters = &net.IPAddr{IP: net.ParseIP("ff02::6")}
)

Functions

func MarshalPacket

func MarshalPacket(p Packet) ([]byte, error)

MarshalPacket turns a Packet into OSPFv3 packet bytes.

Types

type Conn

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

A Conn can send and receive OSPFv3 packets which implement the Packet interface.

func Listen

func Listen(ifi *net.Interface) (*Conn, error)

Listen creates a *Conn using the specified network interface.

func (*Conn) Close

func (c *Conn) Close() error

Close closes the Conn's underlying network connection.

func (*Conn) ReadFrom

func (c *Conn) ReadFrom() (Packet, *ipv6.ControlMessage, *net.IPAddr, error)

ReadFrom reads a single OSPFv3 packet and returns a Packet along with its associated IPv6 control message and source address. ReadFrom will block until a timeout occurs or a valid OSPFv3 packet is read.

func (*Conn) SetReadDeadline

func (c *Conn) SetReadDeadline(t time.Time) error

SetReadDeadline sets the read deadline associated with the Conn.

func (*Conn) WriteTo

func (c *Conn) WriteTo(p Packet, dst *net.IPAddr) error

WriteTo writes a single OSPFv3 Packet to the specified destination address or multicast group.

type DDFlags

type DDFlags uint16

DDFlags are flags which may appear in an OSPFv3 Database Description packet as described in RFC5340, appendix A.3.3.

const (
	MSBit DDFlags = 1 << 0
	MBit  DDFlags = 1 << 1
	IBit  DDFlags = 1 << 2
)

Possible DDFlags values.

func (DDFlags) String

func (f DDFlags) String() string

String returns the string representation of a DDFlags bitmask.

type DatabaseDescription

type DatabaseDescription struct {
	Header         Header
	Options        Options
	InterfaceMTU   uint16
	Flags          DDFlags
	SequenceNumber uint32
	LSAs           []LSAHeader
}

A DatabaseDescription is an OSPFv3 Database Description packet as described in RFC5340, appendix A.3.3.

type FloodingScope

type FloodingScope uint8

A FloodingScope is an OSPFv3 LSA flooding scope as described in RFC 5340, appendix A.4.2.1.

const (
	LinkLocalScoping FloodingScope = 0b00
	AreaScoping      FloodingScope = 0b01
	ASScoping        FloodingScope = 0b10
)

Possible FloodingScope values.

func (FloodingScope) String

func (i FloodingScope) String() string
type Header struct {
	RouterID   ID
	AreaID     ID
	Checksum   uint16
	InstanceID uint8
}

A Header is the OSPFv3 packet header as described in RFC5340, appendix A.3.1. Headers accompany each Packet implementation. The Header only allows setting OSPFv3 header fields which are not calculated programmatically. Version, packet type, and packet length are set automatically when calling MarshalPacket.

type Hello

type Hello struct {
	Header                   Header
	InterfaceID              uint32
	RouterPriority           uint8
	Options                  Options
	HelloInterval            time.Duration
	RouterDeadInterval       time.Duration
	DesignatedRouterID       ID
	BackupDesignatedRouterID ID
	NeighborIDs              []ID
}

A Hello is an OSPFv3 Hello packet as described in RFC5340, appendix A.3.2.

type ID

type ID [4]byte

An ID is a four byte identifier typically used for OSPFv3 router and/or area IDs in a dotted-decimal IPv4 format.

func (ID) String

func (id ID) String() string

type LSA

type LSA struct {
	Type              LSType
	LinkStateID       ID
	AdvertisingRouter ID
}

An LSA is an OSPFv3 Link State Advertisement as described in RFC5340, section 4.4.

type LSAHeader

type LSAHeader struct {
	Age            time.Duration
	LSA            LSA
	SequenceNumber uint32
	Checksum       uint16
	Length         uint16
}

An LSAHeader is an OSPFv3 Link State Advertisement header as described in RFC5340, appendix A.4.2.

type LSType

type LSType uint16

An LSType is the type of an OSPFv3 Link State Advertisement as described in RFC5340, appendix A.4.2.1.

const (
	RouterLSA          LSType = 0x2001
	NetworkLSA         LSType = 0x2002
	InterAreaPrefixLSA LSType = 0x2003
	InterAreaRouterLSA LSType = 0x2004
	ASExternalLSA      LSType = 0x4005

	NSSALSA            LSType = 0x2007
	LinkLSA            LSType = 0x0008
	IntraAreaPrefixLSA LSType = 0x2009
)

Possible LSType values.

func (LSType) FloodingScope

func (t LSType) FloodingScope() FloodingScope

FloodingScope returns the LSA flooding scope value stored in the S1 and S2 bits in the LSType.

func (LSType) LSAHandling

func (t LSType) LSAHandling() bool

LSAHandling returns the value of the U-bit in the LSType. False indicates the LSA should be treated as if it had link-local flooding scope. True indicates that a router should store and flood the LSA as if the type is understood.

func (LSType) String

func (i LSType) String() string

type LinkStateAcknowledgement

type LinkStateAcknowledgement struct {
	Header Header
	LSAs   []LSAHeader
}

A LinkStateAcknowledgement is an OSPFv3 Link State Acknowledgement packet as described in RFC5340, appendix A.3.6.

type LinkStateRequest

type LinkStateRequest struct {
	Header Header
	LSAs   []LSA
}

A LinkStateRequest is an OSPFv3 Link State Request packet as described in RFC5340, appendix A.3.4.

type Options

type Options uint32

Options is a bitmask of OSPFv3 options as described in RFC5340, appendix A.2.

const (
	V6Bit Options = 1 << 0
	EBit  Options = 1 << 1

	NBit  Options = 1 << 3
	RBit  Options = 1 << 4
	DCBit Options = 1 << 5

	AFBit Options = 1 << 8
	LBit  Options = 1 << 9
	ATBit Options = 1 << 10
)

Possible OSPFv3 options bits.

func (Options) String

func (o Options) String() string

String returns the string representation of an Options bitmask.

type Packet

type Packet interface {
	// contains filtered or unexported methods
}

A Packet is an OSPFv3 packet.

func ParsePacket

func ParsePacket(b []byte) (Packet, error)

ParsePacket parses an OSPFv3 Header and trailing Packet from bytes.

Jump to

Keyboard shortcuts

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