class RubySMB::SMB1::DataBlock
Represents the DataBlock
portion of an SMB1
Packet
. The DataBlock
will always contain a byte_count field that gives the size of the rest of the data block in bytes.
Public Class Methods
calculate_byte_count()
click to toggle source
Class method to stub byte count calculation during lazy evaluation.
@return [Fixnum] will always return 0
# File lib/ruby_smb/smb1/data_block.rb, line 15 def self.calculate_byte_count 0 end
data_fields()
click to toggle source
Returns the name of all fields, other than byte_count, in the DataBlock
as symbols.
@return [Array<Symbol>] the names of all other DataBlock
fields
# File lib/ruby_smb/smb1/data_block.rb, line 23 def self.data_fields fields = self.fields.collect(&:name) fields.reject { |field| field == :byte_count } end
Public Instance Methods
calculate_byte_count()
click to toggle source
Calculates the size of the other fields in the DataBlock
in Bytes.
@return [Fixnum] The size of the DataBlock
in Words
# File lib/ruby_smb/smb1/data_block.rb, line 32 def calculate_byte_count total_count = 0 self.class.data_fields.each do |field_name| next unless field_enabled?(field_name) field_value = send(field_name) total_count += field_value.do_num_bytes end total_count end
field_enabled?(field_name)
click to toggle source
# File lib/ruby_smb/smb1/data_block.rb, line 42 def field_enabled?(field_name) send("#{field_name}?".to_sym) end