Generated from Manticore v1.1.5 • 201 packages. View on pkg.go.dev

data

import "github.com/TheManticoreProject/Manticore/network/cifs/message/data"

Index

type Data

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

type Data struct {
    ByteCount uint16
    Bytes     []byte
}

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.