Class: RubySMB::SMB1::ParameterBlock

Inherits:
BinData::Record
  • Object
show all
Defined in:
lib/ruby_smb/smb1/parameter_block.rb

Overview

Represents the ParameterBlock portion of an SMB1 Packet. The ParameterBlock will always contain a word_count field that gives the size of the rest of the data block in words.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.calculate_word_countObject

Class method to stub word count calculation during lazy evaluation.

Parameters:

  • will (Fixnum)

    always return 0



15
16
17
# File 'lib/ruby_smb/smb1/parameter_block.rb', line 15

def self.calculate_word_count
  0
end

.parameter_fieldsArray<Symbol>

Returns the name of all fields, other than word_count, in the ParameterBlock as symbols.

Returns:

  • (Array<Symbol>)

    the names of all other ParameterBlock fields



23
24
25
26
# File 'lib/ruby_smb/smb1/parameter_block.rb', line 23

def self.parameter_fields
  fields = self.fields.collect(&:name)
  fields.reject { |field| field == :word_count }
end

Instance Method Details

#calculate_word_countFixnum

Calculates the size of the other fields in the ParameterBlock in Words.

Returns:

  • (Fixnum)

    The size of the ParameterBlock in Words



32
33
34
35
36
37
38
39
# File 'lib/ruby_smb/smb1/parameter_block.rb', line 32

def calculate_word_count
  total_count = 0
  self.class.parameter_fields.each do |field_name|
    field_value = send(field_name)
    total_count += field_value.do_num_bytes
  end
  total_count.to_i / 2
end