Lines Matching refs:ce
158 const CacheEntry& ce, uint32_t flags = 0) { in cacheLookup() argument
161 const auto cacheStatus = resolv_cache_lookup(netId, ce.query.data(), ce.query.size(), in cacheLookup()
171 if (answer != ce.answer) { in cacheLookup()
187 int cacheAdd(uint32_t netId, const CacheEntry& ce) { in cacheAdd() argument
188 return resolv_cache_add(netId, ce.query.data(), ce.query.size(), ce.answer.data(), in cacheAdd()
189 ce.answer.size()); in cacheAdd()
200 void cacheQueryFailed(uint32_t netId, const CacheEntry& ce, uint32_t flags) { in cacheQueryFailed() argument
201 _resolv_cache_query_failed(netId, ce.query.data(), ce.query.size(), flags); in cacheQueryFailed()
258 CacheEntry ce; in makeCacheEntry() local
259 ce.query = makeQuery(op, qname, qclass, qtype); in makeCacheEntry()
260 ce.answer = makeAnswer(ce.query, rdata, static_cast<unsigned>(ttl.count())); in makeCacheEntry()
261 return ce; in makeCacheEntry()
291 CacheEntry ce = makeCacheEntry(QUERY, "valid.cache", ns_c_in, ns_t_a, "1.2.3.4"); in TEST_F() local
293 EXPECT_EQ(-EINVAL, cacheAdd(TEST_NETID, queryEmpty, ce.answer)); in TEST_F()
294 EXPECT_EQ(-EINVAL, cacheAdd(TEST_NETID, queryTooSmall, ce.answer)); in TEST_F()
297 EXPECT_EQ(-ENONET, cacheAdd(TEST_NETID_2, ce)); in TEST_F()
302 CacheEntry ce = makeCacheEntry(QUERY, "existent.in.cache", ns_c_in, ns_t_a, "1.2.3.4"); in TEST_F() local
306 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_NOTFOUND, TEST_NETID, ce)); in TEST_F()
307 EXPECT_EQ(0, cacheAdd(TEST_NETID, ce)); in TEST_F()
308 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_FOUND, TEST_NETID, ce)); in TEST_F()
312 EXPECT_EQ(0, cacheGetExpiration(TEST_NETID, ce.query, &expiration1)); in TEST_F()
316 EXPECT_EQ(-EEXIST, cacheAdd(TEST_NETID, ce)); in TEST_F()
317 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_FOUND, TEST_NETID, ce)); in TEST_F()
319 EXPECT_EQ(0, cacheGetExpiration(TEST_NETID, ce.query, &expiration2)); in TEST_F()
326 CacheEntry ce = makeCacheEntry(QUERY, "existent.in.cache", ns_c_in, ns_t_a, "1.2.3.4"); in TEST_F() local
329 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_NOTFOUND, TEST_NETID, ce)); in TEST_F()
330 EXPECT_EQ(0, cacheAdd(TEST_NETID, ce)); in TEST_F()
331 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_FOUND, TEST_NETID, ce)); in TEST_F()
334 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_NOTFOUND, TEST_NETID_2, ce)); in TEST_F()
336 ce = makeCacheEntry(QUERY, "existent.in.cache", ns_c_in, ns_t_aaaa, "2001:db8::1.2.3.4"); in TEST_F()
339 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_NOTFOUND, TEST_NETID, ce)); in TEST_F()
340 EXPECT_EQ(0, cacheAdd(TEST_NETID, ce)); in TEST_F()
341 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_FOUND, TEST_NETID, ce)); in TEST_F()
347 CacheEntry ce = makeCacheEntry(QUERY, "existent.in.cache", ns_c_in, ns_t_a, "1.2.3.4"); in TEST_F() local
350 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_NOTFOUND, TEST_NETID, ce, ANDROID_RESOLV_NO_CACHE_LOOKUP)); in TEST_F()
353 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_SKIP, TEST_NETID, ce, ANDROID_RESOLV_NO_CACHE_STORE)); in TEST_F()
356 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_SKIP, TEST_NETID, ce, in TEST_F()
360 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_NOTFOUND, TEST_NETID, ce)); in TEST_F()
361 EXPECT_EQ(0, cacheAdd(TEST_NETID, ce)); in TEST_F()
362 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_FOUND, TEST_NETID, ce)); in TEST_F()
364 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_NOTFOUND, TEST_NETID, ce, ANDROID_RESOLV_NO_CACHE_LOOKUP)); in TEST_F()
367 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_SKIP, TEST_NETID, ce, ANDROID_RESOLV_NO_CACHE_STORE)); in TEST_F()
370 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_SKIP, TEST_NETID, ce, in TEST_F()
390 CacheEntry ce = makeCacheEntry(QUERY, name.data(), ns_c_in, t.type, t.rdata.data()); in TEST_F() local
391 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_NOTFOUND, TEST_NETID, ce)); in TEST_F()
392 EXPECT_EQ(0, cacheAdd(TEST_NETID, ce)); in TEST_F()
393 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_FOUND, TEST_NETID, ce)); in TEST_F()
403 const CacheEntry ce = makeCacheEntry(QUERY, "valid.cache", ns_c_in, ns_t_a, "1.2.3.4"); in TEST_F() local
411 EXPECT_EQ(0, cacheAdd(TEST_NETID, ce)); in TEST_F()
413 EXPECT_EQ(RESOLV_CACHE_UNSUPPORTED, cacheLookupFn(queryEmpty, ce.answer)); in TEST_F()
414 EXPECT_EQ(RESOLV_CACHE_UNSUPPORTED, cacheLookupFn(queryTooSmall, ce.answer)); in TEST_F()
415 EXPECT_EQ(RESOLV_CACHE_UNSUPPORTED, cacheLookupFn(ce.query, answerTooSmall)); in TEST_F()
418 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_FOUND, TEST_NETID, ce)); in TEST_F()
421 EXPECT_EQ(-ENONET, cacheAdd(TEST_NETID_2, ce)); in TEST_F()
422 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_UNSUPPORTED, TEST_NETID_2, ce)); in TEST_F()
429 CacheEntry ce = makeCacheEntry(QUERY, "expired.in.0s", ns_c_in, ns_t_a, "1.2.3.4", 0s); in TEST_F() local
430 EXPECT_EQ(0, cacheAdd(TEST_NETID, ce)); in TEST_F()
431 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_NOTFOUND, TEST_NETID, ce)); in TEST_F()
434 ce = makeCacheEntry(QUERY, "expired.in.1s", ns_c_in, ns_t_a, "1.2.3.4", 1s); in TEST_F()
435 EXPECT_EQ(0, cacheAdd(TEST_NETID, ce)); in TEST_F()
438 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_FOUND, TEST_NETID, ce)); in TEST_F()
440 EXPECT_EQ(0, cacheGetExpiration(TEST_NETID, ce.query, &expiration)); in TEST_F()
445 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_NOTFOUND, TEST_NETID, ce)); in TEST_F()
452 CacheEntry ce = makeCacheEntry(QUERY, "query.deferred", ns_c_in, ns_t_a, "1.2.3.4"); in TEST_F() local
457 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_NOTFOUND, TEST_NETID, ce)); in TEST_F()
462 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_FOUND, TEST_NETID, ce)); in TEST_F()
475 EXPECT_EQ(0, cacheAdd(TEST_NETID_2, ce)); in TEST_F()
476 cacheQueryFailed(TEST_NETID, ce, ANDROID_RESOLV_NO_CACHE_STORE); in TEST_F()
477 cacheQueryFailed(TEST_NETID, ce, ANDROID_RESOLV_NO_CACHE_LOOKUP); in TEST_F()
478 cacheQueryFailed(TEST_NETID_2, ce, ANDROID_RESOLV_NO_CACHE_STORE); in TEST_F()
479 cacheQueryFailed(TEST_NETID_2, ce, ANDROID_RESOLV_NO_CACHE_LOOKUP); in TEST_F()
487 EXPECT_EQ(0, cacheAdd(TEST_NETID, ce)); in TEST_F()
497 CacheEntry ce = makeCacheEntry(QUERY, "query.failed", ns_c_in, ns_t_a, "1.2.3.4"); in TEST_F() local
500 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_NOTFOUND, TEST_NETID, ce)); in TEST_F()
505 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_NOTFOUND, TEST_NETID, ce)); in TEST_F()
517 cacheQueryFailed(TEST_NETID, ce, 0); in TEST_F()
528 CacheEntry ce = makeCacheEntry(QUERY, "query.failed", ns_c_in, ns_t_a, "1.2.3.4"); in TEST_F() local
531 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_NOTFOUND, TEST_NETID, ce)); in TEST_F()
536 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_NOTFOUND, TEST_NETID, ce)); in TEST_F()
568 CacheEntry ce = makeCacheEntry(QUERY, qname.data(), ns_c_in, ns_t_a, "1.2.3.4"); in TEST_F() local
569 EXPECT_EQ(0, cacheAdd(TEST_NETID, ce)); in TEST_F()
570 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_FOUND, TEST_NETID, ce)); in TEST_F()
571 ces.emplace_back(ce); in TEST_F()
602 CacheEntry ce = makeCacheEntry(QUERY, qname.data(), ns_c_in, ns_t_a, "1.2.3.4", 50s); in TEST_F() local
603 EXPECT_EQ(0, cacheAdd(TEST_NETID, ce)); in TEST_F()
604 EXPECT_TRUE(cacheLookup(RESOLV_CACHE_FOUND, TEST_NETID, ce)); in TEST_F()
812 CacheEntry ce = makeCacheEntry(QUERY, "any.data", ns_c_in, ns_t_a, "1.2.3.4"); in TEST_F() local
813 EXPECT_EQ(0, cacheAdd(TEST_NETID, ce)); in TEST_F()
819 ce = makeCacheEntry(QUERY, answer, ns_c_in, ns_t_a, query_v4); in TEST_F()
820 EXPECT_EQ(0, cacheAdd(TEST_NETID, ce)); in TEST_F()
832 ce = makeCacheEntry(QUERY, answer, ns_c_in, ns_t_aaaa, query_v6); in TEST_F()
833 EXPECT_EQ(0, cacheAdd(TEST_NETID, ce)); in TEST_F()