class RubySMB::SMB1::ParameterBlock

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.

Public Class Methods

calculate_word_count() click to toggle source

Class method to stub word count calculation during lazy evaluation.

@param [Fixnum] will always return 0

# File lib/ruby_smb/smb1/parameter_block.rb, line 15
def self.calculate_word_count
  0
end
parameter_fields() click to toggle source

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

@return [Array<Symbol>] the names of all other ParameterBlock fields

# 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

Public Instance Methods

calculate_word_count() click to toggle source

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

@return [Fixnum] The size of the ParameterBlock in Words

# 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