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
Instance Method Summary collapse
-
#dst ⇒ String
Get destination MAC address.
-
#dst=(mac) ⇒ String
Set destination MAC address.
-
#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).
-
#src ⇒ String
Get source MAC address.
-
#src=(mac) ⇒ String
Set source MAC address.
Methods inherited from PacketGen::Header::Dot11
#added_to_packet, #calc_checksum, #fields, #human_type, #inspect, #old_fields, #old_read, #read, #to_s, #to_w
Methods inherited from Base
bind, calculate_and_set_length, #header_id, inherited, #ip_header, known_headers, #ll_header
Methods included from PacketGen::Headerable
#added_to_packet, included, #method_name, #packet, #packet=, #parse?, #protocol_name, #read
Methods inherited from Types::Fields
#[], #[]=, #bits_on, define_bit_fields_on, define_field, define_field_after, define_field_before, #fields, fields, inherited, #inspect, #offset_of, #optional?, #optional_fields, #present?, #read, remove_bit_fields_on, remove_field, #sz, #to_h, #to_s, update_field
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
#dst ⇒ String
Get destination MAC address
69 70 71 72 73 74 75 76 77 |
# File 'lib/packetgen/header/dot11/data.rb', line 69 def dst ds = frame_ctrl & 3 case ds when 0, 2 self.mac1 when 1, 3 self.mac3 end end |
#dst=(mac) ⇒ String
Set destination MAC address
82 83 84 85 86 87 88 89 90 |
# File 'lib/packetgen/header/dot11/data.rb', line 82 def dst=(mac) ds = frame_ctrl & 3 case ds when 0, 2 self.mac1 = mac when 1, 3 self.mac3 = mac end end |
#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 |
#src ⇒ String
Get source MAC address
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/packetgen/header/dot11/data.rb', line 94 def src ds = frame_ctrl & 3 case ds when 0, 1 self.mac2 when 2 self.mac3 when 3 self.mac4 end end |
#src=(mac) ⇒ String
Set source MAC address
109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/packetgen/header/dot11/data.rb', line 109 def src=(mac) ds = frame_ctrl & 3 case ds when 0, 1 self.mac2 = mac when 2 self.mac3 = mac when 3 self.mac4 = mac end end |