Class: Spcap::IPPacket
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Packet
#caplen, #datalink, #len, #raw_data, #time
Instance Method Summary collapse
-
#ip_data ⇒ Object
Return data part as String.
-
#ip_df? ⇒ Boolean
Return true if Don’t Fragment bit is set.
-
#ip_dst ⇒ Object
Return destination IP address as IPAddress.
-
#ip_flags ⇒ Object
Return the value of 3-bits IP flag field.
-
#ip_hlen ⇒ Object
Return header length.
-
#ip_id ⇒ Object
Return identification.
-
#ip_mf? ⇒ Boolean
Return true if More Fragment bit is set.
-
#ip_off ⇒ Object
Return fragment offset.
-
#ip_proto ⇒ Object
Return the value of protocol field.
-
#ip_src ⇒ Object
Return source IP address as IPAddress.
-
#ip_sum ⇒ Object
Return the value of checksum field.
-
#ip_tos ⇒ Object
Return the value of TOS field.
-
#ip_ttl ⇒ Object
Return TTL.
-
#ip_ver ⇒ Object
Return IP version.
-
#to_s ⇒ Object
Return string representation.
Methods inherited from Packet
#initialize, #ip?, #length, #size, #tcp?, #time_i, #udp?
Constructor Details
This class inherits a constructor from Spcap::Packet
Instance Method Details
#ip_data ⇒ Object
Return data part as String.
20 21 22 |
# File 'lib/spcap/ippacket.rb', line 20 def ip_data @raw_data[ip_hlen,self.caplen-ip_hlen] end |
#ip_df? ⇒ Boolean
Return true if Don’t Fragment bit is set.
31 32 33 |
# File 'lib/spcap/ippacket.rb', line 31 def ip_df? (@raw_data.getbyte(6) & 0x40) == 0x40 end |
#ip_dst ⇒ Object
Return destination IP address as IPAddress.
41 42 43 |
# File 'lib/spcap/ippacket.rb', line 41 def ip_dst @dst end |
#ip_flags ⇒ Object
Return the value of 3-bits IP flag field.
26 27 28 |
# File 'lib/spcap/ippacket.rb', line 26 def ip_flags @raw_data.getbyte(6) & 0xE0 end |
#ip_hlen ⇒ Object
Return header length. (Unit: 4 octets)
15 16 17 |
# File 'lib/spcap/ippacket.rb', line 15 def ip_hlen @raw_data.getbyte(0) & 0x0F end |
#ip_id ⇒ Object
Return identification.
50 51 52 |
# File 'lib/spcap/ippacket.rb', line 50 def ip_id @raw_data[4,4] end |
#ip_mf? ⇒ Boolean
Return true if More Fragment bit is set.
36 37 38 |
# File 'lib/spcap/ippacket.rb', line 36 def ip_mf? (self.raw_data.getbyte(6) & 0x20) == 0x20 end |
#ip_off ⇒ Object
Return fragment offset.
55 56 57 |
# File 'lib/spcap/ippacket.rb', line 55 def ip_off @raw_data[4,4].unpack("n").first & 0xFFF end |
#ip_proto ⇒ Object
Return the value of protocol field.
61 62 63 |
# File 'lib/spcap/ippacket.rb', line 61 def ip_proto @raw_data.getbyte(9) end |
#ip_src ⇒ Object
Return source IP address as IPAddress.
45 46 47 |
# File 'lib/spcap/ippacket.rb', line 45 def ip_src @src end |
#ip_sum ⇒ Object
Return the value of checksum field.
66 67 68 |
# File 'lib/spcap/ippacket.rb', line 66 def ip_sum @raw_data[10,2].unpack("n").fisrt end |
#ip_tos ⇒ Object
Return the value of TOS field.
72 73 74 |
# File 'lib/spcap/ippacket.rb', line 72 def ip_tos # TODO end |
#ip_ttl ⇒ Object
Return TTL.
78 79 80 |
# File 'lib/spcap/ippacket.rb', line 78 def ip_ttl @raw_data.getbyte(8) end |
#ip_ver ⇒ Object
Return IP version.
84 85 86 |
# File 'lib/spcap/ippacket.rb', line 84 def ip_ver ( @raw_data.getbyte(0) & 0xF0 ) / 16 end |
#to_s ⇒ Object
Return string representation.
89 90 91 |
# File 'lib/spcap/ippacket.rb', line 89 def to_s "TODO" # TODO end |