Lines Matching refs:address

33  * <li>A starting IP address (IPv4 or IPv6). This is the first IP address of the prefix.
35 * in the IP address, starting from the most significant bit in network byte order, that
47 private final byte[] address; // network byte order
51 if (address.length != 4 && address.length != 16) {
53 "IpPrefix has " + address.length + " bytes which is neither 4 nor 16");
55 NetworkUtils.maskRawAddress(address, prefixLength);
59 * Constructs a new {@code IpPrefix} from a byte array containing an IPv4 or IPv6 address in
60 * network byte order and a prefix length. Silently truncates the address to the prefix length,
63 * @param address the IP address. Must be non-null and exactly 4 or 16 bytes long.
68 public IpPrefix(byte[] address, int prefixLength) {
69 this.address = address.clone();
75 * Constructs a new {@code IpPrefix} from an IPv4 or IPv6 address and a prefix length. Silently
76 * truncates the address to the prefix length, so for example {@code 192.0.2.1/24} is silently
79 * @param address the IP address. Must be non-null.
83 public IpPrefix(InetAddress address, int prefixLength) {
86 this.address = address.getAddress();
93 * Silently truncates the address to the prefix length, so for example {@code 192.0.2.1/24}
104 // cannot assign a value to final variable address". So we just duplicate the code here.
106 this.address = ipAndMask.first.getAddress();
124 return Arrays.equals(this.address, that.address) && this.prefixLength == that.prefixLength;
134 return Arrays.hashCode(address) + 11 * prefixLength;
138 * Returns a copy of the first IP address in the prefix. Modifying the returned object does not
141 * @return the address in the form of a byte array.
145 return InetAddress.getByAddress(address);
154 * Returns a copy of the IP address bytes in network order (the highest order byte is the zeroth
157 * @return the address in the form of a byte array.
160 return address.clone();
173 * Determines whether the prefix contains the specified address.
175 * @param address An {@link InetAddress} to test.
176 * @return {@code true} if the prefix covers the given address.
178 public boolean contains(InetAddress address) {
179 byte[] addrBytes = (address == null) ? null : address.getAddress();
180 if (addrBytes == null || addrBytes.length != this.address.length) {
184 return Arrays.equals(this.address, addrBytes);
194 return InetAddress.getByAddress(address).getHostAddress() + "/" + prefixLength;
197 throw new IllegalStateException("IpPrefix with invalid address! Shouldn't happen.", e);
212 dest.writeByteArray(address);
222 byte[] address = in.createByteArray();
224 return new IpPrefix(address, prefixLength);