IBR-DTNSuite
0.12
Main Page
Namespaces
Classes
Files
File List
File Members
IBR-DTNSuite
Namespaces
Classes
Files
File List
daemon
ibrcommon
ibrdtn
tools
src
io
streaming
BundleStream.cpp
BundleStream.h
BundleStreamBuf.cpp
BundleStreamBuf.h
StreamBundle.cpp
StreamBundle.h
config.h
dtnconvert.cpp
dtninbox.cpp
dtnoutbox.cpp
dtnping.cpp
dtnrecv.cpp
dtnsend.cpp
dtnstream.cpp
dtntracepath.cpp
dtntrigger.cpp
dtntunnel.cpp
File Members
BundleStream.cpp
Go to the documentation of this file.
1
/*
2
* BundleStream.cpp
3
*
4
* Copyright (C) 2011 IBR, TU Braunschweig
5
*
6
* Written-by: Johannes Morgenroth <morgenroth@ibr.cs.tu-bs.de>
7
*
8
* Licensed under the Apache License, Version 2.0 (the "License");
9
* you may not use this file except in compliance with the License.
10
* You may obtain a copy of the License at
11
*
12
* http://www.apache.org/licenses/LICENSE-2.0
13
*
14
* Unless required by applicable law or agreed to in writing, software
15
* distributed under the License is distributed on an "AS IS" BASIS,
16
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
* See the License for the specific language governing permissions and
18
* limitations under the License.
19
*
20
*/
21
22
#include <
streaming/BundleStream.h
>
23
#include <
ibrdtn/data/StatusReportBlock.h
>
24
25
BundleStream::BundleStream
(
ibrcommon::socketstream
&stream,
size_t
min_chunk_size,
size_t
max_chunk_size,
const
std::string &app,
const
dtn::data::EID
&
group
,
bool
wait_seq_zero)
26
: dtn::api::Client(app, group, stream), _stream(stream), _buf(*this, _chunk, min_chunk_size, max_chunk_size, wait_seq_zero), _auto_flush(false)
27
{}
28
29
BundleStream::~BundleStream
() {}
30
31
BundleStreamBuf
&
BundleStream::rdbuf
()
32
{
33
return
_buf;
34
}
35
36
dtn::data::Bundle
&
BundleStream::base
()
37
{
38
return
_chunk;
39
}
40
41
void
BundleStream::setAutoFlush
(
bool
val)
42
{
43
_auto_flush = val;
44
_buf.
setRequestAck
(val);
45
}
46
47
void
BundleStream::setReceiveTimeout
(
unsigned
int
timeout)
48
{
49
_buf.
setReceiveTimeout
(timeout);
50
}
51
52
void
BundleStream::received
(
const
dtn::data::Bundle
&b)
53
{
54
// check if the received bundle contains an administrative record
55
if
(b.
get
(
dtn::data::PrimaryBlock::APPDATA_IS_ADMRECORD
))
56
{
57
// get the payload block of the bundle
58
const
dtn::data::PayloadBlock
&payload = b.
find
<
dtn::data::PayloadBlock
>();
59
60
try
{
61
// try to decode as status report
62
dtn::data::StatusReportBlock
report;
63
report.
read
(payload);
64
65
// check if the received report matches a newer bundle
66
if
((_last_delivery_ack.
source
==
dtn::data::EID
()) || (report.
bundleid
> _last_delivery_ack))
67
{
68
// store the received ack
69
_last_delivery_ack = report.
bundleid
;
70
71
// flush the buffer
72
_buf.
flush
();
73
}
74
75
return
;
76
}
catch
(
const
dtn::data::StatusReportBlock::WrongRecordException
&) {
77
// this is not a status report
78
}
79
return
;
80
}
81
82
// forward received bundles to the BundleStreamBuf
83
_buf.
received
(b);
84
}
tools
src
streaming
BundleStream.cpp
Generated on Thu Mar 27 2014 09:26:21 for IBR-DTNSuite by
1.8.4