jhthorsen/net-isc-dhcpd

shared-network name not correctly parsed

sixela opened this issue · 0 comments

Hi,

I'm currently trying to parse a dhcpd.conf file I've been given. In that file, shared-network sections are named after the adress of the subnet defined within, ending with blocks like:

shared-network prefix-192.0.2.0 {
    subnet 192.0.2.0 netmask 255.255.255.0 { ... }
}

shared-network prefix-192.0.3.0 {
    subnet 192.0.3.0 netmask 255.255.255.0 { ... }
}

Then if I try to parse my file I end up with all my shared-networks named "prefix-192" only, which is annoying.

#!/usr/bin/env perl
use Net::ISC::DHCPd::Config;

my $file        = shift;
my $config      = Net::ISC::DHCPd::Config->new(
                                file => $file,
                        );

$config->parse;
for my $s ($config->sharednetworks) {
        print $s->name . "\n" ;

Outputs:

prefix-192
prefix-192

I'm no perl expert so, you'll probably know better than me how to handle such case ? Given that I can't modify the .conf file.

Thanks in advance

Using:

  • Perl 5.23.7
  • Net::ISC::DHCPd 0.1708