Main Page | Class Hierarchy | Class List | File List | Class Members | Related Pages

net::IPCalc Class Reference

A class to perform calculations on IP addresses. More...

#include <IPCalc.h>

List of all members.

Public Member Functions

 IPCalc (string aString1, string aString2)
 Constructor for IPCalc (string version).
 IPCalc (unsigned long aLong1, unsigned long aLong2)
 Constructor for IPCalc (unsigned long version).
unsigned long getAddress ()
 Get the current address.
unsigned long getNetworkAddress ()
 Get the current network address.
unsigned long getIPClass ()
 Get the current IP address class.
unsigned long getHostNumber ()
 Get the current host number if the current IP address is a host address.
unsigned long getFirstHost ()
 Get the IP address of the first host on the current network.
unsigned long getLastHost ()
 Get the IP address of the last host on the current network.
unsigned long getNetMask ()
 Get the (sub)net mask of the current IP address.
int isInSameNet (IPCalc aIpc)
 determines if the IP address contained in the given IPCalc is in the same network as the current IPCalc object
int isHost ()
 Determines if the current address is a host address.
int isNetwork ()
 Determines if the current address is a network address.
void display ()
 display the IPCalc object
int checkAddress ()
 checks the IPCalc object. Bad cases : IP address is a broadcast, netmask inferior to the IP address class mask eg. 192.168.1.1/255.128.0.0

Static Public Attributes

static const unsigned long kCLASS_A
static const unsigned long kCLASS_B
static const unsigned long kCLASS_C
static const unsigned long kCLASS_A_NETWORK_MASK
static const unsigned long kCLASS_B_NETWORK_MASK
static const unsigned long kCLASS_C_NETWORK_MASK


Detailed Description

A class to perform calculations on IP addresses.

Author:
Laurent Moutel


Constructor & Destructor Documentation

net::IPCalc::IPCalc string  aString1,
string  aString2
 

Constructor for IPCalc (string version).

Parameters:
aString The IP Address to initialize
aString2 The netmask for the IP address. If it's empty, the mask is initialized with the mask of its class (A,B,C)

net::IPCalc::IPCalc unsigned long  aLong1,
unsigned long  aLong2
 

Constructor for IPCalc (unsigned long version).

Parameters:
aLong The IP Address to initialize
aString2 The netmask for the IP address. If it's 0, the mask is initialized with the mask of its class (A,B,C)


Member Function Documentation

int net::IPCalc::checkAddress  ) 
 

checks the IPCalc object. Bad cases : IP address is a broadcast, netmask inferior to the IP address class mask eg. 192.168.1.1/255.128.0.0

Returns:
1 if it's OK, 0 else

unsigned long net::IPCalc::getAddress  ) 
 

Get the current address.

Returns:
an unsigned double containing the value of the address

unsigned long net::IPCalc::getFirstHost  ) 
 

Get the IP address of the first host on the current network.

Returns:
an unsigned double containing the IP address of the first host of the current network

unsigned long net::IPCalc::getHostNumber  ) 
 

Get the current host number if the current IP address is a host address.

Returns:
an unsigned double containing the host number

unsigned long net::IPCalc::getIPClass  ) 
 

Get the current IP address class.

Returns:
an unsigned double containing the value of the ip address class (constants kCLASS_A to cCLASS_C)

unsigned long net::IPCalc::getLastHost  ) 
 

Get the IP address of the last host on the current network.

Returns:
an unsigned double containing the IP address of the last host of the current network

unsigned long net::IPCalc::getNetMask  ) 
 

Get the (sub)net mask of the current IP address.

Returns:
an unsigned double containing the (sub)net mask of the current IP address

unsigned long net::IPCalc::getNetworkAddress  ) 
 

Get the current network address.

Returns:
an unsigned double containing the value of the network address

int net::IPCalc::isHost  ) 
 

Determines if the current address is a host address.

Returns:
1 it it's a host address, else 0

int net::IPCalc::isInSameNet IPCalc  aIpc  ) 
 

determines if the IP address contained in the given IPCalc is in the same network as the current IPCalc object

Parameters:
aIpc an IPCalc object containing an address
Returns:
1 if in same net, else 0

int net::IPCalc::isNetwork  ) 
 

Determines if the current address is a network address.

Returns:
1 it it's a network address, else 0


The documentation for this class was generated from the following file:
Generated on Fri May 19 23:12:37 2006 for common by  doxygen 1.4.4