Class: PacketGen::Header::MLD
- Defined in:
- lib/packetgen/header/mld.rb
Overview
This class supports Multicast Listener Discovery for IPv6 (RFC 2710).
From RFC 2710, a MLD header has the following format:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Maximum Response delay | Reserved |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
+ +
| |
+ Multicast Address +
| |
+ +
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
A MLD header consists of:
-
a #max_resp_delay field (
BinStruct::Int16
type), -
a #reserved field (
BinStruct::Int16
type), -
a #mcast_addr field (IPv6::Addr type),
-
and a #body (unused for MLDv1).
Direct Known Subclasses
Instance Attribute Summary collapse
- #body ⇒ String, Headerable
-
#max_resp_delay ⇒ Integer
(also: #max_resp_code)
16-bit MLD Max Response Delay.
-
#mcast_addr ⇒ IPv6::Addr
IPv6 Multicast address.
-
#reserved ⇒ Integer
16-bit Reserved field.
Instance Method Summary collapse
-
#added_to_packet(packet) ⇒ Object
private
This method adds
#mldize
method topacket
. -
#mldize ⇒ void
Fixup IP header according to RFC 2710: * set Hop limit to 1, * add Router Alert option, * recalculate checksum and length.
Methods inherited from Base
bind, calculate_and_set_length, #header_id, inherited, #initialize, #ip_header, #ll_header
Methods included from PacketGen::Headerable
included, #method_name, #packet, #packet=, #parse?, #protocol_name, #read, #to_s
Constructor Details
This class inherits a constructor from PacketGen::Header::Base
Instance Attribute Details
#body ⇒ String, Headerable
66 |
# File 'lib/packetgen/header/mld.rb', line 66 define_attr :body, BinStruct::String |
#max_resp_delay ⇒ Integer Also known as: max_resp_code
16-bit MLD Max Response Delay
53 |
# File 'lib/packetgen/header/mld.rb', line 53 define_attr :max_resp_delay, BinStruct::Int16 |
#mcast_addr ⇒ IPv6::Addr
IPv6 Multicast address
63 |
# File 'lib/packetgen/header/mld.rb', line 63 define_attr :mcast_addr, IPv6::Addr, default: '::' |
#reserved ⇒ Integer
16-bit Reserved field
59 |
# File 'lib/packetgen/header/mld.rb', line 59 define_attr :reserved, BinStruct::Int16 |
Instance Method Details
#added_to_packet(packet) ⇒ Object
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 is used internally by PacketGen and should not be directly called
This method adds #mldize
method to packet
. This method calls #mldize.
72 73 74 75 |
# File 'lib/packetgen/header/mld.rb', line 72 def added_to_packet(packet) mld_idx = packet.headers.size packet.instance_eval "def mldize() @headers[#{mld_idx}].mldize; end" # def mldize() @headers[3].mldize; end end |
#mldize ⇒ void
This method returns an undefined value.
Fixup IP header according to RFC 2710:
-
set Hop limit to 1,
-
add Router Alert option,
-
recalculate checksum and length.
This method may be called as:
# first method
pkt.mld.mldize
# second method
pkt.mldize
87 88 89 90 91 92 93 94 |
# File 'lib/packetgen/header/mld.rb', line 87 def mldize ipv6 = ip_header(self) ipv6.hop = 1 ipv6.next = 0 packet.insert(ipv6, 'IPv6::HopByHop', next: ICMPv6::IP_PROTOCOL) packet.ipv6_hopbyhop. << { type: 'router_alert', value: [0].pack('n') } packet.calc end |