netconf

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: BSD-2-Clause-Views Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

DefaultCapabilities sets the default capabilities of the client library

View Source
var ErrBadChunk = errors.New("bad chunk")

ErrBadChunk indicates a chunked framing protocol error occurred

Functions

func SSHConfigPubKeyFile

func SSHConfigPubKeyFile(user string, file string, passphrase string) (*ssh.ClientConfig, error)

SSHConfigPubKeyFile is a convenience function that takes a username, private key and passphrase and returns a new ssh.ClientConfig setup to pass credentials to DialSSH

func SplitChunked

func SplitChunked(endOfMessage func()) bufio.SplitFunc

SplitChunked returns a bufio.SplitFunc suitable for decoding "chunked framing" NETCONF transport streams.

endOfMessage will be called at the end of each NETCONF message, and must not be nil.

It must only be used with bufio.Scanner who have a buffer of at least 16 bytes (rarely is this a concern).

Types

type ReadWriteCloser

type ReadWriteCloser struct {
	io.Reader
	io.WriteCloser
}

ReadWriteCloser represents a combined IO Reader and WriteCloser

func NewReadWriteCloser

func NewReadWriteCloser(r io.Reader, w io.WriteCloser) *ReadWriteCloser

NewReadWriteCloser creates a new combined IO Reader and WriteCloser from the provided objects

type Session

type Session struct {
	Transport    Transport
	SessionID    int
	Capabilities []string
}

Session represents a NETCONF sessions with a remote NETCONF server

func DialSSH

func DialSSH(target string, config *ssh.ClientConfig) (*Session, error)

DialSSH creates a new NETCONF session using an SSH Transport. See TransportSSH.Dial for arguments.

func DialSSHTimeout

func DialSSHTimeout(target string, config *ssh.ClientConfig, timeout time.Duration) (*Session, error)

DialSSHTimeout creates a new NETCONF session using an SSH Transport with timeout. See TransportSSH.Dial for arguments. The timeout value is used for both connection establishment and Read/Write operations.

func NewSession

func NewSession(t Transport) *Session

NewSession creates a new NETCONF session using the provided transport layer.

func (*Session) Close

func (s *Session) Close() error

Close is used to close and end a session

func (*Session) ExecRPC

func (s *Session) ExecRPC(operation interface{}) (*message.RPCReply, error)

ExecRPC is used to execute an RPC method

type Transport

type Transport interface {
	Send([]byte) error
	Receive() ([]byte, error)
	Close() error
	ReceiveHello() (*message.Hello, error)
	SendHello(hello *message.Hello) error
	SetVersion(version string)
}

Transport interface defines what characteristics make up a NETCONF transport layer object.

type TransportSSH

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

TransportSSH maintains the information necessary to communicate with the remote device over SSH

func (*TransportSSH) Chunked

func (t *TransportSSH) Chunked(b []byte) ([]byte, error)

func (*TransportSSH) Close

func (t *TransportSSH) Close() error

Close closes an existing SSH session and socket if they exist.

func (*TransportSSH) Dial

func (t *TransportSSH) Dial(target string, config *ssh.ClientConfig) error

Dial connects and establishes SSH sessions

target can be an IP address (e.g.) 172.16.1.1 which utilizes the default NETCONF over SSH port of 830. Target can also specify a port with the following format <host>:<port (e.g. 172.16.1.1:22)

config takes a ssh.ClientConfig connection. See documentation for go.crypto/ssh for documentation. There is a helper function SSHConfigPassword thar returns a ssh.ClientConfig for simple username/password authentication

func (*TransportSSH) Receive

func (t *TransportSSH) Receive() ([]byte, error)

func (*TransportSSH) ReceiveHello

func (t *TransportSSH) ReceiveHello() (*message.Hello, error)

func (*TransportSSH) Send

func (t *TransportSSH) Send(data []byte) error

Send a well formatted NETCONF rpc message as a slice of bytes adding on the necessary framing messages.

func (*TransportSSH) SendHello

func (t *TransportSSH) SendHello(hello *message.Hello) error

func (*TransportSSH) SetVersion

func (t *TransportSSH) SetVersion(version string)

func (*TransportSSH) WaitForBytes

func (t *TransportSSH) WaitForBytes(b []byte) ([]byte, error)

func (*TransportSSH) WaitForFunc

func (t *TransportSSH) WaitForFunc(f func([]byte) (int, error)) ([]byte, error)

func (*TransportSSH) WaitForRegexp

func (t *TransportSSH) WaitForRegexp(re *regexp.Regexp) ([]byte, [][]byte, error)

func (*TransportSSH) WaitForString

func (t *TransportSSH) WaitForString(s string) (string, error)

func (*TransportSSH) Writeln

func (t *TransportSSH) Writeln(b []byte) (int, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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