rec = new DNSRecord.Address(domain, type, clazz, ttl, readBytes(off, len)); break; case DNSConstants.TYPE_CNAME:
if (rec.name.equals(server)) addr = ((DNSRecord.Address) rec).getAddress();
/** * Does the necessary actions, when this as a query. */ boolean handleQuery(JmDNS dns, long expirationTime) { DNSRecord.Address dnsAddress = dns.getLocalHost().getDNSAddressRecord(this); if (dnsAddress != null) { if (dnsAddress.sameType(this) && dnsAddress.sameName(this) && (!dnsAddress.sameValue(this))) { logger.finer("handleQuery() Conflicting probe detected. dns state " + dns.getState() + " lex compare " + lexCompare(dnsAddress)); // Tie-breaker test if (dns.getState().isProbing() && lexCompare(dnsAddress) >= 0) { // We lost the tie-break. We have to choose a different name. dns.getLocalHost().incrementHostName(); dns.getCache().clear(); for (Iterator i = dns.services.values().iterator(); i.hasNext();) { ServiceInfo info = (ServiceInfo) i.next(); info.revertState(); } } dns.revertState(); return true; } } return false; }
/** * Does a lexicographic comparison of the byte array representation * of this record and that record. * This is needed for tie-break tests according to * draft-cheshire-dnsext-multicastdns-04.txt chapter 9.2. */ private int lexCompare(DNSRecord.Address that) { byte[] thisBytes = this.toByteArray(); byte[] thatBytes = that.toByteArray(); for (int i = 0, n = Math.min(thisBytes.length, thatBytes.length); i < n; i++) { if (thisBytes[i] > thatBytes[i]) { return 1; } else { if (thisBytes[i] < thatBytes[i]) { return -1; } } } return thisBytes.length - thatBytes.length; }
/** * Does the necessary actions, when this as a response. */ boolean handleResponse(JmDNS dns) { DNSRecord.Address dnsAddress = dns.getLocalHost().getDNSAddressRecord(this); if (dnsAddress != null) { if (dnsAddress.sameType(this) && dnsAddress.sameName(this) && (!dnsAddress.sameValue(this))) { logger.finer("handleResponse() Denial detected"); if (dns.getState().isProbing()) { dns.getLocalHost().incrementHostName(); dns.getCache().clear(); for (Iterator i = dns.services.values().iterator(); i.hasNext();) { ServiceInfo info = (ServiceInfo) i.next(); info.revertState(); } } dns.revertState(); return true; } } return false; }
boolean sameValue(DNSRecord other) { return addr.equals(((Address) other).getAddress()); }
DNSRecord.Address getDNS6AddressRecord() { if ((getAddress() != null) && (getAddress() instanceof Inet6Address)) { return new DNSRecord.Address(getName(), DNSConstants.TYPE_AAAA, DNSConstants.CLASS_IN, DNSConstants.DNS_TTL, getAddress()); } return null; }
DNSRecord.Address getDNS4AddressRecord() { if ((getAddress() != null) && ((getAddress() instanceof Inet4Address) || ((getAddress() instanceof Inet6Address) && (((Inet6Address) getAddress()).isIPv4CompatibleAddress())))) { return new DNSRecord.Address(getName(), DNSConstants.TYPE_A, DNSConstants.CLASS_IN, DNSConstants.DNS_TTL, getAddress()); } return null; }