Object Modeling Technique
(OMT) view of the SNMP++ Address Class

The network address class is a set of C++
classes which provide for simple, safe, portable and efficient use of network addresses.
Most network management applications require use of network addresses for
accessing and managing devices. This includes address validation, modification
and user interface control. Rather than manage all the internal details of
particular network addresses, the Address class encapsulates and hides the
internal mechanisms freeing the application programmer to focus on the problem
at hand. The motivation for the development of the Address class emerged from
input and discussion at the ‘95 Interop SNMP++
Birds-of-A-Feather (BOF) and from dialog with Hewlett-Packard OpenView programmers.
The address class provides a number of
benefits including: automatic memory management, address validation,
portability to any C++ environment, ease of use and extensibility. Currently,
the Address class consists of four classes, the IpAddress
Class, the IpxAddress Class, the MacAddress
class and the GenAddress class. In the future other
subclasses will be added including IP Next Generation (IPng).
The address classes are based around one
abstract class, the Address class. This is an abstract class. That is, there
may be no instances of this class. The Address class provides a consistent
interface through the use of virtual member functions. This allows passing
addresses to other functions using the generic interface. This minimizes code
changes to modules using addresses.
The base class, the Address class is an
abstract class. The class contains the commonality of all derived address
classes. This includes an identical interface for constructing, accessing and
mutating Addresses.
|
Description |
|
|
IpAddress Class Constructors
|
|
|
IpAddress::IpAddress( void); |
Construct an empty IpAddress object. |
|
IpAddress::IpAddress( const char *string); |
Construct an IpAddress
from a string, do DNS if needed. |
|
IpAddress::IpAddress( const IpAddress
&ipa); |
Copy constructor. |
|
IPAddress Member Functions |
|
|
char * friendly_name( int &
status); |
Invokes DNS lookup for friendly
name. |
|
UdpAddress Constructors
|
|
|
UdpAddress::UdpAddress(
void); |
Construct an invalid UdpAddress Object. |
|
UdpAddress::UdpAddress(
const char *string); |
Construct a
UdpAddress using a char string. |
|
UdpAddress::UdpAddress(
const UdpAddress &udpa); |
Construct a
UdpAddress using another UdpAddress. |
|
UdpAddress Member Functions |
|
|
void UdpAddress:set_port( const unsigned int
p); |
Set the port number for a UdpAddress object. |
|
unsigned int UdpAddress::get_port(); |
Get the port number from a UdpAddress object. |
|
IpxAddress Class Constructors |
|
|
IpxAddress::IpxAddress( void); |
Construct an empty IPX address. |
|
IpxAddress::IpxAddress( const char *string); |
Construct an IPX address using a
char string. |
|
IpxAddress::IpxAddress( const IpxAddress
&ipxa); |
Copy constructor. |
|
IpxSockAddress Constuctors |
|
|
IpxSockAddress::IpxSockAddress(
void); |
Construct an empty IpxSockAddress object. |
|
IpxSockAddress::IpxSockAddress(
const char *string); |
Construct a
IpxSockAddress using a char string. |
|
IpxSockAddress::IpxSockAddress(
const IpxSockAddress &ipxs);
|
Construct a
IpxSockAddress using another IpxSockAddress. |
|
IpxSockAddress Member Functions |
|
|
IpxSockAddress::set_socket(
const unsigned int s); |
Get the socket number from a IpxSockAddress. |
|
unsigned int IpxSocketAddress::get_socket(); |
Set the socket number into a IpxSockAddress. |
|
MacAddress Constructors
|
|
|
MacAddress::MacAddress( void); |
Construct an empty MacAddress object. |
|
MacAddress::MacAddress( const char * string); |
Construct a MacAddress
from a string. |
|
MacAddress::MacAddress( const MacAddress
&mac); |
Copy constructor. |
|
GenAddress Constructors |
|
|
GenAddress::GenAddress(
void); |
Construct a
invalid GenAddress object. |
|
GenAddress::GenAddress(
const char * addr); |
Construct a GenAddress
using a string. |
|
GenAddress::GenAddress(
const GenAddress &addr); |
Copy constructor. |
|
Common
Member Functions, applicable to all Address classes |
|
|
int operator == ( const Address &lhs, const Address rhs); |
Determine if two Addresses are
equal. |
|
int operator != ( const Address &lhs, const Address
&rhs); |
Determine if two Addresses are
not equal. |
|
int operator > ( const Address &lhs, const Address
&rhs); |
Determine if one Address is
greater than another. |
|
int operator >= (const Address &lhs, const Address
&rhs); |
Determine if one Address is
greater than or equal. |
|
int operator < ( const Address &lhs, const Address
&rhs); |
Determine if one Address is less
than another. |
|
int operator<=( const Address &lhs, const Address
&rhs); |
Determine if one Address is less
than or equal to another. |
|
int
operator == ( const Address &lhs, cosnt char *inaddr); |
Determine if two Addresses are
equal. |
|
int operator > ( const Address &lhs, const char *inaddr); |
Determine if an Address if
greater than a string. |
|
int operator < ( const Address &lhs, const char *inaddr); |
Determine if an Address is less
than a string. |
|
virtual int valid( ); |
Determine if an Address is
valid. |
|
unsigned
char& operator[]( int position); |
Allow access to an Address
object using array like access. |
|
char * get_printable ( ); |
Returns Address formatted for
output. |
The IpAddress
class will do automatic Domain Name Services (DNS) lookup when calling the Address::get_printable() member function. If the DNS is not active or if the
address cannot be resolved, the dotted format will be returned. Alternatively,
an IpAddress can be constructed with a friendly name.
In this case the constructor will invoke the DNS lookup. If the friendly name
cannot be found, the address is invalid. This powerful feature allows you to
utilize friendly names in your IpAddress user
presentation.
The
GenAddress class allows creation and usage of generic
addresses where a GenAddress may take on the behavior
and attributes of any of the other Address classes ( IpAddress, IpxAddress and MacAddress). When working with arbitrary addresses, you may
use a GenAddress. The constructor for the GenAddress class allows creating an Address with any
character string. The constructor determines the specific type of Address which
matches the string and thereafter gives the GenAddress
the attributes and behavior of that Address. This saves the programmer from
having to write code which explicitly deals with the differences across
Addresses.
|
GenAddress Examples |