Class: PacketGen::Header::NetBIOS::Session

Inherits:
Base show all
Defined in:
lib/packetgen/header/netbios/session.rb

Overview

NetBIOS Session Service messages.

Author:

  • Sylvain Daubert

Since:

  • 2.5.1

Constant Summary collapse

TCP_PORT =

Port number for NetBIOS Session Service over TCP

Since:

  • 2.5.1

139
TYPES =

Session packet types

Since:

  • 2.5.1

{
  'message'           => 0,
  'request'           => 0x81,
  'positive_response' => 0x82,
  'negative_response' => 0x83,
  'retarget_response' => 0x84,
  'keep_alive'        => 0x85,
}.freeze

Instance Attribute Summary collapse

Attributes inherited from Base

#packet

Instance Method Summary collapse

Methods inherited from Base

bind, bind_header, calculate_and_set_length, #header_id, inherited, #initialize, #ip_header, known_headers, #ll_header, #method_name, #parse?, #protocol_name, protocol_name

Methods inherited from Types::Fields

#[], #[]=, #bits_on, define_bit_fields_on, define_field, define_field_after, define_field_before, delete_field, fields, #fields, #force_binary, inherited, #initialize, #inspect, #is_optional?, #is_present?, #offset_of, #optional?, #optional_fields, #present?, #read, remove_bit_fields_on, remove_field, #sz, #to_h, #to_s, update_field

Constructor Details

This class inherits a constructor from PacketGen::Header::Base

Instance Attribute Details

#bodyString

Returns:

  • (String)


40
# File 'lib/packetgen/header/netbios/session.rb', line 40

define_field :body, Types::String

#lengthInteger

17-bit session packet length

Returns:

  • (Integer)


37
# File 'lib/packetgen/header/netbios/session.rb', line 37

define_field :length, Types::Int24

#typeInteger

8-bit session packet type

Returns:

  • (Integer)


33
# File 'lib/packetgen/header/netbios/session.rb', line 33

define_field :type, Types::Int8Enum, enum: TYPES

Instance Method Details

#added_to_packet(packet) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Note:

This method is used internally by PacketGen and should not be directly called

Since:

  • 2.7.0 Set TCP sport according to bindings, only if sport is 0. Needed by new bind API.



53
54
55
56
57
# File 'lib/packetgen/header/netbios/session.rb', line 53

def added_to_packet(packet)
  return unless packet.is? 'TCP'
  return unless packet.tcp.sport.zero?
  packet.tcp.sport = TCP_PORT
end

#calc_lengthInteger

Compute and set #length field

Returns:

  • (Integer)

    calculated length

Since:

  • 2.5.1



44
45
46
# File 'lib/packetgen/header/netbios/session.rb', line 44

def calc_length
  Base.calculate_and_set_length(self, header_in_size: false)
end