@@ -201,9 +201,8 @@ record = this.readNode(buffer, record, bit);
201201 /**
202202 * Creates a Networks iterator and skips aliased networks.
203203 * Please note that a MaxMind DB may map IPv4 networks into several locations
204- * in an IPv6 database. This iterator will iterate over all of these locations
205- * separately. To disable skipAliasedNetworks, which iterates over the IPv4 networks
206- * only once, use the SkipAliasedNetworks parameter.
204+ * in an IPv6 database. networks() iterates over the canonical locations and
205+ * not the aliases. To include the aliases, you can set includeAliasedNetworks to true.
207206 *
208207 * @param <T> Represents the data type(e.g., Map, HastMap, etc.).
209208 * @param typeParameterClass The type of data returned by the iterator.
@@ -214,25 +213,25 @@ record = this.readNode(buffer, record, bit);
214213 */
215214 public <T > Networks <T > networks (Class <T > typeParameterClass ) throws
216215 InvalidNetworkException , ClosedDatabaseException , InvalidDatabaseException {
217- return this .networks (true , typeParameterClass );
216+ return this .networks (false , typeParameterClass );
218217 }
219218
220219 /**
221220 * Creates a Networks iterator.
222221 * Please note that a MaxMind DB may map IPv4 networks into several locations
223222 * in an IPv6 database. This iterator will iterate over all of these locations
224223 * separately. To set the iteration over the IPv4 networks once, use the
225- * SkipAliasedNetworks option.
224+ * includeAliasedNetworks option.
226225 *
227226 * @param <T> Represents the data type(e.g., Map, HastMap, etc.).
228- * @param skipAliasedNetworks Enable or disable skipping aliased networks.
227+ * @param includeAliasedNetworks Enable including aliased networks.
229228 * @return Networks The Networks iterator.
230229 * @throws InvalidNetworkException Exception for using an IPv6 network in ipv4-only database.
231230 * @throws ClosedDatabaseException Exception for a closed databased.
232231 * @throws InvalidDatabaseException Exception for an invalid database.
233232 */
234233 public <T > Networks <T > networks (
235- boolean skipAliasedNetworks ,
234+ boolean includeAliasedNetworks ,
236235 Class <T > typeParameterClass ) throws
237236 InvalidNetworkException , ClosedDatabaseException , InvalidDatabaseException {
238237 try {
@@ -242,9 +241,9 @@ public <T> Networks<T> networks(
242241 Network ipAllV6 = new Network (ipv6 , 0 ); // Mask 128.
243242
244243 if (this .getMetadata ().getIpVersion () == 6 ) {
245- return this .networksWithin (ipAllV6 , skipAliasedNetworks , typeParameterClass );
244+ return this .networksWithin (ipAllV6 , includeAliasedNetworks , typeParameterClass );
246245 }
247- return this .networksWithin (ipAllV4 , skipAliasedNetworks , typeParameterClass );
246+ return this .networksWithin (ipAllV4 , includeAliasedNetworks , typeParameterClass );
248247 } catch (UnknownHostException e ) {
249248 /* This is returned by getByAddress. This should never happen
250249 as the ipv4 and ipv6 are constants set by us. */
@@ -289,10 +288,10 @@ private int findIpV4StartNode(ByteBuffer buffer)
289288 * Please note that a MaxMind DB may map IPv4 networks into several locations
290289 * in an IPv6 database. This iterator will iterate over all of these locations
291290 * separately. To only iterate over the IPv4 networks once, use the
292- * SkipAliasedNetworks option.
291+ * includeAliasedNetworks option.
293292 * @param <T> Represents the data type(e.g., Map, HastMap, etc.).
294293 * @param network Specifies the network to be iterated.
295- * @param skipAliasedNetworks Boolean for skipping aliased networks.
294+ * @param includeAliasedNetworks Boolean for including aliased networks.
296295 * @param typeParameterClass The type of data returned by the iterator.
297296 * @return Networks
298297 * @throws InvalidNetworkException Exception for using an IPv6 network in ipv4-only database.
@@ -301,7 +300,7 @@ private int findIpV4StartNode(ByteBuffer buffer)
301300 */
302301 public <T > Networks <T > networksWithin (
303302 Network network ,
304- boolean skipAliasedNetworks ,
303+ boolean includeAliasedNetworks ,
305304 Class <T > typeParameterClass )
306305 throws InvalidNetworkException , ClosedDatabaseException , InvalidDatabaseException {
307306 InetAddress networkAddress = network .getNetworkAddress ();
@@ -313,14 +312,14 @@ public <T> Networks<T> networksWithin(
313312 int prefixLength = network .getPrefixLength ();
314313
315314 if (this .metadata .getIpVersion () == 6 && ipBytes .length == IPV4_LEN ) {
316- if (skipAliasedNetworks ) {
317- ipBytes = new byte []{0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
318- ipBytes [0 ], ipBytes [1 ], ipBytes [2 ], ipBytes [3 ] };
319- } else {
315+ if (includeAliasedNetworks ) {
320316 // Convert it to the IP address (in 16-byte from) of the IPv4 address.
321317 ipBytes = new byte []{0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
322318 -1 , -1 , // -1 is for 0xff.
323319 ipBytes [0 ], ipBytes [1 ], ipBytes [2 ], ipBytes [3 ]};
320+ } else {
321+ ipBytes = new byte []{0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
322+ ipBytes [0 ], ipBytes [1 ], ipBytes [2 ], ipBytes [3 ] };
324323 }
325324 prefixLength += 96 ;
326325 }
@@ -329,7 +328,7 @@ public <T> Networks<T> networksWithin(
329328 int node = traverseResult [0 ];
330329 int prefix = traverseResult [1 ];
331330
332- Networks <T > networks = new Networks <T >(this , skipAliasedNetworks ,
331+ Networks <T > networks = new Networks <T >(this , includeAliasedNetworks ,
333332 new Networks .NetworkNode []{new Networks .NetworkNode (ipBytes , prefix , node )},
334333 typeParameterClass );
335334
0 commit comments