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, #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.
32 33 34 35 36 |
# File 'lib/packetgen/header/dot11/data.rb', line 32 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
70 71 72 73 |
# File 'lib/packetgen/header/dot11/data.rb', line 70 def dst _src_mac, dst_mac = src_dst_from_mac self.send(dst_mac) end |
#dst=(mac) ⇒ String
Set destination MAC address
78 79 80 81 |
# File 'lib/packetgen/header/dot11/data.rb', line 78 def dst=(mac) _src_mac, dst_mac = src_dst_from_mac self.send(:"#{dst_mac}=", mac) 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.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/packetgen/header/dot11/data.rb', line 43 def reply! ds = frame_ctrl & 3 case ds when 0 # MAC1: RA/DA, MAC2: TA/SA invert_mac :mac1, :mac2 when 1 # MAC1: RA/BSSID, MAC2: TA/SA, MAC3: DA invert_mac :mac1, :mac2 self.to_ds = false self.from_ds = true when 2 # MAC1: RA/DA, MAC2: BSSID, MAC3: SA or BSSID invert_mac :mac1, :mac2 self.to_ds = true self.from_ds = false when 3 # MAC1: RA, MAC2: TA invert_mac :mac1, :mac2 # MAC3: DA, MAC4: SA invert_mac :mac3, :mac4 end self end |
#src ⇒ String
Get source MAC address
85 86 87 88 |
# File 'lib/packetgen/header/dot11/data.rb', line 85 def src src_mac, = src_dst_from_mac self.send(src_mac) end |
#src=(mac) ⇒ String
Set source MAC address
93 94 95 96 |
# File 'lib/packetgen/header/dot11/data.rb', line 93 def src=(mac) src_mac, = src_dst_from_mac self.send(:"#{src_mac}=", mac) end |