xorp

XrlIO< A > Class Template Reference

Concrete implementation of IO using XRLs. More...

#include <xrl_io.hh>

Inheritance diagram for XrlIO< A >:
IO< A > IfMgrHintObserver ServiceChangeObserverBase IO< A > IfMgrHintObserver ServiceChangeObserverBase ServiceBase ServiceBase ServiceBase ServiceBase BugCatcher BugCatcher BugCatcher BugCatcher

List of all members.

Public Member Functions

 XrlIO (EventLoop &eventloop, XrlRouter &xrl_router, const string &feaname, const string &ribname)
 Construct an XrlIO instance.
 ~XrlIO ()
 Destroy an XrlIO instance.
int startup ()
 Startup operation.
int shutdown ()
 Shutdown operation.
void component_up (string name)
 Called when internal subsystem comes up.
void component_down (string name)
 Called when internal subsystem goes down.
void receive (const string &sockid, const string &interface, const string &vif, const IPv4 &src, const uint16_t &sport, const vector< uint8_t > &payload)
 Receive UDP datagrams.
bool send (const string &interface, const string &vif, const IPv4 &src, const uint16_t &sport, const IPv4 &dst, const uint16_t &dport, uint8_t *data, const uint32_t &len)
 Send a UDP datagram on a specific link.
bool enable_interface_vif (const string &interface, const string &vif)
 Enable the interface/vif to receive frames.
bool disable_interface_vif (const string &interface, const string &vif)
 Disable this interface/vif from receiving frames.
bool enable_address (const string &interface, const string &vif, const IPv4 &address, const uint16_t &port, const IPv4 &all_nodes_address)
 Enable an IPv4 address and port for OLSR datagram reception and transmission.
bool disable_address (const string &interface, const string &vif, const IPv4 &address, const uint16_t &port)
 Disable an IPv4 address and port for OLSR datagram reception.
bool is_interface_enabled (const string &interface) const
 Test whether an interface is enabled.
bool is_vif_enabled (const string &interface, const string &vif) const
 Test whether an interface/vif is enabled.
bool is_vif_broadcast_capable (const string &interface, const string &vif)
 Test whether this interface/vif is broadcast capable.
bool is_vif_multicast_capable (const string &interface, const string &vif)
 Test whether this interface/vif is multicast capable.
bool is_vif_loopback (const string &interface, const string &vif)
 Return true if the given vif is a loopback vif.
bool is_address_enabled (const string &interface, const string &vif, const IPv4 &address) const
 Test whether an interface/vif/address is enabled.
bool get_addresses (const string &interface, const string &vif, list< IPv4 > &addresses) const
 Get all addresses associated with this interface/vif.
bool get_broadcast_address (const string &interface, const string &vif, IPv4 &address) const
 Get the broadcast address associated with this vif.
bool get_broadcast_address (const string &interface, const string &vif, const IPv4 &address, IPv4 &bcast_address) const
 Get the broadcast address associated with this IPv4 address.
bool get_interface_id (const string &interface, uint32_t &interface_id)
 Get the interface ID.
uint32_t get_prefix_length (const string &interface, const string &vif, IPv4 address)
 Obtain the subnet prefix length for an interface/vif/address.
uint32_t get_mtu (const string &interface)
 Obtain the MTU for an interface.
void register_rib ()
 Register with the RIB.
void unregister_rib ()
 Remove registration from the RIB.
void rib_command_done (const XrlError &error, bool up, const char *comment)
 Callback method to: signal that an XRL command which has been sent to the RIB has returned.
bool add_route (IPv4Net net, IPv4 nexthop, uint32_t nexthop_id, uint32_t metric, const PolicyTags &policytags)
 Add route to RIB.
bool replace_route (IPv4Net net, IPv4 nexthop, uint32_t nexthop_id, uint32_t metric, const PolicyTags &policytags)
 Replace route in RIB.
bool delete_route (IPv4Net net)
 Delete route from RIB.
 XrlIO (EventLoop &eventloop, XrlRouter &xrl_router, const string &feaname, const string &ribname)
int startup ()
 Startup operation.
int shutdown ()
 Shutdown operation.
void component_up (string)
 Called when internal subsystem comes up.
void component_down (string)
 Called when internal subsystem goes down.
void recv (const string &interface, const string &vif, A src, A dst, 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)
 Receiver Raw frames.
bool send (const string &interface, const string &vif, A dst, A src, int ttl, uint8_t *data, uint32_t len)
 Send Raw frames.
bool enable_interface_vif (const string &interface, const string &vif)
 Enable the interface/vif to receive frames.
bool disable_interface_vif (const string &interface, const string &vif)
 Disable this interface/vif from receiving frames.
bool is_interface_enabled (const string &interface) const
 Test whether an interface is enabled.
bool is_vif_enabled (const string &interface, const string &vif) const
 Test whether an interface/vif is enabled.
bool is_address_enabled (const string &interface, const string &vif, const A &address) const
 Test whether an interface/vif/address is enabled.
bool get_addresses (const string &interface, const string &vif, list< A > &addresses) const
 Get all addresses associated with this interface/vif.
bool get_link_local_address (const string &interface, const string &vif, A &address)
 Get a link local address for this interface/vif if available.
bool get_interface_id (const string &interface, uint32_t &interface_id)
 Get the interface ID.
uint32_t get_prefix_length (const string &interface, const string &vif, A address)
 Obtain the subnet prefix length for an interface/vif/address.
uint32_t get_mtu (const string &interface)
 Obtain the MTU for an interface.
bool join_multicast_group (const string &interface, const string &vif, A mcast)
 On the interface/vif join this multicast group.
bool leave_multicast_group (const string &interface, const string &vif, A mcast)
 On the interface/vif leave this multicast group.
void register_rib ()
 Register with the RIB.
void unregister_rib ()
 Remove registration from the RIB.
void rib_command_done (const XrlError &error, bool up, const char *comment)
bool add_route (IPNet< A > net, A nexthop, uint32_t nexthop_id, uint32_t metric, bool equal, bool discard, const PolicyTags &policytags)
 Add route to RIB.
bool replace_route (IPNet< A > net, A nexthop, uint32_t nexthop_id, uint32_t metric, bool equal, bool discard, const PolicyTags &policytags)
 Replace route in RIB.
bool delete_route (IPNet< A > net)
 Delete route from RIB.

Private Member Functions

void status_change (ServiceBase *service, ServiceStatus old_status, ServiceStatus new_status)
 A method invoked when the status of a service changes.
const ServiceBaseifmgr_mirror_service_base () const
const IfMgrIfTreeifmgr_iftree () const
void tree_complete ()
 An IfMgrHintObserver method invoked when the initial interface tree information has been received.
void updates_made ()
 An IfMgrHintObserver method invoked whenever the interface tree information has been changed.
void send_cb (const XrlError &xrl_error)
 Callback method to: signal that the XRL command to send a UDP datagram has returned.
XrlPortfind_port (const string &ifname, const string &vifname, const IPv4 &addr)
 Find OLSR port associated with interface, vif, address tuple.
const XrlPortfind_port (const string &ifname, const string &vifname, const IPv4 &addr) const
 Find OLSR port associated with interface, vif, address tuple.
XrlPortList & ports ()
const XrlPortList & ports () const
void try_start_next_port ()
 Gradually start each XrlPort to avoid races with the FEA.
void status_change (ServiceBase *service, ServiceStatus old_status, ServiceStatus new_status)
 A method invoked when the status of a service changes.
const ServiceBaseifmgr_mirror_service_base () const
 Obtain a pointer to the interface manager service base.
const IfMgrIfTreeifmgr_iftree () const
 Obtain a reference to the interface manager's interface tree.
void tree_complete ()
 An IfMgrHintObserver method invoked when the initial interface tree information has been received.
void updates_made ()
 An IfMgrHintObserver method invoked whenever the interface tree information has been changed.
void send_cb (const XrlError &xrl_error, string interface, string vif)
void enable_interface_vif_cb (const XrlError &xrl_error, string interface, string vif)
void disable_interface_vif_cb (const XrlError &xrl_error, string interface, string vif)
void join_multicast_group_cb (const XrlError &xrl_error, string interface, string vif)
void leave_multicast_group_cb (const XrlError &xrl_error, string interface, string vif)

Private Attributes

EventLoop_eventloop
XrlRouter_xrl_router
string _feaname
string _ribname
uint32_t _component_count
IfMgrXrlMirror _ifmgr
 libfeaclient wrapper.
IfMgrIfTree _iftree
 local copy of interface state obtained from libfeaclient.
XrlQueue _rib_queue
 Queue of RIB add/delete XRL commands.
XrlPortList _ports
 List of active XrlPorts.
XrlDeadPortMap _dead_ports
 XrlPorts awaiting I/O shutdown.
XrlQueue< A > _rib_queue

Detailed Description

template<typename A>
class XrlIO< A >

Concrete implementation of IO using XRLs.


Constructor & Destructor Documentation

template<typename A>
XrlIO< A >::XrlIO ( EventLoop eventloop,
XrlRouter xrl_router,
const string &  feaname,
const string &  ribname 
)

Construct an XrlIO instance.

Parameters:
eventloopthe event loop for the OLSR process.
xrl_routerthe name of the XRL router instance.
feanamethe name of the FEA XRL target.
ribnamethe name of the RIB XRL target.

Member Function Documentation

template<typename A>
bool XrlIO< A >::add_route ( IPv4Net  net,
IPv4  nexthop,
uint32_t  nexthop_id,
uint32_t  metric,
const PolicyTags policytags 
) [virtual]

Add route to RIB.

Parameters:
netnetwork
nexthop
nexthop_idinterface ID towards the nexthop
metricto network
policytagspolicy info to the RIB.
Returns:
true if the route add was queued successfully, otherwise false.

Implements IO< A >.

template<typename A>
bool XrlIO< A >::add_route ( IPNet< A >  net,
nexthop,
uint32_t  nexthop_id,
uint32_t  metric,
bool  equal,
bool  discard,
const PolicyTags policytags 
) [virtual]

Add route to RIB.

Parameters:
netnetwork
nexthop
nexthop_idinterface ID towards the nexthop
metricto network
equaltrue if this in another route to the same destination.
discardtrue if this is a discard route.
policytagspolicy info to the RIB.

Implements IO< A >.

template<typename A>
void XrlIO< A >::component_down ( string  name)

Called when internal subsystem goes down.

Parameters:
namethe name of the affected subsystem
template<typename A>
void XrlIO< A >::component_up ( string  name)

Called when internal subsystem comes up.

Parameters:
namethe name of the affected subsystem
template<typename A>
bool XrlIO< A >::delete_route ( IPv4Net  net) [virtual]

Delete route from RIB.

Parameters:
netthe destination to delete route for.
Returns:
true if the route delete was queued successfully, otherwise false.

Implements IO< A >.

template<typename A>
bool XrlIO< A >::disable_address ( const string &  interface,
const string &  vif,
const IPv4 address,
const uint16_t &  port 
) [virtual]

Disable an IPv4 address and port for OLSR datagram reception.

Parameters:
interfacethe interface to disable.
vifthe vif to disable.
addressthe address to disable.
portthe port to disable.
Returns:
true if the address was disabled, otherwise false.

Implements IO< A >.

template<typename A>
bool XrlIO< A >::disable_interface_vif ( const string &  interface,
const string &  vif 
) [virtual]

Disable this interface/vif from receiving frames.

XXX

Parameters:
interfacethe name of the interface to disable.
vifthe name of the vif to disable.
Returns:
true if the interface/vif was disabled successfully, otherwise false.

Implements IO< A >.

template<typename A>
bool XrlIO< A >::enable_address ( const string &  interface,
const string &  vif,
const IPv4 address,
const uint16_t &  port,
const IPv4 all_nodes_address 
) [virtual]

Enable an IPv4 address and port for OLSR datagram reception and transmission.

Parameters:
interfacethe interface to enable.
vifthe vif to enable.
addressthe address to enable.
portthe port to enable.
all_nodes_addressthe address to transmit to.
Returns:
true if the address was enabled, otherwise false.

Implements IO< A >.

template<typename A>
bool XrlIO< A >::enable_interface_vif ( const string &  interface,
const string &  vif 
) [virtual]

Enable the interface/vif to receive frames.

XXX

Parameters:
interfacethe name of the interface to enable.
vifthe name of the vif to enable.
Returns:
true if the interface/vif was enabled successfully, otherwise false.

Implements IO< A >.

template<typename A>
XrlPort * XrlIO< A >::find_port ( const string &  ifname,
const string &  vifname,
const IPv4 addr 
) [private]

Find OLSR port associated with interface, vif, address tuple.

Returns:
pointer to port on success, 0 if port could not be found.
template<typename A>
const XrlPort * XrlIO< A >::find_port ( const string &  ifname,
const string &  vifname,
const IPv4 addr 
) const [private]

Find OLSR port associated with interface, vif, address tuple.

Returns:
pointer to port on success, 0 if port could not be found.
template<typename A>
bool XrlIO< A >::get_addresses ( const string &  interface,
const string &  vif,
list< A > &  addresses 
) const [virtual]

Get all addresses associated with this interface/vif.

Parameters:
interfacethe name of the interface
vifthe name of the vif
addresses(out argument) list of associated addresses
Returns:
true if there are no errors.

Implements IO< A >.

template<typename A>
bool XrlIO< A >::get_addresses ( const string &  interface,
const string &  vif,
list< IPv4 > &  addresses 
) const [virtual]

Get all addresses associated with this interface/vif.

Parameters:
interfacethe name of the interface
vifthe name of the vif
addresses(out argument) list of associated addresses
Returns:
true if there are no errors.

Implements IO< A >.

template<typename A>
bool XrlIO< A >::get_broadcast_address ( const string &  interface,
const string &  vif,
IPv4 address 
) const

Get the broadcast address associated with this vif.

Parameters:
interfacethe name of the interface
vifthe name of the vif
address(out argument) "all nodes" address
Returns:
true if there are no errors.
template<typename A>
bool XrlIO< A >::get_broadcast_address ( const string &  interface,
const string &  vif,
const IPv4 address,
IPv4 bcast_address 
) const [virtual]

Get the broadcast address associated with this IPv4 address.

Parameters:
interfacethe name of the interface
vifthe name of the vif
addressIPv4 binding address
bcast_address(out argument) primary broadcast address
Returns:
true if there are no errors.

Implements IO< A >.

template<typename A >
bool XrlIO< A >::get_interface_id ( const string &  interface,
uint32_t &  interface_id 
) [virtual]

Get the interface ID.

Parameters:
interfacethe name of the interface.
interface_idthe value if found..
Returns:
true if the interface ID has been found..

Implements IO< A >.

template<typename A>
bool XrlIO< A >::get_interface_id ( const string &  interface,
uint32_t &  interface_id 
) [virtual]

Get the interface ID.

Parameters:
interfacethe name of the interface.
interface_idthe value if found..
Returns:
true if the interface ID has been found..

Implements IO< A >.

template<typename A>
bool XrlIO< A >::get_link_local_address ( const string &  interface,
const string &  vif,
A &  address 
) [virtual]

Get a link local address for this interface/vif if available.

Parameters:
interfacethe name of the interface
vifthe name of the vif
address(out argument) set if address is found.
Returns:
true if a link local address is available.

Implements IO< A >.

template<typename A >
uint32_t XrlIO< A >::get_mtu ( const string &  interface) [virtual]

Obtain the MTU for an interface.

Parameters:
interfacethe name of the interface.
Returns:
the mtu for the interface.

Implements IO< A >.

template<typename A>
uint32_t XrlIO< A >::get_mtu ( const string &  interface) [virtual]

Obtain the MTU for an interface.

Parameters:
thename of the interface.
Returns:
the mtu for the interface.

Implements IO< A >.

template<typename A>
uint32_t XrlIO< A >::get_prefix_length ( const string &  interface,
const string &  vif,
IPv4  address 
)

Obtain the subnet prefix length for an interface/vif/address.

Parameters:
interfacethe name of the interface.
vifthe name of the vif.
addressthe address.
Returns:
the subnet prefix length for the address.
template<typename A>
uint32_t XrlIO< A >::get_prefix_length ( const string &  interface,
const string &  vif,
address 
) [virtual]

Obtain the subnet prefix length for an interface/vif/address.

Parameters:
interfacethe name of the interface.
vifthe name of the vif.
addressthe address.
Returns:
the subnet prefix length for the address.

Implements IO< A >.

template<typename A>
const IfMgrIfTree& XrlIO< A >::ifmgr_iftree ( ) const [inline, private]

Obtain a reference to the interface manager's interface tree.

Returns:
a reference to the interface manager's interface tree.
template<typename A>
const IfMgrIfTree& XrlIO< A >::ifmgr_iftree ( ) const [inline, private]
Returns:
a reference to the interface manager's interface tree.
template<typename A>
const ServiceBase* XrlIO< A >::ifmgr_mirror_service_base ( ) const [inline, private]

Obtain a pointer to the interface manager service base.

Returns:
a pointer to the interface manager service base.
template<typename A>
const ServiceBase* XrlIO< A >::ifmgr_mirror_service_base ( ) const [inline, private]
Returns:
a pointer to the interface manager service base.
template<typename A>
bool XrlIO< A >::is_address_enabled ( const string &  interface,
const string &  vif,
const IPv4 address 
) const [virtual]

Test whether an interface/vif/address is enabled.

Parameters:
interfacethe name of the interface to test.
vifthe name of the vif to test.
addressthe address to test.
Returns:
true if it exists and is enabled, otherwise false.

Implements IO< A >.

template<typename A>
bool XrlIO< A >::is_address_enabled ( const string &  interface,
const string &  vif,
const A &  address 
) const [virtual]

Test whether an interface/vif/address is enabled.

Parameters:
interfacethe name of the interface to test.
vifthe name of the vif to test.
addressthe address to test.
Returns:
true if it exists and is enabled, otherwise false.

Implements IO< A >.

template<typename A >
bool XrlIO< A >::is_interface_enabled ( const string &  interface) const [virtual]

Test whether an interface is enabled.

Parameters:
interfacethe name of the interface to test.
Returns:
true if it exists and is enabled, otherwise false.

Implements IO< A >.

template<typename A>
bool XrlIO< A >::is_interface_enabled ( const string &  interface) const [virtual]

Test whether an interface is enabled.

Parameters:
interfacethe name of the interface to test.
Returns:
true if it exists and is enabled, otherwise false.

Implements IO< A >.

template<typename A>
bool XrlIO< A >::is_vif_broadcast_capable ( const string &  interface,
const string &  vif 
) [virtual]

Test whether this interface/vif is broadcast capable.

Parameters:
interfacethe interface to test.
vifthe vif to test.
Returns:
true if it is broadcast capable, otherwise false.

Implements IO< A >.

template<typename A >
bool XrlIO< A >::is_vif_enabled ( const string &  interface,
const string &  vif 
) const [virtual]

Test whether an interface/vif is enabled.

Parameters:
interfacethe name of the interface to test.
vifthe name of the vif to test.
Returns:
true if it exists and is enabled, otherwise false.

Implements IO< A >.

template<typename A>
bool XrlIO< A >::is_vif_enabled ( const string &  interface,
const string &  vif 
) const [virtual]

Test whether an interface/vif is enabled.

Parameters:
interfacethe name of the interface to test.
vifthe name of the vif to test.
Returns:
true if it exists and is enabled, otherwise false.

Implements IO< A >.

template<typename A>
bool XrlIO< A >::is_vif_multicast_capable ( const string &  interface,
const string &  vif 
) [virtual]

Test whether this interface/vif is multicast capable.

Parameters:
interfacethe interface to test.
vifthe vif to test.
Returns:
true if it is multicast capable, otherwise false.

Implements IO< A >.

template<typename A>
XrlPortList& XrlIO< A >::ports ( ) [inline, private]
Returns:
pointer to list of active XrlPorts.
template<typename A>
const XrlPortList& XrlIO< A >::ports ( ) const [inline, private]
Returns:
pointer to list of active XrlPorts.
template<typename A>
void XrlIO< A >::receive ( const string &  sockid,
const string &  interface,
const string &  vif,
const IPv4 src,
const uint16_t &  sport,
const vector< uint8_t > &  payload 
)

Receive UDP datagrams.

Specific to XrlIO.

Parameters:
sockidthe id of the socket.
interfacethe interface where received.
vifthe vif where received.
srcthe source port of the UDP datagram.
sportthe source address of the UDP datagram.
payloadthe datagram payload.
template<typename A>
bool XrlIO< A >::replace_route ( IPv4Net  net,
IPv4  nexthop,
uint32_t  nexthop_id,
uint32_t  metric,
const PolicyTags policytags 
) [virtual]

Replace route in RIB.

Parameters:
netnetwork
nexthop
nexthop_idinterface ID towards the nexthop
metricto network
policytagspolicy info to the RIB.
Returns:
true if the route replacement was queued successfully, otherwise false.

Implements IO< A >.

template<typename A>
bool XrlIO< A >::replace_route ( IPNet< A >  net,
nexthop,
uint32_t  nexthop_id,
uint32_t  metric,
bool  equal,
bool  discard,
const PolicyTags policytags 
) [virtual]

Replace route in RIB.

Parameters:
netnetwork
nexthop
nexthop_idinterface ID towards the nexthop
metricto network
equaltrue if this in another route to the same destination.
discardtrue if this is a discard route.
policytagspolicy info to the RIB.

Implements IO< A >.

template<typename A >
void XrlIO< A >::rib_command_done ( const XrlError error,
bool  up,
const char *  comment 
)

Callback method to: signal that an XRL command which has been sent to the RIB has returned.

Parameters:
errorthe XRL command return code.
upindicates if the RIB component has been brought up or down.
commenttext description of operation being performed.
template<typename A>
bool XrlIO< A >::send ( const string &  interface,
const string &  vif,
const IPv4 src,
const uint16_t &  sport,
const IPv4 dst,
const uint16_t &  dport,
uint8_t *  data,
const uint32_t &  len 
) [virtual]

Send a UDP datagram on a specific link.

Parameters:
interfacethe interface to send from.
vifthe vif to send from.
srcthe IPv4 address to send from.
sportthe UDP port to send from.
dstthe IPv4 address to send to.
dportthe UDP port to send to.
datathe datagram payload.
lenthe length of the buffer
data
Returns:
true if the datagram was queued successfully, otherwise false.

Implements IO< A >.

template<typename A>
void XrlIO< A >::send_cb ( const XrlError xrl_error) [private]

Callback method to: signal that the XRL command to send a UDP datagram has returned.

Parameters:
xrl_errorthe XRL command return code.
template<typename A>
int XrlIO< A >::shutdown ( ) [inline, virtual]

Shutdown operation.

Returns:
XORP_OK on success, otherwise XORP_ERROR.

Implements ServiceBase.

template<typename A>
int XrlIO< A >::shutdown ( ) [virtual]

Shutdown operation.

Returns:
XORP_OK on success, otherwise XORP_ERROR.

Implements ServiceBase.

template<typename A>
int XrlIO< A >::startup ( ) [virtual]

Startup operation.

Returns:
XORP_OK on success, otherwise XORP_ERROR.

Implements ServiceBase.

template<typename A>
int XrlIO< A >::startup ( ) [inline, virtual]

Startup operation.

Returns:
XORP_OK on success, otherwise XORP_ERROR.

Implements ServiceBase.

template<typename A>
void XrlIO< A >::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.

template<typename A>
void XrlIO< A >::status_change ( ServiceBase service,
ServiceStatus  old_status,
ServiceStatus  new_status 
) [inline, 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.


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