Class: PacketGen::Plugin::IKE::Attribute
- Inherits:
-
Types::Fields
- Object
- Types::Fields
- PacketGen::Plugin::IKE::Attribute
- Defined in:
- lib/packetgen/plugin/ike/sa.rb
Overview
Transform attribute.
1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|A| Attribute Type | AF=0 Attribute Length |
|F| | AF=1 Attribute Value |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| AF=0 Attribute Value |
| AF=1 Not Transmitted |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Such an attribute may have a TLV (Type/length/value) format if AF=0, or a TV format (AF=1).
Constant Summary collapse
- TYPE_KEY_LENGTH =
KeyLength attribute type
14
Instance Attribute Summary collapse
- #length ⇒ Integer
-
#type ⇒ Integer
attribute type.
- #value ⇒ Integer
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Attribute
constructor
A new instance of Attribute.
-
#to_human ⇒ String
Get a human readable string.
-
#tv_format? ⇒ Boolean
Say if attribute use TV format (
true
) or TLV one (false
).
Constructor Details
#initialize(options = {}) ⇒ Attribute
Returns a new instance of Attribute.
41 42 43 44 45 46 47 48 |
# File 'lib/packetgen/plugin/ike/sa.rb', line 41 def initialize(={}) super if tv_format? self[:length].value = ([:value] & 0xffff) else self[:length].value = 8 unless [:length] end end |
Instance Attribute Details
#length ⇒ Integer
35 |
# File 'lib/packetgen/plugin/ike/sa.rb', line 35 define_field :length, PacketGen::Types::Int16 |
#type ⇒ Integer
attribute type
31 |
# File 'lib/packetgen/plugin/ike/sa.rb', line 31 define_field :type, PacketGen::Types::Int16 |
#value ⇒ Integer
39 |
# File 'lib/packetgen/plugin/ike/sa.rb', line 39 define_field :value, PacketGen::Types::Int32, optional: ->(h) { !h.tv_format? } |
Instance Method Details
#to_human ⇒ String
Get a human readable string
64 65 66 67 68 69 |
# File 'lib/packetgen/plugin/ike/sa.rb', line 64 def to_human name = self.class.constants.grep(/TYPE_/) .detect { |c| self.class.const_get(c) == (type & 0x7fff) } || "attr[#{type & 0x7fff}]" name = name.to_s.sub(/TYPE_/, '') "#{name}=#{value}" end |
#tv_format? ⇒ Boolean
Say if attribute use TV format (true
) or TLV one (false
)
73 74 75 |
# File 'lib/packetgen/plugin/ike/sa.rb', line 73 def tv_format? type & 0x8000 == 0x8000 end |