Make it configurable

This commit is contained in:
Ryan Voots 2019-05-22 15:35:14 -07:00
parent fc983d033c
commit ec568e59e1

13
igmp.pl
View file

@ -10,9 +10,10 @@ use Net::Write::Layer qw/:constants/;
use Net::Write::Layer3;
use Sys::HostIP;
my $src_ip = Sys::HostIP->new()->ip;
my $hdmi_dev = 0+$ARGV[0];
my $multicast_addr = sprintf("239.255.42.%d", 42+$hdmi_dev);
#socket my $raw_socket, AF_INET, SOCK_RAW, IPPROTO_RAW or die "Couldn't open socket $!";
my $src_ip = Sys::HostIP->new()->ip;
my $ipv4 = Net::Frame::Layer::IPv4->new(
src => $src_ip,
@ -26,7 +27,7 @@ my $report = Net::Frame::Layer::IGMP::v3Report->new(
type => NF_IGMP_REPORTv3TYPE_CHANGEEXCLUDE,
auxDataLen => 0,
numSources => 0,
multicastAddress => '239.255.42.44',
multicastAddress => $multicast_addr,
sourceAddress => [],
auxData => '',
);
@ -55,9 +56,13 @@ my $writer = Net::Write::Layer3->new(
protocol => NW_IPPROTO_RAW,
family => NW_AF_INET,
);
$writer->open();
while(1) {
print "Sending multicast join\n";
$writer->open();
$osimple->send($writer);
$writer->close();
sleep 60;
}
#print Dumper(unpack("H*", $osimple->pack));