NetPacket::IGMP(3)

πŸ’– NetPacket::IGMP β€” bestie's guide to IGMP packets πŸ’–

okay so this is NetPacket::IGMP, a Perl module living in the NetPacket::IGMP(3) man page, and it's literally here to help you assemble and disassemble IGMP (Internet Group Management Protocol) packets. group chat but for routers, no cap 🫢


✨ VERSION ✨

version 1.8.0 β€” that's the one, that's the era we're in πŸ’…


🌸 SYNOPSIS 🌸

the vibe check, in code:

use NetPacket::IGMP;

$igmp_obj = NetPacket::IGMP->decode($raw_pkt);
$igmp_pkt = NetPacket::IGMP->encode(params...);   # Not implemented
$igmp_data = NetPacket::IGMP::strip($raw_pkt);
πŸ‘€ yes bestie, that # Not implemented comment is real and it's staying. we'll get to it.

πŸ¦‹ DESCRIPTION πŸ¦‹

NetPacket::IGMP hands you a whole little set of routines for assembling and disassembling packets using IGMP (Internet Group Management Protocol). it's giving packet whisperer, fr fr ✨

πŸŽ€ Methods πŸŽ€

  • NetPacket::IGMP->decode([RAW PACKET]) β€” decode the raw packet data you hand it and get back an object stuffed with instance data. and listen: this method will quite happily decode garbage input. like, it does not care. it's not gonna stop you. it is the responsibility of the programmer to make sure valid packet data is actually passed to this method. so like… pls be responsible πŸ’€
  • NetPacket::IGMP->encode(param => value) β€” returns an IGMP packet encoded with the instance data you specified. Not implemented. that's it, that's the whole thing πŸ™ˆ

🧚 Functions 🧚

  • NetPacket::IGMP::strip([RAW PACKET]) β€” returns the encapsulated data (aka the payload) contained in the IGMP packet. plot twist: this function returns undef, because there is no encapsulated data in an IGMP packet. it's empty on purpose, main character energy of a function that gives you nothing 😭

πŸ’œ Instance data πŸ’œ

the instance data on the NetPacket::IGMP object is made up of these fields:

  • version β€” the IGMP version of this packet.
  • type β€” the message type for this packet.
  • len β€” the length (including length of header) in bytes for this packet.
  • subtype β€” the message subtype for this packet.
  • cksum β€” the checksum for this packet.
  • group_addr β€” the group address specified in this packet.
  • data β€” the encapsulated data (payload) for this packet.

🌈 Exports 🌈

  • default β€” none. we start with nothing, we build from there 🫢
  • exportable β€” IGMP_VERSION_RFC998 IGMP_VERSION_RFC1112 IGMP_HOST_MQUERY IGMP_HOST_MREPORT IGMP_IP_NO_HOSTS IGMP_IP_ALL_HOSTS IGMP_IP_ALL_ROUTERS
  • tags β€” these tags group together related exportable items:
    • :strip β€” import the strip function igmp_strip.
    • :versions β€” IGMP_VERSION_RFC998 IGMP_VERSION_RFC1112
    • :msgtypes β€” IGMP_HOST_MQUERY IGMP_HOST_MREPORT
    • :group_addrs β€” IGMP_IP_NO_HOSTS IGMP_IP_ALL_HOSTS IGMP_IP_ALL_ROUTERS
    • :ALL β€” all the above exportable items. the everything bagel πŸ₯―

⭐ EXAMPLE ⭐

the following script dumps UDP frames by IP address and UDP port to standard output. iconic behaviour honestly πŸ‘‘

#!/usr/bin/perl -w

use strict;
use Net::PcapUtils;
use NetPacket::Ethernet qw(:strip);
use NetPacket::IP;
use NetPacket::IGMP;

sub process_pkt {
    my($arg, $hdr, $pkt) = @_;

    my $ip_obj = NetPacket::IP->decode(eth_strip($pkt));
    my $igmp_obj = NetPacket::IGMP->decode($ip_obj->{data});

    print("$ip_obj->{src_ip} -> $ip_obj->{dest_ip} ",
          "$igmp_obj->{type}/$igmp_obj->{subtype} ",
          "$igmp_obj->{group_addr}\n");
}

Net::PcapUtils::loop(\&process_pkt, FILTER => 'igmp');

πŸ”₯ TODO πŸ”₯

Implement encode() function

bestie. the encode function. it's on the list. it's been on the list. 😭

Copyright (c) 2001 Tim Potter.

Copyright (c) 1995,1996,1997,1998,1999 ANU and CSIRO on behalf of the participants in the CRC for Advanced Computational Systems ('ACSys').

This module is free software. You can redistribute it and/or modify it under the terms of the Artistic License 2.0.

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.

⚠️ yes that no-warranty line is doing a lot of heavy lifting, and yes it means what it says.

πŸ’… AUTHOR πŸ’…

Tim Potter <tpot@samba.org>


and that's the whole page, bestie 🫢 this was NetPacket::IGMP(3), shipped as part of perl v5.42.0, dated 2026-02-05 β€” ty for coming to my TED talk, go decode something cute πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from