|
xorp
|
Class which manages all interface bindings in the OLSR routing process. More...
#include <face_manager.hh>
Public Member Functions | |
| FaceManager (Olsr &olsr, EventLoop &ev) | |
| MessageDecoder & | message_decoder () |
| Neighborhood * | neighborhood () |
| void | set_neighborhood (Neighborhood *nh) |
| uint32_t | get_face_count () const |
| const Face * | get_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. | |
| DupeTuple * | 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. | |
| 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. | |
Class which manages all interface bindings in the OLSR routing process.
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.
| 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.
| cb | the message receive callback function to register. |
| void FaceManager::address_status_change | ( | const string & | interface, |
| const string & | vif, | ||
| IPv4 | addr, | ||
| bool | state | ||
| ) |
| OlsrTypes::FaceID FaceManager::create_face | ( | const string & | interface, |
| const string & | vif | ||
| ) | throw (BadFace) |
| bool FaceManager::delete_face | ( | OlsrTypes::FaceID | faceid | ) |
| bool FaceManager::delete_message_cb | ( | MessageReceiveCB | cb | ) |
Deregister an OLSR protocol message handler.
| cb | the message receive callback function to deregister. |
| bool FaceManager::flood_message | ( | Message * | message | ) |
Flood a message on all interfaces, performing appropriate fragmentation for each interface.
| message | The message to flood, will be deleted by this method. |
Implement the Default Forwarding Algorithm (Section 3.4.1).
| remote_addr | the 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. |
| msg | the message itself. |
| 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.
| faceid | the ID of Face to get all-nodes address for. |
| all_nodes_addr | output variable which will contain the all-nodes address. |
| bool FaceManager::get_all_nodes_port | ( | OlsrTypes::FaceID | faceid, |
| uint16_t & | all_nodes_port | ||
| ) |
| TimeVal FaceManager::get_dup_hold_time | ( | ) | const [inline] |
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.
| uint32_t FaceManager::get_enabled_face_count | ( | ) | const [inline] |
| const Face * FaceManager::get_face_by_id | ( | const OlsrTypes::FaceID | faceid | ) | const throw (BadFace) |
| uint32_t FaceManager::get_face_count | ( | ) | const [inline] |
| bool FaceManager::get_face_enabled | ( | OlsrTypes::FaceID | faceid | ) |
| void FaceManager::get_face_list | ( | list< OlsrTypes::FaceID > & | face_list | ) | const |
Fill out a list of all face IDs.
| face_list | the list to fill out. |
| bool FaceManager::get_face_stats | ( | const string & | ifname, |
| const string & | vifname, | ||
| FaceCounters & | stats | ||
| ) |
| OlsrTypes::FaceID FaceManager::get_faceid | ( | const string & | interface, |
| const string & | vif | ||
| ) | throw (BadFace) |
| bool FaceManager::get_interface_cost | ( | OlsrTypes::FaceID | faceid, |
| int & | cost | ||
| ) |
| bool FaceManager::get_interface_vif_by_faceid | ( | OlsrTypes::FaceID | faceid, |
| string & | interface, | ||
| string & | vif | ||
| ) |
| bool FaceManager::get_local_addr | ( | OlsrTypes::FaceID | faceid, |
| IPv4 & | local_addr | ||
| ) |
| bool FaceManager::get_local_port | ( | OlsrTypes::FaceID | faceid, |
| uint16_t & | local_port | ||
| ) |
| TimeVal FaceManager::get_mid_hold_time | ( | ) | const [inline] |
| TimeVal FaceManager::get_mid_interval | ( | ) | const [inline] |
| uint16_t FaceManager::get_msg_seqno | ( | ) | [inline] |
| bool FaceManager::is_duplicate_message | ( | const Message * | msg | ) | const |
Check if a message is a previously seen duplicate.
| bool FaceManager::is_forwarded_message | ( | const Message * | msg | ) | const |
| bool FaceManager::is_local_addr | ( | const IPv4 & | addr | ) |
| 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.
| interface | the interface where the datagram was received. |
| vif | the vif where the datagram was received. |
| dst | the IPv4 destination address of the datagram. |
| dport | the UDP destination port of the datagram. |
| src | the IPv4 source address of the datagram. |
| sport | the UDP source port of the datagram. |
| data | the received datagram. |
| len | the 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.
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 | ||
| ) |
| bool FaceManager::set_all_nodes_port | ( | OlsrTypes::FaceID | faceid, |
| const uint16_t | all_nodes_port | ||
| ) |
| void FaceManager::set_dup_hold_time | ( | const TimeVal & | dup_hold_time | ) |
| bool FaceManager::set_face_enabled | ( | OlsrTypes::FaceID | faceid, |
| bool | enabled | ||
| ) |
| 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 | ||
| ) |
| bool FaceManager::set_local_addr | ( | OlsrTypes::FaceID | faceid, |
| const IPv4 & | local_addr | ||
| ) |
| bool FaceManager::set_local_port | ( | OlsrTypes::FaceID | faceid, |
| const uint16_t | local_port | ||
| ) |
| 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 | ) |
| 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.
| interface | the interface to transmit from. |
| vif | the vif to transmit from. |
| dst | the IPv4 destination address to send to. |
| dport | the UDP destination port to send to. |
| src | the IPv4 source address to transmit from. |
| sport | the UDP source port to transmit from. |
| data | the datagram to transmit. |
| len | the length of the datagram to transmit. |
| 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.
| void FaceManager::vif_status_change | ( | const string & | interface, |
| const string & | vif, | ||
| bool | state | ||
| ) |
TimeVal FaceManager::_dup_hold_time [private] |
The DUP_HOLD_TIME protocol control variable.
Section 3.4.1: Default Forwarding Algorithm.
TimeVal FaceManager::_hello_interval [private] |
The HELLO_INTERVAL protocol control variable.
RFC 3626 Section 18.2.
TimeVal FaceManager::_mid_interval [private] |
The MID_INTERVAL protocol control variable.
RFC 3626 Section 18.2.