Class: PcapSimple::Packet
- Inherits:
-
Object
- Object
- PcapSimple::Packet
- Defined in:
- lib/pcap_simple.rb
Instance Attribute Summary collapse
-
#datagram ⇒ Object
readonly
Returns the value of attribute datagram.
-
#ethernet ⇒ Object
readonly
Returns the value of attribute ethernet.
-
#header ⇒ Object
Returns the value of attribute header.
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#raw_data ⇒ Object
Returns the value of attribute raw_data.
Instance Method Summary collapse
- #dport ⇒ Object
- #dst ⇒ Object
-
#initialize(*args) ⇒ Packet
constructor
A new instance of Packet.
- #ip_id ⇒ Object
- #sport ⇒ Object
- #src ⇒ Object
- #time ⇒ Object
- #udp_data ⇒ Object
Constructor Details
#initialize(*args) ⇒ Packet
Returns a new instance of Packet.
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/pcap_simple.rb', line 40 def initialize(*args) Hash[*args].each {|k,v| self.send("%s="%k,v)} raise ArgumentError, "need to specify raw_data" if raw_data.nil? @ethernet=Ethernet.new(raw_data) @ip =IP.new(@ethernet.data) case ip.ip_p when 17 @datagram=UDP.new(ip.data) end end |
Instance Attribute Details
#datagram ⇒ Object (readonly)
Returns the value of attribute datagram.
38 39 40 |
# File 'lib/pcap_simple.rb', line 38 def datagram @datagram end |
#ethernet ⇒ Object (readonly)
Returns the value of attribute ethernet.
38 39 40 |
# File 'lib/pcap_simple.rb', line 38 def ethernet @ethernet end |
#header ⇒ Object
Returns the value of attribute header.
37 38 39 |
# File 'lib/pcap_simple.rb', line 37 def header @header end |
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
38 39 40 |
# File 'lib/pcap_simple.rb', line 38 def ip @ip end |
#raw_data ⇒ Object
Returns the value of attribute raw_data.
37 38 39 |
# File 'lib/pcap_simple.rb', line 37 def raw_data @raw_data end |
Instance Method Details
#dport ⇒ Object
65 66 67 |
# File 'lib/pcap_simple.rb', line 65 def dport datagram.dport end |
#dst ⇒ Object
56 57 58 |
# File 'lib/pcap_simple.rb', line 56 def dst ip.ip_dst end |
#ip_id ⇒ Object
59 60 61 |
# File 'lib/pcap_simple.rb', line 59 def ip_id ip.ip_id end |
#sport ⇒ Object
62 63 64 |
# File 'lib/pcap_simple.rb', line 62 def sport datagram.sport end |
#src ⇒ Object
53 54 55 |
# File 'lib/pcap_simple.rb', line 53 def src ip.ip_src end |
#time ⇒ Object
68 69 70 |
# File 'lib/pcap_simple.rb', line 68 def time Time.at(header.ts_sec) end |
#udp_data ⇒ Object
50 51 52 |
# File 'lib/pcap_simple.rb', line 50 def udp_data datagram.data end |