xorp

StaticRoutesNode Class Reference

The StaticRoutes node class. More...

#include <static_routes_node.hh>

Inheritance diagram for StaticRoutesNode:
IfMgrHintObserver ServiceBase ServiceChangeObserverBase BugCatcher XrlStaticRoutesNode

List of all members.

Public Types

typedef multimap< IPvXNet,
StaticRoute
Table

Public Member Functions

 StaticRoutesNode (EventLoop &eventloop)
 Constructor for a given event loop.
virtual ~StaticRoutesNode ()
 Destructor.
EventLoopeventloop ()
 Get the event loop this node is added to.
const string & protocol_name () const
 Get the protocol name.
int startup ()
 Startup the node operation.
int shutdown ()
 Shutdown the node operation.
ProcessStatus node_status (string &reason_msg)
 Get the node status (see ProcessStatus).
bool is_done () const
 Test if the node processing is done.
bool is_enabled () const
 Test whether the node operation is enabled.
void set_enabled (bool enable)
 Enable/disable node operation.
int add_route4 (bool unicast, bool multicast, const IPv4Net &network, const IPv4 &nexthop, const string &ifname, const string &vifname, uint32_t metric, bool is_backup_route, string &error_msg)
 Add a static IPv4 route.
int add_route6 (bool unicast, bool multicast, const IPv6Net &network, const IPv6 &nexthop, const string &ifname, const string &vifname, uint32_t metric, bool is_backup_route, string &error_msg)
 Add a static IPv6 route.
int replace_route4 (bool unicast, bool multicast, const IPv4Net &network, const IPv4 &nexthop, const string &ifname, const string &vifname, uint32_t metric, bool is_backup_route, string &error_msg)
 Replace a static IPv4 route.
int replace_route6 (bool unicast, bool multicast, const IPv6Net &network, const IPv6 &nexthop, const string &ifname, const string &vifname, uint32_t metric, bool is_backup_route, string &error_msg)
 Replace a static IPv6 route.
int delete_route4 (bool unicast, bool multicast, const IPv4Net &network, const IPv4 &nexthop, const string &ifname, const string &vifname, bool is_backup_route, string &error_msg)
 Delete a static IPv4 route.
int delete_route6 (bool unicast, bool multicast, const IPv6Net &network, const IPv6 &nexthop, const string &ifname, const string &vifname, bool is_backup_route, string &error_msg)
 Delete a static IPv6 route.
StaticRoutesNode::Table::iterator find_route (StaticRoutesNode::Table &table, const StaticRoute &key_route)
 Find a route from the routing table.
StaticRoutesNode::Table::iterator find_best_accepted_route (StaticRoutesNode::Table &table, const StaticRoute &key_route)
 Find the best accepted route from the routing table.
bool is_log_trace () const
 Test if trace log is enabled.
void set_log_trace (bool is_enabled)
 Enable/disable trace log.
void configure_filter (const uint32_t &filter, const string &conf)
 Configure a policy filter.
void reset_filter (const uint32_t &filter)
 Reset a policy filter.
void push_routes ()
 Push all the routes through the policy filters for re-filtering.
void push_pull_rib_routes (bool is_push)
 Push or pull all the routes to/from the RIB.

Protected Member Functions

void tree_complete ()
void updates_made ()
void incr_startup_requests_n ()
void decr_startup_requests_n ()
void incr_shutdown_requests_n ()
void decr_shutdown_requests_n ()
void update_status ()

Private Member Functions

void status_change (ServiceBase *service, ServiceStatus old_status, ServiceStatus new_status)
 A method invoked when the status of a service changes.
virtual const ServiceBaseifmgr_mirror_service_base () const =0
 Get a reference to the service base of the interface manager.
virtual const IfMgrIfTreeifmgr_iftree () const =0
 Get a reference to the interface manager tree.
virtual void fea_register_startup ()=0
 Initiate registration with the FEA.
virtual void fea_register_shutdown ()=0
 Initiate de-registration with the FEA.
virtual void rib_register_startup ()=0
 Initiate registration with the RIB.
virtual void rib_register_shutdown ()=0
 Initiate de-registration with the RIB.
int add_route (const StaticRoute &static_route, string &error_msg)
 Add a static IPvX route.
int replace_route (const StaticRoute &static_route, string &error_msg)
 Replace a static IPvX route.
int delete_route (const StaticRoute &static_route, string &error_msg)
 Delete a static IPvX route.
void prepare_route_for_transmission (StaticRoute &orig_route, StaticRoute &copy_route)
 Prepare a copy of a route for transmission to the RIB.
virtual void inform_rib_route_change (const StaticRoute &static_route)=0
 Inform the RIB about a route change.
virtual void cancel_rib_route_change (const StaticRoute &static_route)=0
 Cancel a pending request to inform the RIB about a route change.
bool update_route (const IfMgrIfTree &iftree, StaticRoute &route)
 Update a route received from the user configuration.
bool do_filtering (StaticRoute &route)
 Do policy filtering on a route.
bool is_accepted_by_nexthop (const StaticRoute &route) const
 Test whether a route is accepted based on its next-hop information.
void inform_rib (const StaticRoute &r)
 Inform the RIB about a route.
void set_node_status (ProcessStatus v)
 Set the node status.

Private Attributes

EventLoop_eventloop
ProcessStatus _node_status
const string _protocol_name
bool _is_enabled
StaticRoutesNode::Table _static_routes
map< IPvXNet, StaticRoute_winning_routes_unicast
map< IPvXNet, StaticRoute_winning_routes_multicast
size_t _startup_requests_n
size_t _shutdown_requests_n
IfMgrIfTree _iftree
bool _is_log_trace
PolicyFilters _policy_filters

Detailed Description

The StaticRoutes node class.

There should be one node per StaticRoutes instance.


Constructor & Destructor Documentation

StaticRoutesNode::StaticRoutesNode ( EventLoop eventloop)

Constructor for a given event loop.

Parameters:
eventloopthe event loop to use.

Member Function Documentation

int StaticRoutesNode::add_route ( const StaticRoute static_route,
string &  error_msg 
) [private]

Add a static IPvX route.

Parameters:
static_routethe route to add.
See also:
StaticRoute
Parameters:
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int StaticRoutesNode::add_route4 ( bool  unicast,
bool  multicast,
const IPv4Net network,
const IPv4 nexthop,
const string &  ifname,
const string &  vifname,
uint32_t  metric,
bool  is_backup_route,
string &  error_msg 
)

Add a static IPv4 route.

Parameters:
unicastif true, then the route would be used for unicast routing.
multicastif true, then the route would be used in the MRIB (Multicast Routing Information Base) for multicast purpose (e.g., computing the Reverse-Path Forwarding information).
networkthe network address prefix this route applies to.
nexthopthe address of the next-hop router for this route.
ifnameof the name of the physical interface toward the destination.
vifnameof the name of the virtual interface toward the destination.
metricthe metric distance for this route.
is_backup_routeif true, then this is a backup route operation.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int StaticRoutesNode::add_route6 ( bool  unicast,
bool  multicast,
const IPv6Net network,
const IPv6 nexthop,
const string &  ifname,
const string &  vifname,
uint32_t  metric,
bool  is_backup_route,
string &  error_msg 
)

Add a static IPv6 route.

Parameters:
unicastif true, then the route would be used for unicast routing.
multicastif true, then the route would be used in the MRIB (Multicast Routing Information Base) for multicast purpose (e.g., computing the Reverse-Path Forwarding information).
networkthe network address prefix this route applies to.
nexthopthe address of the next-hop router for this route.
ifnameof the name of the physical interface toward the destination.
vifnameof the name of the virtual interface toward the destination.
metricthe metric distance for this route.
is_backup_routeif true, then this is a backup route operation.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
virtual void StaticRoutesNode::cancel_rib_route_change ( const StaticRoute static_route) [private, pure virtual]

Cancel a pending request to inform the RIB about a route change.

This is a pure virtual function, and it must be implemented by the communication-wrapper class that inherits this base class.

Parameters:
static_routethe route with the request that would be canceled.

Implemented in XrlStaticRoutesNode.

void StaticRoutesNode::configure_filter ( const uint32_t &  filter,
const string &  conf 
)

Configure a policy filter.

Will throw an exception on error.

Export filter is not supported by static routes.

Parameters:
filteridentifier of filter to configure.
confconfiguration of the filter.
int StaticRoutesNode::delete_route ( const StaticRoute static_route,
string &  error_msg 
) [private]

Delete a static IPvX route.

Parameters:
static_routethe route to delete.
See also:
StaticRoute
Parameters:
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int StaticRoutesNode::delete_route4 ( bool  unicast,
bool  multicast,
const IPv4Net network,
const IPv4 nexthop,
const string &  ifname,
const string &  vifname,
bool  is_backup_route,
string &  error_msg 
)

Delete a static IPv4 route.

Parameters:
unicastif true, then the route would be used for unicast routing.
multicastif true, then the route would be used in the MRIB (Multicast Routing Information Base) for multicast purpose (e.g., computing the Reverse-Path Forwarding information).
networkthe network address prefix this route applies to.
nexthopthe address of the next-hop router for this route.
ifnameof the name of the physical interface toward the destination.
vifnameof the name of the virtual interface toward the destination.
is_backup_routeif true, then this is a backup route operation.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int StaticRoutesNode::delete_route6 ( bool  unicast,
bool  multicast,
const IPv6Net network,
const IPv6 nexthop,
const string &  ifname,
const string &  vifname,
bool  is_backup_route,
string &  error_msg 
)

Delete a static IPv6 route.

Parameters:
unicastif true, then the route would be used for unicast routing.
multicastif true, then the route would be used in the MRIB (Multicast Routing Information Base) for multicast purpose (e.g., computing the Reverse-Path Forwarding information).
networkthe network address prefix this route applies to.
nexthopthe address of the next-hop router for this route.
ifnameof the name of the physical interface toward the destination.
vifnameof the name of the virtual interface toward the destination.
is_backup_routeif true, then this is a backup route operation.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
bool StaticRoutesNode::do_filtering ( StaticRoute route) [private]

Do policy filtering on a route.

Parameters:
routeroute to filter.
Returns:
true if route was accepted by policy filter, otherwise false.
EventLoop& StaticRoutesNode::eventloop ( ) [inline]

Get the event loop this node is added to.

Returns:
the event loop this node is added to.
virtual void StaticRoutesNode::fea_register_shutdown ( ) [private, pure virtual]

Initiate de-registration with the FEA.

This is a pure virtual function, and it must be implemented by the communication-wrapper class that inherits this base class.

Implemented in XrlStaticRoutesNode.

virtual void StaticRoutesNode::fea_register_startup ( ) [private, pure virtual]

Initiate registration with the FEA.

This is a pure virtual function, and it must be implemented by the communication-wrapper class that inherits this base class.

Implemented in XrlStaticRoutesNode.

StaticRoutesNode::Table::iterator StaticRoutesNode::find_best_accepted_route ( StaticRoutesNode::Table &  table,
const StaticRoute key_route 
)

Find the best accepted route from the routing table.

Parameters:
tablethe routing table to seach.
key_routethe route information to search for.
Returns:
a table iterator to the route. If the route is not found, the iterator will point to the end of the table.
StaticRoutesNode::Table::iterator StaticRoutesNode::find_route ( StaticRoutesNode::Table &  table,
const StaticRoute key_route 
)

Find a route from the routing table.

Parameters:
tablethe routing table to seach.
key_routethe route information to search for.
Returns:
a table iterator to the route. If the route is not found, the iterator will point to the end of the table.
virtual const IfMgrIfTree& StaticRoutesNode::ifmgr_iftree ( ) const [private, pure virtual]

Get a reference to the interface manager tree.

This is a pure virtual function, and it must be implemented by the communication-wrapper class that inherits this base class.

Returns:
a reference to the interface manager tree.

Implemented in XrlStaticRoutesNode.

virtual const ServiceBase* StaticRoutesNode::ifmgr_mirror_service_base ( ) const [private, pure virtual]

Get a reference to the service base of the interface manager.

This is a pure virtual function, and it must be implemented by the communication-wrapper class that inherits this base class.

Returns:
a reference to the service base of the interface manager.

Implemented in XrlStaticRoutesNode.

void StaticRoutesNode::inform_rib ( const StaticRoute r) [private]

Inform the RIB about a route.

Parameters:
rroute which should be updated in the RIB.
virtual void StaticRoutesNode::inform_rib_route_change ( const StaticRoute static_route) [private, pure virtual]

Inform the RIB about a route change.

This is a pure virtual function, and it must be implemented by the communication-wrapper class that inherits this base class.

Parameters:
static_routethe route with the information about the change.

Implemented in XrlStaticRoutesNode.

bool StaticRoutesNode::is_accepted_by_nexthop ( const StaticRoute route) const [private]

Test whether a route is accepted based on its next-hop information.

Parameters:
routethe route to test.
Returns:
true if the route is accepted based on its next-hop information, otherwise false.
bool StaticRoutesNode::is_done ( ) const [inline]

Test if the node processing is done.

Returns:
true if the node processing is done, otherwise false.
bool StaticRoutesNode::is_enabled ( ) const [inline]

Test whether the node operation is enabled.

Returns:
true if the node operation is enabled, otherwise false.
bool StaticRoutesNode::is_log_trace ( ) const [inline]

Test if trace log is enabled.

This method is used to test whether to output trace log debug messges.

Returns:
true if trace log is enabled, otherwise false.
ProcessStatus StaticRoutesNode::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).
void StaticRoutesNode::prepare_route_for_transmission ( StaticRoute orig_route,
StaticRoute copy_route 
) [private]

Prepare a copy of a route for transmission to the RIB.

Note that the original route will be modified as appropriate.

Parameters:
orig_routethe original route to prepare.
copy_routethe copy of the original route prepared for transmission to the RIB.
const string& StaticRoutesNode::protocol_name ( ) const [inline]

Get the protocol name.

Returns:
a string with the protocol name.
void StaticRoutesNode::push_pull_rib_routes ( bool  is_push)

Push or pull all the routes to/from the RIB.

Parameters:
is_pushif true, then push the routes, otherwise pull them
int StaticRoutesNode::replace_route ( const StaticRoute static_route,
string &  error_msg 
) [private]

Replace a static IPvX route.

Parameters:
static_routethe replacement route.
See also:
StaticRoute
Parameters:
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int StaticRoutesNode::replace_route4 ( bool  unicast,
bool  multicast,
const IPv4Net network,
const IPv4 nexthop,
const string &  ifname,
const string &  vifname,
uint32_t  metric,
bool  is_backup_route,
string &  error_msg 
)

Replace a static IPv4 route.

Parameters:
unicastif true, then the route would be used for unicast routing.
multicastif true, then the route would be used in the MRIB (Multicast Routing Information Base) for multicast purpose (e.g., computing the Reverse-Path Forwarding information).
networkthe network address prefix this route applies to.
nexthopthe address of the next-hop router for this route.
ifnameof the name of the physical interface toward the destination.
vifnameof the name of the virtual interface toward the destination.
metricthe metric distance for this route.
is_backup_routeif true, then this is a backup route operation.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
int StaticRoutesNode::replace_route6 ( bool  unicast,
bool  multicast,
const IPv6Net network,
const IPv6 nexthop,
const string &  ifname,
const string &  vifname,
uint32_t  metric,
bool  is_backup_route,
string &  error_msg 
)

Replace a static IPv6 route.

Parameters:
unicastif true, then the route would be used for unicast routing.
multicastif true, then the route would be used in the MRIB (Multicast Routing Information Base) for multicast purpose (e.g., computing the Reverse-Path Forwarding information).
networkthe network address prefix this route applies to.
nexthopthe address of the next-hop router for this route.
ifnameof the name of the physical interface toward the destination.
vifnameof the name of the virtual interface toward the destination.
metricthe metric distance for this route.
is_backup_routeif true, then this is a backup route operation.
error_msgthe error message (if error).
Returns:
XORP_OK on success, otherwise XORP_ERROR.
void StaticRoutesNode::reset_filter ( const uint32_t &  filter)

Reset a policy filter.

Parameters:
filteridentifier of filter to reset.
virtual void StaticRoutesNode::rib_register_shutdown ( ) [private, pure virtual]

Initiate de-registration with the RIB.

This is a pure virtual function, and it must be implemented by the communication-wrapper class that inherits this base class.

Implemented in XrlStaticRoutesNode.

virtual void StaticRoutesNode::rib_register_startup ( ) [private, pure virtual]

Initiate registration with the RIB.

This is a pure virtual function, and it must be implemented by the communication-wrapper class that inherits this base class.

Implemented in XrlStaticRoutesNode.

void StaticRoutesNode::set_enabled ( bool  enable)

Enable/disable node operation.

Note that for the time being it affects only whether the routes are installed into RIB. In the future it may affect the interaction with other modules as well.

Parameters:
enableif true then enable node operation, otherwise disable it.
void StaticRoutesNode::set_log_trace ( bool  is_enabled) [inline]

Enable/disable trace log.

This method is used to enable/disable trace log debug messages output.

Parameters:
is_enabledif true, trace log is enabled, otherwise is disabled.
void StaticRoutesNode::set_node_status ( ProcessStatus  v) [inline, private]

Set the node status.

Parameters:
vthe new node status.
int StaticRoutesNode::shutdown ( ) [virtual]

Shutdown the node operation.

Returns:
XORP_OK on success, otherwise XORP_ERROR.

Implements ServiceBase.

Reimplemented in XrlStaticRoutesNode.

int StaticRoutesNode::startup ( ) [virtual]

Startup the node operation.

Returns:
XORP_OK on success, otherwise XORP_ERROR.

Implements ServiceBase.

Reimplemented in XrlStaticRoutesNode.

void StaticRoutesNode::status_change ( ServiceBase service,
ServiceStatus  old_status,
ServiceStatus  new_status 
) [private, virtual]

A method invoked when the status of a service changes.

Parameters:
servicethe service whose status has changed.
old_statusthe old status.
new_statusthe new status.

Implements ServiceChangeObserverBase.

bool StaticRoutesNode::update_route ( const IfMgrIfTree iftree,
StaticRoute route 
) [private]

Update a route received from the user configuration.

Currently, this method is a no-op.

Parameters:
iftreethe tree with the interface state to update the route.
routethe route to update.
Returns:
true if the route was updated, otherwise false.

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