IBR-DTNSuite
0.12
Main Page
Namespaces
Classes
Files
File List
File Members
DiscoveryAgent.h
Go to the documentation of this file.
1
/*
2
* DiscoveryAgent.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 DISCOVERYAGENT_H_
23
#define DISCOVERYAGENT_H_
24
25
#include "
Configuration.h
"
26
#include "
Component.h
"
27
#include "
core/EventReceiver.h
"
28
#include "
core/Node.h
"
29
#include "
net/DiscoveryBeacon.h
"
30
#include "
net/DiscoveryBeaconHandler.h
"
31
#include "
net/DiscoveryService.h
"
32
33
#include <
ibrdtn/data/Number.h
>
34
#include <
ibrcommon/net/vinterface.h
>
35
36
#include <list>
37
38
namespace
dtn
39
{
40
namespace
net
41
{
42
class
DiscoveryAgent
:
public
dtn::core::EventReceiver
,
public
dtn::daemon::IntegratedComponent
43
{
44
public
:
45
DiscoveryAgent
();
46
virtual
~DiscoveryAgent
();
47
51
void
raiseEvent
(
const
dtn::core::Event
*evt)
throw
();
52
53
void
onBeaconReceived
(
const
DiscoveryBeacon
&beacon);
54
55
void
registerService
(
const
ibrcommon::vinterface
&iface,
dtn::net::DiscoveryBeaconHandler
*handler);
56
void
registerService
(
dtn::net::DiscoveryBeaconHandler
*handler);
57
58
void
unregisterService
(
const
ibrcommon::vinterface
&iface,
const
dtn::net::DiscoveryBeaconHandler
*handler);
59
void
unregisterService
(
const
dtn::net::DiscoveryBeaconHandler
*handler);
60
61
DiscoveryBeacon
obtainBeacon
()
const
;
62
63
protected
:
64
virtual
void
componentUp
()
throw
();
65
virtual
void
componentDown
()
throw
();
66
67
virtual
const
std::string
getName
()
const
;
68
69
private
:
70
void
onAdvertise();
71
72
const
dtn::daemon::Configuration::Discovery
&_config;
73
74
bool
_enabled;
75
uint16_t _sn;
76
dtn::data::Timestamp
_adv_next;
77
dtn::data::Timestamp
_last_announce_sent;
78
79
ibrcommon::Mutex
_provider_lock;
80
81
typedef
std::list<dtn::net::DiscoveryBeaconHandler*> handler_list;
82
typedef
std::map<ibrcommon::vinterface, handler_list> handler_map;
83
typedef
std::pair<ibrcommon::vinterface, handler_list> handler_map_entry;
84
85
handler_map _providers;
86
87
const
ibrcommon::vinterface
_any_iface;
88
};
89
}
90
}
91
92
#endif
/* DISCOVERYAGENT_H_ */
daemon
src
net
DiscoveryAgent.h
Generated on Thu Mar 27 2014 09:26:20 for IBR-DTNSuite by
1.8.4