ndr

package
v2.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2020 License: Apache-2.0 Imports: 10 Imported by: 23

Documentation

Overview

Package ndr provides the ability to unmarshal NDR encoded byte steams into Go data structures

Index

Constants

View Source
const (
	TagConformant = "conformant"
	TagVarying    = "varying"
	TagPointer    = "pointer"
	TagPipe       = "pipe"
)

Struct tag values

View Source
const (
	SizeBool   = 1
	SizeChar   = 1
	SizeUint8  = 1
	SizeUint16 = 2
	SizeUint32 = 4
	SizeUint64 = 8
	SizeEnum   = 2
	SizeSingle = 4
	SizeDouble = 8
	SizePtr    = 4
)

Byte sizes of primitive types

View Source
const (
	TagEncapsulated = "encapsulated"
	TagUnionTag     = "unionTag"
	TagUnionField   = "unionField"
)

Union related constants such as struct tag values

Variables

This section is empty.

Functions

This section is empty.

Types

type CommonHeader

type CommonHeader struct {
	Version             uint8
	Endianness          binary.ByteOrder
	CharacterEncoding   uint8
	FloatRepresentation uint8
	HeaderLength        uint16
	Filler              []byte
}

CommonHeader implements the NDR common header: https://msdn.microsoft.com/en-us/library/cc243889.aspx

type Decoder

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

Decoder unmarshals NDR byte stream data into a Go struct representation

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder creates a new instance of a NDR Decoder.

func (*Decoder) Decode

func (dec *Decoder) Decode(s interface{}) error

Decode unmarshals the NDR encoded bytes into the pointer of a struct provided.

type Malformed

type Malformed struct {
	EText string
}

Malformed implements the error interface for malformed NDR encoding errors.

func Errorf

func Errorf(format string, a ...interface{}) Malformed

Errorf formats an error message into a malformed NDR error.

func (Malformed) Error

func (e Malformed) Error() string

Error implements the error interface on the Malformed struct.

type PrivateHeader

type PrivateHeader struct {
	ObjectBufferLength uint32
	Filler             []byte
}

PrivateHeader implements the NDR private header: https://msdn.microsoft.com/en-us/library/cc243919.aspx

type RawBytes

type RawBytes interface {
	Size(interface{}) int
}

RawBytes interface should be implemented if reading just a number of bytes from the NDR stream

type Union

type Union interface {
	SwitchFunc(t interface{}) string
}

Union interface must be implemented by structs that will be unmarshaled into from the NDR byte stream union representation. The union's discriminating tag will be passed to the SwitchFunc method. The discriminating tag field must have the struct tag: `ndr:"unionTag"` If the union is encapsulated the discriminating tag field must have the struct tag: `ndr:"encapsulated"` The possible value fields that can be selected from must have the struct tag: `ndr:"unionField"`

Jump to

Keyboard shortcuts

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