Class: PacketGen::Header::Dot11::Management
- Inherits:
-
PacketGen::Header::Dot11
- Object
- BinStruct::Struct
- Base
- PacketGen::Header::Dot11
- PacketGen::Header::Dot11::Management
- Defined in:
- lib/packetgen/header/dot11/management.rb
Overview
IEEE 802.11 management frame header
This class make a PacketGen::Header::Dot11 header with #type set to 0
(management frame).
A IEEE 802.11 management header consists of:
-
a #frame_ctrl (
BinStruct::Int16
), -
a #id/duration (
BinStruct::Int16le
), -
a #mac1 (Eth::MacAddr).
-
a #mac2 (Eth::MacAddr),
-
a #mac3 (Eth::MacAddr),
-
a #sequence_ctrl (
BinStruct::Int16
), -
a #body (a
BinStruct::String
or another PacketGen::Headerable class), -
and a Frame check sequence (#fcs, of type
BinStruct::Int32le
).
Management frames should be constructed with more headers from SubMngt subclasses. Some frames also need to have Element.
Constant Summary
Constants inherited from PacketGen::Header::Dot11
Instance Attribute Summary
Attributes inherited from PacketGen::Header::Dot11
#body, #fcs, #fragment_number, #frame_ctrl, #from_ds, #ht_ctrl, #id, #mac1, #mac2, #mac3, #mac4, #md, #mf, #order, #proto_version, #pwmngt, #qos_ctrl, #retry, #sequence_ctrl, #sequence_number, #subtype, #to_ds, #type, #wep
Instance Method Summary collapse
- #add_element(type:, value:) ⇒ self
-
#initialize(options = {}) ⇒ Management
constructor
A new instance of Management.
-
#reply! ⇒ self
Invert mac1 and mac2 (resp. destination address and source address).
Methods inherited from PacketGen::Header::Dot11
#added_to_packet, #attributes, #calc_checksum, #human_type, #inspect, #old_attributes, #old_read, #read, #to_s, #to_w
Methods inherited from Base
bind, calculate_and_set_length, #header_id, inherited, #ip_header, #ll_header
Methods included from PacketGen::Headerable
#added_to_packet, included, #method_name, #packet, #packet=, #parse?, #protocol_name, #read, #to_s
Constructor Details
#initialize(options = {}) ⇒ Management
Returns a new instance of Management.
48 49 50 51 52 |
# File 'lib/packetgen/header/dot11/management.rb', line 48 def initialize(={}) super({ type: 0 }.merge!()) @applicable_attributes -= %i[mac4 qos_ctrl ht_ctrl] define_applicable_attributes end |
Instance Method Details
#add_element(type:, value:) ⇒ self
59 60 61 62 63 64 |
# File 'lib/packetgen/header/dot11/management.rb', line 59 def add_element(type:, value:) raise FormatError, 'Before adding an Element, you have to add a Dot11::SubMngt subclass instance' unless self[:body].is_a?(SubMngt) self[:body].elements << { type: type, value: value } self end |
#reply! ⇒ self
Invert mac1 and mac2 (resp. destination address and source address).
68 69 70 |
# File 'lib/packetgen/header/dot11/management.rb', line 68 def reply! self[:mac1], self[:mac2] = self[:mac2], self[:mac1] end |