source: source/ariba/AribaModule.h@ 10006

Last change on this file since 10006 was 9686, checked in by mies, 14 years ago

put protlib doc to protlib module

File size: 7.7 KB
Line 
1// [License]
2// The Ariba-Underlay Copyright
3//
4// Copyright (c) 2008-2009, Institute of Telematics, UniversitÀt Karlsruhe (TH)
5//
6// Institute of Telematics
7// UniversitÀt Karlsruhe (TH)
8// Zirkel 2, 76128 Karlsruhe
9// Germany
10//
11// Redistribution and use in source and binary forms, with or without
12// modification, are permitted provided that the following conditions are
13// met:
14//
15// 1. Redistributions of source code must retain the above copyright
16// notice, this list of conditions and the following disclaimer.
17// 2. Redistributions in binary form must reproduce the above copyright
18// notice, this list of conditions and the following disclaimer in the
19// documentation and/or other materials provided with the distribution.
20//
21// THIS SOFTWARE IS PROVIDED BY THE INSTITUTE OF TELEMATICS ``AS IS'' AND
22// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ARIBA PROJECT OR
25// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
28// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32//
33// The views and conclusions contained in the software and documentation
34// are those of the authors and should not be interpreted as representing
35// official policies, either expressed or implied, of the Institute of
36// Telematics.
37// [License]
38
39#ifndef ARIBAMODULE_H_
40#define ARIBAMODULE_H_
41
42#include <string>
43#include <vector>
44#include <ctime>
45#include <cstdlib>
46#include <algorithm>
47
48using std::vector;
49using std::string;
50
51// forward declaration
52namespace ariba {
53 class AribaModule;
54 class SideportListener;
55}
56
57// local includes
58#include "Name.h"
59#include "Module.h"
60
61namespace ariba {
62
63// forward declaration
64namespace communication {
65 class EndpointDescriptor;
66 class BaseCommunication;
67}
68
69/** \addtogroup public
70 * @{
71 * This class implements a container class for ariba base services. Each node
72 * is a running using this base-module. It also manages Bootstrap information
73 * in a abstract simple way.
74 *
75 * +---+ +---+
76 * |N1 | |N2 |
77 * +--| |---| |--+
78 * | +---+ +---+ |
79 * | |
80 * | AribaModule |
81 * +-----------------+
82 *
83 * N1, N2 are nodes.
84 *
85 * @author Sebastian Mies <mies@tm.uka.de>
86 * @author Christoph Mayer <mayer@tm.uka.de>
87 */
88class AribaModule: public Module {
89 friend class Node;
90 use_logging_h(AribaModule);
91public:
92 /**
93 * Constructor of the ariba underlay module
94 */
95 AribaModule();
96
97 /**
98 * Destructor of the ariba underlay module
99 */
100 virtual ~AribaModule();
101
102 /**
103 * Returns all known bootstrap endpoints to this ariba module in
104 * a human-readable string. This information can be used by other
105 * nodes for bootstraping. It may also be used to publish this info
106 * to other nodes via the web, for example.
107 *
108 * @param The name of the spovnet
109 * @return A human-readable string containing all known bootstrap
110 * information known to this module.
111 */
112 string getBootstrapHints(const Name& spoVNetName = Name::UNSPECIFIED) const;
113
114 /**
115 * Adds bootstrap hints to the local database. The format of the string
116 * must is the same as returned by <code>getBootstrapInfo</code>.
117 *
118 * @param bootinfo A string containing bootstrap information.
119 */
120 void addBootstrapHints(string bootinfo);
121
122 /**
123 * Register a sideport for sniffing on communication events
124 * and get advanced information. The sniffer is attached to
125 * every node that is created on the module. Only one such
126 * sniffer can be active system-wide, a new call to this
127 * register function will only attach the sniffer to nodes
128 * created after the registration call.
129 *
130 * @param sideport The SideportListener to integrate
131 */
132 void registerSideportListener(SideportListener* sideport);
133
134 // --- module implementation ---
135
136 /**
137 * Module Property information:
138 *
139 * ip.addr = preferred ip address (otherwise bind to all)
140 * tcp.port = preferred tcp port (or use default value)
141 * udp.port = preferred udp port (or use default value)
142 * bootstrap.hints = used bootstrap hints
143 * bootstrap.file = used file for bootstrap information
144 */
145 void initialize(); ///< @see Module.h
146 void start(); ///< @see Module.h
147 void stop(); ///< @see Module.h
148 string getName() const; ///< @see Module.h
149 void setProperty(string key, string value); ///< @see Module.h
150 const string getProperty(string key) const; ///< @see Module.h
151 const vector<string> getProperties() const; ///< @see Module.h
152
153 /**
154 * Get the local endpoint information
155 */
156 const string getLocalEndpoints();
157
158private:
159
160 /**
161 * Available bootstrap mechanisms
162 */
163 enum BootstrapMechanism {
164 BootstrapMechanismInvalid = 0,
165 BootstrapMechanismStatic = 1,
166 BootstrapMechanismBroadcast = 2,
167 BootstrapMechanismMulticastDNS = 3,
168 BootstrapMechanismSDP = 4,
169 };
170 static const string BootstrapMechanismNames[5];
171
172 /**
173 * bootstrap node information
174 */
175 class BootstrapNode {
176 public:
177 inline BootstrapNode() :
178 timestamp(0), desc(NULL), mechanism(BootstrapMechanismInvalid), info("") {
179
180 }
181 inline BootstrapNode(const BootstrapNode& copy) :
182 timestamp(copy.timestamp), desc(copy.desc), mechanism(copy.mechanism), info(copy.info) {
183 }
184 inline BootstrapNode(
185 uint32_t timestamp,
186 communication::EndpointDescriptor* desc,
187 BootstrapMechanism mechanism, string info) :
188 timestamp(timestamp), desc(desc), mechanism(mechanism), info(info) {
189 }
190 uint32_t timestamp;
191 communication::EndpointDescriptor* desc;
192 BootstrapMechanism mechanism;
193 string info;
194 };
195
196 /*
197 * bootstrap info, all bootstrap nodes
198 * for a specific spovnet
199 */
200 class BootstrapInfo {
201 public:
202 BootstrapInfo() :
203 spovnetName(), nodes() {
204 }
205
206 BootstrapInfo(const BootstrapInfo& copy) :
207 spovnetName(copy.spovnetName), nodes(copy.nodes) {
208 }
209
210 Name spovnetName;
211 vector<BootstrapNode> nodes;
212 };
213
214 vector<BootstrapInfo> bootstrapNodes; //< all available bootstrap information
215
216protected:
217 // members
218 string endpoints; //< local endpoints the ariba module is bound to
219 bool started; //< flag, if module has been started
220
221 /**
222 * bootstrap node management
223 * add a bootstrap node
224 */
225 void addBootstrapNode(
226 const Name& spovnet,
227 communication::EndpointDescriptor* desc,
228 const string& info,
229 const BootstrapMechanism& mechanism
230 );
231
232 /**
233 * bootstrap node management
234 * add a bootstrap node
235 */
236 void addBootstrapNode(
237 const Name& spovnet,
238 const BootstrapNode& node
239 );
240
241 /**
242 * bootstrap node management
243 * get all available bootstrap mechanisms
244 * where bootstrap nodes are available for
245 */
246 vector<AribaModule::BootstrapMechanism> getBootstrapMechanisms(
247 const Name& spovnet
248 ) const;
249
250 /**
251 * get a endpoint descriptor for a spovnet
252 * using a specific bootstrap mechanisms.
253 * will currently only work with static
254 */
255 const communication::EndpointDescriptor* getBootstrapNode(
256 const Name& spovnet,
257 const BootstrapMechanism mechanism
258 ) const;
259
260 /**
261 * get the info field associated for a given
262 * spovnet through a given mechanism
263 */
264 string getBootstrapInfo(
265 const Name& spovnet,
266 const BootstrapMechanism mechanism
267 ) const;
268
269 communication::BaseCommunication* base_comm; //< the base communication
270 SideportListener* sideport_sniffer; //< the sideport listener
271};
272
273} // namespace ariba
274
275/** @} */
276
277#endif /* ENVIRONMENT_H_ */
Note: See TracBrowser for help on using the repository browser.