#include <ForwardingLog.h>
Public Types | |
typedef ForwardingInfo::state_t | state_t |
typedef std::vector < ForwardingInfo > | Log |
Typedef for the log itself. | |
Public Member Functions | |
ForwardingLog (oasys::SpinLock *lock) | |
Constructor that takes a pointer to the relevant Bundle's lock, used when querying or updating the log. | |
bool | get_latest_entry (const LinkRef &link, ForwardingInfo *info) const |
Get the most recent entry for the given link from the log. | |
state_t | get_latest_entry (const LinkRef &link) const |
Get the most recent state for the given link from the log. | |
bool | get_latest_entry (const Registration *reg, ForwardingInfo *info) const |
Get the most recent entry for the given registration from the log. | |
state_t | get_latest_entry (const Registration *reg) const |
Get the most recent state for the given registration from the log. | |
bool | get_latest_entry (state_t state, ForwardingInfo *info) const |
Get the most recent entry for the given state from the log. | |
size_t | get_count (unsigned int states=ForwardingInfo::ANY_STATE, unsigned int actions=ForwardingInfo::ANY_ACTION) const |
Return the count of matching entries. | |
size_t | get_count (const EndpointID &eid, unsigned int states=ForwardingInfo::ANY_STATE, unsigned int actions=ForwardingInfo::ANY_ACTION) const |
Return the count of matching entries for the given remote endpoint id. | |
void | add_entry (const LinkRef &link, ForwardingInfo::action_t action, state_t state, const CustodyTimerSpec &custody_timer) |
Add a new forwarding info entry for the given link. | |
void | add_entry (const LinkRef &link, ForwardingInfo::action_t action, state_t state) |
Add a new forwarding info entry for the given link using the default custody timer info. | |
void | add_entry (const Registration *reg, ForwardingInfo::action_t action, state_t state) |
Add a new forwarding info entry for the given registration. | |
void | add_entry (const EndpointID &eid, ForwardingInfo::action_t action, state_t state) |
Add a new forwarding info entry for the remote EID without a specific link or registration. | |
bool | update (const LinkRef &link, state_t state) |
Update the state for the latest forwarding info entry for the given link. | |
void | update_all (state_t old_state, state_t new_state) |
Update all entries in the given state to the new state. | |
void | dump (oasys::StringBuffer *buf) const |
Dump a string representation of the log. | |
void | clear () |
Clear the log (used for testing). | |
Protected Attributes | |
Log | log_ |
The actual log. | |
oasys::SpinLock * | lock_ |
Copy of the bundle's lock. |
This state can be (and is) used by the router logic to prevent it from naively forwarding a bundle to the same next hop multiple times. It also is used to store the custody timer spec as supplied by the router so the main forwarding engine knows how to set the appropriate timer.
Although a bundle can be sent over multiple links, and may even be sent over the same link multiple times, the forwarding logic assumes that for a given link and bundle, there is only one active transmission. Thus the accessors below always return / update the last entry in the log for a given link.
Definition at line 52 of file ForwardingLog.h.
typedef std::vector<ForwardingInfo> dtn::ForwardingLog::Log |
Definition at line 54 of file ForwardingLog.h.
dtn::ForwardingLog::ForwardingLog | ( | oasys::SpinLock * | lock | ) |
Constructor that takes a pointer to the relevant Bundle's lock, used when querying or updating the log.
Definition at line 30 of file ForwardingLog.cc.
void dtn::ForwardingLog::add_entry | ( | const EndpointID & | eid, | |
ForwardingInfo::action_t | action, | |||
state_t | state | |||
) |
Add a new forwarding info entry for the remote EID without a specific link or registration.
(used for session management).
Also, if the EID is "*:*" and the state is SUPPRESSED, then the bundle can be prevented from being forwarded to any other nodes.
Definition at line 242 of file ForwardingLog.cc.
References dtn::EndpointID::c_str(), lock_, and log_.
void dtn::ForwardingLog::add_entry | ( | const Registration * | reg, | |
ForwardingInfo::action_t | action, | |||
state_t | state | |||
) |
Add a new forwarding info entry for the given registration.
Definition at line 227 of file ForwardingLog.cc.
References dtn::Registration::endpoint(), lock_, log_, and dtn::Registration::regid().
void dtn::ForwardingLog::add_entry | ( | const LinkRef & | link, | |
ForwardingInfo::action_t | action, | |||
state_t | state | |||
) |
Add a new forwarding info entry for the given link using the default custody timer info.
Used for states other than TRANSMITTED for which the custody timer is irrelevant.
Definition at line 217 of file ForwardingLog.cc.
References add_entry().
void dtn::ForwardingLog::add_entry | ( | const LinkRef & | link, | |
ForwardingInfo::action_t | action, | |||
state_t | state, | |||
const CustodyTimerSpec & | custody_timer | |||
) |
Add a new forwarding info entry for the given link.
Definition at line 204 of file ForwardingLog.cc.
Referenced by add_entry(), dtn::TableBasedRouter::add_subscriber(), dtn::BundleDaemon::deliver_to_registration(), dtn::BundleDaemon::handle_bundle_received(), dtn::DTLSRRouter::handle_lsa(), dtn::TableBasedRouter::handle_session_bundle(), dtn::BundleActions::queue_bundle(), and dtn::DTLSRRouter::update_current_lsa().
void dtn::ForwardingLog::clear | ( | ) |
void dtn::ForwardingLog::dump | ( | oasys::StringBuffer * | buf | ) | const |
Dump a string representation of the log.
Definition at line 180 of file ForwardingLog.cc.
References dtn::ForwardingInfo::action(), dtn::ForwardingInfo::action_to_str(), dtn::EndpointID::c_str(), dtn::ForwardingInfo::custody_spec(), info, dtn::CustodyTimerSpec::lifetime_pct_, dtn::ForwardingInfo::link_name(), lock_, log_, dtn::CustodyTimerSpec::max_, dtn::CustodyTimerSpec::min_, dtn::ForwardingInfo::remote_eid(), dtn::ForwardingInfo::state(), dtn::ForwardingInfo::state_to_str(), and dtn::ForwardingInfo::timestamp().
Referenced by dtn::Bundle::format_verbose(), and dtn::BundleDaemon::handle_bundle_transmitted().
size_t dtn::ForwardingLog::get_count | ( | const EndpointID & | eid, | |
unsigned int | states = ForwardingInfo::ANY_STATE , |
|||
unsigned int | actions = ForwardingInfo::ANY_ACTION | |||
) | const |
Return the count of matching entries for the given remote endpoint id.
The states and actions parameters should contain a concatenation of the requested states/actions to filter the count.
Definition at line 155 of file ForwardingLog.cc.
References lock_, log_, and dtn::EndpointIDPattern::WILDCARD_EID().
size_t dtn::ForwardingLog::get_count | ( | unsigned int | states = ForwardingInfo::ANY_STATE , |
|
unsigned int | actions = ForwardingInfo::ANY_ACTION | |||
) | const |
Return the count of matching entries.
The states and actions parameters should contain a concatenation of the requested states/actions to filter the count.
Definition at line 133 of file ForwardingLog.cc.
Referenced by dtn::TableBasedRouter::route_bundle(), and dtn::BundleRouter::should_fwd().
bool dtn::ForwardingLog::get_latest_entry | ( | state_t | state, | |
ForwardingInfo * | info | |||
) | const |
Get the most recent entry for the given state from the log.
Definition at line 113 of file ForwardingLog.cc.
ForwardingLog::state_t dtn::ForwardingLog::get_latest_entry | ( | const Registration * | reg | ) | const |
Get the most recent state for the given registration from the log.
Definition at line 101 of file ForwardingLog.cc.
References get_latest_entry(), info, dtn::ForwardingInfo::NONE, and dtn::ForwardingInfo::state().
bool dtn::ForwardingLog::get_latest_entry | ( | const Registration * | reg, | |
ForwardingInfo * | info | |||
) | const |
Get the most recent entry for the given registration from the log.
Definition at line 74 of file ForwardingLog.cc.
References ASSERT, dtn::Registration::endpoint(), lock_, log_, dtn::EndpointID::NULL_EID(), and dtn::Registration::regid().
ForwardingLog::state_t dtn::ForwardingLog::get_latest_entry | ( | const LinkRef & | link | ) | const |
Get the most recent state for the given link from the log.
Definition at line 62 of file ForwardingLog.cc.
References get_latest_entry(), info, dtn::ForwardingInfo::NONE, and dtn::ForwardingInfo::state().
bool dtn::ForwardingLog::get_latest_entry | ( | const LinkRef & | link, | |
ForwardingInfo * | info | |||
) | const |
Get the most recent entry for the given link from the log.
Definition at line 37 of file ForwardingLog.cc.
References ASSERT, lock_, log_, and dtn::EndpointID::NULL_EID().
Referenced by dtn::BundleDaemon::deliver_to_registration(), get_latest_entry(), dtn::BundleDaemon::handle_bundle_transmitted(), dtn::DTLSRRouter::handle_lsa(), dtn::BundleActions::queue_bundle(), and dtn::BundleRouter::should_fwd().
Update the state for the latest forwarding info entry for the given link.
Definition at line 257 of file ForwardingLog.cc.
References ASSERT, lock_, log_, and dtn::EndpointID::NULL_EID().
Referenced by dtn::BundleDaemon::handle_bundle_cancelled(), dtn::BundleDaemon::handle_bundle_transmitted(), and dtn::BundleDaemon::handle_custody_timeout().
Update all entries in the given state to the new state.
Definition at line 281 of file ForwardingLog.cc.
oasys::SpinLock* dtn::ForwardingLog::lock_ [protected] |
Copy of the bundle's lock.
Definition at line 171 of file ForwardingLog.h.
Referenced by add_entry(), clear(), dump(), get_count(), get_latest_entry(), update(), and update_all().
Log dtn::ForwardingLog::log_ [protected] |
The actual log.
Definition at line 170 of file ForwardingLog.h.
Referenced by add_entry(), clear(), dump(), get_count(), get_latest_entry(), update(), and update_all().