Class: RubySMB::SMB2::Packet::NegotiateResponse

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

Overview

An SMB2 NEGOTIATE Response packet as defined by 2.2.4 SMB2 NEGOTIATE Response

Constant Summary collapse

COMMAND =
RubySMB::SMB2::Commands::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

#add_negotiate_context(nc) ⇒ Array<Integer>

Adds a Negotiate Context to the #negotiate_context_list

Parameters:

Returns:

  • (Array<Integer>)

    the array of all currently added Negotiate Contexts

Raises:

  • (ArgumentError)

    if the dialect is not a NegotiateContext structure



53
54
55
56
57
58
59
60
# File 'lib/ruby_smb/smb2/packet/negotiate_response.rb', line 53

def add_negotiate_context(nc)
  raise ArgumentError, 'Must be a NegotiateContext' unless nc.is_a? NegotiateContext
  previous_element = negotiate_context_list.last || negotiate_context_list
  pad_length = pad_length(previous_element)
  self.negotiate_context_list << nc
  self.negotiate_context_list.last.pad = "\x00" * pad_length
  self.negotiate_context_list
end

#find_negotiate_context(type) ⇒ NegotiateContext

Find the first Negotiate Context structure that matches the given context type

not found

Parameters:

  • the (Integer)

    Negotiate Context structure you wish to add

Returns:



44
45
46
# File 'lib/ruby_smb/smb2/packet/negotiate_response.rb', line 44

def find_negotiate_context(type)
  negotiate_context_list.find { |nc| nc.context_type == type }
end

#initialize_instanceObject



33
34
35
36
# File 'lib/ruby_smb/smb2/packet/negotiate_response.rb', line 33

def initialize_instance
  super
  smb2_header.flags.reply = 1
end