source: source/ariba/AribaModule.h@ 3055

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

-temporärer commit, sorry kompiliert nicht :( muss aber die änderungen auf die andere maschine kriegen, ist in ca1h gefixt.

File size: 5.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 <boost/foreach.hpp>
45
46// usings
47using std::vector;
48using std::string;
49
50// forward declaration
51namespace ariba {
52class AribaModule;
53}
54
55// local includes
56#include "Name.h"
57#include "Module.h"
58
59namespace ariba {
60
61// forward declarations of old interface
62namespace communication {
63class EndpointDescriptor;
64class NetworkLocator;
65}
66namespace communication {
67class BaseCommunication;
68}
69
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;
90public:
91 /**
92 * Constructor of the ariba underlay module
93 */
94 AribaModule();
95
96 /**
97 * Destructor of the ariba underlay module
98 */
99 virtual ~AribaModule();
100
101 /**
102 * Returns all known bootstrap endpoints to this ariba module in
103 * a human-readable string. This information can be used by other
104 * nodes for bootstraping. It may also be used to publish this info
105 * to other nodes via the web, for example.
106 *
107 * @param The name of the spovnet
108 * @return A human-readable string containing all known bootstrap
109 * information known to this module.
110 */
111 string getBootstrapHints(const Name& spoVNetName = Name::UNSPECIFIED) const;
112
113 /**
114 * Adds bootstrap hints to the local database. The format of the string
115 * must is the same as returned by <code>getBootstrapInfo</code>.
116 *
117 * @param bootinfo A string containing bootstrap information.
118 */
119 void addBootstrapHints(string bootinfo);
120
121 // --- module implementation ---
122
123 /**
124 * Module Property information:
125 *
126 * ip.addr = preferred ip address (otherwise bind to all)
127 * tcp.port = preferred tcp port (or use default value)
128 * udp.port = preferred udp port (or use default value)
129 * bootstrap.hints = used bootstrap hints
130 * bootstrap.file = used file for bootstrap information
131 */
132 void initialize(); ///< @see Module.h
133 void start(); ///< @see Module.h
134 void stop(); ///< @see Module.h
135 string getName() const; ///< @see Module.h
136 void setProperty(string key, string value); ///< @see Module.h
137 const string getProperty(string key) const; ///< @see Module.h
138 const vector<string> getProperties() const; ///< @see Module.h
139
140private:
141 // bootstrap node
142 class BootstrapNode {
143 public:
144 inline BootstrapNode() :
145 timestamp(0), desc(NULL) {
146
147 }
148 inline BootstrapNode(const BootstrapNode& copy) :
149 timestamp(copy.timestamp), desc(copy.desc) {
150 }
151 inline BootstrapNode(uint32_t timestamp,
152 communication::EndpointDescriptor* desc) :
153 timestamp(timestamp), desc(desc) {
154 }
155 uint32_t timestamp;
156 communication::EndpointDescriptor* desc;
157 };
158
159 // bootstrap info
160 class BootstrapInfo {
161 public:
162 BootstrapInfo() :
163 spovnetName(), nodes() {
164 }
165
166 BootstrapInfo(const BootstrapInfo& copy) :
167 spovnetName(copy.spovnetName), nodes(copy.nodes) {
168 }
169
170 Name spovnetName;
171 vector<BootstrapNode> nodes;
172 };
173 vector<BootstrapInfo> bootstrapNodes;
174
175protected:
176 // members
177 string bootstrapFile; //< file with bootstrap information
178 bool started; //< flag, if module has been started
179
180 // bootstrap node management
181 void addBootstrapNode(const Name& spovnet,
182 communication::EndpointDescriptor* desc);
183 const communication::EndpointDescriptor* getBootstrapNode(
184 const Name& spovnet) const;
185
186 communication::BaseCommunication* base_comm;
187
188 // TODO: use "abstract" representations here!
189 communication::NetworkLocator* ip_addr;
190 uint16_t tcp_port, udp_port;
191};
192
193} // namespace ariba
194
195#endif /* ENVIRONMENT_H_ */
Note: See TracBrowser for help on using the repository browser.