[jira] Created: (NET-282) Improvement to isInRange method in SubnetUtil.SubnetInfo class

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (NET-282) Improvement to isInRange method in SubnetUtil.SubnetInfo class

Gary D. Gregory (Jira)
Improvement to isInRange method in SubnetUtil.SubnetInfo class
--------------------------------------------------------------

                 Key: NET-282
                 URL: https://issues.apache.org/jira/browse/NET-282
             Project: Commons Net
          Issue Type: Improvement
    Affects Versions: 2.0
         Environment: All
            Reporter: Scott Davis


I am very pleased to see that the isInRange bug has been corrected in 2.1.  I would like to suggest the additional change to the isInRange method (or perhaps some polymorphism).

Current:

private boolean isInRange(int address)      { return ((address-low()) <= (high()-low())); }

Proposed Fix (I saw in another bug ticket):

{code}
private boolean isInRange(int address) {
    int normal = address - this.low;
    return (normal >= 0 && normal <= (this.high - this.low))
}
{code}

I would argue that the network address and the broadcast address, while not viable IPs to be assigned, are still technically in the range of the network, so I would request that the method be updated as follows (or perhaps a new method or flag you could pass to determine if you want to include the network and broadcast address):

{code}
private boolean isInRange(int address) {
    int normal = address - this.network;
    return (normal >= 0 && normal <= (this.broadcast - this.network))
}
{code}

Polymorphism route:

{code}
private boolean isInRange(int address) {
    return isInRange(address, false);
}

private boolean isInRange(int address, boolean fullRange) {
    int myLow;
    int myHigh;

    if (fullRange) {
        myLow = this.network;
        myHigh = this.broadast;
    }
    else {
        myLow = this.low;
        myHigh = this.high;
    }

    int normal = address - myLow;
    return (normal >= 0 && normal <= (myHigh - myLow));
}
{code}

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (NET-282) Improvement to isInRange method in SubnetUtil.SubnetInfo class

Gary D. Gregory (Jira)

     [ https://issues.apache.org/jira/browse/NET-282?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Scott Davis updated NET-282:
----------------------------

    Priority: Minor  (was: Major)

Updated criticality to be minor.  An oversight on initial add.

> Improvement to isInRange method in SubnetUtil.SubnetInfo class
> --------------------------------------------------------------
>
>                 Key: NET-282
>                 URL: https://issues.apache.org/jira/browse/NET-282
>             Project: Commons Net
>          Issue Type: Improvement
>    Affects Versions: 2.0
>         Environment: All
>            Reporter: Scott Davis
>            Priority: Minor
>
> I am very pleased to see that the isInRange bug has been corrected in 2.1.  I would like to suggest the additional change to the isInRange method (or perhaps some polymorphism).
> Current:
> private boolean isInRange(int address)      { return ((address-low()) <= (high()-low())); }
> Proposed Fix (I saw in another bug ticket):
> {code}
> private boolean isInRange(int address) {
>     int normal = address - this.low;
>     return (normal >= 0 && normal <= (this.high - this.low))
> }
> {code}
> I would argue that the network address and the broadcast address, while not viable IPs to be assigned, are still technically in the range of the network, so I would request that the method be updated as follows (or perhaps a new method or flag you could pass to determine if you want to include the network and broadcast address):
> {code}
> private boolean isInRange(int address) {
>     int normal = address - this.network;
>     return (normal >= 0 && normal <= (this.broadcast - this.network))
> }
> {code}
> Polymorphism route:
> {code}
> private boolean isInRange(int address) {
>     return isInRange(address, false);
> }
> private boolean isInRange(int address, boolean fullRange) {
>     int myLow;
>     int myHigh;
>     if (fullRange) {
>         myLow = this.network;
>         myHigh = this.broadast;
>     }
>     else {
>         myLow = this.low;
>         myHigh = this.high;
>     }
>     int normal = address - myLow;
>     return (normal >= 0 && normal <= (myHigh - myLow));
> }
> {code}

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (NET-282) Improvement to isInRange method in SubnetUtil.SubnetInfo class

Gary D. Gregory (Jira)
In reply to this post by Gary D. Gregory (Jira)

     [ https://issues.apache.org/jira/browse/NET-282?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rory Winston updated NET-282:
-----------------------------

    Fix Version/s: 3.0

Thanks, Scott. I'll put some flag in to handle this.

> Improvement to isInRange method in SubnetUtil.SubnetInfo class
> --------------------------------------------------------------
>
>                 Key: NET-282
>                 URL: https://issues.apache.org/jira/browse/NET-282
>             Project: Commons Net
>          Issue Type: Improvement
>    Affects Versions: 2.0
>         Environment: All
>            Reporter: Scott Davis
>            Priority: Minor
>             Fix For: 3.0
>
>
> I am very pleased to see that the isInRange bug has been corrected in 2.1.  I would like to suggest the additional change to the isInRange method (or perhaps some polymorphism).
> Current:
> private boolean isInRange(int address)      { return ((address-low()) <= (high()-low())); }
> Proposed Fix (I saw in another bug ticket):
> {code}
> private boolean isInRange(int address) {
>     int normal = address - this.low;
>     return (normal >= 0 && normal <= (this.high - this.low))
> }
> {code}
> I would argue that the network address and the broadcast address, while not viable IPs to be assigned, are still technically in the range of the network, so I would request that the method be updated as follows (or perhaps a new method or flag you could pass to determine if you want to include the network and broadcast address):
> {code}
> private boolean isInRange(int address) {
>     int normal = address - this.network;
>     return (normal >= 0 && normal <= (this.broadcast - this.network))
> }
> {code}
> Polymorphism route:
> {code}
> private boolean isInRange(int address) {
>     return isInRange(address, false);
> }
> private boolean isInRange(int address, boolean fullRange) {
>     int myLow;
>     int myHigh;
>     if (fullRange) {
>         myLow = this.network;
>         myHigh = this.broadast;
>     }
>     else {
>         myLow = this.low;
>         myHigh = this.high;
>     }
>     int normal = address - myLow;
>     return (normal >= 0 && normal <= (myHigh - myLow));
> }
> {code}

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Closed: (NET-282) Improvement to isInRange method in SubnetUtil.SubnetInfo class

Gary D. Gregory (Jira)
In reply to this post by Gary D. Gregory (Jira)

     [ https://issues.apache.org/jira/browse/NET-282?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rory Winston closed NET-282.
----------------------------

       Resolution: Fixed
    Fix Version/s:     (was: 3.0)
                   2.1

Fixed. Thanks for the suggestion.

> Improvement to isInRange method in SubnetUtil.SubnetInfo class
> --------------------------------------------------------------
>
>                 Key: NET-282
>                 URL: https://issues.apache.org/jira/browse/NET-282
>             Project: Commons Net
>          Issue Type: Improvement
>    Affects Versions: 2.0
>         Environment: All
>            Reporter: Scott Davis
>            Priority: Minor
>             Fix For: 2.1
>
>
> I am very pleased to see that the isInRange bug has been corrected in 2.1.  I would like to suggest the additional change to the isInRange method (or perhaps some polymorphism).
> Current:
> private boolean isInRange(int address)      { return ((address-low()) <= (high()-low())); }
> Proposed Fix (I saw in another bug ticket):
> {code}
> private boolean isInRange(int address) {
>     int normal = address - this.low;
>     return (normal >= 0 && normal <= (this.high - this.low))
> }
> {code}
> I would argue that the network address and the broadcast address, while not viable IPs to be assigned, are still technically in the range of the network, so I would request that the method be updated as follows (or perhaps a new method or flag you could pass to determine if you want to include the network and broadcast address):
> {code}
> private boolean isInRange(int address) {
>     int normal = address - this.network;
>     return (normal >= 0 && normal <= (this.broadcast - this.network))
> }
> {code}
> Polymorphism route:
> {code}
> private boolean isInRange(int address) {
>     return isInRange(address, false);
> }
> private boolean isInRange(int address, boolean fullRange) {
>     int myLow;
>     int myHigh;
>     if (fullRange) {
>         myLow = this.network;
>         myHigh = this.broadast;
>     }
>     else {
>         myLow = this.low;
>         myHigh = this.high;
>     }
>     int normal = address - myLow;
>     return (normal >= 0 && normal <= (myHigh - myLow));
> }
> {code}

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.