Documentation
¶
Overview ¶
package ndr implements the NDR encoding.
Index ¶
- Variables
- func CharLen(s string) uint64
- func CharNLen(s string) uint64
- func DataSize(d any) int
- func Marshal(d Marshaler, opts ...any) ([]byte, error)
- func Marshal64(d Marshaler, opts ...any) ([]byte, error)
- func MarshalResponse(d Operation, opts ...any) ([]byte, error)
- func MarshalWithTypeSerializationV1(d Marshaler, opts ...any) ([]byte, error)
- func MultiSzLen(s []string) uint64
- func Pad(n int) padding
- func ReadCharNString(ctx context.Context, r Reader, s *string) error
- func ReadCharString(ctx context.Context, r Reader, s *string) error
- func ReadUTF16NString(ctx context.Context, r Reader, s *string) error
- func ReadUTF16String(ctx context.Context, r Reader, s *string) error
- func UTF16Len(s string) uint64
- func UTF16NLen(s string) uint64
- func Unmarshal(b []byte, d Unmarshaler, opts ...any) error
- func Unmarshal64(b []byte, d Unmarshaler, opts ...any) error
- func UnmarshalWithTypeSerializationV1(b []byte, d Unmarshaler, opts ...any) error
- func WriteCharNString(ctx context.Context, w Writer, s string) error
- func WriteCharString(ctx context.Context, w Writer, s string) error
- func WriteUTF16NString(ctx context.Context, w Writer, s string) error
- func WriteUTF16String(ctx context.Context, w Writer, s string) error
- type AfterUnmarshalNDR
- type AlignBuffer
- type Buffer
- type ChunkedBuffer
- type CommonHeaderV1
- type DataRepresentation
- type EnumWrapper
- type Error
- type Int3264
- type MarshalNDRFunc
- type Marshaler
- type NDR
- type Operation
- type Pointer
- type PrivateHeaderV1
- type Reader
- type SizeInfoCtx
- type Uint3264
- type UnmarshalNDRFunc
- type Unmarshaler
- type WaitChunk
- func (c *WaitChunk) Bytes() []byte
- func (c *WaitChunk) Close()
- func (c *WaitChunk) Done()
- func (c *WaitChunk) EOF() bool
- func (c *WaitChunk) Float() math.FloatFormat
- func (c *WaitChunk) Len() int
- func (c *WaitChunk) Order() binary.ByteOrder
- func (c *WaitChunk) Read(p []byte) (int, error)
- func (c *WaitChunk) ReadRepresentation(drep *DataRepresentation) error
- func (c *WaitChunk) Wait(b []byte, frmt DataRepresentation, maxLen int) int
- func (c *WaitChunk) Write(p []byte) (int, error)
- func (c *WaitChunk) WriteRepresentation(drep DataRepresentation) error
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ( // IEEE floating point representation. FloatingPointIEEE uint32 = 0x00000000 // VAX floating point representation. FloatingPointVAX uint32 = 0x00000100 // Cray floating point representation. FloatingPointCray uint32 = 0x00000200 // IBM floating point representation. FloatingPointIBM uint32 = 0x00000300 // Mask. FloatingPointMask uint32 = 0x0000FF00 )
var ( // ASCII character representation. CharASCII uint32 = 0x00000000 // EBCDIC character representation. CharEBCDIC uint32 = 0x00000001 // Mask. CharMask uint32 = 0x0000000F )
var ( // Big-endian data representation. ByteOrderBigEndian uint32 = 0x00000000 // Little-endian data representation. ByteOrderLittleEndian uint32 = 0x00000010 // Mask. ByteOrderMask uint32 = 0x000000F0 )
var Debug debug
var ( // The default data representation (ASCII, FloatIEEE, LittleEndian). DefaultDataRepresentation = DataRepresentation(CharASCII | FloatingPointIEEE | ByteOrderLittleEndian) )
var NoLayout noLayout
var Opaque opaque
Opaque is an NDR option that is used to indicate that implicit NDR data, like size labels, non-encapsulated switches, pointer values must be omitted. Any pointer deferred values must be encoded immediately.
var ( // SizeInfoCtx is a context type for the size information. SizeInfo = SizeInfoCtx{} )
var ( // ZeroString represents the empty null-termination string. ZeroString = string([]byte{0}) )
Functions ¶
func MarshalResponse ¶ added in v1.1.5
MarshalResponse function marshal the operation `d` response using NDR2.0 format.
func MarshalWithTypeSerializationV1 ¶ added in v1.0.3
func MultiSzLen ¶
func ReadCharNString ¶
ReadUTF16NString ...
func ReadCharString ¶
ReadCharString ...
func ReadUTF16NString ¶
ReadUTF16NString ...
func ReadUTF16String ¶
ReadUTF16NString ...
func Unmarshal ¶
func Unmarshal(b []byte, d Unmarshaler, opts ...any) error
Unmarshal function unmarshals the bytes `b` to the data `d` using NDR2.0 format.
func Unmarshal64 ¶ added in v1.1.3
func Unmarshal64(b []byte, d Unmarshaler, opts ...any) error
Unmarshal64 function unmarshals the bytes `b` to the data `d` using NDR64 format.
func UnmarshalWithTypeSerializationV1 ¶ added in v1.0.3
func UnmarshalWithTypeSerializationV1(b []byte, d Unmarshaler, opts ...any) error
func WriteUTF16NString ¶
WriteUTF16NString function ...
Types ¶
type AfterUnmarshalNDR ¶ added in v1.0.2
type AlignBuffer ¶
type AlignBuffer interface { // The chunked buffer interface. ChunkedBuffer // EOF function must return true if underlying chunk buffer // length is zero. (note that it must be used only with chunks // that contain of a single buffer). EOF() bool // Pos must contain the current position of the buffer over // multiple chunks. (can be used to set proper pointer values). Pos() int // SkipMod function must advance the read buffer up to the // modulo of integer parameter. SkipMod(int) error // FillMod function must fill the write buffer up to the // modulo of integer parameter. FillMod(int) error }
AlignBuffer provides the alignment capabilities over the chunked buffer. Since chunked buffer can contain multiple chunks in the implementation, we need to keep track of current position in the stream.
func NewAlignBuffer ¶
func NewAlignBuffer(chk ChunkedBuffer) AlignBuffer
NewAlignBuffer returns the new instance of aligned buffer.
type Buffer ¶
type Buffer interface { // EOF function must returns `true` if there is no more // data in the buffer. EOF() bool // Len function must returns the number of bytes available // for read or number of written bytes. Len() int // Offset function must return current buffer position. Offset() int // Bytes function must return the buffer bytes. Bytes() []byte // WithBytes function assigns the buffer to the parameter // bytes. WithBytes([]byte) NDR }
Buffer interface.
type ChunkedBuffer ¶
type ChunkedBuffer interface { EOF() bool // Read/Write interface. io.ReadWriter // Len function must return the total length of the buffer. Len() int // ReadRepresentation function must read and configure the // representation for the current chunk. ReadRepresentation(*DataRepresentation) error // WriteRepresentation function must write and configure // the representation for the current chunk. WriteRepresentation(DataRepresentation) error // Order function must return the byte order for the chunk. Order() binary.ByteOrder // Float function must return the floating-point format for // the chunk. Float() math.FloatFormat // Bytes function must return the bytes in the current chunk. Bytes() []byte }
ChunkedBuffer interface is aimed to provide an interface for reading the data input chunk by chunk thus enabling capabilities for reusing the same buffer within single network exchange involving multiple chunks.
func NewChunk ¶
func NewChunk(b []byte, drep DataRepresentation) ChunkedBuffer
NewChunk function returns the new chunked buffer.
type CommonHeaderV1 ¶ added in v1.0.3
type CommonHeaderV1 struct { Version uint8 Endianness uint8 CommonHeaderLength uint16 Filler []byte }
func (*CommonHeaderV1) MarshalNDR ¶ added in v1.0.3
func (c *CommonHeaderV1) MarshalNDR(ctx context.Context, w Writer) error
func (*CommonHeaderV1) UnmarshalNDR ¶ added in v1.0.3
func (c *CommonHeaderV1) UnmarshalNDR(ctx context.Context, r Reader) error
type DataRepresentation ¶
type DataRepresentation uint32
The NDR data representation.
func (DataRepresentation) ByteOrder ¶
func (d DataRepresentation) ByteOrder() binary.ByteOrder
ByteOrder function returns the byte order for the data representation.
func (DataRepresentation) FloatFormat ¶
func (d DataRepresentation) FloatFormat() math.FloatFormat
FloatFormat function returns the floating-point format for the data representation.
type EnumWrapper ¶ added in v1.1.3
type EnumWrapper interface { Value() any // contains filtered or unexported methods }
func Enum ¶ added in v1.1.3
func Enum(v any) EnumWrapper
type Error ¶
type Error interface { // Err function must return the captured error. Err() error // SetError must set and returns the error. SetErr(error) error }
Error(er) interface.
type MarshalNDRFunc ¶
MarshalNDRFunc function ...
func (MarshalNDRFunc) MarshalNDR ¶
func (f MarshalNDRFunc) MarshalNDR(ctx context.Context, w Writer) error
MarshalNDR function implements the Marshaler interface.
type Operation ¶
type Operation interface { // The operation number. OpNum() int // The operation name. OpName() string // The function to marshal the request parameters. MarshalNDRRequest(context.Context, Writer) error // The function to unmarshal the request parameters. UnmarshalNDRRequest(context.Context, Reader) error // The function to marshal the response fields. MarshalNDRResponse(context.Context, Writer) error // The function to unmarshal the response fields. UnmarshalNDRResponse(context.Context, Reader) error }
The NDR operation.
type PrivateHeaderV1 ¶ added in v1.0.3
func (*PrivateHeaderV1) MarshalNDR ¶ added in v1.0.3
func (p *PrivateHeaderV1) MarshalNDR(ctx context.Context, w Writer) error
func (*PrivateHeaderV1) UnmarshalNDR ¶ added in v1.0.3
func (p *PrivateHeaderV1) UnmarshalNDR(ctx context.Context, r Reader) error
type Reader ¶
type Reader interface { // Reader is a generic I/O writer interface. io.Reader // Error to return an error. Error // Buffer. Buffer // Marshal function performs the NDR marshaling with pointer // resolution. Unmarshal(context.Context, Unmarshaler) error // ReadAlign function performs alignment of the output buffer. ReadAlign(int) error // ReadUnionAlign function performs alignment of the union // buffer. ReadUnionAlign(int) error // ReadData will align and read the type as-is. // If type has alignment, it should align the data in the // UnmarshalNDR method, if it's the primitive type, // primitive type alignment will be used. ReadData(any) error // ReadSize function reads the maximum count, offset, // and actual count for arrays, strings, pipes. ReadSize(*uint64) error // ReadSwitch function reads the switch value for the union. ReadSwitch(any) error // ReadEnum function reads the enumeration. ReadEnum(any) error // ReadPointer function reads the implementation-specific pointer. // It receives the setter function in case if pointer is not null. ReadPointer(Pointer, func(any), ...Unmarshaler) error // ReadDeferred function reads all the deferred pointers. ReadDeferred() error }
type SizeInfoCtx ¶
type SizeInfoCtx struct{}
SizeInfoCtx is a context key type for the size information.
type UnmarshalNDRFunc ¶
UnmarshalNDRFunc function ...
func (UnmarshalNDRFunc) UnmarshalNDR ¶
func (f UnmarshalNDRFunc) UnmarshalNDR(ctx context.Context, w Reader) error
UnmarshalNDR function implements the Unmarshaler interface.
type Unmarshaler ¶
Unmarshaler interface ...
func UnmarshalerPointer ¶ added in v1.0.3
func UnmarshalerPointer(v Unmarshaler) Unmarshaler
type WaitChunk ¶
type WaitChunk struct {
// contains filtered or unexported fields
}
WaitChunk structure represents the buffer that blocks until provided via `Wait` bytes will be exhausted either by read or by write or by the completion of the operation (Done is called).
func NewWaitChunk ¶
func NewWaitChunk() *WaitChunk
func (*WaitChunk) Float ¶
func (c *WaitChunk) Float() math.FloatFormat
Float function return the floating-point format for the buffer chunk.
func (*WaitChunk) Len ¶
Len function returns the current WaitChunk remaining data. (used for sanity check).
func (*WaitChunk) ReadRepresentation ¶
func (c *WaitChunk) ReadRepresentation(drep *DataRepresentation) error
func (*WaitChunk) Wait ¶
func (c *WaitChunk) Wait(b []byte, frmt DataRepresentation, maxLen int) int
func (*WaitChunk) WriteRepresentation ¶
func (c *WaitChunk) WriteRepresentation(drep DataRepresentation) error
type Writer ¶
type Writer interface { // Writer is a generic I/O writer interface. io.Writer // Error to return an error. Error // Buffer. Buffer // Marshal function performs the NDR marshaling with pointer // resolution. Marshal(context.Context, Marshaler) ([]byte, error) // WriteAlign function performs alignment of the output buffer. WriteAlign(int) error // WriteUnionAlign function performs alignment of the union // output buffer. WriteUnionAlign(int) error // WriteData will write and align the type as-is. // If type implements align method, it will be used, if it's the // primitive type, primitive type alignment will be used. WriteData(any) error // WriteSize function writes the maximum count, offset, // and actual count for arrays, strings, pipes. WriteSize(uint64) error // WriteSwitch function writes the union switch. WriteSwitch(any) error // WriteEnum function writes the enumeration. WriteEnum(any) error // WritePointer function writes the implementation-specific pointer. // Optional data parameter will be used when the full pointer is used. WritePointer(Pointer, ...Marshaler) error // WriteDeferred function writes all the deferred pointers. WriteDeferred() error }
Writer interface ...