Sha256: a12bcbca0e0f45e747d94f64dd041c4f854052d3c76cb08c63266777943647a2

Contents?: true

Size: 1015 Bytes

Versions: 5

Compression:

Stored size: 1015 Bytes

Contents

module RubySMB
  module SMB1
    module Packet
      module Trans2

        # Extends the {RubySMB::SMB1::DataBlock} to include padding methods
        # that all Trans2 DataBlocks will need to handle proper byte alignment.
        class DataBlock < RubySMB::SMB1::DataBlock
          private

          # Determines the correct length for the padding in front of
          # #trans2_parameters. It should always force a 4-byte alignment.
          def pad1_length
            if self.respond_to?(:name)
              offset = (name.abs_offset + 1) % 4
            else
              offset = (byte_count.abs_offset + 2) % 4
            end
            (4 - offset) % 4
          end

          # Determines the correct length for the padding in front of
          # #trans2_data. It should always force a 4-byte alignment.
          def pad2_length
            offset = (trans2_parameters.abs_offset + trans2_parameters.length) % 4
            (4 - offset) % 4
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ruby_smb-0.0.17 lib/ruby_smb/smb1/packet/trans2/data_block.rb
ruby_smb-0.0.16 lib/ruby_smb/smb1/packet/trans2/data_block.rb
ruby_smb-0.0.15 lib/ruby_smb/smb1/packet/trans2/data_block.rb
ruby_smb-0.0.14 lib/ruby_smb/smb1/packet/trans2/data_block.rb
ruby_smb-0.0.13 lib/ruby_smb/smb1/packet/trans2/data_block.rb