source: source/ariba/AribaModule.h@ 4620

Last change on this file since 4620 was 4065, checked in by Christoph Mayer, 15 years ago

include verschoben

File size: 6.1 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
45using std::vector;
46using std::string;
47
48// forward declaration
49namespace ariba {
50 class AribaModule;
51 class SideportListener;
52}
53
54// local includes
55#include "Name.h"
56#include "Module.h"
57
58namespace ariba {
59
60namespace communication {
61class EndpointDescriptor;
62class NetworkLocator;
63}
64namespace communication {
65class BaseCommunication;
66}
67
68/**
69 * This class implements a container class for ariba base services. Each node
70 * is a running using this base-module. It also manages Bootstrap information
71 * in a abstract simple way.
72 *
73 * +---+ +---+
74 * |N1 | |N2 |
75 * +--| |---| |--+
76 * | +---+ +---+ |
77 * | |
78 * | AribaModule |
79 * +-----------------+
80 *
81 * N1, N2 are nodes.
82 *
83 * @author Sebastian Mies <mies@tm.uka.de>
84 * @author Christoph Mayer <mayer@tm.uka.de>
85 */
86class AribaModule: public Module {
87 friend class Node;
88public:
89 /**
90 * Constructor of the ariba underlay module
91 */
92 AribaModule();
93
94 /**
95 * Destructor of the ariba underlay module
96 */
97 virtual ~AribaModule();
98
99 /**
100 * Returns all known bootstrap endpoints to this ariba module in
101 * a human-readable string. This information can be used by other
102 * nodes for bootstraping. It may also be used to publish this info
103 * to other nodes via the web, for example.
104 *
105 * @param The name of the spovnet
106 * @return A human-readable string containing all known bootstrap
107 * information known to this module.
108 */
109 string getBootstrapHints(const Name& spoVNetName = Name::UNSPECIFIED) const;
110
111 /**
112 * Adds bootstrap hints to the local database. The format of the string
113 * must is the same as returned by <code>getBootstrapInfo</code>.
114 *
115 * @param bootinfo A string containing bootstrap information.
116 */
117 void addBootstrapHints(string bootinfo);
118
119 /**
120 * Register a sideport for sniffing on communication events
121 * and get advanced information. The sniffer is attached to
122 * every node that is created on the module. Only one such
123 * sniffer can be active system-wide, a new call to this
124 * register function will only attach the sniffer to nodes
125 * created after the registration call.
126 *
127 * @param sideport The SideportListener to integrate
128 */
129 void registerSideportListener(SideportListener* sideport);
130
131 // --- module implementation ---
132
133 /**
134 * Module Property information:
135 *
136 * ip.addr = preferred ip address (otherwise bind to all)
137 * tcp.port = preferred tcp port (or use default value)
138 * udp.port = preferred udp port (or use default value)
139 * bootstrap.hints = used bootstrap hints
140 * bootstrap.file = used file for bootstrap information
141 */
142 void initialize(); ///< @see Module.h
143 void start(); ///< @see Module.h
144 void stop(); ///< @see Module.h
145 string getName() const; ///< @see Module.h
146 void setProperty(string key, string value); ///< @see Module.h
147 const string getProperty(string key) const; ///< @see Module.h
148 const vector<string> getProperties() const; ///< @see Module.h
149
150private:
151 // bootstrap node
152 class BootstrapNode {
153 public:
154 inline BootstrapNode() :
155 timestamp(0), desc(NULL) {
156
157 }
158 inline BootstrapNode(const BootstrapNode& copy) :
159 timestamp(copy.timestamp), desc(copy.desc) {
160 }
161 inline BootstrapNode(uint32_t timestamp,
162 communication::EndpointDescriptor* desc) :
163 timestamp(timestamp), desc(desc) {
164 }
165 uint32_t timestamp;
166 communication::EndpointDescriptor* desc;
167 };
168
169 // bootstrap info
170 class BootstrapInfo {
171 public:
172 BootstrapInfo() :
173 spovnetName(), nodes() {
174 }
175
176 BootstrapInfo(const BootstrapInfo& copy) :
177 spovnetName(copy.spovnetName), nodes(copy.nodes) {
178 }
179
180 Name spovnetName;
181 vector<BootstrapNode> nodes;
182 };
183 vector<BootstrapInfo> bootstrapNodes;
184
185protected:
186 // members
187 string bootstrapFile; //< file with bootstrap information
188 bool started; //< flag, if module has been started
189
190 // bootstrap node management
191 void addBootstrapNode(const Name& spovnet,
192 communication::EndpointDescriptor* desc);
193 const communication::EndpointDescriptor* getBootstrapNode(
194 const Name& spovnet) const;
195
196 communication::BaseCommunication* base_comm;
197 SideportListener* sideport_sniffer;
198
199 // TODO: use "abstract" representations here!
200 communication::NetworkLocator* ip_addr;
201 uint16_t tcp_port, udp_port;
202};
203
204} // namespace ariba
205
206#endif /* ENVIRONMENT_H_ */
Note: See TracBrowser for help on using the repository browser.