public class ClientSubnetOption extends EDNSOption
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)
EDNSOption.Code
Modifier and Type | Field and Description |
---|---|
private java.net.InetAddress |
address |
private int |
family |
private int |
scopePrefixLength |
private int |
sourcePrefixLength |
Constructor and Description |
---|
ClientSubnetOption() |
ClientSubnetOption(int sourcePrefixLength,
java.net.InetAddress address)
Construct a Client Subnet option with scope netmask set to 0.
|
ClientSubnetOption(int sourcePrefixLength,
int scopePrefixLength,
java.net.InetAddress address)
Construct a Client Subnet option.
|
Modifier and Type | Method and Description |
---|---|
private static int |
checkMaskLength(java.lang.String field,
int family,
int val) |
java.net.InetAddress |
getAddress()
Returns the IP address of the client.
|
int |
getFamily()
Returns the family of the network address.
|
int |
getScopePrefixLength()
Returns the scope netmask.
|
int |
getSourcePrefixLength()
Returns the source netmask.
|
(package private) void |
optionFromWire(DNSInput in)
Converts the wire format of an EDNS Option (the option data only) into the type-specific
format.
|
(package private) java.lang.String |
optionToString() |
(package private) void |
optionToWire(DNSOutput out)
Converts an EDNS Option (the type-specific option data only) into wire format.
|
private int family
private int sourcePrefixLength
private int scopePrefixLength
private java.net.InetAddress address
ClientSubnetOption()
public ClientSubnetOption(int sourcePrefixLength, int scopePrefixLength, java.net.InetAddress address)
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.public ClientSubnetOption(int sourcePrefixLength, java.net.InetAddress address)
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.ClientSubnetOption
private static int checkMaskLength(java.lang.String field, int family, int val)
public int getFamily()
public int getSourcePrefixLength()
public int getScopePrefixLength()
public java.net.InetAddress getAddress()
void optionFromWire(DNSInput in) throws WireParseException
EDNSOption
optionFromWire
in class EDNSOption
in
- The input Stream.WireParseException
void optionToWire(DNSOutput out)
EDNSOption
optionToWire
in class EDNSOption
out
- The output stream.java.lang.String optionToString()
optionToString
in class EDNSOption