Class: RubySMB::SMB1::DataBlock
- Inherits:
-
BinData::Record
- Object
- BinData::Record
- RubySMB::SMB1::DataBlock
- Defined in:
- lib/ruby_smb/smb1/data_block.rb
Overview
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.
Direct Known Subclasses
Packet::CloseRequest::DataBlock, Packet::CloseResponse::DataBlock, Packet::EchoRequest::DataBlock, Packet::EchoResponse::DataBlock, Packet::LogoffRequest::DataBlock, Packet::LogoffResponse::DataBlock, Packet::NegotiateRequest::DataBlock, Packet::NegotiateResponse::DataBlock, Packet::NegotiateResponseExtended::DataBlock, Packet::NtCreateAndxRequest::DataBlock, Packet::NtCreateAndxResponse::DataBlock, Packet::ReadAndxRequest::DataBlock, Packet::ReadAndxResponse::DataBlock, Packet::SessionSetupLegacyRequest::DataBlock, Packet::SessionSetupLegacyResponse::DataBlock, Packet::SessionSetupRequest::DataBlock, Packet::SessionSetupResponse::DataBlock, Packet::Trans2::DataBlock, Packet::Trans::DataBlock, Packet::TreeConnectRequest::DataBlock, Packet::TreeConnectResponse::DataBlock, Packet::TreeDisconnectRequest::DataBlock, Packet::TreeDisconnectResponse::DataBlock, Packet::WriteAndxRequest::DataBlock, Packet::WriteAndxResponse::DataBlock
Class Method Summary collapse
-
.calculate_byte_count ⇒ Integer
Class method to stub byte count calculation during lazy evaluation.
-
.data_fields ⇒ Array<Symbol>
Returns the name of all fields, other than byte_count, in the DataBlock as symbols.
Instance Method Summary collapse
-
#calculate_byte_count ⇒ Integer
Calculates the size of the other fields in the DataBlock in Bytes.
- #field_enabled?(field_name) ⇒ Boolean
Class Method Details
.calculate_byte_count ⇒ Integer
Class method to stub byte count calculation during lazy evaluation.
15 16 17 |
# File 'lib/ruby_smb/smb1/data_block.rb', line 15 def self.calculate_byte_count 0 end |
.data_fields ⇒ Array<Symbol>
Returns the name of all fields, other than byte_count, in the DataBlock as symbols.
23 24 25 26 |
# 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 |
Instance Method Details
#calculate_byte_count ⇒ Integer
Calculates the size of the other fields in the DataBlock in Bytes.
32 33 34 35 36 37 38 39 40 |
# 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) ⇒ Boolean
42 43 44 |
# File 'lib/ruby_smb/smb1/data_block.rb', line 42 def field_enabled?(field_name) send("#{field_name}?".to_sym) end |