{
# TAG: remoteip
#
#	Specifies the local and remote IP address ranges.
#
#	You can specify single IP addresses seperated by commas or you can
#	specify ranges, or both. For example:
#
#		192.168.0.234,192.168.0.245-249,192.168.0.254
#
#	IMPORTANT RESTRICTIONS:
#
#	1. No spaces are permitted between commas or within addresses.
#
#	2. If you give more IP addresses than MAX_CONNECTIONS, it will
#	   start at the beginning of the list and go until it gets 
#	   MAX_CONNECTIONS IPs. Others will be ignored.
#
#	3. No shortcuts in ranges! ie. 234-8 does not mean 234 to 238,
#	   you must type 234-238 if you mean this.
#
#	4. If you give a single localIP, that's ok - all local IPs will
#	   be set to the given one. You MUST still give at least one remote
#	   IP for each simultaneous client.
#
    return "# pptpd disabled - no remoteip"
	unless ($pptpd{status} eq 'enabled');

    # PPTPD can't do ranges in the form 192.168.42.200-192.168.42.210
    # (Grrrr!!!) so we need to use the 192.168.42.200-210 format

    my $netmaskBits = esmith::util::IPquadToAddr ($LocalNetmask);

    my $sessions = $pptpd{sessions} || 0;

    # Calculate pptpd start and end addresses
    my $endIP = $dhcpd{end};
    my $end_addr =  esmith::util::IPquadToAddr($endIP);
    my $start_addr = $end_addr - $sessions + 1;
    my $startIP = esmith::util::IPaddrToQuad($start_addr);
    my @start = split(/\./, $startIP);
    my @end = split(/\./, $endIP);

    $OUT .= "remoteip ";

    my $start = shift @start;
    my $end  = shift @end ;
    $OUT .= ($start eq $end) ? "$start." : "$start-$end.";

    $start = shift @start;
    $end  = shift @end ;
    $OUT .= ($start eq $end) ? "$start." : "$start-$end.";

    $start = shift @start;
    $end  = shift @end ;
    $OUT .= ($start eq $end) ? "$start." : "$start-$end.";

    $start = shift @start;
    $end  = shift @end ;
    $OUT .= ($start eq $end) ? "$start" : "$start-$end";
}
