00001 /* 00002 * BundleStorage.cpp 00003 * 00004 * Created on: 24.03.2009 00005 * Author: morgenro 00006 */ 00007 00008 #include "core/BundleCore.h" 00009 #include "core/BundleStorage.h" 00010 #include "core/CustodyEvent.h" 00011 #include "routing/QueueBundleEvent.h" 00012 #include <ibrdtn/data/BundleID.h> 00013 00014 namespace dtn 00015 { 00016 namespace core 00017 { 00018 BundleStorage::BundleStorage() 00019 { 00020 } 00021 00022 BundleStorage::~BundleStorage() 00023 { 00024 } 00025 00026 void BundleStorage::remove(const dtn::data::Bundle &b) 00027 { 00028 remove(dtn::data::BundleID(b)); 00029 }; 00030 00031 void BundleStorage::acceptCustody(dtn::data::Bundle &bundle) 00032 { 00033 if (bundle._custodian == EID()) return; 00034 00035 if (bundle._procflags & Bundle::CUSTODY_REQUESTED) 00036 { 00037 // we are the new custodian for this bundle 00038 bundle._custodian = dtn::core::BundleCore::local; 00039 00040 // create a new bundle 00041 Bundle b; 00042 00043 // send a custody signal with accept flag 00044 CustodySignalBlock &signal = b.push_back<CustodySignalBlock>(); 00045 00046 // set the bundle to match 00047 signal.setMatch(bundle); 00048 00049 // set accepted 00050 signal._status |= 1; 00051 00052 b._destination = bundle._custodian; 00053 b._source = dtn::core::BundleCore::local; 00054 00055 // send the custody accepted bundle 00056 dtn::routing::QueueBundleEvent::raise(b); 00057 00058 // raise the custody accepted event 00059 dtn::core::CustodyEvent::raise(b, CUSTODY_ACCEPT); 00060 } 00061 } 00062 00063 void BundleStorage::rejectCustody(const dtn::data::Bundle &bundle) 00064 { 00065 if (bundle._custodian == EID()) return; 00066 00067 if (bundle._procflags & Bundle::CUSTODY_REQUESTED) 00068 { 00069 // create a new bundle 00070 Bundle b; 00071 00072 // send a custody signal with reject flag 00073 CustodySignalBlock &signal = b.push_back<CustodySignalBlock>(); 00074 00075 // set the bundle to match 00076 signal.setMatch(bundle); 00077 00078 b._destination = bundle._custodian; 00079 b._source = BundleCore::local; 00080 00081 // send the custody rejected bundle 00082 dtn::routing::QueueBundleEvent::raise(b); 00083 00084 // raise the custody rejected event 00085 dtn::core::CustodyEvent::raise(b, CUSTODY_REJECT); 00086 } 00087 } 00088 } 00089 }
1.6.3