00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include <iostream>
00044 #include "BundleEvent.h"
00045 #include "BundleDaemon.h"
00046 #include <routing/RouteTable.h>
00047 #include <contacts/Contact.h>
00048 #include <contacts/ContactManager.h>
00049 #include <reg/Registration.h>
00050 #include <oasys/util/StringBuffer.h>
00051
00052 namespace dtn {
00053
00054 void
00055 BundleReceivedEvent::serialize(oasys::SerializeAction *a)
00056 {
00057 a->process("source", &source_);
00058 a->process("bytes_received", &bytes_received_);
00059 a->process("bundle", bundleref_.object());
00060 }
00061
00062 void
00063 BundleTransmittedEvent::serialize(oasys::SerializeAction *a)
00064 {
00065 a->process("bytes_sent", &bytes_sent_);
00066 a->process("reliably_sent", &reliably_sent_);
00067 a->process("bundle", bundleref_.object());
00068 a->process("contact", contact_.object());
00069 a->process("link", link_);
00070 }
00071
00072 void
00073 BundleTransmitFailedEvent::serialize(oasys::SerializeAction *a)
00074 {
00075 a->process("bundle", bundleref_.object());
00076 a->process("contact", contact_.object());
00077 a->process("link", link_);
00078 }
00079
00080 void
00081 BundleDeliveryEvent::serialize(oasys::SerializeAction *a)
00082 {
00083 a->process("source", &source_);
00084 a->process("bundle", bundleref_.object());
00085 }
00086
00087 void
00088 BundleExpiredEvent::serialize(oasys::SerializeAction *a)
00089 {
00090 a->process("bundle", bundleref_.object());
00091 }
00092
00093 void
00094 BundleSendRequest::serialize(oasys::SerializeAction* a)
00095 {
00096 a->process("bundleid", &bundleid_);
00097 a->process("link", &link_);
00098 a->process("fwd_action", &action_);
00099 }
00100
00101 void
00102 BundleCancelRequest::serialize(oasys::SerializeAction* a)
00103 {
00104 a->process("bundleid", &bundleid_);
00105 a->process("link", &link_);
00106 }
00107
00108 void
00109 BundleInjectRequest::serialize(oasys::SerializeAction* a)
00110 {
00111 a->process("source", &src_);
00112 a->process("dest", &dest_);
00113 a->process("replyto", &replyto_);
00114 a->process("custodian", &custodian_);
00115 a->process("link", &link_);
00116 a->process("fwd_action", &action_);
00117 a->process("priority", &priority_);
00118 a->process("expiration", &expiration_);
00119 a->process("payload", &payload_);
00120 }
00121
00122 void
00123 BundleAcceptRequest::serialize(oasys::SerializeAction *a)
00124 {
00125
00126
00127 a->process("source", &source_);
00128 a->process("bundle", bundle_.object());
00129 }
00130
00131 void
00132 BundleReportEvent::serialize(oasys::SerializeAction *a)
00133 {
00134 BundleDaemon *bd = BundleDaemon::instance();
00135
00136
00137 const BundleList *bundles = bd->pending_bundles();
00138 BundleList::const_iterator j;
00139
00140 oasys::ScopeLock l(bd->pending_bundles()->lock(),
00141 "BundleEvent::BundleReportEvent");
00142
00143 for(j = bundles->begin(); j != bundles->end(); ++j)
00144 a->process("bundle", *j);
00145
00146 l.unlock();
00147
00148
00149 oasys::ScopeLock m(bd->custody_bundles()->lock(),
00150 "BundleEvent::BundleReportEvent");
00151
00152 bundles = bd->custody_bundles();
00153 BundleList::const_iterator k;
00154
00155 for(k = bundles->begin(); k != bundles->end(); ++k) {
00156 a->process("bundle", *k);
00157 }
00158 }
00159
00160 void
00161 ContactUpEvent::serialize(oasys::SerializeAction *a)
00162 {
00163 a->process("contact", contact_.object());
00164 }
00165
00166 void
00167 ContactDownEvent::serialize(oasys::SerializeAction *a)
00168 {
00169 a->process("reason", &reason_);
00170 a->process("contact", contact_.object());
00171 }
00172
00173 void
00174 ContactReportEvent::serialize(oasys::SerializeAction *a)
00175 {
00176 BundleDaemon *bd = BundleDaemon::instance();
00177 oasys::ScopeLock l(bd->contactmgr()->lock(),
00178 "BundleEvent::ContactReportEvent");
00179
00180 const LinkSet *links = bd->contactmgr()->links();
00181 LinkSet::const_iterator j;
00182
00183 for(j = links->begin(); j != links->end(); ++j) {
00184 if ((*j)->contact() != NULL) {
00185 a->process("contact", (*j)->contact().object());
00186 }
00187 }
00188 }
00189
00190 void
00191 LinkCreatedEvent::serialize(oasys::SerializeAction *a)
00192 {
00193 a->process("reason", &reason_);
00194 a->process("link", link_);
00195 }
00196
00197 void
00198 LinkDeletedEvent::serialize(oasys::SerializeAction *a)
00199 {
00200 a->process("reason", &reason_);
00201 a->process("link", link_);
00202 }
00203
00204 void
00205 LinkAvailableEvent::serialize(oasys::SerializeAction *a)
00206 {
00207 a->process("reason", &reason_);
00208 a->process("link", link_);
00209 }
00210
00211 void
00212 LinkUnavailableEvent::serialize(oasys::SerializeAction *a)
00213 {
00214 a->process("reason", &reason_);
00215 a->process("link", link_);
00216 }
00217
00218 void
00219 LinkReportEvent::serialize(oasys::SerializeAction *a)
00220 {
00221 BundleDaemon *bd = BundleDaemon::instance();
00222 oasys::ScopeLock l(bd->contactmgr()->lock(),
00223 "BundleEvent::LinkReportEvent");
00224
00225 const LinkSet *links = bd->contactmgr()->links();
00226 LinkSet::const_iterator j;
00227
00228 for(j = links->begin(); j != links->end(); ++j) {
00229 a->process("link", *j);
00230 }
00231 }
00232
00233 void
00234 LinkStateChangeRequest::serialize(oasys::SerializeAction* a)
00235 {
00236 if (a->action_code() == oasys::Serialize::UNMARSHAL) {
00237 std::string link;
00238 a->process("link", &link);
00239
00240 BundleDaemon *bd = BundleDaemon::instance();
00241 link_ = bd->contactmgr()->find_link(link.c_str());
00242
00243 if (link_) {
00244 contact_ = link_->contact();
00245 old_state_ = link_->state();
00246 }
00247 }
00248 }
00249
00250 void
00251 RegistrationAddedEvent::serialize(oasys::SerializeAction *a)
00252 {
00253 a->process("registration", registration_);
00254 a->process("source", &source_);
00255 }
00256
00257 void
00258 RegistrationRemovedEvent::serialize(oasys::SerializeAction *a)
00259 {
00260 a->process("registration", registration_);
00261 }
00262
00263 void
00264 RegistrationExpiredEvent::serialize(oasys::SerializeAction *a)
00265 {
00266 a->process("regid", ®id_);
00267 }
00268
00269 void
00270 RouteAddEvent::serialize(oasys::SerializeAction *a)
00271 {
00272 a->process("route_entry", entry_);
00273 }
00274
00275 void
00276 RouteDelEvent::serialize(oasys::SerializeAction *a)
00277 {
00278 a->process("dest", const_cast< std::string * >(&dest_.str()));
00279 }
00280
00281 void
00282 CustodySignalEvent::serialize(oasys::SerializeAction *a)
00283 {
00284 a->process("admin_type", &data_.admin_type_);
00285 a->process("admin_flags", &data_.admin_flags_);
00286 a->process("succeeded", &data_.succeeded_);
00287 a->process("reason", &data_.reason_);
00288 a->process("orig_frag_offset", &data_.orig_frag_offset_);
00289 a->process("orig_frag_length", &data_.orig_frag_length_);
00290 a->process("custody_signal_seconds", &data_.custody_signal_tv_.seconds_);
00291 a->process("custody_signal_seqno", &data_.custody_signal_tv_.seqno_);
00292 a->process("orig_creation_seconds", &data_.orig_creation_tv_.seconds_);
00293 a->process("orig_creation_seqno", &data_.orig_creation_tv_.seqno_);
00294 a->process("orig_source_eid",
00295 const_cast< std::string * >(&data_.orig_source_eid_.str()));
00296 }
00297
00298 void
00299 CustodyTimeoutEvent::serialize(oasys::SerializeAction *a)
00300 {
00301 a->process("bundle", bundle_.object());
00302 a->process("link", link_);
00303 }
00304
00305 }