Class: RubySMB::SMB1::Packet::NegotiateResponse

Inherits:
GenericPacket
  • Object
show all
Defined in:
lib/ruby_smb/smb1/packet/negotiate_response.rb

Overview

A SMB1 SMB_COM_NEGOTIATE Non-Extended Security Response Packet as defined in 2.2.4.5.2.2 Non-Extended Security Response

Defined Under Namespace

Classes: DataBlock, ParameterBlock

Constant Summary collapse

COMMAND =
RubySMB::SMB1::Commands::SMB_COM_NEGOTIATE

Instance Method Summary collapse

Methods inherited from GenericPacket

describe, #display, fields_hashed, format_field, from_hex, #packet_smb_version, read, #status_code, #valid?, walk_fields

Instance Method Details

#dialects=(dialects) ⇒ Object

Stores the list of Dialect that were sent to the peer/server in the related Negotiate Request. This will be used by the #negotiated_dialect method.

Parameters:

  • dialects (Array)

    array of Dialect

Raises:

  • (ArgumentError)

    if dialects is not an array of Dialect



47
48
49
50
51
52
# File 'lib/ruby_smb/smb1/packet/negotiate_response.rb', line 47

def dialects=(dialects)
  unless dialects.all? { |dialect| dialect.is_a? Dialect }
    raise ArgumentError, 'Dialects must be an array of Dialect objects'
  end
  @dialects = dialects
end

#initialize_instanceObject



35
36
37
38
# File 'lib/ruby_smb/smb1/packet/negotiate_response.rb', line 35

def initialize_instance
  super
  smb_header.flags.reply = 1
end

#negotiated_dialectString

Returns the negotiated dialect identifier

Returns:

  • (String)

    the negotiated dialect identifier or an empty string if the list of Dialect was not provided.



57
58
59
60
# File 'lib/ruby_smb/smb1/packet/negotiate_response.rb', line 57

def negotiated_dialect
  return '' if @dialects.nil? || @dialects.empty?
  @dialects[parameter_block.dialect_index].dialect_string
end