IBR-DTNSuite
0.12
Main Page
Namespaces
Classes
Files
File List
File Members
Node.h
Go to the documentation of this file.
1
/*
2
* Node.h
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
#ifndef IBRDTN_DAEMON_NODE_H_
23
#define IBRDTN_DAEMON_NODE_H_
24
25
#include <string>
26
#include <
ibrdtn/data/EID.h
>
27
#include <set>
28
#include <list>
29
#include <iostream>
30
31
namespace
dtn
32
{
33
namespace
net
34
{
35
class
ConvergenceLayer
;
36
}
37
38
namespace
core
39
{
43
class
Node
44
{
45
public
:
46
enum
Protocol
47
{
48
CONN_UNSUPPORTED
= -1,
49
CONN_UNDEFINED
= 0,
50
CONN_TCPIP
= 1,
51
CONN_UDPIP
= 2,
52
CONN_LOWPAN
= 3,
53
CONN_BLUETOOTH
= 4,
54
CONN_HTTP
= 5,
55
CONN_FILE
= 6,
56
CONN_DGRAM_UDP
= 7,
57
CONN_DGRAM_LOWPAN
= 8,
58
CONN_DGRAM_ETHERNET
= 9,
59
CONN_P2P_WIFI
= 10,
60
CONN_P2P_BT
= 11,
61
CONN_EMAIL
= 12
62
};
63
70
enum
Type
71
{
72
NODE_UNAVAILABLE
= 0,
73
NODE_CONNECTED
= 1,
74
NODE_DISCOVERED
= 2,
75
NODE_STATIC_GLOBAL
= 3,
76
NODE_STATIC_LOCAL
= 4,
77
NODE_DHT_DISCOVERED
= 5,
78
NODE_P2P_DIALUP
= 6
79
};
80
81
class
URI
82
{
83
public
:
84
URI
(
const
Type
t,
const
Protocol
proto,
const
std::string &uri,
const
dtn::data::Number
&timeout = 0,
const
int
priority
= 0);
85
~URI
();
86
87
Type
type
;
88
Protocol
protocol
;
89
std::string
value
;
90
dtn::data::Timestamp
expire
;
91
int
priority
;
92
93
void
decode
(std::string &address,
unsigned
int
&port)
const
;
94
95
bool
operator<
(
const
URI
&other)
const
;
96
bool
operator==
(
const
URI
&other)
const
;
97
98
bool
operator==
(
const
Node::Protocol
&p)
const
;
99
bool
operator==
(
const
Node::Type
&t)
const
;
100
101
friend
std::ostream&
operator<<
(std::ostream&,
const
Node::URI
&);
102
};
103
104
class
Attribute
105
{
106
public
:
107
Attribute
(
const
Type
t,
const
std::string &
name
,
const
std::string &
value
,
const
dtn::data::Number
&timeout = 0,
const
int
priority
= 0);
108
~Attribute
();
109
110
Type
type
;
111
std::string
name
;
112
std::string
value
;
113
dtn::data::Timestamp
expire
;
114
int
priority
;
115
116
bool
operator<
(
const
Attribute
&other)
const
;
117
bool
operator==
(
const
Attribute
&other)
const
;
118
119
bool
operator==
(
const
std::string &name)
const
;
120
121
friend
std::ostream&
operator<<
(std::ostream&,
const
Node::Attribute
&);
122
};
123
124
static
std::string
toString
(
const
Node::Type
type);
125
static
std::string
toString
(
const
Node::Protocol
proto);
126
static
Node::Protocol
fromProtocolString
(
const
std::string &protocol);
127
133
Node
(
const
dtn::data::EID
&
id
);
134
Node
();
135
139
virtual
~Node
();
140
146
bool
has
(
Node::Protocol
proto)
const
;
147
bool
has
(
const
std::string &name)
const
;
148
153
void
add
(
const
URI
&u);
154
void
add
(
const
Attribute
&attr);
155
160
void
remove
(
const
URI
&u);
161
void
remove
(
const
Attribute
&attr);
162
166
void
clear
();
167
171
dtn::data::Size
size
()
const
;
172
178
std::list<URI>
get
(
Node::Protocol
proto)
const
;
179
std::list<URI>
get
(
Node::Type
type)
const
;
180
std::list<URI>
get
(
Node::Type
type,
Node::Protocol
proto)
const
;
181
185
std::list<Node::URI>
getAll
()
const
;
186
190
std::set<Node::Type>
getTypes
()
const
;
191
197
std::list<Attribute>
get
(
const
std::string &name)
const
;
198
203
const
dtn::data::EID
&
getEID
()
const
;
204
208
bool
expire
();
209
216
bool
operator==
(
const
Node
&other)
const
;
217
bool
operator<
(
const
Node
&other)
const
;
218
219
bool
operator==
(
const
dtn::data::EID
&other)
const
;
220
221
const
Node
&
operator+=
(
const
Node
&other);
222
const
Node
&
operator-=
(
const
Node
&other);
223
224
std::string
toString
()
const
;
225
226
bool
doConnectImmediately
()
const
;
227
void
setConnectImmediately
(
bool
val);
228
232
bool
hasDialup
()
const
;
233
237
bool
isAvailable
()
const
;
238
242
bool
isAnnounced
()
const
;
243
247
void
setAnnounced
(
bool
val);
248
249
friend
std::ostream&
operator<<
(std::ostream&,
const
Node
&);
250
251
private
:
252
bool
isAvailable
(
const
Node::URI
&uri)
const
;
253
254
bool
_connect_immediately;
255
dtn::data::EID
_id;
256
257
std::set<URI> _uri_list;
258
std::set<Attribute> _attr_list;
259
260
bool
_announced_mark;
261
};
262
}
263
}
264
265
#endif
/*IBRDTN_DAEMON_NODE_H_*/
daemon
src
core
Node.h
Generated on Thu Mar 27 2014 09:26:20 for IBR-DTNSuite by
1.8.4