| 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
|
---|
| 47 | using std::vector;
|
---|
| 48 | using std::string;
|
---|
| 49 |
|
---|
| 50 | // forward declaration
|
---|
| 51 | namespace ariba {
|
---|
| 52 | class AribaModule;
|
---|
| 53 | }
|
---|
| 54 |
|
---|
| 55 | // local includes
|
---|
| 56 | #include "Name.h"
|
---|
| 57 | #include "Module.h"
|
---|
| 58 |
|
---|
| 59 | namespace ariba {
|
---|
| 60 |
|
---|
| 61 | // forward declarations of old interface
|
---|
| 62 | namespace communication {
|
---|
| 63 | class EndpointDescriptor;
|
---|
| 64 | class NetworkLocator;
|
---|
| 65 | }
|
---|
| 66 | namespace interface {
|
---|
| 67 | class UnderlayAbstraction;
|
---|
| 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 | */
|
---|
| 87 | class AribaModule: public Module {
|
---|
| 88 | friend class Node;
|
---|
| 89 | public:
|
---|
| 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 | // --- module implementation ---
|
---|
| 121 |
|
---|
| 122 | /**
|
---|
| 123 | * Module Property information:
|
---|
| 124 | *
|
---|
| 125 | * ip.addr = preferred ip address (otherwise bind to all)
|
---|
| 126 | * tcp.port = preferred tcp port (or use default value)
|
---|
| 127 | * udp.port = preferred udp port (or use default value)
|
---|
| 128 | * bootstrap.hints = used bootstrap hints
|
---|
| 129 | * bootstrap.file = used file for bootstrap information
|
---|
| 130 | */
|
---|
| 131 | void initialize(); ///< @see Module.h
|
---|
| 132 | void start(); ///< @see Module.h
|
---|
| 133 | void stop(); ///< @see Module.h
|
---|
| 134 | string getName() const; ///< @see Module.h
|
---|
| 135 | void setProperty(string key, string value); ///< @see Module.h
|
---|
| 136 | const string getProperty(string key) const; ///< @see Module.h
|
---|
| 137 | const vector<string> getProperties() const; ///< @see Module.h
|
---|
| 138 |
|
---|
| 139 | private:
|
---|
| 140 | // bootstrap node
|
---|
| 141 | class BootstrapNode {
|
---|
| 142 | public:
|
---|
| 143 | uint32_t timestamp;
|
---|
| 144 | communication::EndpointDescriptor* desc;
|
---|
| 145 | };
|
---|
| 146 |
|
---|
| 147 | // bootstrap info
|
---|
| 148 | class BootstrapInfo {
|
---|
| 149 | public:
|
---|
| 150 | Name spovnetName;
|
---|
| 151 | vector<BootstrapNode> desc;
|
---|
| 152 | };
|
---|
| 153 | vector<BootstrapInfo> bootstrapNodes;
|
---|
| 154 |
|
---|
| 155 | protected:
|
---|
| 156 | // members
|
---|
| 157 | string bootstrapFile; //< file with bootstrap information
|
---|
| 158 | bool started; //< flag, if module has been started
|
---|
| 159 |
|
---|
| 160 | // bootstrap node management
|
---|
| 161 | void addBootstrapNode(const Name& spovnet, const Name& node,
|
---|
| 162 | communication::EndpointDescriptor* desc);
|
---|
| 163 | const communication::EndpointDescriptor* getBootstrapNode(
|
---|
| 164 | const Name& spovnet);
|
---|
| 165 |
|
---|
| 166 | // TODO: merge with old interface
|
---|
| 167 | interface::UnderlayAbstraction* underlay_abs;
|
---|
| 168 |
|
---|
| 169 | // TODO: use "abstract" representations here!
|
---|
| 170 | communication::NetworkLocator* ip_addr;
|
---|
| 171 | uint16_t tcp_port, udp_port;
|
---|
| 172 | };
|
---|
| 173 |
|
---|
| 174 | } // namespace ariba
|
---|
| 175 |
|
---|
| 176 | #endif /* ENVIRONMENT_H_ */
|
---|