160 return ((address & 0xf0000000) == 0xe0000000);
161 }
162
163 /**
164 * Utility routine to check if the InetAddress in a wildcard address.
165 * @return a <code>boolean</code> indicating if the Inetaddress is
166 * a wildcard address.
167 * @since 1.4
168 */
169 public boolean isAnyLocalAddress() {
170 return address == 0;
171 }
172
173 /**
174 * Utility routine to check if the InetAddress is a loopback address.
175 *
176 * @return a <code>boolean</code> indicating if the InetAddress is
177 * a loopback address; or false otherwise.
178 * @since 1.4
179 */
180 private static final int loopback = 2130706433; /* 127.0.0.1 */
181 public boolean isLoopbackAddress() {
182 /* 127.x.x.x */
183 byte[] byteAddr = getAddress();
184 return byteAddr[0] == 127;
185 }
186
187 /**
188 * Utility routine to check if the InetAddress is an link local address.
189 *
190 * @return a <code>boolean</code> indicating if the InetAddress is
191 * a link local address; or false if address is not a link local unicast address.
192 * @since 1.4
193 */
194 public boolean isLinkLocalAddress() {
195 // link-local unicast in IPv4 (169.254.0.0/16)
196 // defined in "Documenting Special Use IPv4 Address Blocks
197 // that have been Registered with IANA" by Bill Manning
198 // draft-manning-dsua-06.txt
199 return (((address >>> 24) & 0xFF) == 169)
200 && (((address >>> 16) & 0xFF) == 254);
|
160 return ((address & 0xf0000000) == 0xe0000000);
161 }
162
163 /**
164 * Utility routine to check if the InetAddress in a wildcard address.
165 * @return a <code>boolean</code> indicating if the Inetaddress is
166 * a wildcard address.
167 * @since 1.4
168 */
169 public boolean isAnyLocalAddress() {
170 return address == 0;
171 }
172
173 /**
174 * Utility routine to check if the InetAddress is a loopback address.
175 *
176 * @return a <code>boolean</code> indicating if the InetAddress is
177 * a loopback address; or false otherwise.
178 * @since 1.4
179 */
180 public boolean isLoopbackAddress() {
181 /* 127.x.x.x */
182 byte[] byteAddr = getAddress();
183 return byteAddr[0] == 127;
184 }
185
186 /**
187 * Utility routine to check if the InetAddress is an link local address.
188 *
189 * @return a <code>boolean</code> indicating if the InetAddress is
190 * a link local address; or false if address is not a link local unicast address.
191 * @since 1.4
192 */
193 public boolean isLinkLocalAddress() {
194 // link-local unicast in IPv4 (169.254.0.0/16)
195 // defined in "Documenting Special Use IPv4 Address Blocks
196 // that have been Registered with IANA" by Bill Manning
197 // draft-manning-dsua-06.txt
198 return (((address >>> 24) & 0xFF) == 169)
199 && (((address >>> 16) & 0xFF) == 254);
|