Class: PacketGen::Header::Dot11::Data
- Inherits:
-
PacketGen::Header::Dot11
- Object
- BinStruct::Struct
- 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 (
BinStruct::Int16
), -
a #id/duration (
BinStruct::Int16le
), -
a #mac1 (Eth::MacAddr),
-
a #mac2 (Eth::MacAddr),
-
a #mac3 (Eth::MacAddr),
-
a #sequence_ctrl (
BinStruct::Int16
), -
sometimes a #mac4 (Eth::MacAddr),
-
sometimes a #qos_ctrl (
BinStruct::Int16
), -
a #body (a
BinStruct::String
or another PacketGen::Headerable class), -
and a Frame check sequence (#fcs, of type
BinStruct::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, #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 = {}) ⇒ Data
Returns a new instance of Data.
33 34 35 36 37 |
# File 'lib/packetgen/header/dot11/data.rb', line 33 def initialize(={}) super({ type: 2 }.merge!()) @applicable_attributes -= i[mac4 qos_ctrl ht_ctrl] define_applicable_attributes end |
Instance Method Details
#dst ⇒ String
Get destination MAC address. PacketGen::Header::Dot11#from_ds and PacketGen::Header::Dot11#to_ds must be set before using these method.
71 72 73 74 |
# File 'lib/packetgen/header/dot11/data.rb', line 71 def dst _src_mac, dst_mac = src_dst_from_mac self.send(dst_mac) end |
#dst=(mac) ⇒ String
Set destination MAC address. PacketGen::Header::Dot11#from_ds and PacketGen::Header::Dot11#to_ds must be set before using these method.
79 80 81 82 |
# File 'lib/packetgen/header/dot11/data.rb', line 79 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.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/packetgen/header/dot11/data.rb', line 44 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. PacketGen::Header::Dot11#from_ds and PacketGen::Header::Dot11#to_ds must be set before using these method.
86 87 88 89 |
# File 'lib/packetgen/header/dot11/data.rb', line 86 def src src_mac, = src_dst_from_mac self.send(src_mac) end |
#src=(mac) ⇒ String
Set source MAC address. PacketGen::Header::Dot11#from_ds and PacketGen::Header::Dot11#to_ds must be set before using these method.
94 95 96 97 |
# File 'lib/packetgen/header/dot11/data.rb', line 94 def src=(mac) src_mac, = src_dst_from_mac self.send(:"#{src_mac}=", mac) end |