Class: Packetnom::Packet::Ip
- Inherits:
-
Object
- Object
- Packetnom::Packet::Ip
- Defined in:
- lib/packet/ip.rb
Instance Attribute Summary collapse
-
#ds ⇒ Object
Returns the value of attribute ds.
-
#dst ⇒ Object
(also: #dest, #target)
Returns the value of attribute dst.
-
#flags ⇒ Object
Returns the value of attribute flags.
-
#id ⇒ Object
Returns the value of attribute id.
-
#ihl ⇒ Object
Returns the value of attribute ihl.
-
#len ⇒ Object
(also: #length)
Returns the value of attribute len.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#proto ⇒ Object
(also: #protocol)
Returns the value of attribute proto.
-
#src ⇒ Object
(also: #source, #from)
Returns the value of attribute src.
-
#sum ⇒ Object
(also: #checksum)
Returns the value of attribute sum.
-
#ttl ⇒ Object
Returns the value of attribute ttl.
-
#version ⇒ Object
Attributes.
Instance Method Summary collapse
-
#initialize(bytes) ⇒ Ip
constructor
Initialize the packet.
Constructor Details
#initialize(bytes) ⇒ Ip
Initialize the packet
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/packet/ip.rb', line 22 def initialize( bytes ) @packet = bytes @version = bytes[14].split(//)[0] @ihl = bytes[14].split(//)[1] @ds = bytes[15] @len = bytes[16..17].join().to_i(16) @id = bytes[18..19].join() @flags = bytes[20].split(//)[0].to_i(16) #todo @offset = "#{bytes[20].split(//)[1]}#{bytes[21]}".to_i(16) #todo @ttl = bytes[22].to_i(16) @proto = bytes[23].to_i(16) @sum = bytes[24..25].join().to_i(16) @src = bytes[26..29].map{|octet| octet.to_i(16).to_s(10)}.join('.') @dst = bytes[30..33].map{|octet| octet.to_i(16).to_s(10)}.join('.') end |
Instance Attribute Details
#ds ⇒ Object
Returns the value of attribute ds.
10 11 12 |
# File 'lib/packet/ip.rb', line 10 def ds @ds end |
#dst ⇒ Object Also known as: dest, target
Returns the value of attribute dst.
19 20 21 |
# File 'lib/packet/ip.rb', line 19 def dst @dst end |
#flags ⇒ Object
Returns the value of attribute flags.
13 14 15 |
# File 'lib/packet/ip.rb', line 13 def flags @flags end |
#id ⇒ Object
Returns the value of attribute id.
12 13 14 |
# File 'lib/packet/ip.rb', line 12 def id @id end |
#ihl ⇒ Object
Returns the value of attribute ihl.
9 10 11 |
# File 'lib/packet/ip.rb', line 9 def ihl @ihl end |
#len ⇒ Object Also known as: length
Returns the value of attribute len.
11 12 13 |
# File 'lib/packet/ip.rb', line 11 def len @len end |
#offset ⇒ Object
Returns the value of attribute offset.
14 15 16 |
# File 'lib/packet/ip.rb', line 14 def offset @offset end |
#proto ⇒ Object Also known as: protocol
Returns the value of attribute proto.
16 17 18 |
# File 'lib/packet/ip.rb', line 16 def proto @proto end |
#src ⇒ Object Also known as: source, from
Returns the value of attribute src.
18 19 20 |
# File 'lib/packet/ip.rb', line 18 def src @src end |
#sum ⇒ Object Also known as: checksum
Returns the value of attribute sum.
17 18 19 |
# File 'lib/packet/ip.rb', line 17 def sum @sum end |
#ttl ⇒ Object
Returns the value of attribute ttl.
15 16 17 |
# File 'lib/packet/ip.rb', line 15 def ttl @ttl end |
#version ⇒ Object
Attributes
8 9 10 |
# File 'lib/packet/ip.rb', line 8 def version @version end |