00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef ARIBAMODULE_H_
00040 #define ARIBAMODULE_H_
00041
00042 #include <string>
00043 #include <vector>
00044 #include <ctime>
00045 #include <cstdlib>
00046 #include <algorithm>
00047
00048 using std::vector;
00049 using std::string;
00050
00051
00052 namespace ariba {
00053 class AribaModule;
00054 class SideportListener;
00055 }
00056
00057
00058 #include "Name.h"
00059 #include "Module.h"
00060
00061 namespace ariba {
00062
00063
00064 namespace communication {
00065 class EndpointDescriptor;
00066 class BaseCommunication;
00067 }
00068
00087 class AribaModule: public Module {
00088 friend class Node;
00089 use_logging_h(AribaModule);
00090 public:
00094 AribaModule();
00095
00099 virtual ~AribaModule();
00100
00111 string getBootstrapHints(const Name& spoVNetName = Name::UNSPECIFIED) const;
00112
00119 void addBootstrapHints(string bootinfo);
00120
00131 void registerSideportListener(SideportListener* sideport);
00132
00133
00134
00144 void initialize();
00145 void start();
00146 void stop();
00147 string getName() const;
00148 void setProperty(string key, string value);
00149 const string getProperty(string key) const;
00150 const vector<string> getProperties() const;
00151
00155 const string getLocalEndpoints();
00156
00157 private:
00158
00162 enum BootstrapMechanism {
00163 BootstrapMechanismInvalid = 0,
00164 BootstrapMechanismStatic = 1,
00165 BootstrapMechanismBroadcast = 2,
00166 BootstrapMechanismMulticastDNS = 3,
00167 BootstrapMechanismSDP = 4,
00168 };
00169 static const string BootstrapMechanismNames[5];
00170
00174 class BootstrapNode {
00175 public:
00176 inline BootstrapNode() :
00177 timestamp(0), desc(NULL), mechanism(BootstrapMechanismInvalid), info("") {
00178
00179 }
00180 inline BootstrapNode(const BootstrapNode& copy) :
00181 timestamp(copy.timestamp), desc(copy.desc), mechanism(copy.mechanism), info(copy.info) {
00182 }
00183 inline BootstrapNode(
00184 uint32_t timestamp,
00185 communication::EndpointDescriptor* desc,
00186 BootstrapMechanism mechanism, string info) :
00187 timestamp(timestamp), desc(desc), mechanism(mechanism), info(info) {
00188 }
00189 uint32_t timestamp;
00190 communication::EndpointDescriptor* desc;
00191 BootstrapMechanism mechanism;
00192 string info;
00193 };
00194
00195
00196
00197
00198
00199 class BootstrapInfo {
00200 public:
00201 BootstrapInfo() :
00202 spovnetName(), nodes() {
00203 }
00204
00205 BootstrapInfo(const BootstrapInfo& copy) :
00206 spovnetName(copy.spovnetName), nodes(copy.nodes) {
00207 }
00208
00209 Name spovnetName;
00210 vector<BootstrapNode> nodes;
00211 };
00212
00213 vector<BootstrapInfo> bootstrapNodes;
00214
00215 protected:
00216
00217 string endpoints;
00218 bool started;
00219
00224 void addBootstrapNode(
00225 const Name& spovnet,
00226 communication::EndpointDescriptor* desc,
00227 const string& info,
00228 const BootstrapMechanism& mechanism
00229 );
00230
00235 void addBootstrapNode(
00236 const Name& spovnet,
00237 const BootstrapNode& node
00238 );
00239
00245 vector<AribaModule::BootstrapMechanism> getBootstrapMechanisms(
00246 const Name& spovnet
00247 ) const;
00248
00254 const communication::EndpointDescriptor* getBootstrapNode(
00255 const Name& spovnet,
00256 const BootstrapMechanism mechanism
00257 ) const;
00258
00263 string getBootstrapInfo(
00264 const Name& spovnet,
00265 const BootstrapMechanism mechanism
00266 ) const;
00267
00268 communication::BaseCommunication* base_comm;
00269 SideportListener* sideport_sniffer;
00270 };
00271
00272 }
00273
00274 #endif