Class: Spcap::Packet

Inherits:
Object
  • Object
show all
Defined in:
lib/spcap/packet.rb

Direct Known Subclasses

IPPacket

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time, data, len, datalink) ⇒ Packet

Returns a new instance of Packet.



5
6
7
8
9
10
11
# File 'lib/spcap/packet.rb', line 5

def initialize(time,data,len,datalink)
  @time = time
  @raw_data = data
  @caplen = data.length
  @len = len
  @datalink = datalink
end

Instance Attribute Details

#caplenObject (readonly)

Returns the value of attribute caplen.



3
4
5
# File 'lib/spcap/packet.rb', line 3

def caplen
  @caplen
end

Returns the value of attribute datalink.



3
4
5
# File 'lib/spcap/packet.rb', line 3

def datalink
  @datalink
end

#lenObject (readonly)

Returns the value of attribute len.



3
4
5
# File 'lib/spcap/packet.rb', line 3

def len
  @len
end

#raw_dataObject (readonly)

Returns the value of attribute raw_data.



3
4
5
# File 'lib/spcap/packet.rb', line 3

def raw_data
  @raw_data
end

#timeObject (readonly)

Returns the value of attribute time.



3
4
5
# File 'lib/spcap/packet.rb', line 3

def time
  @time
end

Instance Method Details

#ip?Boolean

Returns:

  • (Boolean)


15
# File 'lib/spcap/packet.rb', line 15

def ip? ; self.kind_of?(IPPacket) ; end

#lengthObject



14
# File 'lib/spcap/packet.rb', line 14

def length ; @len; end

#sizeObject



13
# File 'lib/spcap/packet.rb', line 13

def size ; @len; end

#tcp?Boolean

Returns:

  • (Boolean)


16
# File 'lib/spcap/packet.rb', line 16

def tcp? ; self.kind_of?(TCPPacket) ; end

#time_iObject



18
# File 'lib/spcap/packet.rb', line 18

def time_i ; self.time.to_i ; end

#udp?Boolean

Returns:

  • (Boolean)


17
# File 'lib/spcap/packet.rb', line 17

def udp? ; self.kind_of?(UDPPacket) ; end