packetv3

package
v0.0.3-pre4.0...-0ec3cfc Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RouterOptV6 uint16 = 1 << iota
	RouterOptE

	RouterOptN
	RouterOptR
	RouterOptDC

	RouterOptAF
)

bitmasks for flags in RouterOptions

View Source
const (
	LSATypeUnknown         LSAType = 0
	LSATypeRouter                  = 0x2001
	LSATypeNetwork                 = 0x2002
	LSATypeInterAreaPrefix         = 0x2003
	LSATypeInterAreaRouter         = 0x2004
	LSATypeASExternal              = 0x4005
	LSATypeDeprecated              = 0x2006
	LSATypeNSSA                    = 0x2007
	LSATypeLink                    = 0x0008
	LSATypeIntraAreaPrefix         = 0x2009
)

OSPF LSA types

View Source
const (
	ASExtLSAFlagT uint8 = 1 << iota
	ASExtLSAFlagF
	ASExtLSAFlagE
)

Bitmasks for flags used in ASExternalLSA

View Source
const (
	NUBIT = 1
	LABIT = 2
	PBIT  = 8
	DNBIT = 16
)

Prefix Option Bits

View Source
const LSAHeaderLength = 20
View Source
const OSPFProtocolNumber = 89
View Source
const OSPFv3MessageChecksumAtByte = 12
View Source
const OSPFv3MessageHeaderLength = 16
View Source
const OSPFv3MessagePacketLengthAtByte = 2

Variables

This section is empty.

Functions

func OSPFv3Checksum

func OSPFv3Checksum(data []byte, src, dst net.IP) uint16

Types

type ASExternalLSA

type ASExternalLSA struct {
	Flags  uint8
	Metric uint32 // max: 24 bit
	Prefix LSAPrefix

	ForwardingAddress     net.IP // optional
	ExternalRouteTag      uint32 // optional
	ReferencedLinkStateID ID     // optional
}

func DeserializeASExternalLSA

func DeserializeASExternalLSA(buf *bytes.Buffer) (*ASExternalLSA, int, error)

func (*ASExternalLSA) FlagE

func (a *ASExternalLSA) FlagE() bool

func (*ASExternalLSA) FlagF

func (a *ASExternalLSA) FlagF() bool

func (*ASExternalLSA) FlagT

func (a *ASExternalLSA) FlagT() bool

func (*ASExternalLSA) Serialize

func (x *ASExternalLSA) Serialize(buf *bytes.Buffer)

type AreaLinkDescription

type AreaLinkDescription struct {
	Type                AreaLinkDescriptionType
	Metric              uint32 // max: 24 bit
	InterfaceID         ID
	NeighborInterfaceID ID
	NeighborRouterID    ID
}

func DeserializeAreaLinkDescription

func DeserializeAreaLinkDescription(buf *bytes.Buffer) (AreaLinkDescription, int, error)

func (*AreaLinkDescription) Serialize

func (x *AreaLinkDescription) Serialize(buf *bytes.Buffer)

type AreaLinkDescriptionType

type AreaLinkDescriptionType uint8
const (
	ALDTypePTP AreaLinkDescriptionType
	ALDTypeTransit
	ALDTypeReserved
	ALDTypeVirtualLink
)

type DBFlags

type DBFlags uint8
const (
	DBFlagInit DBFlags = 1 << iota
	DBFlagMore
	DBFlagMS
)

database description flags

type DatabaseDescription

type DatabaseDescription struct {
	Options          RouterOptions
	InterfaceMTU     uint16
	DBFlags          DBFlags
	DDSequenceNumber uint32
	LSAHeaders       []*LSA
}

func DeserializeDatabaseDescription

func DeserializeDatabaseDescription(buf *bytes.Buffer, bodyLength uint16) (*DatabaseDescription, int, error)

func (*DatabaseDescription) Serialize

func (x *DatabaseDescription) Serialize(buf *bytes.Buffer)

type FloodingScope

type FloodingScope uint8
const (
	FloodLinkLocal FloodingScope = iota
	FloodArea
	FloodAS
	FloodReserved
)

type Hello

type Hello struct {
	InterfaceID              ID
	RouterPriority           uint8
	Options                  RouterOptions
	HelloInterval            uint16
	RouterDeadInterval       uint16
	DesignatedRouterID       ID
	BackupDesignatedRouterID ID
	Neighbors                []ID
}

func DeserializeHello

func DeserializeHello(buf *bytes.Buffer, bodyLength uint16) (*Hello, int, error)

func (*Hello) Serialize

func (x *Hello) Serialize(buf *bytes.Buffer)

type ID

type ID uint32

ID is a common type used for 32-bit IDs in OSPF

func DeserializeID

func DeserializeID(buf *bytes.Buffer) (ID, int, error)

func (ID) Serialize

func (i ID) Serialize(buf *bytes.Buffer)

type InterAreaPrefixLSA

type InterAreaPrefixLSA struct {
	Metric uint32 // max: 24 bit
	Prefix LSAPrefix
}

func DeserializeInterAreaPrefixLSA

func DeserializeInterAreaPrefixLSA(buf *bytes.Buffer) (*InterAreaPrefixLSA, int, error)

func (*InterAreaPrefixLSA) Serialize

func (x *InterAreaPrefixLSA) Serialize(buf *bytes.Buffer)

type InterAreaRouterLSA

type InterAreaRouterLSA struct {
	Options             RouterOptions
	Metric              uint32 // max: 24 bit
	DestinationRouterID ID
}

func DeserializeInterAreaRouterLSA

func DeserializeInterAreaRouterLSA(buf *bytes.Buffer) (*InterAreaRouterLSA, int, error)

func (*InterAreaRouterLSA) Serialize

func (x *InterAreaRouterLSA) Serialize(buf *bytes.Buffer)

type IntraAreaPrefixLSA

type IntraAreaPrefixLSA struct {
	ReferencedLSType            LSAType
	ReferencedLinkStateID       ID
	ReferencedAdvertisingRouter ID
	Prefixes                    []LSAPrefix
}

func DeserializeIntraAreaPrefixLSA

func DeserializeIntraAreaPrefixLSA(buf *bytes.Buffer) (*IntraAreaPrefixLSA, int, error)

func (*IntraAreaPrefixLSA) Serialize

func (x *IntraAreaPrefixLSA) Serialize(buf *bytes.Buffer)

type LSA

type LSA struct {
	Age               uint16
	Type              LSAType
	ID                ID
	AdvertisingRouter ID
	SequenceNumber    uint32
	Checksum          uint16
	Length            uint16
	Body              Serializable
}

func DeserializeLSA

func DeserializeLSA(buf *bytes.Buffer) (*LSA, int, error)

func DeserializeLSAHeader

func DeserializeLSAHeader(buf *bytes.Buffer) (*LSA, int, error)

func (*LSA) ReadBody

func (x *LSA) ReadBody(buf *bytes.Buffer) (int, error)

func (*LSA) Serialize

func (x *LSA) Serialize(buf *bytes.Buffer)

func (*LSA) SerializeHeader

func (x *LSA) SerializeHeader(buf *bytes.Buffer)

type LSAPrefix

type LSAPrefix struct {
	PrefixLength uint8
	Options      PrefixOptions

	// this may represent different things
	// used for metric or referenced LSType
	Special uint16

	Address net.IP
}

func DeserializeLSAPrefix

func DeserializeLSAPrefix(buf *bytes.Buffer) (LSAPrefix, int, error)

func (*LSAPrefix) Serialize

func (x *LSAPrefix) Serialize(buf *bytes.Buffer)

func (*LSAPrefix) ToNetPrefix

func (x *LSAPrefix) ToNetPrefix() net.Prefix

type LSAType

type LSAType uint16

func (LSAType) FloodIfUnknown

func (t LSAType) FloodIfUnknown() bool

func (LSAType) FloodingScope

func (t LSAType) FloodingScope() FloodingScope

func (LSAType) Serialize

func (t LSAType) Serialize(buf *bytes.Buffer)

type LinkLSA

type LinkLSA struct {
	RouterPriority            uint8
	Options                   RouterOptions
	LinkLocalInterfaceAddress net.IP
	PrefixNum                 uint32
	Prefixes                  []LSAPrefix
}

func DeserializeLinkLSA

func DeserializeLinkLSA(buf *bytes.Buffer) (*LinkLSA, int, error)

func (*LinkLSA) Serialize

func (x *LinkLSA) Serialize(buf *bytes.Buffer)

type LinkStateAcknowledgement

type LinkStateAcknowledgement []*LSA

func DeserializeLinkStateAcknowledgement

func DeserializeLinkStateAcknowledgement(buf *bytes.Buffer, bodyLength uint16) (LinkStateAcknowledgement, int, error)

func (LinkStateAcknowledgement) Serialize

func (x LinkStateAcknowledgement) Serialize(buf *bytes.Buffer)

type LinkStateRequest

type LinkStateRequest struct {
	LSType            LSAType
	LinkStateID       ID
	AdvertisingRouter ID
}

func DeserializeLinkStateRequest

func DeserializeLinkStateRequest(buf *bytes.Buffer) (LinkStateRequest, int, error)

func (*LinkStateRequest) Serialize

func (x *LinkStateRequest) Serialize(buf *bytes.Buffer)

type LinkStateRequestMsg

type LinkStateRequestMsg []LinkStateRequest

func DeserializeLinkStateRequestMsg

func DeserializeLinkStateRequestMsg(buf *bytes.Buffer, bodyLength uint16) (LinkStateRequestMsg, int, error)

func (LinkStateRequestMsg) Serialize

func (x LinkStateRequestMsg) Serialize(buf *bytes.Buffer)

type LinkStateUpdate

type LinkStateUpdate []*LSA

func DeserializeLinkStateUpdate

func DeserializeLinkStateUpdate(buf *bytes.Buffer) (LinkStateUpdate, int, error)

func (LinkStateUpdate) Serialize

func (x LinkStateUpdate) Serialize(buf *bytes.Buffer)

type NetworkLSA

type NetworkLSA struct {
	Options        RouterOptions
	AttachedRouter []ID
}

func DeserializeNetworkLSA

func DeserializeNetworkLSA(buf *bytes.Buffer, bodyLength uint16) (*NetworkLSA, int, error)

func (*NetworkLSA) Serialize

func (x *NetworkLSA) Serialize(buf *bytes.Buffer)

type OSPFMessageType

type OSPFMessageType uint8
const (
	MsgTypeUnknown OSPFMessageType = iota
	MsgTypeHello
	MsgTypeDatabaseDescription
	MsgTypeLinkStateRequest
	MsgTypeLinkStateUpdate
	MsgTypeLinkStateAcknowledgment
)

OSPF message types

type OSPFv3Message

type OSPFv3Message struct {
	Version      uint8
	Type         OSPFMessageType
	PacketLength uint16
	RouterID     ID
	AreaID       ID
	Checksum     uint16
	InstanceID   uint8
	Body         Serializable
}

func DeserializeOSPFv3Message

func DeserializeOSPFv3Message(buf *bytes.Buffer, src, dst net.IP) (*OSPFv3Message, int, error)

func (*OSPFv3Message) ReadBody

func (m *OSPFv3Message) ReadBody(buf *bytes.Buffer) (int, error)

func (*OSPFv3Message) Serialize

func (x *OSPFv3Message) Serialize(out *bytes.Buffer, src, dst net.IP)

type PrefixOptions

type PrefixOptions struct {
	NoUnicast    bool // NU-bit
	LocalAddress bool // LA-bit
	Propagate    bool // P-bit
	DN           bool // DN-bit
}

func (PrefixOptions) Serialize

func (o PrefixOptions) Serialize(buf *bytes.Buffer)

type RouterLSA

type RouterLSA struct {
	Flags            RouterLSAFlags
	Options          RouterOptions
	LinkDescriptions []AreaLinkDescription
}

func DeserializeRouterLSA

func DeserializeRouterLSA(buf *bytes.Buffer, bodyLength uint16) (*RouterLSA, int, error)

func (*RouterLSA) Serialize

func (x *RouterLSA) Serialize(buf *bytes.Buffer)

type RouterLSAFlags

type RouterLSAFlags uint8
const (
	RouterLSAFlagBorder RouterLSAFlags = 1 << iota
	RouterLSAFlagExternal
	RouterLSAFlagVirtualLink

	RouterLSAFlagNSSATranslation
)

func RouterLSAFlagsFrom

func RouterLSAFlagsFrom(flags ...RouterLSAFlags) RouterLSAFlags

func (RouterLSAFlags) HasFlag

func (f RouterLSAFlags) HasFlag(flag uint8) bool

func (RouterLSAFlags) SetFlag

func (f RouterLSAFlags) SetFlag(flag uint8) uint8

type RouterOptions

type RouterOptions struct {
	Flags uint16
	// contains filtered or unexported fields
}

func OptionsFromFlags

func OptionsFromFlags(flags ...uint16) RouterOptions

func (RouterOptions) HasFlag

func (r RouterOptions) HasFlag(flag uint16) bool

func (*RouterOptions) Serialize

func (r *RouterOptions) Serialize(buf *bytes.Buffer)

func (RouterOptions) SetFlag

func (r RouterOptions) SetFlag(flag uint16) RouterOptions

type Serializable

type Serializable interface {
	Serialize(buf *bytes.Buffer)
}

Serializable represents any packet which can be serialized to bytes to be on the wire

type UnknownLSA

type UnknownLSA []byte

func (UnknownLSA) Serialize

func (u UnknownLSA) Serialize(buf *bytes.Buffer)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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