Pfx.multicast_decode

You're seeing just the function multicast_decode, go back to Pfx module for more information.

Specs

multicast_decode(prefix()) :: map() | nil

Returns a map with multicast address components for given pfx.

Address components are parsed according to:

  • rfc1112 - Host Extensions for IP Multicasting
  • rfc4291 - IP Version 6 Addressing Architecture

Rfc specific fields are put in their own map under the rfc-key.

  • rfc6034 - Unicast-Prefix-Based IPv4 Multicast Addresses
  • rfc3180 - GLOP Addressing in 233/8
  • rfc3956 - Embedding the Rendezvous Point (RP) Address in an IPv6 Multicast Address
  • rfc3306 - Unicast-Prefix-based IPv6 Multicast Addresses

Note that for unicast-prefix-based IPv4 multicast addresses, the unicast prefix is always taken to be 24 bits long. That should still allow for identification of the origin by looking up the assigned unicast address space that includes the /24.

Examples

iex> multicast_decode("234.192.0.2")
%{
  multicast_address: "234.192.0.2",
  protocol: :ipv4,
  rfc: %{
    group_id: 2,
    multicast_prefix: "234.0.0.0/8",
    rfc: 6034,
    unicast_prefix: "192.0.2.0/24"
  }
}

iex> Pfx.multicast_decode("FF32:0030:3FFE:FFFF:0001::/96")
%{
  flags: {0, 0, 1, 1},
  multicast_address: "ff32:30:3ffe:ffff:1:0:0:0/96",
  multicast_prefix: "ff30:0:0:0:0:0:0:0/12",
  protocol: :ipv6,
  rfc: %{
    group_id: 0,
    unicast_prefix: "3ffe:ffff:1:0:0:0:0:0/48",
    plen: 48,
    reserved: 0,
    rfc: 3306
  },
  scope: 2
}