APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.jndi.dns

public Class DnsClient

Additional top-level classes in compilation unit: Tcp, Packet.

extends Object
Class Inheritance
Imports
java.io.IOException, .UncheckedIOException, java.lang.ref.Cleaner, java.net.InetAddress, .InetSocketAddress, .PortUnreachableException, .Socket, .SocketTimeoutException, java.nio.ByteBuffer, java.nio.channels.ClosedSelectorException, .DatagramChannel, .SelectionKey, .Selector, java.security.SecureRandom, javax.naming.CommunicationException, .ConfigurationException, .NameNotFoundException, .NamingException, .OperationNotSupportedException, .ServiceUnavailableException, java.time.Duration, java.util.Arrays, .Collections, .Map, .HashMap, java.util.concurrent.TimeUnit, java.util.concurrent.atomic.AtomicLong, java.util.concurrent.locks.ReentrantLock, java.util.stream.IntStream, jdk.internal.ref.CleanerFactory, sun.security.jca.JCAUtil

The DnsClient class performs DNS client operations in support of DnsContext.

Field Summary

Modifier and TypeField and Description
private static final boolean
private static final int
private static final int
private static final DNSDatagramChannelFactory
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private static final int
private Object
private static final SecureRandom
private static final String[]
private static final int
private Map<Integer, ResourceRecord>
private Map<Integer, byte[]>
private int
private final Cleaner.Cleanable
private static final int
private int[]
private InetAddress[]
private int
private static final int
private final ReentrantLock
private final Selector

Constructor Summary

AccessConstructor and Description
public
DnsClient(String[] servers, int timeout, int retries)

Method Summary

Modifier and TypeMethod and Description
pack-priv boolean
blockingReceive(DatagramChannel dc, InetSocketAddress target, ByteBuffer buffer, long timeout)

private void
public void
private byte[]
private byte[]
doTcpQuery(Tcp tcp, Packet pkt)

private byte[]
doUdpQuery(Packet pkt, InetAddress server, int port, int retry, int xid, AtomicLong unfulfilledTimeout, boolean unfulfilledOnly)

Tries to retrieve a UDP packet matching the given xid received within the timeout.

private static void
dprint(String mess)

pack-priv DatagramChannel
private boolean
isMatchResponse(byte[] pkt, int xid)

private byte[]
private void
makeQueryName(DnsName fqdn, Packet pkt, int off)

private Packet
makeQueryPacket(DnsName fqdn, int xid, int qclass, int qtype, boolean recursion)

pack-priv ResourceRecords
query(DnsName fqdn, int qclass, int qtype, boolean recursion, boolean auth)

pack-priv ResourceRecords
queryZone(DnsName zone, int qclass, boolean recursion)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

debugback to summary
private static final boolean debug
DEFAULT_PORTback to summary
private static final int DEFAULT_PORT
DNS_HDR_SIZEback to summary
private static final int DNS_HDR_SIZE
factoryback to summary
private static final DNSDatagramChannelFactory factory
FLAGS_OFFSETback to summary
private static final int FLAGS_OFFSET
FORMAT_ERRORback to summary
private static final int FORMAT_ERROR
IDENT_OFFSETback to summary
private static final int IDENT_OFFSET
MIN_TIMEOUTback to summary
private static final int MIN_TIMEOUT
NAME_ERRORback to summary
private static final int NAME_ERROR
NO_ERRORback to summary
private static final int NO_ERROR
NOT_IMPLback to summary
private static final int NOT_IMPL
NUMADD_OFFSETback to summary
private static final int NUMADD_OFFSET
NUMANS_OFFSETback to summary
private static final int NUMANS_OFFSET
NUMAUTH_OFFSETback to summary
private static final int NUMAUTH_OFFSET
NUMQ_OFFSETback to summary
private static final int NUMQ_OFFSET
queuesLockback to summary
private Object queuesLock
randomback to summary
private static final SecureRandom random
rcodeDescriptionback to summary
private static final String[] rcodeDescription
REFUSEDback to summary
private static final int REFUSED
reqsback to summary
private Map<Integer, ResourceRecord> reqs
respsback to summary
private Map<Integer, byte[]> resps
retriesback to summary
private int retries
selectorCleanupback to summary
private final Cleaner.Cleanable selectorCleanup
SERVER_FAILUREback to summary
private static final int SERVER_FAILURE
serverPortsback to summary
private int[] serverPorts
serversback to summary
private InetAddress[] servers
timeoutback to summary
private int timeout
TRANSACTION_ID_BOUNDback to summary
private static final int TRANSACTION_ID_BOUND
udpChannelLockback to summary
private final ReentrantLock udpChannelLock
udpChannelSelectorback to summary
private final Selector udpChannelSelector

Constructor Detail

DnsClientback to summary
public DnsClient(String[] servers, int timeout, int retries) throws NamingException

Method Detail

blockingReceiveback to summary
pack-priv boolean blockingReceive(DatagramChannel dc, InetSocketAddress target, ByteBuffer buffer, long timeout) throws IOException
checkResponseCodeback to summary
private void checkResponseCode(Header hdr) throws NamingException
closeback to summary
public void close()
continueTcpQueryback to summary
private byte[] continueTcpQuery(Tcp tcp) throws IOException
doTcpQueryback to summary
private byte[] doTcpQuery(Tcp tcp, Packet pkt) throws IOException
doUdpQueryback to summary
private byte[] doUdpQuery(Packet pkt, InetAddress server, int port, int retry, int xid, AtomicLong unfulfilledTimeout, boolean unfulfilledOnly) throws IOException, NamingException

Tries to retrieve a UDP packet matching the given xid received within the timeout. If a packet with different xid is received, the received packet is enqueued with the corresponding xid in 'resps'.

dprintback to summary
private static void dprint(String mess)
getDatagramChannelback to summary
pack-priv DatagramChannel getDatagramChannel() throws NamingException
isMatchResponseback to summary
private boolean isMatchResponse(byte[] pkt, int xid) throws NamingException
lookupResponseback to summary
private byte[] lookupResponse(Integer xid) throws NamingException
makeQueryNameback to summary
private void makeQueryName(DnsName fqdn, Packet pkt, int off)
makeQueryPacketback to summary
private Packet makeQueryPacket(DnsName fqdn, int xid, int qclass, int qtype, boolean recursion)
queryback to summary
pack-priv ResourceRecords query(DnsName fqdn, int qclass, int qtype, boolean recursion, boolean auth) throws NamingException
queryZoneback to summary
pack-priv ResourceRecords queryZone(DnsName zone, int qclass, boolean recursion) throws NamingException