Class: PacketGen::Header::MLDv2::McastAddressRecord

Inherits:
Types::Fields
  • Object
show all
Includes:
Types::Fieldable
Defined in:
lib/packetgen/header/mldv2/mcast_address_record.rb

Overview

Class to handle MLDv2 Mcast Address Records (MAR).

A Mcast Address Record 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Record Type  |  Aux Data Len |     Number of Sources (N)     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
*                                                               *
|                                                               |
*                       Multicast Address                       *
|                                                               |
*                                                               *
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
*                                                               *
|                                                               |
*                       Source Address [1]                      *
|                                                               |
*                                                               *
|                                                               |
+-                                                             -+
.                               .                               .
.                               .                               .
.                               .                               .
+-                                                             -+
|                                                               |
*                                                               *
|                                                               |
*                       Source Address [N]                      *
|                                                               |
*                                                               *
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
.                                                               .
.                         Auxiliary Data                        .
.                                                               .
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Author:

  • Sylvain Daubert

Since:

  • 2.4.0

Constant Summary collapse

RECORD_TYPES =

Known record types

Since:

  • 2.4.0

IGMPv3::GroupRecord::RECORD_TYPES

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Types::Fieldable

#format_inspect, #read, #sz, #to_s, #type_name

Methods inherited from Types::Fields

#[], #[]=, #bits_on, define_bit_fields_on, define_field, define_field_after, define_field_before, #fields, fields, inherited, #initialize, #inspect, #offset_of, #optional?, #optional_fields, #present?, #read, remove_bit_fields_on, remove_field, #sz, #to_h, #to_s, update_field

Constructor Details

This class inherits a constructor from PacketGen::Types::Fields

Instance Attribute Details

#aux_dataString

Returns:

  • (String)


85
86
# File 'lib/packetgen/header/mldv2/mcast_address_record.rb', line 85

define_field :aux_data, Types::String,
builder: ->(h, t) { t.new(length_from: -> { h[:aux_data_len].to_i * 4 }) }

#aux_data_lenInteger

8-bit length of of the Auxiliary Data field (#aux_data), in unit of 32-bit words

Returns:

  • (Integer)


69
# File 'lib/packetgen/header/mldv2/mcast_address_record.rb', line 69

define_field :aux_data_len, Types::Int8, default: 0

#multicast_addrIPv6::Addr

IP multicast address to which this Multicast Address Record pertains

Returns:



77
# File 'lib/packetgen/header/mldv2/mcast_address_record.rb', line 77

define_field :multicast_addr, IPv6::Addr, default: '::'

#number_of_sourcesInteger

16-bit Number of source addresses in #source_addr

Returns:

  • (Integer)


73
# File 'lib/packetgen/header/mldv2/mcast_address_record.rb', line 73

define_field :number_of_sources, Types::Int16, default: 0

#source_addrIPv6::ArrayOfAddr

Array of source addresses

Returns:



81
82
# File 'lib/packetgen/header/mldv2/mcast_address_record.rb', line 81

define_field :source_addr, IPv6::ArrayOfAddr,
builder: ->(h, t) { t.new(counter: h[:number_of_sources]) }

#typeInteger

8-bit record type

Returns:

  • (Integer)


64
# File 'lib/packetgen/header/mldv2/mcast_address_record.rb', line 64

define_field :type, Types::Int8Enum, enum: RECORD_TYPES

Instance Method Details

#human_typeObject

Since:

  • 2.4.0



88
89
90
# File 'lib/packetgen/header/mldv2/mcast_address_record.rb', line 88

def human_type
  self[:type].to_human
end

#to_humanObject

Since:

  • 2.4.0



92
93
94
# File 'lib/packetgen/header/mldv2/mcast_address_record.rb', line 92

def to_human
  "#{human_type}(ma:#{multicast_addr}|src:#{source_addr.to_human})"
end