Branch data Line data Source code
1 : : // Copyright (C) 2010 Internet Systems Consortium, Inc. ("ISC")
2 : : //
3 : : // Permission to use, copy, modify, and/or distribute this software for any
4 : : // purpose with or without fee is hereby granted, provided that the above
5 : : // copyright notice and this permission notice appear in all copies.
6 : : //
7 : : // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
8 : : // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
9 : : // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
10 : : // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
11 : : // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
12 : : // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
13 : : // PERFORMANCE OF THIS SOFTWARE.
14 : :
15 : : #include <dns/rrset.h>
16 : : #include "local_zone_data.h"
17 : : #include "cache_entry_key.h"
18 : : #include "rrset_copy.h"
19 : : #include "logger.h"
20 : :
21 : : using namespace std;
22 : : using namespace isc::dns;
23 : :
24 : : namespace isc {
25 : : namespace cache {
26 : :
27 : : typedef pair<std::string, RRsetPtr> RRsetMapPair;
28 : : typedef map<std::string, RRsetPtr>::iterator RRsetMapIterator;
29 : :
30 : : isc::dns::RRsetPtr
31 : 73 : LocalZoneData::lookup(const isc::dns::Name& name,
32 : : const isc::dns::RRType& type)
33 : : {
34 : 146 : string key = genCacheEntryName(name, type);
35 : 146 : RRsetMapIterator iter = rrsets_map_.find(key);
36 [ + + ]: 73 : if (iter == rrsets_map_.end()) {
37 [ + - ][ + - ]: 60 : LOG_DEBUG(logger, DBG_TRACE_DATA, CACHE_LOCALZONE_UNKNOWN).arg(key);
[ + - ][ + - ]
[ + - ]
38 : : return (RRsetPtr());
39 : : } else {
40 [ + - ][ + - ]: 13 : LOG_DEBUG(logger, DBG_TRACE_DATA, CACHE_LOCALZONE_FOUND).arg(key);
[ + - ][ + - ]
[ + - ]
41 : 13 : return (iter->second);
42 : : }
43 : : }
44 : :
45 : : void
46 : 6 : LocalZoneData::update(const isc::dns::AbstractRRset& rrset) {
47 : : //TODO Do we really need to recreate the rrset again?
48 : 12 : string key = genCacheEntryName(rrset.getName(), rrset.getType());
49 [ + - ][ + - ]: 6 : LOG_DEBUG(logger, DBG_TRACE_DATA, CACHE_LOCALZONE_UPDATE).arg(key);
[ + - ][ + - ]
[ + - ]
50 : 12 : RRset* rrset_copy = new RRset(rrset.getName(), rrset.getClass(),
51 [ + - ][ + - ]: 6 : rrset.getType(), rrset.getTTL());
[ + - ][ + - ]
[ + - ][ + - ]
52 : :
53 [ + - ]: 6 : rrsetCopy(rrset, *rrset_copy);
54 [ + - ]: 6 : RRsetPtr rrset_ptr(rrset_copy);
55 [ + - ][ + - ]: 6 : rrsets_map_[key] = rrset_ptr;
56 : 6 : }
57 : :
58 : : } // namespace cache
59 : 3 : } // namespace isc
60 : :
|