data

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Data

type Data struct {
	ByteCount uint16
	Bytes     []byte
}

Data represents the data field in an SMB message Source: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/48b4bd5d-7206-4002-bde1-c34cf614b138

func NewData

func NewData() *Data

NewData creates a new Data structure with an empty Bytes field and a ByteCount of 0

This function creates a new Data structure with an empty Bytes field and a ByteCount of 0.

func (*Data) Add

func (d *Data) Add(bytes []byte)

Add appends bytes to the Data structure and updates the ByteCount

This function appends the given bytes to the existing bytes in the Data structure and updates the ByteCount to reflect the new length of the Bytes field.

func (*Data) GetBytes

func (d *Data) GetBytes() []byte

GetBytes returns the data for the message

This function returns the data for the message. It returns the Bytes field.

func (*Data) Marshal

func (d *Data) Marshal() ([]byte, error)

Marshal marshals the Data structure into a byte array

This function marshals the Data structure into a byte array. It creates a new byte array, appends the ByteCount and the Bytes field to it, and returns the resulting byte array.

func (*Data) SetData

func (d *Data) SetData(data []byte)

SetData sets the data for the message

This function sets the data for the message. It sets the Bytes field to the given data and updates the ByteCount to reflect the length of the given data.

func (*Data) Size

func (d *Data) Size() uint16

Size returns the size of the Data structure

This function returns the size of the Data structure. It returns the ByteCount field.

func (*Data) Unmarshal

func (d *Data) Unmarshal(data []byte) (int, error)

Unmarshal unmarshals the Data structure from a byte array

This function unmarshals the Data structure from a byte array. It reads the ByteCount from the first two bytes of the input byte array, and then reads the corresponding number of bytes into the Bytes field. It returns the number of bytes read and an error if the input byte array is empty or too short to unmarshal the Data structure.

Jump to

Keyboard shortcuts

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