We have done it in a simple enough way but fairly good in the interface.
1) in the directory /home/httpd/cgi-bin, we have added a macaddr.txt file with a content similar to this :
00:00:00:00:00:01 = <b>Visitors</b>
00:10:75:FF:DF:9D = MAXTOR
08:00:86:16:56:45 = QMS
192.168.1.56 = Foo
192.168.1.146 = <font color='red'>unknown</font>
Normal lines will be displayed in the list like this :
DF:9D =
MAXTORTCPIP addresses are supported and will be displayed like that :
56 =
FooYou can change the color by adding valid html code. The last line will be displayed like this :
146 =
unknownThe first line is intended to be used as a title. Addresses which start with 00:00:00:00: are considered titles. The value only will be displayed and not the end of the Mac address.
VisitorsThe changes are made in the file proxypolicy.cgi :
First we add a function which will build the table from the macaddr.txt file.
sub mac2host() {
open(FILEIN, "macaddr.txt") || return;
my $ligne = "";
my $key = "";
my $temp = "";
my $temp2 = "";
my $header = "";
my $value = "";
my @tab = ();
my %host2mac = ();
my %mac2host = ();
while($ligne = <FILEIN>)
{
chomp($ligne);
#print "ligne=$ligne\n";
# extraction and verification
@tab = split('=', $ligne, 2);
if(2 > scalar(@tab))
{
next;
}
$key = $tab[0];
# strip spaces; perl does not have a trim function :-(
$key =~ s/^\s+//;
$key =~ s/\s+$//;
# If this is a TCPIP address, keep the last digits
if ($key =~ /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/)
{
$temp = $key;
$temp =~ s/^[0-9]+\.[0-9]+\.[0-9]+\.//;
$header = $temp . " = <font color='green'>";
} else {
$temp = substr $key, 12;
$temp2 = substr $key, 0, 12;
# If MAC address starts with 00:00:00:00, this is a Title, don't add the header
$header = ($temp2 eq "00:00:00:00:") ? "" : $temp . " = <font color='blue'>";
}
$value = $tab[1];
$value =~ s/^\s+//;
$value =~ s/\s+$//;
# construction of the hashtable
$mac2host{$key} = $header . $value . "</font>";
}
return %mac2host;
}
%mac2host_table = mac2host();
Secondly we add some code in the middle of the file :
my $source = $splitted{'src'};
$source =~ s/\|/<br\/>/g;
$source =~ s/GREEN/<font color='$colourgreen'>GREEN<\/font>/g;
$source =~ s/ORANGE/<font color='$colourorange'>ORANGE<\/font>/g;
$source =~ s/BLUE/<font color='$colourblue'>BLUE<\/font>/g;
# Addition by Dysmas
my $idx;
foreach $idx (keys(%mac2host_table))
{
$source =~ s/$idx/$mac2host_table{$idx}/gi;
}
# End of Dysmas's addition
push(@cols, {V_CELL_CONTENT => $source eq "" ? "<b>" . _("ANY") . "</b>" : $source});
my $destination = $splitted{'dst'};
$destination =~ s/\|/<br\/>/g;
$destination =~ s/GREEN/<font color='$colourgreen'>GREEN<\/font>/g;
$destination =~ s/ORANGE/<font color='$colourorange'>ORANGE<\/font>/g;
$destination =~ s/BLUE/<font color='$colourblue'>BLUE<\/font>/g;
push(@cols, {V_CELL_CONTENT => $destination eq "" ? "<b>" . _("ANY") . "</b>" : $destination});
Now if you want to suppress the column auth (useless for us), just comment the two following lines :
#push(@cols, {V_CELL_CONTENT => $auth});
#{HEADING => _("Authgroup/-user")},
Hope it can be useful. We enjoy it.
Next step would be adding the ability to edit the macaddr.txt file in the gui.