SatCat5
igmp_client.h File Reference

Detailed Description

Client-side implementation of the Internet Group Management Protocol (IGMP)

Any IPv4 packet sent to 224.0.0.0/8 (i.e., 224.*.*.*) is a "multicast" packet. Routers should send multicast packets to interested recipients, including routers with downstream recipients, but avoid sending them to uninterested hosts. IGMP is the protocol that routers to determine which next-hop interface(s) have members subscribed to a given multicast address (i.e., a "group"), so it can forward only to those port(s).

This file implements the "host" (i.e., client/endpoint) side of IGMP:

  • ip::IgmpAddress represents a client subscription to a multicast group.
  • ip::IgmpClient is the host endpoint that responds to IGMP queries.

As required by IETF, the client defaults to IGMPv3, but is fully backwards compatible with IGMPv1 and IGMPv2, and will downgrade as needed to support networks with legacy routers. However, SatCat5 does not currently support the source-address filtering features of IGMPv3, always responding as if the end-user has requested an exclude-none policy.

IGMPv1 is defined by IETF RFC-1112. IGMPv2 is defined by IETF RFC-2236. IGMPv3 is defined by IETF RFC-9776.

Definition in file igmp_client.h.

#include <satcat5/ip_core.h>
#include <satcat5/list.h>
#include <satcat5/net_protocol.h>
#include <satcat5/polling.h>
Include dependency graph for igmp_client.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  satcat5::igmp::Client
 Host/Client for the Internet Group Management Protocol (IGMP). More...
 
struct  satcat5::igmp::Address
 Client state for an IGMP multicast subscription. More...
 

Macros

#define SATCAT5_IGMP_ENABLE   1
 

Functions

constexpr satcat5::ip::Addr satcat5::igmp::DST_ALL_SYSTEMS (224, 0, 0, 1)
 
constexpr satcat5::ip::Addr satcat5::igmp::DST_ALL_ROUTERS (224, 0, 0, 2)
 < All endpoints on subnet.
 
constexpr satcat5::ip::Addr satcat5::igmp::DST_IGMPV3_REPORT (224, 0, 0, 22)
 < All routers on subnet. More...
 
bool satcat5::igmp::igmp_send (satcat5::ip::Dispatch *iface, const satcat5::ip::Addr &dst, const unsigned wcount, u16 *data)
 Given IGMP message contents, write Eth/IP headers and send packet. More...
 
u32 satcat5::igmp::decode_maxdly (u16 hdr, bool v3)
 Given the first word of the IGMP query header, decode max delay. More...
 

Variables

constexpr u16 satcat5::igmp::MASK_TYPE = 0xFF00
 Bit-mask "type" from first header word.
 
constexpr u16 satcat5::igmp::MASK_MAXLEN = 0x00FF
 Bit-mask "length" from first header word.
 
constexpr u16 satcat5::igmp::TYPE_QUERY = 0x1100
 IGMP query (all versions)
 
constexpr u16 satcat5::igmp::TYPE_REPORT_V1 = 0x1200
 Reply to IGMPv1 query.
 
constexpr u16 satcat5::igmp::TYPE_REPORT_V2 = 0x1600
 Reply to IGMPv2 query.
 
constexpr u16 satcat5::igmp::TYPE_LEAVE_V2 = 0x1700
 Leaving group (v2 / v3)
 
constexpr u16 satcat5::igmp::TYPE_REPORT_V3 = 0x2200
 Reply to IGMPv3 query.
 
constexpr u16 satcat5::igmp::RECORD_MODE_INCL = 0x0100
 Record type: Include mode.
 
constexpr u16 satcat5::igmp::RECORD_MODE_EXCL = 0x0200
 Record type: Exclude mode.
 
constexpr u16 satcat5::igmp::RECORD_CHANGE_INCL = 0x0300
 Record type: Change to INCL mode.
 
constexpr u16 satcat5::igmp::RECORD_CHANGE_EXCL = 0x0400
 Record type: Change to EXCL mode.
 
constexpr u16 satcat5::igmp::RECORD_ALLOW_NEW = 0x0500
 Record type: Append to allow list.
 
constexpr u16 satcat5::igmp::RECORD_BLOCK_OLD = 0x0600
 Record type: Append to block list.
 
constexpr unsigned satcat5::igmp::MIN_LEN_SHORTS = 4
 Set upper and lower bounds for the length of an IGMP message.
 
constexpr unsigned satcat5::igmp::MIN_LEN_BYTES = 2 * MIN_LEN_SHORTS
 Set upper and lower bounds for the length of an IGMP message.
 
constexpr unsigned satcat5::igmp::MAX_LEN_SHORTS = 730
 Set upper and lower bounds for the length of an IGMP message.
 
constexpr unsigned satcat5::igmp::MAX_LEN_BYTES = 2 * MAX_LEN_SHORTS
 Set upper and lower bounds for the length of an IGMP message.
 
constexpr unsigned satcat5::igmp::MAX_V3_RECORDS = (MAX_LEN_SHORTS - 4) / 4
 Set upper and lower bounds for the length of an IGMP message.
 

Function Documentation

◆ decode_maxdly()

u32 satcat5::igmp::decode_maxdly ( u16  hdr,
bool  v3 
)

Given the first word of the IGMP query header, decode max delay.

The overall message length allows the IGMP version to be inferred.

Returns
Maximum delay in milliseconds.

Definition at line 60 of file igmp_client.cc.

◆ DST_IGMPV3_REPORT()

constexpr satcat5::ip::Addr satcat5::igmp::DST_IGMPV3_REPORT ( 224  ,
,
,
22   
)

< All routers on subnet.

Group for IGMPv3 reports.

◆ igmp_send()

bool satcat5::igmp::igmp_send ( satcat5::ip::Dispatch iface,
const satcat5::ip::Addr dst,
const unsigned  wcount,
u16 *  data 
)

Given IGMP message contents, write Eth/IP headers and send packet.

This helper function is used by igmp::Client and igmp::Server.

Definition at line 26 of file igmp_client.cc.