{

use esmith::HostsDB;
$hosts = esmith::HostsDB->open_ro;

use esmith::DomainsDB;
my $ddb = esmith::DomainsDB->open_ro;

use esmith::util;

#--------------------------------------------------------
# Returns a hash of hostnames with IP addresses as values
#--------------------------------------------------------

sub get_generic_hostentries 
    {
        #--------------------------------------------------
        # Compute local IP address, netmask and network values.
        #--------------------------------------------------

        my $ipaddrBits  = esmith::util::IPquadToAddr ($LocalIP);
        my $netmaskBits = esmith::util::IPquadToAddr ($LocalNetmask);
        my $networkBits = $ipaddrBits & $netmaskBits;

        #--------------------------------------------------
        # Compute our hostid, and the highest hostid, limiting range
        # to a class B at most (so we don't get a huge output file).
        #--------------------------------------------------

        my $myHostid = (~ $netmaskBits) & $ipaddrBits;

        my $maxHostid = ((~ $netmaskBits) & 0xffffff) - 1;
        $maxHostid = ($maxHostid <= 65534) ? $maxHostid : 65534;

        my %name2ip;
        #--------------------------------------------------
        # Generate A records for the entire local network
        # We can then override particular entries if we need to
        # However, multiple A records are not an issue
        # as long as there is a PTR record pointing to the correct
        # hostname
        #--------------------------------------------------

        for ($i = 1; $i <= $maxHostid; $i++)
        {
            my $ip = esmith::util::IPaddrToQuad ($networkBits | $i);
            my $hostname = sprintf ("pc-%.5d", $i);

            $name2ip{$hostname} = $ip;
        }

        return %name2ip;
    }

#--------------------------------------------------------
# Calculates an array of domains that require DNS
#--------------------------------------------------------
@domains = map { $_->key } $ddb->get_all_by_prop('type' => 'domain');

#--------------------------------------------------------
# Returns an array of domains that require DNS
#--------------------------------------------------------
sub get_domains { return @domains; }

sub get_local_domainname { return $DomainName; }

$OUT = '';
}
