class PacketGen::UnknownPacket
Unknown packet, minimaly mimicking a {Packet}.
An unknown packet is generated when capturing packets, and a packet cannot be parsed. @since 3.2.0
Attributes
headers[R]
List of headers. Always empty @return [Array]
Public Class Methods
new()
click to toggle source
# File lib/packetgen/unknown_packet.rb, line 20 def initialize @headers = [].freeze @binary_str = PacketGen.force_binary('') end
Public Instance Methods
==(other)
click to toggle source
equality if {#to_s} is equal @return [Boolean]
# File lib/packetgen/unknown_packet.rb, line 69 def ==(other) to_s == other.to_s end
===(other)
click to toggle source
True only if other
is an {UnknownPacket} and +other == self+ @return [Boolean]
# File lib/packetgen/unknown_packet.rb, line 75 def ===(other) case other when UnknwonPacket self == other else false end end
body()
click to toggle source
Get packet body @return [Types]
# File lib/packetgen/unknown_packet.rb, line 33 def body @binary_str end
Also aliased as: to_s
body=(str)
click to toggle source
Set packet body @param [String] str @return [void]
# File lib/packetgen/unknown_packet.rb, line 41 def body=(str) @binary_str = PacketGen.force_binary(str) end
inspect()
click to toggle source
@return [String]
# File lib/packetgen/unknown_packet.rb, line 63 def inspect # TODO end
is?(_protocol)
click to toggle source
Unknown packet, so unknown protocol. @return [false]
# File lib/packetgen/unknown_packet.rb, line 27 def is?(_protocol) false end
parse(binary_str, _first_header: nil)
click to toggle source
Read binary string @param [String] binary_string @return [self]
# File lib/packetgen/unknown_packet.rb, line 57 def parse(binary_str, _first_header: nil) @binary_str = PacketGen.force_binary(binary_str) self end
to_f(filename)
click to toggle source
Write packet to a PCapNG file on disk. @param [String] filename @return [Array] see return from {PcapNG::File#to_file} @see File
# File lib/packetgen/unknown_packet.rb, line 49 def to_f(filename) PcapNG::File.new.read_array([self]).to_f(filename) end
Also aliased as: write