Method: PacketGen::Header::Dot11#read

Defined in:
lib/packetgen/header/dot11.rb

#read(str) ⇒ Dot11

Populate object from a binary string

Parameters:

  • str (String)

Returns:

  • (Dot11)

    may return a subclass object if a more specific class may be determined

Since:

  • 1.4.0



275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/packetgen/header/dot11.rb', line 275

def read(str)
  fcs = Dot11.fcs?

  if self.instance_of?(Dot11)
    return self if str.nil?

    str = str.b unless str.encoding == Encoding::BINARY
    self[:frame_ctrl].read(str[0, 2])

    case type
    when 0
      Dot11::Management.new.read(str)
    when 1
      Dot11::Control.new.read(str)
    when 2
      Dot11::Data.new.read(str)
    else
      private_read(str, fcs)
    end
  else
    private_read(str, fcs)
  end
end