xorp

FaceManager Class Reference

Class which manages all interface bindings in the OLSR routing process. More...

#include <face_manager.hh>

List of all members.

Public Member Functions

 FaceManager (Olsr &olsr, EventLoop &ev)
MessageDecodermessage_decoder ()
Neighborhoodneighborhood ()
void set_neighborhood (Neighborhood *nh)
uint32_t get_face_count () const
const Faceget_face_by_id (const OlsrTypes::FaceID faceid) const throw (BadFace)
 Get a pointer to a Face given its ID.
void get_face_list (list< OlsrTypes::FaceID > &face_list) const
 Fill out a list of all face IDs.
IPv4 get_main_addr () const
bool set_main_addr (const IPv4 &addr)
 Attempt to set main address on node.
TimeVal get_mid_interval () const
void set_mid_interval (const TimeVal &interval)
 Set the MID_INTERVAL protocol variable.
TimeVal get_mid_hold_time () const
TimeVal get_dup_hold_time () const
void set_dup_hold_time (const TimeVal &dup_hold_time)
 Set the hold time for duplicate messages.
void receive (const string &interface, const string &vif, const IPv4 &dst, const uint16_t &dport, const IPv4 &src, const uint16_t &sport, uint8_t *data, const uint32_t &len)
 Process a received datagram.
bool transmit (const string &interface, const string &vif, const IPv4 &dst, const uint16_t &dport, const IPv4 &src, const uint16_t &sport, uint8_t *data, const uint32_t &len)
 Transmit a datagram.
OlsrTypes::FaceID create_face (const string &interface, const string &vif) throw (BadFace)
 Add a new interface.
void clear_faces ()
 Clear the interface list.
bool activate_face (const string &interface, const string &vif)
 Activate the OLSR binding to the given interface.
bool delete_face (OlsrTypes::FaceID faceid)
 Delete an interface.
bool recompute_addresses_face (OlsrTypes::FaceID faceid)
 Recompute the list of protocol addresses used by OLSR to send and receive protocol control traffic on this Face.
void vif_status_change (const string &interface, const string &vif, bool state)
 Callback method to: Process a change of vif status from the FEA.
void address_status_change (const string &interface, const string &vif, IPv4 addr, bool state)
 Callback method to: Process a change of address status from the FEA.
OlsrTypes::FaceID get_faceid (const string &interface, const string &vif) throw (BadFace)
 Get the ID of an interface, given its names as known to the FEA.
bool get_interface_vif_by_faceid (OlsrTypes::FaceID faceid, string &interface, string &vif)
 Get the FEA names of an interface, given its OLSR interface ID.
bool get_interface_cost (OlsrTypes::FaceID faceid, int &cost)
 Set the cost of an interface.
bool set_face_enabled (OlsrTypes::FaceID faceid, bool enabled)
 Enable the OLSR binding on the given interface.
bool get_face_enabled (OlsrTypes::FaceID faceid)
 Get the "administratively up" status of an OLSR interface.
bool set_interface_cost (OlsrTypes::FaceID faceid, const int cost)
 Set the cost of an OLSR interface.
bool set_local_addr (OlsrTypes::FaceID faceid, const IPv4 &local_addr)
 Set the IPv4 local address of an interface.
bool get_local_addr (OlsrTypes::FaceID faceid, IPv4 &local_addr)
 Get the IPv4 local address of an interface.
bool set_local_port (OlsrTypes::FaceID faceid, const uint16_t local_port)
 Set the UDP local port of an interface.
bool get_local_port (OlsrTypes::FaceID faceid, uint16_t &local_port)
 Get the UDP local port of an interface.
bool set_all_nodes_addr (OlsrTypes::FaceID faceid, const IPv4 &all_nodes_addr)
 Set the IPv4 all-nodes address of an interface.
bool get_all_nodes_addr (OlsrTypes::FaceID faceid, IPv4 &all_nodes_addr)
 Get the IPv4 all-nodes address of an interface.
bool set_all_nodes_port (OlsrTypes::FaceID faceid, const uint16_t all_nodes_port)
 Set the UDP all-nodes port of an interface.
bool get_all_nodes_port (OlsrTypes::FaceID faceid, uint16_t &all_nodes_port)
 Get the UDP all-nodes port of an interface.
bool flood_message (Message *message)
 Flood a message on all interfaces, performing appropriate fragmentation for each interface.
uint16_t get_msg_seqno ()
void stop_all_timers ()
 Stop all timers (HELLO and MID).
void start_hello_timer ()
void stop_hello_timer ()
void restart_hello_timer ()
void reschedule_hello_timer ()
 Reschedule the HELLO protocol timer, if its interval changed.
void reschedule_immediate_hello_timer ()
 Reschedule the HELLO protocol timer to fire as soon as possible.
bool event_send_hello ()
 Broadcast a HELLO message on each enabled interface.
void start_mid_timer ()
void stop_mid_timer ()
void restart_mid_timer ()
void reschedule_mid_timer ()
 Reschedule the MID protocol timer, if its interval changed.
void reschedule_immediate_mid_timer ()
 Reschedule the MID protocol timer to fire as soon as possible.
bool event_send_mid ()
 Callback method to: Send a MID message on each enabled interface.
void set_hello_interval (const TimeVal &interval)
 Set the HELLO_INTERVAL protocol variable.
TimeVal get_hello_interval ()
TimeVal get_max_jitter ()
uint32_t get_enabled_face_count () const
void add_message_cb (MessageReceiveCB cb)
 Register an OLSR protocol message handler.
bool delete_message_cb (MessageReceiveCB cb)
 Deregister an OLSR protocol message handler.
bool event_receive_unknown (Message *msg, const IPv4 &remote_addr, const IPv4 &local_addr)
 Callback method to: forward a Message of unknown type to the rest of the OLSR topology.
bool forward_message (const IPv4 &remote_addr, Message *msg)
 Implement the Default Forwarding Algorithm (Section 3.4.1).
bool is_duplicate_message (const Message *msg) const
 Check if a message is a previously seen duplicate.
bool is_forwarded_message (const Message *msg) const
 Check if a message should be forwarded, according to the default forwarding rules.
DupeTupleget_dupetuple (const IPv4 &origin_addr, const uint16_t seqno) const
 Get a pointer to a tuple in the duplicate set for a message, given its origin address and sequence number.
void update_dupetuple (const Message *msg, const bool is_forwarded)
 Update or create an entry in the duplicate message set.
void event_dupetuple_expired (const IPv4 &origin, const uint16_t seqno)
 Delete a duplicate set entry when it expires.
void clear_dupetuples ()
 Clear the duplicate set.
bool is_local_addr (const IPv4 &addr)
bool get_face_stats (const string &ifname, const string &vifname, FaceCounters &stats)
 Get the statistics for the given face.

Private Types

typedef multimap< IPv4,
DupeTuple * > 
DupeTupleMap
 Maintain state about messages we may have already processed and/or forwarded.

Private Attributes

Olsr_olsr
EventLoop_eventloop
MessageDecoder _md
Neighborhood_nh
OlsrTypes::FaceID _next_faceid
uint32_t _enabled_face_count
uint16_t _next_msg_seqno
 The next available message sequence number.
IPv4 _main_addr
 primary protocol address of this node; used as 'origin' for OLSR control messages.
vector< MessageReceiveCB > _handlers
 Vector of message handlers.
map< string, OlsrTypes::FaceID_faceid_map
 Map interface/vif to OlsrTypes::FaceID.
map< OlsrTypes::FaceID, Face * > _faces
 Map FaceID to Face.
DupeTupleMap _duplicate_set
TimeVal _hello_interval
 The HELLO_INTERVAL protocol control variable.
XorpTimer _hello_timer
TimeVal _mid_interval
 The MID_INTERVAL protocol control variable.
XorpTimer _mid_timer
TimeVal _dup_hold_time
 The DUP_HOLD_TIME protocol control variable.
bool _is_early_mid_enabled
 true if a MID message should be queued as soon as the set of configured interfaces changes.

Detailed Description

Class which manages all interface bindings in the OLSR routing process.


Member Typedef Documentation

typedef multimap<IPv4, DupeTuple*> FaceManager::DupeTupleMap [private]

Maintain state about messages we may have already processed and/or forwarded.

HELLO messages are specifically excluded. Section 3.4: Duplicate Tuple.


Member Function Documentation

bool FaceManager::activate_face ( const string &  interface,
const string &  vif 
)

Activate the OLSR binding to the given interface.

This means recomputing address lists and choosing the primary address on that interface; we do not yet support changing the address used.

We do not bring up any sockets until set_face_enabled().

void FaceManager::add_message_cb ( MessageReceiveCB  cb)

Register an OLSR protocol message handler.

MessageReceiveCBs are invoked in reverse order to which they have been registered. The FaceManager always registers a handler for unknown message types first, so that such messages will be forwarded, even if XORP has no handler for it. Each handler thus registered is given an opportunity to claim the message as its own, by returning true.

C++ dynamic casts are used at runtime by each MessageReceiveCB to determine if it should consume the message.

Parameters:
cbthe message receive callback function to register.
void FaceManager::address_status_change ( const string &  interface,
const string &  vif,
IPv4  addr,
bool  state 
)

Callback method to: Process a change of address status from the FEA.

Parameters:
interfacethe name of the affected interface.
vifthe name of the affected vif.
addrthe affected IPv4 interface address.
statethe new state of the address.
OlsrTypes::FaceID FaceManager::create_face ( const string &  interface,
const string &  vif 
) throw (BadFace)

Add a new interface.

Parameters:
interfacethe name of the interface as known to the FEA.
vifthe name of the vif as known to the FEA.
Returns:
the ID of the new interface.
Exceptions:
BadFaceif the interface could not be added.
bool FaceManager::delete_face ( OlsrTypes::FaceID  faceid)

Delete an interface.

Parameters:
faceidthe ID of the Face to delete.
Returns:
true if the interface was deleted.
bool FaceManager::delete_message_cb ( MessageReceiveCB  cb)

Deregister an OLSR protocol message handler.

Parameters:
cbthe message receive callback function to deregister.
Returns:
true if cb was deregistered, otherwise false.
bool FaceManager::flood_message ( Message message)

Flood a message on all interfaces, performing appropriate fragmentation for each interface.

Parameters:
messageThe message to flood, will be deleted by this method.
bool FaceManager::forward_message ( const IPv4 remote_addr,
Message msg 
)

Implement the Default Forwarding Algorithm (Section 3.4.1).

Parameters:
remote_addrthe interface address of the node which sent or forwarded this message to us. Note: This may not be the origin if the message has previously been forwarded.
msgthe message itself.
Returns:
true if the message will be forwarded to other nodes.
bool FaceManager::get_all_nodes_addr ( OlsrTypes::FaceID  faceid,
IPv4 all_nodes_addr 
)

Get the IPv4 all-nodes address of an interface.

Uses [] so can't be declared const.

Parameters:
faceidthe ID of Face to get all-nodes address for.
all_nodes_addroutput variable which will contain the all-nodes address.
Returns:
true if the all-nodes address was retrieved successfully, otherwise false.
bool FaceManager::get_all_nodes_port ( OlsrTypes::FaceID  faceid,
uint16_t &  all_nodes_port 
)

Get the UDP all-nodes port of an interface.

Parameters:
faceidthe ID of Face to get the all-nodes port for.
all_nodes_portoutput variable which will contain the all-nodes port.
Returns:
true if the all-nodes port was retrieved successfully, otherwise false.
TimeVal FaceManager::get_dup_hold_time ( ) const [inline]
Returns:
the DUP_HOLD_TIME protocol variable.
DupeTuple * FaceManager::get_dupetuple ( const IPv4 origin_addr,
const uint16_t  seqno 
) const

Get a pointer to a tuple in the duplicate set for a message, given its origin address and sequence number.

Avoid throwing an exception as this path may be called very frequently when forwarding or flooding messages. This however means we return a pointer.

Parameters:
origin_addrthe protocol address of the message origin.
seqnothe sequence number of the message.
Returns:
the pointer to the duplicate set entry, or 0 if none exists.
uint32_t FaceManager::get_enabled_face_count ( ) const [inline]
Returns:
the number of interfaces enabled for OLSR.
const Face * FaceManager::get_face_by_id ( const OlsrTypes::FaceID  faceid) const throw (BadFace)

Get a pointer to a Face given its ID.

Parameters:
faceidthe face ID.
Returns:
pointer to the face.
Exceptions:
BadFaceif the face ID cannot be found.
uint32_t FaceManager::get_face_count ( ) const [inline]
Returns:
the number of interfaces known to FaceManager.
bool FaceManager::get_face_enabled ( OlsrTypes::FaceID  faceid)

Get the "administratively up" status of an OLSR interface.

Parameters:
faceidthe ID of Face to query enabled state for.
Returns:
true if faceid is enabled.
void FaceManager::get_face_list ( list< OlsrTypes::FaceID > &  face_list) const

Fill out a list of all face IDs.

Parameters:
face_listthe list to fill out.
bool FaceManager::get_face_stats ( const string &  ifname,
const string &  vifname,
FaceCounters stats 
)

Get the statistics for the given face.

Parameters:
ifnamethe name of the interface to retrieve stats for.
vifnamethe name of the vif to retrieve stats for.
statsoutput; reference to an empty FaceCounters object.
Returns:
true if the stats were retrieved, otherwise false.
OlsrTypes::FaceID FaceManager::get_faceid ( const string &  interface,
const string &  vif 
) throw (BadFace)

Get the ID of an interface, given its names as known to the FEA.

Parameters:
interfacethe name of the interface to look up.
vifthe name of the vif to look up.
Returns:
the ID of the face.
Exceptions:
BadFaceif the interface was not found.
TimeVal FaceManager::get_hello_interval ( ) [inline]
Returns:
the HELLO_INTERVAL protocol variable.
bool FaceManager::get_interface_cost ( OlsrTypes::FaceID  faceid,
int &  cost 
)

Set the cost of an interface.

Used by shortest path calculation.

Parameters:
faceidthe ID of the interface to set cost for.
costthe interface cost to set.
Returns:
true if the interface cost was set, otherwise false.
bool FaceManager::get_interface_vif_by_faceid ( OlsrTypes::FaceID  faceid,
string &  interface,
string &  vif 
)

Get the FEA names of an interface, given its OLSR interface ID.

Parameters:
faceidthe ID of the interface to look up.
interfacethe name of the interface if found.
vifthe name of the vif if found.
Returns:
true if the interface was found, otherwise false.
bool FaceManager::get_local_addr ( OlsrTypes::FaceID  faceid,
IPv4 local_addr 
)

Get the IPv4 local address of an interface.

Parameters:
faceidthe ID of Face to get local address for.
local_addrthe local address, if interface was found.
Returns:
true if the local address was retrieved successfully, otherwise false.
bool FaceManager::get_local_port ( OlsrTypes::FaceID  faceid,
uint16_t &  local_port 
)

Get the UDP local port of an interface.

Uses [] so can't be declared const.

Parameters:
faceidthe ID of Face to get local port for.
local_portthe UDP local port, if interface was found.
Returns:
true if the local port was retrieved successfully, otherwise false.
IPv4 FaceManager::get_main_addr ( ) const [inline]
Returns:
the OLSR main address of this node.
TimeVal FaceManager::get_max_jitter ( ) [inline]
Returns:
the MAX_JITTER protocol variable.
TimeVal FaceManager::get_mid_hold_time ( ) const [inline]
Returns:
the MID_HOLD_TIME protocol variable.
TimeVal FaceManager::get_mid_interval ( ) const [inline]
Returns:
the MID_INTERVAL protocol variable.
uint16_t FaceManager::get_msg_seqno ( ) [inline]
Returns:
the next sequence number to use for a transmitted Message.
bool FaceManager::is_duplicate_message ( const Message msg) const

Check if a message is a previously seen duplicate.

Returns:
true if the message is a duplicate and should neither be processed or forwarded.
bool FaceManager::is_forwarded_message ( const Message msg) const

Check if a message should be forwarded, according to the default forwarding rules.

Parameters:
msgthe message to check.
Returns:
true if the message SHOULD NOT be forwarded, false if it is OK to forward the message.
bool FaceManager::is_local_addr ( const IPv4 addr)
Returns:
true if the given address belongs to any locally configured interface.
void FaceManager::receive ( const string &  interface,
const string &  vif,
const IPv4 dst,
const uint16_t &  dport,
const IPv4 src,
const uint16_t &  sport,
uint8_t *  data,
const uint32_t &  len 
)

Process a received datagram.

Parameters:
interfacethe interface where the datagram was received.
vifthe vif where the datagram was received.
dstthe IPv4 destination address of the datagram.
dportthe UDP destination port of the datagram.
srcthe IPv4 source address of the datagram.
sportthe UDP source port of the datagram.
datathe received datagram.
lenthe length of the received datagram.
bool FaceManager::recompute_addresses_face ( OlsrTypes::FaceID  faceid)

Recompute the list of protocol addresses used by OLSR to send and receive protocol control traffic on this Face.

Parameters:
faceidthe ID of the Face to recompute addresses on.
Returns:
true if the address lists were recomputed successfully.

This method works significantly differently than in OSPF. In OLSR, we need to recompute the list of addresses to which OLSR control traffic may originate from or be received on whenever the configured addresses on an interface change.

This relates only to the MID message; there is no strict parallel to the network LSA in OSPF.

bool FaceManager::set_all_nodes_addr ( OlsrTypes::FaceID  faceid,
const IPv4 all_nodes_addr 
)

Set the IPv4 all-nodes address of an interface.

Parameters:
faceidthe ID of Face to set all-nodes address for.
all_nodes_addrthe all-nodes address to set.
Returns:
true if the all-nodes address was set successfully, otherwise false.
bool FaceManager::set_all_nodes_port ( OlsrTypes::FaceID  faceid,
const uint16_t  all_nodes_port 
)

Set the UDP all-nodes port of an interface.

Parameters:
faceidthe ID of Face to set the all-nodes port for.
all_nodes_portthe all-nodes port to set.
Returns:
true if the all-nodes port was set successfully, otherwise false.
void FaceManager::set_dup_hold_time ( const TimeVal dup_hold_time)

Set the hold time for duplicate messages.

Note: This does not affect messages which are currently being tracked in the duplicate set.

Parameters:
dup_hold_timethe new hold time for duplicate messages.
bool FaceManager::set_face_enabled ( OlsrTypes::FaceID  faceid,
bool  enabled 
)

Enable the OLSR binding on the given interface.

This method is responsible for realizing the socket needed by the Face. If more than one interface is enabled, this method MAY start the MID protocol t imer.

void FaceManager::set_hello_interval ( const TimeVal interval)

Set the HELLO_INTERVAL protocol variable.

The HELLO timer will be rescheduled if running.

bool FaceManager::set_interface_cost ( OlsrTypes::FaceID  faceid,
const int  cost 
)

Set the cost of an OLSR interface.

Parameters:
faceidthe ID of Face to set cost for.
costthe cost to set.
Returns:
true if the cost was set successfully, otherwise false.
bool FaceManager::set_local_addr ( OlsrTypes::FaceID  faceid,
const IPv4 local_addr 
)

Set the IPv4 local address of an interface.

Parameters:
faceidthe ID of Face to set local address for.
local_addrthe local address to set.
Returns:
true if the local address was set successfully, otherwise false.
bool FaceManager::set_local_port ( OlsrTypes::FaceID  faceid,
const uint16_t  local_port 
)

Set the UDP local port of an interface.

Parameters:
faceidthe ID of Face to set local port for.
local_portthe local port to set.
Returns:
true if the local port was set successfully, otherwise false.
bool FaceManager::set_main_addr ( const IPv4 addr)

Attempt to set main address on node.

TODO: Track address changes on interfaces. TODO: Add a flag which does NOT allow the main address to automatically change when interfaces change.

This will fulfil the RFC requirement that the main address may never change, but will effectively halt olsr when the main address is set to an address we are not configured for.

void FaceManager::set_mid_interval ( const TimeVal interval)

Set the MID_INTERVAL protocol variable.

The timer will be rescheduled if it is running.

Parameters:
intervalthe new MID_INTERVAL.
bool FaceManager::transmit ( const string &  interface,
const string &  vif,
const IPv4 dst,
const uint16_t &  dport,
const IPv4 src,
const uint16_t &  sport,
uint8_t *  data,
const uint32_t &  len 
)

Transmit a datagram.

Parameters:
interfacethe interface to transmit from.
vifthe vif to transmit from.
dstthe IPv4 destination address to send to.
dportthe UDP destination port to send to.
srcthe IPv4 source address to transmit from.
sportthe UDP source port to transmit from.
datathe datagram to transmit.
lenthe length of the datagram to transmit.
Returns:
true if the datagram was sent OK, otherwise false.
void FaceManager::update_dupetuple ( const Message msg,
const bool  is_forwarded 
)

Update or create an entry in the duplicate message set.

Given a message, update or create its duplicate set tuple in order that we can detect if other nodes in the OLSR domain loop a message back to us. OLSR uses histogram based message loop detection, as the shortest path tree may be out of phase with the real network topology.

Parameters:
msgthe message itself.
is_forwardedtrue if the message will be forwarded.
void FaceManager::vif_status_change ( const string &  interface,
const string &  vif,
bool  state 
)

Callback method to: Process a change of vif status from the FEA.

Parameters:
interfacethe name of the affected interface.
vifthe name of the affected vif.
statethe new state of the vif.

Member Data Documentation

The DUP_HOLD_TIME protocol control variable.

Section 3.4.1: Default Forwarding Algorithm.

The HELLO_INTERVAL protocol control variable.

RFC 3626 Section 18.2.

The MID_INTERVAL protocol control variable.

RFC 3626 Section 18.2.


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