#include #include #include #include #include "dhcpd.h" #include /* hubert@id-pro.de: some classes to controle if an ip is controlled by dhcp */ PUBLIC UWE_RANGE::UWE_RANGE (const SSTRING& _lo, const SSTRING& _hi) { lo.setfrom(_lo.get()); hi.setfrom(_hi.get()); } /* check if a ip is inside a range */ PUBLIC bool UWE_RANGE::inrange (IP_ADDR* ipa) { return lo.cmp(ipa) < 0 && hi.cmp(ipa) > 0; } PUBLIC UWE_RANGES::UWE_RANGES(DHCP& dh){ DHCP_SUBNETS& subnets = dh.subnets; for (int nsub = 0; nsub < subnets.getnb(); nsub++){ DHCP_RANGES& ranges = subnets.getitem(nsub)->ranges; for (int nrng = 0; nrng < ranges.getnb(); nrng++) add (new UWE_RANGE (ranges.getitem(nrng)->alloc_start, ranges.getitem(nrng)->alloc_stop)); } } PUBLIC UWE_RANGE* UWE_RANGES::getitem(int no) { return (UWE_RANGE*) ARRAY::getitem(no); } /* check if a list of IPs is inside of the ranges of the dhcp server. Return true if all IPs are in range. */ PUBLIC bool UWE_RANGES::inrange ( IP_ADDRS& ips) { for (int nip = 0; nip < ips.getnb(); nip++){ bool found = false; for (int nrng = 0; nrng < getnb(); nrng++){ if (getitem(nrng)->inrange(ips.getitem(nip)) != 0){ found = true; break; } } if (!found) return false; } return true; }