MKCommModel
Classes | Public Member Functions | Protected Attributes | Friends
MKNode Class Reference

Represents a node in the MESH. More...

#include <MKNode.h>

List of all members.

Classes

struct  MKNeighbor
struct  MKRoute

Public Member Functions

 MKNode (mac_t mac_addr, ip4_t ip_addr)
 Constructs a new MKNode with with a mac address and ip address.
 operator std::string () const
 Returns a string containing the mac address and ip address of this node.
node * asCommNode () const
 Returns a new node that represents this node.
void addNeighbor (const MKNode *node, NeighborInfo *link)
 Adds a neighbor node along with the link info between this node and the neighbor node.
MKNeighbornbr (mac_t target)
 get neighbor information
MKRouteroute (mac_t target)
 Get route information.
MKRouteaddRoute (MKNode *target)
 add a new route
void clearRoutes ()
 Clears the route cache.
void clearNeighbors ()
 Clears this node's neighbors.
ip4_t getIP4 () const
 Returns this node's IP address.
mac_t getMAC () const
std::vector< const MKNode * > getNeighbors () const
 Returns a copy of this node's list of neighbors.
void setIP (ip4_t ip)
 Sets this node's ip address.

Protected Attributes

const mac_t mac
ip4_t ip4
std::map< MacAddr, MKNeighbor * > neighbors
std::map< MacAddr, MKRoute * > routes

Friends

class MKNodeTests

Detailed Description

Represents a node in the MESH.


Constructor & Destructor Documentation

MKNode::MKNode ( mac_t  mac_addr,
ip4_t  ip_addr 
)

Constructs a new MKNode with with a mac address and ip address.

Parameters:
mac_addrThe mac address for this node.
ip_addrThe ip address for this node.
Precondition:
mac_addr must not be NULL.
ip_addr must not be NULL.

Member Function Documentation

void MKNode::addNeighbor ( const MKNode node,
NeighborInfo link 
)

Adds a neighbor node along with the link info between this node and the neighbor node.

The link info represents this node's connection with the neighbor node.

Parameters:
nodeThe neighbor node to add.
linkThe link info between this node and the neighbor nodde.
Precondition:
node is not null and has Mac + IP set.
link must not be NULL.
node * MKNode::asCommNode ( ) const

Returns a new node that represents this node.

A new node will be allocated; it is the caller's responsibility to free this memory.

Returns:
A new node that represents this node.
ip4_t MKNode::getIP4 ( ) const [inline]

Returns this node's IP address.

Returns:
This node's IP address.
vector< const MKNode * > MKNode::getNeighbors ( ) const

Returns a copy of this node's list of neighbors.

The nodes shall be ordered in the returned vector in the same order that they where added.

Returns:
n copy of this node's list of neighbors.
MKNode::operator std::string ( ) const

Returns a string containing the mac address and ip address of this node.

Returns:
A string of the form "[MKNode $mac @ $ip4]" where $mac is the mac address and $ip4 is the ip4 address.
void MKNode::setIP ( ip4_t  ip) [inline]

Sets this node's ip address.

Parameters:
ipThe new ip address for this node.
Precondition:
ip must be > 0.

Member Data Documentation

ip4_t MKNode::ip4 [protected]

This node's ip address

const mac_t MKNode::mac [protected]

This node's mac address.

std::map<MacAddr, MKNeighbor *> MKNode::neighbors [protected]

This node's list of neighbors

std::map<MacAddr, MKRoute *> MKNode::routes [protected]

Known route information


The documentation for this class was generated from the following files:
 All Classes Functions Variables