xorp

IO< A > Class Template Reference

Abstract interface to low level IO operations. More...

#include <io.hh>

Inheritance diagram for IO< A >:
ServiceBase ServiceBase BugCatcher BugCatcher DebugIO< A > DebugIO< A > XrlIO< A > XrlIO< A >

List of all members.

Classes

struct  interface_vif

Public Types

typedef XorpCallback2< void,
const string &, bool >::RefPtr 
InterfaceStatusCb
 Callback for interface status from the FEA.
typedef XorpCallback3< void,
const string &, const string
&, bool >::RefPtr 
VifStatusCb
 Callback for vif status from the FEA.
typedef XorpCallback4< void,
const string &, const string
&, IPv4, bool >::RefPtr 
AddressStatusCb
 Callback for address status from the FEA.
typedef XorpCallback8< void,
const string &, const string
&, IPv4, uint16_t, IPv4,
uint16_t, uint8_t *, uint32_t >
::RefPtr 
ReceiveCallback
 Callback for packet reception from the FEA.
typedef XorpCallback6< void,
const string &, const string
&, A, A, uint8_t *, uint32_t >
::RefPtr 
ReceiveCallback
typedef XorpCallback2< void,
const string &, bool >::RefPtr 
InterfaceStatusCb
typedef XorpCallback3< void,
const string &, const string
&, bool >::RefPtr 
VifStatusCb
typedef XorpCallback4< void,
const string &, const string
&, A, bool >::RefPtr 
AddressStatusCb

Public Member Functions

virtual bool enable_address (const string &interface, const string &vif, const IPv4 &address, const uint16_t &port, const IPv4 &all_nodes_address)=0
 Enable an IPv4 address and port for OLSR datagram reception and transmission.
virtual bool disable_address (const string &interface, const string &vif, const IPv4 &address, const uint16_t &port)=0
 Disable an IPv4 address and port for OLSR datagram reception.
virtual bool is_interface_enabled (const string &interface) const =0
 Test whether this interface is enabled.
virtual bool is_vif_enabled (const string &interface, const string &vif) const =0
 Test whether this interface/vif is enabled.
virtual bool is_vif_broadcast_capable (const string &interface, const string &vif)=0
 Test whether this interface/vif is broadcast capable.
virtual bool is_vif_multicast_capable (const string &interface, const string &vif)=0
 Test whether this interface/vif is multicast capable.
virtual bool is_vif_loopback (const string &interface, const string &vif)=0
 Test whether this interface/vif is a loopback interface.
virtual bool is_address_enabled (const string &interface, const string &vif, const IPv4 &address) const =0
 Test whether this interface/vif/address is enabled.
virtual bool get_addresses (const string &interface, const string &vif, list< IPv4 > &addresses) const =0
 Get all addresses associated with this interface/vif.
virtual bool get_broadcast_address (const string &interface, const string &vif, const IPv4 &address, IPv4 &bcast_address) const =0
 Get the broadcast address associated with this interface/vif/address.
virtual bool get_interface_id (const string &interface, uint32_t &interface_id)=0
 Get the ID of the interface, as seen by libfeaclient.
virtual uint32_t get_mtu (const string &interface)=0
 Get the MTU for an interface.
void register_interface_status (InterfaceStatusCb cb)
 Add a callback for tracking the interface status.
void register_vif_status (VifStatusCb cb)
 Add a callback for tracking the interface/vif status.
void register_address_status (AddressStatusCb cb)
 Add a callback for tracking the interface/vif/address status.
void register_receive (ReceiveCallback cb)
 Register for receiving datagrams.
virtual 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)=0
 Send a UDP datagram from src:sport to dst:dport, on the given interface, if possible.
virtual bool add_route (IPv4Net net, IPv4 nexthop, uint32_t faceid, uint32_t metric, const PolicyTags &policytags)=0
 Add route.
virtual bool replace_route (IPv4Net net, IPv4 nexthop, uint32_t faceid, uint32_t metric, const PolicyTags &policytags)=0
 Replace route.
virtual bool delete_route (IPv4Net net)=0
 Delete route.
void set_interface_mapping (uint32_t interface_id, const string &interface, const string &vif)
 Store a mapping of the OLSR internal interface ID to interface/vif.
bool get_interface_vif_by_interface_id (uint32_t interface_id, string &interface, string &vif)
 Given an OLSR interface ID, return the interface/vif.
uint16_t get_ip_protocol_number () const
 Get OSPF protocol number.
virtual bool send (const string &interface, const string &vif, A dst, A src, int ttl, uint8_t *data, uint32_t len)=0
 Send Raw frames.
bool set_ip_router_alert (bool alert)
 Send router alerts in IP packets?
bool get_ip_router_alert () const
 Get router alert state.
void register_receive (ReceiveCallback cb)
 Register for receiving raw frames.
virtual bool enable_interface_vif (const string &interface, const string &vif)=0
 Enable the interface/vif to receive frames.
virtual bool disable_interface_vif (const string &interface, const string &vif)=0
 Disable this interface/vif from receiving frames.
virtual bool is_interface_enabled (const string &interface) const =0
 Test whether this interface is enabled.
virtual bool is_vif_enabled (const string &interface, const string &vif) const =0
 Test whether this interface/vif is enabled.
virtual bool is_address_enabled (const string &interface, const string &vif, const A &address) const =0
 Test whether this interface/vif/address is enabled.
void register_interface_status (InterfaceStatusCb cb)
 Add a callback for tracking the interface status.
void register_vif_status (VifStatusCb cb)
 Add a callback for tracking the interface/vif status.
void register_address_status (AddressStatusCb cb)
 Add a callback for tracking the interface/vif/address status.
virtual bool get_addresses (const string &interface, const string &vif, list< A > &addresses) const =0
 Get all addresses associated with this interface/vif.
virtual bool get_link_local_address (const string &interface, const string &vif, A &address)=0
 Get a link local address for this interface/vif if available.
virtual bool get_interface_id (const string &interface, uint32_t &interface_id)=0
virtual uint32_t get_prefix_length (const string &interface, const string &vif, A address)=0
virtual uint32_t get_mtu (const string &interface)=0
virtual bool join_multicast_group (const string &interface, const string &vif, A mcast)=0
 On the interface/vif join this multicast group.
virtual bool leave_multicast_group (const string &interface, const string &vif, A mcast)=0
 On the interface/vif leave this multicast group.
virtual bool add_route (IPNet< A > net, A nexthop, uint32_t nexthop_id, uint32_t metric, bool equal, bool discard, const PolicyTags &policytags)=0
 Add route.
virtual bool replace_route (IPNet< A > net, A nexthop, uint32_t nexthop_id, uint32_t metric, bool equal, bool discard, const PolicyTags &policytags)=0
 Replace route.
virtual bool delete_route (IPNet< A > net)=0
 Delete route.
void set_interface_mapping (uint32_t interface_id, const string &interface, const string &vif)
 Store a mapping of the OSPF internal interface ID to interface/vif.
bool get_interface_vif_by_interface_id (uint32_t interface_id, string &interface, string &vif)
 Given an OSPF internal interface ID return the interface/vif.

Protected Attributes

ReceiveCallback _receive_cb
InterfaceStatusCb _interface_status_cb
VifStatusCb _vif_status_cb
AddressStatusCb _address_status_cb
map< uint32_t, interface_vif_interface_vif
bool _ip_router_alert

Detailed Description

template<typename A>
class IO< A >

Abstract interface to low level IO operations.

An abstract class that defines packet reception and transmission.

An abstract class that defines packet reception and transmission. The details of how packets are received or transmitted are therefore hidden from the internals of the OLSR code.

The details of how packets are received or transmitted are therefore hidden from the internals of the OSPF code.


Member Function Documentation

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

Add route.

Parameters:
netnetwork
nexthop
faceidinterface ID towards the nexthop
metricto network
policytagspolicy info to the RIB.
Returns:
true if the route was added OK, otherwise false.

Implemented in DebugIO< A >, XrlIO< A >, and XrlIO< IPv4 >.

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

Add route.

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.

Implemented in DebugIO< A >, XrlIO< A >, and XrlIO< IPv4 >.

template<typename A>
virtual bool IO< A >::delete_route ( IPv4Net  net) [pure virtual]

Delete route.

Parameters:
netnetwork
Returns:
true if the route was deleted OK, otherwise false.

Implemented in DebugIO< A >, XrlIO< A >, XrlIO< IPv4 >, and XrlIO< IPv4 >.

template<typename A>
virtual bool IO< A >::disable_address ( const string &  interface,
const string &  vif,
const IPv4 address,
const uint16_t &  port 
) [pure 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.

Implemented in DebugIO< A >, XrlIO< A >, and XrlIO< IPv4 >.

template<typename A>
virtual bool IO< A >::enable_address ( const string &  interface,
const string &  vif,
const IPv4 address,
const uint16_t &  port,
const IPv4 all_nodes_address 
) [pure 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 all-nodes address to enable.
Returns:
true if the address was enabled, otherwise false.

Implemented in DebugIO< A >, XrlIO< A >, and XrlIO< IPv4 >.

template<typename A>
virtual bool IO< A >::get_addresses ( const string &  interface,
const string &  vif,
list< IPv4 > &  addresses 
) const [pure 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.

Implemented in DebugIO< A >, XrlIO< A >, XrlIO< IPv4 >, and XrlIO< IPv4 >.

template<typename A>
virtual bool IO< A >::get_addresses ( const string &  interface,
const string &  vif,
list< A > &  addresses 
) const [pure 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.

Implemented in DebugIO< A >, XrlIO< A >, XrlIO< IPv4 >, and XrlIO< IPv4 >.

template<typename A>
virtual bool IO< A >::get_broadcast_address ( const string &  interface,
const string &  vif,
const IPv4 address,
IPv4 bcast_address 
) const [pure virtual]

Get the broadcast address associated with this interface/vif/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.

Implemented in DebugIO< A >, XrlIO< A >, and XrlIO< IPv4 >.

template<typename A>
virtual bool IO< A >::get_interface_id ( const string &  interface,
uint32_t &  interface_id 
) [pure virtual]
Returns:
the interface id for this interface.

Implemented in DebugIO< A >, XrlIO< A >, DebugIO< A >, XrlIO< A >, XrlIO< IPv4 >, and XrlIO< IPv4 >.

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

Get the ID of the interface, as seen by libfeaclient.

Parameters:
interfacethe name of the interface.
interface_id(out argument) interface ID.
Returns:
the interface id for this interface.

Implemented in DebugIO< A >, XrlIO< A >, DebugIO< A >, XrlIO< A >, XrlIO< IPv4 >, and XrlIO< IPv4 >.

template<typename A>
bool IO< A >::get_interface_vif_by_interface_id ( uint32_t  interface_id,
string &  interface,
string &  vif 
) [inline]

Given an OLSR interface ID, return the interface/vif.

Parameters:
interface_idthe ID of the interface, as seen by libfeaclient.
interfacethe name of the interface mapped to interface_id.
vifthe name of vif mapped to interface_id.
Returns:
true if interface_id was found, otherwise false.
template<typename A>
virtual bool IO< A >::get_link_local_address ( const string &  interface,
const string &  vif,
A &  address 
) [pure 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.

Implemented in XrlIO< A >, and XrlIO< IPv4 >.

template<typename A>
virtual uint32_t IO< A >::get_mtu ( const string &  interface) [pure virtual]
Returns:
the mtu for this interface.

Implemented in DebugIO< A >, XrlIO< A >, DebugIO< A >, XrlIO< A >, XrlIO< IPv4 >, and XrlIO< IPv4 >.

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

Get the MTU for an interface.

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

Implemented in DebugIO< A >, XrlIO< A >, DebugIO< A >, XrlIO< A >, XrlIO< IPv4 >, and XrlIO< IPv4 >.

template<typename A>
virtual uint32_t IO< A >::get_prefix_length ( const string &  interface,
const string &  vif,
address 
) [pure virtual]
Returns:
prefix length for this address.

Implemented in DebugIO< A >, XrlIO< A >, XrlIO< IPv4 >, and XrlIO< IPv4 >.

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

Test whether this interface/vif/address is enabled.

Returns:
true if it exists and is enabled, otherwise false.

Implemented in DebugIO< A >, XrlIO< A >, XrlIO< IPv4 >, and XrlIO< IPv4 >.

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

Test whether this interface/vif/address is enabled.

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

Implemented in DebugIO< A >, XrlIO< A >, XrlIO< IPv4 >, and XrlIO< IPv4 >.

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

Test whether this interface is enabled.

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

Implemented in DebugIO< A >, XrlIO< A >, DebugIO< A >, XrlIO< A >, XrlIO< IPv4 >, and XrlIO< IPv4 >.

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

Test whether this interface is enabled.

Returns:
true if it exists and is enabled, otherwise false.

Implemented in DebugIO< A >, XrlIO< A >, DebugIO< A >, XrlIO< A >, XrlIO< IPv4 >, and XrlIO< IPv4 >.

template<typename A>
virtual bool IO< A >::is_vif_broadcast_capable ( const string &  interface,
const string &  vif 
) [pure 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.

Implemented in DebugIO< A >, XrlIO< A >, and XrlIO< IPv4 >.

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

Test whether this interface/vif is enabled.

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

Implemented in DebugIO< A >, XrlIO< A >, DebugIO< A >, XrlIO< A >, XrlIO< IPv4 >, and XrlIO< IPv4 >.

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

Test whether this interface/vif is enabled.

Returns:
true if it exists and is enabled, otherwise false.

Implemented in DebugIO< A >, XrlIO< A >, DebugIO< A >, XrlIO< A >, XrlIO< IPv4 >, and XrlIO< IPv4 >.

template<typename A>
virtual bool IO< A >::is_vif_loopback ( const string &  interface,
const string &  vif 
) [pure virtual]

Test whether this interface/vif is a loopback interface.

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

Implemented in DebugIO< A >, XrlIO< A >, and XrlIO< IPv4 >.

template<typename A>
virtual bool IO< A >::is_vif_multicast_capable ( const string &  interface,
const string &  vif 
) [pure 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.

Implemented in DebugIO< A >, XrlIO< A >, and XrlIO< IPv4 >.

template<typename A>
void IO< A >::register_address_status ( AddressStatusCb  cb) [inline]

Add a callback for tracking the interface/vif/address status.

The callback will be invoked whenever the status of the tuple (interface, vif, address) is changed from disabled to enabled or vice-versa.

Parameters:
cbthe callback to register.
template<typename A>
void IO< A >::register_address_status ( AddressStatusCb  cb) [inline]

Add a callback for tracking the interface/vif/address status.

The callback will be invoked whenever the status of the tuple (interface, vif, address) is changed from disabled to enabled or vice-versa.

Parameters:
cbthe callback to register.
template<typename A>
void IO< A >::register_interface_status ( InterfaceStatusCb  cb) [inline]

Add a callback for tracking the interface status.

The callback will be invoked whenever the status of the interface is changed from disabled to enabled or vice-versa.

Parameters:
cbthe callback to register.
template<typename A>
void IO< A >::register_interface_status ( InterfaceStatusCb  cb) [inline]

Add a callback for tracking the interface status.

The callback will be invoked whenever the status of the interface is changed from disabled to enabled or vice-versa.

Parameters:
cbthe callback to register.
template<typename A>
void IO< A >::register_receive ( ReceiveCallback  cb) [inline]

Register for receiving datagrams.

Parameters:
cbthe callback to register.
template<typename A>
void IO< A >::register_vif_status ( VifStatusCb  cb) [inline]

Add a callback for tracking the interface/vif status.

The callback will be invoked whenever the status of the interface/vif is changed from disabled to enabled or vice-versa.

Parameters:
cbthe callback to register.
template<typename A>
void IO< A >::register_vif_status ( VifStatusCb  cb) [inline]

Add a callback for tracking the interface/vif status.

The callback will be invoked whenever the status of the interface/vif is changed from disabled to enabled or vice-versa.

Parameters:
cbthe callback to register.
template<typename A>
virtual bool IO< A >::replace_route ( IPNet< A >  net,
nexthop,
uint32_t  nexthop_id,
uint32_t  metric,
bool  equal,
bool  discard,
const PolicyTags policytags 
) [pure virtual]

Replace route.

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.

Implemented in DebugIO< A >, XrlIO< A >, and XrlIO< IPv4 >.

template<typename A>
virtual bool IO< A >::replace_route ( IPv4Net  net,
IPv4  nexthop,
uint32_t  faceid,
uint32_t  metric,
const PolicyTags policytags 
) [pure virtual]

Replace route.

Parameters:
netnetwork
nexthop
faceidinterface ID towards the nexthop
metricto network
policytagspolicy info to the RIB.
Returns:
true if the route was replaced OK, otherwise false.

Implemented in DebugIO< A >, XrlIO< A >, and XrlIO< IPv4 >.

template<typename A>
virtual bool IO< 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 
) [pure virtual]

Send a UDP datagram from src:sport to dst:dport, on the given interface, if possible.

Parameters:
interfacethe interface to transmit from.
vifthe vif to transmit from.
srcthe IPv4 source address to transmit from.
sportthe UDP source port to transmit from.
dstthe IPv4 destination address to send to.
dportthe UDP destination port to send to.
datathe datagram to transmit.
lenthe length of the datagram to transmit.
Returns:
true if the datagram was sent OK, otherwise false.

Implemented in DebugIO< A >, XrlIO< A >, and XrlIO< IPv4 >.

template<typename A>
void IO< A >::set_interface_mapping ( uint32_t  interface_id,
const string &  interface,
const string &  vif 
) [inline]

Store a mapping of the OSPF internal interface ID to interface/vif.

This will be required by when installing a route.

template<typename A>
void IO< A >::set_interface_mapping ( uint32_t  interface_id,
const string &  interface,
const string &  vif 
) [inline]

Store a mapping of the OLSR internal interface ID to interface/vif.

This will be required by when installing a route.

Parameters:
interface_idthe ID of the interface, as seen by libfeaclient.
interfacethe name of the interface mapped to interface_id.
vifthe name of vif mapped to interface_id.

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