forest-net
an overlay networks for large-scale virtual worlds
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator
forest::IfaceTable Class Reference
Collaboration diagram for forest::IfaceTable:

Classes

class  Entry
 < iface table entry More...
 

Public Member Functions

 IfaceTable (int)
 Constructor for IfaceTable, allocates space and initializes private data.
 
 ~IfaceTable ()
 Destructor for IfaceTable, deletes allocated space.
 
bool valid (int) const
 Check an interface number for validity. More...
 
int firstIface () const
 Get the "first" interface number. More...
 
int nextIface (int) const
 Get the "next" interface number. More...
 
EntrygetEntry (int)
 Get a table entry. More...
 
int getDefaultIface () const
 Get the number of the default interface. More...
 
int getFreeIface () const
 Get an an unused interface number. More...
 
bool addEntry (int, ipa_t, ipp_t, RateSpec &)
 Allocate and initialize a new interface table entry. More...
 
void removeEntry (int)
 Remove an interface from the table. More...
 
void setDefaultIface (int)
 Set the default interface. More...
 
bool read (istream &)
 Read interface table entries from the input. More...
 
string toString () const
 Create a string representation of the interface table. More...
 
string entry2string (int) const
 Create a string representation of an entry. More...
 

Private Member Functions

int readEntry (istream &)
 Read a table entry from an input stream and add it to the table. More...
 

Private Attributes

int maxIf
 largest interface number
 
int defaultIf
 default interface
 
Entryift
 ift[i]=data for interface i
 
ListPair * ifaces
 in-use and available iface numbers
 

Detailed Description

Definition at line 20 of file IfaceTable.h.

Member Function Documentation

bool forest::IfaceTable::addEntry ( int  iface,
ipa_t  ipa,
ipp_t  ipp,
RateSpec rs 
)

Allocate and initialize a new interface table entry.

Parameters
ifaceis an interface number for an unused interface
ipais the IP address to be associated with the interface
ippis the port number to be associated with the interface
rsis the rate spec for the interface (up corresponds to in)

Definition at line 31 of file IfaceTable.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

string & forest::IfaceTable::entry2string ( int  iface) const

Create a string representation of an entry.

Parameters
ifaceis the number of the interface to be written
Returns
the string
Parameters
ifaceis the number of the interface to be written
sis a reference to a string inwhich result is returned
Returns
a reference to s

Definition at line 108 of file IfaceTable.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int forest::IfaceTable::firstIface ( ) const
inline

Get the "first" interface number.

This method used to iterate through all the interfaces. The choice of which interface is first is arbitrary and programs should not rely on any particular iterface being the first.

Returns
the interface number of the first interface, or 0 if no interfaces have been defined for this router

Definition at line 88 of file IfaceTable.h.

Here is the caller graph for this function:

int forest::IfaceTable::getDefaultIface ( ) const
inline

Get the number of the default interface.

At the time the first interface is added, the default interface is initialized with the same interface number. The default interface can be changed using the setDefaultIface() method.

Returns
the interface number of the default interface, or 0 if there is no default interface

Definition at line 111 of file IfaceTable.h.

Here is the caller graph for this function:

IfaceTable::Entry & forest::IfaceTable::getEntry ( int  iface)
inline

Get a table entry.

Parameters
ifaceis a valid interface number
Returns
a reference to the interface table entry

Definition at line 127 of file IfaceTable.h.

Here is the caller graph for this function:

int forest::IfaceTable::getFreeIface ( ) const
inline

Get an an unused interface number.

Returns
the number of an interface that is not yet in use, or 0 if there are no available interface numbers

Definition at line 119 of file IfaceTable.h.

int forest::IfaceTable::nextIface ( int  iface) const
inline

Get the "next" interface number.

This method used to iterate through all the interfaces. The order of the interfaces is arbitrary and programs should not rely on any particular order.

Parameters
ifaceis a valid interface number
Returns
the next interface number following iface, or 0 if there is no next interface, or iface is not valid

Definition at line 100 of file IfaceTable.h.

Here is the caller graph for this function:

bool forest::IfaceTable::read ( istream &  in)

Read interface table entries from the input.

The first line must contain an integer, giving the number of entries to be read. The input may include blank lines and comment lines (any text starting with '#'). Each entry must be on a line by itself (possibly with a trailing comment). If the operation fails, a message is sent to cerr, identifying the interface that triggered the failure

Parameters
inis an open input stream
Returns
true on success, false on failure

Definition at line 89 of file IfaceTable.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

int forest::IfaceTable::readEntry ( istream &  in)
private

Read a table entry from an input stream and add it to the table.

The input stream is assumed to be positioned at the start of an interface table entry. An entry is consists of an interface number, an IP address followed by a colon and port number, a maximum bit rate (in Kb/s) and a maximum packet rate (in p/s). Each field is separated by one or more spaces. Comments in the input stream are ignored. A comment starts with a # sign and continues to the end of the line. Non-blank lines that do not start with a comment are expected to contain a complete entry. If the input is formatted incorrectly, or the interface number specified in the input is already in use, the operation will fail.

Parameters
inis an open input stream
Returns
the number of the new interface or 0, if the operation failed

Definition at line 65 of file IfaceTable.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void forest::IfaceTable::removeEntry ( int  iface)

Remove an interface from the table.

Parameters
ifaceis the number of the interface to be removed No action is taken if the specified interface number is not valid

Definition at line 46 of file IfaceTable.cpp.

void forest::IfaceTable::setDefaultIface ( int  iface)
inline

Set the default interface.

Parameters
ifaceis the number of a valid existing interface

Definition at line 139 of file IfaceTable.h.

string & forest::IfaceTable::toString ( ) const

Create a string representation of the interface table.

The output format matches the format expected by the read method.

Returns
the string

The output format matches the format expected by the read method.

Parameters
sis a reference to a string in which result is returned
Returns
a reference to s

Definition at line 120 of file IfaceTable.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool forest::IfaceTable::valid ( int  iface) const
inline

Check an interface number for validity.

Parameters
ifaceis the interface to be checked
Returns
true if iface is a valid interface number, else false

Definition at line 77 of file IfaceTable.h.

Here is the caller graph for this function:


The documentation for this class was generated from the following files: