MCPcopy Create free account
hub / github.com/DeNA/PacketProxy / addMessage

Method addMessage

src/main/java/core/org/xbill/DNS/Cache.java:592–723  ·  view source on GitHub ↗

Adds all data from a Message into the Cache. Each record is added with the appropriate credibility, and negative answers are cached as such. @param in The Message to be added @return A SetResponse that reflects what would be returned from a cache lookup, or null if nothing useful could be cached fr

(Message in)

Source from the content-addressed store, hash-verified

590 * @see Message
591 */
592public SetResponse
593addMessage(Message in) {
594 boolean isAuth = in.getHeader().getFlag(Flags.AA);
595 Record question = in.getQuestion();
596 Name qname;
597 Name curname;
598 int qtype;
599 int qclass;
600 int cred;
601 int rcode = in.getHeader().getRcode();
602 boolean completed = false;
603 RRset [] answers, auth, addl;
604 SetResponse response = null;
605 boolean verbose = Options.check("verbosecache");
606 HashSet additionalNames;
607
608 if ((rcode != Rcode.NOERROR && rcode != Rcode.NXDOMAIN) ||
609 question == null)
610 return null;
611
612 qname = question.getName();
613 qtype = question.getType();
614 qclass = question.getDClass();
615
616 curname = qname;
617
618 additionalNames = new HashSet();
619
620 answers = in.getSectionRRsets(Section.ANSWER);
621 for (int i = 0; i < answers.length; i++) {
622 if (answers[i].getDClass() != qclass)
623 continue;
624 int type = answers[i].getType();
625 Name name = answers[i].getName();
626 cred = getCred(Section.ANSWER, isAuth);
627 if ((type == qtype || qtype == Type.ANY) &&
628 name.equals(curname))
629 {
630 addRRset(answers[i], cred);
631 completed = true;
632 if (curname == qname) {
633 if (response == null)
634 response = new SetResponse(
635 SetResponse.SUCCESSFUL);
636 response.addRRset(answers[i]);
637 }
638 markAdditional(answers[i], additionalNames);
639 } else if (type == Type.CNAME && name.equals(curname)) {
640 CNAMERecord cname;
641 addRRset(answers[i], cred);
642 if (curname == qname)
643 response = new SetResponse(SetResponse.CNAME,
644 answers[i]);
645 cname = (CNAMERecord) answers[i].first();
646 curname = cname.getTarget();
647 } else if (type == Type.DNAME && curname.subdomain(name)) {
648 DNAMERecord dname;
649 addRRset(answers[i], cred);

Callers 1

lookupMethod · 0.80

Calls 15

checkMethod · 0.95
getNameMethod · 0.95
getTypeMethod · 0.95
getDClassMethod · 0.95
getCredMethod · 0.95
equalsMethod · 0.95
addRRsetMethod · 0.95
addRRsetMethod · 0.95
markAdditionalMethod · 0.95
firstMethod · 0.95
getTargetMethod · 0.95
subdomainMethod · 0.95

Tested by

no test coverage detected