[GitHub] [commons-net] Stzx commented on a change in pull request #41: [NET-405] Support for IPv6 in SubnetUtils

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[GitHub] [commons-net] Stzx commented on a change in pull request #41: [NET-405] Support for IPv6 in SubnetUtils

GitBox
Stzx commented on a change in pull request #41: [NET-405] Support for IPv6 in SubnetUtils
URL: https://github.com/apache/commons-net/pull/41#discussion_r324950446
 
 

 ##########
 File path: src/main/java/org/apache/commons/net/util/IP6Subnet.java
 ##########
 @@ -0,0 +1,288 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.net.util;
+
+import java.math.BigInteger;
+
+/**
+ * Convenience container for IPv6 subnet summary information.
+ *
+ * @see <a href="https://tools.ietf.org/html/rfc4291#section-2.3">https://tools.ietf.org/html/rfc4291#section-2.3</a>
+ * @since 3.7
+ */
+public final class IP6Subnet extends SubnetUtils.SubnetInfo
+{
+
+    private static final int NBITS = 128;
+
+    private final int[] ip6Address;
+    private final int cidr;
+
+    /**
+     * Constructor that takes an IPv6 address in CIDR-notation, e.g. "2001:db8:0:0:0:ff00:42:8329/48".
+     *
+     * @param cidrNotation an IPv6 address in CIDR-notation
+     */
+    public IP6Subnet(String cidrNotation)
+    {
+        String[] tmp = cidrNotation.split("/");
+
+        ip6Address = toArray(tmp[0]);
 
 Review comment:
   Doesn't support processing the `::1/128` shorthand format now?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[hidden email]


With regards,
Apache Git Services