* to a *LIST* of *PREFIXES*. Not the other way round.
*
* You can store IPv4 and IPv6 addresses to same tree, separate payload storage is kept per AFI.
+ * Network prefixes (Netmasks) are always recorded in normalized fashion, meaning that only
+ * the network bits are set. This is what is returned in the insert() and lookup() return
+ * values.
*
* Use swap if you need to move the tree to another NetmaskTree instance, it is WAY faster
* than using copy ctor or assignment operator, since it moves the nodes and tree root to
parent(nullptr), node(new node_type()), assigned(false), d_bits(0) {
}
explicit TreeNode(const key_type& key) noexcept :
- parent(nullptr), node(new node_type({key, value_type()})),
+ parent(nullptr), node(new node_type({key.getNormalized(), value_type()})),
assigned(false), d_bits(key.getAddressBits()) {
}
node->assigned = true;
}
- // assign key
- value->first = key;
return *value;
}
{
d_cachecachevalid = false;
// cerr<<"Replacing "<<qname<<" for "<< (ednsmask ? ednsmask->toString() : "everyone") << endl;
+ if (ednsmask) {
+ ednsmask = ednsmask->getNormalized();
+ }
auto key = boost::make_tuple(qname, qt.getCode(), ednsmask ? *ednsmask : Netmask());
bool isNew = false;
cache_t::iterator stored = d_cache.find(key);
struct CacheEntry
{
CacheEntry(const boost::tuple<DNSName, uint16_t, Netmask>& key, bool auth):
- d_qname(key.get<0>()), d_netmask(key.get<2>()), d_state(Indeterminate), d_ttd(0), d_qtype(key.get<1>()), d_auth(auth)
+ d_qname(key.get<0>()), d_netmask(key.get<2>().getNormalized()), d_state(Indeterminate), d_ttd(0), d_qtype(key.get<1>()), d_auth(auth)
{
}