netconf

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: Apache-2.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxChunkSize is the default maximum size of a single chunk in base:1.1 framing
	// Note: This is a local policy, not an RFC requirement. Some peers may send larger chunks.
	MaxChunkSize = 4096

	// MaxMessageSize is the maximum size of a complete NETCONF message
	MaxMessageSize = 16 * 1024 * 1024 // 16 MB

	// MaxChunkHeaderLength is the maximum length of a chunk header line (#<len>\n),
	// excluding the leading LF chunk separator.
	// This prevents DoS attacks via unbounded header lines
	MaxChunkHeaderLength = 64 // Enough for "#" + 18 digits (max int64) + "\n"

	// EOMMarker is the end-of-message marker for base:1.0 framing
	EOMMarker = "]]>]]>"

	// ChunkEnd is the end-of-chunks marker for base:1.1 framing, including leading LF.
	ChunkEnd = "\n##\n"
)
View Source
const (
	// NETCONF capabilities
	CapabilityBase10     = "urn:ietf:params:netconf:base:1.0"
	CapabilityBase11     = "urn:ietf:params:netconf:base:1.1"
	CapabilityCandidate  = "urn:ietf:params:netconf:capability:candidate:1.0"
	CapabilityValidate   = "urn:ietf:params:netconf:capability:validate:1.1"
	CapabilityRollback   = "urn:ietf:params:netconf:capability:rollback-on-error:1.0"
	CapabilityXPath      = "urn:ietf:params:netconf:capability:xpath:1.0"
	CapabilityArcaRouter = "urn:arca:router:config:1.0?module=arca-router&revision=2025-12-27"
	// Arca-specific capability for the safe absolute XPath subset accepted by filters.
	CapabilityArcaXPathFilterSubset = "urn:arca:router:netconf:capability:xpath-filter-subset:1.0"

	// NETCONF namespace
	NetconfNamespace = "urn:ietf:params:xml:ns:netconf:base:1.0"
)
View Source
const (
	DatastoreRunning   = "running"
	DatastoreCandidate = "candidate"
	DatastoreStartup   = "startup"
)

Datastore target constants

View Source
const (
	RoleAdmin    = "admin"
	RoleOperator = "operator"
	RoleReadOnly = "read-only"
)

Role constants for user authorization

View Source
const (
	NetconfBaseNS    = "urn:ietf:params:xml:ns:netconf:base:1.0"
	IETFInterfacesNS = "urn:ietf:params:xml:ns:yang:ietf-interfaces"
	IETFRoutingNS    = "urn:ietf:params:xml:ns:yang:ietf-routing"
	IETFSystemNS     = "urn:ietf:params:xml:ns:yang:ietf-system"
	ArcaConfigNS     = "urn:arca:router:config:1.0"
	ArcaStateNS      = "urn:arca:router:state:1.0"
)

XML Namespace constants per Phase 2 plan

View Source
const (
	MaxXMLDepth      = 50
	MaxXMLElements   = 10000
	MaxXMLAttributes = 20
	MaxXMLSize       = 10 * 1024 * 1024 // 10MB
)

XML size and depth limits per Phase 2 plan Section 10.1

View Source
const (
	MaxXPathExpressionSize     = 4096
	MaxXPathEvaluationDuration = 2 * time.Second
)

Variables

This section is empty.

Functions

func ApplyConfigEdit

func ApplyConfigEdit(existing, edit *config.Config, defaultOp DefaultOperation) (*config.Config, error)

ApplyConfigEdit applies edit-config changes to existing config based on default-operation.

func ApplySubtreeFilter

func ApplySubtreeFilter(xmlData []byte, filter *Filter) ([]byte, error)

ApplySubtreeFilter applies the supported RFC 6241 subtree filtering subset using namespace-aware element path matching.

func ConfigToText

func ConfigToText(cfg *config.Config) (string, error)

ConfigToText converts config.Config to text format (set commands) This implements Phase 2 Step 4: Datastore Bridge Layer

func ConfigToXML

func ConfigToXML(cfg *config.Config, filter *Filter) ([]byte, error)

ConfigToXML converts internal config to NETCONF <data> content with optional filtering This implements Phase 2 Step 3: XML↔Config Conversion

func FormatLockoutError

func FormatLockoutError(unlockAt time.Time) error

FormatLockoutError returns a user-friendly lockout error message

func GetClientCapabilities

func GetClientCapabilities(clientHello *Hello) []string

GetClientCapabilities returns a human-readable list of client capabilities

func GetOperationalData

func GetOperationalData(ctx context.Context, filter *Filter) ([]byte, error)

GetOperationalData builds operational state without a datastore-backed server. It is kept for tests and callers that only need local system state.

func HashPassword

func HashPassword(password string) (string, error)

HashPassword generates an argon2id hash for the given password.

func MarshalHello

func MarshalHello(hello *Hello) ([]byte, error)

MarshalHello marshals a Hello message to XML

func MarshalReply

func MarshalReply(reply *RPCReply) ([]byte, error)

MarshalReply serializes RPCReply to XML bytes

func NegotiateBaseVersion

func NegotiateBaseVersion(clientHello *Hello) string

NegotiateBaseVersion determines the NETCONF base version to use based on client capabilities Returns "1.1" if client supports base:1.1, otherwise "1.0"

func TextToConfig

func TextToConfig(text string) (*config.Config, error)

TextToConfig converts text format (set commands) to config.Config This implements Phase 2 Step 4: Datastore Bridge Layer

func ValidateClientHello

func ValidateClientHello(clientHello *Hello) error

ValidateClientHello validates a client <hello> message

func ValidateConfig

func ValidateConfig(cfg *config.Config) error

ValidateConfig performs depth and size validation per Phase 2 Step 3

func ValidateFilterDepthAndSize

func ValidateFilterDepthAndSize(rpcName string, filter *Filter) error

ValidateFilterDepthAndSize validates filter depth and size per Phase 2 Step 3

func ValidateProtocolNamespace

func ValidateProtocolNamespace(elem xml.Name) error

ValidateProtocolNamespace validates protocol element namespace per Phase 2 Step 2

func ValidateXMLSecurity

func ValidateXMLSecurity(data []byte) error

ValidateXMLSecurity performs token-based DTD/ENTITY detection per Phase 2 Step 2

func VerifyPassword

func VerifyPassword(password, encodedHash string) (bool, error)

VerifyPassword verifies a password against an argon2id hash. Returns true if the password matches, false otherwise.

func XMLToConfig

func XMLToConfig(xmlData []byte, defaultOp DefaultOperation) (*config.Config, error)

XMLToConfig converts NETCONF XML to internal config structure.

Types

type BFDOperationalState added in v0.7.0

type BFDOperationalState struct {
	LastRun           time.Time
	ConfiguredPeers   int
	ObservedPeers     int
	UpPeers           int
	DownPeers         int
	SessionDownEvents uint64
	RxFailPackets     uint64
	Peers             []BFDPeerOperationalState
	Issues            []string
	LastError         string
}

BFDOperationalState holds cached BFD convergence and failure counters.

type BFDPeerOperationalState added in v0.7.0

type BFDPeerOperationalState struct {
	Peer              string
	LocalAddress      string
	Interface         string
	VRF               string
	Status            string
	Diagnostic        string
	RemoteDiagnostic  string
	Observed          bool
	Up                bool
	SessionDownEvents uint64
	RxFailPackets     uint64
}

BFDPeerOperationalState describes one BFD peer in operational output.

type BGPNeighborOperationalState added in v0.7.0

type BGPNeighborOperationalState struct {
	PeerAddress    string
	PeerAS         uint32
	State          string
	UptimeSecs     uint64
	PrefixReceived uint32
	PrefixSent     uint32
}

BGPNeighborOperationalState describes one BGP peer in operational output.

type CommitHook added in v0.5.0

type CommitHook func(ctx context.Context, req *CommitHookRequest, persist func(context.Context) (string, error)) (string, error)

CommitHook can wrap the datastore commit path. The persist callback performs the legacy datastore commit after the hook has applied any external state.

type CommitHookRequest added in v0.5.0

type CommitHookRequest struct {
	SessionID  string
	User       string
	SourceIP   string
	Message    string
	ConfigText string
}

CommitHookRequest contains the data needed to apply a NETCONF candidate through an external commit coordinator before it is persisted.

type CommitRequest

type CommitRequest struct {
	XMLName        xml.Name  `xml:"commit"`
	Confirmed      *struct{} `xml:"confirmed"`
	ConfirmTimeout *string   `xml:"confirm-timeout"`
	Persist        *string   `xml:"persist"`
	PersistID      *string   `xml:"persist-id"`
}

CommitRequest represents <commit> RPC

type ConfigElement

type ConfigElement struct {
	XMLName        xml.Name   `xml:"config"`
	Attrs          []xml.Attr `xml:",any,attr"`
	InheritedAttrs []xml.Attr `xml:"-"`
	Content        []byte     `xml:",innerxml"`
}

ConfigElement represents <config> element in edit-config

func (ConfigElement) XML added in v0.5.0

func (c ConfigElement) XML() ([]byte, error)

type CopyConfigRequest

type CopyConfigRequest struct {
	XMLName xml.Name `xml:"copy-config"`
	Target  Target   `xml:"target"`
	Source  Source   `xml:"source"`
}

CopyConfigRequest represents <copy-config> RPC

func (*CopyConfigRequest) SetInheritedNamespaceAttrs added in v0.9.0

func (r *CopyConfigRequest) SetInheritedNamespaceAttrs(attrs []xml.Attr)

type DataReply

type DataReply struct {
	XMLName xml.Name `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 data"`
	Content []byte   `xml:",innerxml"`
}

DataReply represents <data> element in response

type DatastoreLockReleaser

type DatastoreLockReleaser interface {
	ReleaseLock(ctx context.Context, target string, sessionID string) error
}

DatastoreLockReleaser interface for session cleanup (minimal subset) This avoids circular dependency with full datastore.Datastore interface

type DefaultOperation

type DefaultOperation string

DefaultOperation for edit-config

const (
	DefaultOpMerge   DefaultOperation = "merge"
	DefaultOpReplace DefaultOperation = "replace"
	DefaultOpNone    DefaultOperation = "none"
)

type DeleteConfigRequest

type DeleteConfigRequest struct {
	XMLName xml.Name `xml:"delete-config"`
	Target  Target   `xml:"target"`
}

DeleteConfigRequest represents <delete-config> RPC

type DiscardChangesRequest

type DiscardChangesRequest struct {
	XMLName struct{} `xml:"discard-changes"`
}

DiscardChangesRequest represents <discard-changes> RPC

type EditConfigRequest

type EditConfigRequest struct {
	XMLName          xml.Name          `xml:"edit-config"`
	Target           Target            `xml:"target"`
	DefaultOperation *DefaultOperation `xml:"default-operation"`
	TestOption       *TestOption       `xml:"test-option"`
	ErrorOption      *ErrorOption      `xml:"error-option"`
	Config           ConfigElement     `xml:"config"`
}

EditConfigRequest represents <edit-config> RPC

func (*EditConfigRequest) SetInheritedNamespaceAttrs added in v0.5.0

func (r *EditConfigRequest) SetInheritedNamespaceAttrs(attrs []xml.Attr)

type ErrorInfo

type ErrorInfo struct {
	BadElement       string `xml:"bad-element,omitempty"`
	BadAttribute     string `xml:"bad-attribute,omitempty"`
	BadNamespace     string `xml:"bad-namespace,omitempty"`
	LockOwnerSession string `xml:"lock-owner-session,omitempty"`
}

ErrorInfo contains structured error details per RFC 6241

type ErrorOption

type ErrorOption string

ErrorOption for edit-config

const (
	ErrorStop            ErrorOption = "stop-on-error"
	ErrorContinue        ErrorOption = "continue-on-error"
	ErrorRollbackOnError ErrorOption = "rollback-on-error"
)

type ErrorSeverity

type ErrorSeverity string

ErrorSeverity represents NETCONF error-severity values per RFC 6241

const (
	ErrorSeverityError   ErrorSeverity = "error"
	ErrorSeverityWarning ErrorSeverity = "warning"
)

type ErrorTag

type ErrorTag string

ErrorTag represents NETCONF error-tag values per RFC 6241

const (
	ErrorTagInvalidValue          ErrorTag = "invalid-value"
	ErrorTagMalformedMessage      ErrorTag = "malformed-message"
	ErrorTagOperationNotSupported ErrorTag = "operation-not-supported"
	ErrorTagAccessDenied          ErrorTag = "access-denied"
	ErrorTagLockDenied            ErrorTag = "lock-denied"
	ErrorTagInUse                 ErrorTag = "in-use"
	ErrorTagOperationFailed       ErrorTag = "operation-failed"
	ErrorTagMissingElement        ErrorTag = "missing-element"
	ErrorTagMissingAttribute      ErrorTag = "missing-attribute"
	ErrorTagUnknownElement        ErrorTag = "unknown-element"
	ErrorTagUnknownAttribute      ErrorTag = "unknown-attribute"
	ErrorTagUnknownNamespace      ErrorTag = "unknown-namespace"
)

type ErrorType

type ErrorType string

ErrorType represents NETCONF error-type values per RFC 6241

const (
	ErrorTypeProtocol    ErrorType = "protocol"
	ErrorTypeApplication ErrorType = "application"
	ErrorTypeTransport   ErrorType = "transport"
	ErrorTypeRPC         ErrorType = "rpc"
)

type Filter

type Filter struct {
	Type           string     `xml:"type,attr,omitempty"`
	Select         string     `xml:"select,attr,omitempty"` // For xpath filters
	Attrs          []xml.Attr `xml:",any,attr"`
	InheritedAttrs []xml.Attr `xml:"-"`
	Content        []byte     `xml:",innerxml"`
}

Filter represents optional <filter> element in get-config/get

func (*Filter) Validate

func (f *Filter) Validate(rpcName string) error

Validate validates filter constraints per design document

type FramingReader

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

FramingReader reads NETCONF messages using either base:1.0 (EOM) or base:1.1 (chunked) framing

func NewFramingReader

func NewFramingReader(r io.Reader, baseVersion string) *FramingReader

NewFramingReader creates a new framing reader for the specified NETCONF base version

func (*FramingReader) ReadMessage

func (fr *FramingReader) ReadMessage() ([]byte, error)

ReadMessage reads a complete NETCONF message using the appropriate framing protocol

func (*FramingReader) SetBaseVersion

func (fr *FramingReader) SetBaseVersion(baseVersion string)

SetBaseVersion updates the base version without recreating the reader This preserves any buffered data when switching from base:1.0 to base:1.1 after hello negotiation, which is critical for handling pipelined RPCs.

type FramingWriter

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

FramingWriter writes NETCONF messages using either base:1.0 (EOM) or base:1.1 (chunked) framing

func NewFramingWriter

func NewFramingWriter(w io.Writer, baseVersion string) *FramingWriter

NewFramingWriter creates a new framing writer for the specified NETCONF base version

func (*FramingWriter) SetBaseVersion

func (fw *FramingWriter) SetBaseVersion(baseVersion string)

SetBaseVersion updates the base version without recreating the writer This allows switching framing modes after hello negotiation.

func (*FramingWriter) WriteMessage

func (fw *FramingWriter) WriteMessage(data []byte) error

WriteMessage writes a NETCONF message using the appropriate framing protocol

type GetConfigRequest

type GetConfigRequest struct {
	XMLName xml.Name `xml:"get-config"`
	Source  Source   `xml:"source"`
	Filter  *Filter  `xml:"filter"`
}

GetConfigRequest represents <get-config> RPC

func (*GetConfigRequest) SetInheritedNamespaceAttrs added in v0.5.0

func (r *GetConfigRequest) SetInheritedNamespaceAttrs(attrs []xml.Attr)

type GetRequest

type GetRequest struct {
	XMLName xml.Name `xml:"get"`
	Filter  *Filter  `xml:"filter"`
}

GetRequest represents <get> RPC for operational data

func (*GetRequest) SetInheritedNamespaceAttrs added in v0.5.0

func (r *GetRequest) SetInheritedNamespaceAttrs(attrs []xml.Attr)

type Hello

type Hello struct {
	XMLName      xml.Name `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 hello"`
	Capabilities struct {
		Capability []string `xml:"capability"`
	} `xml:"capabilities"`
	SessionID uint32 `xml:"session-id,omitempty"` // RFC 6241: session-id is an integer (uint32)
}

Hello represents a NETCONF <hello> message

func ServerHello

func ServerHello(sessionID uint32) *Hello

ServerHello creates a server <hello> message with the given session ID

func ServerHelloWithOptions added in v0.10.0

func ServerHelloWithOptions(sessionID uint32, options HelloOptions) *Hello

ServerHelloWithOptions creates a server <hello> with optional capabilities.

func UnmarshalHello

func UnmarshalHello(data []byte) (*Hello, error)

UnmarshalHello unmarshals XML data into a Hello message

func (*Hello) HasCapability

func (h *Hello) HasCapability(capability string) bool

HasCapability checks if the hello message contains a specific capability

type HelloOptions added in v0.10.0

type HelloOptions struct {
	AdvertiseStandardXPath bool
	DisableStandardXPath   bool
}

HelloOptions controls optional NETCONF capability advertisement.

type InterfaceOperationalCounters added in v0.6.0

type InterfaceOperationalCounters struct {
	RxPackets uint64
	TxPackets uint64
	RxBytes   uint64
	TxBytes   uint64
	RxErrors  uint64
	TxErrors  uint64
	Drops     uint64
}

InterfaceOperationalCounters holds live interface counters.

type InterfaceOperationalQueues added in v0.6.0

type InterfaceOperationalQueues struct {
	Rx []InterfaceOperationalRxQueue
	Tx []InterfaceOperationalTxQueue
}

InterfaceOperationalQueues holds RX/TX queue placement for an interface.

type InterfaceOperationalRxQueue added in v0.6.0

type InterfaceOperationalRxQueue struct {
	QueueID  uint32
	WorkerID uint32
	Mode     string
}

InterfaceOperationalRxQueue maps an RX queue to a VPP worker.

type InterfaceOperationalState added in v0.6.0

type InterfaceOperationalState struct {
	Name        string
	AdminStatus string
	OperStatus  string
	MAC         string
	QoSProfile  string
	IPv4TableID uint32
	IPv6TableID uint32
	Counters    *InterfaceOperationalCounters
	Queues      *InterfaceOperationalQueues
}

InterfaceOperationalState is a transport-neutral interface state snapshot.

type InterfaceOperationalTxQueue added in v0.6.0

type InterfaceOperationalTxQueue struct {
	QueueID uint32
	Shared  bool
	Threads []uint32
}

InterfaceOperationalTxQueue maps a TX queue to VPP worker threads.

type LockRequest

type LockRequest struct {
	XMLName struct{} `xml:"lock"`
	Target  Target   `xml:"target"`
}

LockRequest represents <lock> RPC

type NETCONFSession

type NETCONFSession struct {
	ID              string // UUID v4 (internal identifier)
	NumericID       uint32 // RFC 6241 session-id (integer for NETCONF protocol)
	Username        string
	Role            string // admin, operator, read-only
	CreatedAt       time.Time
	LastUsed        time.Time
	IdleTimeout     time.Duration // Idle timeout (e.g., 30m)
	AbsoluteTimeout time.Duration // Absolute max lifetime (e.g., 24h)
	BaseVersion     string        // "1.0" or "1.1" (NETCONF protocol version)
	// contains filtered or unexported fields
}

NETCONFSession represents a NETCONF session

func (*NETCONFSession) AddLock

func (s *NETCONFSession) AddLock(target string)

AddLock adds a datastore lock to session tracking

func (*NETCONFSession) GetLocks

func (s *NETCONFSession) GetLocks() []string

GetLocks returns the list of locked datastores

func (*NETCONFSession) RemoteAddr

func (s *NETCONFSession) RemoteAddr() string

RemoteAddr returns the remote address (for logging)

func (*NETCONFSession) RemoveLock

func (s *NETCONFSession) RemoveLock(target string)

RemoveLock removes a datastore lock from session tracking

func (*NETCONFSession) UpdateLastUsed

func (s *NETCONFSession) UpdateLastUsed()

UpdateLastUsed updates the last used timestamp (called on each RPC)

type OSPFNeighborOperationalState added in v0.7.0

type OSPFNeighborOperationalState struct {
	RouterID     string
	Address      string
	Interface    string
	State        string
	Role         string
	Priority     uint32
	DeadTimeSecs uint64
	UptimeSecs   uint64
}

OSPFNeighborOperationalState describes one OSPF adjacency in operational output.

type OperationalStateProvider added in v0.6.0

type OperationalStateProvider interface {
	// InterfaceStates returns interface state keyed by management-plane interface name.
	InterfaceStates(ctx context.Context) (map[string]*InterfaceOperationalState, error)
	// Routes returns live route table entries.
	Routes(ctx context.Context) ([]RouteOperationalState, error)
	// BGPNeighbors returns live BGP neighbor state.
	BGPNeighbors(ctx context.Context) ([]BGPNeighborOperationalState, error)
	// OSPFNeighbors returns live OSPFv2 or OSPFv3 neighbor state.
	OSPFNeighbors(ctx context.Context, ipv6 bool) ([]OSPFNeighborOperationalState, error)
	// BFDStatus returns cached BFD protocol operational state.
	BFDStatus(ctx context.Context) (*BFDOperationalState, error)
}

OperationalStateProvider supplies live state for NETCONF <get> replies.

type PublicKeyRecord

type PublicKeyRecord struct {
	ID          int64
	Username    string
	Algorithm   string
	KeyData     string
	Fingerprint string
	Comment     string
	Enabled     bool
	CreatedAt   int64
}

PublicKeyRecord represents a stored public key record

type RPC

type RPC struct {
	XMLName   xml.Name `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 rpc"`
	MessageID string   `xml:"message-id,attr"`
	Operation xml.Name `xml:",any"`
	Content   []byte   `xml:",innerxml"`

	NamespaceAttrs []xml.Attr `xml:"-"`
	ReplyAttrs     []xml.Attr `xml:"-"`
}

RPC represents a NETCONF <rpc> request envelope

func ParseAndValidateRPC

func ParseAndValidateRPC(data []byte) (*RPC, error)

ParseAndValidateRPC is a convenience function that parses and performs basic validation

func ParseRPC

func ParseRPC(data []byte) (*RPC, error)

ParseRPC parses NETCONF RPC from XML bytes with security checks

func ReadRPCFromFraming

func ReadRPCFromFraming(reader io.Reader, baseVersion string) (*RPC, error)

ReadRPCFromFraming reads and parses RPC from a framing reader

func (*RPC) GetOperationName

func (r *RPC) GetOperationName() string

GetOperationName returns the RPC operation name (e.g., "get-config", "edit-config")

func (*RPC) GetOperationNamespace

func (r *RPC) GetOperationNamespace() string

GetOperationNamespace returns the RPC operation namespace

func (*RPC) UnmarshalOperation

func (r *RPC) UnmarshalOperation(v interface{}) error

UnmarshalOperation unmarshals the RPC operation content into a specific struct

func (*RPC) ValidateOperationNamespace

func (r *RPC) ValidateOperationNamespace() error

ValidateOperationNamespace checks if operation is in NETCONF namespace

type RPCError

type RPCError struct {
	XMLName       xml.Name      `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 rpc-error"`
	ErrorType     ErrorType     `xml:"error-type"`
	ErrorTag      ErrorTag      `xml:"error-tag"`
	ErrorSeverity ErrorSeverity `xml:"error-severity"`
	ErrorAppTag   string        `xml:"error-app-tag,omitempty"` // RFC 6241: direct child of rpc-error
	ErrorPath     string        `xml:"error-path,omitempty"`
	ErrorMessage  string        `xml:"error-message,omitempty"`
	ErrorInfo     *ErrorInfo    `xml:"error-info,omitempty"`
}

RPCError represents a NETCONF <rpc-error> structure per RFC 6241

func ErrAccessDenied

func ErrAccessDenied(rpcName, reason string) *RPCError

ErrAccessDenied returns error for RBAC denial

func ErrBackendValidationFailed

func ErrBackendValidationFailed(message string) *RPCError

ErrBackendValidationFailed returns error for backend (VPP/FRR) validation failure

func ErrConfigValidationFailed added in v0.9.0

func ErrConfigValidationFailed(rpcName, message string) *RPCError

ErrConfigValidationFailed returns error for config validation failure.

func ErrConfirmedCommitNotSupported added in v0.9.0

func ErrConfirmedCommitNotSupported(element string) *RPCError

ErrConfirmedCommitNotSupported returns an error for confirmed-commit options when the capability is not advertised.

func ErrDTDNotAllowed

func ErrDTDNotAllowed() *RPCError

ErrDTDNotAllowed returns error for DTD/DOCTYPE in XML

func ErrDatastoreError

func ErrDatastoreError(message string) *RPCError

ErrDatastoreError returns error for internal datastore error

func ErrInvalidFilter

func ErrInvalidFilter(rpcName, message string) *RPCError

ErrInvalidFilter returns error for invalid filter content

func ErrInvalidNamespace

func ErrInvalidNamespace(namespace string) *RPCError

ErrInvalidNamespace returns error for XML namespace mismatch

func ErrInvalidTarget

func ErrInvalidTarget(rpcName, target string) *RPCError

ErrInvalidTarget returns error for unsupported datastore target

func ErrLockDenied

func ErrLockDenied(target, rpcName string, hasTargetElement bool) *RPCError

ErrLockDenied returns error when lock is not acquired for write operation rpcName should be the operation name (edit-config, copy-config, delete-config, commit, discard-changes) hasTargetElement indicates if the RPC has an explicit <target> element in its XML structure

func ErrLockDeniedForLock

func ErrLockDeniedForLock(target string, ownerNumericID uint32) *RPCError

ErrLockDeniedForLock returns error for lock conflict (used by lock RPC itself)

func ErrLockDeniedForUnlock

func ErrLockDeniedForUnlock(target string, ownerNumericID uint32) *RPCError

ErrLockDeniedForUnlock returns error for lock conflict (used by unlock RPC)

func ErrLockDeniedWithOwner

func ErrLockDeniedWithOwner(target, rpcName string, ownerNumericID uint32, hasTargetElement bool) *RPCError

ErrLockDeniedWithOwner returns error when lock is held by another session rpcName should be the operation name (edit-config, copy-config, delete-config, commit, discard-changes) hasTargetElement indicates if the RPC has an explicit <target> element in its XML structure If ownerNumericID is 0, omits lock-owner-session (unknown/closed session)

func ErrLockTimeout

func ErrLockTimeout(target string) *RPCError

ErrLockTimeout returns error for lock timeout

func ErrMalformedMessage

func ErrMalformedMessage(message string) *RPCError

ErrMalformedMessage returns XML parse error

func ErrMalformedMessageWithElement

func ErrMalformedMessageWithElement(message, element string) *RPCError

ErrMalformedMessageWithElement returns XML parse error with bad element

func ErrMissingAttribute added in v0.5.0

func ErrMissingAttribute(element, attribute string) *RPCError

ErrMissingAttribute returns error for missing required attribute

func ErrMissingElement

func ErrMissingElement(rpcName, element string) *RPCError

ErrMissingElement returns error for missing required element

func ErrOperationFailed

func ErrOperationFailed(message string) *RPCError

ErrOperationFailed is a helper for generic operation failures

func ErrStartupNotSupported added in v0.9.0

func ErrStartupNotSupported(rpcName, container string) *RPCError

ErrStartupNotSupported returns error for startup datastore operations when the startup capability is not advertised.

func ErrTimeout

func ErrTimeout(message string) *RPCError

ErrTimeout returns error for operation timeout

func ErrTransportClosed

func ErrTransportClosed() *RPCError

ErrTransportClosed returns error for transport/session cleanup

func ErrUnknownAttribute added in v0.5.0

func ErrUnknownAttribute(path, attribute string) *RPCError

ErrUnknownAttribute returns error for unknown/unsupported attribute

func ErrUnknownElement

func ErrUnknownElement(path, element string) *RPCError

ErrUnknownElement returns error for unknown/unsupported element

func ErrUnknownRPC

func ErrUnknownRPC(rpcName string) *RPCError

ErrUnknownRPC returns error for unsupported RPC operation

func ErrUnsupportedConfigElement

func ErrUnsupportedConfigElement(element string) *RPCError

ErrUnsupportedConfigElement returns error for unknown config element

func ErrUnsupportedFilterType

func ErrUnsupportedFilterType(rpcName, filterType string) *RPCError

ErrUnsupportedFilterType returns error for unsupported filter type

func ErrValidationFailed

func ErrValidationFailed(message string) *RPCError

ErrValidationFailed returns error for validation failure

func ErrWritableRunningNotSupported

func ErrWritableRunningNotSupported(rpcName, container string) *RPCError

ErrWritableRunningNotSupported returns error for running datastore write operations when writable-running is not advertised.

func NewRPCError

func NewRPCError(errType ErrorType, errTag ErrorTag, message string) *RPCError

NewRPCError creates a new RPCError with required fields

func (*RPCError) Error

func (e *RPCError) Error() string

Error implements the error interface for RPCError

func (*RPCError) WithAppTag

func (e *RPCError) WithAppTag(tag string) *RPCError

WithAppTag adds error-app-tag as direct child of rpc-error (RFC 6241)

func (*RPCError) WithBadAttribute

func (e *RPCError) WithBadAttribute(attribute string) *RPCError

WithBadAttribute adds bad-attribute to error-info

func (*RPCError) WithBadElement

func (e *RPCError) WithBadElement(element string) *RPCError

WithBadElement adds bad-element to error-info

func (*RPCError) WithBadNamespace

func (e *RPCError) WithBadNamespace(namespace string) *RPCError

WithBadNamespace adds bad-namespace to error-info

func (*RPCError) WithLockOwner

func (e *RPCError) WithLockOwner(sessionID string) *RPCError

WithLockOwner adds lock-owner-session to error-info

func (*RPCError) WithPath

func (e *RPCError) WithPath(path string) *RPCError

WithPath adds error-path to the error

type RPCReply

type RPCReply struct {
	XMLName   xml.Name    `xml:"urn:ietf:params:xml:ns:netconf:base:1.0 rpc-reply"`
	MessageID string      `xml:"message-id,attr"`
	OK        *struct{}   `xml:"ok,omitempty"`
	Data      *DataReply  `xml:"data,omitempty"`
	Errors    []*RPCError `xml:"rpc-error,omitempty"`
	Attrs     []xml.Attr  `xml:"-"`
}

RPCReply represents a NETCONF <rpc-reply> envelope

func NewDataReply

func NewDataReply(messageID string, data []byte) *RPCReply

NewDataReply creates a successful <rpc-reply> with <data>

func NewErrorReply

func NewErrorReply(messageID string, err *RPCError) *RPCReply

NewErrorReply creates an error <rpc-reply> with one <rpc-error>

func NewMultiErrorReply

func NewMultiErrorReply(messageID string, errors []*RPCError) *RPCReply

NewMultiErrorReply creates an error <rpc-reply> with multiple <rpc-error>

func NewOKReply

func NewOKReply(messageID string) *RPCReply

NewOKReply creates a successful <rpc-reply> with <ok/>

func (*RPCReply) WithAttributes added in v0.5.0

func (r *RPCReply) WithAttributes(attrs []xml.Attr) *RPCReply

type RateLimiter

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

RateLimiter tracks authentication failures and enforces lockouts

func NewRateLimiter

func NewRateLimiter(config *SSHConfig) *RateLimiter

NewRateLimiter creates a new rate limiter with the given configuration

func (*RateLimiter) CheckIP

func (rl *RateLimiter) CheckIP(ip string) (bool, time.Time)

CheckIP checks if an IP address is currently locked out Returns true if allowed, false if locked out

func (*RateLimiter) CheckUser

func (rl *RateLimiter) CheckUser(username string) (bool, time.Time)

CheckUser checks if a user is currently locked out Returns true if allowed, false if locked out

func (*RateLimiter) GetStats

func (rl *RateLimiter) GetStats() RateLimiterStats

GetStats returns current rate limiter statistics

func (*RateLimiter) RecordFailure

func (rl *RateLimiter) RecordFailure(ip, username string) (ipLocked, userLocked bool)

RecordFailure records an authentication failure for an IP and user Returns true if the IP or user should be locked out

func (*RateLimiter) RecordSuccess

func (rl *RateLimiter) RecordSuccess(ip, username string)

RecordSuccess records a successful authentication (clears failure history)

func (*RateLimiter) Stop

func (rl *RateLimiter) Stop()

Stop stops the rate limiter cleanup goroutine

type RateLimiterStats

type RateLimiterStats struct {
	IPsTracked    int
	IPsLocked     int
	UsersTracked  int
	UsersLocked   int
	LockoutWindow time.Duration
}

RateLimiterStats contains rate limiter statistics

type RouteOperationalState added in v0.7.0

type RouteOperationalState struct {
	Prefix    string
	NextHop   string
	Protocol  string
	Metric    uint32
	Interface string
	Active    bool
}

RouteOperationalState describes one live route entry or nexthop path.

type RoutingInstanceOperationalState added in v0.7.0

type RoutingInstanceOperationalState struct {
	Name               string
	InstanceType       string
	RouteDistinguisher string
	IPv4TableID        uint32
	IPv6TableID        uint32
	ImportTargets      []string
	ExportTargets      []string
	ImportPolicies     []string
	ExportPolicies     []string
	Interfaces         []string
}

RoutingInstanceOperationalState describes one routing-instance table mapping.

type SSHConfig

type SSHConfig struct {
	ListenAddr                  string // Default: ":830"
	HostKeyPath                 string // Default: "/var/lib/arca-router/ssh_host_ed25519_key"
	UserDBPath                  string // Default: "/var/lib/arca-router/users.db"
	DatastorePath               string // Default: "/var/lib/arca-router/config.db"
	DatastoreConfig             *datastore.Config
	SkipDatastoreStartupCleanup bool // For embedded servers whose parent owns datastore startup
	// AdvertiseStandardXPath controls standard :xpath capability advertisement.
	// It defaults to true for v0.10; set DisableStandardXPath to suppress it.
	AdvertiseStandardXPath bool
	DisableStandardXPath   bool
	IdleTimeout            time.Duration // Default: 30m (idle timeout)
	AbsoluteTimeout        time.Duration // Default: 24h (max session lifetime)
	MaxSessions            int           // Default: 100

	// Lockout configuration
	IPFailureLimit    int           // Default: 3 (IP-based lockout threshold)
	IPLockoutWindow   time.Duration // Default: 5m (IP failure tracking window)
	UserFailureLimit  int           // Default: 5 (User-based lockout threshold)
	UserLockoutWindow time.Duration // Default: 10m (User failure tracking window)
	LockoutDuration   time.Duration // Default: 15m (lockout duration for both IP and user)

	SSHCiphers      []string // Default: modern AEAD ciphers plus AES-CTR for NETCONF client interop
	SSHKeyExchanges []string // Default: ["curve25519-sha256", "ecdh-sha2-nistp256"]
	SSHMACs         []string // Default: ["hmac-sha2-256-etm@openssh.com", "hmac-sha2-512-etm@openssh.com"]
}

SSHConfig holds SSH server configuration

func DefaultSSHConfig

func DefaultSSHConfig() *SSHConfig

DefaultSSHConfig returns default SSH server configuration

type SSHServer

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

SSHServer manages SSH connections for NETCONF Note: This server is not designed to be restarted after Stop() is called. Create a new instance if restart is needed.

func NewSSHServer

func NewSSHServer(config *SSHConfig) (*SSHServer, error)

NewSSHServer creates a new SSH server instance

func (*SSHServer) GetMetrics

func (s *SSHServer) GetMetrics() ServerMetrics

GetMetrics returns current server metrics All metrics are thread-safe and can be called concurrently

func (*SSHServer) HealthCheck

func (s *SSHServer) HealthCheck() error

HealthCheck verifies the server is healthy and operational This method checks: 1. Server is actively accepting connections (not stopped or failed) 2. User database is accessible and healthy 3. Session count is within configured limits

func (*SSHServer) SetCommitHook added in v0.5.0

func (s *SSHServer) SetCommitHook(h CommitHook)

SetCommitHook installs a commit coordinator for NETCONF commits.

func (*SSHServer) SetOperationalStateProvider added in v0.6.0

func (s *SSHServer) SetOperationalStateProvider(provider OperationalStateProvider)

SetOperationalStateProvider installs a live-state source for <get> replies.

func (*SSHServer) Start

func (s *SSHServer) Start(ctx context.Context) error

Start starts the SSH server

func (*SSHServer) Stop

func (s *SSHServer) Stop() error

Stop stops the SSH server gracefully

type Server

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

Server represents NETCONF server with RPC dispatch

func NewServer

func NewServer(ds datastore.Datastore, sm *SessionManager) *Server

NewServer creates a new NETCONF server

func (*Server) HandleRPC

func (s *Server) HandleRPC(ctx context.Context, sess *Session, rpc *RPC) *RPCReply

HandleRPC dispatches RPC to appropriate handler with RBAC enforcement

func (*Server) SetCommitHook added in v0.5.0

func (s *Server) SetCommitHook(h CommitHook)

SetCommitHook installs a commit coordinator for NETCONF commits.

func (*Server) SetOperationalStateProvider added in v0.6.0

func (s *Server) SetOperationalStateProvider(provider OperationalStateProvider)

SetOperationalStateProvider installs a live-state source for <get> replies.

type ServerMetrics

type ServerMetrics struct {
	TotalConnections     uint64 // Total TCP connections accepted since server start
	SuccessfulHandshakes uint64 // Successful SSH protocol handshakes (not authentication - NoClientAuth mode)
	FailedHandshakes     uint64 // Failed SSH handshakes (protocol errors, not authentication)
	ActiveConnections    int32  // Currently active SSH connections
	ActiveSessions       int    // Currently active NETCONF sessions
	ListenAddr           string // Server listen address
	IsListening          bool   // Whether server is currently accepting connections (Start/Stop state)
}

ServerMetrics contains server health and performance metrics

type Session

type Session = NETCONFSession

Session represents an alias for NETCONFSession (for RPC handlers)

type SessionManager

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

SessionManager manages NETCONF sessions

func NewSessionManager

func NewSessionManager(config *SSHConfig, ds DatastoreLockReleaser, log *logger.Logger) *SessionManager

NewSessionManager creates a new session manager

func (*SessionManager) CloseAll

func (sm *SessionManager) CloseAll()

CloseAll closes all active sessions and stops cleanup

func (*SessionManager) CloseSession

func (sm *SessionManager) CloseSession(id string) error

CloseSession closes a specific session by UUID

func (*SessionManager) CloseSessionByNumericID

func (sm *SessionManager) CloseSessionByNumericID(numericID uint32) error

CloseSessionByNumericID closes a specific session by numeric ID (RFC 6241) Returns error if session not found (for RFC 6241 invalid-value error)

func (*SessionManager) Count

func (sm *SessionManager) Count() int

Count returns the number of active sessions

func (*SessionManager) Create

func (sm *SessionManager) Create(username, role string, conn ssh.Conn, channel ssh.Channel) *NETCONFSession

Create creates a new NETCONF session

func (*SessionManager) Get

func (sm *SessionManager) Get(id string) (*NETCONFSession, bool)

Get retrieves a session by UUID

func (*SessionManager) GetByNumericID

func (sm *SessionManager) GetByNumericID(numericID uint32) (*NETCONFSession, bool)

GetByNumericID retrieves a session by numeric ID (RFC 6241 session-id)

func (*SessionManager) StartCleanup

func (sm *SessionManager) StartCleanup(ctx context.Context, wg *sync.WaitGroup)

StartCleanup starts the session cleanup goroutine

func (*SessionManager) UpdateLastUsed

func (sm *SessionManager) UpdateLastUsed(id string)

UpdateLastUsed updates the last used timestamp for a session

type Source

type Source struct {
	Running   *struct{}      `xml:"running"`
	Candidate *struct{}      `xml:"candidate"`
	Startup   *struct{}      `xml:"startup"`
	Config    *ConfigElement `xml:"config"`
}

Source represents <source> element in get-config, copy-config, and validate.

func (*Source) GetDatastore

func (s *Source) GetDatastore() (string, error)

GetDatastore returns the datastore name from Source

type Target

type Target struct {
	Running   *struct{} `xml:"running"`
	Candidate *struct{} `xml:"candidate"`
	Startup   *struct{} `xml:"startup"`
}

Target represents <target> element in edit-config/lock/unlock

func (*Target) GetDatastore

func (t *Target) GetDatastore() (string, error)

GetDatastore returns the datastore name from Target

type TestOption

type TestOption string

TestOption for edit-config

const (
	TestSet         TestOption = "set"
	TestTestThenSet TestOption = "test-then-set"
	TestTestOnly    TestOption = "test-only"
)

type UnlockRequest

type UnlockRequest struct {
	XMLName struct{} `xml:"unlock"`
	Target  Target   `xml:"target"`
}

UnlockRequest represents <unlock> RPC

type User

type User struct {
	Username     string
	PasswordHash string
	Role         string // RoleAdmin, RoleOperator, or RoleReadOnly
	Enabled      bool
	CreatedAt    int64
	UpdatedAt    int64
}

User represents a user account

type UserDatabase

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

UserDatabase manages user authentication data

func NewUserDatabase

func NewUserDatabase(path string, log *logger.Logger) (*UserDatabase, error)

NewUserDatabase creates a new user database connection

func (*UserDatabase) AddPublicKey

func (udb *UserDatabase) AddPublicKey(username, algorithm, keyData, fingerprint, comment string) error

AddPublicKey adds a public key for a user

func (*UserDatabase) Close

func (udb *UserDatabase) Close() error

Close closes the database connection

func (*UserDatabase) CountUsers

func (udb *UserDatabase) CountUsers() (int, error)

CountUsers returns the total number of users

func (*UserDatabase) CreateUser

func (udb *UserDatabase) CreateUser(username, passwordHash, role string) error

CreateUser creates a new user

func (*UserDatabase) DeleteUser

func (udb *UserDatabase) DeleteUser(username string) error

DeleteUser deletes a user

func (*UserDatabase) GetPublicKey

func (udb *UserDatabase) GetPublicKey(fingerprint string) (*PublicKeyRecord, error)

GetPublicKey retrieves a specific public key by fingerprint

func (*UserDatabase) GetUser

func (udb *UserDatabase) GetUser(username string) (*User, error)

GetUser retrieves a user by username

func (*UserDatabase) HealthCheck

func (udb *UserDatabase) HealthCheck() error

HealthCheck verifies the database connection is healthy

func (*UserDatabase) Initialize

func (udb *UserDatabase) Initialize() error

Initialize initializes the database schema

func (*UserDatabase) ListPublicKeys

func (udb *UserDatabase) ListPublicKeys(username string) ([]PublicKeyRecord, error)

ListPublicKeys lists all public keys for a user

func (*UserDatabase) ListUsers

func (udb *UserDatabase) ListUsers() ([]User, error)

ListUsers lists all users (without password hashes) Use limit=0 and offset=0 to get all users (backward compatible)

func (*UserDatabase) ListUsersPaginated

func (udb *UserDatabase) ListUsersPaginated(limit, offset int) ([]User, error)

ListUsersPaginated lists users with pagination support limit=0 means no limit, offset=0 means start from beginning

func (*UserDatabase) LogAuthFailure

func (udb *UserDatabase) LogAuthFailure(username, sourceIP, reason string)

LogAuthFailure logs a failed authentication event

func (*UserDatabase) LogAuthFailureWithMethod

func (udb *UserDatabase) LogAuthFailureWithMethod(username, sourceIP, method, reason string)

LogAuthFailureWithMethod logs a failed authentication event with specified method

func (*UserDatabase) LogAuthSuccess

func (udb *UserDatabase) LogAuthSuccess(username, sourceIP string)

LogAuthSuccess logs a successful authentication event

func (*UserDatabase) LogAuthSuccessWithMethod

func (udb *UserDatabase) LogAuthSuccessWithMethod(username, sourceIP, method string)

LogAuthSuccessWithMethod logs a successful authentication event with specified method

func (*UserDatabase) RemovePublicKey

func (udb *UserDatabase) RemovePublicKey(fingerprint string) error

RemovePublicKey removes a public key by fingerprint

func (*UserDatabase) SetAuditLogger

func (udb *UserDatabase) SetAuditLogger(logger *audit.Logger)

SetAuditLogger sets the audit logger for persistent audit trail

func (*UserDatabase) UpdatePublicKeyStatus

func (udb *UserDatabase) UpdatePublicKeyStatus(fingerprint string, enabled bool) error

UpdatePublicKeyStatus updates the enabled status of a public key

func (*UserDatabase) UpdateUser

func (udb *UserDatabase) UpdateUser(username, passwordHash, role string, enabled bool) error

UpdateUser updates a user's information

func (*UserDatabase) VerifyPassword

func (udb *UserDatabase) VerifyPassword(username, password string) (*User, error)

VerifyPassword verifies a user's password Returns generic "authentication failed" error to prevent user enumeration attacks

func (*UserDatabase) VerifyPasswordWithReason

func (udb *UserDatabase) VerifyPasswordWithReason(username, password string) (*User, string, error)

VerifyPasswordWithReason verifies a user's password and returns a detailed reason for failure Used by SSH authentication callback for audit logging Implements timing attack mitigation by performing dummy hash verification for non-existent users

func (*UserDatabase) VerifyPublicKeyAuth

func (udb *UserDatabase) VerifyPublicKeyAuth(username, keyData string) (*User, string, error)

VerifyPublicKeyAuth verifies public key authentication for a user Returns the user and reason string (empty if successful)

type ValidateRequest

type ValidateRequest struct {
	XMLName struct{} `xml:"validate"`
	Source  Source   `xml:"source"`
}

ValidateRequest represents <validate> RPC

func (*ValidateRequest) SetInheritedNamespaceAttrs added in v0.9.0

func (r *ValidateRequest) SetInheritedNamespaceAttrs(attrs []xml.Attr)

type XPathFilter

type XPathFilter struct {
	// Path segments (e.g., ["interfaces", "interface", "name"])
	Segments []string
	// Namespace URI per path segment when a namespace prefix was used.
	SegmentNamespaces []string

	// Predicates per segment (e.g., map[segmentIndex]map["name"]="ge-0/0/0")
	// Supports multiple simple key-value predicates per segment.
	Predicates map[int]map[string]string
	// Namespace URI per predicate key when a namespace prefix was used.
	PredicateNamespaces map[int]map[string]string
}

XPathFilter represents the safe XPath-like NETCONF filter subset advertised by arca-router. It supports model-rooted paths and simple equality predicates, not full XPath 1.0.

func ParseXPathFilter

func ParseXPathFilter(path string) (*XPathFilter, error)

ParseXPathFilter parses the safe absolute-path XPath subset. Supported formats: - /interfaces - /interfaces/interface - /interfaces/interface[name='ge-0/0/0'] - /interfaces/interface[name='ge-0/0/0'][unit='0'] - /routing-options/static/route[prefix='10.0.0.0/24'] - /if:interfaces/if:interface[if:name='ge-0/0/0']

Not supported by the advertised subset: - Functions (count(), contains(), etc.) - Complex boolean expressions

func ParseXPathFilterWithContext added in v0.9.0

func ParseXPathFilterWithContext(path string, namespaceAttrs []xml.Attr) (*XPathFilter, error)

func (*XPathFilter) MatchesElement

func (f *XPathFilter) MatchesElement(elementPath []string) bool

MatchesElement checks if the filter matches a given element path For example: - Filter /interfaces matches <interfaces>...</interfaces> - Filter /interfaces/interface matches <interfaces><interface>...</interface></interfaces>

func (*XPathFilter) MatchesSection added in v0.9.0

func (f *XPathFilter) MatchesSection(elementPath []string) bool

MatchesSection checks whether the XPath points at the given element path, one of its ancestors, or one of its descendants. Section-level pruning uses this to include parent containers for child XPath selections.

type YANGValidator

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

YANGValidator provides YANG model validation capabilities

func GetGlobalValidator

func GetGlobalValidator() (*YANGValidator, error)

GetGlobalValidator returns the singleton YANG validator instance This validator is initialized once and reused across the application

func NewYANGValidator

func NewYANGValidator() (*YANGValidator, error)

NewYANGValidator creates a new YANG validator with arca-router and the local dependency stubs needed to resolve its IETF augment/import references.

func (*YANGValidator) GetArcaRouterModel

func (v *YANGValidator) GetArcaRouterModel() (*yang.Module, error)

GetArcaRouterModel returns the main arca-router YANG module

func (*YANGValidator) GetModel

func (v *YANGValidator) GetModel(moduleName string) (*yang.Module, error)

GetModel returns the parsed YANG module for programmatic access

func (*YANGValidator) ListModules

func (v *YANGValidator) ListModules() []string

ListModules returns the names of all loaded YANG modules

func (*YANGValidator) ValidateConfig

func (v *YANGValidator) ValidateConfig(xmlData []byte) error

ValidateConfig validates configuration XML against the implemented NETCONF schema subset and the internal semantic config rules.

func (*YANGValidator) ValidateElementPath

func (v *YANGValidator) ValidateElementPath(path string) error

ValidateElementPath validates that an XPath-like element path is valid according to the implemented YANG path schema.

func (*YANGValidator) ValidateElementPathWithContext added in v0.9.0

func (v *YANGValidator) ValidateElementPathWithContext(path string, namespaceAttrs []xml.Attr) error

ValidateElementPathWithContext validates an XPath-like element path using explicit namespace declarations for prefixed path and predicate names.

Jump to

Keyboard shortcuts

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