Class: SimpleCapture::IPv4Header
- Inherits:
-
Object
- Object
- SimpleCapture::IPv4Header
- Defined in:
- lib/simple_capture/header/ipv4_header.rb
Constant Summary collapse
- ICMP =
1
Instance Attribute Summary collapse
-
#checksum ⇒ Object
readonly
Returns the value of attribute checksum.
-
#dst_addr ⇒ Object
readonly
Returns the value of attribute dst_addr.
-
#flags ⇒ Object
readonly
Returns the value of attribute flags.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#ihl ⇒ Object
readonly
Returns the value of attribute ihl.
-
#length ⇒ Object
readonly
Returns the value of attribute length.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#src_addr ⇒ Object
readonly
Returns the value of attribute src_addr.
-
#ttl ⇒ Object
readonly
Returns the value of attribute ttl.
-
#type_of_service ⇒ Object
readonly
Returns the value of attribute type_of_service.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #dump ⇒ Object
-
#initialize(bytes: nil) ⇒ IPv4Header
constructor
A new instance of IPv4Header.
- #upper_layer_protocol_icmp? ⇒ Boolean
Constructor Details
#initialize(bytes: nil) ⇒ IPv4Header
Returns a new instance of IPv4Header.
9 10 11 12 13 14 |
# File 'lib/simple_capture/header/ipv4_header.rb', line 9 def initialize(bytes: nil) # support 20Byte IPHeader only now. raise ArgumentError, "bytes's size must be 20Byte" unless bytes.size == 20 convert_bytes_to_header(bytes) unless bytes.nil? end |
Instance Attribute Details
#checksum ⇒ Object (readonly)
Returns the value of attribute checksum.
5 6 7 |
# File 'lib/simple_capture/header/ipv4_header.rb', line 5 def checksum @checksum end |
#dst_addr ⇒ Object (readonly)
Returns the value of attribute dst_addr.
5 6 7 |
# File 'lib/simple_capture/header/ipv4_header.rb', line 5 def dst_addr @dst_addr end |
#flags ⇒ Object (readonly)
Returns the value of attribute flags.
5 6 7 |
# File 'lib/simple_capture/header/ipv4_header.rb', line 5 def flags @flags end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/simple_capture/header/ipv4_header.rb', line 5 def id @id end |
#ihl ⇒ Object (readonly)
Returns the value of attribute ihl.
5 6 7 |
# File 'lib/simple_capture/header/ipv4_header.rb', line 5 def ihl @ihl end |
#length ⇒ Object (readonly)
Returns the value of attribute length.
5 6 7 |
# File 'lib/simple_capture/header/ipv4_header.rb', line 5 def length @length end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
5 6 7 |
# File 'lib/simple_capture/header/ipv4_header.rb', line 5 def offset @offset end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
5 6 7 |
# File 'lib/simple_capture/header/ipv4_header.rb', line 5 def protocol @protocol end |
#src_addr ⇒ Object (readonly)
Returns the value of attribute src_addr.
5 6 7 |
# File 'lib/simple_capture/header/ipv4_header.rb', line 5 def src_addr @src_addr end |
#ttl ⇒ Object (readonly)
Returns the value of attribute ttl.
5 6 7 |
# File 'lib/simple_capture/header/ipv4_header.rb', line 5 def ttl @ttl end |
#type_of_service ⇒ Object (readonly)
Returns the value of attribute type_of_service.
5 6 7 |
# File 'lib/simple_capture/header/ipv4_header.rb', line 5 def type_of_service @type_of_service end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
5 6 7 |
# File 'lib/simple_capture/header/ipv4_header.rb', line 5 def version @version end |
Instance Method Details
#dump ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/simple_capture/header/ipv4_header.rb', line 16 def dump puts "■ipv4--------------------------------------".yellow print_version print_ihl print_type_of_service print_length print_id print_flags print_offset print_ttl print_protocol print_checksum print_src_addr print_dst_addr end |
#upper_layer_protocol_icmp? ⇒ Boolean
32 33 34 |
# File 'lib/simple_capture/header/ipv4_header.rb', line 32 def upper_layer_protocol_icmp? protocol == ICMP end |