Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > IP Address Range Manager

Reply
Thread Tools

IP Address Range Manager

 
 
miss
Guest
Posts: n/a
 
      08-18-2004
I was wondering if there was any API out there to manage IPAddress. I
already have implemented most of the part using string functions but
it seems there should be better way to do this.

I am storing IPAddress range in decimal format in the database. But
user can put any of the following format.

12.23.*.*
12.23.21.23
12.23.23.0-12.23.23.255
216.239.32.0/19


all of them gets converted to following format

3639557888-3639558143
 
Reply With Quote
 
 
 
 
Paul Lutus
Guest
Posts: n/a
 
      08-18-2004
miss wrote:

> I was wondering if there was any API out there to manage IPAddress. I
> already have implemented most of the part using string functions but
> it seems there should be better way to do this.


A better way to do what? You haven't said what your class needs to do. This
makes giving advice rather difficult.

> I am storing IPAddress range in decimal format in the database.


Please spell out what you mean by "decimal format". Decimal strings?
Integers?

> But
> user can put any of the following format.
>
> 12.23.*.*
> 12.23.21.23
> 12.23.23.0-12.23.23.255
> 216.239.32.0/19
>
>
> all of them gets converted to following format
>
> 3639557888-3639558143


How does the first example in your list -- "12.23.*.*" get converted to a
pair of integers? How do you handle this case and retain the originator's
intentions?

With answers to some of these questions, someone will be able to help you.

--
Paul Lutus
http://www.arachnoid.com

 
Reply With Quote
 
 
 
 
zoopy
Guest
Posts: n/a
 
      08-19-2004
On 18-8-2004 23:43, miss wrote:

> I was wondering if there was any API out there to manage IPAddress. I
> already have implemented most of the part using string functions but
> it seems there should be better way to do this.
>
> I am storing IPAddress range in decimal format in the database. But
> user can put any of the following format.
>
> 12.23.*.*
> 12.23.21.23
> 12.23.23.0-12.23.23.255
> 216.239.32.0/19
>
>
> all of them gets converted to following format
>
> 3639557888-3639558143


Maybe InetAddress and its subclasses?
<http://java.sun.com/j2se/1.4.2/docs/api/java/net/InetAddress.html>

--
Regards,
Z.
 
Reply With Quote
 
miss
Guest
Posts: n/a
 
      08-19-2004
Thanks for the repsonse Paul.
I am trying to have JSP form where users can put any number of IP
ranges separated by comma. This format is same as access control list.
The only difference is they will be stored in database as bigint in
two different columns (fromIP to toIP).
I don't think user will ever use the 12.23.*.* format, atleast
12.23.23.* range will be entered.

In that case, the range is 12.23.23.0-12.23.23.255 which will be
converted to decimal range.

Paul Lutus <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> miss wrote:
>
> > I was wondering if there was any API out there to manage IPAddress. I
> > already have implemented most of the part using string functions but
> > it seems there should be better way to do this.

>
> A better way to do what? You haven't said what your class needs to do. This
> makes giving advice rather difficult.
>
> > I am storing IPAddress range in decimal format in the database.

>
> Please spell out what you mean by "decimal format". Decimal strings?
> Integers?
>
> > But
> > user can put any of the following format.
> >
> > 12.23.*.*
> > 12.23.21.23
> > 12.23.23.0-12.23.23.255
> > 216.239.32.0/19
> >
> >
> > all of them gets converted to following format
> >
> > 3639557888-3639558143

>
> How does the first example in your list -- "12.23.*.*" get converted to a
> pair of integers? How do you handle this case and retain the originator's
> intentions?
>
> With answers to some of these questions, someone will be able to help you.

 
Reply With Quote
 
Paul Lutus
Guest
Posts: n/a
 
      08-19-2004
miss wrote:

> Thanks for the repsonse Paul.
> I am trying to have JSP form where users can put any number of IP
> ranges separated by comma. This format is same as access control list.
> The only difference is they will be stored in database as bigint in
> two different columns (fromIP to toIP).


BigInt? Isn't an int currently 32 bits? Isn't this the same as the size of
an IP? I ask because there's no point in increasing the storage requirement
across the board based on a misconception.

In the case of ranges of addresses, you could use two integers and some code
to interpret the meaning of zero fields. In fact, this might produce a more
robust storage scheme than the alternatives.

--
Paul Lutus
http://www.arachnoid.com

 
Reply With Quote
 
Liz
Guest
Posts: n/a
 
      08-20-2004

"Paul Lutus" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> miss wrote:
>
> > Thanks for the repsonse Paul.
> > I am trying to have JSP form where users can put any number of IP
> > ranges separated by comma. This format is same as access control list.
> > The only difference is they will be stored in database as bigint in
> > two different columns (fromIP to toIP).

>
> BigInt? Isn't an int currently 32 bits? Isn't this the same as the size of
> an IP? I ask because there's no point in increasing the storage

requirement
> across the board based on a misconception.


Isn't IPV6 bigger? What about the mask?

>
> In the case of ranges of addresses, you could use two integers and some

code
> to interpret the meaning of zero fields. In fact, this might produce a

more
> robust storage scheme than the alternatives.
>
> --
> Paul Lutus
> http://www.arachnoid.com
>



 
Reply With Quote
 
Paul Lutus
Guest
Posts: n/a
 
      08-20-2004
Liz wrote:

>
> "Paul Lutus" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> miss wrote:
>>
>> > Thanks for the repsonse Paul.
>> > I am trying to have JSP form where users can put any number of IP
>> > ranges separated by comma. This format is same as access control list.
>> > The only difference is they will be stored in database as bigint in
>> > two different columns (fromIP to toIP).

>>
>> BigInt? Isn't an int currently 32 bits? Isn't this the same as the size
>> of an IP? I ask because there's no point in increasing the storage

> requirement
>> across the board based on a misconception.

>
> Isn't IPV6 bigger? What about the mask?


The OP hasn't addressed either IPV6 or a mask, so I decided not to address
those either. In any case, BigInteger (if this is the OP's meaning) is more
than is needed even for IPV6. I would create a class with appropriate
integer data types for each requirement, and no more.

--
Paul Lutus
http://www.arachnoid.com

 
Reply With Quote
 
Liz
Guest
Posts: n/a
 
      08-20-2004

"miss" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> I was wondering if there was any API out there to manage IPAddress. I
> already have implemented most of the part using string functions but
> it seems there should be better way to do this.
>
> I am storing IPAddress range in decimal format in the database. But
> user can put any of the following format.
>
> 12.23.*.*
> 12.23.21.23
> 12.23.23.0-12.23.23.255
> 216.239.32.0/19
>
>
> all of them gets converted to following format
>
> 3639557888-3639558143


If YOU are MANAGING the IP addresses, why is the USER
providing an IP address or range of IP addresses to you
the MANAGER. I should think that YOU should select the
IP address based on things like the LAN topology.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
range() is not the best way to check range? Summercoolness@gmail.com Python 46 07-25-2006 08:10 PM
Scene range vs dynamic range Robert Feinman Digital Photography 2 07-04-2005 09:30 PM



Advertisments