Uploaded image for project: 'Commons Net'
  1. Commons Net
  2. NET-622

SubnetInfo#getCidrSignature - improve functions

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 3.7
    • None
    • None

    Description

      The processing part of "netmask" is converted an integer to a string to an integer.

      /* SubnetUtils.SubnetInfo#getCidrSignature() */
      // a binary mask address
      int netmask = 0b11111111000000000000000000000000;
      
      // convert to a dotted decimal address
      String maskStr = format(toArray(netmask)); // maskStr: "255.0.0.0"
      
      /* SubnetUtils#toCidrNotation() */
      // counting the 1-bit population
      int cidr = pop(toInteger(maskStr)); // cidr: 8
      

      So, I suggest to create CIDR from the netmask variable.
      https://github.com/apache/commons-net/pull/10

      Attachments

        Activity

          People

            Unassigned Unassigned
            Umoxfo Makoto Sakaguchi
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: