ClientSubnetOption (dnsjava documentation)
Date: 2013-04-10

org.xbill.DNS

## Class ClientSubnetOption

- java.lang.Object
- - org.xbill.DNS.EDNSOption
  - - org.xbill.DNS.ClientSubnetOption

-     public class ClientSubnetOption
      extends EDNSOption

  The Client Subnet EDNS Option, defined in http://tools.ietf.org/html/draft-vandergaast-edns-client-subnet-00 ("Client subnet in DNS requests"). 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 2671 (EDNS0). An option code has not been assigned by IANA; the value 20730 (used here) is also used by several other implementations. 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)
  Author:
    Brian Wellington, Ming Zhou <mizhou@bnivideo.com>, Beaumaris Networks
  See Also:
    `OPTRecord`

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.xbill.DNS.EDNSOption

      `EDNSOption.Code`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClientSubnetOption(int sourceNetmask, InetAddress address)` Construct a Client Subnet option with scope netmask set to 0.
    `ClientSubnetOption(int sourceNetmask, int scopeNetmask, InetAddress address)` Construct a Client Subnet option.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `InetAddress` | `getAddress()` Returns the IP address of the client.
    `int` | `getFamily()` Returns the family of the network address.
    `int` | `getScopeNetmask()` Returns the scope netmask.
    `int` | `getSourceNetmask()` Returns the source netmask.

    - ### Methods inherited from class org.xbill.DNS.EDNSOption

      `equals, fromWire, getCode, hashCode, toString, toWire`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ClientSubnetOption

          public ClientSubnetOption(int sourceNetmask,
                            int scopeNetmask,
                            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. XXX something about Java's mapped addresses
      Parameters:
        `sourceNetmask` - The length of the netmask pertaining to the query. In replies, it mirrors the same value as in the requests.
        `scopeNetmask` - 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 sourceNetmask,
                            InetAddress address)

      Construct a Client Subnet option with scope netmask set to 0.
      Parameters:
        `sourceNetmask` - 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:
        `ClientSubnetOption`

  - ### Method Detail

    - #### getFamily

          public int getFamily()

      Returns the family of the network address. This will be either IPv4 (1) or IPv6 (2).

    - #### getSourceNetmask

          public int getSourceNetmask()

      Returns the source netmask.

    - #### getScopeNetmask

          public int getScopeNetmask()

      Returns the scope netmask.

    - #### getAddress

          public InetAddress getAddress()

      Returns the IP address of the client.