ospf

package
v0.0.0-...-6b8ee43 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: AGPL-3.0 Imports: 63 Imported by: 0

Documentation

Overview

Design: plan/learned/958-ospf-4-component-config.md -- per-area state scaffolding Related: config.go -- areaConfig and interfaceConfig inputs

Design: internal/component/bgp/reactor/peer_bfd.go -- the EXEMPLAR BFD client this mirrors. Design: plan/learned/560-bfd-3-bgp-client.md -- nil-safe Service lookup, per-session subscriber worker, stop+done handshake. RFC: rfc/short/rfc5881.md (single-hop UDP 3784, both ends Active, TTL/Hop-Limit 255 GTSM); rfc/short/rfc5880.md (Down/AdminDown detection); rfc/short/rfc5882.md (client model: BFD is a failure detector, not a session driver).

BFD-for-OSPF glue on the unified v2/v3 engine. When an OSPF adjacency reaches Full on a BFD-enabled interface and the in-process BFD engine is available, the engine opens a single-hop BFD session for the neighbor. A BFD Down/AdminDown drives the AF-neutral NSM down seam (neighbor.Table.NeighborDown), declaring the neighbor dead far faster than the RouterDeadInterval timer. BFD is strictly additive: with no BFD plugin, or BFD not enabled on the interface, OSPF runs exactly as before on the Hello/Dead timers, on both families.

The lifecycle, client map, subscriber discipline, and metrics are AF-neutral and shared; only the request builder forks by codec.IsV6() (bfdRequestForNeighbor vs bfdRequestForNeighborV6). Each engine instance (IPv4 and IPv6) owns its own client map, so a v6 down never touches a v4 neighbor (R-4).

Design: plan/learned/564-bfd-2b-ipv6-transport.md -- the BFD engine's IPv6 single-hop transport (IPV6_UNICAST_HOPS=255 TX, IPV6_RECVHOPLIMIT cmsg GTSM RX). The engine carries an IPv6 single-hop session end-to-end; OSPF adds NO transport code. Design: plan/learned/970-ospfv3-3-ipv6-transport.md -- OSPFv3 is our OSPF; the BFD GTSM-255 single-hop unicast session is independent of base OSPFv3's Hop-Limit-1 multicast. RFC: rfc/short/rfc5881.md -- BFD for IPv4/IPv6 single hop.

The IPv6 (OSPFv3) BFD request builder. The shared client lifecycle lives in bfd_client.go; the ONLY per-address-family divergence is this builder (the link-local pair) versus the IPv4 builder (the on-subnet IPv4 pair), selected by codec.IsV6() in bfdRequestForFamily.

Design: plan/learned/958-ospf-4-component-config.md -- OSPFv2 config resolution Related: yang/ze-ospf-conf.yang -- schema this resolver consumes RFC: rfc/short/rfc3101.md -- NSSA translate-role / stability-interval config

Config flows file -> YANG schema -> validated tree -> SDK ConfigSection as root-wrapped JSON ({"ospf": {...}}). Tree.ToMap renders scalar leaves as strings, keyed lists as key -> entry maps, and nested containers as maps. This file mirrors the IS-IS config resolver shape while keeping OSPFv2 types local.

Design: plan/learned/958-ospf-4-component-config.md -- OSPFv2 event bus types Related: register.go -- registers the namespace and wires the EventBus

Design: plan/learned/1044-ospf-ext-9-graceful-restart.md -- OSPF Graceful Restart control plane. Related: gr_nvs.go (restart fact), gr_lsa.go + packet/grace_lsa.go (IPv4 wire),

v3/packet/lsa_grace.go (IPv6 wire).

RFC: rfc/short/rfc3623.md (OSPFv2 GR restarter + helper, the shared control plane),

rfc/short/rfc5187.md (OSPFv3 GR wire delta + sec 3.1/3.2 preservation).

ONE feature, ONE control plane, TWO wire encodings. grManager holds the shared restarter and helper state machines that drive BOTH address families; only the Grace-LSA origination and decode fork per family (IPv4 = ext-1 Opaque Type 3; IPv6 = native LS Type 0x000B). The restarter FSM lives in gr_restarter.go, the helper FSM in gr_helper.go. The engine owns one grManager per instance; it is nil-safe/inert until the operator enables graceful-restart.

Design: plan/learned/1044-ospf-ext-9-graceful-restart.md -- GR helper (restart-aid) state machine. Related: gr.go (grManager), instance.go (lsdbTopology injects helped neighbors). RFC: rfc/short/rfc3623.md sec 3 (keep advertising X, keep X as DR), sec 3.1 (entry checks),

sec 3.2 (exit triggers incl. strict LSA checking + the stub-area exception);
rfc/short/rfc5187.md sec 2 (OSPFv3 keys X by Advertising Router).

Design: plan/learned/1044-ospf-ext-9-graceful-restart.md -- IPv4 (RFC 3623) Grace-LSA body glue. Related: packet/grace_lsa.go -- the ext-1 opaque TLV codec this wraps. RFC: rfc/short/rfc3623.md sec A -- the Grace-LSA is a Type-9 link-local Opaque LSA,

Opaque Type 3 / Opaque ID 0, body = Grace Period (type 1) + Restart Reason (type 2)
always, plus IP Interface Address (type 3) on broadcast/NBMA/P2MP segments.

Design: plan/learned/1044-ospf-ext-9-graceful-restart.md -- GR restart-fact non-volatile storage. Related: auth_keystore.go -- the pkg/zefs blob-store pattern this reuses. RFC: rfc/short/rfc3623.md sec 2.1 (store the restart fact + grace period in NVS),

rfc/short/rfc5187.md sec 3.1 (LSA-ID->prefix preservation) / sec 3.2 (Interface-ID
preservation), persisted alongside the fact for the OSPFv3 family.

The blob is stored via the same pkg/zefs blob store as the RFC 7474 boot count (auth_keystore.go), keyed per engine (address family + instance) so a v4 and a v6 engine in one process do not clobber each other's fact.

Design: plan/learned/1044-ospf-ext-9-graceful-restart.md -- OSPFv3 GR preservation + v6 Grace-LSA. Related: gr_restarter.go (capture on prepare, restore on resume), origination_v6.go

(v6OriginateLinkLSA pattern), gr.go (grManager preserved Interface-ID map).

RFC: rfc/short/rfc5187.md sec 3.1 (LSA-ID -> prefix correspondence preservation),

sec 3.2 (Interface-ID preservation), sec 2.1/2.2 (native LS Type 0x000B Grace-LSA).

Design: plan/learned/1044-ospf-ext-9-graceful-restart.md -- GR restarting-router state machine. Related: gr.go (grManager), gr_nvs.go (restart fact), origination_v6.go (v6 self-LSA gate). RFC: rfc/short/rfc3623.md sec 2 (in-restart suppression), sec 2.1 (originate Grace-LSAs,

keep FIB, store NVS), sec 2.2 (three exit triggers), sec 2.3 (exit actions);
rfc/short/rfc5187.md sec 3.1/3.2 (OSPFv3 LSA-ID + Interface-ID preservation).

Design: plan/learned/1044-ospf-ext-9-graceful-restart.md -- `show ospf graceful-restart` renderer. Related: gr.go (grManager state), cmd_show.go + register.go (command wiring). RFC: rfc/short/rfc3623.md (restarter + helper state), rfc/short/rfc5187.md (OSPFv3).

Design: plan/learned/958-ospf-4-component-config.md -- OSPFv2 engine skeleton + dispatcher Related: transport/transport.go -- raw IPv4 transport consumed here RFC: rfc/short/rfc2328.md -- OSPFv2; rfc/short/rfc3101.md -- NSSA translator stability

Design: plan/learned/967-ospf-13-cli-diag-interop.md -- engine `show ospf ...` snapshots. Related: instance.go -- the engine that owns the neighbor table, LSDB, and SPF computer. Related: register.go -- OnExecuteCommand renders these snapshots for the show commands.

Design: plan/learned/1036-ospf-ext-12-multi-instance.md -- OSPFv2 Multi-Instance (RFC 6549): one full OSPFv2 engine per configured Instance ID, demuxed by the shared dispatcher rule. Related: instance.go -- the per-engine skeleton this file drives one-per-instance. Related: config.go -- ospfConfig.instanceIDSet / forInstance derive the per-instance set. RFC: rfc/short/rfc6549.md

Design: plan/learned/1037-ospf-ext-15-multi-af.md -- RFC 5838 multiple address families over OSPFv3. Related: dispatcher.go -- the per-instance Instance-ID demux (RFC 5340 §4.2.2) reused per AF. Related: register.go -- one v6-codec engine spawned per configured AF.

RFC 5838 carries several address families over the single OSPFv3 (IPv6) wire by mapping each AF to a reserved Instance-ID range and tagging its packets with the AF-bit in the Options field. This file owns the AF <-> Instance-ID-range mapping (§2.1), the per-AF Loc-RIB install family, the prefix address width, and the AF-bit emission rule (§2.5/§2.6).

RFC: rfc/short/rfc5838.md

Design: plan/learned/972-ospf-af-unify.md -- OSPFv3 (IPv6) Link-LSA + Network Intra-Area-Prefix origination. RFC: rfc/short/rfc5340.md (App A.4.9 Link-LSA, A.4.10 Intra-Area-Prefix-LSA)

Design: plan/learned/958-ospf-4-component-config.md -- OSPFv2 plugin registration Related: config.go -- typed config resolution Related: instance.go -- engine orchestration and packet dispatcher

Design: plan/learned/1037-ospf-ext-15-multi-af.md -- RFC 5838 per-AF engine lifecycle. RFC: rfc/short/rfc5838.md (§2 separate LSDB/neighbors per AF instance) Related: register.go -- runOSPFEngine drives this set from the plugin config callbacks. Related: multiaf.go -- the AF <-> Instance-ID-range mapping each engine is keyed by.

v6EngineSet owns the OSPFv3 (IPv6-transport) engine instances, one per configured RFC 5838 address family. Each engine is fully self-contained (its own LSDB, neighbor table, SPF, and Loc-RIB install family), so per-AF separation is structural: multi-AF is a fan-out of the single v6 engine, not a new LSDB key. The default IPv6-unicast AF preserves the single-instance IPv6-base behavior byte-for-byte when it is the only AF configured.

Index

Constants

View Source
const (
	DefaultReferenceBandwidth = uint32(100000)
	DefaultMaximumPaths       = uint8(8)
	DefaultSPFDelayMS         = uint32(50)
	DefaultSPFHoldMS          = uint32(200)
	DefaultSPFMaxHoldMS       = uint32(5000)
	DefaultMinLSIntervalMS    = uint32(5000)
	DefaultMinLSArrivalMS     = uint32(1000)
	DefaultExternalMetric     = uint32(20)
	DefaultDefaultMetric      = uint32(1)
	DefaultHelloInterval      = uint16(10)
	DefaultDeadInterval       = uint16(40)
	DefaultRetransmitInterval = uint16(5)
	DefaultTransmitDelay      = uint16(1)
	DefaultPriority           = uint8(1)
	// DefaultPollInterval is the RFC 2328 App C.5 PollInterval: the slower Hello rate
	// (seconds) at which an NBMA interface polls a configured but currently silent
	// neighbor.
	DefaultPollInterval = uint16(120)
	DefaultAreaCost     = uint32(1)
	// DefaultNSSAStabilityInterval is the RFC 3101 section 3.5 translator-stability
	// hysteresis (seconds) a newly demoted translator keeps translating.
	DefaultNSSAStabilityInterval = uint16(40)

	// BFD (RFC 5880 / RFC 5881) per-interface defaults. The config leaves are expressed
	// in milliseconds and stored as microseconds (api.SessionRequest is microsecond-valued),
	// so the 50 ms defaults become 50000 us. Detect multiplier 3 matches the BGP-BFD default.
	DefaultBFDMinTxUs    = uint32(50000)
	DefaultBFDMinRxUs    = uint32(50000)
	DefaultBFDMultiplier = uint8(3)
)
View Source
const (
	EventNeighborUp     = "neighbor-up"
	EventNeighborDown   = "neighbor-down"
	EventSPFRun         = "spf-run"
	EventLSDBChange     = "lsdb-change"
	EventInterfaceState = "interface-state"
	EventDRChange       = "dr-change"
	EventNeighborChange = "neighbor-change"
)
View Source
const DefaultRestartInterval = 120

DefaultRestartInterval is the RFC 3623 Appendix B.1 suggested default grace period (seconds).

View Source
const Namespace = "ospf"

Variables

View Source
var (
	ErrNotHello    = errors.New("ospf: packet is not a Hello")
	ErrNotDBDesc   = errors.New("ospf: packet is not a Database Description")
	ErrNotLSReq    = errors.New("ospf: packet is not a Link State Request")
	ErrNotLSUpdate = errors.New("ospf: packet is not a Link State Update")
	ErrNotLSAck    = errors.New("ospf: packet is not a Link State Ack")
)

ErrNot* are returned by the body decoders when the payload decodes to a packet of the wrong type. The dispatcher routes by header type before calling the per-type handler, so these only fire on a malformed or type-mismatched datagram (dropped as a decode failure).

View Source
var (
	ErrRouterIDRequired   = errors.New("ospf: router-id is required or must be derivable from an IPv4 interface address")
	ErrUndeclaredArea     = errors.New("ospf: interface references undeclared area")
	ErrDuplicateArea      = errors.New("ospf: duplicate canonical area")
	ErrNonIPv4Range       = errors.New("ospf: area range prefix must be IPv4")
	ErrInvalidNSSARole    = errors.New("ospf: nssa translate-role must be candidate, always, or never")
	ErrESNRequiresHMAC    = errors.New("ospf: key-chain extended-sequence (AuType 3) requires an hmac-sha algorithm")
	ErrKeyIDTooWide       = errors.New("ospf: AuType 2 key-id must be 0..255 (the on-wire Key ID is one octet); use extended-sequence for 32-bit key-ids")
	ErrKeyLifetimeFormat  = errors.New("ospf: key send/accept lifetime start/end must be an RFC3339 timestamp")
	ErrKeyRolloverGap     = errors.New("ospf: key-chain send-lifetime rollover gap (a key's send start must be at or before the previous key's send end so signing coverage never lapses; RFC 5709 §X / RFC 7210)")
	ErrInterfaceCostZero  = errors.New("ospf: interface cost must be greater than 0 (RFC 2328 App C.3)")
	ErrTransmitDelayZero  = errors.New("ospf: interface transmit-delay must be greater than 0 (RFC 2328 App C.3 InfTransDelay)")
	ErrSimplePasswordLen  = errors.New("ospf: simple-password (AuType 1) secret must be at most 8 octets (RFC 2328 App D); use md5/hmac-sha for longer keys")
	ErrInstanceIDRange    = errors.New("ospf: address-family instance-id is outside its RFC 5838 §2.1 range (ipv6-unicast 0-31, ipv6-multicast 32-63, ipv4-unicast 64-95, ipv4-multicast 96-127)")
	ErrNBMANoNeighbors    = errors.New("ospf: nbma interface requires at least one nbma-neighbor (RFC 2328 App C.6: NBMA has no multicast fallback, so with no configured neighbor it unicasts to nobody and forms no adjacency); use point-to-multipoint for multicast neighbor discovery")
	ErrGraceIntervalRange = errors.New("ospf: graceful-restart restart-interval must be 1..1800 seconds (RFC 3623 sec 2.1 / App B.1: SHOULD NOT exceed LSRefreshTime)")
	// Virtual-link config-time rejections (RFC 2328 section 15 / RFC 5340 section 4.2).
	ErrVirtualLinkTransitMissing  = errors.New("ospf: virtual-link transit area is not declared under areas")
	ErrVirtualLinkTransitBackbone = errors.New("ospf: virtual-link transit area must not be the backbone 0.0.0.0 (RFC 2328 App C.4)")
	ErrVirtualLinkTransitStub     = errors.New("ospf: virtual-link transit area must not be a stub or NSSA area (RFC 2328 section 15 / RFC 5340 section 4.2)")
	ErrVirtualLinkNotABR          = errors.New("ospf: virtual-link requires this router to be an area border router (an interface in two or more areas; RFC 2328 section 15)")
	ErrVirtualLinkSelfRouterID    = errors.New("ospf: virtual-link remote-router-id must not equal this router's own router-id (RFC 2328 section 15)")
)
View Source
var (
	// ErrIPsecIPv4Family rejects an IPsec block on an IPv4-family (OSPFv2) interface.
	ErrIPsecIPv4Family = errors.New("ospf: ipsec is an IPv6-family (OSPFv3) feature only (RFC 4552 §5); it cannot be configured on an IPv4-family interface")
	// ErrIPsecSPIReserved rejects an SPI in the RFC 4303 §2.1 reserved range 0..255.
	ErrIPsecSPIReserved = errors.New("ospf: ipsec spi must be 256..4294967295 (RFC 4303 §2.1 reserves 0..255)")
	// ErrIPsecProtocol rejects a protocol other than ah/esp.
	ErrIPsecProtocol = errors.New("ospf: ipsec protocol must be ah or esp (RFC 4552 §3)")
	// ErrIPsecAuthAlgo rejects an integrity algorithm outside sha1/sha256/sha384/sha512.
	ErrIPsecAuthAlgo = errors.New("ospf: ipsec algorithm must be sha1, sha256, sha384, or sha512")
	// ErrIPsecKeyHex rejects a non-hex key.
	ErrIPsecKeyHex = errors.New("ospf: ipsec key must be a hex string")
	// ErrIPsecKeyLength rejects an integrity key whose length does not match the algorithm.
	ErrIPsecKeyLength = errors.New("ospf: ipsec key length does not match the algorithm")
	// ErrIPsecEncAlgo rejects an encryption algorithm outside null/aes128/aes256.
	ErrIPsecEncAlgo = errors.New("ospf: ipsec encryption-algorithm must be null, aes128, or aes256")
	// ErrIPsecEncKeyHex rejects a non-hex encryption key.
	ErrIPsecEncKeyHex = errors.New("ospf: ipsec encryption-key must be a hex string")
	// ErrIPsecEncKeyLength rejects an encryption key whose length does not match the algorithm.
	ErrIPsecEncKeyLength = errors.New("ospf: ipsec encryption-key length does not match the encryption-algorithm")
	// ErrIPsecMissingEncKey rejects ESP confidentiality with no encryption key.
	ErrIPsecMissingEncKey = errors.New("ospf: ipsec esp with an encryption-algorithm requires an encryption-key")
	// ErrIPsecStrayEncKey rejects an encryption key with no (non-null) encryption algorithm.
	ErrIPsecStrayEncKey = errors.New("ospf: ipsec encryption-key set without an encryption-algorithm")
	// ErrIPsecAHConfidentiality rejects AH + confidentiality (RFC 4552 §4: only ESP).
	ErrIPsecAHConfidentiality = errors.New("ospf: ipsec AH cannot provide confidentiality; use esp for encryption (RFC 4552 §4)")
	// ErrIPsecMutualExclusion rejects IPsec and RFC 7166 on the same interface.
	ErrIPsecMutualExclusion = errors.New("ospf: an interface cannot configure both ipsec (RFC 4552) and a 7166 authentication key-chain; they are mutually exclusive auth paths")
)
View Source
var (
	NeighborUp   = events.Register[*neighborEvent](Namespace, EventNeighborUp)
	NeighborDown = events.Register[*neighborEvent](Namespace, EventNeighborDown)

	InterfaceState = events.Register[*interfaceEvent](Namespace, EventInterfaceState)
	DRChange       = events.Register[*interfaceEvent](Namespace, EventDRChange)
	NeighborChange = events.Register[*interfaceEvent](Namespace, EventNeighborChange)
)
View Source
var (
	ErrTERouterAddress     = errors.New("ospf: traffic-engineering router-address must be a valid IPv4 address")
	ErrTEMetricRange       = errors.New("ospf: traffic-engineering te-metric out of range (0..4294967295)")
	ErrTEAdminGroupRange   = errors.New("ospf: traffic-engineering admin-group out of range (0..4294967295)")
	ErrTERemoteASRange     = errors.New("ospf: traffic-engineering inter-as remote-as out of range (0..4294967295)")
	ErrTEInterASRemoteAS   = errors.New("ospf: traffic-engineering inter-as requires remote-as (RFC 5392 sec 3.3.1)")
	ErrTEInterASRemoteASBR = errors.New("ospf: traffic-engineering inter-as requires at least one remote-asbr (IPv4 or IPv6) (RFC 5392 sec 3.2.1)")
	ErrTEInterASScope      = errors.New("ospf: traffic-engineering inter-as scope must be area or as (RFC 5392 sec 3.1.1)")
	ErrTERemoteASBRv4      = errors.New("ospf: traffic-engineering inter-as remote-asbr-ipv4 must be a valid IPv4 address")
	ErrTERemoteASBRv6      = errors.New("ospf: traffic-engineering inter-as remote-asbr-ipv6 must be a valid IPv6 address")
)
View Source
var ErrExtSubTLVRegistered = errors.New("ospf: extended sub-TLV type already registered")

ErrExtSubTLVRegistered is returned when a consumer registers a sub-TLV type another consumer already owns.

View Source
var ErrExtSubTLVReserved = errors.New("ospf: extended sub-TLV type 0 is reserved")

ErrExtSubTLVReserved is returned when a consumer registers sub-TLV type 0, reserved in the RFC 7684 sec 6.2 / sec 6.5 sub-TLV registries.

View Source
var ErrOpaqueScopeInvalid = errors.New("ospf: invalid opaque scope (must be link/area/AS)")

ErrOpaqueScopeInvalid is returned when a consumer registers with a scope that is not one of the three RFC 5250 opaque scopes (link/area/AS).

View Source
var ErrOpaqueTypeRegistered = errors.New("ospf: opaque type already registered")

ErrOpaqueTypeRegistered is returned when a consumer registers an Opaque Type that another consumer already owns. RFC 5250 §9: an Opaque Type identifies one application.

View Source
var ErrRITLVRegistered = errors.New("ospf: RI TLV type already registered")

ErrRITLVRegistered is returned when a consumer registers a TLV type another consumer owns.

View Source
var ErrRITLVReserved = errors.New("ospf: RI TLV types 1 and 2 are reserved for the RI consumer")

ErrRITLVReserved is returned when a consumer registers TLV type 1 or 2, reserved for the RI consumer's own Informational (sec 2.4) / Functional (sec 2.6) Capabilities TLVs.

View Source
var ErrRITLVScopeInvalid = errors.New("ospf: invalid RI TLV scope (must be link/area/AS)")

ErrRITLVScopeInvalid is returned when a consumer registers with a scope that is not one of the RFC 5250 opaque flooding scopes (link/area/AS).

Functions

This section is empty.

Types

type Codec

type Codec interface {
	DecodeHeader(payload []byte) (Header, error)
	// DecodeHello decodes a Hello packet body onto the AF-neutral types.Hello superset.
	// OSPFv2 fills NetworkMask; OSPFv3 fills InterfaceID. The shared neighbor FSM applies
	// AF-aware validation to the result, so the engine never sees a version-specific body.
	DecodeHello(payload []byte) (types.Hello, error)
	// DecodeDBDesc / DecodeLSReq / DecodeLSAck decode the neighbor-FSM framing bodies onto the
	// shared types. The carried LSA headers (DBDesc, LSAck) and request entries (LSReq) are
	// AF-neutral; only the wire layout differs (v2 vs v6), so the engine's NSM consumes one
	// shape regardless of version.
	DecodeDBDesc(payload []byte) (types.DBDesc, error)
	DecodeLSReq(payload []byte) (types.LSReq, error)
	DecodeLSAck(payload []byte) (types.LSAck, error)
	// DecodeLSUpdate decodes a Link State Update onto packet.LSUpdate (a slice of packet.LSA).
	// packet.LSA is AF-neutral in structure (shared types.LSAHeader + Body + RawBytes); the
	// typed LSA body decode stays version-specific behind the AFPrefixStrategy. The v4 adapter
	// returns ospf/packet's own LSAs; the v6 adapter converts ospfv3 LSAs to the same shape.
	DecodeLSUpdate(payload []byte) (packet.LSUpdate, error)
	VerifyChecksum(payload []byte, src, dst netip.Addr) bool
	// IsV6 reports whether this codec is the OSPFv3 (IPv6) codec. The engine uses it to mark
	// each interface's address family so the neighbor FSM applies AF-aware checks (e.g. the
	// Network Mask match is OSPFv2-only; OSPFv3 carries an Interface ID instead).
	IsV6() bool
}

Codec is the engine's view of the version-specific wire codec: it decodes the common header and verifies the packet checksum. The OSPFv2 checksum covers the datagram itself, so the v4 adapter ignores src/dst; the OSPFv3 checksum is the IPv6 upper-layer checksum bound to the datagram's source and destination (RFC 5340 sec A.3.1), so the v6 adapter (a later phase) consumes them.

type Header struct {
	Type       PacketType
	Length     uint16
	RouterID   types.RouterID
	AreaID     types.AreaID
	Checksum   uint16
	InstanceID uint8
}

Header is the address-family-neutral OSPF common header the engine dispatches on. It carries only the fields the shared engine reads -- Type (dispatch), AreaID (area check), RouterID (neighbor identity), Length/Checksum (validation). Version-specific header details stay inside the codec: OSPFv2's AuType/Auth (RFC 2328 App D) are read from the raw payload by the auth path, and the Instance ID (OSPFv3 RFC 5340 sec 2.5, OSPFv2 RFC 6549 sec 2) is surfaced here as InstanceID for the engine's per-interface demux -- one header location per family, one shared demux rule.

type OpaqueScope

type OpaqueScope uint8

OpaqueScope is the RFC 5250 §3 flooding scope of an opaque LSA. Its underlying value is the LS type that carries the scope: 9 link-local, 10 area-local, 11 AS-wide.

const (
	// OpaqueScopeLink is the RFC 5250 Type-9 link-local flooding scope.
	OpaqueScopeLink OpaqueScope = OpaqueScope(types.LSTypeOpaqueLink)
	// OpaqueScopeArea is the RFC 5250 Type-10 area-local flooding scope.
	OpaqueScopeArea OpaqueScope = OpaqueScope(types.LSTypeOpaqueArea)
	// OpaqueScopeAS is the RFC 5250 Type-11 AS-wide flooding scope.
	OpaqueScopeAS OpaqueScope = OpaqueScope(types.LSTypeOpaqueAS)
)

func (OpaqueScope) String

func (s OpaqueScope) String() string

String returns a stable lowercase scope name.

type PacketType

type PacketType uint8

PacketType is the address-family-neutral OSPF packet type. The 1..5 type codes are identical across OSPFv2 (RFC 2328 sec A.3.1) and OSPFv3 (RFC 5340 sec A.3.1).

const (
	PacketTypeHello    PacketType = 1
	PacketTypeDBDesc   PacketType = 2
	PacketTypeLSReq    PacketType = 3
	PacketTypeLSUpdate PacketType = 4
	PacketTypeLSAck    PacketType = 5
)
type TEDLink struct {
	AdvertisingRouter types.RouterID
	Area              types.AreaID
	Scope             OpaqueScope
	OpaqueType        uint8
	OpaqueID          uint32
	Usable            bool
	Link              packet.TELink
}

TEDLink is a read-only, value-typed view of one TED link entry for a consumer (the show handler or the future rsvpte admission consumer). It carries the LSA identity, the flooding scope, the RFC 5250 sec 5 usability, and a copy of the decoded link attributes.

type TEDRouterAddress

type TEDRouterAddress struct {
	Router  types.RouterID `json:"router"`
	Address [4]byte        `json:"address"`
}

TEDRouterAddress is one advertising router's RFC 3630 sec 2.4.1 Router Address.

type Transport

type Transport interface {
	SendPacket(name string, dst netip.Addr, payload []byte) error
	// SendPacketRouted sends a virtual-link packet ROUTED across a transit area (RFC 2328
	// section 8.1 / RFC 5340 section 2.9): IPv4 uses a TTL > 1 path distinct from the
	// TTL-1 link-local socket; IPv6 uses the global source src and a hop limit > 1 (src is
	// ignored by the IPv4 transport, which lets the kernel pick the source).
	SendPacketRouted(name string, dst, src netip.Addr, payload []byte) error
	Receive() <-chan transport.RawPacket
	EnableInterface(name string)
	DisableInterface(name string)
	HandleLinkUp(name string) error
	HandleLinkDown(name string) error
	JoinAllDRouters(name string) error
	LeaveAllDRouters(name string) error
	RecordDrop(name, reason string)
	InterfaceNameByIfIndex(ifindex int) (string, bool)
	InterfaceOpen(name string) bool
	OpenInterfaceCount() int
	SubscribeIfaceEvents(eb ze.EventBus) func()
	SetSigner(fn func(name string, payload []byte) []byte)
	SetMetrics(reg metrics.Registry)
	OnInterfaceUp(fn func(ifindex int, name string))
	OnInterfaceDown(fn func(ifindex int, name string))
	Close()
}

Transport is the engine's view of the per-address-family raw transport. It is the union of what the engine calls directly and what it hands to the iface and neighbor sender interfaces (SendPacket / JoinAllDRouters / LeaveAllDRouters), so an engine instance can drive either the OSPFv2 (`ospf/transport`) or, once the receive type is made AF-neutral (a later phase), the OSPFv3 (`ospfv3/transport`) transport.

Directories

Path Synopsis
Package iface implements the per-interface OSPF runtime, including the interface state machine, Hello exchange, DR election, and neighbor management.
Package iface implements the per-interface OSPF runtime, including the interface state machine, Hello exchange, DR election, and neighbor management.
Package lsdb implements the per-area OSPF link-state database with LSA flooding, origination, and aging.
Package lsdb implements the per-area OSPF link-state database with LSA flooding, origination, and aging.
Package neighbor implements the OSPFv2 Neighbor State Machine and database-exchange scaffolding.
Package neighbor implements the OSPFv2 Neighbor State Machine and database-exchange scaffolding.
Package packet is the OSPFv2 packet and LSA wire codec: the protocol's serialization boundary.
Package packet is the OSPFv2 packet and LSA wire codec: the protocol's serialization boundary.
events
Design: plan/learned/964-ospf-10-as-external-asbr.md -- OSPF redistevents producer wiring.
Design: plan/learned/964-ospf-10-as-external-asbr.md -- OSPF redistevents producer wiring.
Package spf implements OSPF shortest-path-first computation, route selection, and loop-free-alternate backup calculation.
Package spf implements OSPF shortest-path-first computation, route selection, and loop-free-alternate backup calculation.
Package sr holds the address-family-neutral control plane for OSPF Segment Routing (RFC 8665 for the IPv4 family, RFC 8666 for the IPv6 family).
Package sr holds the address-family-neutral control plane for OSPF Segment Routing (RFC 8665 for the IPv4 family, RFC 8666 for the IPv6 family).
Package transport is the OSPFv2 raw IPv4 transport byte pipe.
Package transport is the OSPFv2 raw IPv4 transport byte pipe.
Package types contains pure OSPFv2 value types and checksum algorithms.
Package types contains pure OSPFv2 value types and checksum algorithms.
v3
packet
Package packet is the OSPFv3 (RFC 5340) packet and LSA wire codec: the protocol's serialization boundary.
Package packet is the OSPFv3 (RFC 5340) packet and LSA wire codec: the protocol's serialization boundary.
transport
Package transport implements the OSPFv3 raw IPv6 socket transport that sends and receives OSPF datagrams per interface.
Package transport implements the OSPFv3 raw IPv6 socket transport that sends and receives OSPF datagrams per interface.
types
Package types holds the OSPFv3 (RFC 5340) leaf value types shared by every later OSPFv3 child spec: Router ID, Area ID, Instance ID, Interface ID, Link State ID, the 16-bit LS Type with embedded flooding scope, the comparable LSA key, sequence numbers, ages, the 24-bit Options field, IPv6 prefix length/options, and metrics.
Package types holds the OSPFv3 (RFC 5340) leaf value types shared by every later OSPFv3 child spec: Router ID, Area ID, Instance ID, Interface ID, Link State ID, the 16-bit LS Type with embedded flooding scope, the comparable LSA key, sequence numbers, ages, the 24-bit Options field, IPv6 prefix length/options, and metrics.
Package wire defines the address-family-neutral RawPacket handed from an OSPF transport up to the shared engine.
Package wire defines the address-family-neutral RawPacket handed from an OSPF transport up to the shared engine.
Package yang embeds and registers the OSPF plugin's YANG command and configuration schemas.
Package yang embeds and registers the OSPF plugin's YANG command and configuration schemas.

Jump to

Keyboard shortcuts

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