Module: PacketGen::Header::HeaderMethods
Overview
Mixin for various headers
Instance Method Summary collapse
-
#header_id(header) ⇒ Integer
private
Get
headerid in packet headers array. -
#ip_header(header) ⇒ Header
private
Get IP or IPv6 previous header from
header. -
#packet ⇒ Packet
private
Get rference on packet which owns this header.
-
#packet=(packet) ⇒ void
private
Set reference of packet which owns this header.
Instance Method Details
#header_id(header) ⇒ Integer
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get header id in packet headers array
28 29 30 31 32 33 34 35 |
# File 'lib/packetgen/header/header_methods.rb', line 28 def header_id(header) raise FormatError, "header of type #{header.class} not in a packet" if packet.nil? id = packet.headers.index(header) if id.nil? raise FormatError, "header of type #{header.class} not in packet #{packet}" end id end |
#ip_header(header) ⇒ Header
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get IP or IPv6 previous header from header
43 44 45 46 47 48 |
# File 'lib/packetgen/header/header_methods.rb', line 43 def ip_header(header) hid = header_id(header) iph = packet.headers[0...hid].reverse.find { |h| h.is_a? IP or h.is_a? IPv6 } raise FormatError, 'no IP or IPv6 header in packet' if iph.nil? iph end |
#packet ⇒ Packet
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get rference on packet which owns this header
19 20 21 |
# File 'lib/packetgen/header/header_methods.rb', line 19 def packet @packet end |
#packet=(packet) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Set reference of packet which owns this header
12 13 14 |
# File 'lib/packetgen/header/header_methods.rb', line 12 def packet=(packet) @packet = packet end |