class RubySMB::SMB2::Packet::NegotiateResponse

An SMB2 NEGOTIATE Response packet as defined by [2.2.4 SMB2 NEGOTIATE Response](msdn.microsoft.com/en-us/library/cc246561.aspx)

Constants

COMMAND

Public Instance Methods

add_negotiate_context(nc) click to toggle source

Adds a Negotiate Context to the negotiate_context_list

@param [NegotiateContext] the Negotiate Context structure you wish to add @return [Array<Fixnum>] the array of all currently added Negotiate Contexts @raise [ArgumentError] if the dialect is not a NegotiateContext structure

# 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) click to toggle source

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

@param [Integer] the Negotiate Context structure you wish to add @return [NegotiateContext] the Negotiate Context structure or nil if not found

# 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_instance() click to toggle source
# File lib/ruby_smb/smb2/packet/negotiate_response.rb, line 33
def initialize_instance
  super
  smb2_header.flags.reply = 1
end

Private Instance Methods

has_negotiate_context?() click to toggle source

Return true if the dialect version requires Negotiate Contexts

# File lib/ruby_smb/smb2/packet/negotiate_response.rb, line 72
def has_negotiate_context?
  dialect_revision == 0x0311
end
pad_length(prev_element) click to toggle source

Determines the correct length for the padding, so that the next field is 8-byte aligned.

# File lib/ruby_smb/smb2/packet/negotiate_response.rb, line 66
def pad_length(prev_element)
  offset = (prev_element.abs_offset + prev_element.to_binary_s.length) % 8
  (8 - offset) % 8
end