Class: PacketGen::Header::EAP::TLS

Inherits:
PacketGen::Header::EAP show all
Defined in:
lib/packetgen/header/eap/tls.rb

Overview

Extensible Authentication Protocol (EAP) - TLS, RFC 5216

TLS has following fields:

Since:

  • 2.1.4

Constant Summary

Constants inherited from PacketGen::Header::EAP

CODES, TYPES

Instance Attribute Summary collapse

Attributes inherited from PacketGen::Header::EAP

#body, #code, #id, #length, #type, #vendor_id, #vendor_type

Attributes inherited from Base

#packet

Instance Method Summary collapse

Methods inherited from PacketGen::Header::EAP

#added_to_packet, #calc_length, #desired_auth_type, #failure?, #has_type?, #human_code, #human_type, #old_read, #read, #reply!, #request?, #response?, #success?, #type?

Methods inherited from Base

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

Methods inherited from Types::Fields

#[], #[]=, #body=, define_bit_fields_on, define_field, define_field_after, define_field_before, delete_field, #fields, #force_binary, inherited, #is_optional?, #is_present?, #optional_fields, #read, #sz, #to_h, #to_s

Constructor Details

#initialize(options = {}) ⇒ EAP::TLS

Since:

  • 2.1.4



48
49
50
# File 'lib/packetgen/header/eap/tls.rb', line 48

def initialize(options={})
  super({ type: 13 }.merge!(options))
end

Instance Attribute Details

#flagsInteger

Returns 8-bit flags.

Returns:

  • (Integer)

    8-bit flags



23
# File 'lib/packetgen/header/eap/tls.rb', line 23

define_field_before :body, :flags, Types::Int8

#lBoolean

Say if length field is included. Defined on #flags field.

Returns:

  • (Boolean)


34
# File 'lib/packetgen/header/eap/tls.rb', line 34

define_bit_fields_on :flags, :l, :m, :s, :reserved, 5

#mBoolean

Say if there are more fragments. Defined on #flags field.

Returns:

  • (Boolean)


34
# File 'lib/packetgen/header/eap/tls.rb', line 34

define_bit_fields_on :flags, :l, :m, :s, :reserved, 5

#sBoolean

If set, this message is a TLS-Start. Defined on #flags field.

Returns:

  • (Boolean)


34
# File 'lib/packetgen/header/eap/tls.rb', line 34

define_bit_fields_on :flags, :l, :m, :s, :reserved, 5

#tls_lengthInteger

TLS message length. This field provides the total length of the TLS message or set of messages that is being fragmented. So, it cannot be automatically calculated (no #calc_length method).

Returns:

  • (Integer)

    32-bit TLS length



44
45
# File 'lib/packetgen/header/eap/tls.rb', line 44

define_field_before :body, :tls_length, Types::Int32,
optional: ->(h) { h.l? }

Instance Method Details

#inspectString

Returns:

  • (String)

Since:

  • 2.1.4



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/packetgen/header/eap/tls.rb', line 53

def inspect
  str = Inspect.dashed_line(self.class, 2)
  fields.each do |attr|
    next if attr == :body
    next unless is_present?(attr)
    if attr == :flags
      shift = Inspect.shift_level(2)
      value = i[l m s].map { |f| send("#{f}?") ? f.to_s : '.' }.join
      value = '%-10s (0x%02x)' % [value, self.flags]
      str << shift
      str << Inspect::FMT_ATTR % [self[attr].class.to_s.sub(/.*::/, ''),
                                  attr, value]
    else
      str << Inspect.inspect_attribute(attr, self[attr], 2)
    end
  end
  str
end