Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrExistingWriter is returned from MsgWriter when there is already a // message io.WriterCloser that hasn't been properly closed yet. ErrExistingWriter = errors.New("netconf: existing message writer still open") // ErrInvalidIO is returned when a write or read operation is called on // message io.Reader or a message io.Writer when they are no longer valid. // (i.e a new reader or writer has been obtained) ErrInvalidIO = errors.New("netconf: read/write on invalid io") )
var ErrMalformedChunk = errors.New("netconf: invalid chunk")
ErrMalformedChunk represents a message that invalid as defined in the chunk framing in RFC6242
Functions ¶
This section is empty.
Types ¶
type Framer ¶
type Framer struct {
// contains filtered or unexported fields
}
Framer is a wrapper used for transports that implement the framing defined in RFC6242. This supports End-of-Message and Chucked framing methods and will move from End-of-Message to Chunked framing after the `Upgrade` method has been called.
This is not a transport on it's own (missing the `Close` method) and is intended to be embedded into other transports.
func NewFramer ¶
NewFramer return a new Framer to be used against the given io.Reader and io.Writer.
func (*Framer) DebugCapture ¶
DebugCapture will copy all *framed* input/output to the the given `io.Writers` for sent or recv data. Either sent of recv can be nil to not capture any data. Useful for displaying to a screen or capturing to a file for debugging.
This needs to be called before `MsgReader` or `MsgWriter`.
func (*Framer) MsgReader ¶
func (t *Framer) MsgReader() (io.ReadCloser, error)
MsgReader returns a new io.Reader that is good for reading exactly one netconf message.
Only one reader can be used at a time. When this is called with an existing reader then the underlying reader is advanced to the start of the next message and invalidates the old reader before returning a new one.
type Transport ¶
type Transport interface { // MsgReader returns a new io.Reader to read a single netconf message. There // can only be a single reader for a transport at a time. Obtaining a new // reader should advance the stream to the start of the next message.` MsgReader() (io.ReadCloser, error) // MsgWriter returns a new io.WriteCloser to write a single netconf message. // After writing a message the writer must be closed. Implementers should // make sure only a single writer can be obtained and return a error if // multiple writers are attempted. MsgWriter() (io.WriteCloser, error) // Close will close the underlying transport. Close() error }
Transport is used for a netconf.Session to talk to the device. It is message oriented to allow for framing and other details to happen on a per message basis.