Class: PacketGen::Header::Dot11::Data
- Inherits:
-
PacketGen::Header::Dot11
- Object
- Types::Fields
- Base
- PacketGen::Header::Dot11
- PacketGen::Header::Dot11::Data
- Defined in:
- lib/packetgen/header/dot11/data.rb
Overview
IEEE 802.11 data frame header
This class make a PacketGen::Header::Dot11 header with #type set to 2 (data frame).
A IEEE 802.11 data header consists of:
-
a #frame_ctrl (Types::Int16),
-
a #id/duration (Types::Int16le),
-
a #mac2 (Eth::MacAddr),
-
a #mac3 (Eth::MacAddr),
-
sometimes a #mac4 (Eth::MacAddr),
-
sometimes a #qos_ctrl (Types::Int16),
-
a #body (a Types::String or another Base class),
-
and a Frame check sequence (#fcs, of type Types::Int32le).
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
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Data
constructor
A new instance of Data.
-
#reply! ⇒ Object
Invert source and destination addresses (see Table 8-19 from IEEE 802.11-2012 document to known which MAC is SA, and which one is DA).
Methods inherited from PacketGen::Header::Dot11
#added_to_packet, #calc_checksum, #fields, has_fcs, has_fcs=, #human_type, #inspect, #old_fields, #old_read, #read, #to_s, #to_w
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
#[], #[]=, #bits_on, #body=, define_bit_fields_on, define_field, define_field_after, define_field_before, delete_field, #fields, #force_binary, inherited, #inspect, #is_optional?, #is_present?, #offset_of, #optional?, #optional_fields, #present?, #read, #sz, #to_h, #to_s
Constructor Details
#initialize(options = {}) ⇒ Data
Returns a new instance of Data.
31 32 33 34 35 |
# File 'lib/packetgen/header/dot11/data.rb', line 31 def initialize(={}) super({ type: 2 }.merge!()) @applicable_fields -= %i[mac4 qos_ctrl ht_ctrl] define_applicable_fields end |
Instance Method Details
#reply! ⇒ Object
Invert source and destination addresses (see Table 8-19 from IEEE 802.11-2012 document to known which MAC is SA, and which one is DA). Also invert Receiver and Transmitter address in case ToDS and FromDS are true.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/packetgen/header/dot11/data.rb', line 42 def reply! ds = frame_ctrl & 3 case ds when 0 # MAC1: RA/DA, MAC2: TA/SA self[:mac1], self[:mac2] = self[:mac2], self[:mac1] when 1 # MAC1: RA/BSSID, MAC2: TA/SA, MAC3: DA self[:mac2], self[:mac1] = self[:mac1], self[:mac2] self.to_ds = false self.from_ds = true when 2 # MAC1: RA/DA, MAC2: BSSID, MAC3: SA or BSSID self[:mac1], self[:mac2] = self[:mac2], self[:mac1] self.to_ds = true self.from_ds = false when 3 # MAC1: RA, MAC2: TA self[:mac1], self[:mac2] = self[:mac2], self[:mac1] # MAC3: DA, MAC4: SA self[:mac4], self[:mac3] = self[:mac3], self[:mac4] end self end |