Class: Jruby::Pcap::Frame
- Inherits:
-
Object
- Object
- Jruby::Pcap::Frame
- Defined in:
- lib/jruby-pcap/frame.rb
Instance Method Summary collapse
- #dst_addr ⇒ Object
- #dst_host ⇒ Object
- #dst_port ⇒ Object
- #dst_port_name ⇒ Object
-
#initialize(handle, frame) ⇒ Frame
constructor
A new instance of Frame.
- #length ⇒ Object
- #protocol ⇒ Object
- #src_addr ⇒ Object
- #src_host ⇒ Object
- #src_port ⇒ Object
- #src_port_name ⇒ Object
- #to_hash ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(handle, frame) ⇒ Frame
Returns a new instance of Frame.
4 5 6 7 8 |
# File 'lib/jruby-pcap/frame.rb', line 4 def initialize(handle, frame) @handle = handle @frame = frame @header = @frame.header end |
Instance Method Details
#dst_addr ⇒ Object
26 27 28 |
# File 'lib/jruby-pcap/frame.rb', line 26 def dst_addr @header.dst_addr.to_s.gsub("/","") end |
#dst_host ⇒ Object
30 31 32 |
# File 'lib/jruby-pcap/frame.rb', line 30 def dst_host @header.dst_addr.host_name end |
#dst_port ⇒ Object
34 35 36 |
# File 'lib/jruby-pcap/frame.rb', line 34 def dst_port @header.dst_port.value_as_string end |
#dst_port_name ⇒ Object
38 39 40 |
# File 'lib/jruby-pcap/frame.rb', line 38 def dst_port_name @header.dst_port.name end |
#length ⇒ Object
50 51 52 |
# File 'lib/jruby-pcap/frame.rb', line 50 def length @frame.length end |
#protocol ⇒ Object
42 43 44 |
# File 'lib/jruby-pcap/frame.rb', line 42 def protocol @header.protocol.name end |
#src_addr ⇒ Object
10 11 12 |
# File 'lib/jruby-pcap/frame.rb', line 10 def src_addr @header.src_addr.to_s.gsub("/","") end |
#src_host ⇒ Object
14 15 16 |
# File 'lib/jruby-pcap/frame.rb', line 14 def src_host @header.src_addr.host_name end |
#src_port ⇒ Object
18 19 20 |
# File 'lib/jruby-pcap/frame.rb', line 18 def src_port @header.src_port.value_as_string end |
#src_port_name ⇒ Object
22 23 24 |
# File 'lib/jruby-pcap/frame.rb', line 22 def src_port_name @header.src_port.name end |
#to_hash ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/jruby-pcap/frame.rb', line 54 def to_hash hash = {} if (@frame.is_a?(IpV4Packet)) hash['src_addr'] = src_addr hash['dst_addr'] = dst_addr hash['procotol'] = protocol hash['version'] = version hash['ip_length'] = length elsif (@frame.is_a?(TcpPacket) || @frame.is_a?(UdpPacket)) hash['src_port'] = src_port hash['src_port_name'] = src_port_name hash['dst_port'] = dst_port hash['dst_port_name'] = dst_port_name hash['tcpip_length'] = length end hash end |
#version ⇒ Object
46 47 48 |
# File 'lib/jruby-pcap/frame.rb', line 46 def version @header.version.name end |