Hi,
I'm trying to the best way to validate that a specified
IP is inside a known range of IP. The IP is held in an
IPAddress type which hold the actual IP in as long and so
the statement:
224.1.0.0 > 224.0.1.0 does not necesarily translate to:
480 > 65760 (which is the representation of these IP as
long).
I would expect that i would able to do something like:
ipAddress.Address > pAddress1.Address
I know I can do all kind of string or mathematical
manipulations but I am hoping for a more elegant solution
that will take advantage of the fact that the data is
held as IPAddress type.
Thanks,
Chen

RE: IPAddress range validation by lukezhan

lukezhan
Fri Nov 07 00:15:32 CST 2003

Hi Chen,

We can't compare two IpAddress objects with symbol ">" or "<" directly. I
think you may consider converting them to Byte array first with IPAddress
class's GetAddressBytes method, and then compare the byte array to get the
result.

Hope this help,

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


RE: IPAddress range validation by anonymous

anonymous
Mon Nov 10 01:25:49 CST 2003

Hi Luke,
Thanks. This is pretty much what I did. I was just hoping
for something more elegant. Maybe in the next framework :)
Chen
>-----Original Message-----
>Hi Chen,
>
>We can't compare two IpAddress objects with symbol ">"
or "<" directly. I
>think you may consider converting them to Byte array
first with IPAddress
>class's GetAddressBytes method, and then compare the
byte array to get the
>result.
>
>Hope this help,
>
>Luke
>Microsoft Online Support
>
>Get Secure! www.microsoft.com/security
>(This posting is provided "AS IS", with no warranties,
and confers no
>rights.)
>
>.
>