transport

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package transport provides the NETCONF transport layer.

The transport layer provides "clean" Reader and Writer interfaces to respectively decode and encode traffic for the underlying transport layer. The message layer reads and writes to these transport layer objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Reader

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

Reader is a NETCONF transport decoder offering an io.Reader interface.

NETCONF sessions exchange request/response and broadcast messages via the transport. Data sent on the wire is encoded according to the framing mode presently chosen; initially (and always, for :base:1.0 sessions), messages are sent verbatim and terminated by the end of message token. After the <hello> message, :base:1.1 sessions use a chunked framing mechanism with the same message semantics (see RFC6242, s4.2).

The Reader decodes data using the current framing protocol, making it available to users via the Read call.

func NewReader

func NewReader(source io.Reader, eomCallback func()) *Reader

NewReader returns a new Reader given the source io.Reader and a function to be called after each message

func (*Reader) Read

func (r *Reader) Read(b []byte) (n int, err error)

func (*Reader) SetFramingMode

func (r *Reader) SetFramingMode(chunked bool)

SetFramingMode sets the NETCONF transport framing to end of message mode (chunked=false) or chunked framing mode (chunked=true).

type Writer

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

Writer is a RFC6242 NETCONF transport encoder, implementing io.WriteCloser.

A Writer takes a destination io.WriteCloser and encodes input appropriately, with a consistent API no matter the Encoder's current framing mode.

It supports both RFC4742 NETCONF 1.0 end-of-message framing as well as NETCONF 1.1 chunked framing.

func NewWriter

func NewWriter(dst io.WriteCloser) *Writer

NewWriter returns a new RFC6242 Encoder (inline filter) writing to the destination dst. Encoder implements io.Writer.

func (*Writer) Close

func (w *Writer) Close() error

Close closes the underlying writer

func (*Writer) SetFramingMode

func (w *Writer) SetFramingMode(chunked bool)

SetFramingMode sets the framing mode of the Encoder. If chunked is true, chunked framing will be used, else end-of-message frming is used.

func (*Writer) Write

func (w *Writer) Write(b []byte) (n int, err error)

Write writes b to the Encoder's destination using the current framing mode.

func (*Writer) WriteEnd

func (w *Writer) WriteEnd() (int, error)

WriteEnd writes the appropriate end of transmission message for the Encoder's current framing mode. It must be called at the end of each request/response message sent by a NETCONF client or server.

It returns the number of bytes written, along with any error.

Jump to

Keyboard shortcuts

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