class Spcap::IPPacket
Attributes
dst[R]
ip_hlen[R]
ip_len[R]
src[R]
Public Class Methods
new(time,data,len,datalink)
click to toggle source
Calls superclass method
# File lib/spcap/ippacket.rb, line 5 def initialize(time,data,len,datalink) super(time,data,len,datalink) @src = IPAddress.new(@raw_data[12,4]) @dst = IPAddress.new(data[16,4]) @ip_hlen = @raw_data.getbyte(0) & 0x0F @ip_len = @raw_data[2,2].unpack("n").first end
Public Instance Methods
ip_data()
click to toggle source
Return data part as String.
# File lib/spcap/ippacket.rb, line 15 def ip_data @raw_data[ip_hlen*4,self.caplen-ip_hlen*4] end
ip_df?()
click to toggle source
Return true if Don't Fragment bit is set.
# File lib/spcap/ippacket.rb, line 26 def ip_df? (@raw_data.getbyte(6) & 0x40) == 0x40 end
ip_dst()
click to toggle source
Return destination IP address as IPAddress
.
# File lib/spcap/ippacket.rb, line 36 def ip_dst @dst end
ip_flags()
click to toggle source
Return the value of 3-bits IP flag field.
# File lib/spcap/ippacket.rb, line 21 def ip_flags @raw_data.getbyte(6) & 0xE0 end
ip_id()
click to toggle source
Return identification.
# File lib/spcap/ippacket.rb, line 45 def ip_id @raw_data[4,4] end
ip_mf?()
click to toggle source
Return true if More Fragment bit is set.
# File lib/spcap/ippacket.rb, line 31 def ip_mf? (self.raw_data.getbyte(6) & 0x20) == 0x20 end
ip_off()
click to toggle source
Return fragment offset.
# File lib/spcap/ippacket.rb, line 50 def ip_off @raw_data[6,2].unpack("n").first & 0xFFF end
ip_proto()
click to toggle source
Return the value of protocol field.
# File lib/spcap/ippacket.rb, line 56 def ip_proto @raw_data.getbyte(9) end
ip_src()
click to toggle source
Return source IP address as IPAddress
.
# File lib/spcap/ippacket.rb, line 40 def ip_src @src end
ip_sum()
click to toggle source
Return the value of checksum field.
# File lib/spcap/ippacket.rb, line 61 def ip_sum @raw_data[10,2].unpack("n").fisrt end
ip_tos()
click to toggle source
Return the value of TOS field.
# File lib/spcap/ippacket.rb, line 67 def ip_tos # TODO end
ip_ttl()
click to toggle source
Return TTL.
# File lib/spcap/ippacket.rb, line 73 def ip_ttl @raw_data.getbyte(8) end
ip_ver()
click to toggle source
Return IP version.
# File lib/spcap/ippacket.rb, line 79 def ip_ver ( @raw_data.getbyte(0) & 0xF0 ) / 16 end
to_s()
click to toggle source
Return string representation.
# File lib/spcap/ippacket.rb, line 84 def to_s "TODO" # TODO end