Hello, In your previous email you mentioned using getData() to get the BLOB::reference out of a bundle. Right now I am trying to work with bundles that are received.fromlocal (which I assume is the data sent in through the api) but since these come from the data namespace I can't access them the way you do for bundles in the api name space. Maybe I'm just confused on how the name spaces work, but is there a way to get the same information you mentioned from the data namespace bundles? Thanks
Carson Dunbar
On Mon, Nov 7, 2011 at 11:13 AM, Johannes Morgenroth < morgenro@ibr.cs.tu-bs.de> wrote:
Am 07.11.2011 16:59, schrieb Carson Dunbar:
If I do have a bundle, let's say the received.bundle from local, is there a way to split up its payload into smaller payloads and make each new payload its own bundle? My objective is to send in a file and then break it up into smaller payloads then choose among them to send to other nodes.
If the received.bundle variable is a object of type dtn::data::Bundle (if not you have to load the bundle from the database first) you can access the payload like this:
dtn::data::PayloadBlock &payload = bundle.getBlockdtn::data::PayloadBlock();
To get the data itself you need to allocate and lock the stream associated with it...
// get BLOB reference ibrcommon::BLOB::Reference ref = b.getData();
// lock the stream - while we are between the curlies, the stream is locked. { ibrcommon::BLOB::iostream stream = ref.iostream(); [ ... read from / write to the stream .... ] }
Once you got the stream you can do standard C++ streaming operations on it. In your case I would read the from the stream continuously and generate a bundle for each chunk while reading the stream.
Kind regards, Johannes
-- Johannes Morgenroth Institut fuer Betriebssysteme und Rechnerverbund Tel.: +49-531-391-3249 Muehlenpfordtstrasse 23 Fax.: +49-531-391-5936 TU Braunschweig D-38106 Braunschweig
-- !! This message is brought to you via the `ibr-dtn' mailing list. !! Please do not reply to this message to unsubscribe. To unsubscribe or adjust !! your settings, send a mail message to ibr-dtn-request@ibr.cs.tu-bs.de !! or look at https://www.ibr.cs.tu-bs.de/mailman/listinfo/ibr-dtn.