open PATCHLIST, "/root/nms/switches.txt"
	or die "switches.txt: $!";
my %vlans = ();

while (<PATCHLIST>) {
	if (/87\.76\.(\d+)\.(\d+) 26 e(\d+)-(\d+)/) {
		my $vlannum = $3.$4;
		my $helper = "87.76.$1." . ($2+1);
		my $name = "e$3-$4";
		my $z = sprintf "f%03u", $vlannum;
		$z =~ /(.)(.)(.)(.)/; $vlans{$helper} = [ $vlannum, $name, "$4.$3.$2.$1" ];
	}
}

while (<>) {
	/DHCPOFFER on 87.76.\d+.\d+ to 00:(.)(.):(.)(.):(.)(.):(.)(.):(.)(.) \((.*?)\) via (\d+\.\d+\.\d+\.\d+)/ or next;
	my $v = $vlans{$12};
	open NSUPDATE, "| nsupdate -y DHCP_UPDATER:F388UOhaIIKHRH9TDE5PTA==";
	print NSUPDATE <<"EOF";
server 127.0.0.1
update delete $11.v6.$v->[1].tg07.gathering.org. AAAA
update add $11.v6.$v->[1].tg07.gathering.org. 3600 AAAA 2001:16d8:ffff:f$v->[0]:02$1$2:$3$4ff:fe$5$6:$7$8$9$10
send
update delete $10.$9.$8.$7.$6.$5.e.f.f.f.$4.$3.$2.$1.2.0.$v->[2].f.f.f.f.8.d.6.1.1.0.0.2.ip6.arpa. PTR
update add $10.$9.$8.$7.$6.$5.e.f.f.f.$4.$3.$2.$1.2.0.$v->[2].f.f.f.f.8.d.6.1.1.0.0.2.ip6.arpa. 3600 PTR $11.v6.$v->[1].tg07.gathering.org.
send
EOF
	close NSUPDATE;
}

