xorp

ProtoNode< V > Class Template Reference

Base class for a protocol node. More...

#include <proto_node.hh>

Inheritance diagram for ProtoNode< V >:
ProtoUnit ProtoState ServiceBase BugCatcher

List of all members.

Public Member Functions

 ProtoNode (int init_family, xorp_module_id init_module_id, EventLoop &init_eventloop)
 Constructor for a given address family, module ID, and event loop.
virtual ~ProtoNode ()
 Destructor.
uint32_t vif_name2vif_index (const string &vif_name) const
 Map a vif name to a vif index.
uint32_t find_unused_vif_index () const
 Find an unused vif index.
V * vif_find_by_name (const string &name) const
 Find a virtual interface for a given name.
V * vif_find_by_addr (const IPvX &ipaddr_test) const
 Find a virtual interface for a given address.
V * vif_find_by_pif_index (uint32_t pif_index) const
 Find a virtual interface for a given physical interface index.
V * vif_find_by_vif_index (uint32_t vif_index) const
 Find a virtual interface for a given virtual interface index.
V * vif_find_same_subnet_or_p2p (const IPvX &ipaddr_test) const
 Find a virtual interface that belongs to the same subnet or point-to-point link as a given address.
bool is_my_addr (const IPvX &ipaddr_test) const
 Test if an address belongs to one of my virtual interfaces.
int add_vif (V *vif)
 Add a virtual interface.
int delete_vif (const V *vif)
 Delete a virtual interface.
vector< V * > & proto_vifs ()
 Get the array of pointers to the virtual interfaces.
const vector< V * > & const_proto_vifs () const
 Get the array of pointers to the virtual interfaces.
uint32_t maxvifs () const
 Get the maximum number of vifs.
EventLoopeventloop ()
 Get the event loop this node is added to.
virtual int proto_recv (const string &if_name, const string &vif_name, const IPvX &src_address, const IPvX &dst_address, uint8_t ip_protocol, int32_t ip_ttl, int32_t ip_tos, bool ip_router_alert, bool ip_internet_control, const vector< uint8_t > &payload, string &error_msg)=0
 Receive a protocol packet.
virtual int proto_send (const string &if_name, const string &vif_name, const IPvX &src_address, const IPvX &dst_address, uint8_t ip_protocol, int32_t ip_ttl, int32_t ip_tos, bool ip_router_alert, bool ip_internet_control, const uint8_t *sndbuf, size_t sndlen, string &error_msg)=0
 Send a protocol packet.
virtual int signal_message_recv (const string &src_module_instance_name, int message_type, uint32_t vif_index, const IPvX &src, const IPvX &dst, const uint8_t *rcvbuf, size_t rcvlen)=0
 Receive a signal message.
virtual int signal_message_send (const string &dst_module_instance_name, int message_type, uint32_t vif_index, const IPvX &src, const IPvX &dst, const uint8_t *sndbuf, size_t sndlen)=0
 Send a signal message.
bool is_done () const
 Test if the node processing is done.
ProcessStatus node_status () const
 Get the node status (see ProcessStatus).
void set_node_status (ProcessStatus v)
 Set the node status (see ProcessStatus).
int start_config (string &error_msg)
 Start a set of configuration changes.
int end_config (string &error_msg)
 End a set of configuration changes.
uint32_t find_unused_config_vif_index () const
 Find an unused vif index from the set of configured vifs.
int add_config_vif (const Vif &vif, string &error_msg)
 Add a configured vif.
int add_config_vif (const string &vif_name, uint32_t vif_index, string &error_msg)
 Add a configured vif.
int delete_config_vif (const string &vif_name, string &error_msg)
 Delete a configured vif.
int add_config_vif_addr (const string &vif_name, const IPvX &addr, const IPvXNet &subnet, const IPvX &broadcast, const IPvX &peer, string &error_msg)
 Add an address to a configured vif.
int delete_config_vif_addr (const string &vif_name, const IPvX &addr, string &error_msg)
 Delete an address from a configured vif.
int set_config_pif_index (const string &vif_name, uint32_t pif_index, string &error_msg)
 Set the pif_index of a configured vif.
int set_config_vif_flags (const string &vif_name, bool is_pim_register, bool is_p2p, bool is_loopback, bool is_multicast, bool is_broadcast, bool is_up, uint32_t mtu, string &error_msg)
 Set the vif flags of a configured vif.
map< string, Vif > & configured_vifs ()
 Get the map with configured vifs.
const Vifconfigured_vif_find_by_name (const string &name) const
 Find a configured virtual interface for a given name.
ProcessStatus node_status (string &reason_msg)
 Get the node status (see ProcessStatus).
void incr_startup_requests_n ()
 Increment the number of startup requests.
void decr_startup_requests_n ()
 Decrement the number of startup requests.
void incr_shutdown_requests_n ()
 Increment the number of shutdown requests.
void decr_shutdown_requests_n ()
 Decrement the number of shutdown requests.

Protected Member Functions

void update_status ()

Private Attributes

vector< V * > _proto_vifs
EventLoop_eventloop
map< string, uint32_t > _vif_name2vif_index_map
ProcessStatus _node_status
size_t _startup_requests_n
size_t _shutdown_requests_n
map< string, Vif_configured_vifs

Detailed Description

template<class V>
class ProtoNode< V >

Base class for a protocol node.


Constructor & Destructor Documentation

template<class V>
ProtoNode< V >::ProtoNode ( int  init_family,
xorp_module_id  init_module_id,
EventLoop init_eventloop 
) [inline]

Constructor for a given address family, module ID, and event loop.

Parameters:
init_familythe address family (AF_INET or AF_INET6 for IPv4 and IPv6 respectively).
init_module_idthe module ID XORP_MODULE_* (xorp_module_id).
init_eventloopthe event loop to use.

Member Function Documentation

template<class V >
int ProtoNode< V >::add_config_vif ( const Vif vif,
string &  error_msg 
) [inline]

Add a configured vif.

Parameters:
vifthe vif with the information to add.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.

Reimplemented in MfeaNode.

template<class V >
int ProtoNode< V >::add_config_vif ( const string &  vif_name,
uint32_t  vif_index,
string &  error_msg 
) [inline]

Add a configured vif.

Parameters:
vif_namethe name of the vif to add.
vif_indexthe vif index of the vif to add.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
template<class V >
int ProtoNode< V >::add_config_vif_addr ( const string &  vif_name,
const IPvX addr,
const IPvXNet subnet,
const IPvX broadcast,
const IPvX peer,
string &  error_msg 
) [inline]

Add an address to a configured vif.

Parameters:
vif_namethe name of the vif.
addrthe address to add.
subnetthe subnet address to add.
broadcastthe broadcast address to add.
peerthe peer address to add.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
template<class V>
int ProtoNode< V >::add_vif ( V *  vif) [inline]

Add a virtual interface.

Parameters:
vifa pointer to the virtual interface to add.
Returns:
XORP_OK on success, otherwise XORP_ERROR.
template<class V >
const Vif * ProtoNode< V >::configured_vif_find_by_name ( const string &  name) const [inline]

Find a configured virtual interface for a given name.

Parameters:
namethe name to search for.
Returns:
the virtual interface with name name if found, otherwise NULL.
template<class V>
map<string, Vif>& ProtoNode< V >::configured_vifs ( ) [inline]

Get the map with configured vifs.

Returns:
a reference for the map with configured vifs.
template<class V>
const vector<V *>& ProtoNode< V >::const_proto_vifs ( ) const [inline]

Get the array of pointers to the virtual interfaces.

Returns:
the array of pointers to the virtual interfaces.
template<class V >
int ProtoNode< V >::delete_config_vif ( const string &  vif_name,
string &  error_msg 
) [inline]

Delete a configured vif.

Parameters:
vif_namethe name of the vif to delete.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
template<class V >
int ProtoNode< V >::delete_config_vif_addr ( const string &  vif_name,
const IPvX addr,
string &  error_msg 
) [inline]

Delete an address from a configured vif.

Parameters:
vif_namethe name of the vif.
addrthe address to delete.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
template<class V>
int ProtoNode< V >::delete_vif ( const V *  vif) [inline]

Delete a virtual interface.

Note: the vif itself is not deleted, only its place in the array of protocol vifs.

Parameters:
vifa pointer to the virtual interface to delete.
Returns:
XORP_OK on success, otherwise XORP_ERROR.
template<class V >
int ProtoNode< V >::end_config ( string &  error_msg) [inline]

End a set of configuration changes.

Note that it may change the node status.

Parameters:
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
template<class V>
EventLoop& ProtoNode< V >::eventloop ( ) [inline]

Get the event loop this node is added to.

Returns:
the event loop this node is added to.
template<class V >
uint32_t ProtoNode< V >::find_unused_config_vif_index ( ) const [inline]

Find an unused vif index from the set of configured vifs.

Returns:
the smallest unused vif index from the set of configured vifs if there is one available, otherwise return Vif::VIF_INDEX_INVALID.
template<class V >
uint32_t ProtoNode< V >::find_unused_vif_index ( ) const [inline]

Find an unused vif index.

Returns:
the smallest unused vif index if there is one available, otherwise return Vif::VIF_INDEX_INVALID.
template<class V>
bool ProtoNode< V >::is_done ( ) const [inline]

Test if the node processing is done.

Returns:
true if the node processing is done, otherwise false.
template<class V>
bool ProtoNode< V >::is_my_addr ( const IPvX ipaddr_test) const [inline]

Test if an address belongs to one of my virtual interfaces.

Note that the PIM Register virtual interfaces are excluded, because they are special, and because they may share the same address as some of the other virtual interfaces.

Parameters:
ipaddr_testthe address to test.
Returns:
true if ipaddr_test belongs to one of my virtual interfaces, otherwise false.
template<class V>
uint32_t ProtoNode< V >::maxvifs ( ) const [inline]

Get the maximum number of vifs.

Note: the interfaces that are not configured or are down are also included.

Returns:
the maximum number of vifs we can have.
template<class V >
ProcessStatus ProtoNode< V >::node_status ( string &  reason_msg)

Get the node status (see ProcessStatus).

Parameters:
reason_msgreturn-by-reference string that contains human-readable information about the status.
Returns:
the node status (see ProcessStatus).
template<class V>
ProcessStatus ProtoNode< V >::node_status ( ) const [inline]

Get the node status (see ProcessStatus).

Returns:
the node status (see ProcessStatus).
template<class V>
virtual int ProtoNode< V >::proto_recv ( const string &  if_name,
const string &  vif_name,
const IPvX src_address,
const IPvX dst_address,
uint8_t  ip_protocol,
int32_t  ip_ttl,
int32_t  ip_tos,
bool  ip_router_alert,
bool  ip_internet_control,
const vector< uint8_t > &  payload,
string &  error_msg 
) [pure virtual]

Receive a protocol packet.

This is a pure virtual function, and it must be implemented by the particular protocol node class that inherits this base class.

Parameters:
if_namethe interface name the packet arrived on.
vif_namethe vif name the packet arrived on.
src_addressthe IP source address.
dst_addressthe IP destination address.
ip_protocolthe IP protocol number.
ip_ttlthe IP TTL (hop-limit). If it has a negative value, then the received value is unknown.
ip_tosthe Type of Service (Diffserv/ECN bits for IPv4). If it has a negative value, then the received value is unknown.
ip_router_alertif true, the IP Router Alert option was included in the IP packet.
ip_internet_controlif true, then this is IP control traffic.
payloadthe payload, everything after the IP header and options.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.

Implemented in CliNode, Mld6igmpNode, MfeaNode, Mld6igmpNode, and PimNode.

template<class V>
virtual int ProtoNode< V >::proto_send ( const string &  if_name,
const string &  vif_name,
const IPvX src_address,
const IPvX dst_address,
uint8_t  ip_protocol,
int32_t  ip_ttl,
int32_t  ip_tos,
bool  ip_router_alert,
bool  ip_internet_control,
const uint8_t *  sndbuf,
size_t  sndlen,
string &  error_msg 
) [pure virtual]

Send a protocol packet.

This is a pure virtual function, and it must be implemented by the particular protocol node class that inherits this base class.

Parameters:
if_namethe interface to send the packet on. It is essential for multicast. In the unicast case this field may be empty.
vif_namethe vif to send the packet on. It is essential for multicast. In the unicast case this field may be empty.
src_addressthe IP source address.
dst_addressthe IP destination address.
ip_protocolthe IP protocol number. It must be between 1 and 255.
ip_ttlthe IP TTL (hop-limit). If it has a negative value, the TTL will be set internally before transmission.
ip_tosthe Type Of Service (Diffserv/ECN bits for IPv4). If it has a negative value, the TOS will be set internally before transmission.
ip_router_alertif true, then add the IP Router Alert option to the IP packet.
ip_internet_controlif true, then this is IP control traffic.
sndbufthe data buffer with the outgoing packet.
sndlenthe data length in sndbuf.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.

Implemented in CliNode, XrlMld6igmpNode, MfeaNode, XrlMld6igmpNode, and XrlPimNode.

template<class V>
vector<V *>& ProtoNode< V >::proto_vifs ( ) [inline]

Get the array of pointers to the virtual interfaces.

Returns:
the array of pointers to the virtual interfaces.
template<class V >
int ProtoNode< V >::set_config_pif_index ( const string &  vif_name,
uint32_t  pif_index,
string &  error_msg 
) [inline]

Set the pif_index of a configured vif.

Parameters:
vif_namethe name of the vif.
pif_indexthe physical interface index.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
template<class V >
int ProtoNode< V >::set_config_vif_flags ( const string &  vif_name,
bool  is_pim_register,
bool  is_p2p,
bool  is_loopback,
bool  is_multicast,
bool  is_broadcast,
bool  is_up,
uint32_t  mtu,
string &  error_msg 
) [inline]

Set the vif flags of a configured vif.

Parameters:
vif_namethe name of the vif.
is_pim_registertrue if the vif is a PIM Register interface.
is_p2ptrue if the vif is point-to-point interface.
is_loopbacktrue if the vif is a loopback interface.
is_multicasttrue if the vif is multicast capable.
is_broadcasttrue if the vif is broadcast capable.
is_uptrue if the underlying vif is UP.
mtuthe MTU of the vif.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.

Reimplemented in MfeaNode.

template<class V>
void ProtoNode< V >::set_node_status ( ProcessStatus  v) [inline]

Set the node status (see ProcessStatus).

Parameters:
vthe value to set the node status to.
template<class V>
virtual int ProtoNode< V >::signal_message_recv ( const string &  src_module_instance_name,
int  message_type,
uint32_t  vif_index,
const IPvX src,
const IPvX dst,
const uint8_t *  rcvbuf,
size_t  rcvlen 
) [pure virtual]

Receive a signal message.

This is a pure virtual function, and it must be implemented by the particular protocol node class that inherits this base class.

Parameters:
src_module_instance_namethe module instance name of the module-origin of the message.
message_typethe message type. The particular values are specific for the origin and recepient of this signal message.
vif_indexthe vif index of the related interface (message-specific relation).
srcthe source address of the message. The exact meaning of this address is message-specific.
dstthe destination address of the message. The exact meaning of this address is message-specific.
rcvbufthe data buffer with the additional information in the message.
rcvlenthe data length in rcvbuf.
Returns:
XORP_OK on success, otherwise XORP_ERROR.

Implemented in CliNode, Mld6igmpNode, MfeaNode, Mld6igmpNode, and PimNode.

template<class V>
virtual int ProtoNode< V >::signal_message_send ( const string &  dst_module_instance_name,
int  message_type,
uint32_t  vif_index,
const IPvX src,
const IPvX dst,
const uint8_t *  sndbuf,
size_t  sndlen 
) [pure virtual]

Send a signal message.

This is a pure virtual function, and it must be implemented by the particular protocol node class that inherits this base class.

Parameters:
dst_module_instance_namethe module instance name of the module-recepient of the message.
message_typethe message type. The particular values are specific for the origin and recepient of this signal message.
vif_indexthe vif index of the related interface (message-specific relation).
srcthe source address of the message. The exact meaning of this address is message-specific.
dstthe destination address of the message. The exact meaning of this address is message-specific.
sndbufthe data buffer with the outgoing message.
sndlenthe data length in sndbuf.
Returns:
XORP_OK on success, otherwise XORP_ERROR.

Implemented in CliNode, Mld6igmpNode, XrlMfeaNode, Mld6igmpNode, and PimNode.

template<class V >
int ProtoNode< V >::start_config ( string &  error_msg) [inline]

Start a set of configuration changes.

Note that it may change the node status.

Parameters:
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
template<class V >
V * ProtoNode< V >::vif_find_by_addr ( const IPvX ipaddr_test) const [inline]

Find a virtual interface for a given address.

Note that the PIM Register virtual interfaces are excluded, because they are special, and because they may share the same address as some of the other virtual interfaces.

Parameters:
ipaddr_testthe address to search for.
Returns:
the virtual interface with address ipaddr_test if found, otherwise NULL.
template<class V >
V * ProtoNode< V >::vif_find_by_name ( const string &  name) const [inline]

Find a virtual interface for a given name.

Parameters:
namethe name to search for.
Returns:
the virtual interface with name name if found, otherwise NULL.
template<class V >
V * ProtoNode< V >::vif_find_by_pif_index ( uint32_t  pif_index) const [inline]

Find a virtual interface for a given physical interface index.

Parameters:
pif_indexthe physical interface index to search for.
Returns:
the virtual interface with physical interface index pif_index if found, otherwise NULL.
template<class V >
V * ProtoNode< V >::vif_find_by_vif_index ( uint32_t  vif_index) const [inline]

Find a virtual interface for a given virtual interface index.

Parameters:
vif_indexthe virtual interface index to search for.
Returns:
the vvirtual interface with virtual interface index vif_index if found, otherwise NULL.
template<class V >
V * ProtoNode< V >::vif_find_same_subnet_or_p2p ( const IPvX ipaddr_test) const [inline]

Find a virtual interface that belongs to the same subnet or point-to-point link as a given address.

Note that the PIM Register virtual interfaces are excluded, because they are special, and because they may share the same address as some of the other virtual interfaces.

Parameters:
ipaddr_testthe address to search by.
Returns:
the virtual interface that belongs to the same subnet or point-to-point link as address ipaddr_test if found, otherwise NULL.
template<class V >
uint32_t ProtoNode< V >::vif_name2vif_index ( const string &  vif_name) const [inline]

Map a vif name to a vif index.

Parameters:
vif_namethe vif name to map to a vif index.
Returns:
the virtual interface index for vif name vif_name.

The documentation for this class was generated from the following file:
 All Classes Namespaces Functions Variables Typedefs Enumerations