Home | History | Annotate | Download | only in net

Lines Matching defs:address

36  * <li>A starting IP address (IPv4 or IPv6). This is the first IP address of the prefix.
38 * in the IP address, starting from the most significant bit in network byte order, that
50 private final byte[] address; // network byte order
54 if (address.length != 4 && address.length != 16) {
56 "IpPrefix has " + address.length + " bytes which is neither 4 nor 16");
58 NetworkUtils.maskRawAddress(address, prefixLength);
62 * Constructs a new {@code IpPrefix} from a byte array containing an IPv4 or IPv6 address in
63 * network byte order and a prefix length. Silently truncates the address to the prefix length,
66 * @param address the IP address. Must be non-null and exactly 4 or 16 bytes long.
71 public IpPrefix(byte[] address, int prefixLength) {
72 this.address = address.clone();
78 * Constructs a new {@code IpPrefix} from an IPv4 or IPv6 address and a prefix length. Silently
79 * truncates the address to the prefix length, so for example {@code 192.0.2.1/24} is silently
82 * @param address the IP address. Must be non-null.
86 public IpPrefix(InetAddress address, int prefixLength) {
89 this.address = address.getAddress();
96 * Silently truncates the address to the prefix length, so for example {@code 192.0.2.1/24}
107 // cannot assign a value to final variable address". So we just duplicate the code here.
109 this.address = ipAndMask.first.getAddress();
127 return Arrays.equals(this.address, that.address) && this.prefixLength == that.prefixLength;
137 return Arrays.hashCode(address) + 11 * prefixLength;
141 * Returns a copy of the first IP address in the prefix. Modifying the returned object does not
144 * @return the address in the form of a byte array.
148 return InetAddress.getByAddress(address);
157 * Returns a copy of the IP address bytes in network order (the highest order byte is the zeroth
160 * @return the address in the form of a byte array.
163 return address.clone();
176 * Determines whether the prefix contains the specified address.
178 * @param address An {@link InetAddress} to test.
179 * @return {@code true} if the prefix covers the given address.
181 public boolean contains(InetAddress address) {
182 byte[] addrBytes = (address == null) ? null : address.getAddress();
183 if (addrBytes == null || addrBytes.length != this.address.length) {
187 return Arrays.equals(this.address, addrBytes);
201 return Arrays.equals(otherAddress, address);
225 return InetAddress.getByAddress(address).getHostAddress() + "/" + prefixLength;
228 throw new IllegalStateException("IpPrefix with invalid address! Shouldn't happen.", e);
243 dest.writeByteArray(address);
249 * Contents of the address will break ties.
265 final byte[] a1 = prefix1.address;
266 final byte[] a2 = prefix2.address;
285 byte[] address = in.createByteArray();
287 return new IpPrefix(address, prefixLength);