source: source/ariba/AribaModule.h@ 5308

Last change on this file since 5308 was 5284, checked in by mies, 15 years ago

+ added new transport modules and adapted ariba to them
+ exchange endpoint descriptors an link establishment
+ clean up of base communication
+ link establishment with in the presence of multiple endpoints
+ local discovery for ipv6, ipv4 and bluetooth mac addresses

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