Package org.xbill.DNS

Class ClientSubnetOption

java.lang.Object
org.xbill.DNS.EDNSOption
org.xbill.DNS.ClientSubnetOption
All Implemented Interfaces:
Serializable

public class ClientSubnetOption extends EDNSOption
The Client Subnet EDNS Option.

The option is used to convey information about the IP address of the originating client, so that an authoritative server can make decisions based on this address, rather than the address of the intermediate caching name server.

The option is transmitted as part of an OPTRecord in the additional section of a DNS message, as defined by RFC 6891 (EDNS0).

The wire format of the option contains a 2-byte length field (1 for IPv4, 2 for IPv6), a 1-byte source netmask, a 1-byte scope netmask, and an address truncated to the source netmask length (where the final octet is padded with bits set to 0)

See Also:
  • Field Details

    • family

      private int family
    • sourcePrefixLength

      private int sourcePrefixLength
    • scopePrefixLength

      private int scopePrefixLength
    • address

      private InetAddress address
  • Constructor Details

    • ClientSubnetOption

      ClientSubnetOption()
    • ClientSubnetOption

      public ClientSubnetOption(int sourcePrefixLength, int scopePrefixLength, InetAddress address)
      Construct a Client Subnet option. Note that the number of significant bits in the address must not be greater than the supplied source netmask. There may also be issues related to Java's handling of mapped addresses
      Parameters:
      sourcePrefixLength - The length of the netmask pertaining to the query. In replies, it mirrors the same value as in the requests.
      scopePrefixLength - The length of the netmask pertaining to the reply. In requests, it MUST be set to 0. In responses, this may or may not match the source netmask.
      address - The address of the client.
    • ClientSubnetOption

      public ClientSubnetOption(int sourcePrefixLength, InetAddress address)
      Construct a Client Subnet option with scope netmask set to 0.
      Parameters:
      sourcePrefixLength - The length of the netmask pertaining to the query. In replies, it mirrors the same value as in the requests.
      address - The address of the client.
      See Also:
  • Method Details

    • checkMaskLength

      private static int checkMaskLength(String field, int family, int val)
    • getFamily

      public int getFamily()
      Returns the family of the network address. This will be either IPv4 (1) or IPv6 (2).
    • getSourcePrefixLength

      public int getSourcePrefixLength()
      Returns the source netmask.
    • getScopePrefixLength

      public int getScopePrefixLength()
      Returns the scope netmask.
    • getAddress

      public InetAddress getAddress()
      Returns the IP address of the client.
    • optionFromWire

      void optionFromWire(DNSInput in) throws WireParseException
      Description copied from class: EDNSOption
      Converts the wire format of an EDNS Option (the option data only) into the type-specific format.
      Specified by:
      optionFromWire in class EDNSOption
      Parameters:
      in - The input Stream.
      Throws:
      WireParseException
    • optionToWire

      void optionToWire(DNSOutput out)
      Description copied from class: EDNSOption
      Converts an EDNS Option (the type-specific option data only) into wire format.
      Specified by:
      optionToWire in class EDNSOption
      Parameters:
      out - The output stream.
    • optionToString

      String optionToString()
      Specified by:
      optionToString in class EDNSOption