IP Address Range Manager

M

miss

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
 
P

Paul Lutus

miss said:
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.
 
Z

zoopy

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>
 
M

miss

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.
 
P

Paul Lutus

miss said:
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.
 
L

Liz

Paul Lutus said:
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?
 
P

Paul Lutus

Liz said:
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.
 
L

Liz

miss said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top