MCPcopy Create free account
hub / github.com/apache/trafficserver / init

Method init

src/iocore/dns/DNS.cc:417–461  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

415}
416
417void
418DNSEntry::init(DNSQueryData target, int qtype_arg, Continuation *acont, DNSProcessor::Options const &opt)
419{
420 qtype = qtype_arg;
421 host_res_style = opt.host_res_style;
422 if (is_addr_query(qtype)) {
423 // adjust things based on family preference.
424 if (HOST_RES_IPV4 == host_res_style || HOST_RES_IPV4_ONLY == host_res_style) {
425 qtype = T_A;
426 } else if (HOST_RES_IPV6 == host_res_style || HOST_RES_IPV6_ONLY == host_res_style) {
427 qtype = T_AAAA;
428 }
429 }
430 submit_time = ink_get_hrtime();
431 action = acont;
432 submit_thread = acont->mutex->thread_holding;
433
434 if (SplitDNSConfig::gsplit_dns_enabled) {
435 dnsH = opt.handler ? opt.handler : dnsProcessor.handler;
436 } else {
437 dnsH = dnsProcessor.handler;
438 }
439
440 dnsH->txn_lookup_timeout = opt.timeout;
441
442 mutex = dnsH->mutex;
443
444 if (is_addr_query(qtype) || qtype == T_SRV) {
445 auto name = target.name.substr(0, MAXDNAME); // be sure of safe copy into @a qname
446 memcpy(qname, name);
447 qname[name.size()] = '\0';
448 orig_qname_len = qname_len = name.size();
449 } else { // T_PTR
450 auto addr = target.addr;
451 if (addr->isIp6()) {
452 orig_qname_len = qname_len = make_ipv6_ptr(&addr->_addr._ip6, qname);
453 } else if (addr->isIp4()) {
454 orig_qname_len = qname_len = make_ipv4_ptr(addr->_addr._ip4, qname);
455 } else {
456 ink_assert(!"T_PTR query to DNS must be IP address.");
457 }
458 }
459
460 SET_HANDLER(&DNSEntry::mainEvent);
461}
462
463/**
464 Open UDP and/or TCP connections based on dns_conn_mode

Callers 1

getbyMethod · 0.45

Calls 9

is_addr_queryFunction · 0.85
ink_get_hrtimeFunction · 0.85
make_ipv6_ptrFunction · 0.85
make_ipv4_ptrFunction · 0.85
isIp6Method · 0.80
isIp4Method · 0.80
memcpyFunction · 0.50
substrMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected