Class: Jruby::Pcap::Packet
- Inherits:
-
Object
- Object
- Jruby::Pcap::Packet
- Defined in:
- lib/jruby-pcap/packet.rb
Instance Method Summary collapse
-
#initialize(packet, handle) ⇒ Packet
constructor
A new instance of Packet.
- #ipv4 ⇒ Object
- #tcp ⇒ Object
- #timestamp ⇒ Object
- #to_hash ⇒ Object
- #to_s ⇒ Object
- #udp ⇒ Object
Constructor Details
#initialize(packet, handle) ⇒ Packet
Returns a new instance of Packet.
6 7 8 9 |
# File 'lib/jruby-pcap/packet.rb', line 6 def initialize(packet, handle) @packet = packet @handle = handle end |
Instance Method Details
#ipv4 ⇒ Object
15 16 17 18 |
# File 'lib/jruby-pcap/packet.rb', line 15 def ipv4 dataset = @packet.get(IpV4Packet) Frame.new( @handle, dataset ) if dataset end |
#tcp ⇒ Object
25 26 27 28 |
# File 'lib/jruby-pcap/packet.rb', line 25 def tcp dataset = @packet.get(TcpPacket) Frame.new( @handle, dataset ) if dataset end |
#timestamp ⇒ Object
11 12 13 |
# File 'lib/jruby-pcap/packet.rb', line 11 def @handle. * 1000 end |
#to_hash ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/jruby-pcap/packet.rb', line 30 def to_hash hash = {} hash.merge!(ipv4.to_hash) if ipv4 hash.merge!(tcp.to_hash) if tcp hash.merge!(udp.to_hash) if udp hash end |
#to_s ⇒ Object
38 39 40 |
# File 'lib/jruby-pcap/packet.rb', line 38 def to_s @packet.to_s end |