parameters

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 Parameters

type Parameters struct {
	// WordCount (1 byte): The size, in two-byte words, of the Words field. This field can be zero, indicating that the Words
	// field is empty. Note that the size of this field is one byte and comes after the fixed 32-byte SMB Header (section 2.2.3.1),
	// which causes the Words field to be unaligned.
	WordCount uint8

	// Words (variable): The message-specific parameters structure. The size of this field MUST be (2 x WordCount) bytes.
	// If WordCount is 0x00, this field is not included.
	Words []uint16
}

SMBParameters represents the parameters structure for SMB packets Source: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-cifs/c87a9a6e-e318-44d3-85e1-82398f8dc9f5

func NewParameters

func NewParameters() *Parameters

NewParameters creates a new SMB Parameters structure with default values. It initializes an empty Parameters structure with WordCount set to 0 and an empty Words slice.

Returns: - A pointer to the initialized Parameters structure

func (*Parameters) AddWord

func (p *Parameters) AddWord(word uint16)

AddWord appends a new 16-bit word to the Parameters structure. This method adds the provided word to the Words slice and updates the WordCount field to reflect the new count.

Parameters: - word: The 16-bit word to add to the Parameters structure

func (*Parameters) AddWordsFromBytesStream

func (p *Parameters) AddWordsFromBytesStream(bytesStream []byte)

AddWordsFromBytesStream converts a byte stream to a slice of uint16 parameters It reads the byte stream in chunks of 2 bytes and converts each chunk to a uint16 word If the byte stream length is odd, the last byte will be padded with zero

func (*Parameters) GetBytes

func (p *Parameters) GetBytes() []byte

GetBytes returns the bytes of the Parameters structure

This function returns the bytes of the Parameters structure. It returns the Bytes field.

func (*Parameters) GetBytesStream

func (p *Parameters) GetBytesStream() []byte

GetBytesStream returns the binary representation of the Parameters structure. This method converts the Parameters structure into a byte slice according to the SMB protocol format. It first writes the WordCount byte, followed by each word in big-endian byte order (high byte first, then low byte).

Unlike Marshal, this method does not return an error and is designed for direct inclusion in message construction.

Returns: - A byte slice containing the binary representation of the Parameters structure

func (*Parameters) Marshal

func (p *Parameters) Marshal() ([]byte, error)

Marshal serializes the Parameters structure into a byte slice. This method converts the Parameters structure into its binary representation according to the SMB protocol format. It first writes the WordCount byte, followed by each word in little-endian byte order.

Returns: - A byte slice containing the marshalled Parameters structure - An error if marshalling fails, or nil if successful

func (*Parameters) Size

func (p *Parameters) 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 (*Parameters) Unmarshal

func (p *Parameters) Unmarshal(data []byte) (int, error)

Unmarshal deserializes a byte slice into the Parameters structure. This method reads the binary representation of the Parameters structure from the input byte slice according to the SMB protocol format. It first reads the WordCount byte, then reads each word in little-endian byte order.

Parameters: - data: The byte slice containing the serialized Parameters structure

Returns: - int: The number of bytes read from the input byte slice - error: Any error encountered during deserialization, or nil if successful

Jump to

Keyboard shortcuts

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